org.jfree.data.general.DefaultValueDataset Java Examples

The following examples show how to use org.jfree.data.general.DefaultValueDataset. 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: PanamaHitek_SingleDialChart.java    From PanamaHitek_Arduino with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void buildChart1() {
    setColorLimits();
    dataset = new DefaultValueDataset(10D);
    JFreeChart jfreechart = createStandardDialChart(chartTitle, variableName, dataset, chartBottonLimit, chartTopLimit, majorDivisions, minorDivisions);
    DialPlot dialplot = (DialPlot) jfreechart.getPlot();
    StandardDialRange standarddialrange = new StandardDialRange(redBottomLimit, redTopLimit, Color.red);
    standarddialrange.setInnerRadius(0.522D);
    standarddialrange.setOuterRadius(0.554D);
    dialplot.addLayer(standarddialrange);
    StandardDialRange standarddialrange1 = new StandardDialRange(yellowBottomLimit, yellowTopLimit, Color.orange);
    standarddialrange1.setInnerRadius(0.522D);
    standarddialrange1.setOuterRadius(0.554D);
    dialplot.addLayer(standarddialrange1);
    StandardDialRange standarddialrange2 = new StandardDialRange(greenBottomLimit, greenTopLimit, Color.green);
    standarddialrange2.setInnerRadius(0.522D);
    standarddialrange2.setOuterRadius(0.554D);
    dialplot.addLayer(standarddialrange2);
    GradientPaint gradientpaint = new GradientPaint(new Point(), new Color(255, 255, 255), new Point(), new Color(170, 170, 220));
    DialBackground dialbackground = new DialBackground(gradientpaint);
    dialbackground.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.VERTICAL));
    dialplot.setBackground(dialbackground);
    dialplot.removePointer(0);
    org.jfree.chart.plot.dial.DialPointer.Pointer pointer = new org.jfree.chart.plot.dial.DialPointer.Pointer();
    dialplot.addPointer(pointer);
    add(new ChartPanel(jfreechart));
}
 
Example #2
Source File: PanamaHitek_SingleDialChart.java    From PanamaHitek_Arduino with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void buildChart2() {
    dataset = new DefaultValueDataset(0);
    DialPlot dialplot = new DialPlot();
    dialplot.setView(0.20D, 0.0D, 0.6D, 0.3D);
    dialplot.setDataset(dataset);
    ArcDialFrame arcdialframe = new ArcDialFrame(60D, 60D);
    arcdialframe.setInnerRadius(0.6D);
    arcdialframe.setOuterRadius(0.9D);
    arcdialframe.setForegroundPaint(Color.darkGray);
    arcdialframe.setStroke(new BasicStroke(3F));
    dialplot.setDialFrame(arcdialframe);
    GradientPaint gradientpaint = new GradientPaint(new Point(), new Color(255, 255, 255), new Point(), new Color(240, 240, 240));
    DialBackground dialbackground = new DialBackground(gradientpaint);
    dialbackground.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.VERTICAL));
    dialplot.addLayer(dialbackground);
    StandardDialScale standarddialscale = new StandardDialScale(chartBottonLimit, chartTopLimit, 115D, -50D, majorDivisions, minorDivisions);
    standarddialscale.setTickRadius(0.88D);
    standarddialscale.setTickLabelOffset(0.07D);
    dialplot.addScale(0, standarddialscale);
    org.jfree.chart.plot.dial.DialPointer.Pin pin = new org.jfree.chart.plot.dial.DialPointer.Pin();
    pin.setRadius(0.8D);
    dialplot.addLayer(pin);
    JFreeChart jfreechart = new JFreeChart(dialplot);
    jfreechart.setTitle(chartTitle);
    add(new ChartPanel(jfreechart));
}
 
Example #3
Source File: MeterChartTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 #4
Source File: UnitStatusPage.java    From freeacs with MIT License 6 votes vote down vote up
/**
 * Gets the overall status speedometer.
 *
 * @param startTms the start tms
 * @param endTms the end tms
 * @param unitId the unit id
 * @param res the res
 * @param session the session
 * @throws Exception the exception
 */
public void getOverallStatusSpeedometer(
    String startTms, String endTms, String unitId, HttpServletResponse res, HttpSession session)
    throws Exception {
  Date fromDate = DateUtils.parseDateDefault(startTms);
  Date toDate = DateUtils.parseDateDefault(endTms);
  Unit unit =
      ACSLoader.getACSUnit(session.getId(), mainDataSource, mainDataSource).getUnitById(unitId);
  UnitStatusInfo info =
      UnitStatusInfo.getUnitStatusInfo(
          unit, fromDate, toDate, session.getId(), mainDataSource, mainDataSource);
  JFreeChart chart =
      createStatusDialChart(
          null,
          "Overall status",
          new DefaultValueDataset(info.getOverallStatus().getStatus()),
          UnitStatusInfo.OVERALL_STATUS_MIN,
          UnitStatusInfo.OVERALL_STATUS_MAX);
  byte[] image = getReportChartImageBytes(null, chart, 380, 380);
  Output.writeImageBytesToResponse(image, res);
}
 
Example #5
Source File: MeterChartTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 #6
Source File: PanamaHitek_ThermometerChart.java    From PanamaHitek_Arduino with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void buildPlot1() {
    setColorLimits();
    dataset = new DefaultValueDataset(30);
    ThermometerPlot thermometerplot = new ThermometerPlot(dataset);
    thermometerplot.setRange(plotBottonLimit, plotTopLimit);
    thermometerplot.setUnits(ThermometerPlot.UNITS_CELCIUS);
    thermometerplot.setSubrange(0, greenBottomLimit, greenTopLimit);
    thermometerplot.setSubrangePaint(0, Color.green);
    thermometerplot.setSubrange(1, yellowBottomLimit, yellowTopLimit);
    thermometerplot.setSubrangePaint(1, Color.yellow);
    thermometerplot.setSubrange(2, redBottomLimit, redTopLimit);
    thermometerplot.setSubrangePaint(2, Color.red);
    JFreeChart jfreechart = new JFreeChart(plotTitle, thermometerplot);
    ChartUtilities.applyCurrentTheme(jfreechart);
    add(new ChartPanel(jfreechart));
}
 
Example #7
Source File: MeterChartTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 #8
Source File: CompassPlotTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Confirm that cloning works.
 */
@Test
public void testCloning() throws CloneNotSupportedException {
    CompassPlot p1 = new CompassPlot(new DefaultValueDataset(15.0));
    CompassPlot p2 = (CompassPlot) p1.clone();
    assertTrue(p1 != p2);
    assertTrue(p1.getClass() == p2.getClass());
    assertTrue(p1.equals(p2));
}
 
Example #9
Source File: JThermometer.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Default constructor.
 */
public JThermometer() {
    super(new CardLayout());
    this.plot.setInsets(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    this.data = new DefaultValueDataset();
    this.plot.setDataset(this.data);
    this.chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT,
            this.plot, false);
    this.panel = new ChartPanel(this.chart);
    add(this.panel, "Panel");
    setBackground(getBackground());
}
 
Example #10
Source File: CompassPlotTest.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Confirm that cloning works.
 */
@Test
public void testCloning() throws CloneNotSupportedException {
    CompassPlot p1 = new CompassPlot(new DefaultValueDataset(15.0));
    CompassPlot p2 = (CompassPlot) p1.clone();
    assertTrue(p1 != p2);
    assertTrue(p1.getClass() == p2.getClass());
    assertTrue(p1.equals(p2));
}
 
Example #11
Source File: MeterPlotTest.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Serialize an instance, restore it, and check for equality.
 */
@Test
public void testSerialization2() {
    MeterPlot p1 = new MeterPlot(new DefaultValueDataset(1.23));
    MeterPlot p2 = (MeterPlot) TestUtilities.serialised(p1);
    assertEquals(p1, p2);

}
 
Example #12
Source File: MeterChartTest.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * 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 #13
Source File: JThermometer.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Default constructor.
 */
public JThermometer() {
    super(new CardLayout());
    this.plot.setInsets(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    this.data = new DefaultValueDataset();
    this.plot.setDataset(this.data);
    this.chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT,
            this.plot, false);
    this.panel = new ChartPanel(this.chart);
    add(this.panel, "Panel");
    setBackground(getBackground());
}
 
Example #14
Source File: CompassPlotTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Confirm that cloning works.
 */
@Test
public void testCloning() throws CloneNotSupportedException {
    CompassPlot p1 = new CompassPlot(new DefaultValueDataset(15.0));
    CompassPlot p2 = (CompassPlot) p1.clone();
    assertTrue(p1 != p2);
    assertTrue(p1.getClass() == p2.getClass());
    assertTrue(p1.equals(p2));
}
 
Example #15
Source File: PanamaHitek_SingleDialChart.java    From PanamaHitek_Arduino with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void buildChart3() {
    dataset = new DefaultValueDataset(0);
    DialPlot dialplot = new DialPlot();
    dialplot.setView(0.78D, 0.37D, 0.22D, 0.26D);
    dialplot.setDataset(dataset);
    ArcDialFrame arcdialframe = new ArcDialFrame(-10D, 20D);
    arcdialframe.setInnerRadius(0.7D);
    arcdialframe.setOuterRadius(0.9D);
    arcdialframe.setForegroundPaint(Color.darkGray);
    arcdialframe.setStroke(new BasicStroke(3F));
    dialplot.setDialFrame(arcdialframe);
    GradientPaint gradientpaint = new GradientPaint(new Point(), new Color(255, 255, 255), new Point(), new Color(240, 240, 240));
    DialBackground dialbackground = new DialBackground(gradientpaint);
    dialbackground.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.VERTICAL));
    dialplot.addLayer(dialbackground);
    StandardDialScale standarddialscale = new StandardDialScale(chartBottonLimit, chartTopLimit, -8D, 16D, majorDivisions, minorDivisions);
    standarddialscale.setTickRadius(0.8D);
    standarddialscale.setTickLabelOffset(-0.041D);
    standarddialscale.setTickLabelFont(new Font("Dialog", 0, 14));
    dialplot.addScale(0, standarddialscale);
    org.jfree.chart.plot.dial.DialPointer.Pin pin = new org.jfree.chart.plot.dial.DialPointer.Pin();
    pin.setRadius(0.84D);
    dialplot.addLayer(pin);
    JFreeChart jfreechart = new JFreeChart(dialplot);
    jfreechart.setTitle(chartTitle);
    add(new ChartPanel(jfreechart));
}
 
Example #16
Source File: CompassPlotTest.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Confirm that cloning works.
 */
@Test
public void testCloning() throws CloneNotSupportedException {
    CompassPlot p1 = new CompassPlot(new DefaultValueDataset(15.0));
    CompassPlot p2 = (CompassPlot) p1.clone();
    assertTrue(p1 != p2);
    assertTrue(p1.getClass() == p2.getClass());
    assertTrue(p1.equals(p2));
}
 
Example #17
Source File: DialCharts.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
public DatasetMap calculateValue() throws Exception{
	logger.debug("IN");
	String res=DataSetAccessFunctions.getDataSetResultFromId(profile, getData(),parametersObject);
	if (res!=null){
		logger.debug("Dataset result:"+res);
		SourceBean sbRows=SourceBean.fromXMLString(res);
		SourceBean sbRow=(SourceBean)sbRows.getAttribute("ROW");
		String result="";
		if(sbRow==null){
			result=(new Double(lower)).toString();
		}
		else{
			List atts=sbRow.getContainedAttributes();
			if (name.indexOf("$F{") >= 0){
				logger.debug("name: " + name);
				setTitleParameter(atts);
			}
			if (getSubName()!= null && getSubName().indexOf("$F") >= 0){
				setSubTitleParameter(atts);
			}
			result=(String)sbRow.getAttribute("value");
		}
		DefaultValueDataset dataset = new DefaultValueDataset(Double.valueOf(result));
		logger.debug("OUT");

		DatasetMap datasets=new DatasetMap();
		datasets.addDataset("1",dataset);
		return datasets;		
	}
	logger.error("dataset is null!!!!!!!!!");
	return null;
}
 
Example #18
Source File: MeterPlotTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Serialize an instance, restore it, and check for equality.
 */
@Test
public void testSerialization2() {
    MeterPlot p1 = new MeterPlot(new DefaultValueDataset(1.23));
    MeterPlot p2 = (MeterPlot) TestUtilities.serialised(p1);
    assertEquals(p1, p2);

}
 
Example #19
Source File: MeterPlotTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Serialize an instance, restore it, and check for equality.
 */
@Test
public void testSerialization2() {
    MeterPlot p1 = new MeterPlot(new DefaultValueDataset(1.23));
    MeterPlot p2 = (MeterPlot) TestUtilities.serialised(p1);
    assertEquals(p1, p2);

}
 
Example #20
Source File: JThermometer.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Default constructor.
 */
public JThermometer() {
    super(new CardLayout());
    this.plot.setInsets(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    this.data = new DefaultValueDataset();
    this.plot.setDataset(this.data);
    this.chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT,
            this.plot, false);
    this.panel = new ChartPanel(this.chart);
    add(this.panel, "Panel");
    setBackground(getBackground());
}
 
Example #21
Source File: CompassPlotTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Confirm that cloning works.
 */
public void testCloning() {
    CompassPlot p1 = new CompassPlot(new DefaultValueDataset(15.0));
    CompassPlot p2 = null;
    try {
        p2 = (CompassPlot) p1.clone();
    }
    catch (CloneNotSupportedException e) {
        e.printStackTrace();
    }
    assertTrue(p1 != p2);
    assertTrue(p1.getClass() == p2.getClass());
    assertTrue(p1.equals(p2));
}
 
Example #22
Source File: CompassPlotTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Confirm that cloning works.
 */
public void testCloning() {
    CompassPlot p1 = new CompassPlot(new DefaultValueDataset(15.0));
    CompassPlot p2 = null;
    try {
        p2 = (CompassPlot) p1.clone();
    }
    catch (CloneNotSupportedException e) {
        e.printStackTrace();
    }
    assertTrue(p1 != p2);
    assertTrue(p1.getClass() == p2.getClass());
    assertTrue(p1.equals(p2));
}
 
Example #23
Source File: JThermometer.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Default constructor.
 */
public JThermometer() {
    super(new CardLayout());
    this.plot.setInsets(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    this.data = new DefaultValueDataset();
    this.plot.setDataset(this.data);
    this.chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, 
            this.plot, false);
    this.panel = new ChartPanel(this.chart);
    add(this.panel, "Panel");
    setBackground(getBackground());
}
 
Example #24
Source File: JThermometer.java    From opensim-gui with Apache License 2.0 5 votes vote down vote up
/**
 * Default constructor.
 */
public JThermometer() {
    super(new CardLayout());
    this.plot.setInsets(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    this.data = new DefaultValueDataset();
    this.plot.setDataset(this.data);
    this.chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, 
            this.plot, false);
    this.panel = new ChartPanel(this.chart);
    add(this.panel, "Panel");
    setBackground(getBackground());
}
 
Example #25
Source File: ValueDataSetCollector.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected void buildDataset() {
  final DefaultValueDataset localValueDataset = (DefaultValueDataset) getDataSet();

  final Object valueObject = getDataRow().get( getValueColumn() );
  final Number value = ( valueObject instanceof Number ) ? (Number) valueObject : null;
  final Number existingValue = CollectorFunctionUtil.queryExistingValueFromDataSet( localValueDataset );
  if ( existingValue != null ) {
    if ( value != null ) {
      localValueDataset.setValue( CollectorFunctionUtil.add( existingValue, value ) );
    }
  } else {
    localValueDataset.setValue( value );
  }
}
 
Example #26
Source File: MeterChartTest.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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 #27
Source File: MeterPlotTest.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Serialize an instance, restore it, and check for equality.
 */
@Test
public void testSerialization2() {
    MeterPlot p1 = new MeterPlot(new DefaultValueDataset(1.23));
    MeterPlot p2 = (MeterPlot) TestUtilities.serialised(p1);
    assertEquals(p1, p2);

}
 
Example #28
Source File: CompassPlotTest.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Confirm that cloning works.
 */
@Test
public void testCloning() throws CloneNotSupportedException {
    CompassPlot p1 = new CompassPlot(new DefaultValueDataset(15.0));
    CompassPlot p2 = (CompassPlot) p1.clone();
    assertTrue(p1 != p2);
    assertTrue(p1.getClass() == p2.getClass());
    assertTrue(p1.equals(p2));
}
 
Example #29
Source File: JThermometer.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Default constructor.
 */
public JThermometer() {
    super(new CardLayout());
    this.plot.setInsets(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    this.data = new DefaultValueDataset();
    this.plot.setDataset(this.data);
    this.chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT,
            this.plot, false);
    this.panel = new ChartPanel(this.chart);
    add(this.panel, "Panel");
    setBackground(getBackground());
}
 
Example #30
Source File: JThermometer.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Default constructor.
 */
public JThermometer() {
    super(new CardLayout());
    this.plot.setInsets(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    this.data = new DefaultValueDataset();
    this.plot.setDataset(this.data);
    this.chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT,
            this.plot, false);
    this.panel = new ChartPanel(this.chart);
    add(this.panel, "Panel");
    setBackground(getBackground());
}