org.jfree.ui.Align Java Examples

The following examples show how to use org.jfree.ui.Align. 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: Plot.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Draws the background image (if there is one) aligned within the
 * specified area.
 *
 * @param g2  the graphics device.
 * @param area  the area.
 *
 * @see #getBackgroundImage()
 * @see #getBackgroundImageAlignment()
 * @see #getBackgroundImageAlpha()
 */
public void drawBackgroundImage(Graphics2D g2, Rectangle2D area) {
    if (this.backgroundImage == null) {
        return;  // nothing to do
    }
    Composite savedComposite = g2.getComposite();
    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
            this.backgroundImageAlpha));
    Rectangle2D dest = new Rectangle2D.Double(0.0, 0.0,
            this.backgroundImage.getWidth(null),
            this.backgroundImage.getHeight(null));
    Align.align(dest, area, this.backgroundImageAlignment);
    Shape savedClip = g2.getClip();
    g2.clip(area);
    g2.drawImage(this.backgroundImage, (int) dest.getX(),
            (int) dest.getY(), (int) dest.getWidth() + 1,
            (int) dest.getHeight() + 1, null);
    g2.setClip(savedClip);
    g2.setComposite(savedComposite);
}
 
Example #2
Source File: Plot.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Draws the background image (if there is one) aligned within the
 * specified area.
 *
 * @param g2  the graphics device.
 * @param area  the area.
 *
 * @see #getBackgroundImage()
 * @see #getBackgroundImageAlignment()
 * @see #getBackgroundImageAlpha()
 */
public void drawBackgroundImage(Graphics2D g2, Rectangle2D area) {
    if (this.backgroundImage == null) {
        return;  // nothing to do
    }
    Composite savedComposite = g2.getComposite();
    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
            this.backgroundImageAlpha));
    Rectangle2D dest = new Rectangle2D.Double(0.0, 0.0,
            this.backgroundImage.getWidth(null),
            this.backgroundImage.getHeight(null));
    Align.align(dest, area, this.backgroundImageAlignment);
    Shape savedClip = g2.getClip();
    g2.clip(area);
    g2.drawImage(this.backgroundImage, (int) dest.getX(),
            (int) dest.getY(), (int) dest.getWidth() + 1,
            (int) dest.getHeight() + 1, null);
    g2.setClip(savedClip);
    g2.setComposite(savedComposite);
}
 
Example #3
Source File: Plot.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Draws the background image (if there is one) aligned within the
 * specified area.
 *
 * @param g2  the graphics device.
 * @param area  the area.
 *
 * @see #getBackgroundImage()
 * @see #getBackgroundImageAlignment()
 * @see #getBackgroundImageAlpha()
 */
public void drawBackgroundImage(Graphics2D g2, Rectangle2D area) {
    if (this.backgroundImage == null) {
        return;  // nothing to do
    }
    Composite savedComposite = g2.getComposite();
    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
            this.backgroundImageAlpha));
    Rectangle2D dest = new Rectangle2D.Double(0.0, 0.0,
            this.backgroundImage.getWidth(null),
            this.backgroundImage.getHeight(null));
    Align.align(dest, area, this.backgroundImageAlignment);
    Shape savedClip = g2.getClip();
    g2.clip(area);
    g2.drawImage(this.backgroundImage, (int) dest.getX(),
            (int) dest.getY(), (int) dest.getWidth() + 1,
            (int) dest.getHeight() + 1, null);
    g2.setClip(savedClip);
    g2.setComposite(savedComposite);
}
 
Example #4
Source File: Plot.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Draws the background image (if there is one) aligned within the
 * specified area.
 *
 * @param g2  the graphics device.
 * @param area  the area.
 *
 * @see #getBackgroundImage()
 * @see #getBackgroundImageAlignment()
 * @see #getBackgroundImageAlpha()
 */
public void drawBackgroundImage(Graphics2D g2, Rectangle2D area) {
    if (this.backgroundImage == null) {
        return;  // nothing to do
    }
    Composite savedComposite = g2.getComposite();
    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
            this.backgroundImageAlpha));
    Rectangle2D dest = new Rectangle2D.Double(0.0, 0.0,
            this.backgroundImage.getWidth(null),
            this.backgroundImage.getHeight(null));
    Align.align(dest, area, this.backgroundImageAlignment);
    Shape savedClip = g2.getClip();
    g2.clip(area);
    g2.drawImage(this.backgroundImage, (int) dest.getX(),
            (int) dest.getY(), (int) dest.getWidth() + 1,
            (int) dest.getHeight() + 1, null);
    g2.setClip(savedClip);
    g2.setComposite(savedComposite);
}
 
Example #5
Source File: Plot.java    From opensim-gui with Apache License 2.0 6 votes vote down vote up
/**
 * Draws the background image (if there is one) aligned within the 
 * specified area.
 * 
 * @param g2  the graphics device.
 * @param area  the area.
 * 
 * @see #getBackgroundImage()
 * @see #getBackgroundImageAlignment()
 * @see #getBackgroundImageAlpha()
 */
protected void drawBackgroundImage(Graphics2D g2, Rectangle2D area) {
    if (this.backgroundImage != null) {
        Composite originalComposite = g2.getComposite();
        g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 
                this.backgroundImageAlpha));
        Rectangle2D dest = new Rectangle2D.Double(0.0, 0.0,
                this.backgroundImage.getWidth(null), 
                this.backgroundImage.getHeight(null));
        Align.align(dest, area, this.backgroundImageAlignment);
        g2.drawImage(this.backgroundImage, (int) dest.getX(), 
                (int) dest.getY(), (int) dest.getWidth() + 1, 
                (int) dest.getHeight() + 1, null);
        g2.setComposite(originalComposite);
    }
}
 
Example #6
Source File: Plot.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Draws the background image (if there is one) aligned within the
 * specified area.
 *
 * @param g2  the graphics device.
 * @param area  the area.
 *
 * @see #getBackgroundImage()
 * @see #getBackgroundImageAlignment()
 * @see #getBackgroundImageAlpha()
 */
public void drawBackgroundImage(Graphics2D g2, Rectangle2D area) {
    if (this.backgroundImage == null) {
        return;  // nothing to do
    }
    Composite savedComposite = g2.getComposite();
    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
            this.backgroundImageAlpha));
    Rectangle2D dest = new Rectangle2D.Double(0.0, 0.0,
            this.backgroundImage.getWidth(null),
            this.backgroundImage.getHeight(null));
    Align.align(dest, area, this.backgroundImageAlignment);
    Shape savedClip = g2.getClip();
    g2.clip(area);
    g2.drawImage(this.backgroundImage, (int) dest.getX(),
            (int) dest.getY(), (int) dest.getWidth() + 1,
            (int) dest.getHeight() + 1, null);
    g2.setClip(savedClip);
    g2.setComposite(savedComposite);
}
 
Example #7
Source File: Plot.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Draws the background image (if there is one) aligned within the
 * specified area.
 *
 * @param g2  the graphics device.
 * @param area  the area.
 *
 * @see #getBackgroundImage()
 * @see #getBackgroundImageAlignment()
 * @see #getBackgroundImageAlpha()
 */
public void drawBackgroundImage(Graphics2D g2, Rectangle2D area) {
    if (this.backgroundImage == null) {
        return;  // nothing to do
    }
    Composite savedComposite = g2.getComposite();
    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
            this.backgroundImageAlpha));
    Rectangle2D dest = new Rectangle2D.Double(0.0, 0.0,
            this.backgroundImage.getWidth(null),
            this.backgroundImage.getHeight(null));
    Align.align(dest, area, this.backgroundImageAlignment);
    Shape savedClip = g2.getClip();
    g2.clip(area);
    g2.drawImage(this.backgroundImage, (int) dest.getX(),
            (int) dest.getY(), (int) dest.getWidth() + 1,
            (int) dest.getHeight() + 1, null);
    g2.setClip(savedClip);
    g2.setComposite(savedComposite);
}
 
Example #8
Source File: ImageAlignmentFieldHandler.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public Object convertUponGet(Object value)
{
	if (value == null)
	{
		return null;
	}
	return 
		value.equals(Align.BOTTOM) 
		? "Align.BOTTOM"
		: value.equals(Align.BOTTOM_LEFT)
		? "Align.BOTTOM_LEFT"
		: value.equals(Align.BOTTOM_RIGHT)
		? "Align.BOTTOM_RIGHT"
		: value.equals(Align.CENTER)
		? "Align.CENTER"
		: value.equals(Align.FIT)
		? "Align.FIT"
		: value.equals(Align.FIT_HORIZONTAL)
		? "Align.FIT_HORIZONTAL"
		: value.equals(Align.FIT_VERTICAL)
		? "Align.FIT_VERTICAL"
		: value.equals(Align.LEFT)
		? "Align.LEFT"
		: value.equals(Align.RIGHT)
		? "Align.RIGHT"
		: value.equals(Align.TOP)
		? "Align.TOP"
		: value.equals(Align.TOP_LEFT)
		? "Align.TOP_LEFT"
		: value.equals(Align.TOP_RIGHT)
		? "Align.TOP_RIGHT" : null;
}
 
Example #9
Source File: ImageAlignmentFieldHandler.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public Object convertUponSet(Object value)
{
	if (value == null)
	{
		return null;
	}
	return 
		"Align.BOTTOM".equals(value) 
		? Align.BOTTOM
		: "Align.BOTTOM_LEFT".equals(value)
		? Align.BOTTOM_LEFT
		: "Align.BOTTOM_RIGHT".equals(value)
		? Align.BOTTOM_RIGHT
		: "Align.CENTER".equals(value)
		? Align.CENTER
		: "Align.FIT".equals(value)
		? Align.FIT
		: "Align.FIT_HORIZONTAL".equals(value)
		? Align.FIT_HORIZONTAL
		: "Align.FIT_VERTICAL".equals(value)
		? Align.FIT_VERTICAL
		: "Align.LEFT".equals(value)
		? Align.LEFT
		: "Align.RIGHT".equals(value)
		? Align.RIGHT
		: "Align.TOP".equals(value)
		? Align.TOP
		: "Align.TOP_LEFT".equals(value)
		? Align.TOP_LEFT
		: "Align.TOP_RIGHT".equals(value)
		? Align.TOP_RIGHT : null;
}
 
Example #10
Source File: JFreeChartTest.java    From openstock with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Check that the equals() method can distinguish all fields.
 */
@Test
public void testEquals() {
    JFreeChart chart1 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new PiePlot(), true);
    JFreeChart chart2 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new PiePlot(), true);
    assertEquals(chart1, chart2);
    assertEquals(chart2, chart1);

    // renderingHints
    chart1.setRenderingHints(new RenderingHints(
            RenderingHints.KEY_TEXT_ANTIALIASING,
            RenderingHints.VALUE_TEXT_ANTIALIAS_ON));
    assertFalse(chart1.equals(chart2));
    chart2.setRenderingHints(new RenderingHints(
            RenderingHints.KEY_TEXT_ANTIALIASING,
            RenderingHints.VALUE_TEXT_ANTIALIAS_ON));
    assertEquals(chart1, chart2);

    // borderVisible
    chart1.setBorderVisible(true);
    assertFalse(chart1.equals(chart2));
    chart2.setBorderVisible(true);
    assertEquals(chart1, chart2);

    // borderStroke
    BasicStroke s = new BasicStroke(2.0f);
    chart1.setBorderStroke(s);
    assertFalse(chart1.equals(chart2));
    chart2.setBorderStroke(s);
    assertEquals(chart1, chart2);

    // borderPaint
    chart1.setBorderPaint(Color.red);
    assertFalse(chart1.equals(chart2));
    chart2.setBorderPaint(Color.red);
    assertEquals(chart1, chart2);

    // padding
    chart1.setPadding(new RectangleInsets(1, 2, 3, 4));
    assertFalse(chart1.equals(chart2));
    chart2.setPadding(new RectangleInsets(1, 2, 3, 4));
    assertEquals(chart1, chart2);

    // title
    chart1.setTitle("XYZ");
    assertFalse(chart1.equals(chart2));
    chart2.setTitle("XYZ");
    assertEquals(chart1, chart2);

    // subtitles
    chart1.addSubtitle(new TextTitle("Subtitle"));
    assertFalse(chart1.equals(chart2));
    chart2.addSubtitle(new TextTitle("Subtitle"));
    assertEquals(chart1, chart2);

    // plot
    chart1 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new RingPlot(), false);
    chart2 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new PiePlot(), false);
    assertFalse(chart1.equals(chart2));
    chart2 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new RingPlot(), false);
    assertEquals(chart1, chart2);

    // backgroundPaint
    chart1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red,
            3.0f, 4.0f, Color.blue));
    assertFalse(chart1.equals(chart2));
    chart2.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red,
            3.0f, 4.0f, Color.blue));
    assertEquals(chart1, chart2);

    // backgroundImage
    chart1.setBackgroundImage(JFreeChart.INFO.getLogo());
    assertFalse(chart1.equals(chart2));
    chart2.setBackgroundImage(JFreeChart.INFO.getLogo());
    assertEquals(chart1, chart2);

    // backgroundImageAlignment
    chart1.setBackgroundImageAlignment(Align.BOTTOM_LEFT);
    assertFalse(chart1.equals(chart2));
    chart2.setBackgroundImageAlignment(Align.BOTTOM_LEFT);
    assertEquals(chart1, chart2);

    // backgroundImageAlpha
    chart1.setBackgroundImageAlpha(0.1f);
    assertFalse(chart1.equals(chart2));
    chart2.setBackgroundImageAlpha(0.1f);
    assertEquals(chart1, chart2);
}
 
Example #11
Source File: JFreeChartTest.java    From ccu-historian with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Check that the equals() method can distinguish all fields.
 */
@Test
public void testEquals() {
    JFreeChart chart1 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new PiePlot(), true);
    JFreeChart chart2 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new PiePlot(), true);
    assertEquals(chart1, chart2);
    assertEquals(chart2, chart1);

    // renderingHints
    chart1.setRenderingHints(new RenderingHints(
            RenderingHints.KEY_TEXT_ANTIALIASING,
            RenderingHints.VALUE_TEXT_ANTIALIAS_ON));
    assertFalse(chart1.equals(chart2));
    chart2.setRenderingHints(new RenderingHints(
            RenderingHints.KEY_TEXT_ANTIALIASING,
            RenderingHints.VALUE_TEXT_ANTIALIAS_ON));
    assertEquals(chart1, chart2);

    // borderVisible
    chart1.setBorderVisible(true);
    assertFalse(chart1.equals(chart2));
    chart2.setBorderVisible(true);
    assertEquals(chart1, chart2);

    // borderStroke
    BasicStroke s = new BasicStroke(2.0f);
    chart1.setBorderStroke(s);
    assertFalse(chart1.equals(chart2));
    chart2.setBorderStroke(s);
    assertEquals(chart1, chart2);

    // borderPaint
    chart1.setBorderPaint(Color.red);
    assertFalse(chart1.equals(chart2));
    chart2.setBorderPaint(Color.red);
    assertEquals(chart1, chart2);

    // padding
    chart1.setPadding(new RectangleInsets(1, 2, 3, 4));
    assertFalse(chart1.equals(chart2));
    chart2.setPadding(new RectangleInsets(1, 2, 3, 4));
    assertEquals(chart1, chart2);

    // title
    chart1.setTitle("XYZ");
    assertFalse(chart1.equals(chart2));
    chart2.setTitle("XYZ");
    assertEquals(chart1, chart2);

    // subtitles
    chart1.addSubtitle(new TextTitle("Subtitle"));
    assertFalse(chart1.equals(chart2));
    chart2.addSubtitle(new TextTitle("Subtitle"));
    assertEquals(chart1, chart2);

    // plot
    chart1 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new RingPlot(), false);
    chart2 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new PiePlot(), false);
    assertFalse(chart1.equals(chart2));
    chart2 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new RingPlot(), false);
    assertEquals(chart1, chart2);

    // backgroundPaint
    chart1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red,
            3.0f, 4.0f, Color.blue));
    assertFalse(chart1.equals(chart2));
    chart2.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red,
            3.0f, 4.0f, Color.blue));
    assertEquals(chart1, chart2);

    // backgroundImage
    chart1.setBackgroundImage(JFreeChart.INFO.getLogo());
    assertFalse(chart1.equals(chart2));
    chart2.setBackgroundImage(JFreeChart.INFO.getLogo());
    assertEquals(chart1, chart2);

    // backgroundImageAlignment
    chart1.setBackgroundImageAlignment(Align.BOTTOM_LEFT);
    assertFalse(chart1.equals(chart2));
    chart2.setBackgroundImageAlignment(Align.BOTTOM_LEFT);
    assertEquals(chart1, chart2);

    // backgroundImageAlpha
    chart1.setBackgroundImageAlpha(0.1f);
    assertFalse(chart1.equals(chart2));
    chart2.setBackgroundImageAlpha(0.1f);
    assertEquals(chart1, chart2);
}
 
Example #12
Source File: JFreeChartTest.java    From SIMVA-SoS with Apache License 2.0 4 votes vote down vote up
/**
 * Check that the equals() method can distinguish all fields.
 */
@Test
public void testEquals() {
    JFreeChart chart1 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new PiePlot(), true);
    JFreeChart chart2 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new PiePlot(), true);
    assertEquals(chart1, chart2);
    assertEquals(chart2, chart1);

    // renderingHints
    chart1.setRenderingHints(new RenderingHints(
            RenderingHints.KEY_TEXT_ANTIALIASING,
            RenderingHints.VALUE_TEXT_ANTIALIAS_ON));
    assertFalse(chart1.equals(chart2));
    chart2.setRenderingHints(new RenderingHints(
            RenderingHints.KEY_TEXT_ANTIALIASING,
            RenderingHints.VALUE_TEXT_ANTIALIAS_ON));
    assertEquals(chart1, chart2);

    // borderVisible
    chart1.setBorderVisible(true);
    assertFalse(chart1.equals(chart2));
    chart2.setBorderVisible(true);
    assertEquals(chart1, chart2);

    // borderStroke
    BasicStroke s = new BasicStroke(2.0f);
    chart1.setBorderStroke(s);
    assertFalse(chart1.equals(chart2));
    chart2.setBorderStroke(s);
    assertEquals(chart1, chart2);

    // borderPaint
    chart1.setBorderPaint(Color.red);
    assertFalse(chart1.equals(chart2));
    chart2.setBorderPaint(Color.red);
    assertEquals(chart1, chart2);

    // padding
    chart1.setPadding(new RectangleInsets(1, 2, 3, 4));
    assertFalse(chart1.equals(chart2));
    chart2.setPadding(new RectangleInsets(1, 2, 3, 4));
    assertEquals(chart1, chart2);

    // title
    chart1.setTitle("XYZ");
    assertFalse(chart1.equals(chart2));
    chart2.setTitle("XYZ");
    assertEquals(chart1, chart2);

    // subtitles
    chart1.addSubtitle(new TextTitle("Subtitle"));
    assertFalse(chart1.equals(chart2));
    chart2.addSubtitle(new TextTitle("Subtitle"));
    assertEquals(chart1, chart2);

    // plot
    chart1 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new RingPlot(), false);
    chart2 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new PiePlot(), false);
    assertFalse(chart1.equals(chart2));
    chart2 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new RingPlot(), false);
    assertEquals(chart1, chart2);

    // backgroundPaint
    chart1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red,
            3.0f, 4.0f, Color.blue));
    assertFalse(chart1.equals(chart2));
    chart2.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red,
            3.0f, 4.0f, Color.blue));
    assertEquals(chart1, chart2);

    // backgroundImage
    chart1.setBackgroundImage(JFreeChart.INFO.getLogo());
    assertFalse(chart1.equals(chart2));
    chart2.setBackgroundImage(JFreeChart.INFO.getLogo());
    assertEquals(chart1, chart2);

    // backgroundImageAlignment
    chart1.setBackgroundImageAlignment(Align.BOTTOM_LEFT);
    assertFalse(chart1.equals(chart2));
    chart2.setBackgroundImageAlignment(Align.BOTTOM_LEFT);
    assertEquals(chart1, chart2);

    // backgroundImageAlpha
    chart1.setBackgroundImageAlpha(0.1f);
    assertFalse(chart1.equals(chart2));
    chart2.setBackgroundImageAlpha(0.1f);
    assertEquals(chart1, chart2);
}
 
Example #13
Source File: JFreeChartTest.java    From ECG-Viewer with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Check that the equals() method can distinguish all fields.
 */
@Test
public void testEquals() {
    JFreeChart chart1 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new PiePlot(), true);
    JFreeChart chart2 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new PiePlot(), true);
    assertEquals(chart1, chart2);
    assertEquals(chart2, chart1);

    // renderingHints
    chart1.setRenderingHints(new RenderingHints(
            RenderingHints.KEY_TEXT_ANTIALIASING,
            RenderingHints.VALUE_TEXT_ANTIALIAS_ON));
    assertFalse(chart1.equals(chart2));
    chart2.setRenderingHints(new RenderingHints(
            RenderingHints.KEY_TEXT_ANTIALIASING,
            RenderingHints.VALUE_TEXT_ANTIALIAS_ON));
    assertEquals(chart1, chart2);

    // borderVisible
    chart1.setBorderVisible(true);
    assertFalse(chart1.equals(chart2));
    chart2.setBorderVisible(true);
    assertEquals(chart1, chart2);

    // borderStroke
    BasicStroke s = new BasicStroke(2.0f);
    chart1.setBorderStroke(s);
    assertFalse(chart1.equals(chart2));
    chart2.setBorderStroke(s);
    assertEquals(chart1, chart2);

    // borderPaint
    chart1.setBorderPaint(Color.red);
    assertFalse(chart1.equals(chart2));
    chart2.setBorderPaint(Color.red);
    assertEquals(chart1, chart2);

    // padding
    chart1.setPadding(new RectangleInsets(1, 2, 3, 4));
    assertFalse(chart1.equals(chart2));
    chart2.setPadding(new RectangleInsets(1, 2, 3, 4));
    assertEquals(chart1, chart2);

    // title
    chart1.setTitle("XYZ");
    assertFalse(chart1.equals(chart2));
    chart2.setTitle("XYZ");
    assertEquals(chart1, chart2);

    // subtitles
    chart1.addSubtitle(new TextTitle("Subtitle"));
    assertFalse(chart1.equals(chart2));
    chart2.addSubtitle(new TextTitle("Subtitle"));
    assertEquals(chart1, chart2);

    // plot
    chart1 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new RingPlot(), false);
    chart2 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new PiePlot(), false);
    assertFalse(chart1.equals(chart2));
    chart2 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new RingPlot(), false);
    assertEquals(chart1, chart2);

    // backgroundPaint
    chart1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red,
            3.0f, 4.0f, Color.blue));
    assertFalse(chart1.equals(chart2));
    chart2.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red,
            3.0f, 4.0f, Color.blue));
    assertEquals(chart1, chart2);

    // backgroundImage
    chart1.setBackgroundImage(JFreeChart.INFO.getLogo());
    assertFalse(chart1.equals(chart2));
    chart2.setBackgroundImage(JFreeChart.INFO.getLogo());
    assertEquals(chart1, chart2);

    // backgroundImageAlignment
    chart1.setBackgroundImageAlignment(Align.BOTTOM_LEFT);
    assertFalse(chart1.equals(chart2));
    chart2.setBackgroundImageAlignment(Align.BOTTOM_LEFT);
    assertEquals(chart1, chart2);

    // backgroundImageAlpha
    chart1.setBackgroundImageAlpha(0.1f);
    assertFalse(chart1.equals(chart2));
    chart2.setBackgroundImageAlpha(0.1f);
    assertEquals(chart1, chart2);
}
 
Example #14
Source File: JFreeChartTest.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Check that the equals() method can distinguish all fields.
 */
@Test
public void testEquals() {
    JFreeChart chart1 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new PiePlot(), true);
    JFreeChart chart2 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new PiePlot(), true);
    assertEquals(chart1, chart2);
    assertEquals(chart2, chart1);

    // renderingHints
    chart1.setRenderingHints(new RenderingHints(
            RenderingHints.KEY_TEXT_ANTIALIASING,
            RenderingHints.VALUE_TEXT_ANTIALIAS_ON));
    assertFalse(chart1.equals(chart2));
    chart2.setRenderingHints(new RenderingHints(
            RenderingHints.KEY_TEXT_ANTIALIASING,
            RenderingHints.VALUE_TEXT_ANTIALIAS_ON));
    assertEquals(chart1, chart2);

    // borderVisible
    chart1.setBorderVisible(true);
    assertFalse(chart1.equals(chart2));
    chart2.setBorderVisible(true);
    assertEquals(chart1, chart2);

    // borderStroke
    BasicStroke s = new BasicStroke(2.0f);
    chart1.setBorderStroke(s);
    assertFalse(chart1.equals(chart2));
    chart2.setBorderStroke(s);
    assertEquals(chart1, chart2);

    // borderPaint
    chart1.setBorderPaint(Color.red);
    assertFalse(chart1.equals(chart2));
    chart2.setBorderPaint(Color.red);
    assertEquals(chart1, chart2);

    // padding
    chart1.setPadding(new RectangleInsets(1, 2, 3, 4));
    assertFalse(chart1.equals(chart2));
    chart2.setPadding(new RectangleInsets(1, 2, 3, 4));
    assertEquals(chart1, chart2);

    // title
    chart1.setTitle("XYZ");
    assertFalse(chart1.equals(chart2));
    chart2.setTitle("XYZ");
    assertEquals(chart1, chart2);

    // subtitles
    chart1.addSubtitle(new TextTitle("Subtitle"));
    assertFalse(chart1.equals(chart2));
    chart2.addSubtitle(new TextTitle("Subtitle"));
    assertEquals(chart1, chart2);

    // plot
    chart1 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new RingPlot(), false);
    chart2 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new PiePlot(), false);
    assertFalse(chart1.equals(chart2));
    chart2 = new JFreeChart("Title",
            new Font("SansSerif", Font.PLAIN, 12), new RingPlot(), false);
    assertEquals(chart1, chart2);

    // backgroundPaint
    chart1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red,
            3.0f, 4.0f, Color.blue));
    assertFalse(chart1.equals(chart2));
    chart2.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red,
            3.0f, 4.0f, Color.blue));
    assertEquals(chart1, chart2);

    // backgroundImage
    chart1.setBackgroundImage(JFreeChart.INFO.getLogo());
    assertFalse(chart1.equals(chart2));
    chart2.setBackgroundImage(JFreeChart.INFO.getLogo());
    assertEquals(chart1, chart2);

    // backgroundImageAlignment
    chart1.setBackgroundImageAlignment(Align.BOTTOM_LEFT);
    assertFalse(chart1.equals(chart2));
    chart2.setBackgroundImageAlignment(Align.BOTTOM_LEFT);
    assertEquals(chart1, chart2);

    // backgroundImageAlpha
    chart1.setBackgroundImageAlpha(0.1f);
    assertFalse(chart1.equals(chart2));
    chart2.setBackgroundImageAlpha(0.1f);
    assertEquals(chart1, chart2);
}