List of usage examples for java.awt Font Font
private Font(String name, int style, float sizePts)
From source file:be.ac.ua.comp.scarletnebula.gui.BareGraph.java
/** * @see Graph/*from w ww . ja v a 2s . co m*/ */ @Override public ChartPanel getChartPanel() { final XYPlot plot = new XYPlot(dataset, domain, range, renderer); plot.setBackgroundPaint(Color.darkGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setInsets(new RectangleInsets(0, 0, 0, 0)); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinesVisible(true); final JFreeChart chart = new JFreeChart(null, new Font("SansSerif", Font.BOLD, 24), plot, true); chart.setBackgroundPaint(Color.white); chart.removeLegend(); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); return chartPanel; }
From source file:org.jfree.chart.demo.XYAreaChartDemo1.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createXYAreaChart("XY Area Chart Demo", "Domain (X)", "Range (Y)", xydataset, PlotOrientation.VERTICAL, true, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setForegroundAlpha(0.65F);//from w w w.ja v a 2s. c o m xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); ValueAxis valueaxis = xyplot.getDomainAxis(); valueaxis.setTickMarkPaint(Color.black); valueaxis.setLowerMargin(0.0D); valueaxis.setUpperMargin(0.0D); ValueAxis valueaxis1 = xyplot.getRangeAxis(); valueaxis1.setTickMarkPaint(Color.black); XYPointerAnnotation xypointerannotation = new XYPointerAnnotation("Test", 5D, -500D, 2.3561944901923448D); xypointerannotation.setTipRadius(0.0D); xypointerannotation.setBaseRadius(35D); xypointerannotation.setFont(new Font("SansSerif", 0, 9)); xypointerannotation.setPaint(Color.blue); xypointerannotation.setTextAnchor(TextAnchor.HALF_ASCENT_RIGHT); xyplot.addAnnotation(xypointerannotation); return jfreechart; }
From source file:com.yanbang.portal.controller.PortalController.java
/** * ???// ww w . ja va2s. c om * * @param request * @param response * @return * @throws Exception */ @RequestMapping(params = "action=handleRnd") public void handleRnd(HttpServletRequest request, HttpServletResponse response) throws Exception { response.setHeader("Cache-Control", "no-store"); response.setHeader("Pragma", "no-cache"); response.setDateHeader("Expires", 0L); response.setContentType("image/jpeg"); BufferedImage image = new BufferedImage(65, 25, BufferedImage.TYPE_INT_RGB); Graphics g = image.getGraphics(); g.setColor(Color.GRAY); g.fillRect(0, 0, 65, 25); g.setColor(Color.yellow); Font font = new Font("", Font.BOLD, 20); g.setFont(font); Random r = new Random(); String rnd = ""; int ir = r.nextInt(10); rnd = rnd + "" + ir; g.drawString("" + ir, 5, 18); g.setColor(Color.red); ir = r.nextInt(10); rnd = rnd + "" + ir; g.drawString("" + ir, 20, 18); g.setColor(Color.blue); ir = r.nextInt(10); rnd = rnd + "" + ir; g.drawString("" + ir, 35, 18); g.setColor(Color.green); ir = r.nextInt(10); rnd = rnd + "" + ir; g.drawString("" + ir, 50, 18); request.getSession().setAttribute("RND", rnd); ServletOutputStream out = response.getOutputStream(); out.write(ImageUtil.imageToBytes(image, "gif")); out.flush(); out.close(); }
From source file:mediamatrix.gui.JVMMemoryProfilerPanel.java
public JVMMemoryProfilerPanel() { initComponents();//from w w w. j ava 2 s . co m profiler = new JVMMemoryProfiler(frequency); profiler.addListener(new JVMMemoryProfilerListener() { @Override public void addScore(long t, long f) { total.add(new Millisecond(), t); free.add(new Millisecond(), f); } }); total = new TimeSeries("Total Memory"); total.setMaximumItemCount(historyCount); free = new TimeSeries("Free Memory"); free.setMaximumItemCount(historyCount); final TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(total); dataset.addSeries(free); final DateAxis domain = new DateAxis("Time"); final NumberAxis range = new NumberAxis("Memory"); domain.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12)); domain.setLabelFont(new Font("SansSerif", Font.PLAIN, 14)); range.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12)); range.setLabelFont(new Font("SansSerif", Font.PLAIN, 14)); range.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); final XYItemRenderer renderer = new DefaultXYItemRenderer(); renderer.setSeriesPaint(0, Color.red); renderer.setSeriesPaint(1, Color.green); renderer.setBaseStroke(new BasicStroke(3f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); final XYPlot plot = new XYPlot(dataset, domain, range, renderer); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); domain.setAutoRange(true); domain.setLowerMargin(0.0); domain.setUpperMargin(0.0); domain.setTickLabelsVisible(true); final JFreeChart chart = new JFreeChart("JVM Memory Usage", new Font("SansSerif", Font.BOLD, 24), plot, true); chart.setBackgroundPaint(Color.white); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4), BorderFactory.createLineBorder(Color.black))); chart.getLegend().setItemFont(new Font("SansSerif", Font.PLAIN, 12)); add(chartPanel, BorderLayout.CENTER); }
From source file:org.epsilonlabs.workflow.execution.example.GraphOutput.java
public GraphOutput(String appname, String graphname, String x, String y) { super(appname); barChart = ChartFactory.createBarChart(graphname, x, y, dataset, PlotOrientation.VERTICAL, false, true, false);//from w w w .jav a2 s .c om ChartPanel chartPanel = new ChartPanel(barChart); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); int width = new Double(screenSize.getWidth()).intValue() - 100; chartPanel.setMaximumDrawHeight(500); chartPanel.setMaximumDrawWidth(width); chartPanel.setPreferredSize(new java.awt.Dimension(width, 500)); setContentPane(chartPanel); Font font = new Font("Dialog", Font.PLAIN, 15); barChart.getCategoryPlot().getDomainAxis().setTickLabelFont(font); barChart.getCategoryPlot().setColumnRenderingOrder(SortOrder.DESCENDING); }
From source file:com.antelink.sourcesquare.gui.view.CopyrightPanel.java
public CopyrightPanel() { super();/* w w w . jav a 2 s. c o m*/ ArrayList<JLabel> sentence = new ArrayList<JLabel>(); sentence.add(new JLabel("Powered by")); sentence.add(createJLabelWithHyperlink("Antepedia", "http://www.antepedia.com")); sentence.add(new JLabel(", an ")); sentence.add(createJLabelWithHyperlink("Antelink", "http://www.antelink.com")); sentence.add(new JLabel(" product - ")); sentence.add( createJLabelWithHyperlink("About SourceSquare", "https://sourcesquare.antepedia.com/about.html")); setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5)); for (JLabel jLabel : sentence) { jLabel.setFont(new Font("Lucida Grande", Font.PLAIN, 11)); this.add(jLabel); } this.setSize(360, 25); }
From source file:agentlogfileanalyzer.gui.ComparisonFrame.java
/** * Creates a chart frame for comparing a selected classifier to a set of * other classifiers.//from w w w .j av a2 s . c o m * * @param firstTitle * the first line of the chart title * @param secondTitle * the second line of the chart title * @param compDataForColumns * the data the will be displayed in the chart */ public ComparisonFrame(String firstTitle, String secondTitle, Vector<ComparisonDataSet> compDataForColumns) { super("Classifier comparison"); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); for (int i = 0; i < compDataForColumns.size(); i++) { ComparisonDataSet mms = compDataForColumns.get(i); dataset.addValue(mms.getMax(), "max", mms.getColumnName()); dataset.addValue(mms.getMin(), "min", mms.getColumnName()); dataset.addValue(mms.getSelected(), "selected", mms.getColumnName()); } JFreeChart jfreechart = ChartFactory.createBarChart("", // title "", // x-axis title "", // y-axis title dataset, PlotOrientation.VERTICAL, true, true, false); TextTitle subtitle1 = new TextTitle(firstTitle, new Font("SansSerif", Font.BOLD, 12)); TextTitle subtitle2 = new TextTitle(secondTitle, new Font("SansSerif", Font.BOLD, 12)); jfreechart.addSubtitle(0, subtitle1); jfreechart.addSubtitle(1, subtitle2); jfreechart.setBackgroundPaint(Color.white); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setBackgroundPaint(Color.lightGray); categoryplot.setRangeGridlinePaint(Color.white); MinMaxCategoryRenderer minmaxcategoryrenderer = new MinMaxCategoryRenderer(); categoryplot.setRenderer(minmaxcategoryrenderer); ChartPanel chartpanel = new ChartPanel(jfreechart); chartpanel.setPreferredSize(new Dimension(500, 270)); setContentPane(chartpanel); }
From source file:PaginationExample.java
public int print(Graphics g, PageFormat pf, int pageIndex) throws PrinterException { Font font = new Font("Serif", Font.PLAIN, 10); FontMetrics metrics = g.getFontMetrics(font); int lineHeight = metrics.getHeight(); if (pageBreaks == null) { initTextLines();/*from w w w .j a v a2s. c o m*/ int linesPerPage = (int) (pf.getImageableHeight() / lineHeight); int numBreaks = (textLines.length - 1) / linesPerPage; pageBreaks = new int[numBreaks]; for (int b = 0; b < numBreaks; b++) { pageBreaks[b] = (b + 1) * linesPerPage; } } if (pageIndex > pageBreaks.length) { return NO_SUCH_PAGE; } /* * User (0,0) is typically outside the imageable area, so we must translate * by the X and Y values in the PageFormat to avoid clipping Since we are * drawing text we */ Graphics2D g2d = (Graphics2D) g; g2d.translate(pf.getImageableX(), pf.getImageableY()); /* * Draw each line that is on this page. Increment 'y' position by lineHeight * for each line. */ int y = 0; int start = (pageIndex == 0) ? 0 : pageBreaks[pageIndex - 1]; int end = (pageIndex == pageBreaks.length) ? textLines.length : pageBreaks[pageIndex]; for (int line = start; line < end; line++) { y += lineHeight; g.drawString(textLines[line], 0, y); } /* tell the caller that this page is part of the printed document */ return PAGE_EXISTS; }
From source file:com.diversityarrays.kdxplore.KDXplore.java
static public void setUIfontSize(float multiplier) { UIDefaults defaults = UIManager.getDefaults(); for (Enumeration<?> e = defaults.keys(); e.hasMoreElements();) { Object key = e.nextElement(); Object value = defaults.get(key); if (value instanceof Font) { Font font = (Font) value; int newSize = Math.round(font.getSize() * multiplier); if (value instanceof FontUIResource) { defaults.put(key, new FontUIResource(font.getName(), font.getStyle(), newSize)); } else { defaults.put(key, new Font(font.getName(), font.getStyle(), newSize)); }//from w ww .ja v a2 s . c o m } else if (value instanceof Integer) { if ("Tree.rowHeight".equals(key)) { //$NON-NLS-1$ // System.out.println(key+": "+value); Integer rh = (Integer) value; rh = (int) (rh * multiplier * 1.4); defaults.put(key, rh); } } } }
From source file:it.alus.GPSreceiver.instruments.Altimeter.java
public Altimeter(float groundAltitudeFt) { super(null);/*from w ww.j a va 2 s . c o m*/ altitude = 0; if (groundAltitudeFt < 0) groundAltitude = 0; else groundAltitude = groundAltitudeFt; hoursDataset = new DefaultValueDataset(0.0); minutesDataset = new DefaultValueDataset(0.0); DialPlot plot = new DialPlot(); plot.setView(0.0, 0.0, 1.0, 1.0); Image background = Toolkit.getDefaultToolkit().getImage(getClass().getResource("altimeter.png")); plot.setDataset(0, hoursDataset); plot.setDataset(1, minutesDataset); StandardDialFrame dialFrame = new StandardDialFrame(); dialFrame.setBackgroundPaint(Color.lightGray); dialFrame.setForegroundPaint(Color.gray); DialTextAnnotation annotation = new DialTextAnnotation("Feet"); annotation.setFont(new Font("Arial", 1, 14)); annotation.setRadius(0.4D); annotation.setPaint(Color.lightGray); plot.addLayer(annotation); DialValueIndicator valueindicator = new DialValueIndicator(0); NumberFormat formatter = new DecimalFormat("#"); plot.addLayer(valueindicator); plot.setDialFrame(dialFrame); StandardDialScale scale = new StandardDialScale(0, 10, 90, -360, 1, 10); scale.setMajorTickPaint(Color.white); scale.setMinorTickPaint(Color.lightGray); scale.setFirstTickLabelVisible(false); scale.setTickRadius(0.88); scale.setTickLabelOffset(0.15); scale.setTickLabelFormatter(formatter); scale.setTickLabelFont(new Font("Arial", Font.BOLD, 24)); scale.setTickLabelPaint(Color.white); plot.addScale(3, scale); plot.setBackground(new DialBackground(Color.black)); StandardDialScale hourScale = new StandardDialScale(0, 10000, 90, -360, 1000, 10); hourScale.setVisible(false); hourScale.setTickRadius(0.88); hourScale.setTickLabelOffset(0.15); plot.addScale(0, hourScale); StandardDialScale minScale = new StandardDialScale(0, 1000, 90, -360, 0, 0); minScale.setVisible(false); minScale.setMajorTickIncrement(5.0); minScale.setTickRadius(0.68); plot.addScale(1, minScale); Pointer hourNeedle = new Pointer(0); hourNeedle.setRadius(0.55); hourNeedle.setFillPaint(Color.lightGray); plot.addLayer(hourNeedle); plot.mapDatasetToScale(1, 1); Pointer minNeedle = new Pointer(1); minNeedle.setFillPaint(Color.white); plot.addLayer(minNeedle); DialCap cap = new DialCap(); cap.setRadius(0.10); cap.setFillPaint(Color.lightGray); plot.setCap(cap); jChart = new JFreeChart(plot); jChart.setBackgroundImage(background); super.setChart(jChart); super.setPreferredSize(new Dimension(400, 400)); }