Java Code Examples for org.jfree.data.xy.DefaultXYZDataset#addSeries()

The following examples show how to use org.jfree.data.xy.DefaultXYZDataset#addSeries() . 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: DefaultXYZDatasetTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Some tests for the addSeries() method.
 */
public void testAddSeries() {
    DefaultXYZDataset d = new DefaultXYZDataset();
    d.addSeries("S1", new double[][] {{1.0}, {2.0}, {3.0}});
    assertEquals(1, d.getSeriesCount());
    assertEquals("S1", d.getSeriesKey(0));
    
    // check that adding a series will overwrite the old series
    d.addSeries("S1", new double[][] {{11.0}, {12.0}, {13.0}});
    assertEquals(1, d.getSeriesCount());
    assertEquals(12.0, d.getYValue(0, 0), EPSILON);
    
    // check null key
    boolean pass = false;
    try
    {
      d.addSeries(null, new double[][] {{1.0}, {2.0}, {3.0}});
    }
    catch (IllegalArgumentException e)
    {
      pass = true;
    }
    assertTrue(pass);
}
 
Example 2
Source File: DefaultXYZDatasetTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
public void testEquals() {
 
    DefaultXYZDataset d1 = new DefaultXYZDataset();
    DefaultXYZDataset d2 = new DefaultXYZDataset();
    assertTrue(d1.equals(d2));
    assertTrue(d2.equals(d1));

    double[] x1 = new double[] {1.0, 2.0, 3.0};
    double[] y1 = new double[] {4.0, 5.0, 6.0};
    double[] z1 = new double[] {7.0, 8.0, 9.0};
    double[][] data1 = new double[][] {x1, y1, z1};
    double[] x2 = new double[] {1.0, 2.0, 3.0};
    double[] y2 = new double[] {4.0, 5.0, 6.0};
    double[] z2 = new double[] {7.0, 8.0, 9.0};
    double[][] data2 = new double[][] {x2, y2, z2};
    d1.addSeries("S1", data1);
    assertFalse(d1.equals(d2));
    d2.addSeries("S1", data2);
    assertTrue(d1.equals(d2));
}
 
Example 3
Source File: DefaultXYZDatasetTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a sample dataset for testing.
 *
 * @return A sample dataset.
 */
public DefaultXYZDataset createSampleDataset1() {
    DefaultXYZDataset d = new DefaultXYZDataset();
    double[] x1 = new double[] {1.0, 2.0, 3.0};
    double[] y1 = new double[] {4.0, 5.0, 6.0};
    double[] z1 = new double[] {7.0, 8.0, 9.0};
    double[][] data1 = new double[][] {x1, y1, z1};
    d.addSeries("S1", data1);

    double[] x2 = new double[] {1.0, 2.0, 3.0};
    double[] y2 = new double[] {4.0, 5.0, 6.0};
    double[] z2 = new double[] {7.0, 8.0, 9.0};
    double[][] data2 = new double[][] {x2, y2, z2};
    d.addSeries("S2", data2);
    return d;
}
 
Example 4
Source File: DefaultXYZDatasetTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Some tests for the addSeries() method.
 */
public void testAddSeries() {
    DefaultXYZDataset d = new DefaultXYZDataset();
    d.addSeries("S1", new double[][] {{1.0}, {2.0}, {3.0}});
    assertEquals(1, d.getSeriesCount());
    assertEquals("S1", d.getSeriesKey(0));

    // check that adding a series will overwrite the old series
    d.addSeries("S1", new double[][] {{11.0}, {12.0}, {13.0}});
    assertEquals(1, d.getSeriesCount());
    assertEquals(12.0, d.getYValue(0, 0), EPSILON);

    // check null key
    boolean pass = false;
    try
    {
      d.addSeries(null, new double[][] {{1.0}, {2.0}, {3.0}});
    }
    catch (IllegalArgumentException e)
    {
      pass = true;
    }
    assertTrue(pass);
}
 
Example 5
Source File: DefaultXYZDatasetTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
public void testEquals() {

    DefaultXYZDataset d1 = new DefaultXYZDataset();
    DefaultXYZDataset d2 = new DefaultXYZDataset();
    assertTrue(d1.equals(d2));
    assertTrue(d2.equals(d1));

    double[] x1 = new double[] {1.0, 2.0, 3.0};
    double[] y1 = new double[] {4.0, 5.0, 6.0};
    double[] z1 = new double[] {7.0, 8.0, 9.0};
    double[][] data1 = new double[][] {x1, y1, z1};
    double[] x2 = new double[] {1.0, 2.0, 3.0};
    double[] y2 = new double[] {4.0, 5.0, 6.0};
    double[] z2 = new double[] {7.0, 8.0, 9.0};
    double[][] data2 = new double[][] {x2, y2, z2};
    d1.addSeries("S1", data1);
    assertFalse(d1.equals(d2));
    d2.addSeries("S1", data2);
    assertTrue(d1.equals(d2));
}
 
Example 6
Source File: ConvertChartContext.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
private XYZDataset createXyzDataset()
{
	if (sampleXyzDataset == null)
	{
		DefaultXYZDataset dataset = new DefaultXYZDataset(); 
		
		dataset.addSeries(
			"First", 
			new double[][]{ 
				{2.1, 2.3, 2.3, 2.2, 2.2, 1.8, 1.8, 1.9, 2.3, 3.8}, 
				{14.1, 11.1, 10.0, 8.8, 8.7, 8.4, 5.4, 4.1, 4.1, 25}, 
				{2.4, 2.7, 2.7, 2.2, 2.2, 2.2, 2.1, 2.2, 1.6, 4}
				}
			);
		
		sampleXyzDataset = dataset;
	}
	
	return sampleXyzDataset;
}
 
Example 7
Source File: DefaultXYZDatasetTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a sample dataset for testing.
 * 
 * @return A sample dataset.
 */
public DefaultXYZDataset createSampleDataset1() {
    DefaultXYZDataset d = new DefaultXYZDataset();
    double[] x1 = new double[] {1.0, 2.0, 3.0};
    double[] y1 = new double[] {4.0, 5.0, 6.0};
    double[] z1 = new double[] {7.0, 8.0, 9.0};
    double[][] data1 = new double[][] {x1, y1, z1};
    d.addSeries("S1", data1);
    
    double[] x2 = new double[] {1.0, 2.0, 3.0};
    double[] y2 = new double[] {4.0, 5.0, 6.0};
    double[] z2 = new double[] {7.0, 8.0, 9.0};
    double[][] data2 = new double[][] {x2, y2, z2};
    d.addSeries("S2", data2);
    return d;
}
 
Example 8
Source File: LegacyChartType.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
private XYZDataset createXYZDataset() {
  final DefaultXYZDataset xyzDataset = new DefaultXYZDataset();
  final double bs = 3;
  xyzDataset
    .addSeries( "First", new double[][] { { 1, 2, 3 }, { 2, 1, 3 }, { 0.1 * bs, 0.2 * bs, 0.1 * bs } } );// NON-NLS
  xyzDataset
    .addSeries( "Second", new double[][] { { 1, 2, 3 }, { 3, 0, 1 }, { 0.2 * bs, 0.1 * bs, 0.15 * bs } } );// NON-NLS
  return xyzDataset;
}
 
Example 9
Source File: XYShapeRendererTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check if finding the bounds in z-dimension of an XYZDataset works. 
 */
public void testFindZBounds() {
    XYShapeRenderer r = new XYShapeRenderer();
    assertNull(r.findZBounds(null));

    DefaultXYZDataset dataset = new DefaultXYZDataset();
    Range range;

    double data1[][] = { {1,1,1}, {1,1,1}, {1,2,3} };
    dataset.addSeries("series1", data1);
    range = r.findZBounds(dataset);
    assertNotNull(range);
    assertEquals(1d, range.getLowerBound(), EPSILON);
    assertEquals(3d, range.getUpperBound(), EPSILON);

    double data2[][] = { {1,1,1}, {1,1,1}, {-1,-2,-3} };
    dataset.removeSeries("series1");
    dataset.addSeries("series2", data2);
    range = r.findZBounds(dataset);
    assertNotNull(range);
    assertEquals(-3d, range.getLowerBound(), EPSILON);
    assertEquals(-1d, range.getUpperBound(), EPSILON);

    double data3[][] = { {1,1,1}, {1,1,1}, {-1.2,2.9,3.8} };
    dataset.removeSeries("series2");
    dataset.addSeries("series3", data3);
    range = r.findZBounds(dataset);
    assertNotNull(range);
    assertEquals(-1.2d, range.getLowerBound(), EPSILON);
    assertEquals(3.8d, range.getUpperBound(), EPSILON);
}
 
Example 10
Source File: XYShapeRendererTest.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Check if finding the bounds in z-dimension of an XYZDataset works. 
 */
public void testFindZBounds() {
    XYShapeRenderer r = new XYShapeRenderer();
    assertNull(r.findZBounds(null));

    DefaultXYZDataset dataset = new DefaultXYZDataset();
    Range range;

    double data1[][] = { {1,1,1}, {1,1,1}, {1,2,3} };
    dataset.addSeries("series1", data1);
    range = r.findZBounds(dataset);
    assertNotNull(range);
    assertEquals(1d, range.getLowerBound(), EPSILON);
    assertEquals(3d, range.getUpperBound(), EPSILON);

    double data2[][] = { {1,1,1}, {1,1,1}, {-1,-2,-3} };
    dataset.removeSeries("series1");
    dataset.addSeries("series2", data2);
    range = r.findZBounds(dataset);
    assertNotNull(range);
    assertEquals(-3d, range.getLowerBound(), EPSILON);
    assertEquals(-1d, range.getUpperBound(), EPSILON);

    double data3[][] = { {1,1,1}, {1,1,1}, {-1.2,2.9,3.8} };
    dataset.removeSeries("series2");
    dataset.addSeries("series3", data3);
    range = r.findZBounds(dataset);
    assertNotNull(range);
    assertEquals(-1.2d, range.getLowerBound(), EPSILON);
    assertEquals(3.8d, range.getUpperBound(), EPSILON);
}
 
Example 11
Source File: XYShapeRendererTest.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Check if finding the bounds in z-dimension of an XYZDataset works. 
 */
public void testFindZBounds() {
    XYShapeRenderer r = new XYShapeRenderer();
    assertNull(r.findZBounds(null));

    DefaultXYZDataset dataset = new DefaultXYZDataset();
    Range range;

    double data1[][] = { {1,1,1}, {1,1,1}, {1,2,3} };
    dataset.addSeries("series1", data1);
    range = r.findZBounds(dataset);
    assertNotNull(range);
    assertEquals(1d, range.getLowerBound(), EPSILON);
    assertEquals(3d, range.getUpperBound(), EPSILON);

    double data2[][] = { {1,1,1}, {1,1,1}, {-1,-2,-3} };
    dataset.removeSeries("series1");
    dataset.addSeries("series2", data2);
    range = r.findZBounds(dataset);
    assertNotNull(range);
    assertEquals(-3d, range.getLowerBound(), EPSILON);
    assertEquals(-1d, range.getUpperBound(), EPSILON);

    double data3[][] = { {1,1,1}, {1,1,1}, {-1.2,2.9,3.8} };
    dataset.removeSeries("series2");
    dataset.addSeries("series3", data3);
    range = r.findZBounds(dataset);
    assertNotNull(range);
    assertEquals(-1.2d, range.getLowerBound(), EPSILON);
    assertEquals(3.8d, range.getUpperBound(), EPSILON);
}
 
Example 12
Source File: XYShapeRendererTest.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Check if finding the bounds in z-dimension of an XYZDataset works. 
 */
public void testFindZBounds() {
    XYShapeRenderer r = new XYShapeRenderer();
    assertNull(r.findZBounds(null));

    DefaultXYZDataset dataset = new DefaultXYZDataset();
    Range range;

    double data1[][] = { {1,1,1}, {1,1,1}, {1,2,3} };
    dataset.addSeries("series1", data1);
    range = r.findZBounds(dataset);
    assertNotNull(range);
    assertEquals(1d, range.getLowerBound(), EPSILON);
    assertEquals(3d, range.getUpperBound(), EPSILON);

    double data2[][] = { {1,1,1}, {1,1,1}, {-1,-2,-3} };
    dataset.removeSeries("series1");
    dataset.addSeries("series2", data2);
    range = r.findZBounds(dataset);
    assertNotNull(range);
    assertEquals(-3d, range.getLowerBound(), EPSILON);
    assertEquals(-1d, range.getUpperBound(), EPSILON);

    double data3[][] = { {1,1,1}, {1,1,1}, {-1.2,2.9,3.8} };
    dataset.removeSeries("series2");
    dataset.addSeries("series3", data3);
    range = r.findZBounds(dataset);
    assertNotNull(range);
    assertEquals(-1.2d, range.getLowerBound(), EPSILON);
    assertEquals(3.8d, range.getUpperBound(), EPSILON);
}
 
Example 13
Source File: XYShapeRendererTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Check if finding the bounds in z-dimension of an XYZDataset works. 
 */
public void testFindZBounds() {
    XYShapeRenderer r = new XYShapeRenderer();
    assertNull(r.findZBounds(null));

    DefaultXYZDataset dataset = new DefaultXYZDataset();
    Range range;

    double data1[][] = { {1,1,1}, {1,1,1}, {1,2,3} };
    dataset.addSeries("series1", data1);
    range = r.findZBounds(dataset);
    assertNotNull(range);
    assertEquals(1d, range.getLowerBound(), EPSILON);
    assertEquals(3d, range.getUpperBound(), EPSILON);

    double data2[][] = { {1,1,1}, {1,1,1}, {-1,-2,-3} };
    dataset.removeSeries("series1");
    dataset.addSeries("series2", data2);
    range = r.findZBounds(dataset);
    assertNotNull(range);
    assertEquals(-3d, range.getLowerBound(), EPSILON);
    assertEquals(-1d, range.getUpperBound(), EPSILON);

    double data3[][] = { {1,1,1}, {1,1,1}, {-1.2,2.9,3.8} };
    dataset.removeSeries("series2");
    dataset.addSeries("series3", data3);
    range = r.findZBounds(dataset);
    assertNotNull(range);
    assertEquals(-1.2d, range.getLowerBound(), EPSILON);
    assertEquals(3.8d, range.getUpperBound(), EPSILON);
}
 
Example 14
Source File: XYBubbleRendererTest.java    From SIMVA-SoS with Apache License 2.0 4 votes vote down vote up
/**
 * A check for the datasetIndex and seriesIndex fields in the LegendItem
 * returned by the getLegendItem() method.
 */
@Test
public void testGetLegendItemSeriesIndex() {
    DefaultXYZDataset d1 = new DefaultXYZDataset();
    double[] x = {2.1, 2.3, 2.3, 2.2, 2.2, 1.8, 1.8, 1.9, 2.3, 3.8};
    double[] y = {14.1, 11.1, 10.0, 8.8, 8.7, 8.4, 5.4, 4.1, 4.1, 25};
    double[] z = {2.4, 2.7, 2.7, 2.2, 2.2, 2.2, 2.1, 2.2, 1.6, 4};
    double[][] s1 = new double[][] {x, y, z};
    d1.addSeries("S1", s1);
    x = new double[] {2.1};
    y = new double[] {14.1};
    z = new double[] {2.4};
    double[][] s2 = new double[][] {x, y, z};
    d1.addSeries("S2", s2);

    DefaultXYZDataset d2 = new DefaultXYZDataset();
    x = new double[] {2.1};
    y = new double[] {14.1};
    z = new double[] {2.4};
    double[][] s3 = new double[][] {x, y, z};
    d2.addSeries("S3", s3);
    x = new double[] {2.1};
    y = new double[] {14.1};
    z = new double[] {2.4};
    double[][] s4 = new double[][] {x, y, z};
    d2.addSeries("S4", s4);
    x = new double[] {2.1};
    y = new double[] {14.1};
    z = new double[] {2.4};
    double[][] s5 = new double[][] {x, y, z};
    d2.addSeries("S5", s5);

    XYBubbleRenderer r = new XYBubbleRenderer();
    XYPlot plot = new XYPlot(d1, new NumberAxis("x"),
            new NumberAxis("y"), r);
    plot.setDataset(1, d2);
    /*JFreeChart chart =*/ new JFreeChart(plot);
    LegendItem li = r.getLegendItem(1, 2);
    assertEquals("S5", li.getLabel());
    assertEquals(1, li.getDatasetIndex());
    assertEquals(2, li.getSeriesIndex());
}
 
Example 15
Source File: XYBubbleRendererTests.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * A check for the datasetIndex and seriesIndex fields in the LegendItem
 * returned by the getLegendItem() method.
 */
public void testGetLegendItemSeriesIndex() {
    DefaultXYZDataset d1 = new DefaultXYZDataset();
    double[] x = {2.1, 2.3, 2.3, 2.2, 2.2, 1.8, 1.8, 1.9, 2.3, 3.8};
    double[] y = {14.1, 11.1, 10.0, 8.8, 8.7, 8.4, 5.4, 4.1, 4.1, 25};
    double[] z = {2.4, 2.7, 2.7, 2.2, 2.2, 2.2, 2.1, 2.2, 1.6, 4};
    double[][] s1 = new double[][] {x, y, z};
    d1.addSeries("S1", s1);
    x = new double[] {2.1};
    y = new double[] {14.1};
    z = new double[] {2.4};
    double[][] s2 = new double[][] {x, y, z};
    d1.addSeries("S2", s2);

    DefaultXYZDataset d2 = new DefaultXYZDataset();
    x = new double[] {2.1};
    y = new double[] {14.1};
    z = new double[] {2.4};
    double[][] s3 = new double[][] {x, y, z};
    d2.addSeries("S3", s3);
    x = new double[] {2.1};
    y = new double[] {14.1};
    z = new double[] {2.4};
    double[][] s4 = new double[][] {x, y, z};
    d2.addSeries("S4", s4);
    x = new double[] {2.1};
    y = new double[] {14.1};
    z = new double[] {2.4};
    double[][] s5 = new double[][] {x, y, z};
    d2.addSeries("S5", s5);

    XYBubbleRenderer r = new XYBubbleRenderer();
    XYPlot plot = new XYPlot(d1, new NumberAxis("x"),
            new NumberAxis("y"), r);
    plot.setDataset(1, d2);
    /*JFreeChart chart =*/ new JFreeChart(plot);
    LegendItem li = r.getLegendItem(1, 2);
    assertEquals("S5", li.getLabel());
    assertEquals(1, li.getDatasetIndex());
    assertEquals(2, li.getSeriesIndex());
}
 
Example 16
Source File: XYBubbleRendererTest.java    From ccu-historian with GNU General Public License v3.0 4 votes vote down vote up
/**
 * A check for the datasetIndex and seriesIndex fields in the LegendItem
 * returned by the getLegendItem() method.
 */
@Test
public void testGetLegendItemSeriesIndex() {
    DefaultXYZDataset d1 = new DefaultXYZDataset();
    double[] x = {2.1, 2.3, 2.3, 2.2, 2.2, 1.8, 1.8, 1.9, 2.3, 3.8};
    double[] y = {14.1, 11.1, 10.0, 8.8, 8.7, 8.4, 5.4, 4.1, 4.1, 25};
    double[] z = {2.4, 2.7, 2.7, 2.2, 2.2, 2.2, 2.1, 2.2, 1.6, 4};
    double[][] s1 = new double[][] {x, y, z};
    d1.addSeries("S1", s1);
    x = new double[] {2.1};
    y = new double[] {14.1};
    z = new double[] {2.4};
    double[][] s2 = new double[][] {x, y, z};
    d1.addSeries("S2", s2);

    DefaultXYZDataset d2 = new DefaultXYZDataset();
    x = new double[] {2.1};
    y = new double[] {14.1};
    z = new double[] {2.4};
    double[][] s3 = new double[][] {x, y, z};
    d2.addSeries("S3", s3);
    x = new double[] {2.1};
    y = new double[] {14.1};
    z = new double[] {2.4};
    double[][] s4 = new double[][] {x, y, z};
    d2.addSeries("S4", s4);
    x = new double[] {2.1};
    y = new double[] {14.1};
    z = new double[] {2.4};
    double[][] s5 = new double[][] {x, y, z};
    d2.addSeries("S5", s5);

    XYBubbleRenderer r = new XYBubbleRenderer();
    XYPlot plot = new XYPlot(d1, new NumberAxis("x"),
            new NumberAxis("y"), r);
    plot.setDataset(1, d2);
    /*JFreeChart chart =*/ new JFreeChart(plot);
    LegendItem li = r.getLegendItem(1, 2);
    assertEquals("S5", li.getLabel());
    assertEquals(1, li.getDatasetIndex());
    assertEquals(2, li.getSeriesIndex());
}
 
Example 17
Source File: BlockChart.java    From Knowage-Server with GNU Affero General Public License v3.0 4 votes vote down vote up
public DatasetMap calculateValue() throws Exception {
	logger.debug("IN");
	
	
	
	String res=DataSetAccessFunctions.getDataSetResultFromId(profile, getData(),parametersObject);

	// XYZDataset dataset = createDataset();
	int xMaxValue = (new Integer(xrangeMax)).intValue();
	int xMinValue = (new Integer(xrangeMin)).intValue();
	int yMaxValue = (new Integer(yrangeMax)).intValue();
	int yMinValue = (new Integer(yrangeMin)).intValue();
	int blockWidth =(new Integer(blockW)).intValue();
	int blockHeight =	(new Integer(blockH)).intValue();


	SourceBean sbRows=SourceBean.fromXMLString(res);
	List listAtts=sbRows.getAttributeAsList("ROW");

	DefaultXYZDataset dataset = new DefaultXYZDataset();
	int rangex = (xMaxValue-xMinValue)/blockWidth;
	int rangey = (yMaxValue-yMinValue)/blockHeight;
	
	double[] xvalues = new double[rangey * rangex];
       double[] yvalues = new double[rangey * rangex];        
       double[] zvalues = new double[rangey * rangex];
       
       
       double[][] data = new double[][] {xvalues, yvalues, zvalues};
       
       int xVal = 0;
       int yVal = 0;
	int col = 0;
	int row = 0;
	int cell = 0;
	double zVal = 0;
	
	boolean first=true;
	
	
   	for (int r = yMinValue/blockHeight; r < rangey; r++)  {
		for (int c = xMinValue/blockWidth; c < rangex; c ++) {
           	
           	cell = c+r+(r*(rangex-1));
           	data[0][cell] = (new Double(((c+1)*blockWidth)).doubleValue())-(new Double(blockWidth).doubleValue()/2);
   			data[1][cell] = (new Double(((r+1)*blockHeight)).doubleValue())-(new Double(blockHeight).doubleValue()/2);
   			data[2][cell] = (new Double(zrangeMax)).doubleValue()*2;
           }
       }
	
	for (Iterator iterator = listAtts.iterator(); iterator.hasNext();) {
		SourceBean category = (SourceBean) iterator.next();
		List atts=category.getContainedAttributes();

		String nameP="";
		String value="";
		
		
		for (Iterator iterator2 = atts.iterator(); iterator2.hasNext();) {
			SourceBeanAttribute object = (SourceBeanAttribute) iterator2.next();

			nameP=new String(object.getKey());
			value=new String((String)object.getValue());
			if(nameP.equalsIgnoreCase("x"))
			{						
					xVal = new Double(value).intValue();	
					col = (xVal/blockWidth)-1;
			}
			if(nameP.equalsIgnoreCase("y"))
			{
				    yVal = new Double(value).intValue();	
				    row = (yVal/blockHeight)-1;
			}
			if(nameP.equalsIgnoreCase("z"))
			{
					zVal = new Double(value).doubleValue();				
			}			    
		   
			
			}
		cell=col+row+(row*(rangex-1));
		if((rangex*rangey)> cell){
			data[0][cell] = xVal-(new Double(blockWidth).doubleValue()/2);
			data[1][cell] = yVal-(new Double(blockHeight).doubleValue()/2);
			data[2][cell] = zVal;				
			  // setValueInData(data, xMaxValue , yMinValue, xVal, yVal, zVal);
		}
		
		}
		
       dataset.addSeries("Series 1", data);
       
       //XYZDataset dataset = createDataset();
       
	DatasetMap datasets=new DatasetMap();
	datasets.addDataset("1",dataset);
	logger.debug("OUT");
	return datasets;
}
 
Example 18
Source File: SimpleBlockChart.java    From Knowage-Server with GNU Affero General Public License v3.0 4 votes vote down vote up
public DatasetMap calculateValue() throws Exception {
	logger.debug("IN");
	String res=DataSetAccessFunctions.getDataSetResultFromId(profile, getData(),parametersObject);

	SourceBean sbRows=SourceBean.fromXMLString(res);
	List listAtts=sbRows.getAttributeAsList("ROW");


	DefaultXYZDataset dataset = new DefaultXYZDataset();
	int length = listAtts != null ? listAtts.size() : 0;

	double[] xvalues = new double[length];
	double[] yvalues = new double[length];        
	double[] zvalues = new double[length];

	double[][] data = new double[][] {xvalues, yvalues, zvalues};

	double xVal = 0;
	double yVal = 0;
	double zVal = 0;

	boolean first=true;
	int cont = 0;

	for (Iterator iterator = listAtts.iterator(); iterator.hasNext();) {
		SourceBean category = (SourceBean) iterator.next();
		List atts=category.getContainedAttributes();

		String nameP="";
		String value="";
		xVal = 0;
		yVal = 0;
		zVal = 0;
		for (Iterator iterator2 = atts.iterator(); iterator2.hasNext();) {
			SourceBeanAttribute object = (SourceBeanAttribute) iterator2.next();

			nameP=new String(object.getKey());
			value=new String((String)object.getValue());
			if(nameP.equalsIgnoreCase("x"))
			{						
				xVal = new Double(value).doubleValue();	
				xvalues[cont] = xVal;
			}
			if(nameP.equalsIgnoreCase("y"))
			{
				yVal = new Double(value).doubleValue();	
				yvalues[cont] = yVal;
			}
			if(nameP.equalsIgnoreCase("z"))
			{
				zVal = new Double(value).doubleValue();				
				zvalues[cont] = zVal;

				if(minScaleValue == null ) minScaleValue = zVal;
				if(maxScaleValue == null ) maxScaleValue = zVal;
				if(zVal<minScaleValue){
					minScaleValue = zVal;
				}
				if(zVal>maxScaleValue){
					maxScaleValue = zVal;
				}				
			}			    
		}
		cont++;	
	}


	dataset.addSeries("Series 1", data);

	//XYZDataset dataset = createDataset();

	DatasetMap datasets=new DatasetMap();
	datasets.addDataset("1",dataset);
	logger.debug("OUT");
	return datasets;
}
 
Example 19
Source File: XYBubbleRendererTests.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * A check for the datasetIndex and seriesIndex fields in the LegendItem
 * returned by the getLegendItem() method.
 */
public void testGetLegendItemSeriesIndex() {
    DefaultXYZDataset d1 = new DefaultXYZDataset(); 
    double[] x = {2.1, 2.3, 2.3, 2.2, 2.2, 1.8, 1.8, 1.9, 2.3, 3.8};
    double[] y = {14.1, 11.1, 10.0, 8.8, 8.7, 8.4, 5.4, 4.1, 4.1, 25};
    double[] z = {2.4, 2.7, 2.7, 2.2, 2.2, 2.2, 2.1, 2.2, 1.6, 4};
    double[][] s1 = new double[][] { x, y, z };
    d1.addSeries("S1", s1);
    x = new double[] {2.1};
    y = new double[] {14.1};
    z = new double[] {2.4};
    double[][] s2 = new double[][] { x, y, z };
    d1.addSeries("S2", s2);
    
    DefaultXYZDataset d2 = new DefaultXYZDataset(); 
    x = new double[] {2.1};
    y = new double[] {14.1};
    z = new double[] {2.4};
    double[][] s3 = new double[][] { x, y, z };
    d2.addSeries("S3", s3);
    x = new double[] {2.1};
    y = new double[] {14.1};
    z = new double[] {2.4};
    double[][] s4 = new double[][] { x, y, z };
    d2.addSeries("S4", s4);
    x = new double[] {2.1};
    y = new double[] {14.1};
    z = new double[] {2.4};
    double[][] s5 = new double[][] { x, y, z };
    d2.addSeries("S5", s5);

    XYBubbleRenderer r = new XYBubbleRenderer();
    XYPlot plot = new XYPlot(d1, new NumberAxis("x"),
            new NumberAxis("y"), r);
    plot.setDataset(1, d2);
    /*JFreeChart chart =*/ new JFreeChart(plot);
    LegendItem li = r.getLegendItem(1, 2);
    assertEquals("S5", li.getLabel());
    assertEquals(1, li.getDatasetIndex());
    assertEquals(2, li.getSeriesIndex());
}
 
Example 20
Source File: XYBubbleRendererTest.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
 * A check for the datasetIndex and seriesIndex fields in the LegendItem
 * returned by the getLegendItem() method.
 */
@Test
public void testGetLegendItemSeriesIndex() {
    DefaultXYZDataset d1 = new DefaultXYZDataset();
    double[] x = {2.1, 2.3, 2.3, 2.2, 2.2, 1.8, 1.8, 1.9, 2.3, 3.8};
    double[] y = {14.1, 11.1, 10.0, 8.8, 8.7, 8.4, 5.4, 4.1, 4.1, 25};
    double[] z = {2.4, 2.7, 2.7, 2.2, 2.2, 2.2, 2.1, 2.2, 1.6, 4};
    double[][] s1 = new double[][] {x, y, z};
    d1.addSeries("S1", s1);
    x = new double[] {2.1};
    y = new double[] {14.1};
    z = new double[] {2.4};
    double[][] s2 = new double[][] {x, y, z};
    d1.addSeries("S2", s2);

    DefaultXYZDataset d2 = new DefaultXYZDataset();
    x = new double[] {2.1};
    y = new double[] {14.1};
    z = new double[] {2.4};
    double[][] s3 = new double[][] {x, y, z};
    d2.addSeries("S3", s3);
    x = new double[] {2.1};
    y = new double[] {14.1};
    z = new double[] {2.4};
    double[][] s4 = new double[][] {x, y, z};
    d2.addSeries("S4", s4);
    x = new double[] {2.1};
    y = new double[] {14.1};
    z = new double[] {2.4};
    double[][] s5 = new double[][] {x, y, z};
    d2.addSeries("S5", s5);

    XYBubbleRenderer r = new XYBubbleRenderer();
    XYPlot plot = new XYPlot(d1, new NumberAxis("x"),
            new NumberAxis("y"), r);
    plot.setDataset(1, d2);
    /*JFreeChart chart =*/ new JFreeChart(plot);
    LegendItem li = r.getLegendItem(1, 2);
    assertEquals("S5", li.getLabel());
    assertEquals(1, li.getDatasetIndex());
    assertEquals(2, li.getSeriesIndex());
}