Java Code Examples for org.jfree.chart.renderer.LookupPaintScale#add()

The following examples show how to use org.jfree.chart.renderer.LookupPaintScale#add() . 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: XYBlockRendererTest.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Confirm that cloning works.
 */
@Test
public void testCloning() throws CloneNotSupportedException {
    XYBlockRenderer r1 = new XYBlockRenderer();
    LookupPaintScale scale1 = new LookupPaintScale();
    r1.setPaintScale(scale1);
    XYBlockRenderer r2 = (XYBlockRenderer) r1.clone();
    assertTrue(r1 != r2);
    assertTrue(r1.getClass() == r2.getClass());
    assertTrue(r1.equals(r2));

    // check independence
    scale1.add(0.5, Color.red);
    assertFalse(r1.equals(r2));
    LookupPaintScale scale2 = (LookupPaintScale) r2.getPaintScale();
    scale2.add(0.5, Color.red);
    assertTrue(r1.equals(r2));
}
 
Example 2
Source File: XYBlockRendererTest.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Confirm that cloning works.
 */
@Test
public void testCloning() throws CloneNotSupportedException {
    XYBlockRenderer r1 = new XYBlockRenderer();
    LookupPaintScale scale1 = new LookupPaintScale();
    r1.setPaintScale(scale1);
    XYBlockRenderer r2 = (XYBlockRenderer) r1.clone();
    assertTrue(r1 != r2);
    assertTrue(r1.getClass() == r2.getClass());
    assertTrue(r1.equals(r2));

    // check independence
    scale1.add(0.5, Color.red);
    assertFalse(r1.equals(r2));
    LookupPaintScale scale2 = (LookupPaintScale) r2.getPaintScale();
    scale2.add(0.5, Color.red);
    assertTrue(r1.equals(r2));
}
 
Example 3
Source File: XYBlockRendererTest.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Confirm that cloning works.
 */
@Test
public void testCloning() throws CloneNotSupportedException {
    XYBlockRenderer r1 = new XYBlockRenderer();
    LookupPaintScale scale1 = new LookupPaintScale();
    r1.setPaintScale(scale1);
    XYBlockRenderer r2 = (XYBlockRenderer) r1.clone();
    assertTrue(r1 != r2);
    assertTrue(r1.getClass() == r2.getClass());
    assertTrue(r1.equals(r2));

    // check independence
    scale1.add(0.5, Color.red);
    assertFalse(r1.equals(r2));
    LookupPaintScale scale2 = (LookupPaintScale) r2.getPaintScale();
    scale2.add(0.5, Color.red);
    assertTrue(r1.equals(r2));
}
 
Example 4
Source File: ChartJFreeChartOutputHeatmap.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
protected static final LookupPaintScale createLUT(final int ncol, final float vmin, final float vmax,
		final Color start, final Color end) {
	final float[][] colors = new float[][] {
			{ start.getRed() / 255f, start.getGreen() / 255f, start.getBlue() / 255f, start.getAlpha() / 255f },
			{ end.getRed() / 255f, end.getGreen() / 255f, end.getBlue() / 255f, end.getAlpha() / 255f } };
	final float[] limits = new float[] { 0, 1 };
	final LookupPaintScale lut = new LookupPaintScale(vmin, vmax, start);
	float val;
	float r, g, b, a;
	for (int j = 0; j < ncol; j++) {
		val = j / (ncol - 0.99f);
		final int i = 0;
		r = colors[i][0] + (val - limits[i]) / (limits[i + 1] - limits[i]) * (colors[i + 1][0] - colors[i][0]);
		g = colors[i][1] + (val - limits[i]) / (limits[i + 1] - limits[i]) * (colors[i + 1][1] - colors[i][1]);
		b = colors[i][2] + (val - limits[i]) / (limits[i + 1] - limits[i]) * (colors[i + 1][2] - colors[i][2]);
		a = colors[i][3] + (val - limits[i]) / (limits[i + 1] - limits[i]) * (colors[i + 1][3] - colors[i][3]);
		lut.add(val * (vmax - vmin) + vmin, new Color(r, g, b, a));
	}
	return lut;
}
 
Example 5
Source File: XYBlockRendererTest.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Confirm that cloning works.
 */
@Test
public void testCloning() throws CloneNotSupportedException {
    XYBlockRenderer r1 = new XYBlockRenderer();
    LookupPaintScale scale1 = new LookupPaintScale();
    r1.setPaintScale(scale1);
    XYBlockRenderer r2 = (XYBlockRenderer) r1.clone();
    assertTrue(r1 != r2);
    assertTrue(r1.getClass() == r2.getClass());
    assertTrue(r1.equals(r2));

    // check independence
    scale1.add(0.5, Color.red);
    assertFalse(r1.equals(r2));
    LookupPaintScale scale2 = (LookupPaintScale) r2.getPaintScale();
    scale2.add(0.5, Color.red);
    assertTrue(r1.equals(r2));
}
 
Example 6
Source File: XYBlockRendererTest.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Confirm that cloning works.
 */
@Test
public void testCloning() throws CloneNotSupportedException {
    XYBlockRenderer r1 = new XYBlockRenderer();
    LookupPaintScale scale1 = new LookupPaintScale();
    r1.setPaintScale(scale1);
    XYBlockRenderer r2 = (XYBlockRenderer) r1.clone();
    assertTrue(r1 != r2);
    assertTrue(r1.getClass() == r2.getClass());
    assertTrue(r1.equals(r2));

    // check independence
    scale1.add(0.5, Color.red);
    assertFalse(r1.equals(r2));
    LookupPaintScale scale2 = (LookupPaintScale) r2.getPaintScale();
    scale2.add(0.5, Color.red);
    assertTrue(r1.equals(r2));
}
 
Example 7
Source File: ChartJFreeChartOutputHeatmap.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
protected static final LookupPaintScale createLUT(final int ncol, final float vmin, final float vmax,
		final Color start, final Color med, final Color end) {
	final float[][] colors = new float[][] {
			{ start.getRed() / 255f, start.getGreen() / 255f, start.getBlue() / 255f, start.getAlpha() / 255f },
			{ med.getRed() / 255f, med.getGreen() / 255f, med.getBlue() / 255f, med.getAlpha() / 255f },
			{ end.getRed() / 255f, end.getGreen() / 255f, end.getBlue() / 255f, end.getAlpha() / 255f } };
	final float[] limits = new float[] { 0, 0.5f, 1 };
	final LookupPaintScale lut = new LookupPaintScale(vmin, vmax, med);
	float val;
	float r, g, b, a;
	for (int j = 0; j < ncol; j++) {
		val = j / (ncol - 0.99f);
		int i = 0;
		for (i = 0; i < limits.length; i++) {
			if (val < limits[i]) {
				break;
			}
		}
		i = i - 1;
		r = colors[i][0] + (val - limits[i]) / (limits[i + 1] - limits[i]) * (colors[i + 1][0] - colors[i][0]);
		g = colors[i][1] + (val - limits[i]) / (limits[i + 1] - limits[i]) * (colors[i + 1][1] - colors[i][1]);
		b = colors[i][2] + (val - limits[i]) / (limits[i + 1] - limits[i]) * (colors[i + 1][2] - colors[i][2]);
		a = colors[i][3] + (val - limits[i]) / (limits[i + 1] - limits[i]) * (colors[i + 1][3] - colors[i][3]);
		lut.add(val * (vmax - vmin) + vmin, new Color(r, g, b, a));
	}
	return lut;
}
 
Example 8
Source File: LookupPaintScaleTests.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Some general checks for the lookup table.
 */
public void testGeneral() {

    LookupPaintScale s = new LookupPaintScale(0.0, 100.0, Color.black);
    assertEquals(Color.black, s.getPaint(-1.0));
    assertEquals(Color.black, s.getPaint(0.0));
    assertEquals(Color.black, s.getPaint(50.0));
    assertEquals(Color.black, s.getPaint(100.0));
    assertEquals(Color.black, s.getPaint(101.0));

    s.add(50.0, Color.blue);
    assertEquals(Color.black, s.getPaint(-1.0));
    assertEquals(Color.black, s.getPaint(0.0));
    assertEquals(Color.blue, s.getPaint(50.0));
    assertEquals(Color.blue, s.getPaint(100.0));
    assertEquals(Color.black, s.getPaint(101.0));

    s.add(50.0, Color.red);
    assertEquals(Color.black, s.getPaint(-1.0));
    assertEquals(Color.black, s.getPaint(0.0));
    assertEquals(Color.red, s.getPaint(50.0));
    assertEquals(Color.red, s.getPaint(100.0));
    assertEquals(Color.black, s.getPaint(101.0));

    s.add(25.0, Color.green);
    assertEquals(Color.black, s.getPaint(-1.0));
    assertEquals(Color.black, s.getPaint(0.0));
    assertEquals(Color.green, s.getPaint(25.0));
    assertEquals(Color.red, s.getPaint(50.0));
    assertEquals(Color.red, s.getPaint(100.0));
    assertEquals(Color.black, s.getPaint(101.0));

    s.add(75.0, Color.yellow);
    assertEquals(Color.black, s.getPaint(-1.0));
    assertEquals(Color.black, s.getPaint(0.0));
    assertEquals(Color.green, s.getPaint(25.0));
    assertEquals(Color.red, s.getPaint(50.0));
    assertEquals(Color.yellow, s.getPaint(75.0));
    assertEquals(Color.yellow, s.getPaint(100.0));
    assertEquals(Color.black, s.getPaint(101.0));
}
 
Example 9
Source File: LookupPaintScaleTests.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Some general checks for the lookup table.
 */
public void testGeneral() {
    
    LookupPaintScale s = new LookupPaintScale(0.0, 100.0, Color.black);
    assertEquals(Color.black, s.getPaint(-1.0));
    assertEquals(Color.black, s.getPaint(0.0));
    assertEquals(Color.black, s.getPaint(50.0));
    assertEquals(Color.black, s.getPaint(100.0));
    assertEquals(Color.black, s.getPaint(101.0));
    
    s.add(50.0, Color.blue);
    assertEquals(Color.black, s.getPaint(-1.0));
    assertEquals(Color.black, s.getPaint(0.0));
    assertEquals(Color.blue, s.getPaint(50.0));
    assertEquals(Color.blue, s.getPaint(100.0));
    assertEquals(Color.black, s.getPaint(101.0));
    
    s.add(50.0, Color.red);
    assertEquals(Color.black, s.getPaint(-1.0));
    assertEquals(Color.black, s.getPaint(0.0));
    assertEquals(Color.red, s.getPaint(50.0));
    assertEquals(Color.red, s.getPaint(100.0));
    assertEquals(Color.black, s.getPaint(101.0));
    
    s.add(25.0, Color.green);
    assertEquals(Color.black, s.getPaint(-1.0));
    assertEquals(Color.black, s.getPaint(0.0));
    assertEquals(Color.green, s.getPaint(25.0));
    assertEquals(Color.red, s.getPaint(50.0));
    assertEquals(Color.red, s.getPaint(100.0));
    assertEquals(Color.black, s.getPaint(101.0));
    
    s.add(75.0, Color.yellow);
    assertEquals(Color.black, s.getPaint(-1.0));
    assertEquals(Color.black, s.getPaint(0.0));
    assertEquals(Color.green, s.getPaint(25.0));
    assertEquals(Color.red, s.getPaint(50.0));
    assertEquals(Color.yellow, s.getPaint(75.0));
    assertEquals(Color.yellow, s.getPaint(100.0));
    assertEquals(Color.black, s.getPaint(101.0));
}