file_name
stringlengths 6
86
| file_path
stringlengths 45
249
| content
stringlengths 47
6.26M
| file_size
int64 47
6.26M
| language
stringclasses 1
value | extension
stringclasses 1
value | repo_name
stringclasses 767
values | repo_stars
int64 8
14.4k
| repo_forks
int64 0
1.17k
| repo_open_issues
int64 0
788
| repo_created_at
stringclasses 767
values | repo_pushed_at
stringclasses 767
values |
---|---|---|---|---|---|---|---|---|---|---|---|
GrayPaintScaleTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/GrayPaintScaleTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2013, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ------------------------
* GrayPaintScaleTests.java
* ------------------------
* (C) Copyright 2006-2013, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 05-Jul-2006 : Version 1 (DG);
* 26-Sep-2007 : Added testConstructor() and testGetPaint() (DG);
* 29-Jan-2009 : Extended testEquals() for new alpha field (DG);
*
*/
package org.jfree.chart.renderer;
import org.junit.Test;
import java.awt.Color;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
/**
* Tests for the {@link GrayPaintScale} class.
*/
public class GrayPaintScaleTest {
private static final double EPSILON = 0.000000001;
/**
* Simple check for the default constructor.
*/
@Test
public void testConstructor() {
GrayPaintScale gps = new GrayPaintScale();
assertEquals(0.0, gps.getLowerBound(), EPSILON);
assertEquals(1.0, gps.getUpperBound(), EPSILON);
assertEquals(255, gps.getAlpha());
}
/**
* Some checks for the getPaint() method.
*/
@Test
public void testGetPaint() {
GrayPaintScale gps = new GrayPaintScale();
Color c = (Color) gps.getPaint(0.0);
assertEquals(c, Color.BLACK);
c = (Color) gps.getPaint(1.0);
assertEquals(c, Color.WHITE);
// check lookup values that are outside the bounds - see bug report
// 1767315
c = (Color) gps.getPaint(-0.5);
assertEquals(c, Color.BLACK);
c = (Color) gps.getPaint(1.5);
assertEquals(c, Color.WHITE);
// add a check for Double.NAN
c = (Color) gps.getPaint(Double.NaN);
assertEquals(c, Color.BLACK);
c = (Color) gps.getPaint(Double.POSITIVE_INFINITY);
assertEquals(c, Color.WHITE);
c = (Color) gps.getPaint(Double.NEGATIVE_INFINITY);
assertEquals(c, Color.BLACK);
}
/**
* A test for the equals() method.
*/
@Test
public void testEquals() {
GrayPaintScale g1 = new GrayPaintScale();
GrayPaintScale g2 = new GrayPaintScale();
assertEquals(g1, g2);
assertEquals(g2, g1);
g1 = new GrayPaintScale(0.0, 1.0);
g2 = new GrayPaintScale(0.0, 1.0);
assertEquals(g1, g2);
g1 = new GrayPaintScale(0.1, 1.0);
assertFalse(g1.equals(g2));
g2 = new GrayPaintScale(0.1, 1.0);
assertEquals(g1, g2);
g1 = new GrayPaintScale(0.1, 0.9);
assertFalse(g1.equals(g2));
g2 = new GrayPaintScale(0.1, 0.9);
assertEquals(g1, g2);
g1 = new GrayPaintScale(0.1, 0.9, 128);
assertFalse(g1.equals(g2));
g2 = new GrayPaintScale(0.1, 0.9, 128);
assertEquals(g1, g2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
GrayPaintScale g1 = new GrayPaintScale();
GrayPaintScale g2 = (GrayPaintScale) g1.clone();
assertNotSame(g1, g2);
assertSame(g1.getClass(), g2.getClass());
assertEquals(g1, g2);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
GrayPaintScale g1 = new GrayPaintScale();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(g1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
GrayPaintScale g2 = (GrayPaintScale) in.readObject();
in.close();
assertEquals(g1, g2);
}
}
| 5,371 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
AreaRendererEndTypeTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/AreaRendererEndTypeTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* -----------------------------
* AreaRendererEndTypeTests.java
* -----------------------------
* (C) Copyright 2004-2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 29-Apr-2004 : Version 1 (DG);
*
*/
package org.jfree.chart.renderer;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
/**
* Tests for the {@link AreaRendererEndType} class.
*/
public class AreaRendererEndTypeTest {
/**
* A test for the equals() method.
*/
@Test
public void testEquals() {
assertEquals(AreaRendererEndType.LEVEL, AreaRendererEndType.LEVEL);
assertEquals(AreaRendererEndType.TAPER, AreaRendererEndType.TAPER);
assertEquals(
AreaRendererEndType.TRUNCATE, AreaRendererEndType.TRUNCATE
);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
AreaRendererEndType t1 = AreaRendererEndType.TAPER;
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(t1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray())
);
AreaRendererEndType t2 = (AreaRendererEndType) in.readObject();
in.close();
assertSame(t1, t2);
}
}
| 3,090 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
RendererUtilitiesTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/RendererUtilitiesTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ---------------------------
* RendererUtilitiesTests.java
* ---------------------------
* (C) Copyright 2007-2012, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 19-Apr-2007 : Version 1 (DG);
* 23-Aug-2012 : Added test3561093() (DG);
*
*/
package org.jfree.chart.renderer;
import org.jfree.data.DomainOrder;
import org.jfree.data.xy.DefaultXYDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
/**
* Some checks for the {@link RendererUtilities} class.
*/
public class RendererUtilitiesTest {
/**
* Some checks for the findLiveItemsLowerBound() method when the dataset is
* unordered.
*/
@Test
public void testFindLiveItemsLowerBound_Unordered() {
DefaultXYDataset d = new DefaultXYDataset();
// check a series with no items
d.addSeries("S1", new double[][] {{}, {}});
assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 0, 10.0,
11.0));
// check a series with one item
d.addSeries("S2", new double[][] {{0.0}, {9.9}});
assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 1, 0.0,
1.1));
assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 1, 2.0,
3.3));
// check a series with two items
d.addSeries("S3", new double[][] {{0.0, 1.0}, {9.9, 9.9}});
assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 2, 0.0,
1.1));
assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 2, 1.0,
2.2));
assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 2, 2.0,
3.3));
assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 2, 3.0,
4.4));
// check a series with three items
d.addSeries("S4", new double[][] {{1.0, 2.0, 1.5}, {9.9, 9.9, 9.9}});
assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 3, 0.0,
1.1));
assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 3, 1.0,
2.2));
assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 3, 2.0,
3.3));
assertEquals(2, RendererUtilities.findLiveItemsLowerBound(d, 3, 3.0,
4.4));
// check a series with four items
d.addSeries("S5", new double[][] {{1.0, 2.0, 1.5, 1.8}, {9.9, 9.9,
9.9, 9.9}});
assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 0.0,
1.1));
assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 1.0,
2.2));
assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 4, 2.0,
3.3));
assertEquals(3, RendererUtilities.findLiveItemsLowerBound(d, 4, 3.0,
4.4));
assertEquals(3, RendererUtilities.findLiveItemsLowerBound(d, 4, 4.0,
5.5));
}
/**
* Some checks for the findLiveItemsLowerBound() method when the dataset is
* ASCENDING.
*/
@Test
public void testFindLiveItemsLowerBound_Ascending() {
DefaultXYDataset d = new DefaultXYDataset() {
@Override
public DomainOrder getDomainOrder() {
// we're doing this for testing only, and make sure that we
// only add data in ascending order by x-value
return DomainOrder.ASCENDING;
}
};
// check a series with no items
d.addSeries("S1", new double[][] {{}, {}});
assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 0, 10.0,
11.1));
// check a series with one item
d.addSeries("S2", new double[][] {{1.0}, {9.9}});
assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 1, 0.0,
1.1));
assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 1, 2.0,
2.2));
// check a series with two items
d.addSeries("S3", new double[][] {{1.0, 2.0}, {9.9, 9.9}});
assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 2, 0.0,
1.1));
assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 2, 1.0,
2.2));
assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 2, 2.0,
3.3));
assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 2, 3.0,
4.4));
// check a series with three items
d.addSeries("S4", new double[][] {{1.0, 2.0, 3.0}, {9.9, 9.9, 9.9}});
assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 3, 0.0,
1.1));
assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 3, 1.0,
2.2));
assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 3, 2.0,
3.3));
assertEquals(2, RendererUtilities.findLiveItemsLowerBound(d, 3, 3.0,
4.4));
// check a series with four items
d.addSeries("S5", new double[][] {{1.0, 2.0, 3.0, 4.0}, {9.9, 9.9,
9.9, 9.9}});
assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 0.0,
1.1));
assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 1.0,
2.2));
assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 4, 2.0,
3.3));
assertEquals(2, RendererUtilities.findLiveItemsLowerBound(d, 4, 3.0,
4.4));
assertEquals(3, RendererUtilities.findLiveItemsLowerBound(d, 4, 4.0,
5.5));
// check a series with repeating items
d.addSeries("S5", new double[][] {{1.0, 2.0, 2.0, 2.0, 3.0}, {9.9, 9.9,
9.9, 9.9, 9.9}});
assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 0.0,
4.0));
assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 1.0,
4.0));
assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 4, 2.0,
4.0));
assertEquals(4, RendererUtilities.findLiveItemsLowerBound(d, 4, 3.0,
4.0));
}
/**
* Some checks for the findLiveItemsLowerBound() method when the dataset is
* DESCENDING.
*/
@Test
public void testFindLiveItemsLowerBound_Descending() {
DefaultXYDataset d = new DefaultXYDataset() {
@Override
public DomainOrder getDomainOrder() {
// we're doing this for testing only, and make sure that we
// only add data in descending order by x-value
return DomainOrder.DESCENDING;
}
};
// check a series with no items
d.addSeries("S1", new double[][] {{}, {}});
assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 0, 10.0,
11.0));
// check a series with one item
d.addSeries("S2", new double[][] {{1.0}, {9.9}});
assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 1, 0.0,
1.0));
assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 1, 1.1,
2.0));
// check a series with two items
d.addSeries("S3", new double[][] {{2.0, 1.0}, {9.9, 9.9}});
assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 2, 0.1,
0.5));
assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 2, 0.1,
1.0));
assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 2, 1.1,
2.0));
assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 2, 2.2,
3.0));
assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 2, 3.3,
4.0));
// check a series with three items
d.addSeries("S4", new double[][] {{3.0, 2.0, 1.0}, {9.9, 9.9, 9.9}});
assertEquals(2, RendererUtilities.findLiveItemsLowerBound(d, 3, 0.0,
1.0));
assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 3, 1.0,
2.0));
assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 3, 2.0,
3.0));
assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 3, 3.0,
4.0));
// check a series with four items
d.addSeries("S5", new double[][] {{4.0, 3.0, 2.0, 1.0}, {9.9, 9.9,
9.9, 9.9}});
assertEquals(3, RendererUtilities.findLiveItemsLowerBound(d, 4, 0.1,
0.5));
assertEquals(3, RendererUtilities.findLiveItemsLowerBound(d, 4, 0.1,
1.0));
assertEquals(2, RendererUtilities.findLiveItemsLowerBound(d, 4, 1.1,
2.0));
assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 4, 2.2,
3.0));
assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 3.3,
4.0));
assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 4.4,
5.0));
// check a series with repeating items
d.addSeries("S6", new double[][] {{3.0, 2.0, 2.0, 2.0, 1.0}, {9.9, 9.9,
9.9, 9.9, 9.9}});
assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 5, 0.0,
3.0));
assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 5, 0.0,
2.0));
assertEquals(4, RendererUtilities.findLiveItemsLowerBound(d, 5, 0.0,
1.0));
assertEquals(4, RendererUtilities.findLiveItemsLowerBound(d, 5, 0.0,
0.5));
}
/**
* Some checks for the findLiveItemsUpperBound() method when the dataset is
* unordered.
*/
@Test
public void testFindLiveItemsUpperBound_Unordered() {
DefaultXYDataset d = new DefaultXYDataset();
// check a series with no items
d.addSeries("S1", new double[][] {{}, {}});
assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 0, 10.0,
11.0));
// check a series with one item
d.addSeries("S2", new double[][] {{1.0}, {9.9}});
assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 1, 0.0,
1.1));
assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 1, 2.0,
3.3));
// check a series with two items
d.addSeries("S3", new double[][] {{1.0, 2.0}, {9.9, 9.9}});
assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 2, 0.0,
1.1));
assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 1.0,
2.2));
assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 2.0,
3.3));
assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 3.0,
4.4));
// check a series with three items
d.addSeries("S4", new double[][] {{1.0, 2.0, 1.5}, {9.9, 9.9, 9.9}});
assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 3, 0.0,
1.1));
assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 3, 1.0,
2.2));
assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 3, 2.0,
3.3));
assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 3, 3.0,
4.4));
// check a series with four items
d.addSeries("S5", new double[][] {{1.0, 2.0, 1.5, 1.8}, {9.9, 9.9,
9.9, 9.9}});
assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 4, 0.0,
1.1));
assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 1.0,
2.2));
assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 2.0,
3.3));
assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 3.0,
4.4));
assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 4.0,
5.5));
}
/**
* Some checks for the findLiveItemsUpperBound() method when the dataset is
* ASCENDING.
*/
@Test
public void testFindLiveItemsUpperBound_Ascending() {
DefaultXYDataset d = new DefaultXYDataset() {
@Override
public DomainOrder getDomainOrder() {
// we're doing this for testing only, and make sure that we
// only add data in ascending order by x-value
return DomainOrder.ASCENDING;
}
};
// check a series with no items
d.addSeries("S1", new double[][] {{}, {}});
assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 0, 10.0,
11.1));
// check a series with one item
d.addSeries("S2", new double[][] {{1.0}, {9.9}});
assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 1, 0.0,
1.1));
assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 1, 2.0,
2.2));
// check a series with two items
d.addSeries("S3", new double[][] {{1.0, 2.0}, {9.9, 9.9}});
assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 2, 0.0,
1.0));
assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 1.0,
2.2));
assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 2.0,
3.3));
assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 3.0,
4.4));
// check a series with three items
d.addSeries("S4", new double[][] {{1.0, 2.0, 3.0}, {9.9, 9.9, 9.9}});
assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 3, 0.0,
1.1));
assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 3, 1.0,
2.2));
assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 3, 2.0,
3.3));
assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 3, 3.0,
4.4));
// check a series with four items
d.addSeries("S5", new double[][] {{1.0, 2.0, 3.0, 4.0}, {9.9, 9.9,
9.9, 9.9}});
assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 4, 0.0,
1.1));
assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 4, 1.0,
2.2));
assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 4, 2.0,
3.3));
assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 3.0,
4.4));
assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 4.0,
5.5));
// check a series with repeating items
d.addSeries("S5", new double[][] {{1.0, 2.0, 2.0, 2.0, 3.0}, {9.9, 9.9,
9.9, 9.9, 9.9}});
assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 4, 0.0,
1.0));
assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 0.0,
2.0));
assertEquals(4, RendererUtilities.findLiveItemsUpperBound(d, 4, 0.0,
3.0));
assertEquals(4, RendererUtilities.findLiveItemsUpperBound(d, 4, 0.0,
4.0));
}
/**
* Some checks for the findLiveItemsUpperBound() method when the dataset is
* DESCENDING.
*/
@Test
public void testFindLiveItemsUpperBound_Descending() {
DefaultXYDataset d = new DefaultXYDataset() {
@Override
public DomainOrder getDomainOrder() {
// we're doing this for testing only, and make sure that we
// only add data in descending order by x-value
return DomainOrder.DESCENDING;
}
};
// check a series with no items
d.addSeries("S1", new double[][] {{}, {}});
assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 0, 10.0,
11.0));
// check a series with one item
d.addSeries("S2", new double[][] {{1.0}, {9.9}});
assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 1, 0.0,
1.0));
assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 1, 1.1,
2.0));
// check a series with two items
d.addSeries("S3", new double[][] {{2.0, 1.0}, {9.9, 9.9}});
assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 0.1,
0.5));
assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 0.1,
1.0));
assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 2, 1.1,
2.0));
assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 2, 2.2,
3.0));
assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 2, 3.3,
4.0));
// check a series with three items
d.addSeries("S4", new double[][] {{3.0, 2.0, 1.0}, {9.9, 9.9, 9.9}});
assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 3, 0.0,
1.0));
assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 3, 1.0,
2.0));
assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 3, 2.0,
3.0));
assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 3, 3.0,
4.0));
// check a series with four items
d.addSeries("S5", new double[][] {{4.0, 3.0, 2.0, 1.0}, {9.9, 9.9,
9.9, 9.9}});
assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 0.1,
0.5));
assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 0.1,
1.0));
assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 4, 1.1,
2.0));
assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 4, 2.2,
3.0));
assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 4, 3.3,
4.0));
assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 4, 4.4,
5.0));
// check a series with repeating items
d.addSeries("S6", new double[][] {{3.0, 2.0, 2.0, 2.0, 1.0}, {9.9, 9.9,
9.9, 9.9, 9.9}});
assertEquals(4, RendererUtilities.findLiveItemsUpperBound(d, 5, 0.0,
5.0));
assertEquals(4, RendererUtilities.findLiveItemsUpperBound(d, 5, 1.0,
5.0));
assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 5, 2.0,
5.0));
assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 5, 3.0,
5.0));
}
/**
* Checks the bounds calculation for a series where the x-ordering is not
* known. See bug 3561093.
*/
@Test
public void test3561093() {
XYSeries s = new XYSeries("S1", false);
s.add(0.0, 0.0);
s.add(21.0, 0.0);
s.add(2.0, 0.0);
s.add(23.0, 0.0);
XYSeriesCollection dataset = new XYSeriesCollection();
dataset.addSeries(s);
assertEquals(1, RendererUtilities.findLiveItemsLowerBound(dataset, 0,
10.0, 20.0));
assertEquals(2, RendererUtilities.findLiveItemsUpperBound(dataset, 0,
10.0, 20.0));
int[] bounds = RendererUtilities.findLiveItems(dataset, 0, 10.0, 20.0);
assertEquals(1, bounds[0]);
assertEquals(2, bounds[1]);
}
}
| 21,046 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
RendererChangeDetector.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/RendererChangeDetector.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ---------------------------
* RendererChangeDetector.java
* ---------------------------
* (C) Copyright 2003-2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 29-Oct-2003 : Version 1 (DG);
*
*/
package org.jfree.chart.renderer;
import org.jfree.chart.event.RendererChangeEvent;
import org.jfree.chart.event.RendererChangeListener;
/**
* A simple class for detecting whether or not a renderer has generated
* a {@link RendererChangeEvent}.
*/
public class RendererChangeDetector implements RendererChangeListener {
/** A flag that records whether or not a change event has been received. */
private boolean notified;
/**
* Creates a new detector.
*/
public RendererChangeDetector() {
this.notified = false;
}
/**
* Returns the flag that indicates whether or not a change event has been
* received.
*
* @return The flag.
*/
public boolean getNotified() {
return this.notified;
}
/**
* Sets the flag that indicates whether or not a change event has been
* received.
*
* @param notified the new value of the flag.
*/
public void setNotified(boolean notified) {
this.notified = notified;
}
/**
* Receives a {@link RendererChangeEvent} from a renderer.
*
* @param event the event.
*/
@Override
public void rendererChanged(RendererChangeEvent event) {
this.notified = true;
}
}
| 2,810 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
LookupPaintScaleTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/LookupPaintScaleTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2013, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* --------------------------
* LookupPaintScaleTests.java
* --------------------------
* (C) Copyright 2006-2013, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 05-Jul-2006 : Version 1 (DG);
* 31-Jan-2007 : Additional serialization tests (DG);
* 07-Mar-2007 : Added new tests (DG);
* 09-Mar-2007 : Check independence in testCloning() (DG);
*
*/
package org.jfree.chart.renderer;
import org.junit.Test;
import java.awt.Color;
import java.awt.GradientPaint;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
/**
* Tests for the {@link LookupPaintScale} class.
*/
public class LookupPaintScaleTest {
/**
* A test for the equals() method.
*/
@Test
public void testEquals() {
LookupPaintScale g1 = new LookupPaintScale();
LookupPaintScale g2 = new LookupPaintScale();
assertEquals(g1, g2);
assertEquals(g2, g1);
g1 = new LookupPaintScale(1.0, 2.0, Color.RED);
assertFalse(g1.equals(g2));
g2 = new LookupPaintScale(1.0, 2.0, Color.RED);
assertEquals(g1, g2);
g1.add(1.5, new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f,
Color.BLUE));
assertFalse(g1.equals(g2));
g2.add(1.5, new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f,
Color.BLUE));
assertEquals(g1, g2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
LookupPaintScale g1 = new LookupPaintScale();
LookupPaintScale g2 = (LookupPaintScale) g1.clone();
assertNotSame(g1, g2);
assertSame(g1.getClass(), g2.getClass());
assertEquals(g1, g2);
// check independence
g1.add(0.5, Color.RED);
assertFalse(g1.equals(g2));
g2.add(0.5, Color.RED);
assertEquals(g1, g2);
// try with gradient paint
g1 = new LookupPaintScale(1.0, 2.0, new GradientPaint(1.0f, 2.0f,
Color.RED, 3.0f, 4.0f, Color.green));
g1.add(1.5, new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f,
Color.BLUE));
g2 = (LookupPaintScale) g1.clone();
assertNotSame(g1, g2);
assertSame(g1.getClass(), g2.getClass());
assertEquals(g1, g2);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
LookupPaintScale g1 = new LookupPaintScale();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(g1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
LookupPaintScale g2 = (LookupPaintScale) in.readObject();
in.close();
assertEquals(g1, g2);
g1 = new LookupPaintScale(1.0, 2.0, new GradientPaint(1.0f, 2.0f,
Color.RED, 3.0f, 4.0f, Color.yellow));
g1.add(1.5, new GradientPaint(1.1f, 2.2f, Color.RED, 3.3f, 4.4f,
Color.BLUE));
buffer = new ByteArrayOutputStream();
out = new ObjectOutputStream(buffer);
out.writeObject(g1);
out.close();
in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
g2 = (LookupPaintScale) in.readObject();
in.close();
assertEquals(g1, g2);
}
private static final double EPSILON = 0.0000000001;
/**
* Some checks for the default constructor.
*/
@Test
public void testConstructor1() {
LookupPaintScale s = new LookupPaintScale();
assertEquals(0.0, s.getLowerBound(), EPSILON);
assertEquals(1.0, s.getUpperBound(), EPSILON);
}
/**
* Some checks for the other constructor.
*/
@Test
public void testConstructor2() {
LookupPaintScale s = new LookupPaintScale(1.0, 2.0, Color.RED);
assertEquals(1.0, s.getLowerBound(), EPSILON);
assertEquals(2.0, s.getUpperBound(), EPSILON);
assertEquals(Color.RED, s.getDefaultPaint());
}
/**
* Some general checks for the lookup table.
*/
@Test
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));
}
/**
* Some checks for special values in the getPaint() method.
*/
@Test
public void testSpecialValues() {
LookupPaintScale s = new LookupPaintScale(0.0, 100.0, Color.black);
s.add(25.0, Color.green);
s.add(50.0, Color.blue);
s.add(75.0, Color.yellow);
assertEquals(Color.black, s.getPaint(Double.NaN));
assertEquals(Color.black, s.getPaint(Double.POSITIVE_INFINITY));
assertEquals(Color.black, s.getPaint(Double.NEGATIVE_INFINITY));
}
}
| 8,228 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
AbstractRendererTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/AbstractRendererTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* --------------------------
* AbstractRendererTests.java
* --------------------------
* (C) Copyright 2003-2012, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 23-Oct-2003 : Version 1 (DG);
* 01-Mar-2004 : Added serialization test (DG);
* 19-Feb-2007 : Added testCloning (DG);
* 28-Feb-2007 : Added checks for cloning (DG);
* 17-Jun-2008 : Added new fields to testEquals() and testCloning() (DG);
* 28-Jan-2009 : Updated testEquals() (DG);
* 28-Apr-2009 : Updated testEquals() (DG);
* 17-Jun-2012 : Removed JCommon dependencies (DG);
*
*/
package org.jfree.chart.renderer;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.event.RendererChangeEvent;
import org.jfree.chart.event.RendererChangeListener;
import org.jfree.chart.labels.ItemLabelAnchor;
import org.jfree.chart.labels.ItemLabelPosition;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.DefaultDrawingSupplier;
import org.jfree.chart.renderer.category.BarRenderer;
import org.jfree.chart.renderer.category.LineAndShapeRenderer;
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
import org.jfree.chart.ui.TextAnchor;
import org.junit.Test;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
import java.awt.GradientPaint;
import java.awt.Rectangle;
import java.awt.Stroke;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Line2D;
import java.awt.geom.Rectangle2D;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link AbstractRenderer} class.
*/
public class AbstractRendererTest {
/**
* Test that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
// have to use a concrete subclass...
BarRenderer r1 = new BarRenderer();
BarRenderer r2 = new BarRenderer();
assertEquals(r1, r2);
assertEquals(r2, r1);
// seriesVisibleList
r1.setSeriesVisible(2, Boolean.TRUE);
assertFalse(r1.equals(r2));
r2.setSeriesVisible(2, Boolean.TRUE);
assertEquals(r1, r2);
// defaultSeriesVisible
r1.setDefaultSeriesVisible(false);
assertFalse(r1.equals(r2));
r2.setDefaultSeriesVisible(false);
assertEquals(r1, r2);
// seriesVisibleInLegendList
r1.setSeriesVisibleInLegend(1, Boolean.TRUE);
assertFalse(r1.equals(r2));
r2.setSeriesVisibleInLegend(1, Boolean.TRUE);
assertEquals(r1, r2);
// baseSeriesVisibleInLegend
r1.setDefaultSeriesVisibleInLegend(false);
assertFalse(r1.equals(r2));
r2.setDefaultSeriesVisibleInLegend(false);
assertEquals(r1, r2);
// paintList
r1.setSeriesPaint(0, new GradientPaint(1.0f, 2.0f, Color.RED,
3.0f, 4.0f, Color.WHITE));
assertFalse(r1.equals(r2));
r2.setSeriesPaint(0, new GradientPaint(1.0f, 2.0f, Color.RED,
3.0f, 4.0f, Color.WHITE));
assertEquals(r1, r2);
// basePaint
r1.setDefaultPaint(new GradientPaint(1.0f, 2.0f, Color.BLUE,
3.0f, 4.0f, Color.RED));
assertFalse(r1.equals(r2));
r2.setDefaultPaint(new GradientPaint(1.0f, 2.0f, Color.BLUE,
3.0f, 4.0f, Color.RED));
assertEquals(r1, r2);
// fillPaintList
r1.setSeriesFillPaint(0, new GradientPaint(1.0f, 2.0f, Color.BLUE,
3.0f, 4.0f, Color.RED));
assertFalse(r1.equals(r2));
r2.setSeriesFillPaint(0, new GradientPaint(1.0f, 2.0f, Color.BLUE,
3.0f, 4.0f, Color.RED));
assertEquals(r1, r2);
// baseFillPaint
r1.setDefaultFillPaint(new GradientPaint(1.0f, 2.0f, Color.BLUE,
3.0f, 4.0f, Color.RED));
assertFalse(r1.equals(r2));
r2.setDefaultFillPaint(new GradientPaint(1.0f, 2.0f, Color.BLUE,
3.0f, 4.0f, Color.RED));
assertEquals(r1, r2);
// outlinePaintList
r1.setSeriesOutlinePaint(0, new GradientPaint(1.0f, 2.0f, Color.BLUE,
3.0f, 4.0f, Color.RED));
assertFalse(r1.equals(r2));
r2.setSeriesOutlinePaint(0, new GradientPaint(1.0f, 2.0f, Color.BLUE,
3.0f, 4.0f, Color.RED));
assertEquals(r1, r2);
// baseOutlinePaint
r1.setDefaultOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.BLUE,
3.0f, 4.0f, Color.RED));
assertFalse(r1.equals(r2));
r2.setDefaultOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.BLUE,
3.0f, 4.0f, Color.RED));
assertEquals(r1, r2);
// strokeList
Stroke s = new BasicStroke(3.21f);
r1.setSeriesStroke(1, s);
assertFalse(r1.equals(r2));
r2.setSeriesStroke(1, s);
assertEquals(r1, r2);
// baseStroke
r1.setDefaultStroke(s);
assertFalse(r1.equals(r2));
r2.setDefaultStroke(s);
assertEquals(r1, r2);
// outlineStrokeList
r1.setSeriesOutlineStroke(0, s);
assertFalse(r1.equals(r2));
r2.setSeriesOutlineStroke(0, s);
assertEquals(r1, r2);
// baseOutlineStroke
r1.setDefaultOutlineStroke(s);
assertFalse(r1.equals(r2));
r2.setDefaultOutlineStroke(s);
assertEquals(r1, r2);
// shapeList
r1.setSeriesShape(1, new Ellipse2D.Double(1, 2, 3, 4));
assertFalse(r1.equals(r2));
r2.setSeriesShape(1, new Ellipse2D.Double(1, 2, 3, 4));
assertEquals(r1, r2);
// baseShape
r1.setDefaultShape(new Ellipse2D.Double(1, 2, 3, 4));
assertFalse(r1.equals(r2));
r2.setDefaultShape(new Ellipse2D.Double(1, 2, 3, 4));
assertEquals(r1, r2);
// itemLabelsVisibleList
r1.setSeriesItemLabelsVisible(1, Boolean.TRUE);
assertFalse(r1.equals(r2));
r2.setSeriesItemLabelsVisible(1, Boolean.TRUE);
assertEquals(r1, r2);
// baseItemLabelsVisible
r1.setDefaultItemLabelsVisible(true);
assertFalse(r1.equals(r2));
r2.setDefaultItemLabelsVisible(true);
assertEquals(r1, r2);
// itemLabelFontList
r1.setSeriesItemLabelFont(1, new Font("Serif", Font.BOLD, 9));
assertFalse(r1.equals(r2));
r2.setSeriesItemLabelFont(1, new Font("Serif", Font.BOLD, 9));
assertEquals(r1, r2);
// baseItemLabelFont
r1.setDefaultItemLabelFont(new Font("Serif", Font.PLAIN, 10));
assertFalse(r1.equals(r2));
r2.setDefaultItemLabelFont(new Font("Serif", Font.PLAIN, 10));
assertEquals(r1, r2);
// itemLabelPaintList
r1.setSeriesItemLabelPaint(0, new GradientPaint(1.0f, 2.0f, Color.RED,
3.0f, 4.0f, Color.gray));
assertFalse(r1.equals(r2));
r2.setSeriesItemLabelPaint(0, new GradientPaint(1.0f, 2.0f, Color.RED,
3.0f, 4.0f, Color.gray));
assertEquals(r1, r2);
// baseItemLabelPaint
r1.setDefaultItemLabelPaint(new GradientPaint(1.0f, 2.0f, Color.RED,
3.0f, 4.0f, Color.gray));
assertFalse(r1.equals(r2));
r2.setDefaultItemLabelPaint(new GradientPaint(1.0f, 2.0f, Color.RED,
3.0f, 4.0f, Color.gray));
assertEquals(r1, r2);
// positiveItemLabelPositionList;
r1.setSeriesPositiveItemLabelPosition(0, new ItemLabelPosition());
assertFalse(r1.equals(r2));
r2.setSeriesPositiveItemLabelPosition(0, new ItemLabelPosition());
assertEquals(r1, r2);
// basePositiveItemLabelPosition;
r1.setDefaultPositiveItemLabelPosition(new ItemLabelPosition(
ItemLabelAnchor.INSIDE10, TextAnchor.BASELINE_RIGHT));
assertFalse(r1.equals(r2));
r2.setDefaultPositiveItemLabelPosition(new ItemLabelPosition(
ItemLabelAnchor.INSIDE10, TextAnchor.BASELINE_RIGHT));
assertEquals(r1, r2);
// negativeItemLabelPositionList;
r1.setSeriesNegativeItemLabelPosition(1, new ItemLabelPosition(
ItemLabelAnchor.INSIDE10, TextAnchor.BASELINE_RIGHT));
assertFalse(r1.equals(r2));
r2.setSeriesNegativeItemLabelPosition(1, new ItemLabelPosition(
ItemLabelAnchor.INSIDE10, TextAnchor.BASELINE_RIGHT));
assertEquals(r1, r2);
// baseNegativeItemLabelPosition;
r1.setDefaultNegativeItemLabelPosition(new ItemLabelPosition(
ItemLabelAnchor.INSIDE10, TextAnchor.BASELINE_RIGHT));
assertFalse(r1.equals(r2));
r2.setDefaultNegativeItemLabelPosition(new ItemLabelPosition(
ItemLabelAnchor.INSIDE10, TextAnchor.BASELINE_RIGHT));
assertEquals(r1, r2);
// itemLabelAnchorOffset
r1.setItemLabelAnchorOffset(3.0);
assertFalse(r1.equals(r2));
r2.setItemLabelAnchorOffset(3.0);
assertEquals(r1, r2);
// createEntitiesList;
r1.setSeriesCreateEntities(0, Boolean.TRUE);
assertFalse(r1.equals(r2));
r2.setSeriesCreateEntities(0, Boolean.TRUE);
assertEquals(r1, r2);
// baseCreateEntities;
r1.setDefaultCreateEntities(false);
assertFalse(r1.equals(r2));
r2.setDefaultCreateEntities(false);
assertEquals(r1, r2);
// legendShape
r1.setLegendShape(0, new Ellipse2D.Double(1.0, 2.0, 3.0, 4.0));
assertFalse(r1.equals(r2));
r2.setLegendShape(0, new Ellipse2D.Double(1.0, 2.0, 3.0, 4.0));
assertEquals(r1, r2);
// baseLegendShape
r1.setDefaultLegendShape(new Ellipse2D.Double(5.0, 6.0, 7.0, 8.0));
assertFalse(r1.equals(r2));
r2.setDefaultLegendShape(new Ellipse2D.Double(5.0, 6.0, 7.0, 8.0));
assertEquals(r1, r2);
// legendTextFont
r1.setLegendTextFont(0, new Font("Dialog", Font.PLAIN, 7));
assertFalse(r1.equals(r2));
r2.setLegendTextFont(0, new Font("Dialog", Font.PLAIN, 7));
assertEquals(r1, r2);
// baseLegendTextFont
r1.setDefaultLegendTextFont(new Font("Dialog", Font.PLAIN, 7));
assertFalse(r1.equals(r2));
r2.setDefaultLegendTextFont(new Font("Dialog", Font.PLAIN, 7));
assertEquals(r1, r2);
// legendTextPaint
r1.setLegendTextPaint(0, new GradientPaint(1.0f, 2.0f, Color.BLUE,
3.0f, 4.0f, Color.RED));
assertFalse(r1.equals(r2));
r2.setLegendTextPaint(0, new GradientPaint(1.0f, 2.0f, Color.BLUE,
3.0f, 4.0f, Color.RED));
assertEquals(r1, r2);
// baseOutlinePaint
r1.setDefaultLegendTextPaint(new GradientPaint(1.0f, 2.0f, Color.BLUE,
3.0f, 4.0f, Color.RED));
assertFalse(r1.equals(r2));
r2.setDefaultLegendTextPaint(new GradientPaint(1.0f, 2.0f, Color.BLUE,
3.0f, 4.0f, Color.RED));
assertEquals(r1, r2);
}
private static class TestRenderer extends XYLineAndShapeRenderer {
@Override
public void setTreatLegendShapeAsLine(boolean flag) {
super.setTreatLegendShapeAsLine(flag);
}
}
/**
* Check that the treatLegendShapeAsLine flag is included in the equals()
* comparison.
*/
@Test
public void testEquals2() {
TestRenderer r1 = new TestRenderer();
TestRenderer r2 = new TestRenderer();
assertEquals(r1, r2);
r1.setTreatLegendShapeAsLine(true);
assertFalse(r1.equals(r2));
r2.setTreatLegendShapeAsLine(true);
assertEquals(r1, r2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
LineAndShapeRenderer r1 = new LineAndShapeRenderer();
Rectangle2D baseShape = new Rectangle2D.Double(11.0, 12.0, 13.0, 14.0);
r1.setDefaultShape(baseShape);
r1.setDefaultLegendShape(new Rectangle(4, 3, 2, 1));
r1.setDefaultLegendTextFont(new Font("Dialog", Font.PLAIN, 3));
r1.setDefaultLegendTextPaint(new Color(1, 2, 3));
LineAndShapeRenderer r2 = (LineAndShapeRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
r1.setSeriesVisible(0, Boolean.FALSE);
assertFalse(r1.equals(r2));
r2.setSeriesVisible(0, Boolean.FALSE);
assertEquals(r1, r2);
r1.setSeriesVisibleInLegend(0, Boolean.FALSE);
assertFalse(r1.equals(r2));
r2.setSeriesVisibleInLegend(0, Boolean.FALSE);
assertEquals(r1, r2);
r1.setSeriesPaint(0, Color.BLACK);
assertFalse(r1.equals(r2));
r2.setSeriesPaint(0, Color.BLACK);
assertEquals(r1, r2);
r1.setSeriesFillPaint(0, Color.yellow);
assertFalse(r1.equals(r2));
r2.setSeriesFillPaint(0, Color.yellow);
assertEquals(r1, r2);
r1.setSeriesOutlinePaint(0, Color.yellow);
assertFalse(r1.equals(r2));
r2.setSeriesOutlinePaint(0, Color.yellow);
assertEquals(r1, r2);
r1.setSeriesStroke(0, new BasicStroke(2.2f));
assertFalse(r1.equals(r2));
r2.setSeriesStroke(0, new BasicStroke(2.2f));
assertEquals(r1, r2);
r1.setSeriesOutlineStroke(0, new BasicStroke(2.2f));
assertFalse(r1.equals(r2));
r2.setSeriesOutlineStroke(0, new BasicStroke(2.2f));
assertEquals(r1, r2);
baseShape.setRect(4.0, 3.0, 2.0, 1.0);
assertFalse(r1.equals(r2));
r2.setDefaultShape(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0));
assertEquals(r1, r2);
r1.setSeriesShape(0, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0));
assertFalse(r1.equals(r2));
r2.setSeriesShape(0, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0));
assertEquals(r1, r2);
r1.setSeriesItemLabelsVisible(0, Boolean.TRUE);
assertFalse(r1.equals(r2));
r2.setSeriesItemLabelsVisible(0, Boolean.TRUE);
assertEquals(r1, r2);
r1.setSeriesItemLabelPaint(0, Color.RED);
assertFalse(r1.equals(r2));
r2.setSeriesItemLabelPaint(0, Color.RED);
assertEquals(r1, r2);
r1.setSeriesPositiveItemLabelPosition(0, new ItemLabelPosition());
assertFalse(r1.equals(r2));
r2.setSeriesPositiveItemLabelPosition(0, new ItemLabelPosition());
assertEquals(r1, r2);
r1.setSeriesNegativeItemLabelPosition(0, new ItemLabelPosition());
assertFalse(r1.equals(r2));
r2.setSeriesNegativeItemLabelPosition(0, new ItemLabelPosition());
assertEquals(r1, r2);
r1.setSeriesCreateEntities(0, Boolean.FALSE);
assertFalse(r1.equals(r2));
r2.setSeriesCreateEntities(0, Boolean.FALSE);
assertEquals(r1, r2);
r1.setLegendShape(0, new Rectangle(9, 7, 3, 4));
assertFalse(r1.equals(r2));
r2.setLegendShape(0, new Rectangle(9, 7, 3, 4));
assertEquals(r1, r2);
r1.setDefaultLegendShape(new Rectangle(3, 4, 1, 5));
assertFalse(r1.equals(r2));
r2.setDefaultLegendShape(new Rectangle(3, 4, 1, 5));
assertEquals(r1, r2);
r1.setLegendTextFont(1, new Font("Dialog", Font.PLAIN, 33));
assertFalse(r1.equals(r2));
r2.setLegendTextFont(1, new Font("Dialog", Font.PLAIN, 33));
assertEquals(r1, r2);
r1.setDefaultLegendTextFont(new Font("Dialog", Font.PLAIN, 11));
assertFalse(r1.equals(r2));
r2.setDefaultLegendTextFont(new Font("Dialog", Font.PLAIN, 11));
assertEquals(r1, r2);
r1.setLegendTextPaint(3, Color.RED);
assertFalse(r1.equals(r2));
r2.setLegendTextPaint(3, Color.RED);
assertEquals(r1, r2);
r1.setDefaultLegendTextPaint(Color.green);
assertFalse(r1.equals(r2));
r2.setDefaultLegendTextPaint(Color.green);
assertEquals(r1, r2);
}
/**
* A utility class for listening to changes to a renderer.
*/
static class MyRendererChangeListener implements RendererChangeListener {
/** The last event received. */
public RendererChangeEvent lastEvent;
/**
* Creates a new instance.
*/
public MyRendererChangeListener() {
this.lastEvent = null;
}
@Override
public void rendererChanged(RendererChangeEvent event) {
this.lastEvent = event;
}
}
/**
* A check for cloning.
*/
@Test
public void testCloning2() throws CloneNotSupportedException {
LineAndShapeRenderer r1 = new LineAndShapeRenderer();
r1.setDefaultPaint(Color.BLUE);
r1.setDefaultLegendTextPaint(new GradientPaint(1.0f, 2.0f, Color.RED,
3.0f, 4.0f, Color.BLUE));
LineAndShapeRenderer r2 = (LineAndShapeRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
MyRendererChangeListener listener = new MyRendererChangeListener();
r2.addChangeListener(listener);
r2.setDefaultPaint(Color.RED);
assertSame(listener.lastEvent.getRenderer(), r2);
assertFalse(r1.hasListener(listener));
}
/**
* Tests each setter method to ensure that it sends an event notification.
*/
@Test
public void testEventNotification() {
RendererChangeDetector detector = new RendererChangeDetector();
BarRenderer r1 = new BarRenderer(); // have to use a subclass of
// AbstractRenderer
r1.addChangeListener(detector);
// PAINT
detector.setNotified(false);
r1.setSeriesPaint(0, Color.RED);
assertTrue(detector.getNotified());
detector.setNotified(false);
r1.setDefaultPaint(Color.RED);
assertTrue(detector.getNotified());
// OUTLINE PAINT
detector.setNotified(false);
r1.setSeriesOutlinePaint(0, Color.RED);
assertTrue(detector.getNotified());
detector.setNotified(false);
r1.setDefaultOutlinePaint(Color.RED);
assertTrue(detector.getNotified());
// STROKE
detector.setNotified(false);
r1.setSeriesStroke(0, new BasicStroke(1.0f));
assertTrue(detector.getNotified());
detector.setNotified(false);
r1.setDefaultStroke(new BasicStroke(1.0f));
assertTrue(detector.getNotified());
// OUTLINE STROKE
detector.setNotified(false);
r1.setSeriesOutlineStroke(0, new BasicStroke(1.0f));
assertTrue(detector.getNotified());
detector.setNotified(false);
r1.setDefaultOutlineStroke(new BasicStroke(1.0f));
assertTrue(detector.getNotified());
// SHAPE
detector.setNotified(false);
r1.setSeriesShape(0, new Rectangle2D.Float());
assertTrue(detector.getNotified());
detector.setNotified(false);
r1.setDefaultShape(new Rectangle2D.Float());
assertTrue(detector.getNotified());
// ITEM_LABELS_VISIBLE
detector.setNotified(false);
r1.setSeriesItemLabelsVisible(0, Boolean.TRUE);
assertTrue(detector.getNotified());
detector.setNotified(false);
r1.setDefaultItemLabelsVisible(Boolean.TRUE);
assertTrue(detector.getNotified());
// ITEM_LABEL_FONT
detector.setNotified(false);
r1.setSeriesItemLabelFont(0, new Font("Serif", Font.PLAIN, 12));
assertTrue(detector.getNotified());
detector.setNotified(false);
r1.setDefaultItemLabelFont(new Font("Serif", Font.PLAIN, 12));
assertTrue(detector.getNotified());
// ITEM_LABEL_PAINT
detector.setNotified(false);
r1.setSeriesItemLabelPaint(0, Color.BLUE);
assertTrue(detector.getNotified());
detector.setNotified(false);
r1.setDefaultItemLabelPaint(Color.BLUE);
assertTrue(detector.getNotified());
// POSITIVE ITEM LABEL POSITION
detector.setNotified(false);
r1.setSeriesPositiveItemLabelPosition(0, new ItemLabelPosition(
ItemLabelAnchor.CENTER, TextAnchor.CENTER));
assertTrue(detector.getNotified());
detector.setNotified(false);
r1.setDefaultPositiveItemLabelPosition(new ItemLabelPosition(
ItemLabelAnchor.CENTER, TextAnchor.CENTER));
assertTrue(detector.getNotified());
// NEGATIVE ITEM LABEL ANCHOR
detector.setNotified(false);
r1.setSeriesNegativeItemLabelPosition(0, new ItemLabelPosition(
ItemLabelAnchor.CENTER, TextAnchor.CENTER));
assertTrue(detector.getNotified());
detector.setNotified(false);
r1.setDefaultNegativeItemLabelPosition(new ItemLabelPosition(
ItemLabelAnchor.CENTER, TextAnchor.CENTER));
assertTrue(detector.getNotified());
}
/**
* Serialize an instance, restore it, and check for equality. In addition,
* test for a bug that was reported where the listener list is 'null' after
* deserialization.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
BarRenderer r1 = new BarRenderer();
r1.setDefaultLegendTextFont(new Font("Dialog", Font.PLAIN, 4));
r1.setDefaultLegendTextPaint(new GradientPaint(1.0f, 2.0f, Color.RED,
3.0f, 4.0f, Color.green));
r1.setDefaultLegendShape(new Line2D.Double(1.0, 2.0, 3.0, 4.0));
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
BarRenderer r2 = (BarRenderer) in.readObject();
in.close();
assertEquals(r1, r2);
r2.notifyListeners(new RendererChangeEvent(r2));
}
/**
* Some checks for the autoPopulate flag default values.
*/
@Test
public void testAutoPopulateFlagDefaults() {
BarRenderer r = new BarRenderer();
assertEquals(true, r.getAutoPopulateSeriesPaint());
assertEquals(false, r.getAutoPopulateSeriesFillPaint());
assertEquals(false, r.getAutoPopulateSeriesOutlinePaint());
assertEquals(true, r.getAutoPopulateSeriesStroke());
assertEquals(false, r.getAutoPopulateSeriesOutlineStroke());
assertEquals(true, r.getAutoPopulateSeriesShape());
}
/**
* Some checks for the paint lookup mechanism.
*/
@Test
public void testPaintLookup() {
BarRenderer r = new BarRenderer();
assertEquals(Color.BLUE, r.getDefaultPaint());
// first check that autoPopulate==false works as expected
r.setAutoPopulateSeriesPaint(false);
assertEquals(Color.BLUE, r.lookupSeriesPaint(0));
assertNull(r.getSeriesPaint(0));
// now check autoPopulate==true
r.setAutoPopulateSeriesPaint(true);
/*CategoryPlot plot =*/ new CategoryPlot(null, new CategoryAxis(
"Category"), new NumberAxis("Value"), r);
assertEquals(DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE[0],
r.lookupSeriesPaint(0));
assertNotNull(r.getSeriesPaint(0));
}
/**
* Some checks for the fill paint lookup mechanism.
*/
@Test
public void testFillPaintLookup() {
BarRenderer r = new BarRenderer();
assertEquals(Color.WHITE, r.getDefaultFillPaint());
// first check that autoPopulate==false works as expected
r.setAutoPopulateSeriesFillPaint(false);
assertEquals(Color.WHITE, r.lookupSeriesFillPaint(0));
assertNull(r.getSeriesFillPaint(0));
// now check autoPopulate==true
r.setAutoPopulateSeriesFillPaint(true);
/*CategoryPlot plot =*/ new CategoryPlot(null, new CategoryAxis(
"Category"), new NumberAxis("Value"), r);
assertEquals(DefaultDrawingSupplier.DEFAULT_FILL_PAINT_SEQUENCE[0],
r.lookupSeriesFillPaint(0));
assertNotNull(r.getSeriesFillPaint(0));
}
/**
* Some checks for the outline paint lookup mechanism.
*/
@Test
public void testOutlinePaintLookup() {
BarRenderer r = new BarRenderer();
assertEquals(Color.gray, r.getDefaultOutlinePaint());
// first check that autoPopulate==false works as expected
r.setAutoPopulateSeriesOutlinePaint(false);
assertEquals(Color.gray, r.lookupSeriesOutlinePaint(0));
assertNull(r.getSeriesOutlinePaint(0));
// now check autoPopulate==true
r.setAutoPopulateSeriesOutlinePaint(true);
/*CategoryPlot plot =*/ new CategoryPlot(null, new CategoryAxis(
"Category"), new NumberAxis("Value"), r);
assertEquals(DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE[0],
r.lookupSeriesOutlinePaint(0));
assertNotNull(r.getSeriesOutlinePaint(0));
}
}
| 26,995 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
OutlierTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/OutlierTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* -----------------
* OutlierTests.java
* -----------------
* (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 21-Nov-2007 : Version 1 (DG);
*
*/
package org.jfree.chart.renderer;
import org.junit.Test;
import java.awt.geom.Point2D;
import java.io.Serializable;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
/**
* Tests for the {@link Outlier} class.
*/
public class OutlierTest {
private static final double EPSILON = 0.000000001;
/**
* Simple check for the default constructor.
*/
@Test
public void testConstructor() {
Outlier out = new Outlier(1.0, 2.0, 3.0);
assertEquals(-2.0, out.getX(), EPSILON);
assertEquals(-1.0, out.getY(), EPSILON);
assertEquals(3.0, out.getRadius(), EPSILON);
}
/**
* A test for the equals() method.
*/
@Test
public void testEquals() {
Outlier out1 = new Outlier(1.0, 2.0, 3.0);
Outlier out2 = new Outlier(1.0, 2.0, 3.0);
assertEquals(out1, out2);
assertEquals(out2, out1);
out1.setPoint(new Point2D.Double(2.0, 2.0));
assertFalse(out1.equals(out2));
out2.setPoint(new Point2D.Double(2.0, 2.0));
assertEquals(out1, out2);
out1.setPoint(new Point2D.Double(2.0, 3.0));
assertFalse(out1.equals(out2));
out2.setPoint(new Point2D.Double(2.0, 3.0));
assertEquals(out1, out2);
out1.setRadius(4.0);
assertFalse(out1.equals(out2));
out2.setRadius(4.0);
assertEquals(out1, out2);
}
/**
* Confirm that cloning is not implemented.
*/
@Test
public void testCloning() {
Outlier out1 = new Outlier(1.0, 2.0, 3.0);
assertFalse(out1 instanceof Cloneable);
}
/**
* Confirm that serialization is not implemented.
*/
@Test
public void testSerialization() {
Outlier out1 = new Outlier(1.0, 2.0, 3.0);
assertFalse(out1 instanceof Serializable);
}
}
| 3,396 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
DefaultPolarItemRendererTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/DefaultPolarItemRendererTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ----------------------------------
* DefaultPolarItemRendererTests.java
* ----------------------------------
* (C) Copyright 2006-2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 04-Aug-2006 : Version 1 (DG);
* 15-Mar-2007 : Added independence check to testCloning() (DG);
*
*/
package org.jfree.chart.renderer;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
/**
* Tests for the {@link DefaultPolarItemRenderer} class.
*/
public class DefaultPolarItemRendererTest {
/**
* Check that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
DefaultPolarItemRenderer r1 = new DefaultPolarItemRenderer();
DefaultPolarItemRenderer r2 = new DefaultPolarItemRenderer();
assertEquals(r1, r2);
r1.setSeriesFilled(1, true);
assertFalse(r1.equals(r2));
r2.setSeriesFilled(1, true);
assertEquals(r1, r2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
DefaultPolarItemRenderer r1 = new DefaultPolarItemRenderer();
DefaultPolarItemRenderer r2 = new DefaultPolarItemRenderer();
assertEquals(r1, r2);
int h1 = r1.hashCode();
int h2 = r2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
DefaultPolarItemRenderer r1 = new DefaultPolarItemRenderer();
DefaultPolarItemRenderer r2 = (DefaultPolarItemRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
r1.setSeriesFilled(1, true);
assertFalse(r1.equals(r2));
r2.setSeriesFilled(1, true);
assertEquals(r1, r2);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
DefaultPolarItemRenderer r1 = new DefaultPolarItemRenderer();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
DefaultPolarItemRenderer r2 = (DefaultPolarItemRenderer) in.readObject();
in.close();
assertEquals(r1, r2);
}
}
| 4,302 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
XYErrorRendererTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/xy/XYErrorRendererTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* -------------------------
* XYErrorRendererTests.java
* -------------------------
* (C) Copyright 2006-2011, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 25-Oct-2006 : Version 1 (DG);
* 22-Apr-2008 : Added testPublicCloneable (DG);
* 28-Jan-2009 : Updated tests for new errorStroke field (DG);
*
*/
package org.jfree.chart.renderer.xy;
import org.jfree.chart.util.PublicCloneable;
import org.junit.Test;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.GradientPaint;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link XYErrorRenderer} class.
*/
public class XYErrorRendererTest {
/**
* Check that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
XYErrorRenderer r1 = new XYErrorRenderer();
XYErrorRenderer r2 = new XYErrorRenderer();
assertEquals(r1, r2);
// drawXError
r1.setDrawXError(false);
assertFalse(r1.equals(r2));
r2.setDrawXError(false);
assertEquals(r1, r2);
// drawYError
r1.setDrawYError(false);
assertFalse(r1.equals(r2));
r2.setDrawYError(false);
assertEquals(r1, r2);
// capLength
r1.setCapLength(9.0);
assertFalse(r1.equals(r2));
r2.setCapLength(9.0);
assertEquals(r1, r2);
// errorPaint
r1.setErrorPaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f,
Color.green));
assertFalse(r1.equals(r2));
r2.setErrorPaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f,
Color.green));
assertEquals(r1, r2);
// errorStroke
r1.setErrorStroke(new BasicStroke(1.5f));
assertFalse(r1.equals(r2));
r2.setErrorStroke(new BasicStroke(1.5f));
assertEquals(r1, r2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
XYErrorRenderer r1 = new XYErrorRenderer();
XYErrorRenderer r2 = new XYErrorRenderer();
assertEquals(r1, r2);
int h1 = r1.hashCode();
int h2 = r2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
XYErrorRenderer r1 = new XYErrorRenderer();
r1.setErrorPaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f,
Color.WHITE));
XYErrorRenderer r2 = (XYErrorRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
}
/**
* A test for cloning.
*/
@Test
public void testCloning2() throws CloneNotSupportedException {
XYErrorRenderer r1 = new XYErrorRenderer();
r1.setErrorStroke(new BasicStroke(1.5f));
XYErrorRenderer r2 = (XYErrorRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
}
/**
* Verify that this class implements {@link PublicCloneable}.
*/
@Test
public void testPublicCloneable() {
XYErrorRenderer r1 = new XYErrorRenderer();
assertTrue(r1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
XYErrorRenderer r1 = new XYErrorRenderer();
r1.setErrorPaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f,
Color.WHITE));
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
XYErrorRenderer r2 = (XYErrorRenderer) in.readObject();
in.close();
assertEquals(r1, r2);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization2() throws IOException, ClassNotFoundException {
XYErrorRenderer r1 = new XYErrorRenderer();
r1.setErrorStroke(new BasicStroke(1.5f));
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
XYErrorRenderer r2 = (XYErrorRenderer) in.readObject();
in.close();
assertEquals(r1, r2);
}
/**
* Some checks for the findDomainBounds() method.
*/
@Test
public void testFindDomainBounds() {
XYErrorRenderer r = new XYErrorRenderer();
assertNull(r.findDomainBounds(null));
}
/**
* Some checks for the findRangeBounds() method.
*/
@Test
public void testFindRangeBounds() {
XYErrorRenderer r = new XYErrorRenderer();
assertNull(r.findRangeBounds(null));
}
}
| 7,074 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
WindItemRendererTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/xy/WindItemRendererTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* --------------------------
* WindItemRendererTests.java
* --------------------------
* (C) Copyright 2003-2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 25-Mar-2003 : Version 1 (DG);
* 22-Apr-2008 : Added testPublicCloneable (DG);
*
*/
package org.jfree.chart.renderer.xy;
import org.jfree.chart.util.PublicCloneable;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link WindItemRenderer} class.
*/
public class WindItemRendererTest {
/**
* Check that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
WindItemRenderer r1 = new WindItemRenderer();
WindItemRenderer r2 = new WindItemRenderer();
assertEquals(r1, r2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
WindItemRenderer r1 = new WindItemRenderer();
WindItemRenderer r2 = new WindItemRenderer();
assertEquals(r1, r2);
int h1 = r1.hashCode();
int h2 = r2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
WindItemRenderer r1 = new WindItemRenderer();
WindItemRenderer r2 = (WindItemRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
}
/**
* Verify that this class implements {@link PublicCloneable}.
*/
@Test
public void testPublicCloneable() {
WindItemRenderer r1 = new WindItemRenderer();
assertTrue(r1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
WindItemRenderer r1 = new WindItemRenderer();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
WindItemRenderer r2 = (WindItemRenderer) in.readObject();
in.close();
assertEquals(r1, r2);
}
}
| 4,128 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
HighLowRendererTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/xy/HighLowRendererTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* -------------------------
* HighLowRendererTests.java
* -------------------------
* (C) Copyright 2003-2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 25-Mar-2003 : Version 1 (DG);
* 22-Oct-2003 : Added hashCode test (DG);
* 01-Nov-2005 : Added tests for new fields (DG);
* 17-Aug-2006 : Added testFindRangeBounds() method (DG);
* 22-Apr-2008 : Added testPublicCloneable (DG);
* 29-Apr-2008 : Extended testEquals() for new field (DG);
*
*/
package org.jfree.chart.renderer.xy;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.data.Range;
import org.jfree.data.xy.DefaultOHLCDataset;
import org.jfree.data.xy.OHLCDataItem;
import org.jfree.data.xy.OHLCDataset;
import org.junit.Test;
import java.awt.Color;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.util.Date;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link HighLowRenderer} class.
*/
public class HighLowRendererTest {
/**
* Check that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
HighLowRenderer r1 = new HighLowRenderer();
HighLowRenderer r2 = new HighLowRenderer();
assertEquals(r1, r2);
// drawOpenTicks
r1.setDrawOpenTicks(false);
assertFalse(r1.equals(r2));
r2.setDrawOpenTicks(false);
assertEquals(r1, r2);
// drawCloseTicks
r1.setDrawCloseTicks(false);
assertFalse(r1.equals(r2));
r2.setDrawCloseTicks(false);
assertEquals(r1, r2);
// openTickPaint
r1.setOpenTickPaint(Color.RED);
assertFalse(r1.equals(r2));
r2.setOpenTickPaint(Color.RED);
assertEquals(r1, r2);
// closeTickPaint
r1.setCloseTickPaint(Color.BLUE);
assertFalse(r1.equals(r2));
r2.setCloseTickPaint(Color.BLUE);
assertEquals(r1, r2);
// tickLength
r1.setTickLength(99.9);
assertFalse(r1.equals(r2));
r2.setTickLength(99.9);
assertEquals(r1, r2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
HighLowRenderer r1 = new HighLowRenderer();
HighLowRenderer r2 = new HighLowRenderer();
assertEquals(r1, r2);
int h1 = r1.hashCode();
int h2 = r2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
HighLowRenderer r1 = new HighLowRenderer();
r1.setCloseTickPaint(Color.green);
HighLowRenderer r2 = (HighLowRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
}
/**
* Verify that this class implements {@link PublicCloneable}.
*/
@Test
public void testPublicCloneable() {
HighLowRenderer r1 = new HighLowRenderer();
assertTrue(r1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
HighLowRenderer r1 = new HighLowRenderer();
r1.setCloseTickPaint(Color.green);
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
HighLowRenderer r2 = (HighLowRenderer) in.readObject();
in.close();
assertEquals(r1, r2);
}
/**
* Some checks for the findRangeBounds() method.
*/
@Test
public void testFindRangeBounds() {
HighLowRenderer renderer = new HighLowRenderer();
OHLCDataItem item1 = new OHLCDataItem(new Date(1L), 2.0, 4.0, 1.0, 3.0,
100);
OHLCDataset dataset = new DefaultOHLCDataset("S1",
new OHLCDataItem[] {item1});
Range range = renderer.findRangeBounds(dataset);
assertEquals(new Range(1.0, 4.0), range);
OHLCDataItem item2 = new OHLCDataItem(new Date(1L), -1.0, 3.0, -1.0,
3.0, 100);
dataset = new DefaultOHLCDataset("S1", new OHLCDataItem[] {item1,
item2});
range = renderer.findRangeBounds(dataset);
assertEquals(new Range(-1.0, 4.0), range);
// try an empty dataset - should return a null range
dataset = new DefaultOHLCDataset("S1", new OHLCDataItem[] {});
range = renderer.findRangeBounds(dataset);
assertNull(range);
// try a null dataset - should return a null range
range = renderer.findRangeBounds(null);
assertNull(range);
}
}
| 6,668 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
VectorRendererTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/xy/VectorRendererTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ------------------------
* VectorRendererTests.java
* ------------------------
* (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 30-Jan-2007 : Version 1 (DG);
* 22-Apr-2008 : Added testPublicCloneable (DG);
*
*/
package org.jfree.chart.renderer.xy;
import org.jfree.chart.util.PublicCloneable;
import org.junit.Test;
import java.awt.Color;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link VectorRenderer} class.
*/
public class VectorRendererTest {
/**
* Test that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
// default instances
VectorRenderer r1 = new VectorRenderer();
VectorRenderer r2 = new VectorRenderer();
assertEquals(r1, r2);
assertEquals(r2, r1);
// check that super class fields are being looked at...
r1.setSeriesFillPaint(0, Color.green);
assertFalse(r1.equals(r2));
r2.setSeriesFillPaint(0, Color.green);
assertEquals(r1, r2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
VectorRenderer r1 = new VectorRenderer();
VectorRenderer r2 = new VectorRenderer();
assertEquals(r1, r2);
int h1 = r1.hashCode();
int h2 = r2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
VectorRenderer r1 = new VectorRenderer();
VectorRenderer r2 = (VectorRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
}
/**
* Verify that this class implements {@link PublicCloneable}.
*/
@Test
public void testPublicCloneable() {
VectorRenderer r1 = new VectorRenderer();
assertTrue(r1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
VectorRenderer r1 = new VectorRenderer();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
VectorRenderer r2 = (VectorRenderer) in.readObject();
in.close();
assertEquals(r1, r2);
}
}
| 4,431 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
XYShapeRendererTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/xy/XYShapeRendererTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* -------------------------
* XYShapeRendererTests.java
* -------------------------
* (C) Copyright 2010, 2011, by Object Refinery Limited.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): Martin Hoeller (patch 2952086);
*
* Changes
* -------
* 17-Sep-2008 : Version 1 (DG);
* 16-Feb-2010 : Added testFindZBounds() (MH);
* 19-Oct-2011 : Added test3026341() (DG);
*
*/
package org.jfree.chart.renderer.xy;
import org.jfree.chart.renderer.LookupPaintScale;
import org.jfree.data.Range;
import org.jfree.data.xy.DefaultXYZDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import org.junit.Test;
import java.awt.Color;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
/**
* Tests for the {@link XYShapeRenderer} class.
*/
public class XYShapeRendererTest {
/**
* Some checks for the equals() method.
*/
@Test
public void testEquals() {
XYShapeRenderer r1 = new XYShapeRenderer();
XYShapeRenderer r2 = new XYShapeRenderer();
assertEquals(r1, r2);
assertEquals(r2, r1);
r1.setPaintScale(new LookupPaintScale(1.0, 2.0, Color.WHITE));
assertFalse(r1.equals(r2));
r2.setPaintScale(new LookupPaintScale(1.0, 2.0, Color.WHITE));
assertEquals(r1, r2);
r1.setDrawOutlines(true);
assertFalse(r1.equals(r2));
r2.setDrawOutlines(true);
assertEquals(r1, r2);
r1.setUseOutlinePaint(false);
assertFalse(r1.equals(r2));
r2.setUseOutlinePaint(false);
assertEquals(r1, r2);
r1.setUseFillPaint(true);
assertFalse(r1.equals(r2));
r2.setUseFillPaint(true);
assertEquals(r1, r2);
r1.setGuideLinesVisible(true);
assertFalse(r1.equals(r2));
r2.setGuideLinesVisible(true);
assertEquals(r1, r2);
r1.setGuideLinePaint(Color.RED);
assertFalse(r1.equals(r2));
r2.setGuideLinePaint(Color.RED);
assertEquals(r1, r2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
XYShapeRenderer r1 = new XYShapeRenderer();
XYShapeRenderer r2 = (XYShapeRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
XYShapeRenderer r1 = new XYShapeRenderer();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
XYShapeRenderer r2 = (XYShapeRenderer) in.readObject();
in.close();
assertEquals(r1, r2);
}
private static final double EPSILON = 0.0000000001;
/**
* Check if finding the bounds in z-dimension of an XYZDataset works.
*/
@Test
public void testFindZBounds() {
XYShapeRenderer r = new XYShapeRenderer();
assertNull(r.findZBounds(null));
DefaultXYZDataset dataset = new DefaultXYZDataset();
Range range;
double data1[][] = { {1,1,1}, {1,1,1}, {1,2,3} };
dataset.addSeries("series1", data1);
range = r.findZBounds(dataset);
assertNotNull(range);
assertEquals(1d, range.getLowerBound(), EPSILON);
assertEquals(3d, range.getUpperBound(), EPSILON);
double data2[][] = { {1,1,1}, {1,1,1}, {-1,-2,-3} };
dataset.removeSeries("series1");
dataset.addSeries("series2", data2);
range = r.findZBounds(dataset);
assertNotNull(range);
assertEquals(-3d, range.getLowerBound(), EPSILON);
assertEquals(-1d, range.getUpperBound(), EPSILON);
double data3[][] = { {1,1,1}, {1,1,1}, {-1.2,2.9,3.8} };
dataset.removeSeries("series2");
dataset.addSeries("series3", data3);
range = r.findZBounds(dataset);
assertNotNull(range);
assertEquals(-1.2d, range.getLowerBound(), EPSILON);
assertEquals(3.8d, range.getUpperBound(), EPSILON);
}
/**
* Test for bug 3026341.
*/
@Test
public void test3026341() {
XYShapeRenderer renderer = new XYShapeRenderer();
assertNull(renderer.findRangeBounds(null));
XYSeriesCollection dataset = new XYSeriesCollection();
XYSeries series = new XYSeries("S1");
series.add(1.0, null);
dataset.addSeries(series);
Range r = renderer.findRangeBounds(dataset);
assertNull(r);
// test findDomainBounds as well
r = renderer.findDomainBounds(dataset);
assertEquals(r.getLowerBound(), 1.0, EPSILON);
assertEquals(r.getUpperBound(), 1.0, EPSILON);
dataset.removeAllSeries();
r = renderer.findDomainBounds(dataset);
assertNull(r);
}
}
| 6,824 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
XYStepRendererTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/xy/XYStepRendererTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ------------------------
* XYStepRendererTests.java
* ------------------------
* (C) Copyright 2003-2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 25-Mar-2003 : Version 1 (DG);
* 14-Feb-2008 : Added checks for new code (DG);
* 22-Apr-2008 : Added testPublicCloneable() (DG);
*
*/
package org.jfree.chart.renderer.xy;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.data.xy.DefaultTableXYDataset;
import org.jfree.data.xy.XYSeries;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link XYStepRenderer} class.
*/
public class XYStepRendererTest {
/**
* Check that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
XYStepRenderer r1 = new XYStepRenderer();
XYStepRenderer r2 = new XYStepRenderer();
assertEquals(r1, r2);
r1.setStepPoint(0.44);
assertFalse(r1.equals(r2));
r2.setStepPoint(0.44);
assertEquals(r1, r2);
// try something from the base class
r1.setDefaultCreateEntities(false);
assertFalse(r1.equals(r2));
r2.setDefaultCreateEntities(false);
assertEquals(r1, r2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
XYStepRenderer r1 = new XYStepRenderer();
r1.setStepPoint(0.123);
XYStepRenderer r2 = new XYStepRenderer();
r2.setStepPoint(0.123);
assertEquals(r1, r2);
int h1 = r1.hashCode();
int h2 = r2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
XYStepRenderer r1 = new XYStepRenderer();
XYStepRenderer r2 = (XYStepRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
}
/**
* Verify that this class implements {@link PublicCloneable}.
*/
@Test
public void testPublicCloneable() {
XYStepRenderer r1 = new XYStepRenderer();
assertTrue(r1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
XYStepRenderer r1 = new XYStepRenderer();
r1.setStepPoint(0.123);
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
XYStepRenderer r2 = (XYStepRenderer) in.readObject();
in.close();
assertEquals(r1, r2);
}
/**
* Draws the chart with a <code>null</code> info object to make sure that
* no exceptions are thrown (particularly by code in the renderer).
*/
@Test
public void testDrawWithNullInfo() {
DefaultTableXYDataset dataset = new DefaultTableXYDataset();
XYSeries s1 = new XYSeries("Series 1", true, false);
s1.add(5.0, 5.0);
s1.add(10.0, 15.5);
s1.add(15.0, 9.5);
s1.add(20.0, 7.5);
dataset.addSeries(s1);
XYSeries s2 = new XYSeries("Series 2", true, false);
s2.add(5.0, 5.0);
s2.add(10.0, 15.5);
s2.add(15.0, 9.5);
s2.add(20.0, 3.5);
dataset.addSeries(s2);
XYPlot plot = new XYPlot(dataset,
new NumberAxis("X"), new NumberAxis("Y"),
new XYStepRenderer());
JFreeChart chart = new JFreeChart(plot);
/* BufferedImage image = */ chart.createBufferedImage(300, 200,
null);
//FIXME we should be asserting a value here
}
/**
* Draws the chart with a <code>null</code> value in the dataset to make
* sure that no exceptions are thrown.
*/
@Test
public void testDrawWithNullValue() {
DefaultTableXYDataset dataset = new DefaultTableXYDataset();
XYSeries s1 = new XYSeries("Series 1", true, false);
s1.add(5.0, 5.0);
s1.add(10.0, null);
s1.add(15.0, 9.5);
s1.add(20.0, 7.5);
dataset.addSeries(s1);
XYSeries s2 = new XYSeries("Series 2", true, false);
s2.add(5.0, 5.0);
s2.add(10.0, 15.5);
s2.add(15.0, null);
s2.add(20.0, null);
dataset.addSeries(s2);
XYPlot plot = new XYPlot(dataset,
new NumberAxis("X"), new NumberAxis("Y"),
new XYStepRenderer());
JFreeChart chart = new JFreeChart(plot);
/* BufferedImage image = */ chart.createBufferedImage(300, 200,
null);
//FIXME we should be asserting a value here
}
}
| 6,954 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
YIntervalRendererTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/xy/YIntervalRendererTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ---------------------------
* YIntervalRendererTests.java
* ---------------------------
* (C) Copyright 2003-2012, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 25-Mar-2003 : Version 1 (DG);
* 20-Feb-2007 : Extended the testEquals() checks (DG);
* 17-May-2007 : Added testGetLegendItemSeriesIndex() (DG);
* 22-Apr-2008 : Added testPublicCloneable() (DG);
* 26-May-2008 : Extended testEquals() (DG);
* 17-Jun-2012 : Removed JCommon dependencies (DG);
*
*/
package org.jfree.chart.renderer.xy;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.LegendItem;
import org.jfree.chart.annotations.XYTextAnnotation;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.labels.IntervalXYItemLabelGenerator;
import org.jfree.chart.labels.StandardXYItemLabelGenerator;
import org.jfree.chart.labels.StandardXYSeriesLabelGenerator;
import org.jfree.chart.labels.StandardXYToolTipGenerator;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.ui.Layer;
import org.jfree.chart.urls.StandardXYURLGenerator;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.data.xy.YIntervalSeries;
import org.jfree.data.xy.YIntervalSeriesCollection;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link YIntervalRenderer} class.
*/
public class YIntervalRendererTest {
/**
* Check that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
YIntervalRenderer r1 = new YIntervalRenderer();
YIntervalRenderer r2 = new YIntervalRenderer();
assertEquals(r1, r2);
// the following fields are inherited from the AbstractXYItemRenderer
r1.setSeriesItemLabelGenerator(0, new StandardXYItemLabelGenerator());
assertFalse(r1.equals(r2));
r2.setSeriesItemLabelGenerator(0, new StandardXYItemLabelGenerator());
assertEquals(r1, r2);
r1.setDefaultItemLabelGenerator(new StandardXYItemLabelGenerator());
assertFalse(r1.equals(r2));
r2.setDefaultItemLabelGenerator(new StandardXYItemLabelGenerator());
assertEquals(r1, r2);
r1.setSeriesToolTipGenerator(0, new StandardXYToolTipGenerator());
assertFalse(r1.equals(r2));
r2.setSeriesToolTipGenerator(0, new StandardXYToolTipGenerator());
assertEquals(r1, r2);
r1.setDefaultToolTipGenerator(new StandardXYToolTipGenerator());
assertFalse(r1.equals(r2));
r2.setDefaultToolTipGenerator(new StandardXYToolTipGenerator());
assertEquals(r1, r2);
r1.setURLGenerator(new StandardXYURLGenerator());
assertFalse(r1.equals(r2));
r2.setURLGenerator(new StandardXYURLGenerator());
assertEquals(r1, r2);
r1.addAnnotation(new XYTextAnnotation("X", 1.0, 2.0), Layer.FOREGROUND);
assertFalse(r1.equals(r2));
r2.addAnnotation(new XYTextAnnotation("X", 1.0, 2.0), Layer.FOREGROUND);
assertEquals(r1, r2);
r1.addAnnotation(new XYTextAnnotation("X", 1.0, 2.0), Layer.BACKGROUND);
assertFalse(r1.equals(r2));
r2.addAnnotation(new XYTextAnnotation("X", 1.0, 2.0), Layer.BACKGROUND);
assertEquals(r1, r2);
r1.setDefaultEntityRadius(99);
assertFalse(r1.equals(r2));
r2.setDefaultEntityRadius(99);
assertEquals(r1, r2);
r1.setLegendItemLabelGenerator(new StandardXYSeriesLabelGenerator(
"{0} {1}"));
assertFalse(r1.equals(r2));
r2.setLegendItemLabelGenerator(new StandardXYSeriesLabelGenerator(
"{0} {1}"));
assertEquals(r1, r2);
r1.setLegendItemToolTipGenerator(new StandardXYSeriesLabelGenerator());
assertFalse(r1.equals(r2));
r2.setLegendItemToolTipGenerator(new StandardXYSeriesLabelGenerator());
assertEquals(r1, r2);
r1.setLegendItemURLGenerator(new StandardXYSeriesLabelGenerator());
assertFalse(r1.equals(r2));
r2.setLegendItemURLGenerator(new StandardXYSeriesLabelGenerator());
assertEquals(r1, r2);
r1.setAdditionalItemLabelGenerator(new IntervalXYItemLabelGenerator());
assertFalse(r1.equals(r2));
r2.setAdditionalItemLabelGenerator(new IntervalXYItemLabelGenerator());
assertEquals(r1, r2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
YIntervalRenderer r1 = new YIntervalRenderer();
YIntervalRenderer r2 = new YIntervalRenderer();
assertEquals(r1, r2);
int h1 = r1.hashCode();
int h2 = r2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
YIntervalRenderer r1 = new YIntervalRenderer();
YIntervalRenderer r2 = (YIntervalRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
// check independence
r1.setSeriesItemLabelGenerator(0, new StandardXYItemLabelGenerator());
assertFalse(r1.equals(r2));
r2.setSeriesItemLabelGenerator(0, new StandardXYItemLabelGenerator());
assertEquals(r1, r2);
r1.setSeriesToolTipGenerator(0, new StandardXYToolTipGenerator());
assertFalse(r1.equals(r2));
r2.setSeriesToolTipGenerator(0, new StandardXYToolTipGenerator());
assertEquals(r1, r2);
r1.addAnnotation(new XYTextAnnotation("ABC", 1.0, 2.0),
Layer.FOREGROUND);
assertFalse(r1.equals(r2));
r2.addAnnotation(new XYTextAnnotation("ABC", 1.0, 2.0),
Layer.FOREGROUND);
assertEquals(r1, r2);
r1.addAnnotation(new XYTextAnnotation("ABC", 1.0, 2.0),
Layer.BACKGROUND);
assertFalse(r1.equals(r2));
r2.addAnnotation(new XYTextAnnotation("ABC", 1.0, 2.0),
Layer.BACKGROUND);
assertEquals(r1, r2);
}
/**
* Verify that this class implements {@link PublicCloneable}.
*/
@Test
public void testPublicCloneable() {
YIntervalRenderer r1 = new YIntervalRenderer();
assertTrue(r1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
YIntervalRenderer r1 = new YIntervalRenderer();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
YIntervalRenderer r2 = (YIntervalRenderer) in.readObject();
in.close();
assertEquals(r1, r2);
}
/**
* A check for the datasetIndex and seriesIndex fields in the LegendItem
* returned by the getLegendItem() method.
*/
@Test
public void testGetLegendItemSeriesIndex() {
YIntervalSeriesCollection d1 = new YIntervalSeriesCollection();
YIntervalSeries s1 = new YIntervalSeries("S1");
s1.add(1.0, 1.1, 1.2, 1.3);
YIntervalSeries s2 = new YIntervalSeries("S2");
s2.add(1.0, 1.1, 1.2, 1.3);
d1.addSeries(s1);
d1.addSeries(s2);
YIntervalSeriesCollection d2 = new YIntervalSeriesCollection();
YIntervalSeries s3 = new YIntervalSeries("S3");
s3.add(1.0, 1.1, 1.2, 1.3);
YIntervalSeries s4 = new YIntervalSeries("S4");
s4.add(1.0, 1.1, 1.2, 1.3);
YIntervalSeries s5 = new YIntervalSeries("S5");
s5.add(1.0, 1.1, 1.2, 1.3);
d2.addSeries(s3);
d2.addSeries(s4);
d2.addSeries(s5);
YIntervalRenderer r = new YIntervalRenderer();
XYPlot plot = new XYPlot(d1, new NumberAxis("x"),
new NumberAxis("y"), r);
plot.setDataset(1, d2);
/*JFreeChart chart =*/ new JFreeChart(plot);
LegendItem li = r.getLegendItem(1, 2);
assertEquals("S5", li.getLabel());
assertEquals(1, li.getDatasetIndex());
assertEquals(2, li.getSeriesIndex());
}
}
| 10,084 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
XYDotRendererTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/xy/XYDotRendererTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* -----------------------
* XYDotRendererTests.java
* -----------------------
* (C) Copyright 2003-2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 25-Mar-2003 : Version 1 (DG);
* 17-May-2007 : Added testGetLegendItemSeriesIndex() (DG);
* 09-Nov-2007 : Updated testEquals() (DG);
* 22-Apr-2008 : Added testPublicCloneable (DG);
*
*/
package org.jfree.chart.renderer.xy;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.LegendItem;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import org.junit.Test;
import java.awt.geom.Rectangle2D;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link XYDotRenderer} class.
*/
public class XYDotRendererTest {
/**
* Check that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
XYDotRenderer r1 = new XYDotRenderer();
XYDotRenderer r2 = new XYDotRenderer();
assertEquals(r1, r2);
r1.setDotWidth(11);
assertFalse(r1.equals(r2));
r2.setDotWidth(11);
assertEquals(r1, r2);
r1.setDotHeight(12);
assertFalse(r1.equals(r2));
r2.setDotHeight(12);
assertEquals(r1, r2);
r1.setLegendShape(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0));
assertFalse(r1.equals(r2));
r2.setLegendShape(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0));
assertEquals(r1, r2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
XYDotRenderer r1 = new XYDotRenderer();
XYDotRenderer r2 = new XYDotRenderer();
assertEquals(r1, r2);
int h1 = r1.hashCode();
int h2 = r2.hashCode();
assertEquals(h1, h2);
r1.setDotHeight(12);
r2.setDotHeight(12);
assertEquals(r1, r2);
h1 = r1.hashCode();
h2 = r2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
XYDotRenderer r1 = new XYDotRenderer();
XYDotRenderer r2 = (XYDotRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
}
/**
* Verify that this class implements {@link PublicCloneable}.
*/
@Test
public void testPublicCloneable() {
XYDotRenderer r1 = new XYDotRenderer();
assertTrue(r1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
XYDotRenderer r1 = new XYDotRenderer();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
XYDotRenderer r2 = (XYDotRenderer) in.readObject();
in.close();
assertEquals(r1, r2);
}
/**
* A check for the datasetIndex and seriesIndex fields in the LegendItem
* returned by the getLegendItem() method.
*/
@Test
public void testGetLegendItemSeriesIndex() {
XYSeriesCollection d1 = new XYSeriesCollection();
XYSeries s1 = new XYSeries("S1");
s1.add(1.0, 1.1);
XYSeries s2 = new XYSeries("S2");
s2.add(1.0, 1.1);
d1.addSeries(s1);
d1.addSeries(s2);
XYSeriesCollection d2 = new XYSeriesCollection();
XYSeries s3 = new XYSeries("S3");
s3.add(1.0, 1.1);
XYSeries s4 = new XYSeries("S4");
s4.add(1.0, 1.1);
XYSeries s5 = new XYSeries("S5");
s5.add(1.0, 1.1);
d2.addSeries(s3);
d2.addSeries(s4);
d2.addSeries(s5);
XYDotRenderer r = new XYDotRenderer();
XYPlot plot = new XYPlot(d1, new NumberAxis("x"),
new NumberAxis("y"), r);
plot.setDataset(1, d2);
/*JFreeChart chart =*/ new JFreeChart(plot);
LegendItem li = r.getLegendItem(1, 2);
assertEquals("S5", li.getLabel());
assertEquals(1, li.getDatasetIndex());
assertEquals(2, li.getSeriesIndex());
}
}
| 6,307 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
XYLine3DRendererTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/xy/XYLine3DRendererTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* --------------------------
* XYLine3DRendererTests.java
* --------------------------
* (C) Copyright 2007, 2008, by Object Refinery Limited.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 30-Apr-2007 : Version 1 (DG);
* 22-Apr-2008 : Added testPublicCloneable (DG);
*
*/
package org.jfree.chart.renderer.xy;
import org.jfree.chart.util.PublicCloneable;
import org.junit.Test;
import java.awt.Color;
import java.awt.GradientPaint;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link XYLine3DRenderer} class.
*/
public class XYLine3DRendererTest {
/**
* Check that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
XYLine3DRenderer r1 = new XYLine3DRenderer();
XYLine3DRenderer r2 = new XYLine3DRenderer();
assertEquals(r1, r2);
r1.setXOffset(11.1);
assertFalse(r1.equals(r2));
r2.setXOffset(11.1);
assertEquals(r1, r2);
r1.setYOffset(11.1);
assertFalse(r1.equals(r2));
r2.setYOffset(11.1);
assertEquals(r1, r2);
r1.setWallPaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f,
4.0f, Color.BLUE));
assertFalse(r1.equals(r2));
r2.setWallPaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f,
4.0f, Color.BLUE));
assertEquals(r1, r2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
XYLine3DRenderer r1 = new XYLine3DRenderer();
XYLine3DRenderer r2 = new XYLine3DRenderer();
assertEquals(r1, r2);
int h1 = r1.hashCode();
int h2 = r2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
XYLine3DRenderer r1 = new XYLine3DRenderer();
r1.setWallPaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f,
Color.BLUE));
XYLine3DRenderer r2 = (XYLine3DRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
}
/**
* Verify that this class implements {@link PublicCloneable}.
*/
@Test
public void testPublicCloneable() {
XYLine3DRenderer r1 = new XYLine3DRenderer();
assertTrue(r1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
XYLine3DRenderer r1 = new XYLine3DRenderer();
r1.setWallPaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f,
Color.BLUE));
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
XYLine3DRenderer r2 = (XYLine3DRenderer) in.readObject();
in.close();
assertEquals(r1, r2);
}
}
| 4,955 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
DeviationRendererTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/xy/DeviationRendererTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ---------------------------
* DeviationRendererTests.java
* ---------------------------
* (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 26-Feb-2007 : Version 1 (DG);
* 22-Apr-2008 : Added testPublicCloneable (DG);
*
*/
package org.jfree.chart.renderer.xy;
import org.jfree.chart.util.PublicCloneable;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link DeviationRenderer} class.
*/
public class DeviationRendererTest {
/**
* Test that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
// default instances
DeviationRenderer r1 = new DeviationRenderer();
DeviationRenderer r2 = new DeviationRenderer();
assertEquals(r1, r2);
assertEquals(r2, r1);
r1.setAlpha(0.1f);
assertFalse(r1.equals(r2));
r2.setAlpha(0.1f);
assertEquals(r1, r2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
DeviationRenderer r1 = new DeviationRenderer();
DeviationRenderer r2 = new DeviationRenderer();
assertEquals(r1, r2);
int h1 = r1.hashCode();
int h2 = r2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
DeviationRenderer r1 = new DeviationRenderer();
DeviationRenderer r2 = (DeviationRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
// check independence
}
/**
* Verify that this class implements {@link PublicCloneable}.
*/
@Test
public void testPublicCloneable() {
DeviationRenderer r1 = new DeviationRenderer();
assertTrue(r1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
DeviationRenderer r1 = new DeviationRenderer();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
DeviationRenderer r2 = (DeviationRenderer) in.readObject();
in.close();
assertEquals(r1, r2);
}
}
| 4,409 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
AbstractXYItemRendererTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/xy/AbstractXYItemRendererTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* --------------------------------
* AbstractXYItemRendererTests.java
* --------------------------------
* (C) Copyright 2004-2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 06-Oct-2004 : Version 1 (DG);
* 24-Nov-2006 : Added cloning tests (DG);
*
*/
package org.jfree.chart.renderer.xy;
import org.jfree.chart.labels.StandardXYSeriesLabelGenerator;
import org.jfree.data.Range;
import org.jfree.data.xy.XYDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
/**
* Tests for the {@link AbstractXYItemRenderer} class.
*/
public class AbstractXYItemRendererTest {
/**
* Creates a test dataset.
*
* @return A test dataset.
*/
private XYDataset createDataset1() {
XYSeries series = new XYSeries("Series");
series.add(1.0, 1.0);
series.add(2.0, 2.0);
series.add(3.0, 3.0);
XYSeriesCollection dataset = new XYSeriesCollection();
dataset.addSeries(series);
return dataset;
}
private static final double EPSILON = 0.0000000001;
/**
* Some checks for the findDomainBounds() method.
*/
@Test
public void testFindDomainBounds() {
AbstractXYItemRenderer renderer = new StandardXYItemRenderer();
// check the bounds of a simple dataset
XYDataset dataset = createDataset1();
Range r = renderer.findDomainBounds(dataset);
assertEquals(1.0, r.getLowerBound(), EPSILON);
assertEquals(3.0, r.getUpperBound(), EPSILON);
// check that a null dataset returns null bounds
assertNull(renderer.findDomainBounds(null));
}
/**
* Some checks for the findRangeBounds() method.
*/
@Test
public void testFindRangeBounds() {
AbstractXYItemRenderer renderer = new StandardXYItemRenderer();
// check that a null dataset returns null bounds
assertNull(renderer.findRangeBounds(null));
}
/**
* Check that the legendItemLabelGenerator is cloned.
*/
@Test
public void testCloning_LegendItemLabelGenerator() throws CloneNotSupportedException {
StandardXYSeriesLabelGenerator generator
= new StandardXYSeriesLabelGenerator("Series {0}");
XYBarRenderer r1 = new XYBarRenderer();
r1.setLegendItemLabelGenerator(generator);
XYBarRenderer r2 = (XYBarRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
// check that the generator has been cloned
assertNotSame(r1.getLegendItemLabelGenerator(), r2.getLegendItemLabelGenerator());
}
/**
* Check that the legendItemToolTipGenerator is cloned.
*/
@Test
public void testCloning_LegendItemToolTipGenerator() throws CloneNotSupportedException {
StandardXYSeriesLabelGenerator generator
= new StandardXYSeriesLabelGenerator("Series {0}");
XYBarRenderer r1 = new XYBarRenderer();
r1.setLegendItemToolTipGenerator(generator);
XYBarRenderer r2 = (XYBarRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
// check that the generator has been cloned
assertNotSame(r1.getLegendItemToolTipGenerator(), r2.getLegendItemToolTipGenerator());
}
/**
* Check that the legendItemURLGenerator is cloned.
*/
@Test
public void testCloning_LegendItemURLGenerator() throws CloneNotSupportedException {
StandardXYSeriesLabelGenerator generator
= new StandardXYSeriesLabelGenerator("Series {0}");
XYBarRenderer r1 = new XYBarRenderer();
r1.setLegendItemURLGenerator(generator);
XYBarRenderer r2 = (XYBarRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
// check that the generator has been cloned
assertNotSame(r1.getLegendItemURLGenerator(), r2.getLegendItemURLGenerator());
}
}
| 5,622 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
XYBarRendererTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/xy/XYBarRendererTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* -----------------------
* XYBarRendererTests.java
* -----------------------
* (C) Copyright 2003-2012, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 25-Mar-2003 : Version 1 (DG);
* 22-Oct-2003 : Added hashCode test (DG);
* 09-Feb-2007 : Added to testCloning() (DG);
* 17-May-2007 : Added testGetLegendItemSeriesIndex() (DG);
* 22-Apr-2008 : Added testPublicCloneable (DG);
* 19-Jun-2008 : Added testFindRangeBounds() (DG);
* 17-Jun-2012 : Removed JCommon dependencies (DG);
*
*/
package org.jfree.chart.renderer.xy;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.LegendItem;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.ui.GradientPaintTransformType;
import org.jfree.chart.ui.StandardGradientPaintTransformer;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.chart.labels.ItemLabelPosition;
import org.jfree.chart.plot.XYPlot;
import org.jfree.data.Range;
import org.jfree.data.xy.DefaultIntervalXYDataset;
import org.jfree.data.xy.XYBarDataset;
import org.jfree.data.xy.XYIntervalSeries;
import org.jfree.data.xy.XYIntervalSeriesCollection;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import org.junit.Test;
import java.io.IOException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link XYBarRenderer} class.
*/
public class XYBarRendererTest {
/**
* Test that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
// default instances
XYBarRenderer r1 = new XYBarRenderer();
XYBarRenderer r2 = new XYBarRenderer();
assertEquals(r1, r2);
assertEquals(r2, r1);
// setBase()
r1.setBase(1.0);
assertFalse(r1.equals(r2));
r2.setBase(1.0);
assertEquals(r1, r2);
// setUseYInterval
r1.setUseYInterval(!r1.getUseYInterval());
assertFalse(r1.equals(r2));
r2.setUseYInterval(!r2.getUseYInterval());
assertEquals(r1, r2);
// setMargin()
r1.setMargin(0.10);
assertFalse(r1.equals(r2));
r2.setMargin(0.10);
assertEquals(r1, r2);
// setDrawBarOutline()
r1.setDrawBarOutline(!r1.isDrawBarOutline());
assertFalse(r1.equals(r2));
r2.setDrawBarOutline(!r2.isDrawBarOutline());
assertEquals(r1, r2);
// setGradientPaintTransformer()
r1.setGradientPaintTransformer(new StandardGradientPaintTransformer(
GradientPaintTransformType.CENTER_HORIZONTAL));
assertFalse(r1.equals(r2));
r2.setGradientPaintTransformer(new StandardGradientPaintTransformer(
GradientPaintTransformType.CENTER_HORIZONTAL));
assertEquals(r1, r2);
// positiveItemLabelFallbackPosition
r1.setPositiveItemLabelPositionFallback(new ItemLabelPosition());
assertFalse(r1.equals(r2));
r2.setPositiveItemLabelPositionFallback(new ItemLabelPosition());
assertEquals(r1, r2);
// negativeItemLabelFallbackPosition
r1.setNegativeItemLabelPositionFallback(new ItemLabelPosition());
assertFalse(r1.equals(r2));
r2.setNegativeItemLabelPositionFallback(new ItemLabelPosition());
assertEquals(r1, r2);
// barPainter
r1.setBarPainter(new GradientXYBarPainter(0.11, 0.22, 0.33));
assertFalse(r1.equals(r2));
r2.setBarPainter(new GradientXYBarPainter(0.11, 0.22, 0.33));
assertEquals(r1, r2);
// shadowsVisible
r1.setShadowVisible(false);
assertFalse(r1.equals(r2));
r2.setShadowVisible(false);
assertEquals(r1, r2);
// shadowXOffset
r1.setShadowXOffset(3.3);
assertFalse(r1.equals(r2));
r2.setShadowXOffset(3.3);
assertEquals(r1, r2);
// shadowYOffset
r1.setShadowYOffset(3.3);
assertFalse(r1.equals(r2));
r2.setShadowYOffset(3.3);
assertEquals(r1, r2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
XYBarRenderer r1 = new XYBarRenderer();
XYBarRenderer r2 = new XYBarRenderer();
assertEquals(r1, r2);
int h1 = r1.hashCode();
int h2 = r2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
XYBarRenderer r1 = new XYBarRenderer();
XYBarRenderer r2 = (XYBarRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
}
/**
* Verify that this class implements {@link PublicCloneable}.
*/
@Test
public void testPublicCloneable() {
XYBarRenderer r1 = new XYBarRenderer();
assertTrue(r1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
XYBarRenderer r1 = new XYBarRenderer();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
XYBarRenderer r2 = (XYBarRenderer) in.readObject();
in.close();
assertEquals(r1, r2);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization2() throws IOException, ClassNotFoundException {
XYBarRenderer r1 = new XYBarRenderer();
r1.setPositiveItemLabelPositionFallback(new ItemLabelPosition());
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
XYBarRenderer r2 = (XYBarRenderer) in.readObject();
in.close();
assertEquals(r1, r2);
}
/**
* Check that the renderer is calculating the domain bounds correctly.
*/
@Test
public void testFindDomainBounds() {
XYSeriesCollection dataset
= RendererXYPackageTests.createTestXYSeriesCollection();
JFreeChart chart = ChartFactory.createXYBarChart("Test Chart", "X",
false, "Y", dataset);
XYPlot plot = (XYPlot) chart.getPlot();
NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
domainAxis.setAutoRangeIncludesZero(false);
Range bounds = domainAxis.getRange();
assertFalse(bounds.contains(0.3));
assertTrue(bounds.contains(0.5));
assertTrue(bounds.contains(2.5));
assertFalse(bounds.contains(2.8));
}
/**
* A test for the findDomainBounds method to ensure it correctly accounts
* for the series visibility.
*/
@Test
public void testFindDomainBounds2() {
XYIntervalSeries s1 = new XYIntervalSeries("S1");
s1.add(1.0, 0.5, 1.5, 10.0, 9.5, 10.5);
s1.add(2.0, 1.9, 2.1, 20.0, 19.8, 20.3);
XYIntervalSeries s2 = new XYIntervalSeries("S2");
s2.add(3.0, 2.5, 3.5, 30.0, 29.5, 30.5);
s2.add(4.0, 3.9, 4.1, 9.0, 9.0, 9.0);
XYIntervalSeriesCollection dataset = new XYIntervalSeriesCollection();
dataset.addSeries(s1);
dataset.addSeries(s2);
XYBarRenderer renderer = new XYBarRenderer();
Range r = renderer.findDomainBounds(dataset);
assertEquals(0.5, r.getLowerBound(), EPSILON);
assertEquals(4.1, r.getUpperBound(), EPSILON);
renderer.setSeriesVisible(1, Boolean.FALSE);
r = renderer.findDomainBounds(dataset);
assertEquals(0.5, r.getLowerBound(), EPSILON);
assertEquals(2.1, r.getUpperBound(), EPSILON);
}
private static final double EPSILON = 0.0000000001;
/**
* A simple test for the findRangeBounds() method.
*/
@Test
public void testFindRangeBounds() {
DefaultIntervalXYDataset dataset = new DefaultIntervalXYDataset();
double[] x = {1.0, 2.0, 3.0, 4.0};
double[] startx = {0.9, 1.8, 2.7, 3.6};
double[] endx = {1.1, 2.2, 3.3, 4.4};
double[] y = {1.0, 2.0, 3.0, 4.0};
double[] starty = {0.9, 1.8, 2.7, 3.6};
double[] endy = {1.1, 2.2, 3.3, 4.4};
double[][] data = new double[][] {x, startx, endx, y, starty, endy};
dataset.addSeries("Series 1", data);
XYBarRenderer renderer = new XYBarRenderer();
renderer.setUseYInterval(true);
Range r = renderer.findRangeBounds(dataset);
assertEquals(0.9, r.getLowerBound(), EPSILON);
assertEquals(4.4, r.getUpperBound(), EPSILON);
renderer.setUseYInterval(false);
r = renderer.findRangeBounds(dataset);
assertEquals(1.0, r.getLowerBound(), EPSILON);
assertEquals(4.0, r.getUpperBound(), EPSILON);
}
/**
* A test for the findRangeBounds method to ensure it correctly accounts
* for the series visibility.
*/
@Test
public void testFindRangeBounds2() {
XYIntervalSeries s1 = new XYIntervalSeries("S1");
s1.add(1.0, 0.5, 1.5, 10.0, 9.5, 10.5);
s1.add(2.0, 1.9, 2.1, 20.0, 19.8, 20.3);
XYIntervalSeries s2 = new XYIntervalSeries("S2");
s2.add(3.0, 2.5, 3.5, 30.0, 29.5, 30.5);
s2.add(4.0, 3.9, 4.1, 9.0, 9.0, 9.0);
XYIntervalSeriesCollection dataset = new XYIntervalSeriesCollection();
dataset.addSeries(s1);
dataset.addSeries(s2);
XYBarRenderer renderer = new XYBarRenderer();
renderer.setUseYInterval(false);
Range r = renderer.findRangeBounds(dataset);
assertEquals(9.0, r.getLowerBound(), EPSILON);
assertEquals(30.0, r.getUpperBound(), EPSILON);
renderer.setSeriesVisible(1, Boolean.FALSE);
r = renderer.findRangeBounds(dataset);
assertEquals(10.0, r.getLowerBound(), EPSILON);
assertEquals(20.0, r.getUpperBound(), EPSILON);
}
/**
* A check for the datasetIndex and seriesIndex fields in the LegendItem
* returned by the getLegendItem() method.
*/
@Test
public void testGetLegendItemSeriesIndex() {
XYSeriesCollection d1 = new XYSeriesCollection();
XYSeries s1 = new XYSeries("S1");
s1.add(1.0, 1.1);
XYSeries s2 = new XYSeries("S2");
s2.add(1.0, 1.1);
d1.addSeries(s1);
d1.addSeries(s2);
XYSeriesCollection d2 = new XYSeriesCollection();
XYSeries s3 = new XYSeries("S3");
s3.add(1.0, 1.1);
XYSeries s4 = new XYSeries("S4");
s4.add(1.0, 1.1);
XYSeries s5 = new XYSeries("S5");
s5.add(1.0, 1.1);
d2.addSeries(s3);
d2.addSeries(s4);
d2.addSeries(s5);
XYBarRenderer r = new XYBarRenderer();
XYPlot plot = new XYPlot(new XYBarDataset(d1, 1.0), new NumberAxis("x"),
new NumberAxis("y"), r);
plot.setDataset(1, new XYBarDataset(d2, 2.0));
/*JFreeChart chart =*/ new JFreeChart(plot);
LegendItem li = r.getLegendItem(1, 2);
assertEquals("S5", li.getLabel());
assertEquals(1, li.getDatasetIndex());
assertEquals(2, li.getSeriesIndex());
}
}
| 13,398 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
GradientXYBarPainterTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/xy/GradientXYBarPainterTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ------------------------------
* GradientXYBarPainterTests.java
* ------------------------------
* (C) Copyright 2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 20-Jun-2008 : Version 1 (DG);
*
*/
package org.jfree.chart.renderer.xy;
import org.jfree.chart.util.PublicCloneable;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
/**
* Tests for the {@link GradientXYBarPainter} class.
*/
public class GradientXYBarPainterTest {
/**
* Check that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
GradientXYBarPainter p1 = new GradientXYBarPainter(0.1, 0.2, 0.3);
GradientXYBarPainter p2 = new GradientXYBarPainter(0.1, 0.2, 0.3);
assertEquals(p1, p2);
p1 = new GradientXYBarPainter(0.11, 0.2, 0.3);
assertFalse(p1.equals(p2));
p2 = new GradientXYBarPainter(0.11, 0.2, 0.3);
assertEquals(p1, p2);
p1 = new GradientXYBarPainter(0.11, 0.22, 0.3);
assertFalse(p1.equals(p2));
p2 = new GradientXYBarPainter(0.11, 0.22, 0.3);
assertEquals(p1, p2);
p1 = new GradientXYBarPainter(0.11, 0.22, 0.33);
assertFalse(p1.equals(p2));
p2 = new GradientXYBarPainter(0.11, 0.22, 0.33);
assertEquals(p1, p2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
GradientXYBarPainter p1 = new GradientXYBarPainter(0.1, 0.2, 0.3);
GradientXYBarPainter p2 = new GradientXYBarPainter(0.1, 0.2, 0.3);
assertEquals(p1, p2);
int h1 = p1.hashCode();
int h2 = p2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning isn't implemented (it isn't required, because
* instances of the class are immutable).
*/
@Test
public void testCloning() throws CloneNotSupportedException {
GradientXYBarPainter p1 = new GradientXYBarPainter(0.1, 0.2, 0.3);
assertFalse(p1 instanceof Cloneable);
assertFalse(p1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
GradientXYBarPainter p1 = new GradientXYBarPainter(0.1, 0.2, 0.3);
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(p1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
GradientXYBarPainter p2 = (GradientXYBarPainter) in.readObject();
in.close();
assertEquals(p1, p2);
}
}
| 4,441 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
CandlestickRendererTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/xy/CandlestickRendererTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* -----------------------------
* CandlestickRendererTests.java
* -----------------------------
* (C) Copyright 2003-2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 25-Mar-2003 : Version 1 (DG);
* 22-Oct-2003 : Added hashCode test (DG);
* 17-Aug-2006 : Strengthened testEquals() and added testFindRangeBounds()
* method (DG);
* 05-Mar-2007 : Added new field to testEquals() (DG);
* 08-Oct-2007 : Added tests for new volumePaint field (DG);
* 22-Apr-2008 : Added testPublicCloneable() (DG);
*
*/
package org.jfree.chart.renderer.xy;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.data.Range;
import org.jfree.data.xy.DefaultOHLCDataset;
import org.jfree.data.xy.OHLCDataItem;
import org.jfree.data.xy.OHLCDataset;
import org.junit.Test;
import java.awt.Color;
import java.awt.GradientPaint;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.util.Date;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link CandlestickRenderer} class.
*/
public class CandlestickRendererTest {
private static final double EPSILON = 0.0000000001;
/**
* Some checks for the constructor.
*/
@Test
public void testConstructor() {
CandlestickRenderer r1 = new CandlestickRenderer();
// check defaults
assertEquals(Color.green, r1.getUpPaint());
assertEquals(Color.RED, r1.getDownPaint());
assertFalse(r1.getUseOutlinePaint());
assertTrue(r1.getDrawVolume());
assertEquals(Color.gray, r1.getVolumePaint());
assertEquals(-1.0, r1.getCandleWidth(), EPSILON);
}
/**
* Check that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
CandlestickRenderer r1 = new CandlestickRenderer();
CandlestickRenderer r2 = new CandlestickRenderer();
assertEquals(r1, r2);
// upPaint
r1.setUpPaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f,
Color.WHITE));
assertFalse(r1.equals(r2));
r2.setUpPaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f,
Color.WHITE));
assertEquals(r1, r2);
// downPaint
r1.setDownPaint(new GradientPaint(5.0f, 6.0f, Color.green, 7.0f, 8.0f,
Color.yellow));
assertFalse(r1.equals(r2));
r2.setDownPaint(new GradientPaint(5.0f, 6.0f, Color.green, 7.0f, 8.0f,
Color.yellow));
assertEquals(r1, r2);
// drawVolume
r1.setDrawVolume(false);
assertFalse(r1.equals(r2));
r2.setDrawVolume(false);
assertEquals(r1, r2);
// candleWidth
r1.setCandleWidth(3.3);
assertFalse(r1.equals(r2));
r2.setCandleWidth(3.3);
assertEquals(r1, r2);
// maxCandleWidthInMilliseconds
r1.setMaxCandleWidthInMilliseconds(123);
assertFalse(r1.equals(r2));
r2.setMaxCandleWidthInMilliseconds(123);
assertEquals(r1, r2);
// autoWidthMethod
r1.setAutoWidthMethod(CandlestickRenderer.WIDTHMETHOD_SMALLEST);
assertFalse(r1.equals(r2));
r2.setAutoWidthMethod(CandlestickRenderer.WIDTHMETHOD_SMALLEST);
assertEquals(r1, r2);
// autoWidthFactor
r1.setAutoWidthFactor(0.22);
assertFalse(r1.equals(r2));
r2.setAutoWidthFactor(0.22);
assertEquals(r1, r2);
// autoWidthGap
r1.setAutoWidthGap(1.1);
assertFalse(r1.equals(r2));
r2.setAutoWidthGap(1.1);
assertEquals(r1, r2);
r1.setUseOutlinePaint(true);
assertFalse(r1.equals(r2));
r2.setUseOutlinePaint(true);
assertEquals(r1, r2);
r1.setVolumePaint(Color.BLUE);
assertFalse(r1.equals(r2));
r2.setVolumePaint(Color.BLUE);
assertEquals(r1, r2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
CandlestickRenderer r1 = new CandlestickRenderer();
CandlestickRenderer r2 = new CandlestickRenderer();
assertEquals(r1, r2);
int h1 = r1.hashCode();
int h2 = r2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
CandlestickRenderer r1 = new CandlestickRenderer();
CandlestickRenderer r2 = (CandlestickRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
}
/**
* Verify that this class implements {@link PublicCloneable}.
*/
@Test
public void testPublicCloneable() {
CandlestickRenderer r1 = new CandlestickRenderer();
assertTrue(r1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
CandlestickRenderer r1 = new CandlestickRenderer();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
CandlestickRenderer r2 = (CandlestickRenderer) in.readObject();
in.close();
assertEquals(r1, r2);
}
/**
* Some checks for the findRangeBounds() method.
*/
@Test
public void testFindRangeBounds() {
CandlestickRenderer renderer = new CandlestickRenderer();
OHLCDataItem item1 = new OHLCDataItem(new Date(1L), 2.0, 4.0, 1.0, 3.0,
100);
OHLCDataset dataset = new DefaultOHLCDataset("S1",
new OHLCDataItem[] {item1});
Range range = renderer.findRangeBounds(dataset);
assertEquals(new Range(1.0, 4.0), range);
OHLCDataItem item2 = new OHLCDataItem(new Date(1L), -1.0, 3.0, -1.0,
3.0, 100);
dataset = new DefaultOHLCDataset("S1", new OHLCDataItem[] {item1,
item2});
range = renderer.findRangeBounds(dataset);
assertEquals(new Range(-1.0, 4.0), range);
// try an empty dataset - should return a null range
dataset = new DefaultOHLCDataset("S1", new OHLCDataItem[] {});
range = renderer.findRangeBounds(dataset);
assertNull(range);
// try a null dataset - should return a null range
range = renderer.findRangeBounds(null);
assertNull(range);
}
}
| 8,465 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
XYAreaRendererTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/xy/XYAreaRendererTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ------------------------
* XYAreaRendererTests.java
* ------------------------
* (C) Copyright 2003-2012, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 25-Mar-2003 : Version 1 (DG);
* 22-Oct-2003 : Added hashCode test (DG);
* 14-Feb-2007 : Updated testCloning() (DG);
* 17-May-2007 : Added testGetLegendItemSeriesIndex() (DG);
* 22-Apr-2008 : Added testPublicCloneable (DG);
* 10-Jun-2009 : Check new fields (DG);
* 17-Jun-2012 : Removed JCommon dependencies (DG);
*
*/
package org.jfree.chart.renderer.xy;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.LegendItem;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.ui.GradientPaintTransformType;
import org.jfree.chart.ui.StandardGradientPaintTransformer;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.data.xy.DefaultTableXYDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import org.junit.Test;
import java.awt.geom.Rectangle2D;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link XYAreaRenderer} class.
*/
public class XYAreaRendererTest {
/**
* Check that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
XYAreaRenderer r1 = new XYAreaRenderer();
XYAreaRenderer r2 = new XYAreaRenderer();
assertEquals(r1, r2);
r1 = new XYAreaRenderer(XYAreaRenderer.AREA_AND_SHAPES);
assertFalse(r1.equals(r2));
r2 = new XYAreaRenderer(XYAreaRenderer.AREA_AND_SHAPES);
assertEquals(r1, r2);
r1 = new XYAreaRenderer(XYAreaRenderer.AREA);
assertFalse(r1.equals(r2));
r2 = new XYAreaRenderer(XYAreaRenderer.AREA);
assertEquals(r1, r2);
r1 = new XYAreaRenderer(XYAreaRenderer.LINES);
assertFalse(r1.equals(r2));
r2 = new XYAreaRenderer(XYAreaRenderer.LINES);
assertEquals(r1, r2);
r1 = new XYAreaRenderer(XYAreaRenderer.SHAPES);
assertFalse(r1.equals(r2));
r2 = new XYAreaRenderer(XYAreaRenderer.SHAPES);
assertEquals(r1, r2);
r1 = new XYAreaRenderer(XYAreaRenderer.SHAPES_AND_LINES);
assertFalse(r1.equals(r2));
r2 = new XYAreaRenderer(XYAreaRenderer.SHAPES_AND_LINES);
assertEquals(r1, r2);
r1.setOutline(true);
assertFalse(r1.equals(r2));
r2.setOutline(true);
assertEquals(r1, r2);
r1.setLegendArea(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0));
assertFalse(r1.equals(r2));
r2.setLegendArea(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0));
assertEquals(r1, r2);
r1.setUseFillPaint(true);
assertFalse(r1.equals(r2));
r2.setUseFillPaint(true);
assertEquals(r1, r2);
r1.setGradientTransformer(new StandardGradientPaintTransformer(
GradientPaintTransformType.CENTER_VERTICAL));
assertFalse(r1.equals(r2));
r2.setGradientTransformer(new StandardGradientPaintTransformer(
GradientPaintTransformType.CENTER_VERTICAL));
assertEquals(r1, r2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
XYAreaRenderer r1 = new XYAreaRenderer();
XYAreaRenderer r2 = new XYAreaRenderer();
assertEquals(r1, r2);
int h1 = r1.hashCode();
int h2 = r2.hashCode();
assertEquals(h1, h2);
r2.setUseFillPaint(true);
assertFalse(r1.hashCode() == r2.hashCode());
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
XYAreaRenderer r1 = new XYAreaRenderer();
Rectangle2D rect1 = new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0);
r1.setLegendArea(rect1);
XYAreaRenderer r2 = (XYAreaRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
// check independence
rect1.setRect(4.0, 3.0, 2.0, 1.0);
assertFalse(r1.equals(r2));
r2.setLegendArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0));
assertEquals(r1, r2);
}
/**
* Verify that this class implements {@link PublicCloneable}.
*/
@Test
public void testPublicCloneable() {
XYAreaRenderer r1 = new XYAreaRenderer();
assertTrue(r1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
XYAreaRenderer r1 = new XYAreaRenderer();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
XYAreaRenderer r2 = (XYAreaRenderer) in.readObject();
in.close();
assertEquals(r1, r2);
}
/**
* Draws the chart with a <code>null</code> info object to make sure that
* no exceptions are thrown (particularly by code in the renderer).
*/
@Test
public void testDrawWithNullInfo() {
DefaultTableXYDataset dataset = new DefaultTableXYDataset();
XYSeries s1 = new XYSeries("Series 1", true, false);
s1.add(5.0, 5.0);
s1.add(10.0, 15.5);
s1.add(15.0, 9.5);
s1.add(20.0, 7.5);
dataset.addSeries(s1);
XYSeries s2 = new XYSeries("Series 2", true, false);
s2.add(5.0, 5.0);
s2.add(10.0, 15.5);
s2.add(15.0, 9.5);
s2.add(20.0, 3.5);
dataset.addSeries(s2);
XYPlot plot = new XYPlot(dataset,
new NumberAxis("X"), new NumberAxis("Y"),
new XYAreaRenderer());
JFreeChart chart = new JFreeChart(plot);
/* BufferedImage image = */ chart.createBufferedImage(300, 200,
null);
}
/**
* A check for the datasetIndex and seriesIndex fields in the LegendItem
* returned by the getLegendItem() method.
*/
@Test
public void testGetLegendItemSeriesIndex() {
XYSeriesCollection d1 = new XYSeriesCollection();
XYSeries s1 = new XYSeries("S1");
s1.add(1.0, 1.1);
XYSeries s2 = new XYSeries("S2");
s2.add(1.0, 1.1);
d1.addSeries(s1);
d1.addSeries(s2);
XYSeriesCollection d2 = new XYSeriesCollection();
XYSeries s3 = new XYSeries("S3");
s3.add(1.0, 1.1);
XYSeries s4 = new XYSeries("S4");
s4.add(1.0, 1.1);
XYSeries s5 = new XYSeries("S5");
s5.add(1.0, 1.1);
d2.addSeries(s3);
d2.addSeries(s4);
d2.addSeries(s5);
XYAreaRenderer r = new XYAreaRenderer();
XYPlot plot = new XYPlot(d1, new NumberAxis("x"),
new NumberAxis("y"), r);
plot.setDataset(1, d2);
/*JFreeChart chart =*/ new JFreeChart(plot);
LegendItem li = r.getLegendItem(1, 2);
assertEquals("S5", li.getLabel());
assertEquals(1, li.getDatasetIndex());
assertEquals(2, li.getSeriesIndex());
}
}
| 9,185 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
StandardXYBarPainterTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/xy/StandardXYBarPainterTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ------------------------------
* StandardXYBarPainterTests.java
* ------------------------------
* (C) Copyright 2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 20-Jun-2008 : Version 1 (DG);
*
*/
package org.jfree.chart.renderer.xy;
import org.jfree.chart.util.PublicCloneable;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
/**
* Tests for the {@link StandardXYBarPainter} class.
*/
public class StandardXYBarPainterTest {
/**
* Check that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
StandardXYBarPainter p1 = new StandardXYBarPainter();
StandardXYBarPainter p2 = new StandardXYBarPainter();
assertEquals(p1, p2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
StandardXYBarPainter p1 = new StandardXYBarPainter();
StandardXYBarPainter p2 = new StandardXYBarPainter();
assertEquals(p1, p2);
int h1 = p1.hashCode();
int h2 = p2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning isn't implemented (it isn't required, because
* instances of the class are immutable).
*/
@Test
public void testCloning() throws CloneNotSupportedException {
StandardXYBarPainter p1 = new StandardXYBarPainter();
assertFalse(p1 instanceof Cloneable);
assertFalse(p1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
StandardXYBarPainter p1 = new StandardXYBarPainter();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(p1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
StandardXYBarPainter p2 = (StandardXYBarPainter) in.readObject();
in.close();
assertEquals(p1, p2);
}
}
| 3,826 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
XYAreaRenderer2Test.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/xy/XYAreaRenderer2Test.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* -------------------------
* AreaXYRenderer2Tests.java
* -------------------------
* (C) Copyright 2005-2008, by Object Refinery Limited.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 24-May-2005 : Version 1 (DG);
* 30-Nov-2006 : Extended testEquals() and testCloning() (DG);
* 17-May-2007 : Added testGetLegendItemSeriesIndex() (DG);
* 22-Apr-2008 : Added testPublicCloneable (DG);
*
*/
package org.jfree.chart.renderer.xy;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.LegendItem;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.data.xy.DefaultTableXYDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import org.junit.Test;
import java.awt.Rectangle;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link XYAreaRenderer2} class.
*/
public class XYAreaRenderer2Test {
/**
* Check that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
XYAreaRenderer2 r1 = new XYAreaRenderer2();
XYAreaRenderer2 r2 = new XYAreaRenderer2();
assertEquals(r1, r2);
r1.setOutline(!r1.isOutline());
assertFalse(r1.equals(r2));
r2.setOutline(r1.isOutline());
assertEquals(r1, r2);
r1.setLegendArea(new Rectangle(1, 2, 3, 4));
assertFalse(r1.equals(r2));
r2.setLegendArea(new Rectangle(1, 2, 3, 4));
assertEquals(r1, r2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
XYAreaRenderer2 r1 = new XYAreaRenderer2();
XYAreaRenderer2 r2 = new XYAreaRenderer2();
assertEquals(r1, r2);
int h1 = r1.hashCode();
int h2 = r2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
XYAreaRenderer2 r1 = new XYAreaRenderer2();
Rectangle rect = new Rectangle(1, 2, 3, 4);
r1.setLegendArea(rect);
XYAreaRenderer2 r2 = (XYAreaRenderer2) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
// check independence
rect.setBounds(99, 99, 99, 99);
assertFalse(r1.equals(r2));
}
/**
* Verify that this class implements {@link PublicCloneable}.
*/
@Test
public void testPublicCloneable() {
XYAreaRenderer2 r1 = new XYAreaRenderer2();
assertTrue(r1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
XYAreaRenderer2 r1 = new XYAreaRenderer2();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
XYAreaRenderer2 r2 = (XYAreaRenderer2) in.readObject();
in.close();
assertEquals(r1, r2);
}
/**
* Draws the chart with a <code>null</code> info object to make sure that
* no exceptions are thrown (particularly by code in the renderer).
*/
@Test
public void testDrawWithNullInfo() {
DefaultTableXYDataset dataset = new DefaultTableXYDataset();
XYSeries s1 = new XYSeries("Series 1", true, false);
s1.add(5.0, 5.0);
s1.add(10.0, 15.5);
s1.add(15.0, 9.5);
s1.add(20.0, 7.5);
dataset.addSeries(s1);
XYSeries s2 = new XYSeries("Series 2", true, false);
s2.add(5.0, 5.0);
s2.add(10.0, 15.5);
s2.add(15.0, 9.5);
s2.add(20.0, 3.5);
dataset.addSeries(s2);
XYPlot plot = new XYPlot(dataset,
new NumberAxis("X"), new NumberAxis("Y"),
new XYAreaRenderer2());
JFreeChart chart = new JFreeChart(plot);
/* BufferedImage image = */ chart.createBufferedImage(300, 200,
null);
}
/**
* A check for the datasetIndex and seriesIndex fields in the LegendItem
* returned by the getLegendItem() method.
*/
@Test
public void testGetLegendItemSeriesIndex() {
XYSeriesCollection d1 = new XYSeriesCollection();
XYSeries s1 = new XYSeries("S1");
s1.add(1.0, 1.1);
XYSeries s2 = new XYSeries("S2");
s2.add(1.0, 1.1);
d1.addSeries(s1);
d1.addSeries(s2);
XYSeriesCollection d2 = new XYSeriesCollection();
XYSeries s3 = new XYSeries("S3");
s3.add(1.0, 1.1);
XYSeries s4 = new XYSeries("S4");
s4.add(1.0, 1.1);
XYSeries s5 = new XYSeries("S5");
s5.add(1.0, 1.1);
d2.addSeries(s3);
d2.addSeries(s4);
d2.addSeries(s5);
XYAreaRenderer2 r = new XYAreaRenderer2();
XYPlot plot = new XYPlot(d1, new NumberAxis("x"),
new NumberAxis("y"), r);
plot.setDataset(1, d2);
/*JFreeChart chart =*/ new JFreeChart(plot);
LegendItem li = r.getLegendItem(1, 2);
assertEquals("S5", li.getLabel());
assertEquals(1, li.getDatasetIndex());
assertEquals(2, li.getSeriesIndex());
}
}
| 7,334 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
RendererXYPackageTests.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/xy/RendererXYPackageTests.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ---------------------------
* RendererXYPackageTests.java
* ---------------------------
* (C) Copyright 2004-2008, by Object Refinery Limited.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes:
* --------
* 23-Aug-2004 : Restructured org.jfree.chart.renderer package (DG);
* 06-Jan-2005 : Added method to create test dataset (DG);
* 07-Jan-2005 : Added a second method to create a test dataset (DG);
* 19-Jan-2005 : Added main() method to run JUnit in text mode (DG);
* 25-Oct-2006 : Added tests for XYErrorRenderer class (DG);
* 31-Jan-2007 : Added XYBlockRendererTests (DG);
* 26-Feb-2007 : Added DeviationRendererTests (DG);
* 30-Apr-2007 : Added XYLine3DRendererTests (DG);
* 25-May-2007 : Added VectorRendererTests (DG);
* 25-Jul-2007 : Added XYSplineAndRendererTests (DG);
*
*/
package org.jfree.chart.renderer.xy;
import org.jfree.data.xy.DefaultTableXYDataset;
import org.jfree.data.xy.TableXYDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
/**
* A collection of tests for the org.jfree.chart.renderer.xy package.
* <P>
* These tests can be run using JUnit (http://www.junit.org).
*/
public class RendererXYPackageTests {
/**
* Creates and returns a sample dataset for testing purposes.
*
* @return A sample dataset.
*/
public static XYSeriesCollection createTestXYSeriesCollection() {
XYSeriesCollection result = new XYSeriesCollection();
XYSeries series1 = new XYSeries("Series 1", false, false);
series1.add(1.0, 2.0);
series1.add(2.0, 5.0);
XYSeries series2 = new XYSeries("Series 2", false, false);
series2.add(1.0, 4.0);
series2.add(2.0, 3.0);
result.addSeries(series1);
result.addSeries(series2);
return result;
}
/**
* Creates and returns a sample dataset for testing purposes.
*
* @return A sample dataset.
*/
public static TableXYDataset createTestTableXYDataset() {
DefaultTableXYDataset result = new DefaultTableXYDataset();
XYSeries series1 = new XYSeries("Series 1", false, false);
series1.add(1.0, 2.0);
series1.add(2.0, 5.0);
XYSeries series2 = new XYSeries("Series 2", false, false);
series2.add(1.0, 4.0);
series2.add(2.0, 3.0);
result.addSeries(series1);
result.addSeries(series2);
return result;
}
}
| 3,709 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
StandardXYItemRendererTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/xy/StandardXYItemRendererTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* --------------------------------
* StandardXYItemRendererTests.java
* --------------------------------
* (C) Copyright 2003-2012, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 25-Mar-2003 : Version 1 (DG);
* 22-Oct-2003 : Added hashCode test (DG);
* 08-Oct-2004 : Strengthened test for equals() method (DG);
* 14-Mar-2007 : Added new checks in testEquals() and testCloning() (DG);
* 17-May-2007 : Added testGetLegendItemSeriesIndex() (DG);
* 08-Jun-2007 : Added testNoDisplayedItem() (DG);
* 22-Apr-2008 : Added testPublicCloneable (DG);
* 17-Jun-2012 : Removed JCommon dependencies (DG);
*
*/
package org.jfree.chart.renderer.xy;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartRenderingInfo;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.LegendItem;
import org.jfree.chart.TestUtilities;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.entity.EntityCollection;
import org.jfree.chart.entity.XYItemEntity;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.chart.util.UnitType;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import org.junit.Test;
import java.awt.Graphics2D;
import java.awt.geom.Line2D;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link StandardXYItemRenderer} class.
*/
public class StandardXYItemRendererTest {
/**
* Test that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
StandardXYItemRenderer r1 = new StandardXYItemRenderer();
StandardXYItemRenderer r2 = new StandardXYItemRenderer();
assertEquals(r1, r2);
r1.setBaseShapesVisible(true);
assertFalse(r1.equals(r2));
r2.setBaseShapesVisible(true);
assertEquals(r1, r2);
r1.setPlotLines(false);
assertFalse(r1.equals(r2));
r2.setPlotLines(false);
assertEquals(r1, r2);
r1.setPlotImages(true);
assertFalse(r1.equals(r2));
r2.setPlotImages(true);
assertEquals(r1, r2);
r1.setPlotDiscontinuous(true);
assertFalse(r1.equals(r2));
r2.setPlotDiscontinuous(true);
assertEquals(r1, r2);
r1.setGapThresholdType(UnitType.ABSOLUTE);
assertFalse(r1.equals(r2));
r2.setGapThresholdType(UnitType.ABSOLUTE);
assertEquals(r1, r2);
r1.setGapThreshold(1.23);
assertFalse(r1.equals(r2));
r2.setGapThreshold(1.23);
assertEquals(r1, r2);
r1.setLegendLine(new Line2D.Double(1.0, 2.0, 3.0, 4.0));
assertFalse(r1.equals(r2));
r2.setLegendLine(new Line2D.Double(1.0, 2.0, 3.0, 4.0));
assertEquals(r1, r2);
r1.setSeriesShapesFilled(1, Boolean.TRUE);
assertFalse(r1.equals(r2));
r2.setSeriesShapesFilled(1, Boolean.TRUE);
assertEquals(r1, r2);
r1.setBaseShapesFilled(false);
assertFalse(r1.equals(r2));
r2.setBaseShapesFilled(false);
assertEquals(r1, r2);
r1.setDrawSeriesLineAsPath(true);
assertFalse(r1.equals(r2));
r2.setDrawSeriesLineAsPath(true);
assertEquals(r1, r2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
StandardXYItemRenderer r1 = new StandardXYItemRenderer();
StandardXYItemRenderer r2 = new StandardXYItemRenderer();
assertEquals(r1, r2);
int h1 = r1.hashCode();
int h2 = r2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
StandardXYItemRenderer r1 = new StandardXYItemRenderer();
Rectangle2D rect1 = new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0);
r1.setLegendLine(rect1);
StandardXYItemRenderer r2 = (StandardXYItemRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
// check independence
rect1.setRect(4.0, 3.0, 2.0, 1.0);
assertFalse(r1.equals(r2));
r2.setLegendLine(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0));
assertEquals(r1, r2);
r1.setSeriesShapesFilled(1, Boolean.TRUE);
assertFalse(r1.equals(r2));
r2.setSeriesShapesFilled(1, Boolean.TRUE);
assertEquals(r1, r2);
}
/**
* Verify that this class implements {@link PublicCloneable}.
*/
@Test
public void testPublicCloneable() {
StandardXYItemRenderer r1 = new StandardXYItemRenderer();
assertTrue(r1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
StandardXYItemRenderer r1 = new StandardXYItemRenderer();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
StandardXYItemRenderer r2 = (StandardXYItemRenderer) in.readObject();
in.close();
assertEquals(r1, r2);
}
/**
* A check for the datasetIndex and seriesIndex fields in the LegendItem
* returned by the getLegendItem() method.
*/
@Test
public void testGetLegendItemSeriesIndex() {
XYSeriesCollection d1 = new XYSeriesCollection();
XYSeries s1 = new XYSeries("S1");
s1.add(1.0, 1.1);
XYSeries s2 = new XYSeries("S2");
s2.add(1.0, 1.1);
d1.addSeries(s1);
d1.addSeries(s2);
XYSeriesCollection d2 = new XYSeriesCollection();
XYSeries s3 = new XYSeries("S3");
s3.add(1.0, 1.1);
XYSeries s4 = new XYSeries("S4");
s4.add(1.0, 1.1);
XYSeries s5 = new XYSeries("S5");
s5.add(1.0, 1.1);
d2.addSeries(s3);
d2.addSeries(s4);
d2.addSeries(s5);
StandardXYItemRenderer r = new StandardXYItemRenderer();
XYPlot plot = new XYPlot(d1, new NumberAxis("x"),
new NumberAxis("y"), r);
plot.setDataset(1, d2);
/*JFreeChart chart =*/ new JFreeChart(plot);
LegendItem li = r.getLegendItem(1, 2);
assertEquals("S5", li.getLabel());
assertEquals(1, li.getDatasetIndex());
assertEquals(2, li.getSeriesIndex());
}
/**
* A check to ensure that an item that falls outside the plot's data area
* does NOT generate an item entity.
*/
@Test
public void testNoDisplayedItem() {
XYSeriesCollection dataset = new XYSeriesCollection();
XYSeries s1 = new XYSeries("S1");
s1.add(10.0, 10.0);
dataset.addSeries(s1);
JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y",
dataset);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setRenderer(new StandardXYItemRenderer());
NumberAxis xAxis = (NumberAxis) plot.getDomainAxis();
xAxis.setRange(0.0, 5.0);
NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
yAxis.setRange(0.0, 5.0);
BufferedImage image = new BufferedImage(200 , 100,
BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = image.createGraphics();
ChartRenderingInfo info = new ChartRenderingInfo();
chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, info);
g2.dispose();
EntityCollection ec = info.getEntityCollection();
assertFalse(TestUtilities.containsInstanceOf(ec.getEntities(),
XYItemEntity.class));
}
}
| 9,709 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
XYSplineRendererTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/xy/XYSplineRendererTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* --------------------------
* XYSplineRendererTests.java
* --------------------------
* (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 25-Jul-2007 : Version 1 (DG);
* 22-Apr-2008 : Added testPublicCloneable() (DG);
*
*/
package org.jfree.chart.renderer.xy;
import org.jfree.chart.util.PublicCloneable;
import org.junit.Test;
import java.awt.geom.Rectangle2D;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link XYSplineRenderer} class.
*/
public class XYSplineRendererTest {
/**
* 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);
assertEquals(r1, r2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
XYSplineRenderer r1 = new XYSplineRenderer();
XYSplineRenderer r2 = new XYSplineRenderer();
assertEquals(r1, r2);
int h1 = r1.hashCode();
int h2 = r2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
Rectangle2D legendShape = new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0);
XYSplineRenderer r1 = new XYSplineRenderer();
r1.setLegendLine(legendShape);
XYSplineRenderer r2 = (XYSplineRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
}
/**
* Verify that this class implements {@link PublicCloneable}.
*/
@Test
public void testPublicCloneable() {
XYSplineRenderer r1 = new XYSplineRenderer();
assertTrue(r1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
XYSplineRenderer r1 = new XYSplineRenderer();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
XYSplineRenderer r2 = (XYSplineRenderer) in.readObject();
in.close();
assertEquals(r1, r2);
}
}
| 4,478 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
XYStepAreaRendererTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/xy/XYStepAreaRendererTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2013, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ----------------------------
* XYStepAreaRendererTests.java
* ----------------------------
* (C) Copyright 2003-2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): Matthias Rose;
*
* Changes
* -------
* 25-Mar-2003 : Version 1 (DG);
* 26-Sep-2003 : copied XYStepRendererTests.java and used for
* testing XYStepAreaRenderer (MR);
* 14-Feb-2007 : Extended testEquals() (DG);
* 22-Apr-2008 : Added testPublicCloneable (DG);
*
*/
package org.jfree.chart.renderer.xy;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.data.xy.DefaultTableXYDataset;
import org.jfree.data.xy.XYSeries;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link XYStepAreaRenderer} class.
*/
public class XYStepAreaRendererTest {
/**
* Check that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
XYStepAreaRenderer r1 = new XYStepAreaRenderer();
XYStepAreaRenderer r2 = new XYStepAreaRenderer();
assertEquals(r1, r2);
r1.setOutline(true);
assertFalse(r1.equals(r2));
r2.setOutline(true);
assertEquals(r1, r2);
r1.setShapesVisible(true);
assertFalse(r1.equals(r2));
r2.setShapesVisible(true);
assertEquals(r1, r2);
r1.setShapesFilled(true);
assertFalse(r1.equals(r2));
r2.setShapesFilled(true);
assertEquals(r1, r2);
r1.setPlotArea(false);
assertFalse(r1.equals(r2));
r2.setPlotArea(false);
assertEquals(r1, r2);
r1.setRangeBase(-1.0);
assertFalse(r1.equals(r2));
r2.setRangeBase(-1.0);
assertEquals(r1, r2);
r1.setStepPoint(0.33);
assertFalse(r1.equals(r2));
r2.setStepPoint(0.33);
assertEquals(r1, r2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
XYStepAreaRenderer r1 = new XYStepAreaRenderer();
XYStepAreaRenderer r2 = new XYStepAreaRenderer();
assertEquals(r1, r2);
int h1 = r1.hashCode();
int h2 = r2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
XYStepAreaRenderer r1 = new XYStepAreaRenderer();
XYStepAreaRenderer r2 = (XYStepAreaRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
}
/**
* Verify that this class implements {@link PublicCloneable}.
*/
@Test
public void testPublicCloneable() {
XYStepAreaRenderer r1 = new XYStepAreaRenderer();
assertTrue(r1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
XYStepAreaRenderer r1 = new XYStepAreaRenderer();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
XYStepAreaRenderer r2 = (XYStepAreaRenderer) in.readObject();
in.close();
assertEquals(r1, r2);
}
/**
* Draws the chart with a <code>null</code> info object to make sure that
* no exceptions are thrown (particularly by code in the renderer).
*/
@Test
public void testDrawWithNullInfo() {
DefaultTableXYDataset dataset = new DefaultTableXYDataset();
XYSeries s1 = new XYSeries("Series 1", true, false);
s1.add(5.0, 5.0);
s1.add(10.0, 15.5);
s1.add(15.0, 9.5);
s1.add(20.0, 7.5);
dataset.addSeries(s1);
XYSeries s2 = new XYSeries("Series 2", true, false);
s2.add(5.0, 5.0);
s2.add(10.0, 15.5);
s2.add(15.0, 9.5);
s2.add(20.0, 3.5);
dataset.addSeries(s2);
XYPlot plot = new XYPlot(dataset,
new NumberAxis("X"), new NumberAxis("Y"),
new XYStepAreaRenderer());
JFreeChart chart = new JFreeChart(plot);
/* BufferedImage image = */ chart.createBufferedImage(300, 200,
null);
}
}
| 6,431 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
StackedXYAreaRenderer2Test.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/xy/StackedXYAreaRenderer2Test.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* -------------------------------
* StackedXYAreaRenderer2Tests.java
* -------------------------------
* (C) Copyright 2005-2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 06-Jan-2005 : Version 1 (DG);
* 22-Aug-2006 : Added testDrawWithEmptyDataset() method (DG);
* 30-Nov-2006 : Extended testEquals() (DG);
* 22-Apr-2008 : Added testPublicCloneable (DG);
*
*/
package org.jfree.chart.renderer.xy;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.data.Range;
import org.jfree.data.xy.DefaultTableXYDataset;
import org.jfree.data.xy.TableXYDataset;
import org.junit.Test;
import java.awt.Graphics2D;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link StackedXYAreaRenderer2} class.
*/
public class StackedXYAreaRenderer2Test {
/**
* Test chart drawing with an empty dataset to ensure that this special
* case doesn't cause any exceptions.
*/
@Test
public void testDrawWithEmptyDataset() {
JFreeChart chart = ChartFactory.createStackedXYAreaChart("title", "x",
"y", new DefaultTableXYDataset());
XYPlot plot = (XYPlot) chart.getPlot();
plot.setRenderer(new StackedXYAreaRenderer2());
BufferedImage image = new BufferedImage(200 , 100,
BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = image.createGraphics();
chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null);
g2.dispose();
}
/**
* Test that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
StackedXYAreaRenderer2 r1 = new StackedXYAreaRenderer2();
StackedXYAreaRenderer2 r2 = new StackedXYAreaRenderer2();
assertEquals(r1, r2);
assertEquals(r2, r1);
r1.setRoundXCoordinates(!r1.getRoundXCoordinates());
assertFalse(r1.equals(r2));
r2.setRoundXCoordinates(r1.getRoundXCoordinates());
assertEquals(r1, r2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
StackedXYAreaRenderer2 r1 = new StackedXYAreaRenderer2();
StackedXYAreaRenderer2 r2 = new StackedXYAreaRenderer2();
assertEquals(r1, r2);
int h1 = r1.hashCode();
int h2 = r2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
StackedXYAreaRenderer2 r1 = new StackedXYAreaRenderer2();
StackedXYAreaRenderer2 r2 = (StackedXYAreaRenderer2) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
}
/**
* Verify that this class implements {@link PublicCloneable}.
*/
@Test
public void testPublicCloneable() {
StackedXYAreaRenderer2 r1 = new StackedXYAreaRenderer2();
assertTrue(r1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
StackedXYAreaRenderer2 r1 = new StackedXYAreaRenderer2();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
StackedXYAreaRenderer2 r2 = (StackedXYAreaRenderer2) in.readObject();
in.close();
assertEquals(r1, r2);
}
/**
* Check that the renderer is calculating the range bounds correctly.
*/
@Test
public void testFindRangeBounds() {
TableXYDataset dataset
= RendererXYPackageTests.createTestTableXYDataset();
JFreeChart chart = ChartFactory.createStackedXYAreaChart(
"Test Chart", "X", "Y", dataset);
XYPlot plot = (XYPlot) chart.getPlot();
StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2();
plot.setRenderer(renderer);
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
Range bounds = rangeAxis.getRange();
assertTrue(bounds.contains(6.0));
assertTrue(bounds.contains(8.0));
// try null argument
assertNull(renderer.findRangeBounds(null));
// try empty dataset
assertNull(renderer.findRangeBounds(new DefaultTableXYDataset()));
}
}
| 6,641 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
StackedXYBarRendererTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/xy/StackedXYBarRendererTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ------------------------------
* StackedXYBarRendererTests.java
* ------------------------------
* (C) Copyright 2004-2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 10-Sep-2004 : Version 1 (DG);
* 06-Jan-2005 : Added test for auto range calculation (DG);
* 06-Dec-2006 : Confirm serialization of GradientPaint (DG);
* 22-Apr-2008 : Added testPublicCloneable (DG);
*
*/
package org.jfree.chart.renderer.xy;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.data.Range;
import org.jfree.data.xy.TableXYDataset;
import org.junit.Test;
import java.awt.Color;
import java.awt.GradientPaint;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link StackedXYBarRenderer} class.
*/
public class StackedXYBarRendererTest {
/**
* Test that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
StackedXYBarRenderer r1 = new StackedXYBarRenderer();
StackedXYBarRenderer r2 = new StackedXYBarRenderer();
assertEquals(r1, r2);
assertEquals(r2, r1);
r1.setRenderAsPercentages(true);
assertFalse(r1.equals(r2));
r2.setRenderAsPercentages(true);
assertEquals(r1, r2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
StackedXYBarRenderer r1 = new StackedXYBarRenderer();
StackedXYBarRenderer r2 = new StackedXYBarRenderer();
assertEquals(r1, r2);
int h1 = r1.hashCode();
int h2 = r2.hashCode();
assertEquals(h1, h2);
r1.setRenderAsPercentages(true);
h1 = r1.hashCode();
h2 = r2.hashCode();
assertFalse(h1 == h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
StackedXYBarRenderer r1 = new StackedXYBarRenderer();
StackedXYBarRenderer r2 = (StackedXYBarRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
}
/**
* Verify that this class implements {@link PublicCloneable}.
*/
@Test
public void testPublicCloneable() {
StackedXYBarRenderer r1 = new StackedXYBarRenderer();
assertTrue(r1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
StackedXYBarRenderer r1 = new StackedXYBarRenderer();
r1.setSeriesPaint(0, new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f,
4.0f, Color.yellow));
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
StackedXYBarRenderer r2 = (StackedXYBarRenderer) in.readObject();
in.close();
assertEquals(r1, r2);
}
/**
* Check that the renderer is calculating the domain bounds correctly.
*/
@Test
public void testFindDomainBounds() {
TableXYDataset dataset
= RendererXYPackageTests.createTestTableXYDataset();
JFreeChart chart = ChartFactory.createStackedXYAreaChart(
"Test Chart", "X", "Y", dataset);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setRenderer(new StackedXYBarRenderer());
NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
domainAxis.setAutoRangeIncludesZero(false);
Range bounds = domainAxis.getRange();
assertFalse(bounds.contains(0.3));
assertTrue(bounds.contains(0.5));
assertTrue(bounds.contains(2.5));
assertFalse(bounds.contains(2.8));
}
/**
* Check that the renderer is calculating the range bounds correctly.
*/
@Test
public void testFindRangeBounds() {
TableXYDataset dataset
= RendererXYPackageTests.createTestTableXYDataset();
JFreeChart chart = ChartFactory.createStackedXYAreaChart(
"Test Chart", "X", "Y", dataset);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setRenderer(new StackedXYBarRenderer());
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
Range bounds = rangeAxis.getRange();
assertTrue(bounds.contains(6.0));
assertTrue(bounds.contains(8.0));
}
}
| 6,539 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
XYLineAndShapeRendererTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/xy/XYLineAndShapeRendererTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* --------------------------------
* XYLineAndShapeRendererTests.java
* --------------------------------
* (C) Copyright 2004-2012, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 27-Jan-2004 : Version 1 (DG);
* 07-Jan-2005 : Added check for findRangeBounds() method (DG);
* 21-Feb-2007 : Check independence in testCloning() (DG);
* 17-May-2007 : Added testGetLegendItemSeriesIndex() (DG);
* 22-Apr-2008 : Added testPublicCloneable() (DG);
*
*/
package org.jfree.chart.renderer.xy;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.LegendItem;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.urls.TimeSeriesURLGenerator;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.data.Range;
import org.jfree.data.xy.TableXYDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import org.junit.Test;
import java.awt.geom.Line2D;
import java.awt.geom.Rectangle2D;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link XYLineAndShapeRenderer} class.
*/
public class XYLineAndShapeRendererTest {
/**
* Test that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
XYLineAndShapeRenderer r1 = new XYLineAndShapeRenderer();
XYLineAndShapeRenderer r2 = new XYLineAndShapeRenderer();
assertEquals(r1, r2);
assertEquals(r2, r1);
r1.setSeriesLinesVisible(3, true);
assertFalse(r1.equals(r2));
r2.setSeriesLinesVisible(3, true);
assertEquals(r1, r2);
r1.setBaseLinesVisible(false);
assertFalse(r1.equals(r2));
r2.setBaseLinesVisible(false);
assertEquals(r1, r2);
r1.setLegendLine(new Line2D.Double(1.0, 2.0, 3.0, 4.0));
assertFalse(r1.equals(r2));
r2.setLegendLine(new Line2D.Double(1.0, 2.0, 3.0, 4.0));
assertEquals(r1, r2);
r1.setSeriesShapesVisible(3, true);
assertFalse(r1.equals(r2));
r2.setSeriesShapesVisible(3, true);
assertEquals(r1, r2);
r1.setBaseShapesVisible(false);
assertFalse(r1.equals(r2));
r2.setBaseShapesVisible(false);
assertEquals(r1, r2);
r1.setSeriesShapesFilled(3, true);
assertFalse(r1.equals(r2));
r2.setSeriesShapesFilled(3, true);
assertEquals(r1, r2);
r1.setBaseShapesFilled(false);
assertFalse(r1.equals(r2));
r2.setBaseShapesFilled(false);
assertEquals(r1, r2);
r1.setDrawOutlines(!r1.getDrawOutlines());
assertFalse(r1.equals(r2));
r2.setDrawOutlines(r1.getDrawOutlines());
assertEquals(r1, r2);
r1.setUseOutlinePaint(true);
assertFalse(r1.equals(r2));
r2.setUseOutlinePaint(true);
assertEquals(r1, r2);
r1.setUseFillPaint(true);
assertFalse(r1.equals(r2));
r2.setUseFillPaint(true);
assertEquals(r1, r2);
r1.setDrawSeriesLineAsPath(true);
assertFalse(r1.equals(r2));
r2.setDrawSeriesLineAsPath(true);
assertEquals(r1, r2);
}
/**
* Test that the equals() method works for a TimeSeriesURLGenerator.
*/
@Test
public void testEquals2() {
XYLineAndShapeRenderer r1 = new XYLineAndShapeRenderer();
XYLineAndShapeRenderer r2 = new XYLineAndShapeRenderer();
assertEquals(r1, r2);
assertEquals(r2, r1);
r1.setURLGenerator(new TimeSeriesURLGenerator());
assertFalse(r1.equals(r2));
r2.setURLGenerator(new TimeSeriesURLGenerator());
assertEquals(r1, r2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
XYLineAndShapeRenderer r1 = new XYLineAndShapeRenderer();
XYLineAndShapeRenderer r2 = new XYLineAndShapeRenderer();
assertEquals(r1, r2);
int h1 = r1.hashCode();
int h2 = r2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
Rectangle2D legendShape = new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0);
XYLineAndShapeRenderer r1 = new XYLineAndShapeRenderer();
r1.setLegendLine(legendShape);
XYLineAndShapeRenderer r2 = (XYLineAndShapeRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
r1.setSeriesLinesVisible(0, false);
assertFalse(r1.equals(r2));
r2.setSeriesLinesVisible(0, false);
assertEquals(r1, r2);
legendShape.setRect(4.0, 3.0, 2.0, 1.0);
assertFalse(r1.equals(r2));
r2.setLegendLine(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0));
assertEquals(r1, r2);
r1.setSeriesShapesVisible(1, true);
assertFalse(r1.equals(r2));
r2.setSeriesShapesVisible(1, true);
assertEquals(r1, r2);
r1.setSeriesShapesFilled(1, true);
assertFalse(r1.equals(r2));
r2.setSeriesShapesFilled(1, true);
assertEquals(r1, r2);
}
/**
* Verify that this class implements {@link PublicCloneable}.
*/
@Test
public void testPublicCloneable() {
XYLineAndShapeRenderer r1 = new XYLineAndShapeRenderer();
assertTrue(r1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
XYLineAndShapeRenderer r1 = new XYLineAndShapeRenderer();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
XYLineAndShapeRenderer r2 = (XYLineAndShapeRenderer) in.readObject();
in.close();
assertEquals(r1, r2);
}
/**
* Check that the renderer is calculating the domain bounds correctly.
*/
@Test
public void testFindDomainBounds() {
XYSeriesCollection dataset
= RendererXYPackageTests.createTestXYSeriesCollection();
JFreeChart chart = ChartFactory.createXYLineChart(
"Test Chart", "X", "Y", dataset);
XYPlot plot = (XYPlot) chart.getPlot();
NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
domainAxis.setAutoRangeIncludesZero(false);
Range bounds = domainAxis.getRange();
assertFalse(bounds.contains(0.9));
assertTrue(bounds.contains(1.0));
assertTrue(bounds.contains(2.0));
assertFalse(bounds.contains(2.10));
}
/**
* Check that the renderer is calculating the range bounds correctly.
*/
@Test
public void testFindRangeBounds() {
TableXYDataset dataset
= RendererXYPackageTests.createTestTableXYDataset();
JFreeChart chart = ChartFactory.createXYLineChart(
"Test Chart", "X", "Y", dataset);
XYPlot plot = (XYPlot) chart.getPlot();
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setAutoRangeIncludesZero(false);
Range bounds = rangeAxis.getRange();
assertFalse(bounds.contains(1.0));
assertTrue(bounds.contains(2.0));
assertTrue(bounds.contains(5.0));
assertFalse(bounds.contains(6.0));
}
/**
* A check for the datasetIndex and seriesIndex fields in the LegendItem
* returned by the getLegendItem() method.
*/
@Test
public void testGetLegendItemSeriesIndex() {
XYSeriesCollection d1 = new XYSeriesCollection();
XYSeries s1 = new XYSeries("S1");
s1.add(1.0, 1.1);
XYSeries s2 = new XYSeries("S2");
s2.add(1.0, 1.1);
d1.addSeries(s1);
d1.addSeries(s2);
XYSeriesCollection d2 = new XYSeriesCollection();
XYSeries s3 = new XYSeries("S3");
s3.add(1.0, 1.1);
XYSeries s4 = new XYSeries("S4");
s4.add(1.0, 1.1);
XYSeries s5 = new XYSeries("S5");
s5.add(1.0, 1.1);
d2.addSeries(s3);
d2.addSeries(s4);
d2.addSeries(s5);
XYLineAndShapeRenderer r = new XYLineAndShapeRenderer();
XYPlot plot = new XYPlot(d1, new NumberAxis("x"),
new NumberAxis("y"), r);
plot.setDataset(1, d2);
/*JFreeChart chart =*/ new JFreeChart(plot);
LegendItem li = r.getLegendItem(1, 2);
assertEquals("S5", li.getLabel());
assertEquals(1, li.getDatasetIndex());
assertEquals(2, li.getSeriesIndex());
}
}
| 10,654 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
XYDifferenceRendererTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/xy/XYDifferenceRendererTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ------------------------------
* XYDifferenceRendererTests.java
* ------------------------------
* (C) Copyright 2003-2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 22-Oct-2003 : Version 1 (DG);
* 04-May-2005 : Improved equals() test (DG);
* 24-Jan-2007 : Added 'roundXCoordinates' to testEquals(), and improved
* testClone() (DG);
* 17-May-2007 : Added testGetLegendItemSeriesIndex() (DG);
* 22-Apr-2008 : Added testPublicCloneable (DG);
*
*/
package org.jfree.chart.renderer.xy;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.LegendItem;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import org.junit.Test;
import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Shape;
import java.awt.geom.Line2D;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link XYDifferenceRenderer} class.
*/
public class XYDifferenceRendererTest {
/**
* Check that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
XYDifferenceRenderer r1 = new XYDifferenceRenderer(
Color.RED, Color.BLUE, false);
XYDifferenceRenderer r2 = new XYDifferenceRenderer(
Color.RED, Color.BLUE, false);
assertEquals(r1, r2);
// positive paint
r1.setPositivePaint(new GradientPaint(1.0f, 2.0f, Color.RED,
3.0f, 4.0f, Color.BLUE));
assertFalse(r1.equals(r2));
r2.setPositivePaint(new GradientPaint(1.0f, 2.0f, Color.RED,
3.0f, 4.0f, Color.BLUE));
assertEquals(r1, r2);
// negative paint
r1.setNegativePaint(new GradientPaint(1.0f, 2.0f, Color.yellow,
3.0f, 4.0f, Color.BLUE));
assertFalse(r1.equals(r2));
r2.setNegativePaint(new GradientPaint(1.0f, 2.0f, Color.yellow,
3.0f, 4.0f, Color.BLUE));
assertEquals(r1, r2);
// shapesVisible
r1 = new XYDifferenceRenderer(Color.green, Color.yellow, true);
assertFalse(r1.equals(r2));
r2 = new XYDifferenceRenderer(Color.green, Color.yellow, true);
assertEquals(r1, r2);
// legendLine
r1.setLegendLine(new Line2D.Double(1.0, 2.0, 3.0, 4.0));
assertFalse(r1.equals(r2));
r2.setLegendLine(new Line2D.Double(1.0, 2.0, 3.0, 4.0));
assertEquals(r1, r2);
// roundXCoordinates
r1.setRoundXCoordinates(true);
assertFalse(r1.equals(r2));
r2.setRoundXCoordinates(true);
assertEquals(r1, r2);
assertFalse(r1.equals(null));
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
XYDifferenceRenderer r1
= new XYDifferenceRenderer(Color.RED, Color.BLUE, false);
XYDifferenceRenderer r2
= new XYDifferenceRenderer(Color.RED, Color.BLUE, false);
assertEquals(r1, r2);
int h1 = r1.hashCode();
int h2 = r2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
XYDifferenceRenderer r1 = new XYDifferenceRenderer(Color.RED,
Color.BLUE, false);
XYDifferenceRenderer r2 = (XYDifferenceRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
// check independence
Shape s = r1.getLegendLine();
if (s instanceof Line2D) {
Line2D l = (Line2D) s;
l.setLine(1.0, 2.0, 3.0, 4.0);
assertFalse(r1.equals(r2));
}
}
/**
* Verify that this class implements {@link PublicCloneable}.
*/
@Test
public void testPublicCloneable() {
XYDifferenceRenderer r1 = new XYDifferenceRenderer();
assertTrue(r1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
XYDifferenceRenderer r1 = new XYDifferenceRenderer(Color.RED,
Color.BLUE, false);
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
XYDifferenceRenderer r2 = (XYDifferenceRenderer) in.readObject();
in.close();
assertEquals(r1, r2);
}
/**
* A check for the datasetIndex and seriesIndex fields in the LegendItem
* returned by the getLegendItem() method.
*/
@Test
public void testGetLegendItemSeriesIndex() {
XYSeriesCollection d1 = new XYSeriesCollection();
XYSeries s1 = new XYSeries("S1");
s1.add(1.0, 1.1);
XYSeries s2 = new XYSeries("S2");
s2.add(1.0, 1.1);
d1.addSeries(s1);
d1.addSeries(s2);
XYSeriesCollection d2 = new XYSeriesCollection();
XYSeries s3 = new XYSeries("S3");
s3.add(1.0, 1.1);
XYSeries s4 = new XYSeries("S4");
s4.add(1.0, 1.1);
XYSeries s5 = new XYSeries("S5");
s5.add(1.0, 1.1);
d2.addSeries(s3);
d2.addSeries(s4);
d2.addSeries(s5);
XYDifferenceRenderer r = new XYDifferenceRenderer();
XYPlot plot = new XYPlot(d1, new NumberAxis("x"),
new NumberAxis("y"), r);
plot.setDataset(1, d2);
/*JFreeChart chart =*/ new JFreeChart(plot);
LegendItem li = r.getLegendItem(1, 2);
assertEquals("S5", li.getLabel());
assertEquals(1, li.getDatasetIndex());
assertEquals(2, li.getSeriesIndex());
}
}
| 7,826 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
ClusteredXYBarRendererTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/xy/ClusteredXYBarRendererTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* --------------------------------
* ClusteredXYBarRendererTests.java
* --------------------------------
* (C) Copyright 2003-2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 25-Mar-2003 : Version 1 (DG);
* 22-Oct-2003 : Added hashCode test (DG);
* 10-Jul-2007 : Fixed compile errors (DG);
* 22-Apr-2008 : Added testPublicCloneable() (DG);
*
*/
package org.jfree.chart.renderer.xy;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.data.Range;
import org.jfree.data.xy.DefaultIntervalXYDataset;
import org.jfree.data.xy.XYDataset;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link ClusteredXYBarRenderer} class.
*/
public class ClusteredXYBarRendererTest {
/**
* Check that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
ClusteredXYBarRenderer r1 = new ClusteredXYBarRenderer();
ClusteredXYBarRenderer r2 = new ClusteredXYBarRenderer();
assertEquals(r1, r2);
assertEquals(r2, r1);
r1 = new ClusteredXYBarRenderer(1.2, false);
assertFalse(r1.equals(r2));
r2 = new ClusteredXYBarRenderer(1.2, false);
assertEquals(r1, r2);
r1 = new ClusteredXYBarRenderer(1.2, true);
assertFalse(r1.equals(r2));
r2 = new ClusteredXYBarRenderer(1.2, true);
assertEquals(r1, r2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
ClusteredXYBarRenderer r1 = new ClusteredXYBarRenderer();
ClusteredXYBarRenderer r2 = new ClusteredXYBarRenderer();
assertEquals(r1, r2);
int h1 = r1.hashCode();
int h2 = r2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
ClusteredXYBarRenderer r1 = new ClusteredXYBarRenderer();
ClusteredXYBarRenderer r2 = (ClusteredXYBarRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
}
/**
* Verify that this class implements {@link PublicCloneable}.
*/
@Test
public void testPublicCloneable() {
ClusteredXYBarRenderer r1 = new ClusteredXYBarRenderer();
assertTrue(r1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
ClusteredXYBarRenderer r1 = new ClusteredXYBarRenderer();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
ClusteredXYBarRenderer r2 = (ClusteredXYBarRenderer) in.readObject();
in.close();
assertEquals(r1, r2);
}
private static final double EPSILON = 0.0000000001;
/**
* Some checks for the findDomainBounds() method (which requires special
* handling when the centerBarAtStartValue flag is set to true).
*/
@Test
public void testFindDomainBounds() {
AbstractXYItemRenderer renderer = new ClusteredXYBarRenderer();
XYDataset dataset = createSampleDataset1();
Range r = renderer.findDomainBounds(dataset);
assertEquals(0.9, r.getLowerBound(), EPSILON);
assertEquals(13.1, r.getUpperBound(), EPSILON);
renderer = new ClusteredXYBarRenderer(0.0, true);
r = renderer.findDomainBounds(dataset);
assertEquals(0.8, r.getLowerBound(), EPSILON);
assertEquals(13.0, r.getUpperBound(), EPSILON);
// check that a null dataset returns null bounds
assertNull(renderer.findDomainBounds(null));
}
/**
* Creates a sample dataset for testing.
*
* @return A sample dataset.
*/
public DefaultIntervalXYDataset createSampleDataset1() {
DefaultIntervalXYDataset d = new DefaultIntervalXYDataset();
double[] x1 = new double[] {1.0, 2.0, 3.0};
double[] x1Start = new double[] {0.9, 1.9, 2.9};
double[] x1End = new double[] {1.1, 2.1, 3.1};
double[] y1 = new double[] {4.0, 5.0, 6.0};
double[] y1Start = new double[] {1.09, 2.09, 3.09};
double[] y1End = new double[] {1.11, 2.11, 3.11};
double[][] data1 = new double[][] {x1, x1Start, x1End, y1, y1Start,
y1End};
d.addSeries("S1", data1);
double[] x2 = new double[] {11.0, 12.0, 13.0};
double[] x2Start = new double[] {10.9, 11.9, 12.9};
double[] x2End = new double[] {11.1, 12.1, 13.1};
double[] y2 = new double[] {14.0, 15.0, 16.0};
double[] y2Start = new double[] {11.09, 12.09, 13.09};
double[] y2End = new double[] {11.11, 12.11, 13.11};
double[][] data2 = new double[][] {x2, x2Start, x2End, y2, y2Start,
y2End};
d.addSeries("S2", data2);
return d;
}
}
| 7,010 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
XYBlockRendererTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/xy/XYBlockRendererTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* -------------------------
* XYBlockRendererTests.java
* -------------------------
* (C) Copyright 2006-2011, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 05-Jul-2006 : Version 1 (DG);
* 09-Mar-2007 : Added independence check to testCloning (DG);
* 22-Apr-2008 : Added testPublicCloneable (DG);
* 20-Oct-2011 : Added testFindDomainBounds() and testFindRangeBounds() (DG);
*
*/
package org.jfree.chart.renderer.xy;
import org.jfree.chart.renderer.GrayPaintScale;
import org.jfree.chart.renderer.LookupPaintScale;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.data.Range;
import org.jfree.data.xy.DefaultXYZDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import org.junit.Test;
import java.awt.Color;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link XYBlockRenderer} class.
*/
public class XYBlockRendererTest {
private static final double EPSILON = 0.0000000001;
/**
* Test that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
// default instances
XYBlockRenderer r1 = new XYBlockRenderer();
XYBlockRenderer r2 = new XYBlockRenderer();
assertEquals(r1, r2);
assertEquals(r2, r1);
// blockHeight
r1.setBlockHeight(2.0);
assertFalse(r1.equals(r2));
r2.setBlockHeight(2.0);
assertEquals(r1, r2);
// blockWidth
r1.setBlockWidth(2.0);
assertFalse(r1.equals(r2));
r2.setBlockWidth(2.0);
assertEquals(r1, r2);
// paintScale
r1.setPaintScale(new GrayPaintScale(0.0, 1.0));
assertFalse(r1.equals(r2));
r2.setPaintScale(new GrayPaintScale(0.0, 1.0));
assertEquals(r1, r2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
XYBlockRenderer r1 = new XYBlockRenderer();
XYBlockRenderer r2 = new XYBlockRenderer();
assertEquals(r1, r2);
int h1 = r1.hashCode();
int h2 = r2.hashCode();
assertEquals(h1, h2);
}
/**
* 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();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
// check independence
scale1.add(0.5, Color.RED);
assertFalse(r1.equals(r2));
LookupPaintScale scale2 = (LookupPaintScale) r2.getPaintScale();
scale2.add(0.5, Color.RED);
assertEquals(r1, r2);
}
/**
* Verify that this class implements {@link PublicCloneable}.
*/
@Test
public void testPublicCloneable() {
XYBlockRenderer r1 = new XYBlockRenderer();
assertTrue(r1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
XYBlockRenderer r1 = new XYBlockRenderer();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
XYBlockRenderer r2 = (XYBlockRenderer) in.readObject();
in.close();
assertEquals(r1, r2);
}
/**
* A simple test for bug 1766646.
*/
@Test
public void testBug1766646A() {
XYBlockRenderer r = new XYBlockRenderer();
Range range = r.findDomainBounds(null);
assertNull(range);
DefaultXYZDataset emptyDataset = new DefaultXYZDataset();
range = r.findDomainBounds(emptyDataset);
assertNull(range);
}
/**
* A simple test for bug 1766646.
*/
@Test
public void testBug1766646B() {
XYBlockRenderer r = new XYBlockRenderer();
Range range = r.findRangeBounds(null);
assertNull(range);
DefaultXYZDataset emptyDataset = new DefaultXYZDataset();
range = r.findRangeBounds(emptyDataset);
assertNull(range);
}
/**
* Some tests for the findRangeBounds() method.
*/
@Test
public void testFindRangeBounds() {
XYBlockRenderer renderer = new XYBlockRenderer();
assertNull(renderer.findRangeBounds(null));
XYSeriesCollection dataset = new XYSeriesCollection();
XYSeries series = new XYSeries("S1");
series.add(1.0, null);
dataset.addSeries(series);
Range r = renderer.findRangeBounds(dataset);
assertNull(r);
}
/**
* Some tests for the findDomainBounds() method.
*/
@Test
public void testFindDomainBounds() {
XYBlockRenderer renderer = new XYBlockRenderer();
assertNull(renderer.findRangeBounds(null));
XYSeriesCollection dataset = new XYSeriesCollection();
XYSeries series = new XYSeries("S1");
series.add(1.0, null);
dataset.addSeries(series);
Range r = renderer.findDomainBounds(dataset);
assertEquals(0.5, r.getLowerBound(), EPSILON);
assertEquals(1.5, r.getUpperBound(), EPSILON);
dataset.removeAllSeries();
r = renderer.findDomainBounds(dataset);
assertNull(r);
}
}
| 7,474 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
StackedXYAreaRendererTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/xy/StackedXYAreaRendererTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* -------------------------------
* StackedXYAreaRendererTests.java
* -------------------------------
* (C) Copyright 2003-2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 25-Mar-2003 : Version 1 (DG);
* 06-Jan-2005 : Renamed StackedAreaXYRendererTests -->
* StackedXYAreaRendererTests, improved testEquals() method,
* added check for auto range calculation (DG);
* 10-Nov-2006 : Added testBug1593156() (DG);
* 22-Apr-2008 : Added testPublicCloneable (DG);
*
*/
package org.jfree.chart.renderer.xy;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.data.Range;
import org.jfree.data.xy.DefaultTableXYDataset;
import org.jfree.data.xy.TableXYDataset;
import org.jfree.data.xy.XYSeries;
import org.junit.Test;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Stroke;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link StackedXYAreaRenderer} class.
*/
public class StackedXYAreaRendererTest {
/**
* Test that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
StackedXYAreaRenderer r1 = new StackedXYAreaRenderer();
StackedXYAreaRenderer r2 = new StackedXYAreaRenderer();
assertEquals(r1, r2);
assertEquals(r2, r1);
r1.setShapePaint(new GradientPaint(1.0f, 2.0f, Color.yellow,
3.0f, 4.0f, Color.green));
assertFalse(r1.equals(r2));
r2.setShapePaint(new GradientPaint(1.0f, 2.0f, Color.yellow,
3.0f, 4.0f, Color.green));
assertEquals(r1, r2);
Stroke s = new BasicStroke(1.23f);
r1.setShapeStroke(s);
assertFalse(r1.equals(r2));
r2.setShapeStroke(s);
assertEquals(r1, r2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
StackedXYAreaRenderer r1 = new StackedXYAreaRenderer();
StackedXYAreaRenderer r2 = new StackedXYAreaRenderer();
assertEquals(r1, r2);
int h1 = r1.hashCode();
int h2 = r2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
StackedXYAreaRenderer r1 = new StackedXYAreaRenderer();
StackedXYAreaRenderer r2 = (StackedXYAreaRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
}
/**
* Verify that this class implements {@link PublicCloneable}.
*/
@Test
public void testPublicCloneable() {
StackedXYAreaRenderer r1 = new StackedXYAreaRenderer();
assertTrue(r1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
StackedXYAreaRenderer r1 = new StackedXYAreaRenderer();
r1.setShapePaint(Color.RED);
r1.setShapeStroke(new BasicStroke(1.23f));
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
StackedXYAreaRenderer r2 = (StackedXYAreaRenderer) in.readObject();
in.close();
assertEquals(r1, r2);
}
/**
* Check that the renderer is calculating the range bounds correctly.
*/
@Test
public void testFindRangeBounds() {
TableXYDataset dataset
= RendererXYPackageTests.createTestTableXYDataset();
JFreeChart chart = ChartFactory.createStackedXYAreaChart(
"Test Chart", "X", "Y", dataset);
XYPlot plot = (XYPlot) chart.getPlot();
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
Range bounds = rangeAxis.getRange();
assertTrue(bounds.contains(6.0));
assertTrue(bounds.contains(8.0));
}
/**
* Draws the chart with a <code>null</code> info object to make sure that
* no exceptions are thrown (particularly by code in the renderer).
*/
@Test
public void testDrawWithNullInfo() {
DefaultTableXYDataset dataset = new DefaultTableXYDataset();
XYSeries s1 = new XYSeries("Series 1", true, false);
s1.add(5.0, 5.0);
s1.add(10.0, 15.5);
s1.add(15.0, 9.5);
s1.add(20.0, 7.5);
dataset.addSeries(s1);
XYSeries s2 = new XYSeries("Series 2", true, false);
s2.add(5.0, 5.0);
s2.add(10.0, 15.5);
s2.add(15.0, 9.5);
s2.add(20.0, 3.5);
dataset.addSeries(s2);
XYPlot plot = new XYPlot(dataset,
new NumberAxis("X"), new NumberAxis("Y"),
new StackedXYAreaRenderer());
JFreeChart chart = new JFreeChart(plot);
/* BufferedImage image = */ chart.createBufferedImage(300, 200,
null);
}
/**
* A test for bug 1593156.
*/
@Test
public void testBug1593156() {
DefaultTableXYDataset dataset = new DefaultTableXYDataset();
XYSeries s1 = new XYSeries("Series 1", true, false);
s1.add(5.0, 5.0);
s1.add(10.0, 15.5);
s1.add(15.0, 9.5);
s1.add(20.0, 7.5);
dataset.addSeries(s1);
XYSeries s2 = new XYSeries("Series 2", true, false);
s2.add(5.0, 5.0);
s2.add(10.0, 15.5);
s2.add(15.0, 9.5);
s2.add(20.0, 3.5);
dataset.addSeries(s2);
StackedXYAreaRenderer renderer = new StackedXYAreaRenderer(
XYAreaRenderer.LINES);
XYPlot plot = new XYPlot(dataset,
new NumberAxis("X"), new NumberAxis("Y"),
renderer);
JFreeChart chart = new JFreeChart(plot);
/* BufferedImage image = */ chart.createBufferedImage(300, 200,
null);
}
}
| 8,211 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
XYBoxAndWhiskerRendererTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/xy/XYBoxAndWhiskerRendererTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ---------------------------------
* XYBoxAndWhiskerRendererTests.java
* ---------------------------------
* (C) Copyright 2003-2009, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 22-Oct-2003 : Version 1 (DG);
* 23-Apr-2004 : Extended testEquals() method (DG);
* 27-Mar-2008 : Extended testEquals() some more (DG);
* 22-Apr-2008 : Added testPublicCloneable (DG);
* 08-Dec-2008 : Added test2909215() (DG);
*
*/
package org.jfree.chart.renderer.xy;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.data.statistics.BoxAndWhiskerItem;
import org.jfree.data.statistics.DefaultBoxAndWhiskerXYDataset;
import org.junit.Test;
import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Graphics2D;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.util.Date;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link XYBoxAndWhiskerRenderer} class.
*/
public class XYBoxAndWhiskerRendererTest {
/**
* Check that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
XYBoxAndWhiskerRenderer r1 = new XYBoxAndWhiskerRenderer();
XYBoxAndWhiskerRenderer r2 = new XYBoxAndWhiskerRenderer();
assertEquals(r1, r2);
r1.setArtifactPaint(new GradientPaint(1.0f, 2.0f, Color.green,
3.0f, 4.0f, Color.RED));
assertFalse(r1.equals(r2));
r2.setArtifactPaint(new GradientPaint(1.0f, 2.0f, Color.green,
3.0f, 4.0f, Color.RED));
assertEquals(r1, r2);
r1.setBoxWidth(0.55);
assertFalse(r1.equals(r2));
r2.setBoxWidth(0.55);
assertEquals(r1, r2);
r1.setFillBox(!r1.getFillBox());
assertFalse(r1.equals(r2));
r2.setFillBox(!r2.getFillBox());
assertEquals(r1, r2);
r1.setBoxPaint(Color.yellow);
assertFalse(r1.equals(r2));
r2.setBoxPaint(Color.yellow);
assertEquals(r1, r2);
// check boxPaint null also
r1.setBoxPaint(null);
assertFalse(r1.equals(r2));
r2.setBoxPaint(null);
assertEquals(r1, r2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
XYBoxAndWhiskerRenderer r1 = new XYBoxAndWhiskerRenderer();
XYBoxAndWhiskerRenderer r2 = new XYBoxAndWhiskerRenderer();
assertEquals(r1, r2);
int h1 = r1.hashCode();
int h2 = r2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
XYBoxAndWhiskerRenderer r1 = new XYBoxAndWhiskerRenderer();
XYBoxAndWhiskerRenderer r2 = (XYBoxAndWhiskerRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
}
/**
* Verify that this class implements {@link PublicCloneable}.
*/
@Test
public void testPublicCloneable() {
XYBoxAndWhiskerRenderer r1 = new XYBoxAndWhiskerRenderer();
assertTrue(r1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
XYBoxAndWhiskerRenderer r1 = new XYBoxAndWhiskerRenderer();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(
buffer.toByteArray()));
XYBoxAndWhiskerRenderer r2 = (XYBoxAndWhiskerRenderer) in.readObject();
in.close();
assertEquals(r1, r2);
}
/**
* A test for bug report 2909215.
*/
@Test
public void test2909215() {
DefaultBoxAndWhiskerXYDataset d1 = new DefaultBoxAndWhiskerXYDataset(
"Series");
d1.add(new Date(1L), new BoxAndWhiskerItem(1.0,
2.0, 3.0, 4.0,
5.0, 6.0, null, null, null));
JFreeChart chart = ChartFactory.createBoxAndWhiskerChart("Title", "X",
"Y", d1);
BufferedImage image = new BufferedImage(400, 200,
BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = image.createGraphics();
chart.draw(g2, new Rectangle2D.Double(0, 0, 400, 200), null, null);
g2.dispose();
//FIXME we should assert a value here
}
}
| 6,453 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
XYBubbleRendererTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/xy/XYBubbleRendererTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* --------------------------
* XYBubbleRendererTests.java
* --------------------------
* (C) Copyright 2003-2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 25-Mar-2003 : Version 1 (DG);
* 24-Jan-2007 : Added more checks to testEquals() (DG);
* 17-May-2007 : Added testGetLegendItemSeriesIndex() (DG);
* 22-Apr-2008 : Added testPublicCloneable (DG);
*
*/
package org.jfree.chart.renderer.xy;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.LegendItem;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.data.xy.DefaultXYZDataset;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link XYBubbleRenderer} class.
*/
public class XYBubbleRendererTest {
/**
* Check that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
XYBubbleRenderer r1 = new XYBubbleRenderer();
XYBubbleRenderer r2 = new XYBubbleRenderer();
assertEquals(r1, r2);
r1 = new XYBubbleRenderer(XYBubbleRenderer.SCALE_ON_RANGE_AXIS);
assertFalse(r1.equals(r2));
r2 = new XYBubbleRenderer(XYBubbleRenderer.SCALE_ON_RANGE_AXIS);
assertEquals(r1, r2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
XYBubbleRenderer r1 = new XYBubbleRenderer();
XYBubbleRenderer r2 = new XYBubbleRenderer();
assertEquals(r1, r2);
int h1 = r1.hashCode();
int h2 = r2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
XYBubbleRenderer r1 = new XYBubbleRenderer();
XYBubbleRenderer r2 = (XYBubbleRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
}
/**
* Verify that this class implements {@link PublicCloneable}.
*/
@Test
public void testPublicCloneable() {
XYBubbleRenderer r1 = new XYBubbleRenderer();
assertTrue(r1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
XYBubbleRenderer r1 = new XYBubbleRenderer();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
XYBubbleRenderer r2 = (XYBubbleRenderer) in.readObject();
in.close();
assertEquals(r1, r2);
}
/**
* A check for the datasetIndex and seriesIndex fields in the LegendItem
* returned by the getLegendItem() method.
*/
@Test
public void testGetLegendItemSeriesIndex() {
DefaultXYZDataset d1 = new DefaultXYZDataset();
double[] x = {2.1, 2.3, 2.3, 2.2, 2.2, 1.8, 1.8, 1.9, 2.3, 3.8};
double[] y = {14.1, 11.1, 10.0, 8.8, 8.7, 8.4, 5.4, 4.1, 4.1, 25};
double[] z = {2.4, 2.7, 2.7, 2.2, 2.2, 2.2, 2.1, 2.2, 1.6, 4};
double[][] s1 = new double[][] {x, y, z};
d1.addSeries("S1", s1);
x = new double[] {2.1};
y = new double[] {14.1};
z = new double[] {2.4};
double[][] s2 = new double[][] {x, y, z};
d1.addSeries("S2", s2);
DefaultXYZDataset d2 = new DefaultXYZDataset();
x = new double[] {2.1};
y = new double[] {14.1};
z = new double[] {2.4};
double[][] s3 = new double[][] {x, y, z};
d2.addSeries("S3", s3);
x = new double[] {2.1};
y = new double[] {14.1};
z = new double[] {2.4};
double[][] s4 = new double[][] {x, y, z};
d2.addSeries("S4", s4);
x = new double[] {2.1};
y = new double[] {14.1};
z = new double[] {2.4};
double[][] s5 = new double[][] {x, y, z};
d2.addSeries("S5", s5);
XYBubbleRenderer r = new XYBubbleRenderer();
XYPlot plot = new XYPlot(d1, new NumberAxis("x"),
new NumberAxis("y"), r);
plot.setDataset(1, d2);
/*JFreeChart chart =*/ new JFreeChart(plot);
LegendItem li = r.getLegendItem(1, 2);
assertEquals("S5", li.getLabel());
assertEquals(1, li.getDatasetIndex());
assertEquals(2, li.getSeriesIndex());
}
}
| 6,447 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
WaterfallBarRendererTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/category/WaterfallBarRendererTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ------------------------------
* WaterfallBarRendererTests.java
* ------------------------------
* (C) Copyright 2003-2009, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 21-Oct-2003 : Version 1 (DG);
* 23-Apr-2008 : Added testPublicCloneable() (DG);
* 04-Feb-2009 : Added testFindRangeBounds() (DG);
*
*/
package org.jfree.chart.renderer.category;
import org.jfree.chart.util.PublicCloneable;
import org.junit.Test;
import java.awt.Color;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link WaterfallBarRenderer} class.
*/
public class WaterfallBarRendererTest {
/**
* Some tests for the findRangeBounds() method.
*/
@Test
public void testFindRangeBounds() {
WaterfallBarRenderer r = new WaterfallBarRenderer();
assertNull(r.findRangeBounds(null));
}
/**
* Check that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
WaterfallBarRenderer r1 = new WaterfallBarRenderer();
WaterfallBarRenderer r2 = new WaterfallBarRenderer();
assertEquals(r1, r2);
// firstBarPaint;
r1.setFirstBarPaint(Color.cyan);
assertFalse(r1.equals(r2));
r2.setFirstBarPaint(Color.cyan);
assertEquals(r1, r2);
// lastBarPaint;
r1.setLastBarPaint(Color.cyan);
assertFalse(r1.equals(r2));
r2.setLastBarPaint(Color.cyan);
assertEquals(r1, r2);
// positiveBarPaint;
r1.setPositiveBarPaint(Color.cyan);
assertFalse(r1.equals(r2));
r2.setPositiveBarPaint(Color.cyan);
assertEquals(r1, r2);
//private Paint negativeBarPaint;
r1.setNegativeBarPaint(Color.cyan);
assertFalse(r1.equals(r2));
r2.setNegativeBarPaint(Color.cyan);
assertEquals(r1, r2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
WaterfallBarRenderer r1 = new WaterfallBarRenderer();
WaterfallBarRenderer r2 = new WaterfallBarRenderer();
assertEquals(r1, r2);
int h1 = r1.hashCode();
int h2 = r2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
WaterfallBarRenderer r1 = new WaterfallBarRenderer();
WaterfallBarRenderer r2 = (WaterfallBarRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
// quick check for independence
r1.setFirstBarPaint(Color.yellow);
assertFalse(r1.equals(r2));
r2.setFirstBarPaint(Color.yellow);
assertEquals(r1, r2);
}
/**
* Check that this class implements PublicCloneable.
*/
@Test
public void testPublicCloneable() {
WaterfallBarRenderer r1 = new WaterfallBarRenderer();
assertTrue(r1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
WaterfallBarRenderer r1 = new WaterfallBarRenderer();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray())
);
WaterfallBarRenderer r2 = (WaterfallBarRenderer) in.readObject();
in.close();
assertEquals(r1, r2);
}
}
| 5,543 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
StatisticalLineAndShapeRendererTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/category/StatisticalLineAndShapeRendererTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* -----------------------------------------
* StatisticalLineAndShapeRendererTests.java
* -----------------------------------------
* (C) Copyright 2005-2009, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 15-Jun-2005 : Version 1 (DG);
* 25-Sep-2006 : Added test1562759() (DG);
* 23-Apr-2008 : Added testPublicCloneable() (DG);
* 16-May-2009 : Added testFindRangeBounds() (DG);
*
*/
package org.jfree.chart.renderer.category;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.data.Range;
import org.jfree.data.statistics.DefaultStatisticalCategoryDataset;
import org.junit.Test;
import java.awt.Color;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link StatisticalLineAndShapeRenderer} class.
*/
public class StatisticalLineAndShapeRendererTest {
/**
* Check that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
StatisticalLineAndShapeRenderer r1
= new StatisticalLineAndShapeRenderer();
StatisticalLineAndShapeRenderer r2
= new StatisticalLineAndShapeRenderer();
assertEquals(r1, r2);
assertEquals(r2, r1);
r1.setErrorIndicatorPaint(Color.RED);
assertFalse(r1.equals(r2));
r2.setErrorIndicatorPaint(Color.RED);
assertEquals(r2, r1);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
StatisticalLineAndShapeRenderer r1
= new StatisticalLineAndShapeRenderer();
StatisticalLineAndShapeRenderer r2
= new StatisticalLineAndShapeRenderer();
assertEquals(r1, r2);
int h1 = r1.hashCode();
int h2 = r2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
StatisticalLineAndShapeRenderer r1
= new StatisticalLineAndShapeRenderer();
StatisticalLineAndShapeRenderer r2 = (StatisticalLineAndShapeRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
}
/**
* Check that this class implements PublicCloneable.
*/
@Test
public void testPublicCloneable() {
StatisticalLineAndShapeRenderer r1
= new StatisticalLineAndShapeRenderer();
assertTrue(r1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
StatisticalLineAndShapeRenderer r1
= new StatisticalLineAndShapeRenderer();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
StatisticalLineAndShapeRenderer r2 = (StatisticalLineAndShapeRenderer) in.readObject();
in.close();
assertEquals(r1, r2);
}
/**
* Draws the chart with a <code>null</code> info object to make sure that
* no exceptions are thrown (particularly by code in the renderer).
*/
@Test
public void testDrawWithNullInfo() {
DefaultStatisticalCategoryDataset dataset
= new DefaultStatisticalCategoryDataset();
dataset.add(1.0, 2.0, "S1", "C1");
dataset.add(3.0, 4.0, "S1", "C2");
CategoryPlot plot = new CategoryPlot(dataset,
new CategoryAxis("Category"), new NumberAxis("Value"),
new StatisticalLineAndShapeRenderer());
JFreeChart chart = new JFreeChart(plot);
/* BufferedImage image = */ chart.createBufferedImage(300, 200,
null);
}
/**
* A simple test for bug report 1562759.
*/
@Test
public void test1562759() {
StatisticalLineAndShapeRenderer r
= new StatisticalLineAndShapeRenderer(true, false);
assertTrue(r.getBaseLinesVisible());
assertFalse(r.getBaseShapesVisible());
r = new StatisticalLineAndShapeRenderer(false, true);
assertFalse(r.getBaseLinesVisible());
assertTrue(r.getBaseShapesVisible());
}
/**
* Some checks for the findRangeBounds() method.
*/
@Test
public void testFindRangeBounds() {
StatisticalLineAndShapeRenderer r
= new StatisticalLineAndShapeRenderer();
assertNull(r.findRangeBounds(null));
// an empty dataset should return a null range
DefaultStatisticalCategoryDataset dataset
= new DefaultStatisticalCategoryDataset();
assertNull(r.findRangeBounds(dataset));
dataset.add(1.0, 0.5, "R1", "C1");
assertEquals(new Range(0.5, 1.5), r.findRangeBounds(dataset));
dataset.add(-2.0, 0.2, "R1", "C2");
assertEquals(new Range(-2.2, 1.5), r.findRangeBounds(dataset));
dataset.add(null, null, "R1", "C3");
assertEquals(new Range(-2.2, 1.5), r.findRangeBounds(dataset));
dataset.add(5.0, 1.0, "R2", "C3");
assertEquals(new Range(-2.2, 6.0), r.findRangeBounds(dataset));
// check that the series visible flag is observed
r.setSeriesVisible(1, Boolean.FALSE);
assertEquals(new Range(-2.2, 1.5), r.findRangeBounds(dataset));
}
}
| 7,582 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
StackedBarRendererTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/category/StackedBarRendererTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ----------------------------
* StackedBarRendererTests.java
* ----------------------------
* (C) Copyright 2003-2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 25-Mar-2003 : Version 1 (DG);
* 23-Apr-2008 : Added testPublicCloneable() (DG);
*
*/
package org.jfree.chart.renderer.category;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.data.Range;
import org.jfree.data.category.DefaultCategoryDataset;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link StackedBarRenderer} class.
*/
public class StackedBarRendererTest {
/**
* Check that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
StackedBarRenderer r1 = new StackedBarRenderer();
StackedBarRenderer r2 = new StackedBarRenderer();
assertEquals(r1, r2);
assertEquals(r2, r1);
r1.setRenderAsPercentages(true);
assertFalse(r1.equals(r2));
r2.setRenderAsPercentages(true);
assertEquals(r1, r2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashCode() {
StackedBarRenderer r1 = new StackedBarRenderer();
StackedBarRenderer r2 = new StackedBarRenderer();
assertEquals(r1, r2);
int h1 = r1.hashCode();
int h2 = r2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
StackedBarRenderer r1 = new StackedBarRenderer();
StackedBarRenderer r2 = (StackedBarRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
}
/**
* Check that this class implements PublicCloneable.
*/
@Test
public void testPublicCloneable() {
StackedBarRenderer r1 = new StackedBarRenderer();
assertTrue(r1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
StackedBarRenderer r1 = new StackedBarRenderer();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
StackedBarRenderer r2 = (StackedBarRenderer) in.readObject();
in.close();
assertEquals(r1, r2);
}
/**
* Some checks for the findRangeBounds() method.
*/
@Test
public void testFindRangeBounds() {
StackedBarRenderer r = new StackedBarRenderer();
assertNull(r.findRangeBounds(null));
// an empty dataset should return a null range
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
assertNull(r.findRangeBounds(dataset));
dataset.addValue(1.0, "R1", "C1");
assertEquals(new Range(0.0, 1.0), r.findRangeBounds(dataset));
dataset.addValue(-2.0, "R1", "C2");
assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset));
dataset.addValue(null, "R1", "C3");
assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset));
dataset.addValue(2.0, "R2", "C1");
assertEquals(new Range(-2.0, 3.0), r.findRangeBounds(dataset));
dataset.addValue(null, "R2", "C2");
assertEquals(new Range(-2.0, 3.0), r.findRangeBounds(dataset));
}
}
| 5,508 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
IntervalBarRendererTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/category/IntervalBarRendererTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* -----------------------------
* IntervalBarRendererTests.java
* -----------------------------
* (C) Copyright 2003-2009, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 25-Mar-2003 : Version 1 (DG);
* 23-Apr-2008 : Added testPublicCloneable (DG);
* 16-May-2009 : Added testFindRangeBounds() (DG);
*
*/
package org.jfree.chart.renderer.category;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.data.Range;
import org.jfree.data.category.DefaultIntervalCategoryDataset;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link IntervalBarRenderer} class.
*/
public class IntervalBarRendererTest {
/**
* Problem that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
IntervalBarRenderer r1 = new IntervalBarRenderer();
IntervalBarRenderer r2 = new IntervalBarRenderer();
assertEquals(r1, r2);
// the renderer should not be equal to a BarRenderer
BarRenderer br = new BarRenderer();
assertFalse(r1.equals(br));
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
IntervalBarRenderer r1 = new IntervalBarRenderer();
IntervalBarRenderer r2 = new IntervalBarRenderer();
assertEquals(r1, r2);
int h1 = r1.hashCode();
int h2 = r2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
IntervalBarRenderer r1 = new IntervalBarRenderer();
IntervalBarRenderer r2 = (IntervalBarRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
}
/**
* Check that this class implements PublicCloneable.
*/
@Test
public void testPublicCloneable() {
IntervalBarRenderer r1 = new IntervalBarRenderer();
assertTrue(r1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
IntervalBarRenderer r1 = new IntervalBarRenderer();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(
buffer.toByteArray()));
IntervalBarRenderer r2 = (IntervalBarRenderer) in.readObject();
in.close();
assertEquals(r1, r2);
}
/**
* Draws the chart with a <code>null</code> info object to make sure that
* no exceptions are thrown (particularly by code in the renderer).
*/
@Test
public void testDrawWithNullInfo() {
double[][] starts = new double[][] {{0.1, 0.2, 0.3},
{0.3, 0.4, 0.5}};
double[][] ends = new double[][] {{0.5, 0.6, 0.7}, {0.7, 0.8, 0.9}};
DefaultIntervalCategoryDataset dataset
= new DefaultIntervalCategoryDataset(starts, ends);
IntervalBarRenderer renderer = new IntervalBarRenderer();
CategoryPlot plot = new CategoryPlot(dataset,
new CategoryAxis("Category"), new NumberAxis("Value"),
renderer);
JFreeChart chart = new JFreeChart(plot);
/* BufferedImage image = */ chart.createBufferedImage(300, 200,
null);
}
/**
* Some checks for the findRangeBounds() method.
*/
@Test
public void testFindRangeBounds() {
IntervalBarRenderer r = new IntervalBarRenderer();
assertNull(r.findRangeBounds(null));
// an empty dataset should return a null range
DefaultIntervalCategoryDataset dataset
= new DefaultIntervalCategoryDataset(new double[0][0],
new double[0][0]);
assertNull(r.findRangeBounds(dataset));
double[][] starts = new double[][] {{0.1, 0.2, 0.3}, {0.3, 0.4, 0.5}};
double[][] ends = new double[][] {{0.5, 0.6, 0.7}, {0.7, 0.8, 0.9}};
dataset = new DefaultIntervalCategoryDataset(starts, ends);
assertEquals(new Range(0.0, 0.9), r.findRangeBounds(dataset));
r.setIncludeBaseInRange(false);
assertEquals(new Range(0.1, 0.9), r.findRangeBounds(dataset));
r.setIncludeBaseInRange(true);
r.setSeriesVisible(1, Boolean.FALSE);
assertEquals(new Range(0.0, 0.7), r.findRangeBounds(dataset));
}
}
| 6,697 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
StackedBarRenderer3DTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/category/StackedBarRenderer3DTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ------------------------------
* StackedBarRenderer3DTests.java
* ------------------------------
* (C) Copyright 2003-2009, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 25-Mar-2003 : Version 1 (DG);
* 18-Jan-2007 : Added many new tests (DG);
* 23-Apr-2008 : Added testPublicCloneable() (DG);
* 03-Feb-2009 : Added testFindRangeBounds() (DG);
*
*/
package org.jfree.chart.renderer.category;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.data.Range;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.category.DefaultCategoryDataset;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link StackedBarRenderer3D} class.
*/
public class StackedBarRenderer3DTest {
/**
* Provide access to protected method.
*/
static class MyRenderer extends StackedBarRenderer3D {
@Override
public List createStackedValueList(CategoryDataset dataset,
Comparable category, int[] includedRows, double base,
boolean asPercentages) {
return super.createStackedValueList(dataset, category,
includedRows, base, asPercentages);
}
}
/**
* Some checks for the findRangeBounds() method.
*/
@Test
public void testFindRangeBounds() {
StackedBarRenderer3D r = new StackedBarRenderer3D();
assertNull(r.findRangeBounds(null));
// an empty dataset should return a null range
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
assertNull(r.findRangeBounds(dataset));
dataset.addValue(1.0, "R1", "C1");
assertEquals(new Range(0.0, 1.0), r.findRangeBounds(dataset));
dataset.addValue(-2.0, "R1", "C2");
assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset));
dataset.addValue(null, "R1", "C3");
assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset));
dataset.addValue(2.0, "R2", "C1");
assertEquals(new Range(-2.0, 3.0), r.findRangeBounds(dataset));
dataset.addValue(null, "R2", "C2");
assertEquals(new Range(-2.0, 3.0), r.findRangeBounds(dataset));
}
/**
* Check that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
StackedBarRenderer3D r1 = new StackedBarRenderer3D();
StackedBarRenderer3D r2 = new StackedBarRenderer3D();
assertEquals(r1, r2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
StackedBarRenderer3D r1 = new StackedBarRenderer3D();
StackedBarRenderer3D r2 = new StackedBarRenderer3D();
assertEquals(r1, r2);
int h1 = r1.hashCode();
int h2 = r2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
StackedBarRenderer3D r1 = new StackedBarRenderer3D();
StackedBarRenderer3D r2 = (StackedBarRenderer3D) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
}
/**
* Check that this class implements PublicCloneable.
*/
@Test
public void testPublicCloneable() {
StackedBarRenderer3D r1 = new StackedBarRenderer3D();
assertTrue(r1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
StackedBarRenderer3D r1 = new StackedBarRenderer3D();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
StackedBarRenderer3D r2 = (StackedBarRenderer3D) in.readObject();
in.close();
assertEquals(r1, r2);
}
/**
* A test for the createStackedValueList() method.
*/
@Test
public void testCreateStackedValueList1() {
DefaultCategoryDataset d = new DefaultCategoryDataset();
d.addValue(1.0, "s0", "c0");
MyRenderer r = new MyRenderer();
List l = r.createStackedValueList(d, "c0", new int[] { 0 }, 0.0, false);
assertEquals(2, l.size());
assertEquals(0.0, ((Object[]) l.get(0))[1]);
assertEquals(1.0, ((Object[]) l.get(1))[1]);
}
/**
* A test for the createStackedValueList() method.
*/
@Test
public void testCreateStackedValueList2() {
DefaultCategoryDataset d = new DefaultCategoryDataset();
d.addValue(-1.0, "s0", "c0");
MyRenderer r = new MyRenderer();
List l = r.createStackedValueList(d, "c0", new int[] { 0 }, 0.0, false);
assertEquals(2, l.size());
assertEquals(-1.0, ((Object[]) l.get(0))[1]);
assertEquals(0.0, ((Object[]) l.get(1))[1]);
}
/**
* A test for the createStackedValueList() method.
*/
@Test
public void testCreateStackedValueList3() {
DefaultCategoryDataset d = new DefaultCategoryDataset();
d.addValue(0.0, "s0", "c0");
MyRenderer r = new MyRenderer();
List l = r.createStackedValueList(d, "c0", new int[] { 0 }, 0.0, false);
assertEquals(2, l.size());
assertEquals(0.0, ((Object[]) l.get(0))[1]);
assertEquals(0.0, ((Object[]) l.get(1))[1]);
}
/**
* A test for the createStackedValueList() method.
*/
@Test
public void testCreateStackedValueList4() {
DefaultCategoryDataset d = new DefaultCategoryDataset();
d.addValue(null, "s0", "c0");
MyRenderer r = new MyRenderer();
List l = r.createStackedValueList(d, "c0", new int[] { 0 }, 0.0, false);
assertEquals(0, l.size());
}
/**
* A test for the createStackedValueList() method.
*/
@Test
public void testCreateStackedValueList1a() {
DefaultCategoryDataset d = new DefaultCategoryDataset();
d.addValue(1.0, "s0", "c0");
d.addValue(1.1, "s1", "c0");
MyRenderer r = new MyRenderer();
List l = r.createStackedValueList(d, "c0", new int[] { 0, 1 }, 0.0,
false);
assertEquals(3, l.size());
assertEquals(0.0, ((Object[]) l.get(0))[1]);
assertEquals(1.0, ((Object[]) l.get(1))[1]);
assertEquals(2.1, ((Object[]) l.get(2))[1]);
}
/**
* A test for the createStackedValueList() method.
*/
@Test
public void testCreateStackedValueList1b() {
DefaultCategoryDataset d = new DefaultCategoryDataset();
d.addValue(1.0, "s0", "c0");
d.addValue(-1.1, "s1", "c0");
MyRenderer r = new MyRenderer();
List l = r.createStackedValueList(d, "c0", new int[] { 0, 1 }, 0.0,
false);
assertEquals(3, l.size());
assertEquals(-1.1, ((Object[]) l.get(0))[1]);
assertEquals(0.0, ((Object[]) l.get(1))[1]);
assertEquals(1.0, ((Object[]) l.get(2))[1]);
}
/**
* A test for the createStackedValueList() method.
*/
@Test
public void testCreateStackedValueList1c() {
DefaultCategoryDataset d = new DefaultCategoryDataset();
d.addValue(1.0, "s0", "c0");
d.addValue(0.0, "s1", "c0");
MyRenderer r = new MyRenderer();
List l = r.createStackedValueList(d, "c0", new int[] { 0, 1 }, 0.0,
false);
assertEquals(3, l.size());
assertEquals(0.0, ((Object[]) l.get(0))[1]);
assertEquals(1.0, ((Object[]) l.get(1))[1]);
assertEquals(1.0, ((Object[]) l.get(2))[1]);
}
/**
* A test for the createStackedValueList() method.
*/
@Test
public void testCreateStackedValueList1d() {
DefaultCategoryDataset d = new DefaultCategoryDataset();
d.addValue(1.0, "s0", "c0");
d.addValue(null, "s1", "c0");
MyRenderer r = new MyRenderer();
List l = r.createStackedValueList(d, "c0", new int[] { 0, 1 }, 0.0,
false);
assertEquals(2, l.size());
assertEquals(0.0, ((Object[]) l.get(0))[1]);
assertEquals(1.0, ((Object[]) l.get(1))[1]);
}
/**
* A test for the createStackedValueList() method.
*/
@Test
public void testCreateStackedValueList2a() {
DefaultCategoryDataset d = new DefaultCategoryDataset();
d.addValue(-1.0, "s0", "c0");
d.addValue(1.1, "s1", "c0");
MyRenderer r = new MyRenderer();
List l = r.createStackedValueList(d, "c0", new int[] { 0, 1 }, 0.0,
false);
assertEquals(3, l.size());
assertEquals(-1.0, ((Object[]) l.get(0))[1]);
assertEquals(0.0, ((Object[]) l.get(1))[1]);
assertEquals(1.1, ((Object[]) l.get(2))[1]);
}
/**
* A test for the createStackedValueList() method.
*/
@Test
public void testCreateStackedValueList2b() {
DefaultCategoryDataset d = new DefaultCategoryDataset();
d.addValue(-1.0, "s0", "c0");
d.addValue(-1.1, "s1", "c0");
MyRenderer r = new MyRenderer();
List l = r.createStackedValueList(d, "c0", new int[] { 0, 1 }, 0.0,
false);
assertEquals(3, l.size());
assertEquals(-2.1, ((Object[]) l.get(0))[1]);
assertEquals(-1.0, ((Object[]) l.get(1))[1]);
assertEquals(0.0, ((Object[]) l.get(2))[1]);
}
/**
* A test for the createStackedValueList() method.
*/
@Test
public void testCreateStackedValueList2c() {
DefaultCategoryDataset d = new DefaultCategoryDataset();
d.addValue(-1.0, "s0", "c0");
d.addValue(0.0, "s1", "c0");
MyRenderer r = new MyRenderer();
List l = r.createStackedValueList(d, "c0", new int[] { 0, 1 }, 0.0,
false);
assertEquals(3, l.size());
assertEquals(-1.0, ((Object[]) l.get(0))[1]);
assertEquals(0.0, ((Object[]) l.get(1))[1]);
assertEquals(0.0, ((Object[]) l.get(2))[1]);
}
/**
* A test for the createStackedValueList() method.
*/
@Test
public void testCreateStackedValueList2d() {
DefaultCategoryDataset d = new DefaultCategoryDataset();
d.addValue(-1.0, "s0", "c0");
d.addValue(null, "s1", "c0");
MyRenderer r = new MyRenderer();
List l = r.createStackedValueList(d, "c0", new int[] { 0, 1 }, 0.0,
false);
assertEquals(2, l.size());
assertEquals(-1.0, ((Object[]) l.get(0))[1]);
assertEquals(0.0, ((Object[]) l.get(1))[1]);
}
/**
* A test for the createStackedValueList() method.
*/
@Test
public void testCreateStackedValueList3a() {
DefaultCategoryDataset d = new DefaultCategoryDataset();
d.addValue(0.0, "s0", "c0");
d.addValue(1.1, "s1", "c0");
MyRenderer r = new MyRenderer();
List l = r.createStackedValueList(d, "c0", new int[] { 0, 1 }, 0.0,
false);
assertEquals(3, l.size());
assertEquals(0.0, ((Object[]) l.get(0))[1]);
assertEquals(0.0, ((Object[]) l.get(1))[1]);
assertEquals(1.1, ((Object[]) l.get(2))[1]);
}
/**
* A test for the createStackedValueList() method.
*/
@Test
public void testCreateStackedValueList3b() {
DefaultCategoryDataset d = new DefaultCategoryDataset();
d.addValue(0.0, "s0", "c0");
d.addValue(-1.1, "s1", "c0");
MyRenderer r = new MyRenderer();
List l = r.createStackedValueList(d, "c0", new int[] { 0, 1 }, 0.0,
false);
assertEquals(3, l.size());
assertEquals(-1.1, ((Object[]) l.get(0))[1]);
assertEquals(0.0, ((Object[]) l.get(1))[1]);
assertEquals(0.0, ((Object[]) l.get(2))[1]);
}
/**
* A test for the createStackedValueList() method.
*/
@Test
public void testCreateStackedValueList3c() {
DefaultCategoryDataset d = new DefaultCategoryDataset();
d.addValue(0.0, "s0", "c0");
d.addValue(0.0, "s1", "c0");
MyRenderer r = new MyRenderer();
List l = r.createStackedValueList(d, "c0", new int[] { 0, 1 }, 0.0,
false);
assertEquals(3, l.size());
assertEquals(0.0, ((Object[]) l.get(0))[1]);
assertEquals(0.0, ((Object[]) l.get(1))[1]);
assertEquals(0.0, ((Object[]) l.get(2))[1]);
}
/**
* A test for the createStackedValueList() method.
*/
@Test
public void testCreateStackedValueList3d() {
DefaultCategoryDataset d = new DefaultCategoryDataset();
d.addValue(0.0, "s0", "c0");
d.addValue(null, "s1", "c0");
MyRenderer r = new MyRenderer();
List l = r.createStackedValueList(d, "c0", new int[] { 0, 1 }, 0.0,
false);
assertEquals(2, l.size());
assertEquals(0.0, ((Object[]) l.get(0))[1]);
assertEquals(0.0, ((Object[]) l.get(1))[1]);
}
/**
* A test for the createStackedValueList() method.
*/
@Test
public void testCreateStackedValueList5() {
DefaultCategoryDataset d = new DefaultCategoryDataset();
d.addValue(1.0, "s0", "c0");
d.addValue(null, "s1", "c0");
d.addValue(2.0, "s2", "c0");
MyRenderer r = new MyRenderer();
List l = r.createStackedValueList(d, "c0", new int[] { 0, 1, 2 }, 0.0,
false);
assertEquals(3, l.size());
assertEquals(0.0, ((Object[]) l.get(0))[1]);
assertEquals(1.0, ((Object[]) l.get(1))[1]);
assertEquals(3.0, ((Object[]) l.get(2))[1]);
}
}
| 15,669 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
GanttRendererTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/category/GanttRendererTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* -----------------------
* GanttRendererTests.java
* -----------------------
* (C) Copyright 2003-2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 22-Oct-2003 : Version 1 (DG);
* 20-Mar-2007 : Extended testEquals() (DG);
* 23-Apr-2008 : Added testPublicCloneable() (DG);
*
*/
package org.jfree.chart.renderer.category;
import org.jfree.chart.util.PublicCloneable;
import org.junit.Test;
import java.awt.Color;
import java.awt.GradientPaint;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link GanttRenderer} class.
*/
public class GanttRendererTest {
/**
* Check that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
GanttRenderer r1 = new GanttRenderer();
GanttRenderer r2 = new GanttRenderer();
assertEquals(r1, r2);
r1.setCompletePaint(Color.yellow);
assertFalse(r1.equals(r2));
r2.setCompletePaint(Color.yellow);
assertEquals(r1, r2);
r1.setIncompletePaint(Color.green);
assertFalse(r1.equals(r2));
r2.setIncompletePaint(Color.green);
assertEquals(r1, r2);
r1.setStartPercent(0.11);
assertFalse(r1.equals(r2));
r2.setStartPercent(0.11);
assertEquals(r1, r2);
r1.setEndPercent(0.88);
assertFalse(r1.equals(r2));
r2.setEndPercent(0.88);
assertEquals(r1, r2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
GanttRenderer r1 = new GanttRenderer();
GanttRenderer r2 = new GanttRenderer();
assertEquals(r1, r2);
int h1 = r1.hashCode();
int h2 = r2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
GanttRenderer r1 = new GanttRenderer();
GanttRenderer r2 = (GanttRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
}
/**
* Check that this class implements PublicCloneable.
*/
@Test
public void testPublicCloneable() {
GanttRenderer r1 = new GanttRenderer();
assertTrue(r1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
GanttRenderer r1 = new GanttRenderer();
r1.setCompletePaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f,
4.0f, Color.BLUE));
r1.setIncompletePaint(new GradientPaint(4.0f, 3.0f, Color.RED, 2.0f,
1.0f, Color.BLUE));
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
GanttRenderer r2 = (GanttRenderer) in.readObject();
in.close();
assertEquals(r1, r2);
}
}
| 4,999 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
CategoryStepRendererTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/category/CategoryStepRendererTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ------------------------------
* CategoryStepRendererTests.java
* ------------------------------
* (C) Copyright 2005-2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 08-Mar-2005 : Version 1 (DG);
* 22-Feb-2007 : Minor updates (DG);
* 17-May-2007 : Added testGetLegendItemSeriesIndex() (DG);
* 23-Apr-2008 : Added testPublicCloneable (DG);
*
*/
package org.jfree.chart.renderer.category;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.LegendItem;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.data.category.DefaultCategoryDataset;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link CategoryStepRenderer} class.
*/
public class CategoryStepRendererTest {
/**
* Check that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
CategoryStepRenderer r1 = new CategoryStepRenderer(false);
CategoryStepRenderer r2 = new CategoryStepRenderer(false);
assertEquals(r1, r2);
r1 = new CategoryStepRenderer(true);
assertFalse(r1.equals(r2));
r2 = new CategoryStepRenderer(true);
assertEquals(r1, r2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
CategoryStepRenderer r1 = new CategoryStepRenderer(false);
CategoryStepRenderer r2 = (CategoryStepRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
}
/**
* Check that this class implements PublicCloneable.
*/
@Test
public void testPublicCloneable() {
CategoryStepRenderer r1 = new CategoryStepRenderer(false);
assertTrue(r1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
CategoryStepRenderer r1 = new CategoryStepRenderer();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
CategoryStepRenderer r2 = (CategoryStepRenderer) in.readObject();
in.close();
assertEquals(r1, r2);
}
/**
* A check for the datasetIndex and seriesIndex fields in the LegendItem
* returned by the getLegendItem() method.
*/
@Test
public void testGetLegendItemSeriesIndex() {
DefaultCategoryDataset dataset0 = new DefaultCategoryDataset();
dataset0.addValue(21.0, "R1", "C1");
dataset0.addValue(22.0, "R2", "C1");
DefaultCategoryDataset dataset1 = new DefaultCategoryDataset();
dataset1.addValue(23.0, "R3", "C1");
dataset1.addValue(24.0, "R4", "C1");
dataset1.addValue(25.0, "R5", "C1");
CategoryStepRenderer r = new CategoryStepRenderer();
CategoryPlot plot = new CategoryPlot(dataset0, new CategoryAxis("x"),
new NumberAxis("y"), r);
plot.setDataset(1, dataset1);
/*JFreeChart chart =*/ new JFreeChart(plot);
LegendItem li = r.getLegendItem(1, 2);
assertEquals("R5", li.getLabel());
assertEquals(1, li.getDatasetIndex());
assertEquals(2, li.getSeriesIndex());
}
}
| 5,423 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
GroupedStackedBarRendererTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/category/GroupedStackedBarRendererTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* -----------------------------------
* GroupedStackedBarRendererTests.java
* -----------------------------------
* (C) Copyright 2004-2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 08-Jul-2004 : Version 1 (DG);
* 23-Apr-2008 : Added testPublicCloneable() (DG);
*
*/
package org.jfree.chart.renderer.category;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.data.KeyToGroupMap;
import org.jfree.data.Range;
import org.jfree.data.category.DefaultCategoryDataset;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link GroupedStackedBarRenderer} class.
*/
public class GroupedStackedBarRendererTest {
/**
* Test that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
GroupedStackedBarRenderer r1 = new GroupedStackedBarRenderer();
GroupedStackedBarRenderer r2 = new GroupedStackedBarRenderer();
assertEquals(r1, r2);
assertEquals(r2, r1);
// map
KeyToGroupMap m1 = new KeyToGroupMap("G1");
m1.mapKeyToGroup("S1", "G2");
r1.setSeriesToGroupMap(m1);
assertFalse(r1.equals(r2));
KeyToGroupMap m2 = new KeyToGroupMap("G1");
m2.mapKeyToGroup("S1", "G2");
r2.setSeriesToGroupMap(m2);
assertEquals(r1, r2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
GroupedStackedBarRenderer r1 = new GroupedStackedBarRenderer();
GroupedStackedBarRenderer r2 = (GroupedStackedBarRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
}
/**
* Check that this class implements PublicCloneable.
*/
@Test
public void testPublicCloneable() {
GroupedStackedBarRenderer r1 = new GroupedStackedBarRenderer();
assertTrue(r1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
GroupedStackedBarRenderer r1 = new GroupedStackedBarRenderer();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(
buffer.toByteArray()));
GroupedStackedBarRenderer r2 = (GroupedStackedBarRenderer) in.readObject();
in.close();
assertEquals(r1, r2);
}
/**
* Draws the chart with a <code>null</code> info object to make sure that
* no exceptions are thrown (particularly by code in the renderer).
*/
@Test
public void testDrawWithNullInfo() {
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.addValue(1.0, "S1", "C1");
dataset.addValue(2.0, "S1", "C2");
dataset.addValue(3.0, "S2", "C1");
dataset.addValue(4.0, "S2", "C2");
GroupedStackedBarRenderer renderer
= new GroupedStackedBarRenderer();
CategoryPlot plot = new CategoryPlot(dataset,
new CategoryAxis("Category"), new NumberAxis("Value"),
renderer);
JFreeChart chart = new JFreeChart(plot);
/* BufferedImage image = */ chart.createBufferedImage(300, 200,
null);
}
/**
* Some checks for the findRangeBounds() method.
*/
@Test
public void testFindRangeBounds() {
GroupedStackedBarRenderer r = new GroupedStackedBarRenderer();
assertNull(r.findRangeBounds(null));
// an empty dataset should return a null range
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
assertNull(r.findRangeBounds(dataset));
dataset.addValue(1.0, "R1", "C1");
assertEquals(new Range(0.0, 1.0), r.findRangeBounds(dataset));
dataset.addValue(-2.0, "R1", "C2");
assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset));
dataset.addValue(null, "R1", "C3");
assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset));
KeyToGroupMap m = new KeyToGroupMap("G1");
m.mapKeyToGroup("R1", "G1");
m.mapKeyToGroup("R2", "G1");
m.mapKeyToGroup("R3", "G2");
r.setSeriesToGroupMap(m);
dataset.addValue(0.5, "R3", "C1");
assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset));
dataset.addValue(5.0, "R3", "C2");
assertEquals(new Range(-2.0, 5.0), r.findRangeBounds(dataset));
}
}
| 6,759 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
LineRenderer3DTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/category/LineRenderer3DTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ------------------------
* LineRenderer3DTests.java
* ------------------------
* (C) Copyright 2004-2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 15-Oct-2004 : Version 1 (DG);
* 23-Apr-2008 : Added testPublicCloneable() (DG);
*
*/
package org.jfree.chart.renderer.category;
import org.jfree.chart.util.PublicCloneable;
import org.junit.Test;
import java.awt.Color;
import java.awt.GradientPaint;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link LineRenderer3D} class.
*/
public class LineRenderer3DTest {
/**
* Test that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
LineRenderer3D r1 = new LineRenderer3D();
LineRenderer3D r2 = new LineRenderer3D();
assertEquals(r1, r2);
r1.setXOffset(99.9);
assertFalse(r1.equals(r2));
r2.setXOffset(99.9);
assertEquals(r1, r2);
r1.setYOffset(111.1);
assertFalse(r1.equals(r2));
r2.setYOffset(111.1);
assertEquals(r1, r2);
r1.setWallPaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f,
Color.BLUE));
assertFalse(r1.equals(r2));
r2.setWallPaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f,
Color.BLUE));
assertEquals(r1, r2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
LineRenderer3D r1 = new LineRenderer3D();
LineRenderer3D r2 = new LineRenderer3D();
assertEquals(r1, r2);
int h1 = r1.hashCode();
int h2 = r2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
LineRenderer3D r1 = new LineRenderer3D();
LineRenderer3D r2 = (LineRenderer3D) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
assertTrue(checkIndependence(r1, r2));
}
/**
* Check that this class implements PublicCloneable.
*/
@Test
public void testPublicCloneable() {
LineRenderer3D r1 = new LineRenderer3D();
assertTrue(r1 instanceof PublicCloneable);
}
/**
* Checks that the two renderers are equal but independent of one another.
*
* @param r1 renderer 1.
* @param r2 renderer 2.
*
* @return A boolean.
*/
private boolean checkIndependence(LineRenderer3D r1, LineRenderer3D r2) {
// should be equal...
boolean b0 = r1.equals(r2);
// and independent...
r1.setBaseLinesVisible(!r1.getBaseLinesVisible());
if (r1.equals(r2)) {
return false;
}
r2.setBaseLinesVisible(r1.getBaseLinesVisible());
if (!r1.equals(r2)) {
return false;
}
r1.setSeriesLinesVisible(1, true);
if (r1.equals(r2)) {
return false;
}
r2.setSeriesLinesVisible(1, true);
if (!r1.equals(r2)) {
return false;
}
r1.setBaseShapesVisible(!r1.getBaseShapesVisible());
if (r1.equals(r2)) {
return false;
}
r2.setBaseShapesVisible(r1.getBaseShapesVisible());
if (!r1.equals(r2)) {
return false;
}
r1.setSeriesShapesVisible(1, true);
if (r1.equals(r2)) {
return false;
}
r2.setSeriesShapesVisible(1, true);
if (!r1.equals(r2)) {
return false;
}
r1.setSeriesShapesFilled(0, false);
r2.setSeriesShapesFilled(0, true);
boolean b7 = !r1.equals(r2);
r2.setSeriesShapesFilled(0, false);
boolean b8 = (r1.equals(r2));
r1.setBaseShapesFilled(false);
r2.setBaseShapesFilled(true);
boolean b9 = !r1.equals(r2);
r2.setBaseShapesFilled(false);
boolean b10 = (r1.equals(r2));
return b0 && b7 && b8 && b9 && b10;
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
LineRenderer3D r1 = new LineRenderer3D();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(
buffer.toByteArray()));
LineRenderer3D r2 = (LineRenderer3D) in.readObject();
in.close();
assertEquals(r1, r2);
}
}
| 6,521 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
GradientBarPainterTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/category/GradientBarPainterTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ----------------------------
* GradientBarPainterTests.java
* ----------------------------
* (C) Copyright 2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 20-Jun-2008 : Version 1 (DG);
*
*/
package org.jfree.chart.renderer.category;
import org.jfree.chart.util.PublicCloneable;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
/**
* Tests for the {@link GradientBarPainter} class.
*/
public class GradientBarPainterTest {
/**
* Check that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
GradientBarPainter p1 = new GradientBarPainter(0.1, 0.2, 0.3);
GradientBarPainter p2 = new GradientBarPainter(0.1, 0.2, 0.3);
assertEquals(p1, p2);
p1 = new GradientBarPainter(0.11, 0.2, 0.3);
assertFalse(p1.equals(p2));
p2 = new GradientBarPainter(0.11, 0.2, 0.3);
assertEquals(p1, p2);
p1 = new GradientBarPainter(0.11, 0.22, 0.3);
assertFalse(p1.equals(p2));
p2 = new GradientBarPainter(0.11, 0.22, 0.3);
assertEquals(p1, p2);
p1 = new GradientBarPainter(0.11, 0.22, 0.33);
assertFalse(p1.equals(p2));
p2 = new GradientBarPainter(0.11, 0.22, 0.33);
assertEquals(p1, p2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
GradientBarPainter p1 = new GradientBarPainter(0.1, 0.2, 0.3);
GradientBarPainter p2 = new GradientBarPainter(0.1, 0.2, 0.3);
assertEquals(p1, p2);
int h1 = p1.hashCode();
int h2 = p2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning isn't implemented (it isn't required, because
* instances of the class are immutable).
*/
@Test
public void testCloning() throws CloneNotSupportedException {
GradientBarPainter p1 = new GradientBarPainter(0.1, 0.2, 0.3);
assertFalse(p1 instanceof Cloneable);
assertFalse(p1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
GradientBarPainter p1 = new GradientBarPainter(0.1, 0.2, 0.3);
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(p1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
GradientBarPainter p2 = (GradientBarPainter) in.readObject();
in.close();
assertEquals(p1, p2);
}
}
| 4,397 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
AbstractCategoryItemRendererTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/category/AbstractCategoryItemRendererTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2014, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* --------------------------------------
* AbstractCategoryItemRendererTests.java
* --------------------------------------
* (C) Copyright 2004-2014, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 12-Feb-2004 : Version 1 (DG);
* 24-Nov-2006 : New cloning tests (DG);
* 07-Dec-2006 : Added testEquals() method (DG);
* 25-Nov-2008 : Added testFindRangeBounds() (DG);
* 09-Feb-2010 : Added test2947660() (DG);
* 10-Mar-2014 : Removed LegendItemCollection (DG);
*
*/
package org.jfree.chart.renderer.category;
import org.jfree.chart.labels.IntervalCategoryItemLabelGenerator;
import org.jfree.chart.labels.StandardCategoryItemLabelGenerator;
import org.jfree.chart.labels.StandardCategorySeriesLabelGenerator;
import org.jfree.chart.labels.StandardCategoryToolTipGenerator;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.urls.StandardCategoryURLGenerator;
import org.jfree.data.Range;
import org.jfree.data.category.DefaultCategoryDataset;
import org.junit.Test;
import java.text.NumberFormat;
import java.util.List;
import org.jfree.chart.LegendItem;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
/**
* Tests for the {@link AbstractCategoryItemRenderer} class.
*/
public class AbstractCategoryItemRendererTest {
/**
* Checks that all fields are distinguished.
*/
@Test
public void testEquals() {
BarRenderer r1 = new BarRenderer();
BarRenderer r2 = new BarRenderer();
assertEquals(r1, r2);
// the plot field is NOT tested
// toolTipGeneratorList
r1.setSeriesToolTipGenerator(1, new StandardCategoryToolTipGenerator());
assertFalse(r1.equals(r2));
r2.setSeriesToolTipGenerator(1, new StandardCategoryToolTipGenerator());
assertEquals(r1, r2);
// baseToolTipGenerator
r1.setDefaultToolTipGenerator(new StandardCategoryToolTipGenerator("{2}",
NumberFormat.getInstance()));
assertFalse(r1.equals(r2));
r2.setDefaultToolTipGenerator(new StandardCategoryToolTipGenerator("{2}",
NumberFormat.getInstance()));
assertEquals(r1, r2);
// itemLabelGeneratorList
r1.setSeriesItemLabelGenerator(1,
new StandardCategoryItemLabelGenerator());
assertFalse(r1.equals(r2));
r2.setSeriesItemLabelGenerator(1,
new StandardCategoryItemLabelGenerator());
assertEquals(r1, r2);
// baseItemLabelGenerator
r1.setDefaultItemLabelGenerator(new StandardCategoryItemLabelGenerator(
"{2}", NumberFormat.getInstance()));
assertFalse(r1.equals(r2));
r2.setDefaultItemLabelGenerator(new StandardCategoryItemLabelGenerator(
"{2}", NumberFormat.getInstance()));
assertEquals(r1, r2);
// urlGeneratorList
r1.setSeriesItemURLGenerator(1, new StandardCategoryURLGenerator());
assertFalse(r1.equals(r2));
r2.setSeriesItemURLGenerator(1, new StandardCategoryURLGenerator());
assertEquals(r1, r2);
// baseItemURLGenerator
r1.setDefaultItemURLGenerator(new StandardCategoryURLGenerator(
"abc.html"));
assertFalse(r1.equals(r2));
r2.setDefaultItemURLGenerator(new StandardCategoryURLGenerator(
"abc.html"));
assertEquals(r1, r2);
// legendItemLabelGenerator
r1.setLegendItemLabelGenerator(new StandardCategorySeriesLabelGenerator(
"XYZ"));
assertFalse(r1.equals(r2));
r2.setLegendItemLabelGenerator(new StandardCategorySeriesLabelGenerator(
"XYZ"));
assertEquals(r1, r2);
// legendItemToolTipGenerator
r1.setLegendItemToolTipGenerator(
new StandardCategorySeriesLabelGenerator("ToolTip"));
assertFalse(r1.equals(r2));
r2.setLegendItemToolTipGenerator(
new StandardCategorySeriesLabelGenerator("ToolTip"));
assertEquals(r1, r2);
// legendItemURLGenerator
r1.setLegendItemURLGenerator(
new StandardCategorySeriesLabelGenerator("URL"));
assertFalse(r1.equals(r2));
r2.setLegendItemURLGenerator(
new StandardCategorySeriesLabelGenerator("URL"));
assertEquals(r1, r2);
}
/**
* Confirm that cloning works.
* @throws CloneNotSupportedException
*/
@Test
public void testCloning1() throws CloneNotSupportedException {
AbstractCategoryItemRenderer r1 = new BarRenderer();
r1.setSeriesItemLabelGenerator(0,
new StandardCategoryItemLabelGenerator());
AbstractCategoryItemRenderer r2 = (BarRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
r1 = new BarRenderer();
r1.setDefaultItemLabelGenerator(new StandardCategoryItemLabelGenerator());
r2 = (BarRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
}
/**
* Confirm that cloning works.
* @throws CloneNotSupportedException
*/
@Test
public void testCloning2() throws CloneNotSupportedException {
BarRenderer r1 = new BarRenderer();
r1.setSeriesItemLabelGenerator(0,
new IntervalCategoryItemLabelGenerator());
BarRenderer r2 = (BarRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
r1 = new BarRenderer();
r1.setDefaultItemLabelGenerator(new IntervalCategoryItemLabelGenerator());
r2 = (BarRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
}
/**
* Check that the legendItemLabelGenerator is cloned.
* @throws CloneNotSupportedException
*/
@Test
public void testCloning_LegendItemLabelGenerator()
throws CloneNotSupportedException {
StandardCategorySeriesLabelGenerator generator
= new StandardCategorySeriesLabelGenerator("Series {0}");
BarRenderer r1 = new BarRenderer();
r1.setLegendItemLabelGenerator(generator);
BarRenderer r2 = (BarRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
// check that the generator has been cloned
assertNotSame(r1.getLegendItemLabelGenerator(),
r2.getLegendItemLabelGenerator());
}
/**
* Check that the legendItemToolTipGenerator is cloned.
* @throws CloneNotSupportedException
*/
@Test
public void testCloning_LegendItemToolTipGenerator()
throws CloneNotSupportedException {
StandardCategorySeriesLabelGenerator generator
= new StandardCategorySeriesLabelGenerator("Series {0}");
BarRenderer r1 = new BarRenderer();
r1.setLegendItemToolTipGenerator(generator);
BarRenderer r2 = (BarRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
// check that the generator has been cloned
assertNotSame(r1.getLegendItemToolTipGenerator(),
r2.getLegendItemToolTipGenerator());
}
/**
* Check that the legendItemURLGenerator is cloned.
* @throws CloneNotSupportedException
*/
@Test
public void testCloning_LegendItemURLGenerator()
throws CloneNotSupportedException {
StandardCategorySeriesLabelGenerator generator
= new StandardCategorySeriesLabelGenerator("Series {0}");
BarRenderer r1 = new BarRenderer();
r1.setLegendItemURLGenerator(generator);
BarRenderer r2 = (BarRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
// check that the generator has been cloned
assertNotSame(r1.getLegendItemURLGenerator(),
r2.getLegendItemURLGenerator());
}
/**
* Some checks for the findRangeBounds() method.
*/
@Test
public void testFindRangeBounds() {
AbstractCategoryItemRenderer r = new LineAndShapeRenderer();
assertNull(r.findRangeBounds(null));
// an empty dataset should return a null range
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
assertNull(r.findRangeBounds(dataset));
dataset.addValue(1.0, "R1", "C1");
assertEquals(new Range(1.0, 1.0), r.findRangeBounds(dataset));
dataset.addValue(-2.0, "R1", "C2");
assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset));
dataset.addValue(null, "R1", "C3");
assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset));
}
/**
* A test that reproduces the problem reported in bug 2947660.
*/
@Test
public void test2947660() {
AbstractCategoryItemRenderer r = new LineAndShapeRenderer();
assertNotNull(r.getLegendItems());
assertEquals(0, r.getLegendItems().size());
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
CategoryPlot plot = new CategoryPlot();
plot.setDataset(dataset);
plot.setRenderer(r);
assertEquals(0, r.getLegendItems().size());
dataset.addValue(1.0, "S1", "C1");
List<LegendItem> lic = r.getLegendItems();
assertEquals(1, lic.size());
assertEquals("S1", lic.get(0).getLabel());
}
}
| 11,252 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
LineAndShapeRendererTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/category/LineAndShapeRendererTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ------------------------------
* LineAndShapeRendererTests.java
* ------------------------------
* (C) Copyright 2003-2009, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 22-Sep-2003 : Version 1 (DG);
* 17-May-2007 : Added check for getLegendItem() method (DG);
* 27-Sep-2007 : Extended equals() test (DG);
* 23-Apr-2008 : Added testPublicCloneable() (DG);
* 16-May-2009 : Added testFindRangeBounds() (DG);
*
*/
package org.jfree.chart.renderer.category;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.LegendItem;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.data.Range;
import org.jfree.data.category.DefaultCategoryDataset;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link LineAndShapeRenderer} class.
*/
public class LineAndShapeRendererTest {
/**
* Test that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
LineAndShapeRenderer r1 = new LineAndShapeRenderer();
LineAndShapeRenderer r2 = new LineAndShapeRenderer();
assertEquals(r1, r2);
r1.setBaseLinesVisible(!r1.getBaseLinesVisible());
assertFalse(r1.equals(r2));
r2.setBaseLinesVisible(r1.getBaseLinesVisible());
assertEquals(r1, r2);
r1.setSeriesLinesVisible(1, true);
assertFalse(r1.equals(r2));
r2.setSeriesLinesVisible(1, true);
assertEquals(r1, r2);
r1.setBaseShapesVisible(!r1.getBaseShapesVisible());
assertFalse(r1.equals(r2));
r2.setBaseShapesVisible(r1.getBaseShapesVisible());
assertEquals(r1, r2);
r1.setSeriesShapesVisible(1, true);
assertFalse(r1.equals(r2));
r2.setSeriesShapesVisible(1, true);
assertEquals(r1, r2);
r1.setSeriesShapesFilled(1, true);
assertFalse(r1.equals(r2));
r2.setSeriesShapesFilled(1, true);
assertEquals(r1, r2);
r1.setBaseShapesFilled(false);
assertFalse(r1.equals(r2));
r2.setBaseShapesFilled(false);
assertEquals(r1, r2);
r1.setUseOutlinePaint(true);
assertFalse(r1.equals(r2));
r2.setUseOutlinePaint(true);
assertEquals(r1, r2);
r1.setUseSeriesOffset(true);
assertFalse(r1.equals(r2));
r2.setUseSeriesOffset(true);
assertEquals(r1, r2);
r1.setItemMargin(0.14);
assertFalse(r1.equals(r2));
r2.setItemMargin(0.14);
assertEquals(r1, r2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
LineAndShapeRenderer r1 = new LineAndShapeRenderer();
LineAndShapeRenderer r2 = new LineAndShapeRenderer();
assertEquals(r1, r2);
int h1 = r1.hashCode();
int h2 = r2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
LineAndShapeRenderer r1 = new LineAndShapeRenderer();
LineAndShapeRenderer r2 = (LineAndShapeRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
assertTrue(checkIndependence(r1, r2));
}
/**
* Check that this class implements PublicCloneable.
*/
@Test
public void testPublicCloneable() {
LineAndShapeRenderer r1 = new LineAndShapeRenderer();
assertTrue(r1 instanceof PublicCloneable);
}
/**
* Checks that the two renderers are equal but independent of one another.
*
* @param r1 renderer 1.
* @param r2 renderer 2.
*
* @return A boolean.
*/
private boolean checkIndependence(LineAndShapeRenderer r1,
LineAndShapeRenderer r2) {
// should be equal...
if (!r1.equals(r2)) {
return false;
}
// and independent...
r1.setBaseLinesVisible(!r1.getBaseLinesVisible());
if (r1.equals(r2)) {
return false;
}
r2.setBaseLinesVisible(r1.getBaseLinesVisible());
if (!r1.equals(r2)) {
return false;
}
r1.setSeriesLinesVisible(1, true);
if (r1.equals(r2)) {
return false;
}
r2.setSeriesLinesVisible(1, true);
if (!r1.equals(r2)) {
return false;
}
r1.setBaseShapesVisible(!r1.getBaseShapesVisible());
if (r1.equals(r2)) {
return false;
}
r2.setBaseShapesVisible(r1.getBaseShapesVisible());
if (!r1.equals(r2)) {
return false;
}
r1.setSeriesShapesVisible(1, true);
if (r1.equals(r2)) {
return false;
}
r2.setSeriesShapesVisible(1, true);
if (!r1.equals(r2)) {
return false;
}
r1.setSeriesShapesFilled(0, false);
r2.setSeriesShapesFilled(0, true);
if (r1.equals(r2)) {
return false;
}
r2.setSeriesShapesFilled(0, false);
if (!r1.equals(r2)) {
return false;
}
r1.setBaseShapesFilled(false);
r2.setBaseShapesFilled(true);
if (r1.equals(r2)) {
return false;
}
r2.setBaseShapesFilled(false);
if (!r1.equals(r2)) {
return false;
}
return true;
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
LineAndShapeRenderer r1 = new LineAndShapeRenderer();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
LineAndShapeRenderer r2 = (LineAndShapeRenderer) in.readObject();
in.close();
assertEquals(r1, r2);
}
/**
* A check for the datasetIndex and seriesIndex fields in the LegendItem
* returned by the getLegendItem() method.
*/
@Test
public void testGetLegendItemSeriesIndex() {
DefaultCategoryDataset dataset0 = new DefaultCategoryDataset();
dataset0.addValue(21.0, "R1", "C1");
dataset0.addValue(22.0, "R2", "C1");
DefaultCategoryDataset dataset1 = new DefaultCategoryDataset();
dataset1.addValue(23.0, "R3", "C1");
dataset1.addValue(24.0, "R4", "C1");
dataset1.addValue(25.0, "R5", "C1");
LineAndShapeRenderer r = new LineAndShapeRenderer();
CategoryPlot plot = new CategoryPlot(dataset0, new CategoryAxis("x"),
new NumberAxis("y"), r);
plot.setDataset(1, dataset1);
/*JFreeChart chart =*/ new JFreeChart(plot);
LegendItem li = r.getLegendItem(1, 2);
assertEquals("R5", li.getLabel());
assertEquals(1, li.getDatasetIndex());
assertEquals(2, li.getSeriesIndex());
}
/**
* Some checks for the findRangeBounds() method.
*/
@Test
public void testFindRangeBounds() {
LineAndShapeRenderer r = new LineAndShapeRenderer();
assertNull(r.findRangeBounds(null));
// an empty dataset should return a null range
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
assertNull(r.findRangeBounds(dataset));
dataset.addValue(1.0, "R1", "C1");
assertEquals(new Range(1.0, 1.0), r.findRangeBounds(dataset));
dataset.addValue(-2.0, "R1", "C2");
assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset));
dataset.addValue(null, "R1", "C3");
assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset));
dataset.addValue(-6.0, "R2", "C1");
assertEquals(new Range(-6.0, 1.0), r.findRangeBounds(dataset));
r.setSeriesVisible(1, Boolean.FALSE);
assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset));
}
}
| 10,135 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
StatisticalBarRendererTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/category/StatisticalBarRendererTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* --------------------------------
* StatisticalBarRendererTests.java
* --------------------------------
* (C) Copyright 2003-2009, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 25-Mar-2003 : Version 1 (DG);
* 28-Aug-2007 : Added tests for bug 1779941 (DG);
* 14-Nov-2007 : Updated testEquals() (DG);
* 23-Apr-2008 : Added testPublicCloneable() (DG);
* 16-May-2009 : Added testFindRangeBounds (DG);
*
*/
package org.jfree.chart.renderer.category;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.data.Range;
import org.jfree.data.statistics.DefaultStatisticalCategoryDataset;
import org.junit.Test;
import java.awt.BasicStroke;
import java.awt.Color;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link StatisticalBarRenderer} class.
*/
public class StatisticalBarRendererTest {
/**
* Check that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
StatisticalBarRenderer r1 = new StatisticalBarRenderer();
StatisticalBarRenderer r2 = new StatisticalBarRenderer();
assertEquals(r1, r2);
r1.setErrorIndicatorPaint(Color.RED);
assertFalse(r1.equals(r2));
r2.setErrorIndicatorPaint(Color.RED);
assertEquals(r2, r1);
r1.setErrorIndicatorStroke(new BasicStroke(1.5f));
assertFalse(r1.equals(r2));
r2.setErrorIndicatorStroke(new BasicStroke(1.5f));
assertEquals(r2, r1);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
StatisticalBarRenderer r1 = new StatisticalBarRenderer();
StatisticalBarRenderer r2 = new StatisticalBarRenderer();
assertEquals(r1, r2);
int h1 = r1.hashCode();
int h2 = r2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
StatisticalBarRenderer r1 = new StatisticalBarRenderer();
StatisticalBarRenderer r2 = (StatisticalBarRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
}
/**
* Check that this class implements PublicCloneable.
*/
@Test
public void testPublicCloneable() {
StatisticalBarRenderer r1 = new StatisticalBarRenderer();
assertTrue(r1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
StatisticalBarRenderer r1 = new StatisticalBarRenderer();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(
buffer.toByteArray()));
StatisticalBarRenderer r2 = (StatisticalBarRenderer) in.readObject();
in.close();
assertEquals(r1, r2);
}
/**
* Draws the chart with a <code>null</code> info object to make sure that
* no exceptions are thrown (particularly by code in the renderer).
*/
@Test
public void testDrawWithNullInfo() {
DefaultStatisticalCategoryDataset dataset
= new DefaultStatisticalCategoryDataset();
dataset.add(1.0, 2.0, "S1", "C1");
dataset.add(3.0, 4.0, "S1", "C2");
CategoryPlot plot = new CategoryPlot(dataset,
new CategoryAxis("Category"), new NumberAxis("Value"),
new StatisticalBarRenderer());
JFreeChart chart = new JFreeChart(plot);
/* BufferedImage image = */ chart.createBufferedImage(300, 200,
null);
}
/**
* Draws the chart with a <code>null</code> mean value to make sure that
* no exceptions are thrown (particularly by code in the renderer). See
* bug report 1779941.
*/
@Test
public void testDrawWithNullMeanVertical() {
DefaultStatisticalCategoryDataset dataset
= new DefaultStatisticalCategoryDataset();
dataset.add(1.0, 2.0, "S1", "C1");
dataset.add(null, 4.0, "S1", "C2");
CategoryPlot plot = new CategoryPlot(dataset,
new CategoryAxis("Category"), new NumberAxis("Value"),
new StatisticalBarRenderer());
JFreeChart chart = new JFreeChart(plot);
/* BufferedImage image = */ chart.createBufferedImage(300, 200,
null);
}
/**
* Draws the chart with a <code>null</code> mean value to make sure that
* no exceptions are thrown (particularly by code in the renderer). See
* bug report 1779941.
*/
@Test
public void testDrawWithNullMeanHorizontal() {
DefaultStatisticalCategoryDataset dataset
= new DefaultStatisticalCategoryDataset();
dataset.add(1.0, 2.0, "S1", "C1");
dataset.add(null, 4.0, "S1", "C2");
CategoryPlot plot = new CategoryPlot(dataset,
new CategoryAxis("Category"), new NumberAxis("Value"),
new StatisticalBarRenderer());
plot.setOrientation(PlotOrientation.HORIZONTAL);
JFreeChart chart = new JFreeChart(plot);
/* BufferedImage image = */ chart.createBufferedImage(300, 200,
null);
}
/**
* Draws the chart with a <code>null</code> standard deviation to make sure
* that no exceptions are thrown (particularly by code in the renderer).
* See bug report 1779941.
*/
@Test
public void testDrawWithNullDeviationVertical() {
DefaultStatisticalCategoryDataset dataset
= new DefaultStatisticalCategoryDataset();
dataset.add(1.0, 2.0, "S1", "C1");
dataset.add(4.0, null, "S1", "C2");
CategoryPlot plot = new CategoryPlot(dataset,
new CategoryAxis("Category"), new NumberAxis("Value"),
new StatisticalBarRenderer());
JFreeChart chart = new JFreeChart(plot);
/* BufferedImage image = */ chart.createBufferedImage(300, 200,
null);
}
/**
* Draws the chart with a <code>null</code> standard deviation to make sure
* that no exceptions are thrown (particularly by code in the renderer).
* See bug report 1779941.
*/
@Test
public void testDrawWithNullDeviationHorizontal() {
DefaultStatisticalCategoryDataset dataset
= new DefaultStatisticalCategoryDataset();
dataset.add(1.0, 2.0, "S1", "C1");
dataset.add(4.0, null, "S1", "C2");
CategoryPlot plot = new CategoryPlot(dataset,
new CategoryAxis("Category"), new NumberAxis("Value"),
new StatisticalBarRenderer());
plot.setOrientation(PlotOrientation.HORIZONTAL);
JFreeChart chart = new JFreeChart(plot);
/* BufferedImage image = */ chart.createBufferedImage(300, 200,
null);
}
/**
* Some checks for the findRangeBounds() method.
*/
@Test
public void testFindRangeBounds() {
StatisticalBarRenderer r = new StatisticalBarRenderer();
assertNull(r.findRangeBounds(null));
// an empty dataset should return a null range
DefaultStatisticalCategoryDataset dataset
= new DefaultStatisticalCategoryDataset();
assertNull(r.findRangeBounds(dataset));
dataset.add(1.0, 0.5, "R1", "C1");
assertEquals(new Range(0.0, 1.5), r.findRangeBounds(dataset));
r.setIncludeBaseInRange(false);
assertEquals(new Range(0.5, 1.5), r.findRangeBounds(dataset));
r.setIncludeBaseInRange(true);
dataset.add(-2.0, 0.2, "R1", "C2");
assertEquals(new Range(-2.2, 1.5), r.findRangeBounds(dataset));
dataset.add(null, null, "R1", "C3");
assertEquals(new Range(-2.2, 1.5), r.findRangeBounds(dataset));
dataset.add(5.0, 1.0, "R2", "C3");
assertEquals(new Range(-2.2, 6.0), r.findRangeBounds(dataset));
// check that the series visible flag is observed
r.setSeriesVisible(1, Boolean.FALSE);
assertEquals(new Range(-2.2, 1.5), r.findRangeBounds(dataset));
}
}
| 10,623 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
BarRendererTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/category/BarRendererTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ---------------------
* BarRendererTests.java
* ---------------------
* (C) Copyright 2003-2012, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 25-Mar-2003 : Version 1 (DG);
* 19-Aug-2003 : Renamed HorizontalBarRendererTests --> BarRendererTests (DG);
* 22-Oct-2003 : Added hashCode test (DG);
* 18-May-2005 : Added field to equals() test (DG);
* 22-Sep-2005 : Renamed getMaxBarWidth() --> getMaximumBarWidth() (DG);
* 11-May-2007 : Added testGetLegendItem() (DG);
* 23-Apr-2008 : Added testPublicCloneable() (DG);
* 25-Nov-2008 : Added testFindRangeBounds (DG);
* 16-May-2009 : Added series visibility check in testFindRangeBounds() (DG);
* 17-Jun-2012 : Removed JCommon dependencies (DG);
*
*/
package org.jfree.chart.renderer.category;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.LegendItem;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.labels.ItemLabelAnchor;
import org.jfree.chart.labels.ItemLabelPosition;
import org.jfree.chart.labels.StandardCategoryItemLabelGenerator;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.renderer.RendererChangeDetector;
import org.jfree.chart.ui.GradientPaintTransformType;
import org.jfree.chart.ui.StandardGradientPaintTransformer;
import org.jfree.chart.ui.TextAnchor;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.data.Range;
import org.jfree.data.category.DefaultCategoryDataset;
import org.junit.Test;
import java.awt.Color;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link BarRenderer} class.
*/
public class BarRendererTest {
/**
* Test that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
BarRenderer r1 = new BarRenderer();
BarRenderer r2 = new BarRenderer();
assertEquals(r1, r2);
assertEquals(r2, r1);
// base value
r1.setBase(0.123);
assertFalse(r1.equals(r2));
r2.setBase(0.123);
assertEquals(r1, r2);
// itemMargin
r1.setItemMargin(0.22);
assertFalse(r1.equals(r2));
r2.setItemMargin(0.22);
assertEquals(r1, r2);
// drawBarOutline
r1.setDrawBarOutline(!r1.isDrawBarOutline());
assertFalse(r1.equals(r2));
r2.setDrawBarOutline(!r2.isDrawBarOutline());
assertEquals(r1, r2);
// maximumBarWidth
r1.setMaximumBarWidth(0.11);
assertFalse(r1.equals(r2));
r2.setMaximumBarWidth(0.11);
assertEquals(r1, r2);
// minimumBarLength
r1.setMinimumBarLength(0.04);
assertFalse(r1.equals(r2));
r2.setMinimumBarLength(0.04);
assertEquals(r1, r2);
// gradientPaintTransformer
r1.setGradientPaintTransformer(new StandardGradientPaintTransformer(
GradientPaintTransformType.CENTER_VERTICAL));
assertFalse(r1.equals(r2));
r2.setGradientPaintTransformer(new StandardGradientPaintTransformer(
GradientPaintTransformType.CENTER_VERTICAL));
assertEquals(r1, r2);
// positiveItemLabelPositionFallback
r1.setPositiveItemLabelPositionFallback(new ItemLabelPosition(
ItemLabelAnchor.INSIDE1, TextAnchor.CENTER));
assertFalse(r1.equals(r2));
r2.setPositiveItemLabelPositionFallback(new ItemLabelPosition(
ItemLabelAnchor.INSIDE1, TextAnchor.CENTER));
assertEquals(r1, r2);
// negativeItemLabelPositionFallback
r1.setNegativeItemLabelPositionFallback(new ItemLabelPosition(
ItemLabelAnchor.INSIDE1, TextAnchor.CENTER));
assertFalse(r1.equals(r2));
r2.setNegativeItemLabelPositionFallback(new ItemLabelPosition(
ItemLabelAnchor.INSIDE1, TextAnchor.CENTER));
assertEquals(r1, 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));
assertEquals(r1, r2);
// shadowsVisible
r1.setShadowVisible(false);
assertFalse(r1.equals(r2));
r2.setShadowVisible(false);
assertEquals(r1, r2);
r1.setShadowPaint(Color.RED);
assertFalse(r1.equals(r2));
r2.setShadowPaint(Color.RED);
assertEquals(r1, r2);
// shadowXOffset
r1.setShadowXOffset(3.3);
assertFalse(r1.equals(r2));
r2.setShadowXOffset(3.3);
assertEquals(r1, r2);
// shadowYOffset
r1.setShadowYOffset(3.3);
assertFalse(r1.equals(r2));
r2.setShadowYOffset(3.3);
assertEquals(r1, r2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
BarRenderer r1 = new BarRenderer();
BarRenderer r2 = new BarRenderer();
assertEquals(r1, r2);
int h1 = r1.hashCode();
int h2 = r2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
BarRenderer r1 = new BarRenderer();
r1.setDefaultItemLabelGenerator(new StandardCategoryItemLabelGenerator());
r1.setBarPainter(new GradientBarPainter(0.11, 0.22, 0.33));
BarRenderer r2 = (BarRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
}
/**
* Check that this class implements PublicCloneable.
*/
@Test
public void testPublicCloneable() {
BarRenderer r1 = new BarRenderer();
assertTrue(r1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
BarRenderer r1 = new BarRenderer();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(
buffer.toByteArray()));
BarRenderer r2 = (BarRenderer) in.readObject();
in.close();
assertEquals(r1, r2);
}
/**
* Tests each setter method to ensure that it sends an event notification.
*/
@Test
public void testEventNotification() {
RendererChangeDetector detector = new RendererChangeDetector();
BarRenderer r1 = new BarRenderer();
r1.addChangeListener(detector);
detector.setNotified(false);
r1.setDefaultPaint(Color.RED);
assertTrue(detector.getNotified());
}
/**
* Some checks for the getLegendItem() method.
*/
@Test
public void testGetLegendItem() {
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.addValue(21.0, "R1", "C1");
BarRenderer r = new BarRenderer();
CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("x"),
new NumberAxis("y"), r);
/*JFreeChart chart =*/ new JFreeChart(plot);
LegendItem li = r.getLegendItem(0, 0);
assertNotNull(li);
r.setSeriesVisibleInLegend(0, Boolean.FALSE);
li = r.getLegendItem(0, 0);
assertNull(li);
}
/**
* A check for the datasetIndex and seriesIndex fields in the LegendItem
* returned by the getLegendItem() method.
*/
@Test
public void testGetLegendItemSeriesIndex() {
DefaultCategoryDataset dataset0 = new DefaultCategoryDataset();
dataset0.addValue(21.0, "R1", "C1");
dataset0.addValue(22.0, "R2", "C1");
DefaultCategoryDataset dataset1 = new DefaultCategoryDataset();
dataset1.addValue(23.0, "R3", "C1");
dataset1.addValue(24.0, "R4", "C1");
dataset1.addValue(25.0, "R5", "C1");
BarRenderer r = new BarRenderer();
CategoryPlot plot = new CategoryPlot(dataset0, new CategoryAxis("x"),
new NumberAxis("y"), r);
plot.setDataset(1, dataset1);
/*JFreeChart chart =*/ new JFreeChart(plot);
LegendItem li = r.getLegendItem(1, 2);
assertEquals("R5", li.getLabel());
assertEquals(1, li.getDatasetIndex());
assertEquals(2, li.getSeriesIndex());
}
/**
* Some checks for the findRangeBounds() method.
*/
@Test
public void testFindRangeBounds() {
BarRenderer r = new BarRenderer();
assertNull(r.findRangeBounds(null));
// an empty dataset should return a null range
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
assertNull(r.findRangeBounds(dataset));
dataset.addValue(1.0, "R1", "C1");
assertEquals(new Range(0.0, 1.0), r.findRangeBounds(dataset));
r.setIncludeBaseInRange(false);
assertEquals(new Range(1.0, 1.0), r.findRangeBounds(dataset));
r.setIncludeBaseInRange(true);
dataset.addValue(-2.0, "R1", "C2");
assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset));
dataset.addValue(null, "R1", "C3");
assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset));
dataset.addValue(-6.0, "R2", "C1");
assertEquals(new Range(-6.0, 1.0), r.findRangeBounds(dataset));
r.setSeriesVisible(1, Boolean.FALSE);
assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset));
}
}
| 11,499 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
AreaRendererTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/category/AreaRendererTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ----------------------
* AreaRendererTests.java
* ----------------------
* (C) Copyright 2003-2012, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 25-Mar-2003 : Version 1 (DG);
* 22-Oct-2003 : Added hashCode() test (DG);
* 11-Oct-2006 : Strengthened the testEquals() method (DG);
* 17-May-2007 : Added testGetLegendItemSeriesIndex() (DG);
* 23-Apr-2008 : Added testPublicCloneable() (DG);
* 17-Jun-2012 : Removed JCommon dependencies (DG);
*
*/
package org.jfree.chart.renderer.category;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.LegendItem;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.renderer.AreaRendererEndType;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.data.category.DefaultCategoryDataset;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link AreaRenderer} class.
*/
public class AreaRendererTest {
/**
* Check that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
AreaRenderer r1 = new AreaRenderer();
AreaRenderer r2 = new AreaRenderer();
assertEquals(r1, r2);
r1.setEndType(AreaRendererEndType.LEVEL);
assertFalse(r1.equals(r2));
r2.setEndType(AreaRendererEndType.LEVEL);
assertEquals(r1, r2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
AreaRenderer r1 = new AreaRenderer();
AreaRenderer r2 = new AreaRenderer();
assertEquals(r1, r2);
int h1 = r1.hashCode();
int h2 = r2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
AreaRenderer r1 = new AreaRenderer();
AreaRenderer r2 = (AreaRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
}
/**
* Check that this class implements PublicCloneable.
*/
@Test
public void testPublicCloneable() {
AreaRenderer r1 = new AreaRenderer();
assertTrue(r1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
AreaRenderer r1 = new AreaRenderer();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
AreaRenderer r2 = (AreaRenderer) in.readObject();
in.close();
assertEquals(r1, r2);
}
/**
* A check for the datasetIndex and seriesIndex fields in the LegendItem
* returned by the getLegendItem() method.
*/
@Test
public void testGetLegendItemSeriesIndex() {
DefaultCategoryDataset dataset0 = new DefaultCategoryDataset();
dataset0.addValue(21.0, "R1", "C1");
dataset0.addValue(22.0, "R2", "C1");
DefaultCategoryDataset dataset1 = new DefaultCategoryDataset();
dataset1.addValue(23.0, "R3", "C1");
dataset1.addValue(24.0, "R4", "C1");
dataset1.addValue(25.0, "R5", "C1");
AreaRenderer r = new AreaRenderer();
CategoryPlot plot = new CategoryPlot(dataset0, new CategoryAxis("x"),
new NumberAxis("y"), r);
plot.setDataset(1, dataset1);
/*JFreeChart chart =*/ new JFreeChart(plot);
LegendItem li = r.getLegendItem(1, 2);
assertEquals("R5", li.getLabel());
assertEquals(1, li.getDatasetIndex());
assertEquals(2, li.getSeriesIndex());
}
}
| 5,776 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
LevelRendererTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/category/LevelRendererTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* -----------------------
* LevelRendererTests.java
* -----------------------
* (C) Copyright 2005-2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 29-Mar-2005 : Version 1 (DG);
* 23-Apr-2008 : Added testPublicCloneable (DG);
*
*/
package org.jfree.chart.renderer.category;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.LegendItem;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.data.category.DefaultCategoryDataset;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link LevelRenderer} class.
*/
public class LevelRendererTest {
/**
* Test that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
LevelRenderer r1 = new LevelRenderer();
LevelRenderer r2 = new LevelRenderer();
assertEquals(r1, r2);
assertEquals(r2, r1);
r1.setItemMargin(0.123);
assertFalse(r1.equals(r2));
r2.setItemMargin(0.123);
assertEquals(r1, r2);
r1.setMaximumItemWidth(0.234);
assertFalse(r1.equals(r2));
r2.setMaximumItemWidth(0.234);
assertEquals(r1, r2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
LevelRenderer r1 = new LevelRenderer();
LevelRenderer r2 = new LevelRenderer();
assertEquals(r1, r2);
int h1 = r1.hashCode();
int h2 = r2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
LevelRenderer r1 = new LevelRenderer();
r1.setItemMargin(0.123);
r1.setMaximumItemWidth(0.234);
LevelRenderer r2 = (LevelRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
assertTrue(checkIndependence(r1, r2));
}
/**
* Check that this class implements PublicCloneable.
*/
@Test
public void testPublicCloneable() {
LevelRenderer r1 = new LevelRenderer();
assertTrue(r1 instanceof PublicCloneable);
}
/**
* Checks that the two renderers are equal but independent of one another.
*
* @param r1 renderer 1.
* @param r2 renderer 2.
*
* @return A boolean.
*/
private boolean checkIndependence(LevelRenderer r1, LevelRenderer r2) {
// should be equal...
boolean b0 = r1.equals(r2);
// and independent...
r1.setItemMargin(0.0);
boolean b1 = !r1.equals(r2);
r2.setItemMargin(0.0);
boolean b2 = r1.equals(r2);
return b0 && b1 && b2;
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
LevelRenderer r1 = new LevelRenderer();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray())
);
LevelRenderer r2 = (LevelRenderer) in.readObject();
in.close();
assertEquals(r1, r2);
}
/**
* Draws the chart with a <code>null</code> info object to make sure that
* no exceptions are thrown (particularly by code in the renderer).
*/
@Test
public void testDrawWithNullInfo() {
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.addValue(1.0, "S1", "C1");
CategoryPlot plot = new CategoryPlot(dataset,
new CategoryAxis("Category"), new NumberAxis("Value"),
new LevelRenderer());
JFreeChart chart = new JFreeChart(plot);
/* BufferedImage image = */ chart.createBufferedImage(300, 200,
null);
}
/**
* A check for the datasetIndex and seriesIndex fields in the LegendItem
* returned by the getLegendItem() method.
*/
@Test
public void testGetLegendItemSeriesIndex() {
DefaultCategoryDataset dataset0 = new DefaultCategoryDataset();
dataset0.addValue(21.0, "R1", "C1");
dataset0.addValue(22.0, "R2", "C1");
DefaultCategoryDataset dataset1 = new DefaultCategoryDataset();
dataset1.addValue(23.0, "R3", "C1");
dataset1.addValue(24.0, "R4", "C1");
dataset1.addValue(25.0, "R5", "C1");
LevelRenderer r = new LevelRenderer();
CategoryPlot plot = new CategoryPlot(dataset0, new CategoryAxis("x"),
new NumberAxis("y"), r);
plot.setDataset(1, dataset1);
/*JFreeChart chart =*/ new JFreeChart(plot);
LegendItem li = r.getLegendItem(1, 2);
assertEquals("R5", li.getLabel());
assertEquals(1, li.getDatasetIndex());
assertEquals(2, li.getSeriesIndex());
}
}
| 7,024 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
DefaultCategoryItemRendererTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/category/DefaultCategoryItemRendererTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* -------------------------------------
* DefaultCategoryItemRendererTests.java
* -------------------------------------
* (C) Copyright 2003-2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 29-Apr-2003 : Version 1 (DG);
* 22-Oct-2003 : Added hashCode test (DG);
* 23-Apr-2008 : Added testPublicCloneable() (DG);
*
*/
package org.jfree.chart.renderer.category;
import org.jfree.chart.util.PublicCloneable;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link DefaultCategoryItemRenderer} class.
*/
public class DefaultCategoryItemRendererTest {
/**
* Check that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
DefaultCategoryItemRenderer r1 = new DefaultCategoryItemRenderer();
DefaultCategoryItemRenderer r2 = new DefaultCategoryItemRenderer();
assertEquals(r1, r2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
DefaultCategoryItemRenderer r1 = new DefaultCategoryItemRenderer();
DefaultCategoryItemRenderer r2 = new DefaultCategoryItemRenderer();
assertEquals(r1, r2);
int h1 = r1.hashCode();
int h2 = r2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
DefaultCategoryItemRenderer r1 = new DefaultCategoryItemRenderer();
DefaultCategoryItemRenderer r2 = (DefaultCategoryItemRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
}
/**
* Check that this class implements PublicCloneable.
*/
@Test
public void testPublicCloneable() {
DefaultCategoryItemRenderer r1 = new DefaultCategoryItemRenderer();
assertTrue(r1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
DefaultCategoryItemRenderer r1 = new DefaultCategoryItemRenderer();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray())
);
DefaultCategoryItemRenderer r2 = (DefaultCategoryItemRenderer) in.readObject();
in.close();
assertEquals(r1, r2);
}
}
| 4,432 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
StackedAreaRendererTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/category/StackedAreaRendererTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* -----------------------------
* StackedAreaRendererTests.java
* -----------------------------
* (C) Copyright 2003-2009, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 25-Mar-2003 : Version 1 (DG);
* 23-Apr-2008 : Added testPublicCloneable() (DG);
* 04-Feb-2009 : Added testFindRangeBounds (DG);
*
*/
package org.jfree.chart.renderer.category;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.data.Range;
import org.jfree.data.category.DefaultCategoryDataset;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link StackedAreaRenderer} class.
*/
public class StackedAreaRendererTest {
/**
* Some checks for the findRangeBounds() method.
*/
@Test
public void testFindRangeBounds() {
StackedAreaRenderer r = new StackedAreaRenderer();
assertNull(r.findRangeBounds(null));
// an empty dataset should return a null range
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
assertNull(r.findRangeBounds(dataset));
dataset.addValue(1.0, "R1", "C1");
assertEquals(new Range(0.0, 1.0), r.findRangeBounds(dataset));
dataset.addValue(-2.0, "R1", "C2");
assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset));
dataset.addValue(null, "R1", "C3");
assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset));
dataset.addValue(2.0, "R2", "C1");
assertEquals(new Range(-2.0, 3.0), r.findRangeBounds(dataset));
dataset.addValue(null, "R2", "C2");
assertEquals(new Range(-2.0, 3.0), r.findRangeBounds(dataset));
}
/**
* Check that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
StackedAreaRenderer r1 = new StackedAreaRenderer();
StackedAreaRenderer r2 = new StackedAreaRenderer();
assertEquals(r1, r2);
r1.setRenderAsPercentages(true);
assertFalse(r1.equals(r2));
r2.setRenderAsPercentages(true);
assertEquals(r1, r2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
StackedAreaRenderer r1 = new StackedAreaRenderer();
StackedAreaRenderer r2 = new StackedAreaRenderer();
assertEquals(r1, r2);
int h1 = r1.hashCode();
int h2 = r2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
StackedAreaRenderer r1 = new StackedAreaRenderer();
StackedAreaRenderer r2 = (StackedAreaRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
}
/**
* Check that this class implements PublicCloneable.
*/
@Test
public void testPublicCloneable() {
StackedAreaRenderer r1 = new StackedAreaRenderer();
assertTrue(r1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
StackedAreaRenderer r1 = new StackedAreaRenderer();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
StackedAreaRenderer r2 = (StackedAreaRenderer) in.readObject();
in.close();
assertEquals(r1, r2);
}
}
| 5,553 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
ScatterRendererTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/category/ScatterRendererTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* -------------------------
* ScatterRendererTests.java
* -------------------------
* (C) Copyright 2007-2009, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 08-Oct-2007 : Version 1 (DG);
* 11-Oct-2007 : Renamed ScatterRenderer (DG);
* 23-Apr-2008 : Added testPublicCloneable() (DG);
* 16-May-2009 : Added testFindRangeBounds() (DG);
*
*/
package org.jfree.chart.renderer.category;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.data.Range;
import org.jfree.data.statistics.DefaultMultiValueCategoryDataset;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.util.Arrays;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link ScatterRenderer} class.
*/
public class ScatterRendererTest {
/**
* Test that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
ScatterRenderer r1 = new ScatterRenderer();
ScatterRenderer r2 = new ScatterRenderer();
assertEquals(r1, r2);
r1.setSeriesShapesFilled(1, true);
assertFalse(r1.equals(r2));
r2.setSeriesShapesFilled(1, true);
assertEquals(r1, r2);
r1.setBaseShapesFilled(false);
assertFalse(r1.equals(r2));
r2.setBaseShapesFilled(false);
assertEquals(r1, r2);
r1.setUseFillPaint(true);
assertFalse(r1.equals(r2));
r2.setUseFillPaint(true);
assertEquals(r1, r2);
r1.setDrawOutlines(true);
assertFalse(r1.equals(r2));
r2.setDrawOutlines(true);
assertEquals(r1, r2);
r1.setUseOutlinePaint(true);
assertFalse(r1.equals(r2));
r2.setUseOutlinePaint(true);
assertEquals(r1, r2);
r1.setUseSeriesOffset(false);
assertFalse(r1.equals(r2));
r2.setUseSeriesOffset(false);
assertEquals(r1, r2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
ScatterRenderer r1 = new ScatterRenderer();
ScatterRenderer r2 = new ScatterRenderer();
assertEquals(r1, r2);
int h1 = r1.hashCode();
int h2 = r2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
ScatterRenderer r1 = new ScatterRenderer();
ScatterRenderer r2 = (ScatterRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
assertTrue(checkIndependence(r1, r2));
}
/**
* Check that this class implements PublicCloneable.
*/
@Test
public void testPublicCloneable() {
ScatterRenderer r1 = new ScatterRenderer();
assertTrue(r1 instanceof PublicCloneable);
}
/**
* Checks that the two renderers are equal but independent of one another.
*
* @param r1 renderer 1.
* @param r2 renderer 2.
*
* @return A boolean.
*/
private boolean checkIndependence(ScatterRenderer r1,
ScatterRenderer r2) {
// should be equal...
if (!r1.equals(r2)) {
return false;
}
// and independent...
r1.setSeriesShapesFilled(1, true);
if (r1.equals(r2)) {
return false;
}
r2.setSeriesShapesFilled(1, true);
if (!r1.equals(r2)) {
return false;
}
r1.setBaseShapesFilled(false);
r2.setBaseShapesFilled(true);
if (r1.equals(r2)) {
return false;
}
r2.setBaseShapesFilled(false);
if (!r1.equals(r2)) {
return false;
}
return true;
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
ScatterRenderer r1 = new ScatterRenderer();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
ScatterRenderer r2 = (ScatterRenderer) in.readObject();
in.close();
assertEquals(r1, r2);
}
/**
* Some checks for the findRangeBounds() method.
*/
@Test
public void testFindRangeBounds() {
ScatterRenderer r = new ScatterRenderer();
assertNull(r.findRangeBounds(null));
// an empty dataset should return a null range
DefaultMultiValueCategoryDataset dataset
= new DefaultMultiValueCategoryDataset();
assertNull(r.findRangeBounds(dataset));
List values = Arrays.asList(1.0);
dataset.add(values, "R1", "C1");
assertEquals(new Range(1.0, 1.0), r.findRangeBounds(dataset));
values = Arrays.asList(2.0, 2.2);
dataset.add(values, "R1", "C2");
assertEquals(new Range(1.0, 2.2), r.findRangeBounds(dataset));
values = Arrays.asList(-3.0, -3.2);
dataset.add(values, "R1", "C3");
assertEquals(new Range(-3.2, 2.2), r.findRangeBounds(dataset));
values = Arrays.asList(6.0);
dataset.add(values, "R2", "C1");
assertEquals(new Range(-3.2, 6.0), r.findRangeBounds(dataset));
r.setSeriesVisible(1, Boolean.FALSE);
assertEquals(new Range(-3.2, 2.2), r.findRangeBounds(dataset));
}
}
| 7,385 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
LayeredBarRendererTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/category/LayeredBarRendererTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ----------------------------
* LayeredBarRendererTests.java
* ----------------------------
* (C) Copyright 2003-2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 22-Oct-2003 : Version 1 (DG);
* 23-Apr-2008 : Added testPublicCloneable() (DG);
*
*/
package org.jfree.chart.renderer.category;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.data.category.DefaultCategoryDataset;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link LayeredBarRenderer} class.
*/
public class LayeredBarRendererTest {
/**
* Check that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
LayeredBarRenderer r1 = new LayeredBarRenderer();
LayeredBarRenderer r2 = new LayeredBarRenderer();
assertEquals(r1, r2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
LayeredBarRenderer r1 = new LayeredBarRenderer();
LayeredBarRenderer r2 = new LayeredBarRenderer();
assertEquals(r1, r2);
int h1 = r1.hashCode();
int h2 = r2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
LayeredBarRenderer r1 = new LayeredBarRenderer();
LayeredBarRenderer r2 = (LayeredBarRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
}
/**
* Check that this class implements PublicCloneable.
*/
@Test
public void testPublicCloneable() {
LayeredBarRenderer r1 = new LayeredBarRenderer();
assertTrue(r1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
LayeredBarRenderer r1 = new LayeredBarRenderer();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray())
);
LayeredBarRenderer r2 = (LayeredBarRenderer) in.readObject();
in.close();
assertEquals(r1, r2);
}
/**
* Draws the chart with a <code>null</code> info object to make sure that
* no exceptions are thrown (particularly by code in the renderer).
*/
@Test
public void testDrawWithNullInfo() {
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.addValue(1.0, "S1", "C1");
CategoryPlot plot = new CategoryPlot(dataset,
new CategoryAxis("Category"), new NumberAxis("Value"),
new LayeredBarRenderer());
JFreeChart chart = new JFreeChart(plot);
/* BufferedImage image = */ chart.createBufferedImage(300, 200,
null);
}
}
| 5,079 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
MinMaxCategoryRendererTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/category/MinMaxCategoryRendererTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* --------------------------------
* MinMaxCategoryRendererTests.java
* --------------------------------
* (C) Copyright 2003-2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 22-Oct-2003 : Version 1 (DG);
* 28-Sep-2007 : Added testEquals() method (DG);
* 23-Apr-2008 : Added testPublicCloneable() (DG);
*
*/
package org.jfree.chart.renderer.category;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.data.category.DefaultCategoryDataset;
import org.junit.Test;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.GradientPaint;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link MinMaxCategoryRenderer} class.
*/
public class MinMaxCategoryRendererTest {
/**
* Check that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
MinMaxCategoryRenderer r1 = new MinMaxCategoryRenderer();
MinMaxCategoryRenderer r2 = new MinMaxCategoryRenderer();
assertEquals(r1, r2);
r1.setDrawLines(true);
assertFalse(r1.equals(r2));
r2.setDrawLines(true);
assertEquals(r1, r2);
r1.setGroupPaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f,
Color.yellow));
assertFalse(r1.equals(r2));
r2.setGroupPaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f,
Color.yellow));
assertEquals(r1, r2);
r1.setGroupStroke(new BasicStroke(1.2f));
assertFalse(r1.equals(r2));
r2.setGroupStroke(new BasicStroke(1.2f));
assertEquals(r1, r2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
MinMaxCategoryRenderer r1 = new MinMaxCategoryRenderer();
MinMaxCategoryRenderer r2 = new MinMaxCategoryRenderer();
assertEquals(r1, r2);
int h1 = r1.hashCode();
int h2 = r2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
MinMaxCategoryRenderer r1 = new MinMaxCategoryRenderer();
MinMaxCategoryRenderer r2 = (MinMaxCategoryRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
}
/**
* Check that this class implements PublicCloneable.
*/
@Test
public void testPublicCloneable() {
MinMaxCategoryRenderer r1 = new MinMaxCategoryRenderer();
assertTrue(r1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
MinMaxCategoryRenderer r1 = new MinMaxCategoryRenderer();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
MinMaxCategoryRenderer r2 = (MinMaxCategoryRenderer) in.readObject();
in.close();
assertEquals(r1, r2);
}
/**
* Draws the chart with a <code>null</code> info object to make sure that
* no exceptions are thrown (particularly by code in the renderer).
*/
@Test
public void testDrawWithNullInfo() {
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.addValue(1.0, "S1", "C1");
CategoryPlot plot = new CategoryPlot(dataset,
new CategoryAxis("Category"), new NumberAxis("Value"),
new MinMaxCategoryRenderer());
JFreeChart chart = new JFreeChart(plot);
/* BufferedImage image = */ chart.createBufferedImage(300, 200,
null);
}
}
| 5,923 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
BoxAndWhiskerRendererTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/category/BoxAndWhiskerRendererTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* -------------------------------
* BoxAndWhiskerRendererTests.java
* -------------------------------
* (C) Copyright 2003-2012, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 22-Oct-2003 : Version 1 (DG);
* 23-Apr-2004 : Extended testEquals() method (DG);
* 12-Oct-2006 : Added new checks for bug 1572478 (DG);
* 11-May-2007 : Added testGetLegendItem() (DG);
* 17-May-2007 : Added testGetLegendItemSeriesIndex() (DG);
* 08-Oct-2007 : Added tests for null items in dataset (DG);
* 15-Jan-2008 : Updated testEquals() (DG);
* 23-Apr-2008 : Added testPublicCloneable() (DG);
* 21-Jan-2009 : Updated testEquals() for new fields (DG);
* 17-Jun-2012 : Removed JCommon dependencies (DG);
*
*/
package org.jfree.chart.renderer.category;
import org.jfree.chart.ChartRenderingInfo;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.LegendItem;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.data.statistics.BoxAndWhiskerItem;
import org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset;
import org.junit.Test;
import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Graphics2D;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link BoxAndWhiskerRenderer} class.
*/
public class BoxAndWhiskerRendererTest {
/**
* Test that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
BoxAndWhiskerRenderer r1 = new BoxAndWhiskerRenderer();
BoxAndWhiskerRenderer r2 = new BoxAndWhiskerRenderer();
assertEquals(r1, r2);
r1.setArtifactPaint(new GradientPaint(1.0f, 2.0f, Color.yellow,
3.0f, 4.0f, Color.BLUE));
assertFalse(r1.equals(r2));
r2.setArtifactPaint(new GradientPaint(1.0f, 2.0f, Color.yellow,
3.0f, 4.0f, Color.BLUE));
assertEquals(r1, r2);
r1.setFillBox(!r1.getFillBox());
assertFalse(r1.equals(r2));
r2.setFillBox(!r2.getFillBox());
assertEquals(r1, r2);
r1.setItemMargin(0.11);
assertFalse(r1.equals(r2));
r2.setItemMargin(0.11);
assertEquals(r1, r2);
r1.setMaximumBarWidth(0.99);
assertFalse(r1.equals(r2));
r2.setMaximumBarWidth(0.99);
assertEquals(r1, r2);
r1.setMeanVisible(false);
assertFalse(r1.equals(r2));
r2.setMeanVisible(false);
assertEquals(r1, r2);
r1.setMedianVisible(false);
assertFalse(r1.equals(r2));
r2.setMedianVisible(false);
assertEquals(r1, r2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
BoxAndWhiskerRenderer r1 = new BoxAndWhiskerRenderer();
BoxAndWhiskerRenderer r2 = new BoxAndWhiskerRenderer();
assertEquals(r1, r2);
int h1 = r1.hashCode();
int h2 = r2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
BoxAndWhiskerRenderer r1 = new BoxAndWhiskerRenderer();
BoxAndWhiskerRenderer r2 = (BoxAndWhiskerRenderer) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
}
/**
* Check that this class implements PublicCloneable.
*/
@Test
public void testPublicCloneable() {
BoxAndWhiskerRenderer r1 = new BoxAndWhiskerRenderer();
assertTrue(r1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
BoxAndWhiskerRenderer r1 = new BoxAndWhiskerRenderer();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
BoxAndWhiskerRenderer r2 = (BoxAndWhiskerRenderer) in.readObject();
in.close();
assertEquals(r1, r2);
}
/**
* Draws the chart with a <code>null</code> info object to make sure that
* no exceptions are thrown (particularly by code in the renderer).
*/
@Test
public void testDrawWithNullInfo() {
DefaultBoxAndWhiskerCategoryDataset dataset
= new DefaultBoxAndWhiskerCategoryDataset();
dataset.add(new BoxAndWhiskerItem(1.0, 2.0,
0.0, 4.0, 0.5,
4.5, -0.5, 5.5,
null), "S1", "C1");
CategoryPlot plot = new CategoryPlot(dataset,
new CategoryAxis("Category"), new NumberAxis("Value"),
new BoxAndWhiskerRenderer());
JFreeChart chart = new JFreeChart(plot);
/* BufferedImage image = */ chart.createBufferedImage(300, 200,
null);
//FIXME we should assert a value here
}
/**
* A check for bug 1572478 (for the vertical orientation).
*/
@Test
public void testBug1572478Vertical() {
DefaultBoxAndWhiskerCategoryDataset dataset
= new DefaultBoxAndWhiskerCategoryDataset() {
@Override
public Number getQ1Value(int row, int column) {
return null;
}
@Override
public Number getQ1Value(Comparable rowKey, Comparable columnKey) {
return null;
}
};
List<Number> values = new ArrayList<Number>();
values.add(1.0);
values.add(10.0);
values.add(100.0);
dataset.add(values, "row", "column");
CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("x"),
new NumberAxis("y"), new BoxAndWhiskerRenderer());
JFreeChart chart = new JFreeChart(plot);
BufferedImage image = new BufferedImage(200 , 100,
BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = image.createGraphics();
chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null,
new ChartRenderingInfo());
g2.dispose();
//FIXME we should really assert a value here
}
/**
* A check for bug 1572478 (for the horizontal orientation).
*/
@Test
public void testBug1572478Horizontal() {
DefaultBoxAndWhiskerCategoryDataset dataset
= new DefaultBoxAndWhiskerCategoryDataset() {
@Override
public Number getQ1Value(int row, int column) {
return null;
}
@Override
public Number getQ1Value(Comparable rowKey, Comparable columnKey) {
return null;
}
};
List<Number> values = new ArrayList<Number>();
values.add(1.0);
values.add(10.0);
values.add(100.0);
dataset.add(values, "row", "column");
CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("x"),
new NumberAxis("y"), new BoxAndWhiskerRenderer());
plot.setOrientation(PlotOrientation.HORIZONTAL);
JFreeChart chart = new JFreeChart(plot);
BufferedImage image = new BufferedImage(200 , 100,
BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = image.createGraphics();
chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null,
new ChartRenderingInfo());
g2.dispose();
//FIXME we should assert a value here
}
/**
* Some checks for the getLegendItem() method.
*/
@Test
public void testGetLegendItem() {
DefaultBoxAndWhiskerCategoryDataset dataset
= new DefaultBoxAndWhiskerCategoryDataset();
List<Number> values = new ArrayList<Number>();
values.add(1.10);
values.add(1.45);
values.add(1.33);
values.add(1.23);
dataset.add(values, "R1", "C1");
BoxAndWhiskerRenderer r = new BoxAndWhiskerRenderer();
CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("x"),
new NumberAxis("y"), r);
/*JFreeChart chart =*/ new JFreeChart(plot);
LegendItem li = r.getLegendItem(0, 0);
assertNotNull(li);
r.setSeriesVisibleInLegend(0, Boolean.FALSE);
li = r.getLegendItem(0, 0);
assertNull(li);
}
/**
* A check for the datasetIndex and seriesIndex fields in the LegendItem
* returned by the getLegendItem() method.
*/
@Test
public void testGetLegendItemSeriesIndex() {
DefaultCategoryDataset dataset0 = new DefaultCategoryDataset();
dataset0.addValue(21.0, "R1", "C1");
dataset0.addValue(22.0, "R2", "C1");
DefaultCategoryDataset dataset1 = new DefaultCategoryDataset();
dataset1.addValue(23.0, "R3", "C1");
dataset1.addValue(24.0, "R4", "C1");
dataset1.addValue(25.0, "R5", "C1");
BoxAndWhiskerRenderer r = new BoxAndWhiskerRenderer();
CategoryPlot plot = new CategoryPlot(dataset0, new CategoryAxis("x"),
new NumberAxis("y"), r);
plot.setDataset(1, dataset1);
/*JFreeChart chart =*/ new JFreeChart(plot);
LegendItem li = r.getLegendItem(1, 2);
assertEquals("R5", li.getLabel());
assertEquals(1, li.getDatasetIndex());
assertEquals(2, li.getSeriesIndex());
}
/**
* Draws a chart where the dataset contains a null mean value.
*/
@Test
public void testDrawWithNullMean() {
DefaultBoxAndWhiskerCategoryDataset dataset
= new DefaultBoxAndWhiskerCategoryDataset();
dataset.add(new BoxAndWhiskerItem(null, 2.0,
0.0, 4.0, 0.5,
4.5, -0.5, 5.5,
null), "S1", "C1");
CategoryPlot plot = new CategoryPlot(dataset,
new CategoryAxis("Category"), new NumberAxis("Value"),
new BoxAndWhiskerRenderer());
ChartRenderingInfo info = new ChartRenderingInfo();
JFreeChart chart = new JFreeChart(plot);
/* BufferedImage image = */ chart.createBufferedImage(300, 200,
info);
//FIXME we should really assert a value here
}
/**
* Draws a chart where the dataset contains a null median value.
*/
@Test
public void testDrawWithNullMedian() {
DefaultBoxAndWhiskerCategoryDataset dataset
= new DefaultBoxAndWhiskerCategoryDataset();
dataset.add(new BoxAndWhiskerItem(1.0, null,
0.0, 4.0, 0.5,
4.5, -0.5, 5.5,
null), "S1", "C1");
CategoryPlot plot = new CategoryPlot(dataset,
new CategoryAxis("Category"), new NumberAxis("Value"),
new BoxAndWhiskerRenderer());
ChartRenderingInfo info = new ChartRenderingInfo();
JFreeChart chart = new JFreeChart(plot);
/* BufferedImage image = */ chart.createBufferedImage(300, 200,
info);
//FIXME we should really assert a value here
}
/**
* Draws a chart where the dataset contains a null Q1 value.
*/
@Test
public void testDrawWithNullQ1() {
DefaultBoxAndWhiskerCategoryDataset dataset
= new DefaultBoxAndWhiskerCategoryDataset();
dataset.add(new BoxAndWhiskerItem(1.0, 2.0,
null, 4.0, 0.5,
4.5, -0.5, 5.5,
null), "S1", "C1");
CategoryPlot plot = new CategoryPlot(dataset,
new CategoryAxis("Category"), new NumberAxis("Value"),
new BoxAndWhiskerRenderer());
ChartRenderingInfo info = new ChartRenderingInfo();
JFreeChart chart = new JFreeChart(plot);
/* BufferedImage image = */ chart.createBufferedImage(300, 200,
info);
//FIXME we should really assert a value here
}
/**
* Draws a chart where the dataset contains a null Q3 value.
*/
@Test
public void testDrawWithNullQ3() {
DefaultBoxAndWhiskerCategoryDataset dataset
= new DefaultBoxAndWhiskerCategoryDataset();
dataset.add(new BoxAndWhiskerItem(1.0, 2.0,
3.0, null, 0.5,
4.5, -0.5, 5.5,
null), "S1", "C1");
CategoryPlot plot = new CategoryPlot(dataset,
new CategoryAxis("Category"), new NumberAxis("Value"),
new BoxAndWhiskerRenderer());
ChartRenderingInfo info = new ChartRenderingInfo();
JFreeChart chart = new JFreeChart(plot);
/* BufferedImage image = */ chart.createBufferedImage(300, 200,
info);
//FIXME we should really assert a value here
}
/**
* Draws a chart where the dataset contains a null min regular value.
*/
@Test
public void testDrawWithNullMinRegular() {
DefaultBoxAndWhiskerCategoryDataset dataset
= new DefaultBoxAndWhiskerCategoryDataset();
dataset.add(new BoxAndWhiskerItem(1.0, 2.0,
3.0, 4.0, null,
4.5, -0.5, 5.5,
null), "S1", "C1");
CategoryPlot plot = new CategoryPlot(dataset,
new CategoryAxis("Category"), new NumberAxis("Value"),
new BoxAndWhiskerRenderer());
ChartRenderingInfo info = new ChartRenderingInfo();
JFreeChart chart = new JFreeChart(plot);
/* BufferedImage image = */ chart.createBufferedImage(300, 200,
info);
//FIXME we should assert a value here
}
/**
* Draws a chart where the dataset contains a null max regular value.
*/
@Test
public void testDrawWithNullMaxRegular() {
DefaultBoxAndWhiskerCategoryDataset dataset
= new DefaultBoxAndWhiskerCategoryDataset();
dataset.add(new BoxAndWhiskerItem(1.0, 2.0,
3.0, 4.0, 0.5,
null, -0.5, 5.5,
null), "S1", "C1");
CategoryPlot plot = new CategoryPlot(dataset,
new CategoryAxis("Category"), new NumberAxis("Value"),
new BoxAndWhiskerRenderer());
ChartRenderingInfo info = new ChartRenderingInfo();
JFreeChart chart = new JFreeChart(plot);
/* BufferedImage image = */ chart.createBufferedImage(300, 200,
info);
//FIXME we should assert a value here
}
/**
* Draws a chart where the dataset contains a null min outlier value.
*/
@Test
public void testDrawWithNullMinOutlier() {
DefaultBoxAndWhiskerCategoryDataset dataset
= new DefaultBoxAndWhiskerCategoryDataset();
dataset.add(new BoxAndWhiskerItem(1.0, 2.0,
3.0, 4.0, 0.5,
4.5, null, 5.5,
null), "S1", "C1");
CategoryPlot plot = new CategoryPlot(dataset,
new CategoryAxis("Category"), new NumberAxis("Value"),
new BoxAndWhiskerRenderer());
ChartRenderingInfo info = new ChartRenderingInfo();
JFreeChart chart = new JFreeChart(plot);
/* BufferedImage image = */ chart.createBufferedImage(300, 200,
info);
//FIXME we should assert a value here
}
/**
* Draws a chart where the dataset contains a null max outlier value.
*/
@Test
public void testDrawWithNullMaxOutlier() {
DefaultBoxAndWhiskerCategoryDataset dataset
= new DefaultBoxAndWhiskerCategoryDataset();
dataset.add(new BoxAndWhiskerItem(1.0, 2.0,
3.0, 4.0, 0.5,
4.5, -0.5, null,
new java.util.ArrayList()), "S1", "C1");
CategoryPlot plot = new CategoryPlot(dataset,
new CategoryAxis("Category"), new NumberAxis("Value"),
new BoxAndWhiskerRenderer());
ChartRenderingInfo info = new ChartRenderingInfo();
JFreeChart chart = new JFreeChart(plot);
/* BufferedImage image = */ chart.createBufferedImage(300, 200,
info);
//FIXME we should assert a value here
}
}
| 18,644 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
BarRenderer3DTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/category/BarRenderer3DTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* -----------------------
* BarRenderer3DTests.java
* -----------------------
* (C) Copyright 2003-2012, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 25-Mar-2003 : Version 1 (DG);
* 22-Oct-2003 : Added hashCode test (DG);
* 07-Dec-2006 : Improved testEquals() (DG);
* 23-Apr-2008 : Added testPublicCloneable (DG);
* 17-Jun-2012 : Removed JCommon dependencies (DG);
*
*/
package org.jfree.chart.renderer.category;
import org.jfree.chart.util.PublicCloneable;
import org.junit.Test;
import java.awt.Color;
import java.awt.GradientPaint;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link BarRenderer3D} class.
*/
public class BarRenderer3DTest {
/**
* Check that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
BarRenderer3D r1 = new BarRenderer3D(1.0, 2.0);
BarRenderer3D r2 = new BarRenderer3D(1.0, 2.0);
assertEquals(r1, r2);
r1 = new BarRenderer3D(1.1, 2.0);
assertFalse(r1.equals(r2));
r2 = new BarRenderer3D(1.1, 2.0);
assertEquals(r1, r2);
r1 = new BarRenderer3D(1.1, 2.2);
assertFalse(r1.equals(r2));
r2 = new BarRenderer3D(1.1, 2.2);
assertEquals(r1, r2);
r1.setWallPaint(new GradientPaint(1.0f, 2.0f, Color.RED, 4.0f, 3.0f,
Color.BLUE));
assertFalse(r1.equals(r2));
r2.setWallPaint(new GradientPaint(1.0f, 2.0f, Color.RED, 4.0f, 3.0f,
Color.BLUE));
assertEquals(r1, r2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
BarRenderer3D r1 = new BarRenderer3D();
BarRenderer3D r2 = new BarRenderer3D();
assertEquals(r1, r2);
int h1 = r1.hashCode();
int h2 = r2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
BarRenderer3D r1 = new BarRenderer3D();
BarRenderer3D r2 = (BarRenderer3D) r1.clone();
assertNotSame(r1, r2);
assertSame(r1.getClass(), r2.getClass());
assertEquals(r1, r2);
}
/**
* Check that this class implements PublicCloneable.
*/
@Test
public void testPublicCloneable() {
BarRenderer3D r1 = new BarRenderer3D();
assertTrue(r1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
BarRenderer3D r1 = new BarRenderer3D();
r1.setWallPaint(new GradientPaint(1.0f, 2.0f, Color.RED, 4.0f, 3.0f,
Color.BLUE));
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(r1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
BarRenderer3D r2 = (BarRenderer3D) in.readObject();
in.close();
assertEquals(r1, r2);
}
}
| 4,998 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
StandardBarPainterTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/renderer/category/StandardBarPainterTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ----------------------------
* StandardBarPainterTests.java
* ----------------------------
* (C) Copyright 2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 20-Jun-2008 : Version 1 (DG);
*
*/
package org.jfree.chart.renderer.category;
import org.jfree.chart.util.PublicCloneable;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
/**
* Tests for the {@link StandardBarPainter} class.
*/
public class StandardBarPainterTest {
/**
* Check that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
StandardBarPainter p1 = new StandardBarPainter();
StandardBarPainter p2 = new StandardBarPainter();
assertEquals(p1, p2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
StandardBarPainter p1 = new StandardBarPainter();
StandardBarPainter p2 = new StandardBarPainter();
assertEquals(p1, p2);
int h1 = p1.hashCode();
int h2 = p2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning isn't implemented (it isn't required, because
* instances of the class are immutable).
*/
@Test
public void testCloning() {
StandardBarPainter p1 = new StandardBarPainter();
assertFalse(p1 instanceof Cloneable);
assertFalse(p1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
StandardBarPainter p1 = new StandardBarPainter();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(p1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
StandardBarPainter p2 = (StandardBarPainter) in.readObject();
in.close();
assertEquals(p1, p2);
}
}
| 3,760 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
TextTitleTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/title/TextTitleTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* -------------------
* TextTitleTests.java
* -------------------
* (C) Copyright 2004-2012, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 17-Feb-2004 : Version 1 (DG);
* 06-Jun-2005 : Use GradientPaint in equals() test (DG);
* 07-Oct-2005 : Updated testEquals() (DG);
* 28-Apr-2008 : Extended testEquals() (DG);
* 17-Jun-2012 : Remove JCommon dependencies (DG);
*
*/
package org.jfree.chart.title;
import org.jfree.chart.ui.HorizontalAlignment;
import org.junit.Test;
import java.awt.Color;
import java.awt.Font;
import java.awt.GradientPaint;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
/**
* Tests for the {@link TextTitle} class.
*/
public class TextTitleTest {
/**
* Check that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
TextTitle t1 = new TextTitle();
TextTitle t2 = new TextTitle();
assertEquals(t1, t2);
t1.setText("Test 1");
assertFalse(t1.equals(t2));
t2.setText("Test 1");
assertEquals(t1, t2);
Font f = new Font("SansSerif", Font.PLAIN, 15);
t1.setFont(f);
assertFalse(t1.equals(t2));
t2.setFont(f);
assertEquals(t1, t2);
t1.setTextAlignment(HorizontalAlignment.RIGHT);
assertFalse(t1.equals(t2));
t2.setTextAlignment(HorizontalAlignment.RIGHT);
assertEquals(t1, t2);
// paint
t1.setPaint(new GradientPaint(1.0f, 2.0f, Color.RED,
3.0f, 4.0f, Color.BLUE));
assertFalse(t1.equals(t2));
t2.setPaint(new GradientPaint(1.0f, 2.0f, Color.RED,
3.0f, 4.0f, Color.BLUE));
assertEquals(t1, t2);
// backgroundPaint
t1.setBackgroundPaint(new GradientPaint(4.0f, 3.0f, Color.RED,
2.0f, 1.0f, Color.BLUE));
assertFalse(t1.equals(t2));
t2.setBackgroundPaint(new GradientPaint(4.0f, 3.0f, Color.RED,
2.0f, 1.0f, Color.BLUE));
assertEquals(t1, t2);
// maximumLinesToDisplay
t1.setMaximumLinesToDisplay(3);
assertFalse(t1.equals(t2));
t2.setMaximumLinesToDisplay(3);
assertEquals(t1, t2);
// toolTipText
t1.setToolTipText("TTT");
assertFalse(t1.equals(t2));
t2.setToolTipText("TTT");
assertEquals(t1, t2);
// urlText
t1.setURLText(("URL"));
assertFalse(t1.equals(t2));
t2.setURLText(("URL"));
assertEquals(t1, t2);
// expandToFitSpace
t1.setExpandToFitSpace(!t1.getExpandToFitSpace());
assertFalse(t1.equals(t2));
t2.setExpandToFitSpace(!t2.getExpandToFitSpace());
assertEquals(t1, t2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
TextTitle t1 = new TextTitle();
TextTitle t2 = new TextTitle();
assertEquals(t1, t2);
int h1 = t1.hashCode();
int h2 = t2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
TextTitle t1 = new TextTitle();
TextTitle t2 = (TextTitle) t1.clone();
assertNotSame(t1, t2);
assertSame(t1.getClass(), t2.getClass());
assertEquals(t1, t2);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
TextTitle t1 = new TextTitle("Test");
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(t1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
TextTitle t2 = (TextTitle) in.readObject();
in.close();
assertEquals(t1, t2);
}
}
| 5,752 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
CompositeTitleTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/title/CompositeTitleTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ------------------------
* CompositeTitleTests.java
* ------------------------
* (C) Copyright 2005-2012, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 04-Feb-2005 : Version 1 (DG);
* 09-Jul-2008 : Added new field into testEquals() (DG);
* 17-Jun-2012 : Removed JCommon dependencies (DG);
*
*/
package org.jfree.chart.title;
import org.jfree.chart.block.BlockBorder;
import org.jfree.chart.block.BlockContainer;
import org.jfree.chart.ui.RectangleInsets;
import org.junit.Test;
import java.awt.Color;
import java.awt.GradientPaint;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
/**
* Tests for the {@link CompositeTitle} class.
*/
public class CompositeTitleTest {
/**
* Some checks for the constructor.
*/
@Test
public void testConstructor() {
CompositeTitle t = new CompositeTitle();
assertNull(t.getBackgroundPaint());
}
/**
* Check that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
CompositeTitle t1 = new CompositeTitle(new BlockContainer());
CompositeTitle t2 = new CompositeTitle(new BlockContainer());
assertEquals(t1, t2);
assertEquals(t2, t1);
// margin
t1.setMargin(new RectangleInsets(1.0, 2.0, 3.0, 4.0));
assertFalse(t1.equals(t2));
t2.setMargin(new RectangleInsets(1.0, 2.0, 3.0, 4.0));
assertEquals(t1, t2);
// border
t1.setFrame(new BlockBorder(Color.RED));
assertFalse(t1.equals(t2));
t2.setFrame(new BlockBorder(Color.RED));
assertEquals(t1, t2);
// padding
t1.setPadding(new RectangleInsets(1.0, 2.0, 3.0, 4.0));
assertFalse(t1.equals(t2));
t2.setPadding(new RectangleInsets(1.0, 2.0, 3.0, 4.0));
assertEquals(t1, t2);
// contained titles
t1.getContainer().add(new TextTitle("T1"));
assertFalse(t1.equals(t2));
t2.getContainer().add(new TextTitle("T1"));
assertEquals(t1, t2);
t1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.RED,
3.0f, 4.0f, Color.yellow));
assertFalse(t1.equals(t2));
t2.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.RED,
3.0f, 4.0f, Color.yellow));
assertEquals(t1, t2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
CompositeTitle t1 = new CompositeTitle(new BlockContainer());
t1.getContainer().add(new TextTitle("T1"));
CompositeTitle t2 = new CompositeTitle(new BlockContainer());
t2.getContainer().add(new TextTitle("T1"));
assertEquals(t1, t2);
int h1 = t1.hashCode();
int h2 = t2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
CompositeTitle t1 = new CompositeTitle(new BlockContainer());
t1.getContainer().add(new TextTitle("T1"));
t1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.RED,
3.0f, 4.0f, Color.yellow));
CompositeTitle t2 = (CompositeTitle) t1.clone();
assertNotSame(t1, t2);
assertSame(t1.getClass(), t2.getClass());
assertEquals(t1, t2);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
CompositeTitle t1 = new CompositeTitle(new BlockContainer());
t1.getContainer().add(new TextTitle("T1"));
t1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.RED,
3.0f, 4.0f, Color.BLUE));
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(t1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
CompositeTitle t2 = (CompositeTitle) in.readObject();
in.close();
assertEquals(t1, t2);
}
}
| 5,970 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
ShortTextTitleTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/title/ShortTextTitleTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ------------------------
* ShortTextTitleTests.java
* ------------------------
* (C) Copyright 2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 05-May-2008 : Version 1 (DG);
*
*/
package org.jfree.chart.title;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
/**
* Tests for the {@link ShortTextTitle} class.
*/
public class ShortTextTitleTest {
/**
* Check that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
ShortTextTitle t1 = new ShortTextTitle("ABC");
ShortTextTitle t2 = new ShortTextTitle("ABC");
assertEquals(t1, t2);
t1.setText("Test 1");
assertFalse(t1.equals(t2));
t2.setText("Test 1");
assertEquals(t1, t2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
ShortTextTitle t1 = new ShortTextTitle("ABC");
ShortTextTitle t2 = new ShortTextTitle("ABC");
assertEquals(t1, t2);
int h1 = t1.hashCode();
int h2 = t2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
ShortTextTitle t1 = new ShortTextTitle("ABC");
ShortTextTitle t2 = (ShortTextTitle) t1.clone();
assertNotSame(t1, t2);
assertSame(t1.getClass(), t2.getClass());
assertEquals(t1, t2);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
ShortTextTitle t1 = new ShortTextTitle("ABC");
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(t1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
ShortTextTitle t2 = (ShortTextTitle) in.readObject();
in.close();
assertEquals(t1, t2);
}
}
| 3,897 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
TitleTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/title/TitleTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ---------------
* TitleTests.java
* ---------------
* (C) Copyright 2004-2012, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 17-Feb-2004 : Version 1 (DG);
* 18-Sep-2008 : Updated testEquals() (DG);
* 17-Jun-2012 : Removed JCommon dependencies (DG);
*
*/
package org.jfree.chart.title;
import org.jfree.chart.ui.HorizontalAlignment;
import org.jfree.chart.ui.RectangleEdge;
import org.jfree.chart.ui.VerticalAlignment;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
/**
* Tests for the abstract {@link Title} class.
*/
public class TitleTest {
/**
* Some checks for the equals() method.
*/
@Test
public void testEquals() {
// use the TextTitle class because it is a concrete subclass
Title t1 = new TextTitle();
Title t2 = new TextTitle();
assertEquals(t1, t2);
t1.setPosition(RectangleEdge.LEFT);
assertFalse(t1.equals(t2));
t2.setPosition(RectangleEdge.LEFT);
assertEquals(t1, t2);
t1.setHorizontalAlignment(HorizontalAlignment.RIGHT);
assertFalse(t1.equals(t2));
t2.setHorizontalAlignment(HorizontalAlignment.RIGHT);
assertEquals(t1, t2);
t1.setVerticalAlignment(VerticalAlignment.BOTTOM);
assertFalse(t1.equals(t2));
t2.setVerticalAlignment(VerticalAlignment.BOTTOM);
assertEquals(t1, t2);
t1.setVisible(false);
assertFalse(t1.equals(t2));
t2.setVisible(false);
assertEquals(t1, t2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
TextTitle t1 = new TextTitle();
TextTitle t2 = new TextTitle();
assertEquals(t1, t2);
int h1 = t1.hashCode();
int h2 = t2.hashCode();
assertEquals(h1, h2);
}
}
| 3,262 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
DateTitleTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/title/DateTitleTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* -------------------
* DateTitleTests.java
* -------------------
* (C) Copyright 2004-2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 17-Feb-2004 : Version 1 (DG);
*
*/
package org.jfree.chart.title;
import org.junit.Test;
import java.awt.Color;
import java.awt.Font;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
/**
* Tests for the {@link DateTitle} class.
*/
public class DateTitleTest {
/**
* Check that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
DateTitle t1 = new DateTitle();
DateTitle t2 = new DateTitle();
assertEquals(t1, t2);
t1.setText("Test 1");
assertFalse(t1.equals(t2));
t2.setText("Test 1");
assertEquals(t1, t2);
Font f = new Font("SansSerif", Font.PLAIN, 15);
t1.setFont(f);
assertFalse(t1.equals(t2));
t2.setFont(f);
assertEquals(t1, t2);
t1.setPaint(Color.BLUE);
assertFalse(t1.equals(t2));
t2.setPaint(Color.BLUE);
assertEquals(t1, t2);
t1.setBackgroundPaint(Color.BLUE);
assertFalse(t1.equals(t2));
t2.setBackgroundPaint(Color.BLUE);
assertEquals(t1, t2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
DateTitle t1 = new DateTitle();
DateTitle t2 = new DateTitle();
assertEquals(t1, t2);
int h1 = t1.hashCode();
int h2 = t2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
DateTitle t1 = new DateTitle();
DateTitle t2 = (DateTitle) t1.clone();
assertNotSame(t1, t2);
assertSame(t1.getClass(), t2.getClass());
assertEquals(t1, t2);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
DateTitle t1 = new DateTitle();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(t1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
DateTitle t2 = (DateTitle) in.readObject();
in.close();
assertEquals(t1, t2);
}
}
| 4,268 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
LegendGraphicTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/title/LegendGraphicTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* -----------------------
* LegendGraphicTests.java
* -----------------------
* (C) Copyright 2005-2012, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 01-Sep-2005 : Version 1 (DG);
* 17-Jun-2012 : Removed JCommon dependencies (DG);
*
*/
package org.jfree.chart.title;
import org.jfree.chart.ui.GradientPaintTransformType;
import org.jfree.chart.ui.RectangleAnchor;
import org.jfree.chart.ui.StandardGradientPaintTransformer;
import org.junit.Test;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Rectangle;
import java.awt.Stroke;
import java.awt.geom.Line2D;
import java.awt.geom.Rectangle2D;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
/**
* Tests for the {@link LegendGraphic} class.
*/
public class LegendGraphicTest {
/**
* Check that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
LegendGraphic g1 = new LegendGraphic(new Rectangle2D.Double(1.0, 2.0,
3.0, 4.0), Color.BLACK);
LegendGraphic g2 = new LegendGraphic(new Rectangle2D.Double(1.0, 2.0,
3.0, 4.0), Color.BLACK);
assertEquals(g1, g2);
assertEquals(g2, g1);
// shapeVisible
g1.setShapeVisible(!g1.isShapeVisible());
assertFalse(g1.equals(g2));
g2.setShapeVisible(!g2.isShapeVisible());
assertEquals(g1, g2);
// shape
g1.setShape(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0));
assertFalse(g1.equals(g2));
g2.setShape(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0));
assertEquals(g1, g2);
// shapeFilled
g1.setShapeFilled(!g1.isShapeFilled());
assertFalse(g1.equals(g2));
g2.setShapeFilled(!g2.isShapeFilled());
assertEquals(g1, g2);
// fillPaint
g1.setFillPaint(Color.green);
assertFalse(g1.equals(g2));
g2.setFillPaint(Color.green);
assertEquals(g1, g2);
// shapeOutlineVisible
g1.setShapeOutlineVisible(!g1.isShapeOutlineVisible());
assertFalse(g1.equals(g2));
g2.setShapeOutlineVisible(!g2.isShapeOutlineVisible());
assertEquals(g1, g2);
// outlinePaint
g1.setOutlinePaint(Color.green);
assertFalse(g1.equals(g2));
g2.setOutlinePaint(Color.green);
assertEquals(g1, g2);
// outlineStroke
g1.setOutlineStroke(new BasicStroke(1.23f));
assertFalse(g1.equals(g2));
g2.setOutlineStroke(new BasicStroke(1.23f));
assertEquals(g1, g2);
// shapeAnchor
g1.setShapeAnchor(RectangleAnchor.BOTTOM_RIGHT);
assertFalse(g1.equals(g2));
g2.setShapeAnchor(RectangleAnchor.BOTTOM_RIGHT);
assertEquals(g1, g2);
// shapeLocation
g1.setShapeLocation(RectangleAnchor.BOTTOM_RIGHT);
assertFalse(g1.equals(g2));
g2.setShapeLocation(RectangleAnchor.BOTTOM_RIGHT);
assertEquals(g1, g2);
// lineVisible
g1.setLineVisible(!g1.isLineVisible());
assertFalse(g1.equals(g2));
g2.setLineVisible(!g2.isLineVisible());
assertEquals(g1, g2);
// line
g1.setLine(new Line2D.Double(1.0, 2.0, 3.0, 4.0));
assertFalse(g1.equals(g2));
g2.setLine(new Line2D.Double(1.0, 2.0, 3.0, 4.0));
assertEquals(g1, g2);
// linePaint
g1.setLinePaint(Color.green);
assertFalse(g1.equals(g2));
g2.setLinePaint(Color.green);
assertEquals(g1, g2);
// lineStroke
g1.setLineStroke(new BasicStroke(1.23f));
assertFalse(g1.equals(g2));
g2.setLineStroke(new BasicStroke(1.23f));
assertEquals(g1, g2);
// fillPaintTransformer
g1.setFillPaintTransformer(new StandardGradientPaintTransformer(
GradientPaintTransformType.CENTER_HORIZONTAL));
assertFalse(g1.equals(g2));
g2.setFillPaintTransformer(new StandardGradientPaintTransformer(
GradientPaintTransformType.CENTER_HORIZONTAL));
assertEquals(g1, g2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
LegendGraphic g1 = new LegendGraphic(new Rectangle2D.Double(1.0, 2.0,
3.0, 4.0), Color.BLACK);
LegendGraphic g2 = new LegendGraphic(new Rectangle2D.Double(1.0, 2.0,
3.0, 4.0), Color.BLACK);
assertEquals(g1, g2);
int h1 = g1.hashCode();
int h2 = g2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
Rectangle r = new Rectangle(1, 2, 3, 4);
LegendGraphic g1 = new LegendGraphic(r, Color.BLACK);
LegendGraphic g2 = (LegendGraphic) g1.clone();
assertNotSame(g1, g2);
assertSame(g1.getClass(), g2.getClass());
assertEquals(g1, g2);
// check independence
r.setBounds(4, 3, 2, 1);
assertFalse(g1.equals(g2));
}
/**
* A test for cloning - checks that the line shape is cloned correctly.
*/
@Test
public void testCloning2() throws CloneNotSupportedException {
Rectangle r = new Rectangle(1, 2, 3, 4);
LegendGraphic g1 = new LegendGraphic(r, Color.BLACK);
Line2D l = new Line2D.Double(1.0, 2.0, 3.0, 4.0);
g1.setLine(l);
LegendGraphic g2 = (LegendGraphic) g1.clone();
assertNotSame(g1, g2);
assertSame(g1.getClass(), g2.getClass());
assertEquals(g1, g2);
// check independence
l.setLine(4.0, 3.0, 2.0, 1.0);
assertFalse(g1.equals(g2));
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
Stroke s = new BasicStroke(1.23f);
LegendGraphic g1 = new LegendGraphic(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), Color.BLACK);
g1.setOutlineStroke(s);
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(g1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
LegendGraphic g2 = (LegendGraphic) in.readObject();
in.close();
assertEquals(g1, g2);
}
}
| 8,225 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
LegendTitleTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/title/LegendTitleTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ---------------------
* LegendTitleTests.java
* ---------------------
* (C) Copyright 2005-2012, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 25-Feb-2005 : Version 1 (DG);
* 16-Mar-2005 : Extended testEquals() (DG);
* 11-Mar-2012 : Extended testEquals() (MH);
* 17-Jun-2012 : Removed JCommon dependencies (DG);
*
*/
package org.jfree.chart.title;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.ui.RectangleAnchor;
import org.jfree.chart.ui.RectangleEdge;
import org.jfree.chart.util.SortOrder;
import org.junit.Test;
import java.awt.Color;
import java.awt.Font;
import java.awt.GradientPaint;
import java.awt.geom.Rectangle2D;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
/**
* Some tests for the {@link LegendTitle} class.
*/
public class LegendTitleTest {
/**
* Check that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
XYPlot plot1 = new XYPlot();
LegendTitle t1 = new LegendTitle(plot1);
LegendTitle t2 = new LegendTitle(plot1);
assertEquals(t1, t2);
t1.setBackgroundPaint(
new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.yellow)
);
assertFalse(t1.equals(t2));
t2.setBackgroundPaint(
new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.yellow)
);
assertEquals(t1, t2);
t1.setLegendItemGraphicEdge(RectangleEdge.BOTTOM);
assertFalse(t1.equals(t2));
t2.setLegendItemGraphicEdge(RectangleEdge.BOTTOM);
assertEquals(t1, t2);
t1.setLegendItemGraphicAnchor(RectangleAnchor.BOTTOM_LEFT);
assertFalse(t1.equals(t2));
t2.setLegendItemGraphicAnchor(RectangleAnchor.BOTTOM_LEFT);
assertEquals(t1, t2);
t1.setLegendItemGraphicLocation(RectangleAnchor.TOP_LEFT);
assertFalse(t1.equals(t2));
t2.setLegendItemGraphicLocation(RectangleAnchor.TOP_LEFT);
assertEquals(t1, t2);
t1.setItemFont(new Font("Dialog", Font.PLAIN, 19));
assertFalse(t1.equals(t2));
t2.setItemFont(new Font("Dialog", Font.PLAIN, 19));
assertEquals(t1, t2);
t1.setSortOrder(SortOrder.DESCENDING);
assertFalse(t1.equals(t2));
t2.setSortOrder(SortOrder.DESCENDING);
assertEquals(t1, t2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
XYPlot plot1 = new XYPlot();
LegendTitle t1 = new LegendTitle(plot1);
LegendTitle t2 = new LegendTitle(plot1);
assertEquals(t1, t2);
int h1 = t1.hashCode();
int h2 = t2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
XYPlot plot = new XYPlot();
Rectangle2D bounds1 = new Rectangle2D.Double(10.0, 20.0, 30.0, 40.0);
LegendTitle t1 = new LegendTitle(plot);
t1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f,
4.0f, Color.yellow));
t1.setBounds(bounds1);
LegendTitle t2 = (LegendTitle) t1.clone();
assertNotSame(t1, t2);
assertSame(t1.getClass(), t2.getClass());
assertEquals(t1, t2);
// check independence
bounds1.setFrame(40.0, 30.0, 20.0, 10.0);
assertFalse(t1.equals(t2));
t2.setBounds(new Rectangle2D.Double(40.0, 30.0, 20.0, 10.0));
assertEquals(t1, t2);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
XYPlot plot = new XYPlot();
LegendTitle t1 = new LegendTitle(plot);
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(t1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray())
);
LegendTitle t2 = (LegendTitle) in.readObject();
in.close();
assertEquals(t1, t2);
assertEquals(t2.getSources()[0], plot);
}
}
| 6,013 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
ImageTitleTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/title/ImageTitleTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2013, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* --------------------
* ImageTitleTests.java
* --------------------
* (C) Copyright 2004-2013, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 17-Feb-2004 : Version 1 (DG);
* 21-Mar-2008 : Added tests for arrange method (DG);
*
*/
package org.jfree.chart.title;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.ui.Size2D;
import org.junit.Test;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URL;
import javax.swing.ImageIcon;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
/**
* Tests for the {@link ImageTitle} class.
*/
public class ImageTitleTest {
private Image testImage;
private Image getTestImage() {
if (testImage == null) {
URL imageURL = getClass().getClassLoader().getResource(
"org/jfree/chart/gorilla.jpg");
if (imageURL != null) {
ImageIcon temp = new ImageIcon(imageURL);
// use ImageIcon because it waits for the image to load...
testImage = temp.getImage();
}
}
return testImage;
}
/**
* Check that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
ImageTitle t1 = new ImageTitle(getTestImage());
ImageTitle t2 = new ImageTitle(getTestImage());
assertEquals(t1, t2);
t1.setImage(new BufferedImage(2, 1, BufferedImage.TYPE_INT_RGB));
assertFalse(t1.equals(t2));
t2.setImage(new BufferedImage(2, 1, BufferedImage.TYPE_INT_RGB));
// images considered equal only if they're the SAME object
// TODO: is there a way to do a better test?
assertFalse(t1.equals(t2));
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
ImageTitle t1 = new ImageTitle(getTestImage());
ImageTitle t2 = new ImageTitle(getTestImage());
assertEquals(t1, t2);
int h1 = t1.hashCode();
int h2 = t2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
ImageTitle t1 = new ImageTitle(getTestImage());
ImageTitle t2 = (ImageTitle) t1.clone();
assertNotSame(t1, t2);
assertSame(t1.getClass(), t2.getClass());
assertEquals(t1, t2);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
// TODO: add serialization support for images
}
private static final double EPSILON = 0.00000001;
/**
* Check the width and height.
*/
@Test
public void testWidthAndHeight() {
ImageTitle t1 = new ImageTitle(getTestImage());
assertEquals(100, t1.getWidth(), EPSILON);
assertEquals(100, t1.getHeight(), EPSILON);
}
/**
* Some checks for the arrange method.
*/
@Test
public void testArrangeNN() {
BufferedImage image = new BufferedImage(100, 100,
BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = image.createGraphics();
ImageTitle t = new ImageTitle(getTestImage());
Size2D s = t.arrange(g2);
assertEquals(102.0, s.getWidth(), EPSILON);
assertEquals(102.0, s.getHeight(), EPSILON);
t.setPadding(1.0, 2.0, 3.0, 4.0);
s = t.arrange(g2);
assertEquals(106.0, s.getWidth(), EPSILON);
assertEquals(104.0, s.getHeight(), EPSILON);
t.setMargin(5.0, 6.0, 7.0, 8.0);
s = t.arrange(g2);
assertEquals(120.0, s.getWidth(), EPSILON);
assertEquals(116.0, s.getHeight(), EPSILON);
}
}
| 5,325 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
PaintScaleLegendTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/title/PaintScaleLegendTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* --------------------------
* PaintScaleLegendTests.java
* --------------------------
* (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 22-Jan-2007 : Version 1 (DG);
* 18-Jun-2008 : Extended testEquals() for new field (DG);
*
*/
package org.jfree.chart.title;
import org.jfree.chart.axis.AxisLocation;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.renderer.GrayPaintScale;
import org.jfree.chart.renderer.LookupPaintScale;
import org.junit.Test;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.GradientPaint;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
/**
* Tests for the {@link PaintScaleLegend} class.
*/
public class PaintScaleLegendTest {
/**
* Test that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
// default instances
PaintScaleLegend l1 = new PaintScaleLegend(new GrayPaintScale(),
new NumberAxis("X"));
PaintScaleLegend l2 = new PaintScaleLegend(new GrayPaintScale(),
new NumberAxis("X"));
assertEquals(l1, l2);
assertEquals(l2, l1);
// paintScale
l1.setScale(new LookupPaintScale());
assertFalse(l1.equals(l2));
l2.setScale(new LookupPaintScale());
assertEquals(l1, l2);
// axis
l1.setAxis(new NumberAxis("Axis 2"));
assertFalse(l1.equals(l2));
l2.setAxis(new NumberAxis("Axis 2"));
assertEquals(l1, l2);
// axisLocation
l1.setAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);
assertFalse(l1.equals(l2));
l2.setAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);
assertEquals(l1, l2);
// axisOffset
l1.setAxisOffset(99.0);
assertFalse(l1.equals(l2));
l2.setAxisOffset(99.0);
assertEquals(l1, l2);
// stripWidth
l1.setStripWidth(99.0);
assertFalse(l1.equals(l2));
l2.setStripWidth(99.0);
assertEquals(l1, l2);
// stripOutlineVisible
l1.setStripOutlineVisible(!l1.isStripOutlineVisible());
assertFalse(l1.equals(l2));
l2.setStripOutlineVisible(l1.isStripOutlineVisible());
assertEquals(l1, l2);
// stripOutlinePaint
l1.setStripOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.RED,
3.0f, 4.0f, Color.BLUE));
assertFalse(l1.equals(l2));
l2.setStripOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.RED,
3.0f, 4.0f, Color.BLUE));
assertEquals(l1, l2);
// stripOutlineStroke
l1.setStripOutlineStroke(new BasicStroke(1.1f));
assertFalse(l1.equals(l2));
l2.setStripOutlineStroke(new BasicStroke(1.1f));
assertEquals(l1, l2);
// backgroundPaint
l1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.RED,
3.0f, 4.0f, Color.BLUE));
assertFalse(l1.equals(l2));
l2.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.RED,
3.0f, 4.0f, Color.BLUE));
assertEquals(l1, l2);
l1.setSubdivisionCount(99);
assertFalse(l1.equals(l2));
l2.setSubdivisionCount(99);
assertEquals(l1, l2);
}
/**
* Two objects that are equal are required to return the same hashCode.
*/
@Test
public void testHashcode() {
PaintScaleLegend l1 = new PaintScaleLegend(new GrayPaintScale(),
new NumberAxis("X"));
PaintScaleLegend l2 = new PaintScaleLegend(new GrayPaintScale(),
new NumberAxis("X"));
assertEquals(l1, l2);
int h1 = l1.hashCode();
int h2 = l2.hashCode();
assertEquals(h1, h2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
PaintScaleLegend l1 = new PaintScaleLegend(new GrayPaintScale(),
new NumberAxis("X"));
PaintScaleLegend l2 = (PaintScaleLegend) l1.clone();
assertNotSame(l1, l2);
assertSame(l1.getClass(), l2.getClass());
assertEquals(l1, l2);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
PaintScaleLegend l1 = new PaintScaleLegend(new GrayPaintScale(),
new NumberAxis("X"));
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(l1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
PaintScaleLegend l2 = (PaintScaleLegend) in.readObject();
in.close();
assertEquals(l1, l2);
}
}
| 6,596 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
StandardXYZToolTipGeneratorTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/labels/StandardXYZToolTipGeneratorTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* -------------------------------------
* StandardXYZToolTipGeneratorTests.java
* -------------------------------------
* (C) Copyright 2003-2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 23-Mar-2003 : Version 1 (DG);
* 23-Apr-2008 : Added testPublicCloneable() (DG);
*
*/
package org.jfree.chart.labels;
import org.jfree.chart.util.PublicCloneable;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link StandardXYZToolTipGenerator} class.
*/
public class StandardXYZToolTipGeneratorTest {
/**
* Tests that the equals() method can distinguish all fields.
*/
@Test
public void testEquals() {
// some setup...
String f1 = "{1}";
String f2 = "{2}";
NumberFormat xnf1 = new DecimalFormat("0.00");
NumberFormat xnf2 = new DecimalFormat("0.000");
NumberFormat ynf1 = new DecimalFormat("0.00");
NumberFormat ynf2 = new DecimalFormat("0.000");
NumberFormat znf1 = new DecimalFormat("0.00");
NumberFormat znf2 = new DecimalFormat("0.000");
DateFormat xdf1 = new SimpleDateFormat("d-MMM");
DateFormat xdf2 = new SimpleDateFormat("d-MMM-yyyy");
DateFormat ydf1 = new SimpleDateFormat("d-MMM");
DateFormat ydf2 = new SimpleDateFormat("d-MMM-yyyy");
DateFormat zdf1 = new SimpleDateFormat("d-MMM");
DateFormat zdf2 = new SimpleDateFormat("d-MMM-yyyy");
StandardXYZToolTipGenerator g1;
StandardXYZToolTipGenerator g2;
g1 = new StandardXYZToolTipGenerator(f1, xnf1, ynf1, znf1);
g2 = new StandardXYZToolTipGenerator(f1, xnf1, ynf1, znf1);
assertEquals(g1, g2);
// format string...
g1 = new StandardXYZToolTipGenerator(f2, xnf1, ynf1, znf1);
assertFalse(g1.equals(g2));
g2 = new StandardXYZToolTipGenerator(f2, xnf1, ynf1, znf1);
assertEquals(g1, g2);
// x number format
g1 = new StandardXYZToolTipGenerator(f2, xnf2, ynf1, znf1);
assertFalse(g1.equals(g2));
g2 = new StandardXYZToolTipGenerator(f2, xnf2, ynf1, znf1);
assertEquals(g1, g2);
// y number format
g1 = new StandardXYZToolTipGenerator(f2, xnf2, ynf2, znf1);
assertFalse(g1.equals(g2));
g2 = new StandardXYZToolTipGenerator(f2, xnf2, ynf2, znf1);
assertEquals(g1, g2);
// z number format
g1 = new StandardXYZToolTipGenerator(f2, xnf2, ynf2, znf2);
assertFalse(g1.equals(g2));
g2 = new StandardXYZToolTipGenerator(f2, xnf2, ynf2, znf2);
assertEquals(g1, g2);
g1 = new StandardXYZToolTipGenerator(f2, xdf1, ydf1, zdf1);
g2 = new StandardXYZToolTipGenerator(f2, xdf1, ydf1, zdf1);
assertEquals(g1, g2);
// x date format
g1 = new StandardXYZToolTipGenerator(f2, xdf2, ydf1, zdf1);
assertFalse(g1.equals(g2));
g2 = new StandardXYZToolTipGenerator(f2, xdf2, ydf1, zdf1);
assertEquals(g1, g2);
// y date format
g1 = new StandardXYZToolTipGenerator(f2, xdf2, ydf2, zdf1);
assertFalse(g1.equals(g2));
g2 = new StandardXYZToolTipGenerator(f2, xdf2, ydf2, zdf1);
assertEquals(g1, g2);
// z date format
g1 = new StandardXYZToolTipGenerator(f2, xdf2, ydf2, zdf2);
assertFalse(g1.equals(g2));
g2 = new StandardXYZToolTipGenerator(f2, xdf2, ydf2, zdf2);
assertEquals(g1, g2);
}
/**
* Simple check that hashCode is implemented.
*/
@Test
public void testHashCode() {
StandardXYZToolTipGenerator g1
= new StandardXYZToolTipGenerator();
StandardXYZToolTipGenerator g2
= new StandardXYZToolTipGenerator();
assertEquals(g1, g2);
assertEquals(g1.hashCode(), g2.hashCode());
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
StandardXYZToolTipGenerator g1 = new StandardXYZToolTipGenerator();
StandardXYZToolTipGenerator g2 = (StandardXYZToolTipGenerator) g1.clone();
assertNotSame(g1, g2);
assertSame(g1.getClass(), g2.getClass());
assertEquals(g1, g2);
}
/**
* Check to ensure that this class implements PublicCloneable.
*/
@Test
public void testPublicCloneable() {
StandardXYZToolTipGenerator g1 = new StandardXYZToolTipGenerator();
assertTrue(g1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
StandardXYZToolTipGenerator g1 = new StandardXYZToolTipGenerator();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(g1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
StandardXYZToolTipGenerator g2 = (StandardXYZToolTipGenerator) in.readObject();
in.close();
assertEquals(g1, g2);
}
}
| 7,099 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
ItemLabelAnchorTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/labels/ItemLabelAnchorTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* -------------------------
* ItemLabelAnchorTests.java
* -------------------------
* (C) Copyright 2004, 2007, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 19-Feb-2004 : Version 1 (DG);
*
*/
package org.jfree.chart.labels;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertSame;
/**
* Tests for the {@link ItemLabelAnchor} class.
*/
public class ItemLabelAnchorTest {
/**
* Test the equals() method.
*/
@Test
public void testEquals() {
assertEquals(ItemLabelAnchor.INSIDE1, ItemLabelAnchor.INSIDE1);
assertFalse(ItemLabelAnchor.INSIDE1.equals(ItemLabelAnchor.INSIDE2));
}
/**
* Serialize an instance, restore it, and check for identity.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
ItemLabelAnchor a1 = ItemLabelAnchor.INSIDE1;
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(a1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
ItemLabelAnchor a2 = (ItemLabelAnchor) in.readObject();
in.close();
assertSame(a1, a2);
}
}
| 2,950 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
SymbolicXYItemLabelGeneratorTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/labels/SymbolicXYItemLabelGeneratorTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* --------------------------------------
* SymbolicXYItemLabelGeneratorTests.java
* --------------------------------------
* (C) Copyright 2003-2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 13-Aug-2003 : Version 1 (DG);
* 23-Apr-2008 : Added testPublicCloneable() (DG);
*
*/
package org.jfree.chart.labels;
import org.jfree.chart.util.PublicCloneable;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link SymbolicXYItemLabelGenerator} class.
*/
public class SymbolicXYItemLabelGeneratorTest {
/**
* Tests the equals method.
*/
@Test
public void testEquals() {
SymbolicXYItemLabelGenerator g1 = new SymbolicXYItemLabelGenerator();
SymbolicXYItemLabelGenerator g2 = new SymbolicXYItemLabelGenerator();
assertEquals(g1, g2);
assertEquals(g2, g1);
}
/**
* Simple check that hashCode is implemented.
*/
@Test
public void testHashCode() {
SymbolicXYItemLabelGenerator g1
= new SymbolicXYItemLabelGenerator();
SymbolicXYItemLabelGenerator g2
= new SymbolicXYItemLabelGenerator();
assertEquals(g1, g2);
assertSame(g1.hashCode(), g2.hashCode());
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
SymbolicXYItemLabelGenerator g1 = new SymbolicXYItemLabelGenerator();
SymbolicXYItemLabelGenerator g2 = (SymbolicXYItemLabelGenerator) g1.clone();
assertNotSame(g1, g2);
assertSame(g1.getClass(), g2.getClass());
assertEquals(g1, g2);
}
/**
* Check to ensure that this class implements PublicCloneable.
*/
@Test
public void testPublicCloneable() {
SymbolicXYItemLabelGenerator g1 = new SymbolicXYItemLabelGenerator();
assertTrue(g1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
SymbolicXYItemLabelGenerator g1 = new SymbolicXYItemLabelGenerator();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(g1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
SymbolicXYItemLabelGenerator g2 = (SymbolicXYItemLabelGenerator) in.readObject();
in.close();
assertEquals(g1, g2);
}
}
| 4,334 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
StandardXYToolTipGeneratorTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/labels/StandardXYToolTipGeneratorTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ------------------------------------
* StandardXYToolTipGeneratorTests.java
* ------------------------------------
* (C) Copyright 2004-2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 11-May-2004 : Version 1 (DG);
* 23-Apr-2008 : Added testPublicCloneable() (DG);
*
*/
package org.jfree.chart.labels;
import org.jfree.chart.util.PublicCloneable;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link StandardXYToolTipGenerator} class.
*/
public class StandardXYToolTipGeneratorTest {
/**
* Tests the equals() method.
*/
@Test
public void testEquals() {
// some setup...
String f1 = "{1}";
String f2 = "{2}";
NumberFormat xnf1 = new DecimalFormat("0.00");
NumberFormat xnf2 = new DecimalFormat("0.000");
NumberFormat ynf1 = new DecimalFormat("0.00");
NumberFormat ynf2 = new DecimalFormat("0.000");
StandardXYToolTipGenerator g1;
StandardXYToolTipGenerator g2;
g1 = new StandardXYToolTipGenerator(f1, xnf1, ynf1);
g2 = new StandardXYToolTipGenerator(f1, xnf1, ynf1);
assertEquals(g1, g2);
assertEquals(g2, g1);
g1 = new StandardXYToolTipGenerator(f2, xnf1, ynf1);
assertFalse(g1.equals(g2));
g2 = new StandardXYToolTipGenerator(f2, xnf1, ynf1);
assertEquals(g1, g2);
g1 = new StandardXYToolTipGenerator(f2, xnf2, ynf1);
assertFalse(g1.equals(g2));
g2 = new StandardXYToolTipGenerator(f2, xnf2, ynf1);
assertEquals(g1, g2);
g1 = new StandardXYToolTipGenerator(f2, xnf2, ynf2);
assertFalse(g1.equals(g2));
g2 = new StandardXYToolTipGenerator(f2, xnf2, ynf2);
assertEquals(g1, g2);
DateFormat xdf1 = new SimpleDateFormat("d-MMM");
DateFormat xdf2 = new SimpleDateFormat("d-MMM-yyyy");
DateFormat ydf1 = new SimpleDateFormat("d-MMM");
DateFormat ydf2 = new SimpleDateFormat("d-MMM-yyyy");
g1 = new StandardXYToolTipGenerator(f1, xdf1, ydf1);
g2 = new StandardXYToolTipGenerator(f1, xdf1, ydf1);
assertEquals(g1, g2);
assertEquals(g2, g1);
g1 = new StandardXYToolTipGenerator(f1, xdf2, ydf1);
assertFalse(g1.equals(g2));
g2 = new StandardXYToolTipGenerator(f1, xdf2, ydf1);
assertEquals(g1, g2);
g1 = new StandardXYToolTipGenerator(f1, xdf2, ydf2);
assertFalse(g1.equals(g2));
g2 = new StandardXYToolTipGenerator(f1, xdf2, ydf2);
assertEquals(g1, g2);
}
/**
* Simple check that hashCode is implemented.
*/
@Test
public void testHashCode() {
StandardXYToolTipGenerator g1
= new StandardXYToolTipGenerator();
StandardXYToolTipGenerator g2
= new StandardXYToolTipGenerator();
assertEquals(g1, g2);
assertEquals(g1.hashCode(), g2.hashCode());
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
StandardXYToolTipGenerator g1 = new StandardXYToolTipGenerator();
StandardXYToolTipGenerator g2 = (StandardXYToolTipGenerator) g1.clone();
assertNotSame(g1, g2);
assertSame(g1.getClass(), g2.getClass());
assertEquals(g1, g2);
}
/**
* Check to ensure that this class implements PublicCloneable.
*/
@Test
public void testPublicCloneable() {
StandardXYToolTipGenerator g1 = new StandardXYToolTipGenerator();
assertTrue(g1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
StandardXYToolTipGenerator g1 = new StandardXYToolTipGenerator();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(g1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
StandardXYToolTipGenerator g2 = (StandardXYToolTipGenerator) in.readObject();
in.close();
assertEquals(g1, g2);
}
}
| 6,188 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
StandardCategoryToolTipGeneratorTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/labels/StandardCategoryToolTipGeneratorTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ------------------------------------------
* StandardCategoryToolTipGeneratorTests.java
* ------------------------------------------
* (C) Copyright 2004-2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 11-May-2004 : Version 1 (DG);
* ------------- JFREECHART 1.0.x ---------------------------------------------
* 03-May-2006 : Added testEquals1481087() (DG);
* 23-Apr-2008 : Added testPublicCloneable() (DG);
*
*/
package org.jfree.chart.labels;
import org.jfree.chart.util.PublicCloneable;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link StandardCategoryToolTipGenerator} class.
*/
public class StandardCategoryToolTipGeneratorTest {
/**
* Tests the equals() method.
*/
@Test
public void testEquals() {
StandardCategoryToolTipGenerator g1
= new StandardCategoryToolTipGenerator();
StandardCategoryToolTipGenerator g2
= new StandardCategoryToolTipGenerator();
assertEquals(g1, g2);
assertEquals(g2, g1);
g1 = new StandardCategoryToolTipGenerator("{0}",
new DecimalFormat("0.000"));
assertFalse(g1.equals(g2));
g2 = new StandardCategoryToolTipGenerator("{0}",
new DecimalFormat("0.000"));
assertEquals(g1, g2);
g1 = new StandardCategoryToolTipGenerator("{1}",
new DecimalFormat("0.000"));
assertFalse(g1.equals(g2));
g2 = new StandardCategoryToolTipGenerator("{1}",
new DecimalFormat("0.000"));
assertEquals(g1, g2);
g1 = new StandardCategoryToolTipGenerator("{2}",
new SimpleDateFormat("d-MMM"));
assertFalse(g1.equals(g2));
g2 = new StandardCategoryToolTipGenerator("{2}",
new SimpleDateFormat("d-MMM"));
assertEquals(g1, g2);
}
/**
* Simple check that hashCode is implemented.
*/
@Test
public void testHashCode() {
StandardCategoryToolTipGenerator g1
= new StandardCategoryToolTipGenerator();
StandardCategoryToolTipGenerator g2
= new StandardCategoryToolTipGenerator();
assertEquals(g1, g2);
assertEquals(g1.hashCode(), g2.hashCode());
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
StandardCategoryToolTipGenerator g1
= new StandardCategoryToolTipGenerator();
StandardCategoryToolTipGenerator g2 = (StandardCategoryToolTipGenerator) g1.clone();
assertNotSame(g1, g2);
assertSame(g1.getClass(), g2.getClass());
assertEquals(g1, g2);
}
/**
* Check to ensure that this class implements PublicCloneable.
*/
@Test
public void testPublicCloneable() {
StandardCategoryToolTipGenerator g1
= new StandardCategoryToolTipGenerator();
assertTrue(g1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
StandardCategoryToolTipGenerator g1
= new StandardCategoryToolTipGenerator("{2}",
DateFormat.getInstance());
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(g1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
StandardCategoryToolTipGenerator g2 = (StandardCategoryToolTipGenerator) in.readObject();
in.close();
assertEquals(g1, g2);
}
/**
* A test for bug 1481087.
*/
@Test
public void testEquals1481087() {
StandardCategoryToolTipGenerator g1
= new StandardCategoryToolTipGenerator("{0}",
new DecimalFormat("0.00"));
StandardCategoryItemLabelGenerator g2
= new StandardCategoryItemLabelGenerator("{0}",
new DecimalFormat("0.00"));
assertFalse(g1.equals(g2));
}
}
| 6,088 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
BoxAndWhiskerXYToolTipGeneratorTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/labels/BoxAndWhiskerXYToolTipGeneratorTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* -----------------------------------------
* BoxAndWhiskerXYToolTipGeneratorTests.java
* -----------------------------------------
* (C) Copyright 2003-2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 13-Aug-2003 : Version 1 (DG);
* 27-Feb-2004 : Renamed BoxAndWhiskerItemLabelGenerator
* --> XYBoxAndWhiskerItemLabelGenerator (DG);
* 23-Apr-2008 : Added testPublicCloneable() (DG);
*
*/
package org.jfree.chart.labels;
import org.jfree.chart.util.PublicCloneable;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link BoxAndWhiskerXYToolTipGenerator} class.
*/
public class BoxAndWhiskerXYToolTipGeneratorTest {
/**
* A series of tests for the equals() method.
*/
@Test
public void testEquals() {
// standard test
BoxAndWhiskerXYToolTipGenerator g1
= new BoxAndWhiskerXYToolTipGenerator();
BoxAndWhiskerXYToolTipGenerator g2
= new BoxAndWhiskerXYToolTipGenerator();
assertEquals(g1, g2);
assertEquals(g2, g1);
// tooltip format
g1 = new BoxAndWhiskerXYToolTipGenerator("{0} --> {1} {2}",
new SimpleDateFormat("yyyy"), new DecimalFormat("0.0"));
g2 = new BoxAndWhiskerXYToolTipGenerator("{1} {2}",
new SimpleDateFormat("yyyy"), new DecimalFormat("0.0"));
assertFalse(g1.equals(g2));
g2 = new BoxAndWhiskerXYToolTipGenerator("{0} --> {1} {2}",
new SimpleDateFormat("yyyy"), new DecimalFormat("0.0"));
assertEquals(g1, g2);
// date format
g1 = new BoxAndWhiskerXYToolTipGenerator("{0} --> {1} {2}",
new SimpleDateFormat("yyyy"), new DecimalFormat("0.0"));
g2 = new BoxAndWhiskerXYToolTipGenerator("{0} --> {1} {2}",
new SimpleDateFormat("MMM-yyyy"), new DecimalFormat("0.0"));
assertFalse(g1.equals(g2));
g2 = new BoxAndWhiskerXYToolTipGenerator("{0} --> {1} {2}",
new SimpleDateFormat("yyyy"), new DecimalFormat("0.0"));
assertEquals(g1, g2);
// Y format
g1 = new BoxAndWhiskerXYToolTipGenerator("{0} --> {1} {2}",
new SimpleDateFormat("yyyy"), new DecimalFormat("0.0"));
g2 = new BoxAndWhiskerXYToolTipGenerator("{0} --> {1} {2}",
new SimpleDateFormat("yyyy"), new DecimalFormat("0.00"));
assertFalse(g1.equals(g2));
g2 = new BoxAndWhiskerXYToolTipGenerator("{0} --> {1} {2}",
new SimpleDateFormat("yyyy"), new DecimalFormat("0.0"));
assertEquals(g1, g2);
}
/**
* Simple check that hashCode is implemented.
*/
@Test
public void testHashCode() {
BoxAndWhiskerXYToolTipGenerator g1
= new BoxAndWhiskerXYToolTipGenerator();
BoxAndWhiskerXYToolTipGenerator g2
= new BoxAndWhiskerXYToolTipGenerator();
assertEquals(g1, g2);
assertEquals(g1.hashCode(), g2.hashCode());
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
BoxAndWhiskerXYToolTipGenerator g1
= new BoxAndWhiskerXYToolTipGenerator();
BoxAndWhiskerXYToolTipGenerator g2 = (BoxAndWhiskerXYToolTipGenerator) g1.clone();
assertNotSame(g1, g2);
assertSame(g1.getClass(), g2.getClass());
assertEquals(g1, g2);
}
/**
* Check to ensure that this class implements PublicCloneable.
*/
@Test
public void testPublicCloneable() {
BoxAndWhiskerXYToolTipGenerator g1
= new BoxAndWhiskerXYToolTipGenerator();
assertTrue(g1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
BoxAndWhiskerXYToolTipGenerator g1
= new BoxAndWhiskerXYToolTipGenerator();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(g1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
BoxAndWhiskerXYToolTipGenerator g2 = (BoxAndWhiskerXYToolTipGenerator) in.readObject();
in.close();
assertEquals(g1, g2);
}
}
| 6,326 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
StandardPieSectionLabelGeneratorTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/labels/StandardPieSectionLabelGeneratorTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ------------------------------------------
* StandardPieSectionLabelGeneratorTests.java
* ------------------------------------------
* (C) Copyright 2003-2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 18-Mar-2003 : Version 1 (DG);
* 13-Aug-2003 : Added clone tests (DG);
* 04-Mar-2004 : Added test for equals() method (DG);
* 23-Nov-2006 : Extended equals() test (DG);
* 23-Apr-2008 : Added testPublicCloneable() (DG);
*
*/
package org.jfree.chart.labels;
import org.jfree.chart.util.PublicCloneable;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.text.AttributedString;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link StandardPieSectionLabelGenerator} class.
*/
public class StandardPieSectionLabelGeneratorTest {
/**
* Test that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
StandardPieSectionLabelGenerator g1
= new StandardPieSectionLabelGenerator();
StandardPieSectionLabelGenerator g2
= new StandardPieSectionLabelGenerator();
assertEquals(g1, g2);
assertEquals(g2, g1);
g1 = new StandardPieSectionLabelGenerator("{0}",
new DecimalFormat("#,##0.00"),
NumberFormat.getPercentInstance());
assertFalse(g1.equals(g2));
g2 = new StandardPieSectionLabelGenerator("{0}",
new DecimalFormat("#,##0.00"),
NumberFormat.getPercentInstance());
assertEquals(g1, g2);
g1 = new StandardPieSectionLabelGenerator("{0} {1}",
new DecimalFormat("#,##0.00"),
NumberFormat.getPercentInstance());
assertFalse(g1.equals(g2));
g2 = new StandardPieSectionLabelGenerator("{0} {1}",
new DecimalFormat("#,##0.00"),
NumberFormat.getPercentInstance());
assertEquals(g1, g2);
g1 = new StandardPieSectionLabelGenerator("{0} {1}",
new DecimalFormat("#,##0"), NumberFormat.getPercentInstance());
assertFalse(g1.equals(g2));
g2 = new StandardPieSectionLabelGenerator("{0} {1}",
new DecimalFormat("#,##0"), NumberFormat.getPercentInstance());
assertEquals(g1, g2);
g1 = new StandardPieSectionLabelGenerator("{0} {1}",
new DecimalFormat("#,##0"), new DecimalFormat("0.000%"));
assertFalse(g1.equals(g2));
g2 = new StandardPieSectionLabelGenerator("{0} {1}",
new DecimalFormat("#,##0"), new DecimalFormat("0.000%"));
assertEquals(g1, g2);
AttributedString as = new AttributedString("XYZ");
g1.setAttributedLabel(0, as);
assertFalse(g1.equals(g2));
g2.setAttributedLabel(0, as);
assertEquals(g1, g2);
}
/**
* Simple check that hashCode is implemented.
*/
@Test
public void testHashCode() {
StandardPieSectionLabelGenerator g1
= new StandardPieSectionLabelGenerator();
StandardPieSectionLabelGenerator g2
= new StandardPieSectionLabelGenerator();
assertEquals(g1, g2);
assertEquals(g1.hashCode(), g2.hashCode());
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
StandardPieSectionLabelGenerator g1
= new StandardPieSectionLabelGenerator();
StandardPieSectionLabelGenerator g2 = (StandardPieSectionLabelGenerator) g1.clone();
assertNotSame(g1, g2);
assertSame(g1.getClass(), g2.getClass());
assertEquals(g1, g2);
}
/**
* Check to ensure that this class implements PublicCloneable.
*/
@Test
public void testPublicCloneable() {
StandardPieSectionLabelGenerator g1
= new StandardPieSectionLabelGenerator();
assertTrue(g1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
StandardPieSectionLabelGenerator g1
= new StandardPieSectionLabelGenerator();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(g1);
out.close();
ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(
buffer.toByteArray()));
StandardPieSectionLabelGenerator g2 = (StandardPieSectionLabelGenerator) in.readObject();
in.close();
assertEquals(g1, g2);
}
}
| 6,509 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
IntervalCategoryToolTipGeneratorTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/labels/IntervalCategoryToolTipGeneratorTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ------------------------------------------
* IntervalCategoryToolTipGeneratorTests.java
* ------------------------------------------
* (C) Copyright 2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 07-Oct-2008 : Version 1, based on
* IntervalCategoryItemLabelGeneratorTests (DG);
*
*/
package org.jfree.chart.labels;
import org.jfree.chart.util.PublicCloneable;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link IntervalCategoryToolTipGenerator} class.
*/
public class IntervalCategoryToolTipGeneratorTest {
/**
* Tests the equals() method.
*/
@Test
public void testEquals() {
IntervalCategoryToolTipGenerator g1
= new IntervalCategoryToolTipGenerator();
IntervalCategoryToolTipGenerator g2
= new IntervalCategoryToolTipGenerator();
assertEquals(g1, g2);
assertEquals(g2, g1);
g1 = new IntervalCategoryToolTipGenerator("{3} - {4}",
new DecimalFormat("0.000"));
assertFalse(g1.equals(g2));
g2 = new IntervalCategoryToolTipGenerator("{3} - {4}",
new DecimalFormat("0.000"));
assertEquals(g1, g2);
g1 = new IntervalCategoryToolTipGenerator("{3} - {4}",
new SimpleDateFormat("d-MMM"));
assertFalse(g1.equals(g2));
g2 = new IntervalCategoryToolTipGenerator("{3} - {4}",
new SimpleDateFormat("d-MMM"));
assertEquals(g1, g2);
}
/**
* Check that the subclass is not equal to an instance of the superclass.
*/
@Test
public void testEquals2() {
IntervalCategoryToolTipGenerator g1
= new IntervalCategoryToolTipGenerator();
StandardCategoryToolTipGenerator g2
= new StandardCategoryToolTipGenerator(
IntervalCategoryToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT_STRING,
NumberFormat.getInstance());
assertFalse(g1.equals(g2));
}
/**
* Simple check that hashCode is implemented.
*/
@Test
public void testHashCode() {
IntervalCategoryToolTipGenerator g1
= new IntervalCategoryToolTipGenerator();
IntervalCategoryToolTipGenerator g2
= new IntervalCategoryToolTipGenerator();
assertEquals(g1, g2);
assertEquals(g1.hashCode(), g2.hashCode());
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
IntervalCategoryToolTipGenerator g1
= new IntervalCategoryToolTipGenerator();
IntervalCategoryToolTipGenerator g2 = (IntervalCategoryToolTipGenerator) g1.clone();
assertNotSame(g1, g2);
assertSame(g1.getClass(), g2.getClass());
assertEquals(g1, g2);
}
/**
* Check to ensure that this class implements PublicCloneable.
*/
@Test
public void testPublicCloneable() {
IntervalCategoryToolTipGenerator g1
= new IntervalCategoryToolTipGenerator();
assertTrue(g1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
IntervalCategoryToolTipGenerator g1
= new IntervalCategoryToolTipGenerator("{3} - {4}",
DateFormat.getInstance());
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(g1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
IntervalCategoryToolTipGenerator g2 = (IntervalCategoryToolTipGenerator) in.readObject();
in.close();
assertEquals(g1, g2);
}
}
| 5,822 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
MultipleXYSeriesLabelGeneratorTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/labels/MultipleXYSeriesLabelGeneratorTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ----------------------------------------
* MultipleXYSeriesLabelGeneratorTests.java
* ----------------------------------------
* (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 20-Jan-2007 : Version 1 (DG);
* 23-Apr-2008 : Added testPublicCloneable() (DG);
*
*/
package org.jfree.chart.labels;
import org.jfree.chart.util.PublicCloneable;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link MultipleXYSeriesLabelGenerator} class.
*/
public class MultipleXYSeriesLabelGeneratorTest {
/**
* A series of tests for the equals() method.
*/
@Test
public void testEquals() {
MultipleXYSeriesLabelGenerator g1
= new MultipleXYSeriesLabelGenerator();
MultipleXYSeriesLabelGenerator g2
= new MultipleXYSeriesLabelGenerator();
assertEquals(g1, g2);
assertEquals(g2, g1);
g1 = new MultipleXYSeriesLabelGenerator("Series {0}");
assertFalse(g1.equals(g2));
g2 = new MultipleXYSeriesLabelGenerator("Series {0}");
assertEquals(g1, g2);
g1.addSeriesLabel(1, "Additional 1");
assertFalse(g1.equals(g2));
g2.addSeriesLabel(1, "Additional 1");
assertEquals(g1, g2);
}
/**
* Simple check that hashCode is implemented.
*/
@Test
public void testHashCode() {
MultipleXYSeriesLabelGenerator g1
= new MultipleXYSeriesLabelGenerator();
MultipleXYSeriesLabelGenerator g2
= new MultipleXYSeriesLabelGenerator();
assertEquals(g1, g2);
assertEquals(g1.hashCode(), g2.hashCode());
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
MultipleXYSeriesLabelGenerator g1
= new MultipleXYSeriesLabelGenerator();
MultipleXYSeriesLabelGenerator g2 = (MultipleXYSeriesLabelGenerator) g1.clone();
assertNotSame(g1, g2);
assertSame(g1.getClass(), g2.getClass());
assertEquals(g1, g2);
// check independence
g1.addSeriesLabel(3, "Add3");
assertFalse(g1.equals(g2));
g2.addSeriesLabel(3, "Add3");
assertEquals(g1, g2);
}
/**
* Check to ensure that this class implements PublicCloneable.
*/
@Test
public void testPublicCloneable() {
MultipleXYSeriesLabelGenerator g1
= new MultipleXYSeriesLabelGenerator();
assertTrue(g1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
MultipleXYSeriesLabelGenerator g1
= new MultipleXYSeriesLabelGenerator();
g1.addSeriesLabel(0, "Add0");
g1.addSeriesLabel(0, "Add0b");
g1.addSeriesLabel(1, "Add1");
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(g1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
MultipleXYSeriesLabelGenerator g2 = (MultipleXYSeriesLabelGenerator) in.readObject();
in.close();
assertEquals(g1, g2);
}
}
| 5,166 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
StandardXYSeriesLabelGeneratorTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/labels/StandardXYSeriesLabelGeneratorTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ----------------------------------------
* StandardXYSeriesLabelGeneratorTests.java
* ----------------------------------------
* (C) Copyright 2006-2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 24-Nov-2006 : Version 1 (DG);
* 23-Apr-2008 : Added testPublicCloneable() (DG)
*
*/
package org.jfree.chart.labels;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link StandardXYSeriesLabelGenerator} class.
*/
public class StandardXYSeriesLabelGeneratorTest {
/**
* Some checks for the generalLabel() method.
*/
@Test
public void testGenerateLabel() {
StandardXYSeriesLabelGenerator g
= new StandardXYSeriesLabelGenerator("Series {0}");
XYSeriesCollection dataset = new XYSeriesCollection();
dataset.addSeries(new XYSeries("1"));
dataset.addSeries(new XYSeries("2"));
assertEquals("Series 1", g.generateLabel(dataset, 0));
assertEquals("Series 2", g.generateLabel(dataset, 1));
}
/**
* Some checks for the equals() method.
*/
@Test
public void testEquals() {
StandardXYSeriesLabelGenerator g1
= new StandardXYSeriesLabelGenerator("Series {0}");
StandardXYSeriesLabelGenerator g2
= new StandardXYSeriesLabelGenerator("Series {0}");
assertEquals(g1, g2);
assertEquals(g2, g1);
g1 = new StandardXYSeriesLabelGenerator("{1}");
assertFalse(g1.equals(g2));
g2 = new StandardXYSeriesLabelGenerator("{1}");
assertEquals(g1, g2);
}
/**
* Simple check that hashCode is implemented.
*/
@Test
public void testHashCode() {
StandardXYSeriesLabelGenerator g1
= new StandardXYSeriesLabelGenerator();
StandardXYSeriesLabelGenerator g2
= new StandardXYSeriesLabelGenerator();
assertEquals(g1, g2);
assertEquals(g1.hashCode(), g2.hashCode());
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
StandardXYSeriesLabelGenerator g1
= new StandardXYSeriesLabelGenerator("Series {0}");
StandardXYSeriesLabelGenerator g2 = (StandardXYSeriesLabelGenerator) g1.clone();
assertNotSame(g1, g2);
assertSame(g1.getClass(), g2.getClass());
assertEquals(g1, g2);
}
/**
* Check to ensure that this class implements PublicCloneable.
*/
@Test
public void testPublicCloneable() {
StandardXYSeriesLabelGenerator g1
= new StandardXYSeriesLabelGenerator("Series {0}");
assertTrue(g1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
StandardXYSeriesLabelGenerator g1
= new StandardXYSeriesLabelGenerator("Series {0}");
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(g1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
StandardXYSeriesLabelGenerator g2 = (StandardXYSeriesLabelGenerator) in.readObject();
in.close();
assertEquals(g1, g2);
}
}
| 5,346 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
StandardCategoryItemLabelGeneratorTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/labels/StandardCategoryItemLabelGeneratorTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* --------------------------------------------
* StandardCategoryItemLabelGeneratorTests.java
* --------------------------------------------
* (C) Copyright 2003-2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 21-Mar-2003 : Version 1 (DG);
* 13-Aug-2003 : Added cloning tests (DG);
* 11-May-2004 : Renamed class (DG);
* 23-Apr-2008 : Added testPublicCloneable() (DG);
*
*/
package org.jfree.chart.labels;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.data.category.DefaultCategoryDataset;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link StandardCategoryItemLabelGenerator} class.
*/
public class StandardCategoryItemLabelGeneratorTest {
/**
* Some checks for the generalLabel() method.
*/
@Test
public void testGenerateLabel() {
StandardCategoryItemLabelGenerator g
= new StandardCategoryItemLabelGenerator("{2}",
new DecimalFormat("0.000"));
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.addValue(1.0, "R0", "C0");
dataset.addValue(2.0, "R0", "C1");
dataset.addValue(3.0, "R1", "C0");
dataset.addValue(null, "R1", "C1");
String s = g.generateLabel(dataset, 0, 0);
assertTrue(s.startsWith("1"));
assertTrue(s.endsWith("000"));
// try a null value
s = g.generateLabel(dataset, 1, 1);
assertEquals("-", s);
}
/**
* Some checks for the equals() method.
*/
@Test
public void testEquals() {
StandardCategoryItemLabelGenerator g1
= new StandardCategoryItemLabelGenerator();
StandardCategoryItemLabelGenerator g2
= new StandardCategoryItemLabelGenerator();
assertEquals(g1, g2);
assertEquals(g2, g1);
g1 = new StandardCategoryItemLabelGenerator("{0}",
new DecimalFormat("0.000"));
assertFalse(g1.equals(g2));
g2 = new StandardCategoryItemLabelGenerator("{0}",
new DecimalFormat("0.000"));
assertEquals(g1, g2);
g1 = new StandardCategoryItemLabelGenerator("{1}",
new DecimalFormat("0.000"));
assertFalse(g1.equals(g2));
g2 = new StandardCategoryItemLabelGenerator("{1}",
new DecimalFormat("0.000"));
assertEquals(g1, g2);
g1 = new StandardCategoryItemLabelGenerator("{2}",
new SimpleDateFormat("d-MMM"));
assertFalse(g1.equals(g2));
g2 = new StandardCategoryItemLabelGenerator("{2}",
new SimpleDateFormat("d-MMM"));
assertEquals(g1, g2);
}
/**
* Simple check that hashCode is implemented.
*/
@Test
public void testHashCode() {
StandardCategoryItemLabelGenerator g1
= new StandardCategoryItemLabelGenerator();
StandardCategoryItemLabelGenerator g2
= new StandardCategoryItemLabelGenerator();
assertEquals(g1, g2);
assertEquals(g1.hashCode(), g2.hashCode());
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
StandardCategoryItemLabelGenerator g1
= new StandardCategoryItemLabelGenerator();
StandardCategoryItemLabelGenerator g2 = (StandardCategoryItemLabelGenerator) g1.clone();
assertNotSame(g1, g2);
assertSame(g1.getClass(), g2.getClass());
assertEquals(g1, g2);
}
/**
* Check to ensure that this class implements PublicCloneable.
*/
@Test
public void testPublicCloneable() {
StandardCategoryItemLabelGenerator g1
= new StandardCategoryItemLabelGenerator();
assertTrue(g1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
StandardCategoryItemLabelGenerator g1
= new StandardCategoryItemLabelGenerator("{2}",
DateFormat.getInstance());
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(g1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
StandardCategoryItemLabelGenerator g2 = (StandardCategoryItemLabelGenerator) in.readObject();
in.close();
assertEquals(g1, g2);
}
/**
* A test for bug 1481087.
*/
@Test
public void testEquals1481087() {
StandardCategoryItemLabelGenerator g1
= new StandardCategoryItemLabelGenerator("{0}",
new DecimalFormat("0.00"));
StandardCategoryToolTipGenerator g2
= new StandardCategoryToolTipGenerator("{0}",
new DecimalFormat("0.00"));
assertFalse(g1.equals(g2));
}
}
| 6,917 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
IntervalCategoryItemLabelGeneratorTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/labels/IntervalCategoryItemLabelGeneratorTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* --------------------------------------------
* IntervalCategoryItemLabelGeneratorTests.java
* --------------------------------------------
* (C) Copyright 2003-2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 21-Mar-2003 : Version 1 (DG);
* 13-Aug-2003 : Added cloning tests, and renamed class (DG);
* 23-Apr-2008 : Added testPublicCloneble() (DG);
*
*/
package org.jfree.chart.labels;
import org.jfree.chart.util.PublicCloneable;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link IntervalCategoryItemLabelGenerator} class.
*/
public class IntervalCategoryItemLabelGeneratorTest {
/**
* Tests the equals() method.
*/
@Test
public void testEquals() {
IntervalCategoryItemLabelGenerator g1
= new IntervalCategoryItemLabelGenerator();
IntervalCategoryItemLabelGenerator g2
= new IntervalCategoryItemLabelGenerator();
assertEquals(g1, g2);
assertEquals(g2, g1);
g1 = new IntervalCategoryItemLabelGenerator("{3} - {4}",
new DecimalFormat("0.000"));
assertFalse(g1.equals(g2));
g2 = new IntervalCategoryItemLabelGenerator("{3} - {4}",
new DecimalFormat("0.000"));
assertEquals(g1, g2);
g1 = new IntervalCategoryItemLabelGenerator("{3} - {4}",
new SimpleDateFormat("d-MMM"));
assertFalse(g1.equals(g2));
g2 = new IntervalCategoryItemLabelGenerator("{3} - {4}",
new SimpleDateFormat("d-MMM"));
assertEquals(g1, g2);
}
/**
* Simple check that hashCode is implemented.
*/
@Test
public void testHashCode() {
IntervalCategoryItemLabelGenerator g1
= new IntervalCategoryItemLabelGenerator();
IntervalCategoryItemLabelGenerator g2
= new IntervalCategoryItemLabelGenerator();
assertEquals(g1, g2);
assertEquals(g1.hashCode(), g2.hashCode());
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
IntervalCategoryItemLabelGenerator g1
= new IntervalCategoryItemLabelGenerator();
IntervalCategoryItemLabelGenerator g2 = (IntervalCategoryItemLabelGenerator) g1.clone();
assertNotSame(g1, g2);
assertSame(g1.getClass(), g2.getClass());
assertEquals(g1, g2);
}
/**
* Check to ensure that this class implements PublicCloneable.
*/
@Test
public void testPublicCloneable() {
IntervalCategoryItemLabelGenerator g1
= new IntervalCategoryItemLabelGenerator();
assertTrue(g1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
IntervalCategoryItemLabelGenerator g1
= new IntervalCategoryItemLabelGenerator("{3} - {4}",
DateFormat.getInstance());
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(g1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
IntervalCategoryItemLabelGenerator g2 = (IntervalCategoryItemLabelGenerator) in.readObject();
in.close();
assertEquals(g1, g2);
}
}
| 5,389 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
StandardCategorySeriesLabelGeneratorTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/labels/StandardCategorySeriesLabelGeneratorTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ----------------------------------------------
* StandardCategorySeriesLabelGeneratorTests.java
* ----------------------------------------------
* (C) Copyright 2006-2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 03-May-2006 : Version 1 (DG);
* 23-Apr-2008 : Added testPublicCloneable() (DG);
*
*/
package org.jfree.chart.labels;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.data.category.DefaultCategoryDataset;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link StandardCategorySeriesLabelGenerator} class.
*/
public class StandardCategorySeriesLabelGeneratorTest {
/**
* Some checks for the generalLabel() method.
*/
@Test
public void testGenerateLabel() {
StandardCategorySeriesLabelGenerator g
= new StandardCategorySeriesLabelGenerator("{0}");
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.addValue(1.0, "R0", "C0");
dataset.addValue(2.0, "R0", "C1");
dataset.addValue(3.0, "R1", "C0");
dataset.addValue(null, "R1", "C1");
String s = g.generateLabel(dataset, 0);
assertEquals("R0", s);
}
/**
* Some checks for the equals() method.
*/
@Test
public void testEquals() {
StandardCategorySeriesLabelGenerator g1
= new StandardCategorySeriesLabelGenerator();
StandardCategorySeriesLabelGenerator g2
= new StandardCategorySeriesLabelGenerator();
assertEquals(g1, g2);
assertEquals(g2, g1);
g1 = new StandardCategorySeriesLabelGenerator("{1}");
assertFalse(g1.equals(g2));
g2 = new StandardCategorySeriesLabelGenerator("{1}");
assertEquals(g1, g2);
}
/**
* Simple check that hashCode is implemented.
*/
@Test
public void testHashCode() {
StandardCategorySeriesLabelGenerator g1
= new StandardCategorySeriesLabelGenerator();
StandardCategorySeriesLabelGenerator g2
= new StandardCategorySeriesLabelGenerator();
assertEquals(g1, g2);
assertEquals(g1.hashCode(), g2.hashCode());
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
StandardCategorySeriesLabelGenerator g1
= new StandardCategorySeriesLabelGenerator("{1}");
StandardCategorySeriesLabelGenerator g2 = (StandardCategorySeriesLabelGenerator) g1.clone();
assertNotSame(g1, g2);
assertSame(g1.getClass(), g2.getClass());
assertEquals(g1, g2);
}
/**
* Check to ensure that this class implements PublicCloneable.
*/
@Test
public void testPublicCloneable() {
StandardCategorySeriesLabelGenerator g1
= new StandardCategorySeriesLabelGenerator("{1}");
assertTrue(g1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
StandardCategorySeriesLabelGenerator g1
= new StandardCategorySeriesLabelGenerator("{2}");
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(g1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
StandardCategorySeriesLabelGenerator g2 = (StandardCategorySeriesLabelGenerator) in.readObject();
in.close();
assertEquals(g1, g2);
}
}
| 5,476 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
StandardXYItemLabelGeneratorTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/labels/StandardXYItemLabelGeneratorTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* --------------------------------------
* StandardXYItemLabelGeneratorTests.java
* --------------------------------------
* (C) Copyright 2003-2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 23-Mar-2003 : Version 1 (DG);
* 26-Feb-2004 : Updates for new code (DG);
* 20-Jan-2006 : Renamed StandardXYItemLabelGeneratorTests.java (DG);
* 25-Jan-2007 : Added independence checks to testCloning() (DG);
* 23-Apr-2008 : Added testPublicCloneable() (DG);
*
*/
package org.jfree.chart.labels;
import org.jfree.chart.util.PublicCloneable;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link StandardXYItemLabelGenerator} class.
*/
public class StandardXYItemLabelGeneratorTest {
/**
* A series of tests for the equals() method.
*/
@Test
public void testEquals() {
// some setup...
String f1 = "{1}";
String f2 = "{2}";
NumberFormat xnf1 = new DecimalFormat("0.00");
NumberFormat xnf2 = new DecimalFormat("0.000");
NumberFormat ynf1 = new DecimalFormat("0.00");
NumberFormat ynf2 = new DecimalFormat("0.000");
StandardXYItemLabelGenerator g1;
StandardXYItemLabelGenerator g2;
g1 = new StandardXYItemLabelGenerator(f1, xnf1, ynf1);
g2 = new StandardXYItemLabelGenerator(f1, xnf1, ynf1);
assertEquals(g1, g2);
assertEquals(g2, g1);
g1 = new StandardXYItemLabelGenerator(f2, xnf1, ynf1);
assertFalse(g1.equals(g2));
g2 = new StandardXYItemLabelGenerator(f2, xnf1, ynf1);
assertEquals(g1, g2);
g1 = new StandardXYItemLabelGenerator(f2, xnf2, ynf1);
assertFalse(g1.equals(g2));
g2 = new StandardXYItemLabelGenerator(f2, xnf2, ynf1);
assertEquals(g1, g2);
g1 = new StandardXYItemLabelGenerator(f2, xnf2, ynf2);
assertFalse(g1.equals(g2));
g2 = new StandardXYItemLabelGenerator(f2, xnf2, ynf2);
assertEquals(g1, g2);
DateFormat xdf1 = new SimpleDateFormat("d-MMM");
DateFormat xdf2 = new SimpleDateFormat("d-MMM-yyyy");
DateFormat ydf1 = new SimpleDateFormat("d-MMM");
DateFormat ydf2 = new SimpleDateFormat("d-MMM-yyyy");
g1 = new StandardXYItemLabelGenerator(f1, xdf1, ydf1);
g2 = new StandardXYItemLabelGenerator(f1, xdf1, ydf1);
assertEquals(g1, g2);
assertEquals(g2, g1);
g1 = new StandardXYItemLabelGenerator(f1, xdf2, ydf1);
assertFalse(g1.equals(g2));
g2 = new StandardXYItemLabelGenerator(f1, xdf2, ydf1);
assertEquals(g1, g2);
g1 = new StandardXYItemLabelGenerator(f1, xdf2, ydf2);
assertFalse(g1.equals(g2));
g2 = new StandardXYItemLabelGenerator(f1, xdf2, ydf2);
assertEquals(g1, g2);
}
/**
* Simple check that hashCode is implemented.
*/
@Test
public void testHashCode() {
StandardXYItemLabelGenerator g1
= new StandardXYItemLabelGenerator();
StandardXYItemLabelGenerator g2
= new StandardXYItemLabelGenerator();
assertEquals(g1, g2);
assertEquals(g1.hashCode(), g2.hashCode());
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
StandardXYItemLabelGenerator g1 = new StandardXYItemLabelGenerator();
StandardXYItemLabelGenerator g2 = (StandardXYItemLabelGenerator) g1.clone();
assertNotSame(g1, g2);
assertSame(g1.getClass(), g2.getClass());
assertEquals(g1, g2);
// check independence
g1.getXFormat().setMinimumIntegerDigits(2);
assertFalse(g1.equals(g2));
g2.getXFormat().setMinimumIntegerDigits(2);
assertEquals(g1, g2);
g1.getYFormat().setMinimumIntegerDigits(2);
assertFalse(g1.equals(g2));
g2.getYFormat().setMinimumIntegerDigits(2);
assertEquals(g1, g2);
// another test...
g1 = new StandardXYItemLabelGenerator("{0} {1} {2}",
DateFormat.getInstance(), DateFormat.getInstance());
g2 = (StandardXYItemLabelGenerator) g1.clone();
assertNotSame(g1, g2);
assertSame(g1.getClass(), g2.getClass());
assertEquals(g1, g2);
// check independence
g1.getXDateFormat().setNumberFormat(new DecimalFormat("0.000"));
assertFalse(g1.equals(g2));
g2.getXDateFormat().setNumberFormat(new DecimalFormat("0.000"));
assertEquals(g1, g2);
g1.getYDateFormat().setNumberFormat(new DecimalFormat("0.000"));
assertFalse(g1.equals(g2));
g2.getYDateFormat().setNumberFormat(new DecimalFormat("0.000"));
assertEquals(g1, g2);
}
/**
* Check to ensure that this class implements PublicCloneable.
*/
@Test
public void testPublicCloneable() {
StandardXYItemLabelGenerator g1 = new StandardXYItemLabelGenerator();
assertTrue(g1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
StandardXYItemLabelGenerator g1 = new StandardXYItemLabelGenerator();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(g1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
StandardXYItemLabelGenerator g2 = (StandardXYItemLabelGenerator) in.readObject();
in.close();
assertEquals(g1, g2);
}
}
| 7,642 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
BoxAndWhiskerToolTipGeneratorTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/labels/BoxAndWhiskerToolTipGeneratorTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ---------------------------------------
* BoxAndWhiskerToolTipGeneratorTests.java
* ---------------------------------------
* (C) Copyright 2004-2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 02-Jun-2004 : Version 1 (DG);
* 23-Apr-2008 : Added testPublicCloneable() (DG);
*
*/
package org.jfree.chart.labels;
import org.jfree.chart.util.PublicCloneable;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.text.DecimalFormat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link BoxAndWhiskerToolTipGenerator} class.
*/
public class BoxAndWhiskerToolTipGeneratorTest {
/**
* A series of tests for the equals() method.
*/
@Test
public void testEquals() {
// standard test
BoxAndWhiskerToolTipGenerator g1 = new BoxAndWhiskerToolTipGenerator();
BoxAndWhiskerToolTipGenerator g2 = new BoxAndWhiskerToolTipGenerator();
assertEquals(g1, g2);
assertEquals(g2, g1);
// tooltip format
g1 = new BoxAndWhiskerToolTipGenerator("{0} --> {1} {2}",
new DecimalFormat("0.0"));
g2 = new BoxAndWhiskerToolTipGenerator("{1} {2}",
new DecimalFormat("0.0"));
assertFalse(g1.equals(g2));
g2 = new BoxAndWhiskerToolTipGenerator("{0} --> {1} {2}",
new DecimalFormat("0.0"));
assertEquals(g1, g2);
// Y format
g1 = new BoxAndWhiskerToolTipGenerator("{0} --> {1} {2}",
new DecimalFormat("0.0"));
g2 = new BoxAndWhiskerToolTipGenerator("{0} --> {1} {2}",
new DecimalFormat("0.00"));
assertFalse(g1.equals(g2));
}
/**
* Simple check that hashCode is implemented.
*/
@Test
public void testHashCode() {
BoxAndWhiskerToolTipGenerator g1 = new BoxAndWhiskerToolTipGenerator();
BoxAndWhiskerToolTipGenerator g2 = new BoxAndWhiskerToolTipGenerator();
assertEquals(g1, g2);
assertEquals(g1.hashCode(), g2.hashCode());
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
BoxAndWhiskerToolTipGenerator g1 = new BoxAndWhiskerToolTipGenerator();
BoxAndWhiskerToolTipGenerator g2 = (BoxAndWhiskerToolTipGenerator) g1.clone();
assertNotSame(g1, g2);
assertSame(g1.getClass(), g2.getClass());
assertEquals(g1, g2);
}
/**
* Check to ensure that this class implements PublicCloneable.
*/
@Test
public void testPublicCloneable() {
BoxAndWhiskerToolTipGenerator g1 = new BoxAndWhiskerToolTipGenerator();
assertTrue(g1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
BoxAndWhiskerToolTipGenerator g1 = new BoxAndWhiskerToolTipGenerator();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(g1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
BoxAndWhiskerToolTipGenerator g2 = (BoxAndWhiskerToolTipGenerator) in.readObject();
in.close();
assertEquals(g1, g2);
}
}
| 5,136 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
CustomXYItemLabelGeneratorTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/labels/CustomXYItemLabelGeneratorTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ------------------------------------
* CustomXYItemLabelGeneratorTests.java
* ------------------------------------
* (C) Copyright 2003-2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 23-Mar-2003 : Version 1 (DG);
* 13-Aug-2003 : Added cloning tests (DG);
* 23-Apr-2008 : Added testPublicCloneable() (DG);
*
*/
package org.jfree.chart.labels;
import org.jfree.chart.util.PublicCloneable;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link CustomXYToolTipGenerator} class.
*/
public class CustomXYItemLabelGeneratorTest {
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
CustomXYToolTipGenerator g1 = new CustomXYToolTipGenerator();
CustomXYToolTipGenerator g2 = (CustomXYToolTipGenerator) g1.clone();
assertNotSame(g1, g2);
assertSame(g1.getClass(), g2.getClass());
assertEquals(g1, g2);
}
/**
* Check to ensure that this class implements PublicCloneable.
*/
@Test
public void testPublicCloneable() {
CustomXYToolTipGenerator g1 = new CustomXYToolTipGenerator();
assertTrue(g1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
List<String> t1 = new java.util.ArrayList<String>();
t1.add("Tooltip A1");
t1.add("Tooltip A2");
t1.add("Tooltip A3");
List<String> t2 = new java.util.ArrayList<String>();
t2.add("Tooltip B1");
t2.add("Tooltip B2");
t2.add("Tooltip B3");
CustomXYToolTipGenerator g1 = new CustomXYToolTipGenerator();
g1.addToolTipSeries(t1);
g1.addToolTipSeries(t2);
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(g1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
CustomXYToolTipGenerator g2 = (CustomXYToolTipGenerator) in.readObject();
in.close();
assertEquals(g1, g2);
}
}
| 4,023 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
BubbleXYItemLabelGeneratorTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/labels/BubbleXYItemLabelGeneratorTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ------------------------------------
* BubbleXYItemLabelGeneratorTests.java
* ------------------------------------
* (C) Copyright 2006-2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 20-Jan-2006 : Version 1 (DG);
* 23-Apr-2008 : Added testPublicCloneable() (DG);
*
*/
package org.jfree.chart.labels;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link BubbleXYItemLabelGenerator} class.
*/
public class BubbleXYItemLabelGeneratorTest {
/**
* A series of tests for the equals() method.
*/
@Test
public void testEquals() {
// some setup...
String f1 = "{1}";
String f2 = "{2}";
NumberFormat xnf1 = new DecimalFormat("0.00");
NumberFormat xnf2 = new DecimalFormat("0.000");
NumberFormat ynf1 = new DecimalFormat("0.00");
NumberFormat ynf2 = new DecimalFormat("0.000");
NumberFormat znf1 = new DecimalFormat("0.00");
NumberFormat znf2 = new DecimalFormat("0.000");
BubbleXYItemLabelGenerator g1;
BubbleXYItemLabelGenerator g2;
g1 = new BubbleXYItemLabelGenerator(f1, xnf1, ynf1, znf1);
g2 = new BubbleXYItemLabelGenerator(f1, xnf1, ynf1, znf1);
assertEquals(g1, g2);
assertEquals(g2, g1);
g1 = new BubbleXYItemLabelGenerator(f2, xnf1, ynf1, znf1);
assertFalse(g1.equals(g2));
g2 = new BubbleXYItemLabelGenerator(f2, xnf1, ynf1, znf1);
assertEquals(g1, g2);
g1 = new BubbleXYItemLabelGenerator(f2, xnf2, ynf1, znf1);
assertFalse(g1.equals(g2));
g2 = new BubbleXYItemLabelGenerator(f2, xnf2, ynf1, znf1);
assertEquals(g1, g2);
g1 = new BubbleXYItemLabelGenerator(f2, xnf2, ynf2, znf1);
assertFalse(g1.equals(g2));
g2 = new BubbleXYItemLabelGenerator(f2, xnf2, ynf2, znf1);
assertEquals(g1, g2);
g1 = new BubbleXYItemLabelGenerator(f2, xnf2, ynf2, znf2);
assertFalse(g1.equals(g2));
g2 = new BubbleXYItemLabelGenerator(f2, xnf2, ynf2, znf2);
assertEquals(g1, g2);
DateFormat xdf1 = new SimpleDateFormat("d-MMM");
DateFormat xdf2 = new SimpleDateFormat("d-MMM-yyyy");
DateFormat ydf1 = new SimpleDateFormat("d-MMM");
DateFormat ydf2 = new SimpleDateFormat("d-MMM-yyyy");
DateFormat zdf1 = new SimpleDateFormat("d-MMM");
DateFormat zdf2 = new SimpleDateFormat("d-MMM-yyyy");
g1 = new BubbleXYItemLabelGenerator(f1, xdf1, ydf1, zdf1);
g2 = new BubbleXYItemLabelGenerator(f1, xdf1, ydf1, zdf1);
assertEquals(g1, g2);
assertEquals(g2, g1);
g1 = new BubbleXYItemLabelGenerator(f1, xdf2, ydf1, zdf1);
assertFalse(g1.equals(g2));
g2 = new BubbleXYItemLabelGenerator(f1, xdf2, ydf1, zdf1);
assertEquals(g1, g2);
g1 = new BubbleXYItemLabelGenerator(f1, xdf2, ydf2, zdf1);
assertFalse(g1.equals(g2));
g2 = new BubbleXYItemLabelGenerator(f1, xdf2, ydf2, zdf1);
assertEquals(g1, g2);
g1 = new BubbleXYItemLabelGenerator(f1, xdf2, ydf2, zdf2);
assertFalse(g1.equals(g2));
g2 = new BubbleXYItemLabelGenerator(f1, xdf2, ydf2, zdf2);
assertEquals(g1, g2);
}
/**
* Simple check that hashCode is implemented.
*/
@Test
public void testHashCode() {
BubbleXYItemLabelGenerator g1
= new BubbleXYItemLabelGenerator();
BubbleXYItemLabelGenerator g2
= new BubbleXYItemLabelGenerator();
assertEquals(g1, g2);
assertEquals(g1.hashCode(), g2.hashCode());
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
BubbleXYItemLabelGenerator g1 = new BubbleXYItemLabelGenerator();
BubbleXYItemLabelGenerator g2 = (BubbleXYItemLabelGenerator) g1.clone();
assertNotSame(g1, g2);
assertSame(g1.getClass(), g2.getClass());
assertEquals(g1, g2);
}
/**
* Check to ensure that this class implements PublicCloneable.
*/
@Test
public void testPublicCloneable() {
BubbleXYItemLabelGenerator g1 = new BubbleXYItemLabelGenerator();
assertTrue(g1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
BubbleXYItemLabelGenerator g1 = new BubbleXYItemLabelGenerator();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(g1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
BubbleXYItemLabelGenerator g2 = (BubbleXYItemLabelGenerator) in.readObject();
in.close();
assertEquals(g1, g2);
}
/**
* Some checks for the testGenerateLabel() method.
*/
@Test
public void testGenerateLabel() {
// check handling when the dataset is a regular XYDataset, not an
// XYZDataset...
XYSeries s1 = new XYSeries("S1");
s1.add(1.0, 2.0);
s1.add(2.2, 3.3);
XYSeriesCollection dataset = new XYSeriesCollection(s1);
BubbleXYItemLabelGenerator g = new BubbleXYItemLabelGenerator();
assertEquals("{3}", g.generateLabel(dataset, 0, 0));
assertEquals("{3}", g.generateLabel(dataset, 0, 1));
}
}
| 7,578 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
HighLowItemLabelGeneratorTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/labels/HighLowItemLabelGeneratorTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* -----------------------------------
* HighLowItemLabelGeneratorTests.java
* -----------------------------------
* (C) Copyright 2003-2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 18-Mar-2003 : Version 1 (DG);
* 23-Apr-2008 : Added testPublicCloneable() (DG);
*
*/
package org.jfree.chart.labels;
import org.jfree.chart.util.PublicCloneable;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link HighLowItemLabelGenerator} class.
*/
public class HighLowItemLabelGeneratorTest {
/**
* Tests that the equals method can distinguish all fields.
*/
@Test
public void testEquals() {
HighLowItemLabelGenerator g1 = new HighLowItemLabelGenerator();
HighLowItemLabelGenerator g2 = new HighLowItemLabelGenerator();
assertEquals(g1, g2);
assertEquals(g2, g1);
g1 = new HighLowItemLabelGenerator(new SimpleDateFormat("d-MMM-yyyy"),
NumberFormat.getInstance());
assertFalse(g1.equals(g2));
g2 = new HighLowItemLabelGenerator(new SimpleDateFormat("d-MMM-yyyy"),
NumberFormat.getInstance());
assertEquals(g1, g2);
g1 = new HighLowItemLabelGenerator(new SimpleDateFormat("d-MMM-yyyy"),
new DecimalFormat("0.000"));
assertFalse(g1.equals(g2));
g2 = new HighLowItemLabelGenerator(new SimpleDateFormat("d-MMM-yyyy"),
new DecimalFormat("0.000"));
assertEquals(g1, g2);
}
/**
* Simple check that hashCode is implemented.
*/
@Test
public void testHashCode() {
HighLowItemLabelGenerator g1 = new HighLowItemLabelGenerator();
HighLowItemLabelGenerator g2 = new HighLowItemLabelGenerator();
assertEquals(g1, g2);
assertEquals(g1.hashCode(), g2.hashCode());
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
HighLowItemLabelGenerator g1 = new HighLowItemLabelGenerator();
HighLowItemLabelGenerator g2 = (HighLowItemLabelGenerator) g1.clone();
assertNotSame(g1, g2);
assertSame(g1.getClass(), g2.getClass());
assertEquals(g1, g2);
}
/**
* Check to ensure that this class implements PublicCloneable.
*/
@Test
public void testPublicCloneable() {
HighLowItemLabelGenerator g1 = new HighLowItemLabelGenerator();
assertTrue(g1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
HighLowItemLabelGenerator g1 = new HighLowItemLabelGenerator();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(g1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
HighLowItemLabelGenerator g2 = (HighLowItemLabelGenerator) in.readObject();
in.close();
assertEquals(g1, g2);
}
}
| 5,038 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
ItemLabelPositionTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/labels/ItemLabelPositionTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ---------------------------
* ItemLabelPositionTests.java
* ---------------------------
* (C) Copyright 2003-2007, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 30-Oct-2003 : Version 1 (DG);
* 19-Feb-2004 : Moved to org.jfree.chart.labels.junit (DG);
*
*/
package org.jfree.chart.labels;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
/**
* Tests for the {@link ItemLabelPosition} class.
*/
public class ItemLabelPositionTest {
/**
* Check that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
ItemLabelPosition p1 = new ItemLabelPosition();
ItemLabelPosition p2 = new ItemLabelPosition();
assertEquals(p1, p2);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
ItemLabelPosition p1 = new ItemLabelPosition();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(p1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
ItemLabelPosition p2 = (ItemLabelPosition) in.readObject();
in.close();
assertEquals(p1, p2);
}
}
| 2,998 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
StandardPieToolTipGeneratorTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/labels/StandardPieToolTipGeneratorTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* -------------------------------------
* StandardPieToolTipGeneratorTests.java
* -------------------------------------
* (C) Copyright 2003-2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 18-Mar-2003 : Version 1 (DG);
* 13-Aug-2003 : Added clone tests (DG);
* 04-Mar-2004 : Added test for equals() method (DG);
* ------------- JFREECHART 1.0.x ---------------------------------------------
* 03-May-2006 : Extended test for clone() method (DG);
* 03-May-2006 : Renamed StandardPieItemLabelGeneratorTests
* --> StandardPieToolTipGeneratorTests (DG);
* 23-Apr-2008 : Added testPublicCloneable() (DG);
*
*/
package org.jfree.chart.labels;
import org.jfree.chart.util.PublicCloneable;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link StandardPieToolTipGenerator} class.
*/
public class StandardPieToolTipGeneratorTest {
/**
* Test that the equals() method distinguishes all fields.
*/
@Test
public void testEquals() {
StandardPieToolTipGenerator g1 = new StandardPieToolTipGenerator();
StandardPieToolTipGenerator g2 = new StandardPieToolTipGenerator();
assertEquals(g1, g2);
assertEquals(g2, g1);
g1 = new StandardPieToolTipGenerator("{0}",
new DecimalFormat("#,##0.00"),
NumberFormat.getPercentInstance());
assertFalse(g1.equals(g2));
g2 = new StandardPieToolTipGenerator("{0}",
new DecimalFormat("#,##0.00"),
NumberFormat.getPercentInstance());
assertEquals(g1, g2);
g1 = new StandardPieToolTipGenerator("{0} {1}",
new DecimalFormat("#,##0.00"),
NumberFormat.getPercentInstance());
assertFalse(g1.equals(g2));
g2 = new StandardPieToolTipGenerator("{0} {1}",
new DecimalFormat("#,##0.00"),
NumberFormat.getPercentInstance());
assertEquals(g1, g2);
g1 = new StandardPieToolTipGenerator("{0} {1}",
new DecimalFormat("#,##0"), NumberFormat.getPercentInstance());
assertFalse(g1.equals(g2));
g2 = new StandardPieToolTipGenerator("{0} {1}",
new DecimalFormat("#,##0"), NumberFormat.getPercentInstance());
assertEquals(g1, g2);
g1 = new StandardPieToolTipGenerator("{0} {1}",
new DecimalFormat("#,##0"), new DecimalFormat("0.000%"));
assertFalse(g1.equals(g2));
g2 = new StandardPieToolTipGenerator("{0} {1}",
new DecimalFormat("#,##0"), new DecimalFormat("0.000%"));
assertEquals(g1, g2);
}
/**
* Simple check that hashCode is implemented.
*/
@Test
public void testHashCode() {
StandardPieToolTipGenerator g1
= new StandardPieToolTipGenerator();
StandardPieToolTipGenerator g2
= new StandardPieToolTipGenerator();
assertEquals(g1, g2);
assertEquals(g1.hashCode(), g2.hashCode());
}
/**
* Some checks for cloning.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
StandardPieToolTipGenerator g1 = new StandardPieToolTipGenerator();
StandardPieToolTipGenerator g2 = (StandardPieToolTipGenerator) g1.clone();
assertNotSame(g1, g2);
assertSame(g1.getClass(), g2.getClass());
assertEquals(g1, g2);
assertNotSame(g1.getNumberFormat(), g2.getNumberFormat());
assertNotSame(g1.getPercentFormat(), g2.getPercentFormat());
}
/**
* Check to ensure that this class implements PublicCloneable.
*/
@Test
public void testPublicCloneable() {
StandardPieToolTipGenerator g1 = new StandardPieToolTipGenerator();
assertTrue(g1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
StandardPieToolTipGenerator g1 = new StandardPieToolTipGenerator();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(g1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
StandardPieToolTipGenerator g2 = (StandardPieToolTipGenerator) in.readObject();
in.close();
assertEquals(g1, g2);
}
}
| 6,381 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
CustomCategoryURLGeneratorTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/urls/CustomCategoryURLGeneratorTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ------------------------------------
* CustomCategoryURLGeneratorTests.java
* ------------------------------------
* (C) Copyright 2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 23-Apr-2008 : Version 1, based on CustomXYURLGeneratorTests.java (DG);
*
*/
package org.jfree.chart.urls;
import org.jfree.chart.util.PublicCloneable;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link CustomCategoryURLGenerator} class.
*/
public class CustomCategoryURLGeneratorTest {
/**
* Some checks for the equals() method.
*/
@Test
public void testEquals() {
CustomCategoryURLGenerator g1 = new CustomCategoryURLGenerator();
CustomCategoryURLGenerator g2 = new CustomCategoryURLGenerator();
assertEquals(g1, g2);
List<String> u1 = new java.util.ArrayList<String>();
u1.add("URL A1");
u1.add("URL A2");
u1.add("URL A3");
g1.addURLSeries(u1);
assertFalse(g1.equals(g2));
List<String> u2 = new java.util.ArrayList<String>();
u2.add("URL A1");
u2.add("URL A2");
u2.add("URL A3");
g2.addURLSeries(u2);
assertEquals(g1, g2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
CustomCategoryURLGenerator g1 = new CustomCategoryURLGenerator();
List<String> u1 = new java.util.ArrayList<String>();
u1.add("URL A1");
u1.add("URL A2");
u1.add("URL A3");
g1.addURLSeries(u1);
CustomCategoryURLGenerator g2 = (CustomCategoryURLGenerator) g1.clone();
assertNotSame(g1, g2);
assertSame(g1.getClass(), g2.getClass());
assertEquals(g1, g2);
// check independence
List<String> u2 = new java.util.ArrayList<String>();
u2.add("URL XXX");
g1.addURLSeries(u2);
assertFalse(g1.equals(g2));
g2.addURLSeries(new java.util.ArrayList<String>(u2));
assertEquals(g1, g2);
}
/**
* Checks that the class implements PublicCloneable.
*/
@Test
public void testPublicCloneable() {
CustomCategoryURLGenerator g1 = new CustomCategoryURLGenerator();
assertTrue(g1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
List<String> u1 = new java.util.ArrayList<String>();
u1.add("URL A1");
u1.add("URL A2");
u1.add("URL A3");
List<String> u2 = new java.util.ArrayList<String>();
u2.add("URL B1");
u2.add("URL B2");
u2.add("URL B3");
CustomCategoryURLGenerator g1 = new CustomCategoryURLGenerator();
g1.addURLSeries(u1);
g1.addURLSeries(u2);
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(g1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
CustomCategoryURLGenerator g2 = (CustomCategoryURLGenerator) in.readObject();
in.close();
assertEquals(g1, g2);
}
/**
* Some checks for the addURLSeries() method.
*/
@Test
public void testAddURLSeries() {
CustomCategoryURLGenerator g1 = new CustomCategoryURLGenerator();
// you can add a null list - it would have been better if this
// required EMPTY_LIST
g1.addURLSeries(null);
assertEquals(1, g1.getListCount());
assertEquals(0, g1.getURLCount(0));
List<String> list1 = new java.util.ArrayList<String>();
list1.add("URL1");
g1.addURLSeries(list1);
assertEquals(2, g1.getListCount());
assertEquals(0, g1.getURLCount(0));
assertEquals(1, g1.getURLCount(1));
assertEquals("URL1", g1.getURL(1, 0));
// if we modify the original list, it's best if the URL generator is
// not affected
list1.clear();
assertEquals("URL1", g1.getURL(1, 0));
}
}
| 6,041 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
StandardPieURLGeneratorTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/urls/StandardPieURLGeneratorTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ---------------------------------
* StandardPieURLGeneratorTests.java
* ---------------------------------
* (C) Copyright 2003-2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 21-Mar-2003 : Version 1 (DG);
* 06-Jan-2003 : Added a test for URL generation (DG);
* 24-Nov-2006 : New equals() test (DG);
* 17-Apr-2007 : Added additional check to testURL() (DG);
* 23-Apr-2008 : Added testPublicCloneable (DG);
*
*/
package org.jfree.chart.urls;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.data.general.DefaultPieDataset;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
/**
* Tests for the {@link StandardPieURLGenerator} class.
*/
public class StandardPieURLGeneratorTest {
/**
* Some checks for the equals() method.
*/
@Test
public void testEquals() {
StandardPieURLGenerator g1 = new StandardPieURLGenerator();
StandardPieURLGenerator g2 = new StandardPieURLGenerator();
assertEquals(g1, g2);
g1 = new StandardPieURLGenerator("prefix", "category", "index");
assertFalse(g1.equals(g2));
g2 = new StandardPieURLGenerator("prefix", "category", "index");
assertEquals(g1, g2);
g1 = new StandardPieURLGenerator("prefix2", "category", "index");
assertFalse(g1.equals(g2));
g2 = new StandardPieURLGenerator("prefix2", "category", "index");
assertEquals(g1, g2);
g1 = new StandardPieURLGenerator("prefix2", "category2", "index");
assertFalse(g1.equals(g2));
g2 = new StandardPieURLGenerator("prefix2", "category2", "index");
assertEquals(g1, g2);
g1 = new StandardPieURLGenerator("prefix2", "category2", "index2");
assertFalse(g1.equals(g2));
g2 = new StandardPieURLGenerator("prefix2", "category2", "index2");
assertEquals(g1, g2);
g1 = new StandardPieURLGenerator("prefix2", "category2", null);
assertFalse(g1.equals(g2));
g2 = new StandardPieURLGenerator("prefix2", "category2", null);
assertEquals(g1, g2);
}
/**
* Checks that the class does not implement PublicCloneable (the generator
* is immutable).
*/
@Test
public void testPublicCloneable() {
StandardPieURLGenerator g1 = new StandardPieURLGenerator(
"index.html?", "cat");
assertFalse(g1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
StandardPieURLGenerator g1 = new StandardPieURLGenerator(
"index.html?", "cat");
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(g1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
StandardPieURLGenerator g2 = (StandardPieURLGenerator) in.readObject();
in.close();
assertEquals(g1, g2);
}
/**
* Test that the generated URL is as expected.
*/
@Test
public void testURL() {
DefaultPieDataset dataset = new DefaultPieDataset();
dataset.setValue("Alpha '1'", new Double(5.0));
dataset.setValue("Beta", new Double(5.5));
StandardPieURLGenerator g1 = new StandardPieURLGenerator(
"chart.jsp", "category");
String url = g1.generateURL(dataset, "Beta", 0);
assertEquals("chart.jsp?category=Beta&pieIndex=0", url);
url = g1.generateURL(dataset, "Alpha '1'", 0);
assertEquals("chart.jsp?category=Alpha+%271%27&pieIndex=0", url);
}
}
| 5,420 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
StandardCategoryURLGeneratorTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/urls/StandardCategoryURLGeneratorTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* --------------------------------------
* StandardCategoryURLGeneratorTests.java
* --------------------------------------
* (C) Copyright 2003-2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 13-Aug-2003 : Version 1 (DG);
* 13-Dec-2007 : Added testGenerateURL() and testEquals() (DG);
* 23-Apr-2008 : Added testPublicCloneable (DG);
*
*/
package org.jfree.chart.urls;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.data.category.DefaultCategoryDataset;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
/**
* Tests for the {@link StandardCategoryURLGenerator} class.
*/
public class StandardCategoryURLGeneratorTest {
/**
* Some tests for the generateURL() method.
*/
@Test
public void testGenerateURL() {
StandardCategoryURLGenerator g1 = new StandardCategoryURLGenerator();
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.addValue(1.0, "R1", "C1");
dataset.addValue(2.0, "R2", "C2");
dataset.addValue(3.0, "R&", "C&");
assertEquals("index.html?series=R1&category=C1",
g1.generateURL(dataset, 0, 0));
assertEquals("index.html?series=R1&category=C2",
g1.generateURL(dataset, 0, 1));
assertEquals("index.html?series=R2&category=C2",
g1.generateURL(dataset, 1, 1));
assertEquals("index.html?series=R%26&category=C%26",
g1.generateURL(dataset, 2, 2));
}
/**
* Checks that the class does not implement PublicCloneable (the generator
* is immutable, so cloning is not necessary).
*/
@Test
public void testPublicCloneable() {
StandardCategoryURLGenerator g1 = new StandardCategoryURLGenerator();
assertFalse(g1 instanceof PublicCloneable);
}
/**
* Some tests for the equals() method.
*/
@Test
public void testEquals() {
StandardCategoryURLGenerator g1 = new StandardCategoryURLGenerator();
StandardCategoryURLGenerator g2 = new StandardCategoryURLGenerator();
assertEquals(g1, g2);
g1 = new StandardCategoryURLGenerator("index2.html?");
assertFalse(g1.equals(g2));
g2 = new StandardCategoryURLGenerator("index2.html?");
assertEquals(g1, g2);
g1 = new StandardCategoryURLGenerator("index2.html?", "A", "B");
assertFalse(g1.equals(g2));
g2 = new StandardCategoryURLGenerator("index2.html?", "A", "B");
assertEquals(g1, g2);
g1 = new StandardCategoryURLGenerator("index2.html?", "A", "C");
assertFalse(g1.equals(g2));
g2 = new StandardCategoryURLGenerator("index2.html?", "A", "C");
assertEquals(g1, g2);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
StandardCategoryURLGenerator g1 = new StandardCategoryURLGenerator(
"index.html?");
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(g1);
out.close();
ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(
buffer.toByteArray()));
StandardCategoryURLGenerator g2 = (StandardCategoryURLGenerator) in.readObject();
in.close();
assertEquals(g1, g2);
}
}
| 5,124 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
TimeSeriesURLGeneratorTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/urls/TimeSeriesURLGeneratorTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* --------------------------------
* TimeSeriesURLGeneratorTests.java
* --------------------------------
* (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 17-Apr-2007 : Version 1 (DG);
* 23-Apr-2008 : Added testPublicCloneable (DG);
*
*/
package org.jfree.chart.urls;
import org.jfree.chart.util.PublicCloneable;
import org.jfree.data.xy.DefaultXYDataset;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.text.SimpleDateFormat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link TimeSeriesURLGenerator} class.
*/
public class TimeSeriesURLGeneratorTest {
/**
* A basic check for the generateURL() method.
*/
@Test
public void testGenerateURL() {
TimeSeriesURLGenerator g = new TimeSeriesURLGenerator();
DefaultXYDataset dataset = new DefaultXYDataset();
dataset.addSeries("Series '1'", new double[][] {{1.0, 2.0},
{3.0, 4.0}});
String s = g.generateURL(dataset, 0, 0);
assertTrue(s.startsWith("index.html?series=Series+%271%27&item="));
}
/**
* Check that the equals() method can distinguish all fields.
*/
@Test
public void testEquals() {
TimeSeriesURLGenerator g1 = new TimeSeriesURLGenerator();
TimeSeriesURLGenerator g2 = new TimeSeriesURLGenerator();
assertEquals(g1, g2);
g1 = new TimeSeriesURLGenerator(new SimpleDateFormat("yyyy"), "prefix",
"series", "item");
assertFalse(g1.equals(g2));
g2 = new TimeSeriesURLGenerator(new SimpleDateFormat("yyyy"), "prefix",
"series", "item");
assertEquals(g1, g2);
g1 = new TimeSeriesURLGenerator(new SimpleDateFormat("yy"), "prefix",
"series", "item");
assertFalse(g1.equals(g2));
g2 = new TimeSeriesURLGenerator(new SimpleDateFormat("yy"), "prefix",
"series", "item");
assertEquals(g1, g2);
g1 = new TimeSeriesURLGenerator(new SimpleDateFormat("yy"), "prefix1",
"series", "item");
assertFalse(g1.equals(g2));
g2 = new TimeSeriesURLGenerator(new SimpleDateFormat("yy"), "prefix1",
"series", "item");
assertEquals(g1, g2);
g1 = new TimeSeriesURLGenerator(new SimpleDateFormat("yy"), "prefix1",
"series1", "item");
assertFalse(g1.equals(g2));
g2 = new TimeSeriesURLGenerator(new SimpleDateFormat("yy"), "prefix1",
"series1", "item");
assertEquals(g1, g2);
g1 = new TimeSeriesURLGenerator(new SimpleDateFormat("yy"), "prefix1",
"series1", "item1");
assertFalse(g1.equals(g2));
g2 = new TimeSeriesURLGenerator(new SimpleDateFormat("yy"), "prefix1",
"series1", "item1");
assertEquals(g1, g2);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
TimeSeriesURLGenerator g1 = new TimeSeriesURLGenerator();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(g1);
out.close();
ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(
buffer.toByteArray()));
TimeSeriesURLGenerator g2 = (TimeSeriesURLGenerator) in.readObject();
in.close();
assertEquals(g1, g2);
}
/**
* Checks that the class does not implement PublicCloneable (the generator
* is immutable).
*/
@Test
public void testPublicCloneable() {
TimeSeriesURLGenerator g1 = new TimeSeriesURLGenerator();
assertFalse(g1 instanceof PublicCloneable);
}
}
| 5,501 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
CustomXYURLGeneratorTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/urls/CustomXYURLGeneratorTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ------------------------------
* CustomXYURLGeneratorTests.java
* ------------------------------
* (C) Copyright 2003-2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 21-Mar-2003 : Version 1 (DG);
* 11-Apr-2008 : Added testCloning() and testEquals() (DG);
* 21-Apr-2008 : Enhanced testCloning() (DG);
* 23-Apr-2008 : Added testPublicCloneable (DG);
*
*/
package org.jfree.chart.urls;
import org.jfree.chart.util.PublicCloneable;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link CustomXYURLGenerator} class.
*/
public class CustomXYURLGeneratorTest {
/**
* Some checks for the equals() method.
*/
@Test
public void testEquals() {
CustomXYURLGenerator g1 = new CustomXYURLGenerator();
CustomXYURLGenerator g2 = new CustomXYURLGenerator();
assertEquals(g1, g2);
List<String> u1 = new java.util.ArrayList<String>();
u1.add("URL A1");
u1.add("URL A2");
u1.add("URL A3");
g1.addURLSeries(u1);
assertFalse(g1.equals(g2));
List<String> u2 = new java.util.ArrayList<String>();
u2.add("URL A1");
u2.add("URL A2");
u2.add("URL A3");
g2.addURLSeries(u2);
assertEquals(g1, g2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
CustomXYURLGenerator g1 = new CustomXYURLGenerator();
List<String> u1 = new java.util.ArrayList<String>();
u1.add("URL A1");
u1.add("URL A2");
u1.add("URL A3");
g1.addURLSeries(u1);
CustomXYURLGenerator g2 = (CustomXYURLGenerator) g1.clone();
assertNotSame(g1, g2);
assertSame(g1.getClass(), g2.getClass());
assertEquals(g1, g2);
// check independence
List<String> u2 = new java.util.ArrayList<String>();
u2.add("URL XXX");
g1.addURLSeries(u2);
assertFalse(g1.equals(g2));
g2.addURLSeries(new java.util.ArrayList<String>(u2));
assertEquals(g1, g2);
}
/**
* Checks that the class implements PublicCloneable.
*/
@Test
public void testPublicCloneable() {
CustomXYURLGenerator g1 = new CustomXYURLGenerator();
assertTrue(g1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
List<String> u1 = new java.util.ArrayList<String>();
u1.add("URL A1");
u1.add("URL A2");
u1.add("URL A3");
List<String> u2 = new java.util.ArrayList<String>();
u2.add("URL B1");
u2.add("URL B2");
u2.add("URL B3");
CustomXYURLGenerator g1 = new CustomXYURLGenerator();
g1.addURLSeries(u1);
g1.addURLSeries(u2);
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(g1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
CustomXYURLGenerator g2 = (CustomXYURLGenerator) in.readObject();
in.close();
assertEquals(g1, g2);
}
/**
* Some checks for the addURLSeries() method.
*/
@Test
public void testAddURLSeries() {
CustomXYURLGenerator g1 = new CustomXYURLGenerator();
// you can add a null list - it would have been better if this
// required EMPTY_LIST
g1.addURLSeries(null);
assertEquals(1, g1.getListCount());
assertEquals(0, g1.getURLCount(0));
List<String> list1 = new java.util.ArrayList<String>();
list1.add("URL1");
g1.addURLSeries(list1);
assertEquals(2, g1.getListCount());
assertEquals(0, g1.getURLCount(0));
assertEquals(1, g1.getURLCount(1));
assertEquals("URL1", g1.getURL(1, 0));
// if we modify the original list, it's best if the URL generator is
// not affected
list1.clear();
assertEquals("URL1", g1.getURL(1, 0));
}
}
| 6,033 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
StandardXYURLGeneratorTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/urls/StandardXYURLGeneratorTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* --------------------------------
* StandardXYURLGeneratorTests.java
* --------------------------------
* (C) Copyright 2004-2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 01-Mar-2004 : Version 1 (DG);
* 23-Apr-2008 : Added testPublicCloneable (DG);
*
*/
package org.jfree.chart.urls;
import org.jfree.chart.util.PublicCloneable;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
/**
* Tests for the {@link StandardXYURLGenerator} class.
*/
public class StandardXYURLGeneratorTest {
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
StandardXYURLGenerator g1 = new StandardXYURLGenerator("index.html?");
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(g1);
out.close();
ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(
buffer.toByteArray()));
StandardXYURLGenerator g2 = (StandardXYURLGenerator) in.readObject();
in.close();
assertEquals(g1, g2);
}
/**
* Checks that the class does not implement PublicCloneable (the generator
* is immutable).
*/
@Test
public void testPublicCloneable() {
StandardXYURLGenerator g1 = new StandardXYURLGenerator("index.html?");
assertFalse(g1 instanceof PublicCloneable);
}
}
| 3,162 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
CustomPieURLGeneratorTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/urls/CustomPieURLGeneratorTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* -------------------------------
* CustomPieURLGeneratorTests.java
* -------------------------------
* (C) Copyright 2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 11-Apr-2008 : Version 1 (DG);
* 23-Apr-2008 : Added testPublicCloneable (DG);
*
*/
package org.jfree.chart.urls;
import org.jfree.chart.util.PublicCloneable;
import org.junit.Test;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.util.HashMap;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Tests for the {@link CustomPieURLGenerator} class.
*/
public class CustomPieURLGeneratorTest {
/**
* Some checks for the equals() method.
*/
@Test
public void testEquals() {
CustomPieURLGenerator g1 = new CustomPieURLGenerator();
CustomPieURLGenerator g2 = new CustomPieURLGenerator();
assertEquals(g1, g2);
Map<Comparable, String> m1 = new HashMap<Comparable, String>();
m1.put("A", "http://www.jfree.org/");
g1.addURLs(m1);
assertFalse(g1.equals(g2));
g2.addURLs(m1);
assertEquals(g1, g2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
CustomPieURLGenerator g1 = new CustomPieURLGenerator();
Map<Comparable, String> m1 = new HashMap<Comparable, String>();
m1.put("A", "http://www.jfree.org/");
g1.addURLs(m1);
CustomPieURLGenerator g2 = (CustomPieURLGenerator) g1.clone();
assertNotSame(g1, g2);
assertSame(g1.getClass(), g2.getClass());
assertEquals(g1, g2);
// check independence
Map<Comparable, String> m2 = new HashMap<Comparable, String>();
m2.put("B", "XYZ");
g1.addURLs(m2);
assertFalse(g1.equals(g2));
}
/**
* Checks that the class implements PublicCloneable.
*/
@Test
public void testPublicCloneable() {
CustomPieURLGenerator g1 = new CustomPieURLGenerator();
assertTrue(g1 instanceof PublicCloneable);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
CustomPieURLGenerator g1 = new CustomPieURLGenerator();
Map<Comparable, String> m1 = new HashMap<Comparable, String>();
m1.put("A", "http://www.jfree.org/");
g1.addURLs(m1);
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(g1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
CustomPieURLGenerator g2 = (CustomPieURLGenerator) in.readObject();
in.close();
assertEquals(g1, g2);
}
}
| 4,578 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
CrosshairOverlayTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/panel/CrosshairOverlayTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* --------------------------
* CrosshairOverlayTests.java
* --------------------------
* (C) Copyright 2009, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 10-Apr-2009 : Version 1 (DG);
*
*/
package org.jfree.chart.panel;
import org.jfree.chart.plot.Crosshair;
import org.junit.Test;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.GradientPaint;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
/**
* Tests for the {@link CrosshairOverlay} class.
*/
public class CrosshairOverlayTest {
/**
* Confirm that the equals method can distinguish all the required fields.
*/
@Test
public void testEquals() {
CrosshairOverlay o1 = new CrosshairOverlay();
CrosshairOverlay o2 = new CrosshairOverlay();
assertEquals(o1, o2);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
CrosshairOverlay o1 = new CrosshairOverlay();
o1.addDomainCrosshair(new Crosshair(99.9));
o1.addRangeCrosshair(new Crosshair(1.23, new GradientPaint(1.0f, 2.0f,
Color.RED, 3.0f, 4.0f, Color.BLUE), new BasicStroke(1.1f)));
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(o1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray()));
CrosshairOverlay o2 = (CrosshairOverlay) in.readObject();
in.close();
assertEquals(o1, o2);
}
/**
* Basic checks for cloning.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
CrosshairOverlay o1 = new CrosshairOverlay();
o1.addDomainCrosshair(new Crosshair(99.9));
o1.addRangeCrosshair(new Crosshair(1.23, new GradientPaint(1.0f, 2.0f,
Color.RED, 3.0f, 4.0f, Color.BLUE), new BasicStroke(1.1f)));
CrosshairOverlay o2 = (CrosshairOverlay) o1.clone();
assertNotSame(o1, o2);
assertSame(o1.getClass(), o2.getClass());
assertEquals(o1, o2);
o1.addDomainCrosshair(new Crosshair(3.21));
o1.addRangeCrosshair(new Crosshair(4.32));
assertFalse(o1.equals(o2));
}
}
| 4,095 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
StandardEntityCollectionTest.java | /FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/entity/StandardEntityCollectionTest.java | /* ===========================================================
* JFreeChart : a free chart library for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2000-2012, by Object Refinery Limited and Contributors.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* ----------------------------------
* StandardEntityCollectionTests.java
* ----------------------------------
* (C) Copyright 2004-2008, by Object Refinery Limited and Contributors.
*
* Original Author: David Gilbert (for Object Refinery Limited);
* Contributor(s): -;
*
* Changes
* -------
* 19-May-2004 : Version 1 (DG);
*
*/
package org.jfree.chart.entity;
import org.jfree.data.general.DefaultPieDataset;
import org.junit.Test;
import java.awt.geom.Rectangle2D;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
/**
* Tests for the {@link StandardEntityCollection} class.
*/
public class StandardEntityCollectionTest {
/**
* Confirm that the equals method can distinguish all the required fields.
*/
@Test
public void testEquals() {
StandardEntityCollection c1 = new StandardEntityCollection();
StandardEntityCollection c2 = new StandardEntityCollection();
assertEquals(c1, c2);
PieSectionEntity e1 = new PieSectionEntity(new Rectangle2D.Double(1.0,
2.0, 3.0, 4.0), new DefaultPieDataset(), 0, 1, "Key",
"ToolTip", "URL");
c1.add(e1);
assertFalse(c1.equals(c2));
PieSectionEntity e2 = new PieSectionEntity(new Rectangle2D.Double(1.0,
2.0, 3.0, 4.0), new DefaultPieDataset(), 0, 1, "Key",
"ToolTip", "URL");
c2.add(e2);
assertEquals(c1, c2);
}
/**
* Confirm that cloning works.
*/
@Test
public void testCloning() throws CloneNotSupportedException {
PieSectionEntity e1 = new PieSectionEntity(new Rectangle2D.Double(1.0,
2.0, 3.0, 4.0), new DefaultPieDataset(), 0, 1, "Key",
"ToolTip", "URL");
StandardEntityCollection c1 = new StandardEntityCollection();
c1.add(e1);
StandardEntityCollection c2 = (StandardEntityCollection) c1.clone();
assertNotSame(c1, c2);
assertSame(c1.getClass(), c2.getClass());
assertEquals(c1, c2);
// check independence
c1.clear();
assertFalse(c1.equals(c2));
c2.clear();
assertEquals(c1, c2);
}
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() throws IOException, ClassNotFoundException {
PieSectionEntity e1 = new PieSectionEntity(new Rectangle2D.Double(1.0,
2.0, 3.0, 4.0), new DefaultPieDataset(), 0, 1, "Key",
"ToolTip", "URL");
StandardEntityCollection c1 = new StandardEntityCollection();
c1.add(e1);
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(c1);
out.close();
ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(
buffer.toByteArray()));
StandardEntityCollection c2 = (StandardEntityCollection) in.readObject();
in.close();
assertEquals(c1, c2);
}
}
| 4,636 | Java | .java | akardapolov/ASH-Viewer | 156 | 72 | 35 | 2011-05-25T05:22:11Z | 2023-12-04T11:03:40Z |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.