List of usage examples for org.jfree.chart.block BlockBorder BlockBorder
public BlockBorder()
From source file:net.sf.jasperreports.chartthemes.provider.BlockBorderProvider.java
@Override public BlockFrame getBlockFrame() { Paint borderPaint = paint == null ? null : paint.getPaint(); BlockBorder border;// www .j a va 2s .com if (insets == null) { if (paint == null) { border = new BlockBorder(); } else { border = new BlockBorder(borderPaint); } } else { if (borderPaint == null) { border = new BlockBorder(insets, Color.black); } else { border = new BlockBorder(insets, borderPaint); } } return border; }
From source file:org.jfree.chart.demo.DualAxisDemo1.java
private static JFreeChart createChart() { JFreeChart jfreechart = ChartFactory.createBarChart("Dual Axis Chart", "Category", "Value", createDataset1(), PlotOrientation.VERTICAL, false, true, false); jfreechart.setBackgroundPaint(Color.white); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setBackgroundPaint(new Color(238, 238, 255)); categoryplot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); CategoryDataset categorydataset = createDataset2(); categoryplot.setDataset(1, categorydataset); categoryplot.mapDatasetToRangeAxis(1, 1); CategoryAxis categoryaxis = categoryplot.getDomainAxis(); categoryaxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45); NumberAxis numberaxis = new NumberAxis("Secondary"); categoryplot.setRangeAxis(1, numberaxis); LineAndShapeRenderer lineandshaperenderer = new LineAndShapeRenderer(); lineandshaperenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator()); categoryplot.setRenderer(1, lineandshaperenderer); categoryplot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); LegendTitle legendtitle = new LegendTitle(categoryplot.getRenderer(0)); legendtitle.setMargin(new RectangleInsets(2D, 2D, 2D, 2D)); legendtitle.setFrame(new BlockBorder()); LegendTitle legendtitle1 = new LegendTitle(categoryplot.getRenderer(1)); legendtitle1.setMargin(new RectangleInsets(2D, 2D, 2D, 2D)); legendtitle1.setFrame(new BlockBorder()); BlockContainer blockcontainer = new BlockContainer(new BorderArrangement()); blockcontainer.add(legendtitle, RectangleEdge.LEFT); blockcontainer.add(legendtitle1, RectangleEdge.RIGHT); blockcontainer.add(new EmptyBlock(2000D, 0.0D)); CompositeTitle compositetitle = new CompositeTitle(blockcontainer); compositetitle.setPosition(RectangleEdge.BOTTOM); jfreechart.addSubtitle(compositetitle); return jfreechart; }
From source file:org.codehaus.mojo.dashboard.report.plugin.chart.time.SurefirePercentAxisDecorator.java
/** * */// w w w . jav a 2 s.co m public void createChart() { XYPlot xyplot = (XYPlot) report.getPlot(); if (this.decoratedChart instanceof TimeChartRenderer && this.results != null && !this.results.isEmpty()) { Iterator iter = this.results.iterator(); TimeSeriesCollection defaultdataset = new TimeSeriesCollection(); TimeSeries s1 = new TimeSeries("% success", Day.class); while (iter.hasNext()) { SurefireReportBean surefire = (SurefireReportBean) iter.next(); Date date = surefire.getDateGeneration(); s1.addOrUpdate(new Day(TimePeriod.DAY.normalize(date)), surefire.getSucessRate() / PCENT); } defaultdataset.addSeries(s1); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setSeriesPaint(0, ChartColor.DARK_BLUE); renderer.setBaseShapesVisible(true); renderer.setDrawOutlines(true); StandardXYItemLabelGenerator labelgenerator = new StandardXYItemLabelGenerator( StandardXYItemLabelGenerator.DEFAULT_ITEM_LABEL_FORMAT, TimePeriod.DAY.getDateFormat(), NumberFormat.getPercentInstance(Locale.getDefault())); renderer.setBaseItemLabelGenerator(labelgenerator); renderer.setBaseItemLabelFont(new Font("SansSerif", Font.BOLD, ITEM_LABEL_FONT_SIZE)); renderer.setBaseItemLabelsVisible(true); renderer.setBasePositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE10, TextAnchor.BASELINE_RIGHT)); renderer.setBaseStroke(new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); LegendTitle legendtitle = new LegendTitle(xyplot.getRenderer(0)); legendtitle.setMargin(new RectangleInsets(2D, 2D, 2D, 2D)); legendtitle.setFrame(new BlockBorder()); legendtitle.setBackgroundPaint(ChartColor.WHITE); LegendTitle legendtitle1 = new LegendTitle(renderer); legendtitle1.setMargin(new RectangleInsets(2D, 2D, 2D, 2D)); legendtitle1.setFrame(new BlockBorder()); legendtitle1.setBackgroundPaint(ChartColor.WHITE); BlockContainer blockcontainer = new BlockContainer(new BorderArrangement()); blockcontainer.add(legendtitle, RectangleEdge.LEFT); blockcontainer.add(legendtitle1, RectangleEdge.RIGHT); blockcontainer.add(new EmptyBlock(BLOCK_CONTAINER_WIDTH, 0.0D)); CompositeTitle compositetitle = new CompositeTitle(blockcontainer); compositetitle.setPosition(RectangleEdge.BOTTOM); report.clearSubtitles(); report.addSubtitle(compositetitle); xyplot.setDataset(1, defaultdataset); NumberAxis valueaxis = new NumberAxis("% success"); valueaxis.setLowerMargin(0.0D); valueaxis.setUpperMargin(AXIS_UPPER_MARGIN); valueaxis.setRangeWithMargins(0.0D, 1.0D); valueaxis.setNumberFormatOverride(NumberFormat.getPercentInstance()); xyplot.setRangeAxis(1, valueaxis); xyplot.mapDatasetToRangeAxis(1, 1); xyplot.setRenderer(1, renderer); } }
From source file:org.jfree.chart.demo.StackedXYBarChartDemo2.java
private static JFreeChart createChart(TableXYDataset tablexydataset) { DateAxis dateaxis = new DateAxis("Date"); dateaxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); dateaxis.setLowerMargin(0.01D);//from w ww . j a va2 s .co m dateaxis.setUpperMargin(0.01D); NumberAxis numberaxis = new NumberAxis("Count"); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); numberaxis.setUpperMargin(0.10000000000000001D); StackedXYBarRenderer stackedxybarrenderer = new StackedXYBarRenderer(0.14999999999999999D); stackedxybarrenderer.setDrawBarOutline(false); stackedxybarrenderer.setBaseItemLabelsVisible(true); stackedxybarrenderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator()); stackedxybarrenderer.setBasePositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER)); stackedxybarrenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{0} : {1} = {2}", new SimpleDateFormat("yyyy"), new DecimalFormat("0"))); XYPlot xyplot = new XYPlot(tablexydataset, dateaxis, numberaxis, stackedxybarrenderer); JFreeChart jfreechart = new JFreeChart("Holes-In-One / Double Eagles", xyplot); jfreechart.removeLegend(); jfreechart.addSubtitle(new TextTitle("PGA Tour, 1983 to 2003")); TextTitle texttitle = new TextTitle( "http://www.golfdigest.com/majors/masters/index.ssf?/majors/masters/gw20040402albatross.html", new Font("Dialog", 0, 8)); jfreechart.addSubtitle(texttitle); jfreechart.setTextAntiAlias(RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT); LegendTitle legendtitle = new LegendTitle(xyplot); legendtitle.setBackgroundPaint(Color.white); legendtitle.setFrame(new BlockBorder()); legendtitle.setPosition(RectangleEdge.BOTTOM); jfreechart.addSubtitle(legendtitle); return jfreechart; }
From source file:gda.plots.SimplePlot.java
/** * @param type/*from w ww . ja v a 2 s . c om*/ * @param autoRange * @param enableHistory */ public SimplePlot(int type, boolean autoRange, boolean enableHistory) { super(new JFreeChart(new XYPlot())); setChart(ChartFactory.createXYLineChart(title, "xaxis", "yaxis", leftSeriesCollection, PlotOrientation.VERTICAL, true, false, false)); this.type = type; if (enableHistory) { history = new LinkedList<SimpleXYSeries>(); addHistoryCommandsToPopupMenu(); } // For width and height greater than these values the graph is drawn by // using a transform on the Graphics2D. If this comes into operation // then the placing of components added with wrapAndDisplay goes wrong. // The easiest way to keep out of trouble is to make them large. This // also // stops distortion of fonts when expanding to full screen size. setMaximumDrawWidth(5000); setMaximumDrawHeight(2000); // Next line added to fix sun.dc.pr.PRException on Windows PC's getChart().setAntiAlias(false); xYPlot = getChart().getXYPlot(); if (type == BARCHART) { xYPlot.setRenderer(new SimpleXYBarRenderer()); } else { xYPlot.setRenderer(new SimpleXYItemRenderer()); xYPlot.getRenderer().setToolTipGenerator(new SimpleXYToolTipGenerator()); } // The x and y axes are created and set here so that SimpleNumberAxis // can // be used. This allows SimplePlot to keep the CoordinateFormatter up to // date about the accuracy required (seeForXAxis paintComponent()). NB // Any secondary y axes will be of type NumberAxis. createXAxes(autoRange); xYPlot.setDomainAxis(linearXAxis); createYAxes(autoRange); xYPlot.setRangeAxis(linearYAxis); // There are two legends. We use the exisiting default one for // lines displayed with respect to the left Y axis and create a // new one for those of the right Y axis (if there is one). // Normally getChart().getPlot() would provide the LegendItemSource // for the default legend but we extract it and set its Source to be a // LegendItemsGetter (defined here) and change its position to RIGHT // (default is TOP). // leftSeriesLegend = getChart().getLegend(); // leftSeriesLegend.setPosition(RectangleEdge.RIGHT); // This LegendItemsGetter will return only left series legend items. leftSeriesLegendItemsGetter = new LegendItemsGetter(0); // TEST CODE DO NOT REMOVE leftSeriesLegend = new SimpleLegendTitle(leftSeriesLegendItemsGetter); leftSeriesLegend.setMargin(new RectangleInsets(1.0, 1.0, 1.0, 1.0)); leftSeriesLegend.setBorder(new BlockBorder()); leftSeriesLegend.setBackgroundPaint(Color.white); leftSeriesLegend.setPosition(RectangleEdge.BOTTOM); leftSeriesLegend.setPosition(RectangleEdge.RIGHT); getChart().removeLegend(); getChart().addLegend(leftSeriesLegend); // END OF TEST CODE leftSeriesLegend.setSources(new LegendItemSource[] { leftSeriesLegendItemsGetter }); rightSeriesLegend = new SimpleLegendTitle(null); rightSeriesLegend.setPosition(RectangleEdge.RIGHT); rightSeriesLegend.setBorder(leftSeriesLegend.getBorder()); rightSeriesLegend.setBackgroundPaint(leftSeriesLegend.getBackgroundPaint()); // This LegendItemsGetter will return only right series legend items. rightSeriesLegendItemsGetter = new LegendItemsGetter(1); rightSeriesLegend.setSources(new LegendItemSource[] { rightSeriesLegendItemsGetter }); getChart().addLegend(rightSeriesLegend); // The mousePositionTracker is added as a subtitle mpt = new MousePositionTracker(""); addChartMouseListener(mpt); getChart().addSubtitle(mpt); // The coordinateFormatter is used in the MousePositionTracker when // displaying the mouse position. coordinateFormatter = new SimpleCoordinateFormatter(); dataMagnifierWindow = new DataMagnifierWindow(SwingUtilities.getRoot(this)); dataMagnifierWindow.setSimplePlot(this, leftSeriesCollection); // Make sure zooming starts in the correct state. setZooming(false); setTurboMode(false); setStripWidth(null); setTrackPointer(true); }
From source file:com.naryx.tagfusion.cfm.tag.awt.cfCHART.java
private void setTitle(JFreeChart chart, String title, Font titleFont, Color foregroundColor, List<cfCHARTTITLEData> titles) throws cfmRunTimeException { if (titles.size() > 0) { // One or more CFCHARTTITLE tags were specified so use them to configure // the chart titles for (int i = 0; i < titles.size(); i++) { cfCHARTTITLEData data = titles.get(i); Font font = getFont(data.getFont(), data.getFontBold(), data.getFontItalic(), data.getFontSize()); TextTitle textTitle = new TextTitle(data.getTitle(), font); textTitle.setPaint(convertStringToColor(data.getLabelColor())); textTitle.setBackgroundPaint(convertStringToColor(data.getBackgroundColor())); String pos = data.getPosition(); if (pos.equals("top")) textTitle.setPosition(RectangleEdge.TOP); else if (pos.equals("bottom")) textTitle.setPosition(RectangleEdge.BOTTOM); else if (pos.equals("left")) textTitle.setPosition(RectangleEdge.LEFT); else if (pos.equals("right")) textTitle.setPosition(RectangleEdge.RIGHT); if (!data.getShowBorder()) textTitle.setBorder(BlockBorder.NONE); else//from w ww . jav a 2 s .co m textTitle.setBorder(new BlockBorder()); textTitle.setPadding(data.getPadding(), data.getPadding(), data.getPadding(), data.getPadding()); textTitle.setMargin(data.getMargin(), data.getMargin(), data.getMargin(), data.getMargin()); chart.addSubtitle(textTitle); } } else { // A CFCHARTTITLE tag was NOT specified so use the CFCHART attributes to // configure the chart title if (title == null) return; TextTitle textTitle = new TextTitle(title, titleFont); textTitle.setPaint(foregroundColor); // Add a border around the title to match CFMX 7 textTitle.setBorder(new BlockBorder()); textTitle.setPadding(10, 10, 10, 10); textTitle.setMargin(5, 5, 5, 5); chart.setTitle(textTitle); } }
From source file:com.naryx.tagfusion.cfm.tag.awt.cfCHART.java
private void setLegend(JFreeChart chart, boolean bShowLegend, Font font, Color foregroundColor, Color backgroundColor, cfCHARTLEGENDData legendData) throws cfmRunTimeException { LegendTitle legend = new LegendTitle(chart.getPlot()); legend.setMargin(new RectangleInsets(1.0, 1.0, 1.0, 1.0)); // If a CFCHARTLEGEND tag was used then use it's attributes to configure the // legend//from www. j a va 2 s . c o m if (legendData != null) { // A CFCHARTLEGEND tag is present so use its attributes to configure the // legend legend.setItemFont(getFont(legendData.getFont(), legendData.getFontBold(), legendData.getFontItalic(), legendData.getFontSize())); legend.setItemPaint(convertStringToColor(legendData.getLabelColor())); legend.setBackgroundPaint(convertStringToColor(legendData.getBackgroundColor())); String pos = legendData.getPosition(); if (pos.equals("top")) legend.setPosition(RectangleEdge.TOP); else if (pos.equals("bottom")) legend.setPosition(RectangleEdge.BOTTOM); else if (pos.equals("left")) legend.setPosition(RectangleEdge.LEFT); else if (pos.equals("right")) legend.setPosition(RectangleEdge.RIGHT); if (!legendData.getShowBorder()) legend.setBorder(BlockBorder.NONE); else legend.setBorder(new BlockBorder()); } else { // A CFCHARTLEGEND tag is NOT present so use the attributes from the // CFCHART tag to configure the legend if (!bShowLegend) return; legend.setItemFont(font); legend.setItemPaint(foregroundColor); legend.setBackgroundPaint(backgroundColor); // By default CFMX 7 places the legend at the top with no border legend.setPosition(RectangleEdge.TOP); legend.setBorder(BlockBorder.NONE); } // Add the legend to the chart chart.addSubtitle(legend); }