List of usage examples for java.awt Font PLAIN
int PLAIN
To view the source code for java.awt Font PLAIN.
Click Source Link
From source file:st.jigasoft.dbutil.util.ReportTheme.java
public static void circularTheme(JFreeChart chart, String... colunsName) { chart.setBackgroundPaint(//from w ww . j av a 2 s . co m new GradientPaint(new Point(0, 0), new Color(20, 20, 20), new Point(400, 200), Color.DARK_GRAY)); TextTitle t = chart.getTitle(); t.setHorizontalAlignment(HorizontalAlignment.LEFT); t.setPaint(new Color(240, 240, 240)); t.setFont(new Font("Arial", Font.BOLD, 26)); PiePlot plot = (PiePlot) chart.getPlot(); plot.setBackgroundPaint(null); plot.setInteriorGap(0.04); plot.setOutlineVisible(false); int iCount = 0; // use gradients and white borders for the section colours for (Object s : colunsName) { plot.setSectionPaint(s.toString(), createGradientPaint(new Color(200, 200, 255), colorItems(iCount++))); if (iCount == MAX_COLUNS_COLOR) iCount = 0; } plot.setBaseSectionOutlinePaint(Color.WHITE); plot.setSectionOutlinesVisible(true); plot.setBaseSectionOutlineStroke(new BasicStroke(2.0f)); plot.setLabelFont(new Font("Courier New", Font.BOLD, 20)); plot.setLabelLinkPaint(Color.WHITE); plot.setLabelLinkStroke(new BasicStroke(2.0f)); plot.setLabelOutlineStroke(null); plot.setLabelPaint(Color.WHITE); plot.setLabelBackgroundPaint(null); // // add a subtitle giving the data source TextTitle source = new TextTitle("Source: http://www.bbc.co.uk/news/business-15489523", new Font("Courier New", Font.PLAIN, 12)); source.setPaint(Color.WHITE); source.setPosition(RectangleEdge.BOTTOM); source.setHorizontalAlignment(HorizontalAlignment.RIGHT); chart.addSubtitle(source); }
From source file:com.ouc.cpss.view.SupTradeChartBuilder.java
private static JFreeChart createJFreeChart(PieDataset dataset) { /**/*from w w w . j a v a 2s . com*/ * JFreeChart */ //? StandardChartTheme standardChartTheme = new StandardChartTheme("CN"); // standardChartTheme.setExtraLargeFont(new Font("", Font.BOLD, 20)); // standardChartTheme.setRegularFont(new Font("", Font.PLAIN, 15)); //? standardChartTheme.setLargeFont(new Font("", Font.PLAIN, 15)); //? ChartFactory.setChartTheme(standardChartTheme); //?? //createPieChart 2D; createPieChart3D 3D JFreeChart chart = ChartFactory.createPieChart("", dataset, true, true, false); //,? chart.setTitle(new TextTitle("", new Font("", Font.ITALIC, 22))); //? LegendTitle legend = chart.getLegend(0); //,ture,? legend.setItemFont(new Font("", Font.BOLD, 20)); //?(??) PiePlot plot = (PiePlot) chart.getPlot(); //?==? plot.setLabelFont(new Font("", Font.BOLD, 22)); // plot.setBaseSectionOutlinePaint(Color.BLUE); // plot.setBaseSectionOutlineStroke(new BasicStroke(0.5f)); //?,??,?? plot.setDirection(Rotation.CLOCKWISE);//,Rotation.CLOCKWISE //() plot.setStartAngle(70); //??? //plot.setExplodePercent(1, 0.5D); //plot.setExplodePercent("One", 0.5D); //,3D? plot.setExplodePercent(dataset.getKey(0), 0.1d); // plot.setLabelLinkPaint(Color.BLUE); // plot.setLabelOutlinePaint(Color.black); // plot.setLabelShadowPaint(Color.RED); // plot.setSectionPaint(1, Color.BLACK); // :,{0},{1},{2}?,??? plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}:{1}\r\n{2}", NumberFormat.getNumberInstance(), new DecimalFormat("0.00%"))); // plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator("{0}={2}")); //:(true),(false) plot.setCircular(true); //? plot.setNoDataMessage("??..."); //??? plot.setToolTipGenerator(new StandardPieToolTipGenerator()); // //plot.setURLGenerator(new StandardPieURLGenerator("detail.jsp")); return chart; }
From source file:java2d.ps.EPSColorsExample.java
/** * Creates an EPS file. The contents are painted using a Graphics2D * implementation that generates an EPS file. * //from ww w .j a v a 2s .c o m * @param outputFile * the target file * @throws IOException * In case of an I/O error */ public static void generateEPSusingJava2D(final File outputFile) throws IOException { OutputStream out = new java.io.FileOutputStream(outputFile); out = new java.io.BufferedOutputStream(out); try { // Instantiate the EPSDocumentGraphics2D instance final EPSDocumentGraphics2D g2d = new EPSDocumentGraphics2D(false); g2d.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext()); // Set up the document size g2d.setupDocument(out, 400, 200); // 400pt x 200pt // Paint a bounding box g2d.drawRect(0, 0, 400, 200); g2d.setFont(new Font("sans-serif", Font.BOLD, 14)); g2d.drawString("Color usage example:", 10, 20); g2d.setFont(new Font("sans-serif", Font.PLAIN, 12)); g2d.drawString("RGB", 10, 84); g2d.drawString("CMYK", 60, 84); g2d.drawString("(Lab)", 110, 84); g2d.drawString("(Named)", 160, 84); // We're creating a few boxes all filled with some variant of the // "Postgelb" (postal yellow) color as used by Swiss Post. final Color colRGB = new Color(255, 204, 0); g2d.setColor(colRGB); g2d.fillRect(10, 30, 40, 40); // Just convert RGB to CMYK and use that final float[] compsRGB = colRGB.getColorComponents(null); final DeviceCMYKColorSpace cmykCS = ColorSpaces.getDeviceCMYKColorSpace(); final float[] compsCMYK = cmykCS.fromRGB(compsRGB); final Color colCMYK = DeviceCMYKColorSpace.createCMYKColor(compsCMYK); g2d.setColor(colCMYK); g2d.fillRect(60, 30, 40, 40); // Try CIELab (not implemented, yet) final CIELabColorSpace d50 = ColorSpaces.getCIELabColorSpaceD50(); final Color colLab = d50.toColor(83.25f, 16.45f, 96.89f, 1.0f); g2d.setColor(colLab); g2d.fillRect(110, 30, 40, 40); // Try named color (Separation, not implemented, yet) final float[] c1xyz = d50.toCIEXYZNative(83.25f, 16.45f, 96.89f); final NamedColorSpace postgelb = new NamedColorSpace("Postgelb", c1xyz); final Color colNamed = new Color(postgelb, new float[] { 1.0f }, 1.0f); g2d.setColor(colNamed); g2d.fillRect(160, 30, 40, 40); // Cleanup g2d.finish(); } finally { IOUtils.closeQuietly(out); } }
From source file:com.ouc.cpss.view.ChartProBuilder.java
private static JFreeChart createJFreeChart(CategoryDataset dataset) { /**//from w ww .j a va 2s .c o m * JFreeChart */ //? StandardChartTheme standardChartTheme = new StandardChartTheme("CN"); // standardChartTheme.setExtraLargeFont(new Font("", Font.BOLD, 20)); // standardChartTheme.setRegularFont(new Font("", Font.PLAIN, 15)); //? standardChartTheme.setLargeFont(new Font("", Font.PLAIN, 15)); //? ChartFactory.setChartTheme(standardChartTheme); //? // ? JFreeChart jfreeChart = null; if (choice == 1) { jfreeChart = ChartFactory.createBarChart3D("? -- ?TOP10", "", "?", dataset, PlotOrientation.VERTICAL, true, false, false); /** * JFreeChart */ jfreeChart.setTitle(new TextTitle("? -- ?TOP10", new Font("", Font.BOLD + Font.ITALIC, 20))); CategoryPlot plot = (CategoryPlot) jfreeChart.getPlot(); CategoryAxis categoryAxis = plot.getDomainAxis(); categoryAxis.setLabelFont(new Font("", Font.ROMAN_BASELINE, 12)); } else { jfreeChart = ChartFactory.createBarChart3D("? -- ?TOP10", "", "?", dataset, PlotOrientation.VERTICAL, true, false, false); jfreeChart.setTitle(new TextTitle("? -- ?TOP10", new Font("", Font.BOLD + Font.ITALIC, 20))); CategoryPlot plot = (CategoryPlot) jfreeChart.getPlot(); CategoryAxis categoryAxis = plot.getDomainAxis(); categoryAxis.setLabelFont(new Font("", Font.ROMAN_BASELINE, 12)); } return jfreeChart; }
From source file:org.martus.client.reports.MartusChartTheme.java
public MartusChartTheme() { super("Martus"); // NOTE: JFreeChart default is "Tahoma", which somehow maps to Dialog, // which for some reason (in J6) doesn't fall back to the fallback fonts, // and therefore doesn't work in Armenian, Bangla, Khmer, or Nepali setExtraLargeFont(new Font(FontHandler.getDefaultFontName(), Font.BOLD, 20)); setLargeFont(new Font(FontHandler.getDefaultFontName(), Font.BOLD, 14)); setRegularFont(new Font(FontHandler.getDefaultFontName(), Font.PLAIN, 12)); setSmallFont(new Font(FontHandler.getDefaultFontName(), Font.PLAIN, 10)); }
From source file:Main.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); int cx = getSize().width / 2; int cy = getSize().height / 2; g2.translate(cx, cy);//from w ww .j a v a2s . com g2.rotate(theta * Math.PI / 180); Shape oldClip = g2.getClip(); Shape e = new Ellipse2D.Float(-cx, -cy, cx * 2, cy * 2); g2.clip(e); Shape c = new Ellipse2D.Float(-cx, -cy, cx * 3 / 4, cy * 2); g2.setPaint(new GradientPaint(40, 40, Color.blue, 60, 50, Color.white, true)); g2.fill(c); g2.setPaint(Color.yellow); g2.fillOval(cx / 4, 0, cx, cy); g2.setClip(oldClip); g2.setFont(new Font("Times New Roman", Font.PLAIN, 64)); g2.setPaint(new GradientPaint(-cx, 0, Color.red, cx, 0, Color.black, false)); g2.drawString("Hello, 2D!", -cx * 3 / 4, cy / 4); AlphaComposite ac = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float) .75); g2.setComposite(ac); Shape r = new RoundRectangle2D.Float(0, -cy * 3 / 4, cx * 3 / 4, cy * 3 / 4, 20, 20); g2.setStroke(new BasicStroke(4)); g2.setPaint(Color.magenta); g2.fill(r); g2.setPaint(Color.green); g2.draw(r); g2.drawImage(image, -cx / 2, -cy / 2, this); }
From source file:Highlights.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); String s = "Drag the text to highlight Java Source and Support."; Font font = new Font("Serif", Font.PLAIN, 32); if (textLayout == null) { FontRenderContext frc = g2.getFontRenderContext(); textLayout = new TextLayout(s, font, frc); }//from w w w . jav a2 s . co m // Draw the highlight. if (firstHit != null && secondHit != null) { Shape base = textLayout.getLogicalHighlightShape(firstHit.getInsertionIndex(), secondHit.getInsertionIndex()); AffineTransform at = AffineTransform.getTranslateInstance(x, y); Shape highlight = at.createTransformedShape(base); g2.setPaint(Color.white); g2.fill(highlight); } g2.setPaint(Color.black); textLayout.draw(g2, x, y); }
From source file:charts.ErrorPorcentajePie.java
private JFreeChart createChart(PieDataset dataset, String title) { JFreeChart chart = ChartFactory.createPieChart(title, dataset, true, true, false); PiePlot plot = (PiePlot) chart.getPlot(); plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); plot.setNoDataMessage("no data"); plot.setCircular(false);// w w w . j a v a2s.c o m plot.setLabelGap(0.02); return chart; }
From source file:com.rapidminer.gui.plotter.charts.RingChartPlotter.java
@Override public JFreeChart createChart(PieDataset pieDataSet, boolean createLegend) { JFreeChart chart = ChartFactory.createRingChart(null, pieDataSet, createLegend, // legend true, false);/*from w ww . j av a 2 s . c o m*/ PiePlot plot = (PiePlot) chart.getPlot(); plot.setSectionOutlinesVisible(false); plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 11)); plot.setNoDataMessage("No data available"); plot.setCircular(false); plot.setLabelGap(0.02); return chart; }
From source file:org.gbif.portal.web.util.ChartUtils.java
/** * Writes out the image using the supplied file name. * /*w w w . java 2s . com*/ * @param legend * @param fileName * @return */ public static String writePieChartImageToTempFile(Map<String, Double> legend, String fileName) { String filePath = System.getProperty(tmpDirSystemProperty) + File.separator + fileName + defaultExtension; File fileToCheck = new File(filePath); if (fileToCheck.exists()) { return fileName + defaultExtension; } final DefaultPieDataset data = new DefaultPieDataset(); Set<String> keys = legend.keySet(); for (String key : keys) { logger.info("Adding key : " + key); data.setValue(key, legend.get(key)); } // create a pie chart... final boolean withLegend = true; final JFreeChart chart = ChartFactory.createPieChart(null, data, withLegend, false, false); PiePlot piePlot = (PiePlot) chart.getPlot(); piePlot.setLabelFont(new Font("Arial", Font.PLAIN, 10)); piePlot.setLabelBackgroundPaint(Color.WHITE); LegendTitle lt = chart.getLegend(); lt.setBackgroundPaint(Color.WHITE); lt.setWidth(300); lt.setBorder(0, 0, 0, 0); lt.setItemFont(new Font("Arial", Font.PLAIN, 11)); chart.setPadding(new RectangleInsets(0, 0, 0, 0)); chart.setBorderVisible(false); chart.setBackgroundImageAlpha(0); chart.setBackgroundPaint(Color.WHITE); chart.setBorderPaint(Color.LIGHT_GRAY); final BufferedImage image = new BufferedImage(300, 250, BufferedImage.TYPE_INT_RGB); KeypointPNGEncoderAdapter adapter = new KeypointPNGEncoderAdapter(); adapter.setQuality(1); try { adapter.encode(image); } catch (IOException e) { logger.error(e.getMessage(), e); } final Graphics2D g2 = image.createGraphics(); g2.setFont(new Font("Arial", Font.PLAIN, 11)); final Rectangle2D chartArea = new Rectangle2D.Double(0, 0, 300, 250); // draw chart.draw(g2, chartArea, null, null); try { FileOutputStream fOut = new FileOutputStream(fileToCheck); ChartUtilities.writeChartAsPNG(fOut, chart, 300, 250); return fileToCheck.getName(); } catch (IOException e) { logger.error(e.getMessage(), e); return null; } }