Search in sources :

Example 1 with StandardGradientPaintTransformer

use of org.jfree.ui.StandardGradientPaintTransformer in project hmftools by hartwigmedical.

the class GradientBarCustomizer method customizeRenderer.

private void customizeRenderer(@NotNull final BarRenderer renderer) {
    renderer.setShadowPaint(Color.LIGHT_GRAY);
    renderer.setShadowVisible(true);
    renderer.setSeriesPaint(0, gradientPaint());
    renderer.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.HORIZONTAL));
}
Also used : StandardGradientPaintTransformer(org.jfree.ui.StandardGradientPaintTransformer)

Example 2 with StandardGradientPaintTransformer

use of org.jfree.ui.StandardGradientPaintTransformer in project bamboobsc by billchen198318.

the class CommonMeterChartAction method fillChart.

private void fillChart(String title, float value, int lowerBound, int upperBound) throws Exception {
    DefaultValueDataset dataset = new DefaultValueDataset();
    dataset.setValue(value);
    DialPlot plot = new DialPlot();
    plot.setView(0.0d, 0.0d, 1.0d, 1.0d);
    plot.setDataset(0, dataset);
    StandardDialFrame frame = new StandardDialFrame();
    plot.setDialFrame(frame);
    DialBackground dialBackground = new DialBackground();
    dialBackground.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.VERTICAL));
    plot.setBackground(dialBackground);
    DialTextAnnotation textAnnotation = new DialTextAnnotation(title);
    textAnnotation.setRadius(0.555555555555555555D);
    plot.addLayer(textAnnotation);
    DialValueIndicator valueIndicator = new DialValueIndicator(0);
    plot.addLayer(valueIndicator);
    StandardDialScale scale1 = new StandardDialScale();
    scale1.setLowerBound(lowerBound);
    scale1.setUpperBound(upperBound);
    // -120
    scale1.setStartAngle(-140);
    // -300D 
    scale1.setExtent(-260D);
    scale1.setTickRadius(0.88D);
    scale1.setTickLabelOffset(0.14999999999999999D);
    scale1.setTickLabelFont(new Font("", Font.TRUETYPE_FONT, 14));
    plot.addScale(0, scale1);
    StandardDialRange standarddialrange0 = new StandardDialRange(lowerBound, (upperBound * 0.6), Color.red);
    standarddialrange0.setInnerRadius(0.52000000000000002D);
    standarddialrange0.setOuterRadius(0.55000000000000004D);
    plot.addLayer(standarddialrange0);
    StandardDialRange standarddialrange1 = new StandardDialRange((upperBound * 0.6), (upperBound * 0.8), Color.orange);
    standarddialrange1.setInnerRadius(0.52000000000000002D);
    standarddialrange1.setOuterRadius(0.55000000000000004D);
    plot.addLayer(standarddialrange1);
    StandardDialRange standarddialrange2 = new StandardDialRange((upperBound * 0.8), upperBound, Color.green);
    standarddialrange2.setInnerRadius(0.52000000000000002D);
    standarddialrange2.setOuterRadius(0.55000000000000004D);
    plot.addLayer(standarddialrange2);
    Pointer pointer = new Pointer(0);
    pointer.setFillPaint(new Color(144, 196, 246));
    plot.addPointer(pointer);
    plot.mapDatasetToScale(0, 0);
    DialCap dialcap = new DialCap();
    dialcap.setRadius(0.0700000000000001D);
    plot.setCap(dialcap);
    this.chart = new JFreeChart(plot);
    //this.chart.setBackgroundPaint(new Color(234, 244, 253));
    this.chart.setBackgroundPaint(Color.white);
}
Also used : DefaultValueDataset(org.jfree.data.general.DefaultValueDataset) StandardDialFrame(org.jfree.chart.plot.dial.StandardDialFrame) DialBackground(org.jfree.chart.plot.dial.DialBackground) StandardGradientPaintTransformer(org.jfree.ui.StandardGradientPaintTransformer) Color(java.awt.Color) Pointer(org.jfree.chart.plot.dial.DialPointer.Pointer) DialPlot(org.jfree.chart.plot.dial.DialPlot) DialTextAnnotation(org.jfree.chart.plot.dial.DialTextAnnotation) Font(java.awt.Font) JFreeChart(org.jfree.chart.JFreeChart) StandardDialScale(org.jfree.chart.plot.dial.StandardDialScale) DialValueIndicator(org.jfree.chart.plot.dial.DialValueIndicator) StandardDialRange(org.jfree.chart.plot.dial.StandardDialRange) DialCap(org.jfree.chart.plot.dial.DialCap)

Example 3 with StandardGradientPaintTransformer

use of org.jfree.ui.StandardGradientPaintTransformer in project SIMVA-SoS by SESoS.

the class LegendItemTest method testEquals.

/**
 * Confirm that the equals method can distinguish all the required fields.
 */
@Test
public void testEquals() {
    LegendItem item1 = new LegendItem("Label", "Description", "ToolTip", "URL", true, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), true, Color.red, true, Color.blue, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.green);
    LegendItem item2 = new LegendItem("Label", "Description", "ToolTip", "URL", true, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), true, Color.red, true, Color.blue, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.green);
    assertEquals(item1, item2);
    assertEquals(item2, item1);
    item1 = new LegendItem("Label2", "Description", "ToolTip", "URL", true, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), true, Color.red, true, Color.blue, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.green);
    assertFalse(item1.equals(item2));
    item2 = new LegendItem("Label2", "Description", "ToolTip", "URL", true, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), true, Color.red, true, Color.blue, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.green);
    assertEquals(item1, item2);
    item1 = new LegendItem("Label2", "Description2", "ToolTip", "URL", true, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), true, Color.red, true, Color.blue, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.green);
    assertFalse(item1.equals(item2));
    item2 = new LegendItem("Label2", "Description2", "ToolTip", "URL", true, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), true, Color.red, true, Color.blue, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.green);
    assertEquals(item1, item2);
    item1 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), true, Color.red, true, Color.blue, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.green);
    assertFalse(item1.equals(item2));
    item2 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), true, Color.red, true, Color.blue, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.green);
    assertEquals(item1, item2);
    item1 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), true, Color.red, true, Color.blue, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.green);
    assertFalse(item1.equals(item2));
    item2 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), true, Color.red, true, Color.blue, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.green);
    assertEquals(item1, item2);
    item1 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.red, true, Color.blue, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.green);
    assertFalse(item1.equals(item2));
    item2 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.red, true, Color.blue, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.green);
    assertEquals(item1, item2);
    item1 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.black, true, Color.blue, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.green);
    assertFalse(item1.equals(item2));
    item2 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.black, true, Color.blue, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.green);
    assertEquals(item1, item2);
    item1 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.black, false, Color.blue, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.green);
    assertFalse(item1.equals(item2));
    item2 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.black, false, Color.blue, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.green);
    assertEquals(item1, item2);
    item1 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.black, false, Color.yellow, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.green);
    assertFalse(item1.equals(item2));
    item2 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.black, false, Color.yellow, new BasicStroke(1.2f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.green);
    assertEquals(item1, item2);
    item1 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.black, false, Color.yellow, new BasicStroke(2.1f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.green);
    assertFalse(item1.equals(item2));
    item2 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.black, false, Color.yellow, new BasicStroke(2.1f), true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.green);
    assertEquals(item1, item2);
    item1 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.black, false, Color.yellow, new BasicStroke(2.1f), false, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.green);
    assertFalse(item1.equals(item2));
    item2 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.black, false, Color.yellow, new BasicStroke(2.1f), false, new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), Color.green);
    assertEquals(item1, item2);
    item1 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.black, false, Color.yellow, new BasicStroke(2.1f), false, new Line2D.Double(4.0, 3.0, 2.0, 1.0), new BasicStroke(2.1f), Color.green);
    assertFalse(item1.equals(item2));
    item2 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.black, false, Color.yellow, new BasicStroke(2.1f), false, new Line2D.Double(4.0, 3.0, 2.0, 1.0), new BasicStroke(2.1f), Color.green);
    assertEquals(item1, item2);
    item1 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.black, false, Color.yellow, new BasicStroke(2.1f), false, new Line2D.Double(4.0, 3.0, 2.0, 1.0), new BasicStroke(3.3f), Color.green);
    assertFalse(item1.equals(item2));
    item2 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.black, false, Color.yellow, new BasicStroke(2.1f), false, new Line2D.Double(4.0, 3.0, 2.0, 1.0), new BasicStroke(3.3f), Color.green);
    assertEquals(item1, item2);
    item1 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.black, false, Color.yellow, new BasicStroke(2.1f), false, new Line2D.Double(4.0, 3.0, 2.0, 1.0), new BasicStroke(3.3f), Color.white);
    assertFalse(item1.equals(item2));
    item2 = new LegendItem("Label2", "Description2", "ToolTip", "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, Color.black, false, Color.yellow, new BasicStroke(2.1f), false, new Line2D.Double(4.0, 3.0, 2.0, 1.0), new BasicStroke(3.3f), Color.white);
    assertEquals(item1, item2);
    // fillPaintTransformer
    item1.setFillPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_VERTICAL));
    assertFalse(item1.equals(item2));
    item2.setFillPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_VERTICAL));
    assertEquals(item1, item2);
    // labelFont
    item1.setLabelFont(new Font("Dialog", Font.PLAIN, 13));
    assertFalse(item1.equals(item2));
    item2.setLabelFont(new Font("Dialog", Font.PLAIN, 13));
    assertEquals(item1, item2);
    // labelPaint
    item1.setLabelPaint(Color.red);
    assertFalse(item1.equals(item2));
    item2.setLabelPaint(Color.red);
    assertEquals(item1, item2);
    // fillPaint
    item1.setFillPaint(new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.blue));
    assertFalse(item1.equals(item2));
    item2.setFillPaint(new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.blue));
    assertEquals(item1, item2);
    // outlinePaint
    item1.setOutlinePaint(new GradientPaint(1.1f, 2.2f, Color.green, 3.3f, 4.4f, Color.blue));
    assertFalse(item1.equals(item2));
    item2.setOutlinePaint(new GradientPaint(1.1f, 2.2f, Color.green, 3.3f, 4.4f, Color.blue));
    assertEquals(item1, item2);
    // linePaint
    item1.setLinePaint(new GradientPaint(0.1f, 0.2f, Color.green, 0.3f, 0.4f, Color.blue));
    assertFalse(item1.equals(item2));
    item2.setLinePaint(new GradientPaint(0.1f, 0.2f, Color.green, 0.3f, 0.4f, Color.blue));
    assertEquals(item1, item2);
}
Also used : BasicStroke(java.awt.BasicStroke) StandardGradientPaintTransformer(org.jfree.ui.StandardGradientPaintTransformer) Rectangle2D(java.awt.geom.Rectangle2D) GradientPaint(java.awt.GradientPaint) Line2D(java.awt.geom.Line2D) Font(java.awt.Font) Test(org.junit.Test)

Example 4 with StandardGradientPaintTransformer

use of org.jfree.ui.StandardGradientPaintTransformer in project SIMVA-SoS by SESoS.

the class BarRendererTest method testEquals.

/**
 * Test that the equals() method distinguishes all fields.
 */
@Test
public void testEquals() {
    BarRenderer r1 = new BarRenderer();
    BarRenderer r2 = new BarRenderer();
    assertTrue(r1.equals(r2));
    assertTrue(r2.equals(r1));
    // base value
    r1.setBase(0.123);
    assertFalse(r1.equals(r2));
    r2.setBase(0.123);
    assertTrue(r1.equals(r2));
    // itemMargin
    r1.setItemMargin(0.22);
    assertFalse(r1.equals(r2));
    r2.setItemMargin(0.22);
    assertTrue(r1.equals(r2));
    // drawBarOutline
    r1.setDrawBarOutline(!r1.isDrawBarOutline());
    assertFalse(r1.equals(r2));
    r2.setDrawBarOutline(!r2.isDrawBarOutline());
    assertTrue(r1.equals(r2));
    // maximumBarWidth
    r1.setMaximumBarWidth(0.11);
    assertFalse(r1.equals(r2));
    r2.setMaximumBarWidth(0.11);
    assertTrue(r1.equals(r2));
    // minimumBarLength
    r1.setMinimumBarLength(0.04);
    assertFalse(r1.equals(r2));
    r2.setMinimumBarLength(0.04);
    assertTrue(r1.equals(r2));
    // gradientPaintTransformer
    r1.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_VERTICAL));
    assertFalse(r1.equals(r2));
    r2.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_VERTICAL));
    assertTrue(r1.equals(r2));
    // positiveItemLabelPositionFallback
    r1.setPositiveItemLabelPositionFallback(new ItemLabelPosition(ItemLabelAnchor.INSIDE1, TextAnchor.CENTER));
    assertFalse(r1.equals(r2));
    r2.setPositiveItemLabelPositionFallback(new ItemLabelPosition(ItemLabelAnchor.INSIDE1, TextAnchor.CENTER));
    assertTrue(r1.equals(r2));
    // negativeItemLabelPositionFallback
    r1.setNegativeItemLabelPositionFallback(new ItemLabelPosition(ItemLabelAnchor.INSIDE1, TextAnchor.CENTER));
    assertFalse(r1.equals(r2));
    r2.setNegativeItemLabelPositionFallback(new ItemLabelPosition(ItemLabelAnchor.INSIDE1, TextAnchor.CENTER));
    assertTrue(r1.equals(r2));
    // barPainter
    r1.setBarPainter(new GradientBarPainter(0.1, 0.2, 0.3));
    assertFalse(r1.equals(r2));
    r2.setBarPainter(new GradientBarPainter(0.1, 0.2, 0.3));
    assertTrue(r1.equals(r2));
    // shadowsVisible
    r1.setShadowVisible(false);
    assertFalse(r1.equals(r2));
    r2.setShadowVisible(false);
    assertTrue(r1.equals(r2));
    r1.setShadowPaint(Color.red);
    assertFalse(r1.equals(r2));
    r2.setShadowPaint(Color.red);
    assertTrue(r1.equals(r2));
    // shadowXOffset
    r1.setShadowXOffset(3.3);
    assertFalse(r1.equals(r2));
    r2.setShadowXOffset(3.3);
    assertTrue(r1.equals(r2));
    // shadowYOffset
    r1.setShadowYOffset(3.3);
    assertFalse(r1.equals(r2));
    r2.setShadowYOffset(3.3);
    assertTrue(r1.equals(r2));
}
Also used : StandardGradientPaintTransformer(org.jfree.ui.StandardGradientPaintTransformer) ItemLabelPosition(org.jfree.chart.labels.ItemLabelPosition) Test(org.junit.Test)

Example 5 with StandardGradientPaintTransformer

use of org.jfree.ui.StandardGradientPaintTransformer in project SIMVA-SoS by SESoS.

the class DialBackgroundTest method testEquals.

/**
 * Confirm that the equals method can distinguish all the required fields.
 */
@Test
public void testEquals() {
    DialBackground b1 = new DialBackground();
    DialBackground b2 = new DialBackground();
    assertTrue(b1.equals(b2));
    // paint
    b1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow));
    assertFalse(b1.equals(b2));
    b2.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow));
    assertTrue(b1.equals(b2));
    // gradient paint transformer
    b1.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_VERTICAL));
    assertFalse(b1.equals(b2));
    b2.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_VERTICAL));
    assertTrue(b1.equals(b2));
    // check an inherited attribute
    b1.setVisible(false);
    assertFalse(b1.equals(b2));
    b2.setVisible(false);
    assertTrue(b1.equals(b2));
}
Also used : StandardGradientPaintTransformer(org.jfree.ui.StandardGradientPaintTransformer) GradientPaint(java.awt.GradientPaint) Test(org.junit.Test)

Aggregations

StandardGradientPaintTransformer (org.jfree.ui.StandardGradientPaintTransformer)12 Test (org.junit.Test)10 GradientPaint (java.awt.GradientPaint)4 Rectangle2D (java.awt.geom.Rectangle2D)4 BasicStroke (java.awt.BasicStroke)2 Font (java.awt.Font)2 Line2D (java.awt.geom.Line2D)2 ItemLabelPosition (org.jfree.chart.labels.ItemLabelPosition)2 Color (java.awt.Color)1 JFreeChart (org.jfree.chart.JFreeChart)1 DialBackground (org.jfree.chart.plot.dial.DialBackground)1 DialCap (org.jfree.chart.plot.dial.DialCap)1 DialPlot (org.jfree.chart.plot.dial.DialPlot)1 Pointer (org.jfree.chart.plot.dial.DialPointer.Pointer)1 DialTextAnnotation (org.jfree.chart.plot.dial.DialTextAnnotation)1 DialValueIndicator (org.jfree.chart.plot.dial.DialValueIndicator)1 StandardDialFrame (org.jfree.chart.plot.dial.StandardDialFrame)1 StandardDialRange (org.jfree.chart.plot.dial.StandardDialRange)1 StandardDialScale (org.jfree.chart.plot.dial.StandardDialScale)1 DefaultValueDataset (org.jfree.data.general.DefaultValueDataset)1