List of usage examples for org.jfree.chart.title LegendTitle getItemPaint
public Paint getItemPaint()
From source file:net.sf.dynamicreports.test.jasper.chart.ChartTest.java
@Override public void test() { super.test(); numberOfPagesTest(1);//from w w w . j a va 2s. co m chartCountTest("summary.chart1", 1); JFreeChart chart = getChart("summary.chart1", 0); TextTitle title = chart.getTitle(); Assert.assertEquals("title", "title", title.getText()); Assert.assertEquals("title color", Color.BLUE, title.getPaint()); Assert.assertEquals("title font", new Font("Arial", Font.BOLD, 10), title.getFont()); Assert.assertEquals("title position", RectangleEdge.RIGHT, title.getPosition()); TextTitle subtitle = (TextTitle) chart.getSubtitle(1); Assert.assertEquals("subtitle", "subtitle", subtitle.getText()); Assert.assertEquals("subtitle color", Color.CYAN, subtitle.getPaint()); Assert.assertEquals("subtitle font", new Font("Arial", Font.PLAIN, 10), subtitle.getFont()); LegendTitle legend = (LegendTitle) chart.getSubtitle(0); Assert.assertEquals("legend color", Color.BLUE, legend.getItemPaint()); Assert.assertEquals("legend backgroundcolor", Color.LIGHT_GRAY, legend.getBackgroundPaint()); Assert.assertEquals("legend font", new Font("Courier New", Font.PLAIN, 10), legend.getItemFont()); Assert.assertEquals("legend position", RectangleEdge.LEFT, legend.getPosition()); chartCountTest("summary.chart2", 1); chart = getChart("summary.chart2", 0); Assert.assertNull("legend", chart.getLegend()); Assert.assertEquals("plot orientation", PlotOrientation.HORIZONTAL, chart.getCategoryPlot().getOrientation()); Assert.assertEquals("plot series colors", Color.BLUE, chart.getPlot().getDrawingSupplier().getNextPaint()); Assert.assertEquals("plot series colors", Color.GREEN, chart.getPlot().getDrawingSupplier().getNextPaint()); Assert.assertEquals("plot series colors", Color.RED, chart.getPlot().getDrawingSupplier().getNextPaint()); }
From source file:userinterface.graph.Histogram.java
/** * Update the settings of the graph if the settings changed *//*ww w .j ava2 s. com*/ public void updateGraph() { /* Update title if necessary. */ if (!this.chart.getTitle().equals(graphTitle)) { this.chart.setTitle(graphTitle.getStringValue()); } /* Update title font if necessary. */ if (!titleFont.getFontColorValue().f.equals(this.chart.getTitle().getFont())) { this.chart.getTitle().setFont(titleFont.getFontColorValue().f); } /* Update title colour if necessary. */ if (!titleFont.getFontColorValue().c.equals(this.chart.getTitle().getPaint())) { this.chart.getTitle().setPaint(titleFont.getFontColorValue().c); } if (legendVisible.getBooleanValue() != (this.chart.getLegend() != null)) { if (!legendVisible.getBooleanValue()) { this.chart.removeLegend(); } else { LegendTitle legend = new LegendTitle(plot.getRenderer()); legend.setBackgroundPaint(Color.white); legend.setBorder(1, 1, 1, 1); this.chart.addLegend(legend); } } if (this.chart.getLegend() != null) { LegendTitle legend = this.chart.getLegend(); /* Put legend on the left if appropriate. */ if ((legendPosition.getCurrentIndex() == Graph.LEFT) && !legend.getPosition().equals(RectangleEdge.LEFT)) { legend.setPosition(RectangleEdge.LEFT); } /* Put legend on the right if appropriate. */ if ((legendPosition.getCurrentIndex() == Graph.RIGHT) && !legend.getPosition().equals(RectangleEdge.RIGHT)) { legend.setPosition(RectangleEdge.RIGHT); } /* Put legend on the top if appropriate. */ if ((legendPosition.getCurrentIndex() == Graph.TOP) && !legend.getPosition().equals(RectangleEdge.TOP)) { legend.setPosition(RectangleEdge.TOP); } /* Put legend on the bottom if appropriate. */ if ((legendPosition.getCurrentIndex() == Graph.BOTTOM) && !legend.getPosition().equals(RectangleEdge.BOTTOM)) { legend.setPosition(RectangleEdge.BOTTOM); } /* Set legend font. */ if (!legend.getItemFont().equals(legendFont.getFontColorValue().f)) { legend.setItemFont(legendFont.getFontColorValue().f); } /* Set legend font colour. */ if (!legend.getItemPaint().equals(legendFont.getFontColorValue().c)) { legend.setItemPaint(legendFont.getFontColorValue().c); } } super.repaint(); doEnables(); }
From source file:userinterface.graph.Graph.java
private void updateGraph() { /* Update title if necessary. */ if (!this.chart.getTitle().equals(graphTitle)) { this.chart.setTitle(graphTitle.getStringValue()); }//from w ww .jav a2 s . c o m /* Update title font if necessary. */ if (!titleFont.getFontColorValue().f.equals(this.chart.getTitle().getFont())) { this.chart.getTitle().setFont(titleFont.getFontColorValue().f); } /* Update title colour if necessary. */ if (!titleFont.getFontColorValue().c.equals(this.chart.getTitle().getPaint())) { this.chart.getTitle().setPaint(titleFont.getFontColorValue().c); } if (legendVisible.getBooleanValue() != (this.chart.getLegend() != null)) { if (!legendVisible.getBooleanValue()) { this.chart.removeLegend(); } else { LegendTitle legend = new LegendTitle(plot.getRenderer()); legend.setBackgroundPaint(Color.white); legend.setBorder(1, 1, 1, 1); this.chart.addLegend(legend); } } if (this.chart.getLegend() != null) { LegendTitle legend = this.chart.getLegend(); /* Put legend on the left if appropriate. */ if ((legendPosition.getCurrentIndex() == LEFT) && !legend.getPosition().equals(RectangleEdge.LEFT)) { legend.setPosition(RectangleEdge.LEFT); } /* Put legend on the right if appropriate. */ if ((legendPosition.getCurrentIndex() == RIGHT) && !legend.getPosition().equals(RectangleEdge.RIGHT)) { legend.setPosition(RectangleEdge.RIGHT); } /* Put legend on the top if appropriate. */ if ((legendPosition.getCurrentIndex() == TOP) && !legend.getPosition().equals(RectangleEdge.TOP)) { legend.setPosition(RectangleEdge.TOP); } /* Put legend on the bottom if appropriate. */ if ((legendPosition.getCurrentIndex() == BOTTOM) && !legend.getPosition().equals(RectangleEdge.BOTTOM)) { legend.setPosition(RectangleEdge.BOTTOM); } /* Set legend font. */ if (!legend.getItemFont().equals(legendFont.getFontColorValue().f)) { legend.setItemFont(legendFont.getFontColorValue().f); } /* Set legend font colour. */ if (!legend.getItemPaint().equals(legendFont.getFontColorValue().c)) { legend.setItemPaint(legendFont.getFontColorValue().c); } } super.repaint(); doEnables(); }