org.jfree.ui.StandardGradientPaintTransformer Java Examples

The following examples show how to use org.jfree.ui.StandardGradientPaintTransformer. 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: WaterfallBarRenderer.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructs a new waterfall renderer.
 *
 * @param firstBarPaint  the color of the first bar (<code>null</code> not
 *                       permitted).
 * @param positiveBarPaint  the color for bars with positive values
 *                          (<code>null</code> not permitted).
 * @param negativeBarPaint  the color for bars with negative values
 *                          (<code>null</code> not permitted).
 * @param lastBarPaint  the color of the last bar (<code>null</code> not
 *                      permitted).
 */
public WaterfallBarRenderer(Paint firstBarPaint, Paint positiveBarPaint,
        Paint negativeBarPaint, Paint lastBarPaint) {
    super();
    ParamChecks.nullNotPermitted(firstBarPaint, "firstBarPaint");
    ParamChecks.nullNotPermitted(positiveBarPaint, "positiveBarPaint");
    ParamChecks.nullNotPermitted(negativeBarPaint, "negativeBarPaint");
    ParamChecks.nullNotPermitted(lastBarPaint, "lastBarPaint");
    this.firstBarPaint = firstBarPaint;
    this.lastBarPaint = lastBarPaint;
    this.positiveBarPaint = positiveBarPaint;
    this.negativeBarPaint = negativeBarPaint;
    setGradientPaintTransformer(new StandardGradientPaintTransformer(
            GradientPaintTransformType.CENTER_VERTICAL));
    setMinimumBarLength(1.0);
}
 
Example #2
Source File: DialBackgroundTest.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Serialize an instance, restore it, and check for equality.
 */
@Test
public void testSerialization() {
    // test a default instance
    DialBackground b1 = new DialBackground();
    DialBackground b2 = (DialBackground) TestUtilities.serialised(b1);
    assertEquals(b1, b2);

    // test a customised instance
    b1 = new DialBackground();
    b1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f,
            Color.green));
    b1.setGradientPaintTransformer(new StandardGradientPaintTransformer(
            GradientPaintTransformType.CENTER_VERTICAL));

    b2 = (DialBackground) TestUtilities.serialised(b1);
    assertEquals(b1, b2);
}
 
Example #3
Source File: WaterfallBarRenderer.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Constructs a new waterfall renderer.
 *
 * @param firstBarPaint  the color of the first bar (<code>null</code> not
 *                       permitted).
 * @param positiveBarPaint  the color for bars with positive values
 *                          (<code>null</code> not permitted).
 * @param negativeBarPaint  the color for bars with negative values
 *                          (<code>null</code> not permitted).
 * @param lastBarPaint  the color of the last bar (<code>null</code> not
 *                      permitted).
 */
public WaterfallBarRenderer(Paint firstBarPaint, Paint positiveBarPaint,
        Paint negativeBarPaint, Paint lastBarPaint) {
    super();
    ParamChecks.nullNotPermitted(firstBarPaint, "firstBarPaint");
    ParamChecks.nullNotPermitted(positiveBarPaint, "positiveBarPaint");
    ParamChecks.nullNotPermitted(negativeBarPaint, "negativeBarPaint");
    ParamChecks.nullNotPermitted(lastBarPaint, "lastBarPaint");
    this.firstBarPaint = firstBarPaint;
    this.lastBarPaint = lastBarPaint;
    this.positiveBarPaint = positiveBarPaint;
    this.negativeBarPaint = negativeBarPaint;
    setGradientPaintTransformer(new StandardGradientPaintTransformer(
            GradientPaintTransformType.CENTER_VERTICAL));
    setMinimumBarLength(1.0);
}
 
Example #4
Source File: BarRenderer.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates a new bar renderer with default settings.
 */
public BarRenderer() {
    super();
    this.base = 0.0;
    this.includeBaseInRange = true;
    this.itemMargin = DEFAULT_ITEM_MARGIN;
    this.drawBarOutline = false;
    this.maximumBarWidth = 1.0;
        // 100 percent, so it will not apply unless changed
    this.positiveItemLabelPositionFallback = null;
    this.negativeItemLabelPositionFallback = null;
    this.gradientPaintTransformer = new StandardGradientPaintTransformer();
    this.minimumBarLength = 0.0;
    setBaseLegendShape(new Rectangle2D.Double(-4.0, -4.0, 8.0, 8.0));
    this.barPainter = getDefaultBarPainter();
    this.shadowsVisible = getDefaultShadowsVisible();
    this.shadowPaint = Color.gray;
    this.shadowXOffset = 4.0;
    this.shadowYOffset = 4.0;
}
 
Example #5
Source File: DialBackgroundTest.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Serialize an instance, restore it, and check for equality.
 */
@Test
public void testSerialization() {
    // test a default instance
    DialBackground b1 = new DialBackground();
    DialBackground b2 = (DialBackground) TestUtilities.serialised(b1);
    assertEquals(b1, b2);

    // test a customised instance
    b1 = new DialBackground();
    b1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f,
            Color.green));
    b1.setGradientPaintTransformer(new StandardGradientPaintTransformer(
            GradientPaintTransformType.CENTER_VERTICAL));

    b2 = (DialBackground) TestUtilities.serialised(b1);
    assertEquals(b1, b2);
}
 
Example #6
Source File: WaterfallBarRenderer.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Constructs a new waterfall renderer.
 *
 * @param firstBarPaint  the color of the first bar (<code>null</code> not
 *                       permitted).
 * @param positiveBarPaint  the color for bars with positive values
 *                          (<code>null</code> not permitted).
 * @param negativeBarPaint  the color for bars with negative values
 *                          (<code>null</code> not permitted).
 * @param lastBarPaint  the color of the last bar (<code>null</code> not
 *                      permitted).
 */
public WaterfallBarRenderer(Paint firstBarPaint, Paint positiveBarPaint,
        Paint negativeBarPaint, Paint lastBarPaint) {
    super();
    ParamChecks.nullNotPermitted(firstBarPaint, "firstBarPaint");
    ParamChecks.nullNotPermitted(positiveBarPaint, "positiveBarPaint");
    ParamChecks.nullNotPermitted(negativeBarPaint, "negativeBarPaint");
    ParamChecks.nullNotPermitted(lastBarPaint, "lastBarPaint");
    this.firstBarPaint = firstBarPaint;
    this.lastBarPaint = lastBarPaint;
    this.positiveBarPaint = positiveBarPaint;
    this.negativeBarPaint = negativeBarPaint;
    setGradientPaintTransformer(new StandardGradientPaintTransformer(
            GradientPaintTransformType.CENTER_VERTICAL));
    setMinimumBarLength(1.0);
}
 
Example #7
Source File: BarRenderer.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Creates a new bar renderer with default settings.
 */
public BarRenderer() {
    super();
    this.base = 0.0;
    this.includeBaseInRange = true;
    this.itemMargin = DEFAULT_ITEM_MARGIN;
    this.drawBarOutline = false;
    this.maximumBarWidth = 1.0;
        // 100 percent, so it will not apply unless changed
    this.positiveItemLabelPositionFallback = null;
    this.negativeItemLabelPositionFallback = null;
    this.gradientPaintTransformer = new StandardGradientPaintTransformer();
    this.minimumBarLength = 0.0;
    setBaseLegendShape(new Rectangle2D.Double(-4.0, -4.0, 8.0, 8.0));
    this.barPainter = getDefaultBarPainter();
    this.shadowsVisible = getDefaultShadowsVisible();
    this.shadowPaint = Color.gray;
    this.shadowXOffset = 4.0;
    this.shadowYOffset = 4.0;
}
 
Example #8
Source File: EyeCandySixtiesChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected JFreeChart createBarChart() throws JRException
{
	JFreeChart jfreeChart = super.createBarChart();

	CategoryPlot categoryPlot = (CategoryPlot)jfreeChart.getPlot();
	//categoryPlot.setOrientation(PlotOrientation.HORIZONTAL);
	BarRenderer barRenderer = (BarRenderer)categoryPlot.getRenderer();
	barRenderer.setItemMargin(0);
	barRenderer.setGradientPaintTransformer(
		new StandardGradientPaintTransformer(GradientPaintTransformType.HORIZONTAL)
		);
	CategoryDataset categoryDataset = categoryPlot.getDataset();
	if (categoryDataset != null)
	{
		for (int i = 0; i < categoryDataset.getRowCount(); i++)
		{
			barRenderer.setSeriesPaint(i, ChartThemesConstants.EYE_CANDY_SIXTIES_GRADIENT_PAINTS.get(i));
		}
	}
	return jfreeChart;
}
 
Example #9
Source File: EyeCandySixtiesChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected JFreeChart createXYBarChart() throws JRException
{
	JFreeChart jfreeChart = super.createXYBarChart();
	XYPlot xyPlot = (XYPlot)jfreeChart.getPlot();
	XYBarRenderer renderer = (XYBarRenderer)xyPlot.getRenderer();
	renderer.setMargin(0.1);
	renderer.setGradientPaintTransformer(
			new StandardGradientPaintTransformer(GradientPaintTransformType.HORIZONTAL)
			);
	XYDataset xyDataset = xyPlot.getDataset();
	if (xyDataset != null)
	{
		for (int i = 0; i < xyDataset.getSeriesCount(); i++)
		{
			renderer.setSeriesPaint(i, ChartThemesConstants.EYE_CANDY_SIXTIES_GRADIENT_PAINTS.get(i));
		}
	}
	return jfreeChart;
}
 
Example #10
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 #11
Source File: WaterfallBarRenderer.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Constructs a new waterfall renderer.
 *
 * @param firstBarPaint  the color of the first bar (<code>null</code> not
 *                       permitted).
 * @param positiveBarPaint  the color for bars with positive values
 *                          (<code>null</code> not permitted).
 * @param negativeBarPaint  the color for bars with negative values
 *                          (<code>null</code> not permitted).
 * @param lastBarPaint  the color of the last bar (<code>null</code> not
 *                      permitted).
 */
public WaterfallBarRenderer(Paint firstBarPaint, Paint positiveBarPaint,
        Paint negativeBarPaint, Paint lastBarPaint) {
    super();
    ParamChecks.nullNotPermitted(firstBarPaint, "firstBarPaint");
    ParamChecks.nullNotPermitted(positiveBarPaint, "positiveBarPaint");
    ParamChecks.nullNotPermitted(negativeBarPaint, "negativeBarPaint");
    ParamChecks.nullNotPermitted(lastBarPaint, "lastBarPaint");
    this.firstBarPaint = firstBarPaint;
    this.lastBarPaint = lastBarPaint;
    this.positiveBarPaint = positiveBarPaint;
    this.negativeBarPaint = negativeBarPaint;
    setGradientPaintTransformer(new StandardGradientPaintTransformer(
            GradientPaintTransformType.CENTER_VERTICAL));
    setMinimumBarLength(1.0);
}
 
Example #12
Source File: BarRenderer.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a new bar renderer with default settings.
 */
public BarRenderer() {
    super();
    this.base = 0.0;
    this.includeBaseInRange = true;
    this.itemMargin = DEFAULT_ITEM_MARGIN;
    this.drawBarOutline = false;
    this.maximumBarWidth = 1.0;
        // 100 percent, so it will not apply unless changed
    this.positiveItemLabelPositionFallback = null;
    this.negativeItemLabelPositionFallback = null;
    this.gradientPaintTransformer = new StandardGradientPaintTransformer();
    this.minimumBarLength = 0.0;
    setBaseLegendShape(new Rectangle2D.Double(-4.0, -4.0, 8.0, 8.0));
    this.barPainter = getDefaultBarPainter();
    this.shadowsVisible = getDefaultShadowsVisible();
    this.shadowPaint = Color.gray;
    this.shadowXOffset = 4.0;
    this.shadowYOffset = 4.0;
}
 
Example #13
Source File: DialBackgroundTest.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Serialize an instance, restore it, and check for equality.
 */
@Test
public void testSerialization() {
    // test a default instance
    DialBackground b1 = new DialBackground();
    DialBackground b2 = (DialBackground) TestUtilities.serialised(b1);
    assertEquals(b1, b2);

    // test a customised instance
    b1 = new DialBackground();
    b1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f,
            Color.green));
    b1.setGradientPaintTransformer(new StandardGradientPaintTransformer(
            GradientPaintTransformType.CENTER_VERTICAL));

    b2 = (DialBackground) TestUtilities.serialised(b1);
    assertEquals(b1, b2);
}
 
Example #14
Source File: EyeCandySixtiesChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected JFreeChart createStackedBarChart() throws JRException
{
	JFreeChart jfreeChart = super.createStackedBarChart();

	CategoryPlot categoryPlot = (CategoryPlot)jfreeChart.getPlot();
	//categoryPlot.setOrientation(PlotOrientation.HORIZONTAL);
	BarRenderer barRenderer = (BarRenderer)categoryPlot.getRenderer();
	barRenderer.setItemMargin(0);
	barRenderer.setGradientPaintTransformer(
		new StandardGradientPaintTransformer(GradientPaintTransformType.HORIZONTAL)
		);

	CategoryDataset categoryDataset = categoryPlot.getDataset();
	if (categoryDataset != null)
	{
		for (int i = 0; i < categoryDataset.getRowCount(); i++)
		{
			barRenderer.setSeriesPaint(i, ChartThemesConstants.EYE_CANDY_SIXTIES_GRADIENT_PAINTS.get(i));
		}
	}
	return jfreeChart;
}
 
Example #15
Source File: LegendGraphic.java    From opensim-gui with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new legend graphic.
 * 
 * @param shape  the shape (<code>null</code> not permitted).
 * @param fillPaint  the fill paint (<code>null</code> not permitted).
 */
public LegendGraphic(Shape shape, Paint fillPaint) {
    if (shape == null) {
        throw new IllegalArgumentException("Null 'shape' argument.");
    }
    if (fillPaint == null) {
        throw new IllegalArgumentException("Null 'fillPaint' argument.");
    }
    this.shapeVisible = true;
    this.shape = shape;
    this.shapeAnchor = RectangleAnchor.CENTER;
    this.shapeLocation = RectangleAnchor.CENTER;
    this.shapeFilled = true;
    this.fillPaint = fillPaint;
    this.fillPaintTransformer = new StandardGradientPaintTransformer();
    setPadding(2.0, 2.0, 2.0, 2.0);
}
 
Example #16
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 #17
Source File: XYAreaRenderer.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs a new renderer.  To specify the type of renderer, use one of
 * the constants: <code>SHAPES</code>, <code>LINES</code>,
 * <code>SHAPES_AND_LINES</code>, <code>AREA</code> or
 * <code>AREA_AND_SHAPES</code>.
 *
 * @param type  the type of renderer.
 * @param toolTipGenerator  the tool tip generator to use
 *                          (<code>null</code> permitted).
 * @param urlGenerator  the URL generator (<code>null</code> permitted).
 */
public XYAreaRenderer(int type, XYToolTipGenerator toolTipGenerator,
                      XYURLGenerator urlGenerator) {

    super();
    setBaseToolTipGenerator(toolTipGenerator);
    setURLGenerator(urlGenerator);

    if (type == SHAPES) {
        this.plotShapes = true;
    }
    if (type == LINES) {
        this.plotLines = true;
    }
    if (type == SHAPES_AND_LINES) {
        this.plotShapes = true;
        this.plotLines = true;
    }
    if (type == AREA) {
        this.plotArea = true;
    }
    if (type == AREA_AND_SHAPES) {
        this.plotArea = true;
        this.plotShapes = true;
    }
    this.showOutline = false;
    GeneralPath area = new GeneralPath();
    area.moveTo(0.0f, -4.0f);
    area.lineTo(3.0f, -2.0f);
    area.lineTo(4.0f, 4.0f);
    area.lineTo(-4.0f, 4.0f);
    area.lineTo(-3.0f, -2.0f);
    area.closePath();
    this.legendArea = area;
    this.useFillPaint = false;
    this.gradientTransformer = new StandardGradientPaintTransformer();
}
 
Example #18
Source File: DialBackgroundTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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));

}
 
Example #19
Source File: XYSplineRenderer.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new renderer with the specified precision
 * and specified fill of the area 'under' (between '0' and) the spline.
 *
 * @param precision  the number of points between data items.
 * @param fillType  the type of fill beneath the curve (<code>null</code> 
 *     not permitted).
 * 
 * @since 1.0.17
 */
public XYSplineRenderer(int precision, FillType fillType) {
    super();
    if (precision <= 0) {
        throw new IllegalArgumentException("Requires precision > 0.");
    }
    ParamChecks.nullNotPermitted(fillType, "fillType");
    this.precision = precision;
    this.fillType = fillType;
    this.gradientPaintTransformer = new StandardGradientPaintTransformer();
}
 
Example #20
Source File: LegendItem.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new legend item.
 *
 * @param label  the label ({@code null} not permitted).
 * @param description  the description (not currently used,
 *        <code>null</code> permitted).
 * @param toolTipText  the tool tip text (<code>null</code> permitted).
 * @param urlText  the URL text (<code>null</code> permitted).
 * @param shapeVisible  a flag that controls whether or not the shape is
 *                      displayed.
 * @param shape  the shape (<code>null</code> permitted).
 * @param shapeFilled  a flag that controls whether or not the shape is
 *                     filled.
 * @param fillPaint  the fill paint (<code>null</code> not permitted).
 * @param shapeOutlineVisible  a flag that controls whether or not the
 *                             shape is outlined.
 * @param outlinePaint  the outline paint (<code>null</code> not permitted).
 * @param outlineStroke  the outline stroke (<code>null</code> not
 *                       permitted).
 * @param lineVisible  a flag that controls whether or not the line is
 *                     visible.
 * @param line  the line.
 * @param lineStroke  the stroke (<code>null</code> not permitted).
 * @param linePaint  the line paint (<code>null</code> not permitted).
 */
public LegendItem(String label, String description,
                  String toolTipText, String urlText,
                  boolean shapeVisible, Shape shape,
                  boolean shapeFilled, Paint fillPaint,
                  boolean shapeOutlineVisible, Paint outlinePaint,
                  Stroke outlineStroke,
                  boolean lineVisible, Shape line,
                  Stroke lineStroke, Paint linePaint) {

    ParamChecks.nullNotPermitted(label, "label");
    ParamChecks.nullNotPermitted(fillPaint, "fillPaint");
    ParamChecks.nullNotPermitted(lineStroke, "lineStroke");
    ParamChecks.nullNotPermitted(outlinePaint, "outlinePaint");
    ParamChecks.nullNotPermitted(outlineStroke, "outlineStroke");
    this.label = label;
    this.labelPaint = null;
    this.attributedLabel = null;
    this.description = description;
    this.shapeVisible = shapeVisible;
    this.shape = shape;
    this.shapeFilled = shapeFilled;
    this.fillPaint = fillPaint;
    this.fillPaintTransformer = new StandardGradientPaintTransformer();
    this.shapeOutlineVisible = shapeOutlineVisible;
    this.outlinePaint = outlinePaint;
    this.outlineStroke = outlineStroke;
    this.lineVisible = lineVisible;
    this.line = line;
    this.lineStroke = lineStroke;
    this.linePaint = linePaint;
    this.toolTipText = toolTipText;
    this.urlText = urlText;
}
 
Example #21
Source File: DialBackgroundTest.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * 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));

}
 
Example #22
Source File: XYSplineRendererTest.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Test that the equals() method distinguishes all fields.
 */
@Test
public void testEquals() {
    XYSplineRenderer r1 = new XYSplineRenderer();
    XYSplineRenderer r2 = new XYSplineRenderer();
    assertEquals(r1, r2);
    assertEquals(r2, r1);

    r1.setPrecision(9);
    assertFalse(r1.equals(r2));
    r2.setPrecision(9);
    assertTrue(r1.equals(r2));
    
    r1.setFillType(XYSplineRenderer.FillType.TO_ZERO);
    assertFalse(r1.equals(r2));
    r2.setFillType(XYSplineRenderer.FillType.TO_ZERO);
    assertTrue(r1.equals(r2));
    
    r1.setGradientPaintTransformer(null);
    assertFalse(r1.equals(r2));
    r2.setGradientPaintTransformer(null);
    assertTrue(r1.equals(r2));
    
    r1.setGradientPaintTransformer(new StandardGradientPaintTransformer(
            GradientPaintTransformType.HORIZONTAL));
    assertFalse(r1.equals(r2));
    r2.setGradientPaintTransformer(new StandardGradientPaintTransformer(
            GradientPaintTransformType.HORIZONTAL));
    assertTrue(r1.equals(r2));
}
 
Example #23
Source File: XYSplineRendererTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Test that the equals() method distinguishes all fields.
 */
@Test
public void testEquals() {
    XYSplineRenderer r1 = new XYSplineRenderer();
    XYSplineRenderer r2 = new XYSplineRenderer();
    assertEquals(r1, r2);
    assertEquals(r2, r1);

    r1.setPrecision(9);
    assertFalse(r1.equals(r2));
    r2.setPrecision(9);
    assertTrue(r1.equals(r2));
    
    r1.setFillType(XYSplineRenderer.FillType.TO_ZERO);
    assertFalse(r1.equals(r2));
    r2.setFillType(XYSplineRenderer.FillType.TO_ZERO);
    assertTrue(r1.equals(r2));
    
    r1.setGradientPaintTransformer(null);
    assertFalse(r1.equals(r2));
    r2.setGradientPaintTransformer(null);
    assertTrue(r1.equals(r2));
    
    r1.setGradientPaintTransformer(new StandardGradientPaintTransformer(
            GradientPaintTransformType.HORIZONTAL));
    assertFalse(r1.equals(r2));
    r2.setGradientPaintTransformer(new StandardGradientPaintTransformer(
            GradientPaintTransformType.HORIZONTAL));
    assertTrue(r1.equals(r2));
}
 
Example #24
Source File: DialBackgroundTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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));

}
 
Example #25
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 #26
Source File: DialBackgroundTest.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 {
    // test default instance
    DialBackground b1 = new DialBackground();
    DialBackground b2 = (DialBackground) b1.clone();
    assertTrue(b1 != b2);
    assertTrue(b1.getClass() == b2.getClass());
    assertTrue(b1.equals(b2));

    // test a customised instance
    b1 = new DialBackground();
    b1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f,
            Color.green));
    b1.setGradientPaintTransformer(new StandardGradientPaintTransformer(
            GradientPaintTransformType.CENTER_VERTICAL));
    b2 = (DialBackground) b1.clone();
    assertTrue(b1 != b2);
    assertTrue(b1.getClass() == b2.getClass());
    assertTrue(b1.equals(b2));

    // check that the listener lists are independent
    MyDialLayerChangeListener l1 = new MyDialLayerChangeListener();
    b1.addChangeListener(l1);
    assertTrue(b1.hasListener(l1));
    assertFalse(b2.hasListener(l1));
}
 
Example #27
Source File: LegendItem.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a new legend item.
 *
 * @param label  the label ({@code null} not permitted).
 * @param description  the description (not currently used,
 *        <code>null</code> permitted).
 * @param toolTipText  the tool tip text (<code>null</code> permitted).
 * @param urlText  the URL text (<code>null</code> permitted).
 * @param shapeVisible  a flag that controls whether or not the shape is
 *                      displayed.
 * @param shape  the shape (<code>null</code> permitted).
 * @param shapeFilled  a flag that controls whether or not the shape is
 *                     filled.
 * @param fillPaint  the fill paint (<code>null</code> not permitted).
 * @param shapeOutlineVisible  a flag that controls whether or not the
 *                             shape is outlined.
 * @param outlinePaint  the outline paint (<code>null</code> not permitted).
 * @param outlineStroke  the outline stroke (<code>null</code> not
 *                       permitted).
 * @param lineVisible  a flag that controls whether or not the line is
 *                     visible.
 * @param line  the line.
 * @param lineStroke  the stroke (<code>null</code> not permitted).
 * @param linePaint  the line paint (<code>null</code> not permitted).
 */
public LegendItem(String label, String description,
                  String toolTipText, String urlText,
                  boolean shapeVisible, Shape shape,
                  boolean shapeFilled, Paint fillPaint,
                  boolean shapeOutlineVisible, Paint outlinePaint,
                  Stroke outlineStroke,
                  boolean lineVisible, Shape line,
                  Stroke lineStroke, Paint linePaint) {

    ParamChecks.nullNotPermitted(label, "label");
    ParamChecks.nullNotPermitted(fillPaint, "fillPaint");
    ParamChecks.nullNotPermitted(lineStroke, "lineStroke");
    ParamChecks.nullNotPermitted(outlinePaint, "outlinePaint");
    ParamChecks.nullNotPermitted(outlineStroke, "outlineStroke");
    this.label = label;
    this.labelPaint = null;
    this.attributedLabel = null;
    this.description = description;
    this.shapeVisible = shapeVisible;
    this.shape = shape;
    this.shapeFilled = shapeFilled;
    this.fillPaint = fillPaint;
    this.fillPaintTransformer = new StandardGradientPaintTransformer();
    this.shapeOutlineVisible = shapeOutlineVisible;
    this.outlinePaint = outlinePaint;
    this.outlineStroke = outlineStroke;
    this.lineVisible = lineVisible;
    this.line = line;
    this.lineStroke = lineStroke;
    this.linePaint = linePaint;
    this.toolTipText = toolTipText;
    this.urlText = urlText;
}
 
Example #28
Source File: IntervalMarkerTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
@Test
public void testEquals() {

    IntervalMarker m1 = new IntervalMarker(45.0, 50.0);
    IntervalMarker m2 = new IntervalMarker(45.0, 50.0);
    assertTrue(m1.equals(m2));
    assertTrue(m2.equals(m1));

    m1 = new IntervalMarker(44.0, 50.0);
    assertFalse(m1.equals(m2));
    m2 = new IntervalMarker(44.0, 50.0);
    assertTrue(m1.equals(m2));

    m1 = new IntervalMarker(44.0, 55.0);
    assertFalse(m1.equals(m2));
    m2 = new IntervalMarker(44.0, 55.0);
    assertTrue(m1.equals(m2));

    GradientPaintTransformer t = new StandardGradientPaintTransformer(
            GradientPaintTransformType.HORIZONTAL);
    m1.setGradientPaintTransformer(t);
    assertFalse(m1.equals(m2));
    m2.setGradientPaintTransformer(t);
    assertTrue(m1.equals(m2));

}
 
Example #29
Source File: LeitnerStatePanel.java    From opencards with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void reconfigureColorEncoding() {
    StackedBarRenderer renderer = new StackedBarRenderer();
    renderer.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.HORIZONTAL));

    renderer.setItemMargin(0.0);

    int barIndex = 0;

    //blue
    Paint p1 = new GradientPaint(0.0f, 0.0f, new Color(0x22, 0x22, 0xFF), 0.0f, 0.0f, new Color(0x88, 0x88, 0xFF));
    renderer.setSeriesPaint(barIndex, p1);
    renderer.setSeriesToolTipGenerator(barIndex, new StandardCategoryToolTipGenerator());

    //green
    barIndex++;
    Paint p3 = new GradientPaint(0.0f, 0.0f, new Color(0x22, 0xFF, 0x22), 0.0f, 0.0f, new Color(0x88, 0xFF, 0x88));
    renderer.setSeriesPaint(barIndex, p3);
    renderer.setSeriesToolTipGenerator(barIndex, new StandardCategoryToolTipGenerator());

    if (hightlightItem != null) {
        //red
        barIndex++;
        Paint p2 = new GradientPaint(0.0f, 0.0f, new Color(0xFF, 0x22, 0x22), 0.0f, 0.0f, new Color(0xFF, 0x88, 0x88));
        renderer.setSeriesPaint(barIndex, p2);
        renderer.setSeriesToolTipGenerator(barIndex, new StandardCategoryToolTipGenerator());
    }

    plot.setRenderer(renderer);
}
 
Example #30
Source File: LegendGraphic.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new legend graphic.
 *
 * @param shape  the shape (<code>null</code> not permitted).
 * @param fillPaint  the fill paint (<code>null</code> not permitted).
 */
public LegendGraphic(Shape shape, Paint fillPaint) {
    ParamChecks.nullNotPermitted(shape, "shape");
    ParamChecks.nullNotPermitted(fillPaint, "fillPaint");
    this.shapeVisible = true;
    this.shape = shape;
    this.shapeAnchor = RectangleAnchor.CENTER;
    this.shapeLocation = RectangleAnchor.CENTER;
    this.shapeFilled = true;
    this.fillPaint = fillPaint;
    this.fillPaintTransformer = new StandardGradientPaintTransformer();
    setPadding(2.0, 2.0, 2.0, 2.0);
}