List of usage examples for org.jfree.chart.plot CategoryMarker setLabelFont
public void setLabelFont(Font font)
From source file:org.jfree.chart.demo.CategoryMarkerDemo1.java
private static JFreeChart createChart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createLineChart("Category Marker Demo 1", "Category", "Count", categorydataset, PlotOrientation.VERTICAL, true, true, false); jfreechart.setBackgroundPaint(Color.white); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setBackgroundPaint(Color.lightGray); categoryplot.setRangeGridlinePaint(Color.white); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); LineAndShapeRenderer lineandshaperenderer = (LineAndShapeRenderer) categoryplot.getRenderer(); lineandshaperenderer.setSeriesShapesVisible(0, true); lineandshaperenderer.setDrawOutlines(true); lineandshaperenderer.setUseFillPaint(true); lineandshaperenderer.setBaseFillPaint(Color.white); CategoryMarker categorymarker = new CategoryMarker("Category 4", Color.blue, new BasicStroke(1.0F)); categorymarker.setDrawAsLine(true);/* ww w . j av a 2s . c o m*/ categorymarker.setLabel("Marker Label"); categorymarker.setLabelFont(new Font("Dialog", 0, 11)); categorymarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT); categorymarker.setLabelOffset(new RectangleInsets(2D, 5D, 2D, 5D)); categoryplot.addDomainMarker(categorymarker, Layer.BACKGROUND); return jfreechart; }
From source file:org.jfree.chart.demo.CategoryMarkerDemo2.java
private static JFreeChart createChart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createLineChart("Category Marker Demo 2", "Category", "Count", categorydataset, PlotOrientation.VERTICAL, true, true, false); jfreechart.setBackgroundPaint(Color.white); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setBackgroundPaint(Color.lightGray); categoryplot.setRangeGridlinePaint(Color.white); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); LineAndShapeRenderer lineandshaperenderer = (LineAndShapeRenderer) categoryplot.getRenderer(); lineandshaperenderer.setSeriesShapesVisible(0, true); lineandshaperenderer.setDrawOutlines(true); lineandshaperenderer.setUseFillPaint(true); lineandshaperenderer.setBaseFillPaint(Color.white); CategoryMarker categorymarker = new CategoryMarker("Category 4", new Color(0, 0, 255, 25), new BasicStroke(1.0F)); categorymarker.setDrawAsLine(false); categorymarker.setAlpha(1.0F);//from w w w .j ava 2 s . co m categorymarker.setLabel("Marker Label"); categorymarker.setLabelFont(new Font("Dialog", 0, 11)); categorymarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT); categorymarker.setLabelOffset(new RectangleInsets(2D, 5D, 2D, 5D)); categoryplot.addDomainMarker(categorymarker, Layer.BACKGROUND); return jfreechart; }
From source file:net.sf.jasperreports.customizers.marker.CategoryMarkerCustomizer.java
protected CategoryMarker createMarker(JRChart jrc) { Comparable<?> value = getProperty(PROPERTY_CATEGORY); if (value == null) { return null; }//from w ww . ja v a2 s.com CategoryMarker marker = new CategoryMarker(value); configureMarker(marker); configureStroke(marker); Boolean drawAsLine = getBooleanProperty(PROPERTY_DRAW_AS_LINE); if (drawAsLine != null) { marker.setDrawAsLine(drawAsLine); } //Setup the font Font font = marker.getLabelFont(); String fontName = getProperty(PROPERTY_FONT_NAME); if (fontName == null) { fontName = font.getName(); } Float fontSize = getFloatProperty(PROPERTY_FONT_SIZE); if (fontSize == null) { fontSize = Float.valueOf(font.getSize()); } int fontStyle = Font.PLAIN; Boolean isBold = getBooleanProperty(PROPERTY_FONT_BOLD); if (isBold != null) { fontStyle = fontStyle | Font.BOLD; } Boolean isItalic = getBooleanProperty(PROPERTY_FONT_ITALIC); if (isItalic != null) { fontStyle = fontStyle | Font.ITALIC; } marker.setLabelFont(FontUtil.getInstance(filler.getJasperReportsContext()).getAwtFontFromBundles(fontName, fontStyle, fontSize, filler.getFillContext().getMasterLocale(), true)); return marker; }
From source file:com.naryx.tagfusion.cfm.tag.awt.cfCHART.java
public void addDomainMarker(CategoryPlot plot, cfCHARTDOMAINMARKERData dmData) throws cfmRunTimeException { CategoryMarker domainMarker = new CategoryMarker(dmData.getValue()); boolean drawAsLine = false; if (dmData.getShape().equals("line")) drawAsLine = true;/* w w w . j av a2 s. co m*/ domainMarker.setDrawAsLine(drawAsLine); domainMarker.setPaint(convertStringToColor(dmData.getColor())); if (dmData.getLabel() != null) { domainMarker.setLabel(dmData.getLabel()); domainMarker.setLabelPaint(convertStringToColor(dmData.getLabelColor())); String labelPos = dmData.getLabelPosition(); if (labelPos.equals("top_left")) { domainMarker.setLabelAnchor(RectangleAnchor.TOP_LEFT); if (drawAsLine) domainMarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT); else domainMarker.setLabelTextAnchor(TextAnchor.TOP_LEFT); } else if (labelPos.equals("top")) { domainMarker.setLabelAnchor(RectangleAnchor.TOP); domainMarker.setLabelTextAnchor(TextAnchor.TOP_CENTER); } else if (labelPos.equals("top_right")) { domainMarker.setLabelAnchor(RectangleAnchor.TOP_RIGHT); if (drawAsLine) domainMarker.setLabelTextAnchor(TextAnchor.TOP_LEFT); else domainMarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT); } else if (labelPos.equals("left")) { domainMarker.setLabelAnchor(RectangleAnchor.LEFT); if (drawAsLine) domainMarker.setLabelTextAnchor(TextAnchor.CENTER_RIGHT); else domainMarker.setLabelTextAnchor(TextAnchor.CENTER_LEFT); } else if (labelPos.equals("center")) { domainMarker.setLabelAnchor(RectangleAnchor.CENTER); domainMarker.setLabelTextAnchor(TextAnchor.CENTER); } else if (labelPos.equals("right")) { domainMarker.setLabelAnchor(RectangleAnchor.RIGHT); if (drawAsLine) domainMarker.setLabelTextAnchor(TextAnchor.CENTER_LEFT); else domainMarker.setLabelTextAnchor(TextAnchor.CENTER_RIGHT); } else if (labelPos.equals("bottom_left")) { domainMarker.setLabelAnchor(RectangleAnchor.BOTTOM_LEFT); if (drawAsLine) domainMarker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT); else domainMarker.setLabelTextAnchor(TextAnchor.BOTTOM_LEFT); } else if (labelPos.equals("bottom")) { domainMarker.setLabelAnchor(RectangleAnchor.BOTTOM); domainMarker.setLabelTextAnchor(TextAnchor.BOTTOM_CENTER); } else if (labelPos.equals("bottom_right")) { domainMarker.setLabelAnchor(RectangleAnchor.BOTTOM_RIGHT); if (drawAsLine) domainMarker.setLabelTextAnchor(TextAnchor.BOTTOM_LEFT); else domainMarker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT); } domainMarker.setLabelOffsetType(LengthAdjustmentType.NO_CHANGE); domainMarker.setLabelFont( getFont(dmData.getFont(), dmData.getFontBold(), dmData.getFontItalic(), dmData.getFontSize())); } plot.addDomainMarker(domainMarker, Layer.BACKGROUND); }