Java Code Examples for org.jfree.chart.plot.MeterPlot#addInterval()
The following examples show how to use
org.jfree.chart.plot.MeterPlot#addInterval() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MeterChartTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Draws the chart with a single range. At one point, this caused a null * pointer exception (fixed now). */ public void testDrawWithNullInfo() { boolean success = false; MeterPlot plot = new MeterPlot(new DefaultValueDataset(60.0)); plot.addInterval(new MeterInterval("Normal", new Range(0.0, 80.0))); JFreeChart chart = new JFreeChart(plot); try { BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); success = true; } catch (Exception e) { success = false; } assertTrue(success); }
Example 2
Source File: MeterChartTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Draws the chart with a single range. At one point, this caused a null * pointer exception (fixed now). */ public void testDrawWithNullInfo() { boolean success = false; MeterPlot plot = new MeterPlot(new DefaultValueDataset(60.0)); plot.addInterval(new MeterInterval("Normal", new Range(0.0, 80.0))); JFreeChart chart = new JFreeChart(plot); try { BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); success = true; } catch (Exception e) { success = false; } assertTrue(success); }
Example 3
Source File: MeterChartTest.java From openstock with GNU General Public License v3.0 | 5 votes |
/** * Draws the chart with a single range. At one point, this caused a null * pointer exception (fixed now). */ @Test public void testDrawWithNullInfo() { MeterPlot plot = new MeterPlot(new DefaultValueDataset(60.0)); plot.addInterval(new MeterInterval("Normal", new Range(0.0, 80.0))); JFreeChart chart = new JFreeChart(plot); BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); //FIXME we should really assert a value here }
Example 4
Source File: MeterChartTest.java From ccu-historian with GNU General Public License v3.0 | 5 votes |
/** * Draws the chart with a single range. At one point, this caused a null * pointer exception (fixed now). */ @Test public void testDrawWithNullInfo() { MeterPlot plot = new MeterPlot(new DefaultValueDataset(60.0)); plot.addInterval(new MeterInterval("Normal", new Range(0.0, 80.0))); JFreeChart chart = new JFreeChart(plot); BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); //FIXME we should really assert a value here }
Example 5
Source File: MeterChartTest.java From SIMVA-SoS with Apache License 2.0 | 5 votes |
/** * Draws the chart with a single range. At one point, this caused a null * pointer exception (fixed now). */ @Test public void testDrawWithNullInfo() { MeterPlot plot = new MeterPlot(new DefaultValueDataset(60.0)); plot.addInterval(new MeterInterval("Normal", new Range(0.0, 80.0))); JFreeChart chart = new JFreeChart(plot); BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); //FIXME we should really assert a value here }
Example 6
Source File: DefaultChartService.java From dhis2-core with BSD 3-Clause "New" or "Revised" License | 5 votes |
private JFreeChart getGaugeChart( BaseChart chart, ValueDataset dataSet ) { MeterPlot meterPlot = new MeterPlot( dataSet ); meterPlot.setUnits( "" ); meterPlot.setRange( new Range( 0.0d, 100d ) ); for ( int i = 0; i < 10; i++ ) { double start = i * 10d; double end = start + 10d; String label = String.valueOf( start ); meterPlot.addInterval( new MeterInterval( label, new Range( start, end ), COLOR_LIGHT_GRAY, null, COLOR_LIGHT_GRAY ) ); } meterPlot.setMeterAngle( 180 ); meterPlot.setDialBackgroundPaint( COLOR_LIGHT_GRAY ); meterPlot.setDialShape( DialShape.CHORD ); meterPlot.setNeedlePaint( COLORS[0] ); meterPlot.setTickLabelsVisible( true ); meterPlot.setTickLabelFont( LABEL_FONT ); meterPlot.setTickLabelPaint( Color.BLACK ); meterPlot.setTickPaint( COLOR_LIGHTER_GRAY ); meterPlot.setValueFont( TITLE_FONT ); meterPlot.setValuePaint( Color.BLACK ); JFreeChart meterChart = new JFreeChart( chart.getName(), meterPlot ); setBasicConfig( meterChart, chart ); meterChart.removeLegend(); return meterChart; }
Example 7
Source File: ChartImageGenerator.java From dhis2-core with BSD 3-Clause "New" or "Revised" License | 5 votes |
private JFreeChart getGaugeChart( final Visualization visualization, ValueDataset dataSet ) { MeterPlot meterPlot = new MeterPlot( dataSet ); meterPlot.setUnits( "" ); meterPlot.setRange( new Range( 0.0d, 100d ) ); for ( int i = 0; i < 10; i++ ) { double start = i * 10d; double end = start + 10d; String label = String.valueOf( start ); meterPlot.addInterval( new MeterInterval( label, new Range( start, end ), COLOR_LIGHT_GRAY, null, COLOR_LIGHT_GRAY ) ); } meterPlot.setMeterAngle( 180 ); meterPlot.setDialBackgroundPaint( COLOR_LIGHT_GRAY ); meterPlot.setDialShape( DialShape.CHORD ); meterPlot.setNeedlePaint( COLORS[0] ); meterPlot.setTickLabelsVisible( true ); meterPlot.setTickLabelFont( LABEL_FONT ); meterPlot.setTickLabelPaint( Color.BLACK ); meterPlot.setTickPaint( COLOR_LIGHTER_GRAY ); meterPlot.setValueFont( TITLE_FONT ); meterPlot.setValuePaint( Color.BLACK ); JFreeChart meterChart = new JFreeChart( visualization.getName(), meterPlot ); setBasicConfig( meterChart, visualization ); meterChart.removeLegend(); return meterChart; }
Example 8
Source File: MeterChartTest.java From ECG-Viewer with GNU General Public License v2.0 | 5 votes |
/** * Draws the chart with a single range. At one point, this caused a null * pointer exception (fixed now). */ @Test public void testDrawWithNullInfo() { MeterPlot plot = new MeterPlot(new DefaultValueDataset(60.0)); plot.addInterval(new MeterInterval("Normal", new Range(0.0, 80.0))); JFreeChart chart = new JFreeChart(plot); BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); //FIXME we should really assert a value here }
Example 9
Source File: MeterChartTest.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Draws the chart with a single range. At one point, this caused a null * pointer exception (fixed now). */ @Test public void testDrawWithNullInfo() { MeterPlot plot = new MeterPlot(new DefaultValueDataset(60.0)); plot.addInterval(new MeterInterval("Normal", new Range(0.0, 80.0))); JFreeChart chart = new JFreeChart(plot); BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); //FIXME we should really assert a value here }
Example 10
Source File: Meter.java From Knowage-Server with GNU Affero General Public License v3.0 | 4 votes |
/** * Creates the chart . * * @param chartTitle the chart title. * @param dataset the dataset. * * @return A chart . */ public JFreeChart createChart(DatasetMap datasets) { Dataset dataset=(Dataset)datasets.getDatasets().get("1"); MeterPlot plot = new MeterPlot((ValueDataset)dataset); plot.setRange(new Range(lower, upper)); for (Iterator iterator = intervals.iterator(); iterator.hasNext();) { KpiInterval interval = (KpiInterval) iterator.next(); plot.addInterval(new MeterInterval(interval.getLabel(), new Range(interval.getMin(), interval.getMax()), Color.lightGray, new BasicStroke(2.0f), interval.getColor())); } plot.setNeedlePaint(Color.darkGray); plot.setDialBackgroundPaint(Color.white); plot.setDialOutlinePaint(Color.gray); plot.setDialShape(DialShape.CHORD); plot.setMeterAngle(260); plot.setTickLabelsVisible(true); //set tick label style Font tickLabelsFont = new Font(labelsTickStyle.getFontName(), Font.PLAIN, labelsTickStyle.getSize()); plot.setTickLabelFont(tickLabelsFont); plot.setTickLabelPaint(labelsTickStyle.getColor()); plot.setTickSize(5.0); plot.setTickPaint(Color.lightGray); if(units!=null){ plot.setUnits(units); } plot.setValuePaint(labelsValueStyle.getColor()); plot.setValueFont(new Font(labelsValueStyle.getFontName(), Font.PLAIN, labelsValueStyle.getSize())); JFreeChart chart = new JFreeChart(name, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); chart.setBackgroundPaint(color); TextTitle title = setStyleTitle(name, styleTitle); chart.setTitle(title); if(subName!= null && !subName.equals("")){ TextTitle subTitle =setStyleTitle(subName, styleSubTitle); chart.addSubtitle(subTitle); } return chart; }