org.jfree.chart.renderer.category.DefaultCategoryItemRenderer Java Examples

The following examples show how to use org.jfree.chart.renderer.category.DefaultCategoryItemRenderer. 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: CategoryPlotTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Some tests for the getRangeAxisForDataset() method.
 */
@Test
public void testGetRangeAxisForDataset() {
    CategoryDataset dataset = new DefaultCategoryDataset();
    CategoryAxis xAxis = new CategoryAxis("X");
    NumberAxis yAxis = new NumberAxis("Y");
    CategoryItemRenderer renderer = new DefaultCategoryItemRenderer();
    CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);
    assertEquals(yAxis, plot.getRangeAxisForDataset(0));

    // should get IllegalArgumentException for negative index
    boolean pass = false;
    try {
        plot.getRangeAxisForDataset(-1);
    }
    catch (IllegalArgumentException e) {
        pass = true;
    }
    assertTrue(pass);

    // if multiple axes are mapped, the first in the list should be
    // returned...
    NumberAxis yAxis2 = new NumberAxis("Y2");
    plot.setRangeAxis(1, yAxis2);
    assertEquals(yAxis, plot.getRangeAxisForDataset(0));

    plot.mapDatasetToRangeAxis(0, 1);
    assertEquals(yAxis2, plot.getRangeAxisForDataset(0));

    List axisIndices = Arrays.asList(new Integer[] {new Integer(0),
            new Integer(1)});
    plot.mapDatasetToRangeAxes(0, axisIndices);
    assertEquals(yAxis, plot.getRangeAxisForDataset(0));

    axisIndices = Arrays.asList(new Integer[] {new Integer(1),
            new Integer(2)});
    plot.mapDatasetToRangeAxes(0, axisIndices);
    assertEquals(yAxis2, plot.getRangeAxisForDataset(0));
}
 
Example #2
Source File: CategoryPlotTest.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Some tests for the getRangeAxisForDataset() method.
 */
@Test
public void testGetRangeAxisForDataset() {
    CategoryDataset dataset = new DefaultCategoryDataset();
    CategoryAxis xAxis = new CategoryAxis("X");
    NumberAxis yAxis = new NumberAxis("Y");
    CategoryItemRenderer renderer = new DefaultCategoryItemRenderer();
    CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);
    assertEquals(yAxis, plot.getRangeAxisForDataset(0));

    // should get IllegalArgumentException for negative index
    boolean pass = false;
    try {
        plot.getRangeAxisForDataset(-1);
    }
    catch (IllegalArgumentException e) {
        pass = true;
    }
    assertTrue(pass);

    // if multiple axes are mapped, the first in the list should be
    // returned...
    NumberAxis yAxis2 = new NumberAxis("Y2");
    plot.setRangeAxis(1, yAxis2);
    assertEquals(yAxis, plot.getRangeAxisForDataset(0));

    plot.mapDatasetToRangeAxis(0, 1);
    assertEquals(yAxis2, plot.getRangeAxisForDataset(0));

    List axisIndices = Arrays.asList(new Integer[] {new Integer(0),
            new Integer(1)});
    plot.mapDatasetToRangeAxes(0, axisIndices);
    assertEquals(yAxis, plot.getRangeAxisForDataset(0));

    axisIndices = Arrays.asList(new Integer[] {new Integer(1),
            new Integer(2)});
    plot.mapDatasetToRangeAxes(0, axisIndices);
    assertEquals(yAxis2, plot.getRangeAxisForDataset(0));
}
 
Example #3
Source File: CategoryPlotTest.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Some tests for the getRangeAxisForDataset() method.
 */
@Test
public void testGetRangeAxisForDataset() {
    CategoryDataset dataset = new DefaultCategoryDataset();
    CategoryAxis xAxis = new CategoryAxis("X");
    NumberAxis yAxis = new NumberAxis("Y");
    CategoryItemRenderer renderer = new DefaultCategoryItemRenderer();
    CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);
    assertEquals(yAxis, plot.getRangeAxisForDataset(0));

    // should get IllegalArgumentException for negative index
    boolean pass = false;
    try {
        plot.getRangeAxisForDataset(-1);
    }
    catch (IllegalArgumentException e) {
        pass = true;
    }
    assertTrue(pass);

    // if multiple axes are mapped, the first in the list should be
    // returned...
    NumberAxis yAxis2 = new NumberAxis("Y2");
    plot.setRangeAxis(1, yAxis2);
    assertEquals(yAxis, plot.getRangeAxisForDataset(0));

    plot.mapDatasetToRangeAxis(0, 1);
    assertEquals(yAxis2, plot.getRangeAxisForDataset(0));

    List axisIndices = Arrays.asList(new Integer[] {new Integer(0),
            new Integer(1)});
    plot.mapDatasetToRangeAxes(0, axisIndices);
    assertEquals(yAxis, plot.getRangeAxisForDataset(0));

    axisIndices = Arrays.asList(new Integer[] {new Integer(1),
            new Integer(2)});
    plot.mapDatasetToRangeAxes(0, axisIndices);
    assertEquals(yAxis2, plot.getRangeAxisForDataset(0));
}
 
Example #4
Source File: CategoryPlotTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some tests for the getRangeAxisForDataset() method.
 */
@Test
public void testGetRangeAxisForDataset() {
    CategoryDataset dataset = new DefaultCategoryDataset();
    CategoryAxis xAxis = new CategoryAxis("X");
    NumberAxis yAxis = new NumberAxis("Y");
    CategoryItemRenderer renderer = new DefaultCategoryItemRenderer();
    CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);
    assertEquals(yAxis, plot.getRangeAxisForDataset(0));

    // should get IllegalArgumentException for negative index
    boolean pass = false;
    try {
        plot.getRangeAxisForDataset(-1);
    }
    catch (IllegalArgumentException e) {
        pass = true;
    }
    assertTrue(pass);

    // if multiple axes are mapped, the first in the list should be
    // returned...
    NumberAxis yAxis2 = new NumberAxis("Y2");
    plot.setRangeAxis(1, yAxis2);
    assertEquals(yAxis, plot.getRangeAxisForDataset(0));

    plot.mapDatasetToRangeAxis(0, 1);
    assertEquals(yAxis2, plot.getRangeAxisForDataset(0));

    List axisIndices = Arrays.asList(new Integer[] {new Integer(0),
            new Integer(1)});
    plot.mapDatasetToRangeAxes(0, axisIndices);
    assertEquals(yAxis, plot.getRangeAxisForDataset(0));

    axisIndices = Arrays.asList(new Integer[] {new Integer(1),
            new Integer(2)});
    plot.mapDatasetToRangeAxes(0, axisIndices);
    assertEquals(yAxis2, plot.getRangeAxisForDataset(0));
}
 
Example #5
Source File: DefaultCategoryItemRendererTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Two objects that are equal are required to return the same hashCode.
 */
public void testHashcode() {
    DefaultCategoryItemRenderer r1 = new DefaultCategoryItemRenderer();
    DefaultCategoryItemRenderer r2 = new DefaultCategoryItemRenderer();
    assertTrue(r1.equals(r2));
    int h1 = r1.hashCode();
    int h2 = r2.hashCode();
    assertEquals(h1, h2);
}
 
Example #6
Source File: CategoryPlotTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Some tests for the getRangeAxisForDataset() method.
 */
public void testGetRangeAxisForDataset() {
    CategoryDataset dataset = new DefaultCategoryDataset();
    CategoryAxis xAxis = new CategoryAxis("X");
    NumberAxis yAxis = new NumberAxis("Y");
    CategoryItemRenderer renderer = new DefaultCategoryItemRenderer();
    CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);
    assertEquals(yAxis, plot.getRangeAxisForDataset(0));

    // should get IllegalArgumentException for negative index
    boolean pass = false;
    try {
        plot.getRangeAxisForDataset(-1);
    }
    catch (IllegalArgumentException e) {
        pass = true;
    }
    assertTrue(pass);

    // if multiple axes are mapped, the first in the list should be
    // returned...
    NumberAxis yAxis2 = new NumberAxis("Y2");
    plot.setRangeAxis(1, yAxis2);
    assertEquals(yAxis, plot.getRangeAxisForDataset(0));

    plot.mapDatasetToRangeAxis(0, 1);
    assertEquals(yAxis2, plot.getRangeAxisForDataset(0));

    List axisIndices = Arrays.asList(new Integer[] {new Integer(0),
            new Integer(1)});
    plot.mapDatasetToRangeAxes(0, axisIndices);
    assertEquals(yAxis, plot.getRangeAxisForDataset(0));

    axisIndices = Arrays.asList(new Integer[] {new Integer(1),
            new Integer(2)});
    plot.mapDatasetToRangeAxes(0, axisIndices);
    assertEquals(yAxis2, plot.getRangeAxisForDataset(0));
}
 
Example #7
Source File: DefaultCategoryItemRendererTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Two objects that are equal are required to return the same hashCode. 
 */
public void testHashcode() {
    DefaultCategoryItemRenderer r1 = new DefaultCategoryItemRenderer();
    DefaultCategoryItemRenderer r2 = new DefaultCategoryItemRenderer();
    assertTrue(r1.equals(r2));
    int h1 = r1.hashCode();
    int h2 = r2.hashCode();
    assertEquals(h1, h2);
}
 
Example #8
Source File: CategoryPlotTest.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Some tests for the getRangeAxisForDataset() method.
 */
@Test
public void testGetRangeAxisForDataset() {
    CategoryDataset dataset = new DefaultCategoryDataset();
    CategoryAxis xAxis = new CategoryAxis("X");
    NumberAxis yAxis = new NumberAxis("Y");
    CategoryItemRenderer renderer = new DefaultCategoryItemRenderer();
    CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);
    assertEquals(yAxis, plot.getRangeAxisForDataset(0));

    // should get IllegalArgumentException for negative index
    boolean pass = false;
    try {
        plot.getRangeAxisForDataset(-1);
    }
    catch (IllegalArgumentException e) {
        pass = true;
    }
    assertTrue(pass);

    // if multiple axes are mapped, the first in the list should be
    // returned...
    NumberAxis yAxis2 = new NumberAxis("Y2");
    plot.setRangeAxis(1, yAxis2);
    assertEquals(yAxis, plot.getRangeAxisForDataset(0));

    plot.mapDatasetToRangeAxis(0, 1);
    assertEquals(yAxis2, plot.getRangeAxisForDataset(0));

    List axisIndices = Arrays.asList(new Integer[] {new Integer(0),
            new Integer(1)});
    plot.mapDatasetToRangeAxes(0, axisIndices);
    assertEquals(yAxis, plot.getRangeAxisForDataset(0));

    axisIndices = Arrays.asList(new Integer[] {new Integer(1),
            new Integer(2)});
    plot.mapDatasetToRangeAxes(0, axisIndices);
    assertEquals(yAxis2, plot.getRangeAxisForDataset(0));
}
 
Example #9
Source File: ExpressionProfile.java    From chipster with MIT License 5 votes vote down vote up
private CategoryItemRenderer createRenderer(List<ProfileRow> rows){
	// create renderer
       DefaultCategoryItemRenderer renderer = new DefaultCategoryItemRenderer();        
       renderer.setToolTipGenerator(new StandardCategoryToolTipGenerator());
       renderer.setShapesVisible(false);
       
       // generate colors
       Collections.sort(rows);
	float position = 0.0f;
	float step = 1.0f / ((float)rows.size());
		
	for (ProfileRow row : rows) {
		if(selectedIndexes.contains(row.series)){
			renderer.setSeriesPaint(row.series, Color.black);
		} else {
			row.color = getColor(position);
			renderer.setSeriesPaint(row.series, getColor(position));
		}
		position += step;
	}
	
	//List isn't initialised, if visualising clustered profiles
	if(list != null){
		list.setSelectedRows(selectedIndexes, this, false, data);
	}
	
	return renderer;
}
 
Example #10
Source File: DefaultCategoryItemRendererTests.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Check that the equals() method distinguishes all fields.
 */
public void testEquals() {
    DefaultCategoryItemRenderer r1 = new DefaultCategoryItemRenderer();
    DefaultCategoryItemRenderer r2 = new DefaultCategoryItemRenderer();
    assertEquals(r1, r2);
}
 
Example #11
Source File: DefaultCategoryItemRendererTests.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Check that this class implements PublicCloneable.
 */
public void testPublicCloneable() {
    DefaultCategoryItemRenderer r1 = new DefaultCategoryItemRenderer();
    assertTrue(r1 instanceof PublicCloneable);
}
 
Example #12
Source File: DefaultCategoryItemRendererTests.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Check that the equals() method distinguishes all fields.
 */
public void testEquals() {
    DefaultCategoryItemRenderer r1 = new DefaultCategoryItemRenderer();
    DefaultCategoryItemRenderer r2 = new DefaultCategoryItemRenderer();
    assertEquals(r1, r2);
}