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
CategoryLabelEntityTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/entity/CategoryLabelEntityTest.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.] * * ----------------------------- * CategoryLabelEntityTests.java * ----------------------------- * (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 17-Nov-2007 : Version 1 (DG); * */ package org.jfree.chart.entity; 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 CategoryLabelEntity} class. */ public class CategoryLabelEntityTest { /** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { CategoryLabelEntity e1 = new CategoryLabelEntity("A", new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), "ToolTip", "URL"); CategoryLabelEntity e2 = new CategoryLabelEntity("A", new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), "ToolTip", "URL"); assertEquals(e1, e2); e1 = new CategoryLabelEntity("B", new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), "ToolTip", "URL"); assertFalse(e1.equals(e2)); e2 = new CategoryLabelEntity("B", new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), "ToolTip", "URL"); assertEquals(e1, e2); e1.setArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); assertFalse(e1.equals(e2)); e2.setArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); assertEquals(e1, e2); e1.setToolTipText("New ToolTip"); assertFalse(e1.equals(e2)); e2.setToolTipText("New ToolTip"); assertEquals(e1, e2); e1.setURLText("New URL"); assertFalse(e1.equals(e2)); e2.setURLText("New URL"); assertEquals(e1, e2); } /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { CategoryLabelEntity e1 = new CategoryLabelEntity("A", new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), "ToolTip", "URL"); CategoryLabelEntity e2 = (CategoryLabelEntity) e1.clone(); assertNotSame(e1, e2); assertSame(e1.getClass(), e2.getClass()); assertEquals(e1, e2); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { CategoryLabelEntity e1 = new CategoryLabelEntity("A", new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), "ToolTip", "URL"); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(e1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); CategoryLabelEntity e2 = (CategoryLabelEntity) in.readObject(); in.close(); assertEquals(e1, e2); } }
4,599
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
LegendItemEntityTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/entity/LegendItemEntityTest.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.] * * -------------------------- * LegendItemEntityTests.java * -------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-May-2004 : Version 1 (DG); * 18-May-2007 : Added checks for new fields (DG); * */ package org.jfree.chart.entity; import org.jfree.data.category.DefaultCategoryDataset; 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 LegendItemEntity} class. */ public class LegendItemEntityTest { /** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { LegendItemEntity e1 = new LegendItemEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); LegendItemEntity e2 = new LegendItemEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); assertEquals(e1, e2); e1.setArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); assertFalse(e1.equals(e2)); e2.setArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); assertEquals(e1, e2); e1.setToolTipText("New ToolTip"); assertFalse(e1.equals(e2)); e2.setToolTipText("New ToolTip"); assertEquals(e1, e2); e1.setURLText("New URL"); assertFalse(e1.equals(e2)); e2.setURLText("New URL"); assertEquals(e1, e2); e1.setDataset(new DefaultCategoryDataset()); assertFalse(e1.equals(e2)); e2.setDataset(new DefaultCategoryDataset()); assertEquals(e1, e2); e1.setSeriesKey("A"); assertFalse(e1.equals(e2)); e2.setSeriesKey("A"); assertEquals(e1, e2); } /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { LegendItemEntity e1 = new LegendItemEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); LegendItemEntity e2 = (LegendItemEntity) e1.clone(); assertNotSame(e1, e2); assertSame(e1.getClass(), e2.getClass()); assertEquals(e1, e2); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { LegendItemEntity e1 = new LegendItemEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(e1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); LegendItemEntity e2 = (LegendItemEntity) in.readObject(); in.close(); assertEquals(e1, e2); } }
4,551
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
TickLabelEntityTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/entity/TickLabelEntityTest.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.] * * ------------------------- * TickLabelEntityTests.java * ------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-May-2004 : Version 1 (DG); * */ package org.jfree.chart.entity; 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 TickLabelEntity} class. */ public class TickLabelEntityTest { /** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { TickLabelEntity e1 = new TickLabelEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), "ToolTip", "URL"); TickLabelEntity e2 = new TickLabelEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), "ToolTip", "URL"); assertEquals(e1, e2); e1.setArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); assertFalse(e1.equals(e2)); e2.setArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); assertEquals(e1, e2); e1.setToolTipText("New ToolTip"); assertFalse(e1.equals(e2)); e2.setToolTipText("New ToolTip"); assertEquals(e1, e2); e1.setURLText("New URL"); assertFalse(e1.equals(e2)); e2.setURLText("New URL"); assertEquals(e1, e2); } /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { TickLabelEntity e1 = new TickLabelEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), "ToolTip", "URL"); TickLabelEntity e2 = (TickLabelEntity) e1.clone(); assertNotSame(e1, e2); assertSame(e1.getClass(), e2.getClass()); assertEquals(e1, e2); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { TickLabelEntity e1 = new TickLabelEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), "ToolTip", "URL"); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(e1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); TickLabelEntity e2 = (TickLabelEntity) in.readObject(); in.close(); assertEquals(e1, e2); } }
4,200
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
PieSectionEntityTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/entity/PieSectionEntityTest.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.] * * -------------------------- * PieSectionEntityTests.java * -------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-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 PieSectionEntity} class. */ public class PieSectionEntityTest { /** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { PieSectionEntity e1 = new PieSectionEntity(new Rectangle2D.Double( 1.0, 2.0, 3.0, 4.0), new DefaultPieDataset(), 1, 2, "Key", "ToolTip", "URL"); PieSectionEntity e2 = new PieSectionEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new DefaultPieDataset(), 1, 2, "Key", "ToolTip", "URL"); assertEquals(e1, e2); e1.setArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); assertFalse(e1.equals(e2)); e2.setArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); assertEquals(e1, e2); e1.setToolTipText("New ToolTip"); assertFalse(e1.equals(e2)); e2.setToolTipText("New ToolTip"); assertEquals(e1, e2); e1.setURLText("New URL"); assertFalse(e1.equals(e2)); e2.setURLText("New URL"); assertEquals(e1, e2); e1.setDataset(null); assertFalse(e1.equals(e2)); e2.setDataset(null); assertEquals(e1, e2); e1.setPieIndex(99); assertFalse(e1.equals(e2)); e2.setPieIndex(99); assertEquals(e1, e2); e1.setSectionIndex(66); assertFalse(e1.equals(e2)); e2.setSectionIndex(66); assertEquals(e1, e2); e1.setSectionKey("ABC"); assertFalse(e1.equals(e2)); e2.setSectionKey("ABC"); assertEquals(e1, e2); } /** * 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(), 1, 2, "Key", "ToolTip", "URL"); PieSectionEntity e2 = (PieSectionEntity) e1.clone(); assertNotSame(e1, e2); assertSame(e1.getClass(), e2.getClass()); assertEquals(e1, e2); } /** * 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(), 1, 2, "Key", "ToolTip", "URL"); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(e1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); PieSectionEntity e2 = (PieSectionEntity) in.readObject(); in.close(); assertEquals(e1, e2); } }
4,993
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
XYItemEntityTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/entity/XYItemEntityTest.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.] * * ---------------------- * XYItemEntityTests.java * ---------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-May-2004 : Version 1 (DG); * */ package org.jfree.chart.entity; import org.jfree.data.time.TimeSeriesCollection; 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 XYItemEntity} class. */ public class XYItemEntityTest { /** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { XYItemEntity e1 = new XYItemEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new TimeSeriesCollection(), 1, 9, "ToolTip", "URL"); XYItemEntity e2 = new XYItemEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new TimeSeriesCollection(), 1, 9, "ToolTip", "URL"); assertEquals(e1, e2); e1.setArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); assertFalse(e1.equals(e2)); e2.setArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); assertEquals(e1, e2); e1.setToolTipText("New ToolTip"); assertFalse(e1.equals(e2)); e2.setToolTipText("New ToolTip"); assertEquals(e1, e2); e1.setURLText("New URL"); assertFalse(e1.equals(e2)); e2.setURLText("New URL"); assertEquals(e1, e2); e1.setSeriesIndex(88); assertFalse(e1.equals(e2)); e2.setSeriesIndex(88); assertEquals(e1, e2); e1.setItem(88); assertFalse(e1.equals(e2)); e2.setItem(88); assertEquals(e1, e2); } /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { XYItemEntity e1 = new XYItemEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new TimeSeriesCollection(), 1, 9, "ToolTip", "URL"); XYItemEntity e2 = (XYItemEntity) e1.clone(); assertNotSame(e1, e2); assertSame(e1.getClass(), e2.getClass()); assertEquals(e1, e2); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { XYItemEntity e1 = new XYItemEntity(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new TimeSeriesCollection(), 1, 9, "ToolTip", "URL"); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(e1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); XYItemEntity e2 = (XYItemEntity) in.readObject(); in.close(); assertEquals(e1, e2); } }
4,576
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
CategoryItemEntityTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/entity/CategoryItemEntityTest.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.] * * ---------------------------- * CategoryItemEntityTests.java * ---------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-May-2004 : Version 1 (DG); * */ package org.jfree.chart.entity; import org.jfree.data.category.DefaultCategoryDataset; 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 CategoryItemEntity} class. */ public class CategoryItemEntityTest { /** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { DefaultCategoryDataset d = new DefaultCategoryDataset(); d.addValue(1.0, "R1", "C1"); d.addValue(2.0, "R1", "C2"); d.addValue(3.0, "R2", "C1"); d.addValue(4.0, "R2", "C2"); CategoryItemEntity e1 = new CategoryItemEntity(new Rectangle2D.Double( 1.0, 2.0, 3.0, 4.0), "ToolTip", "URL", d, "R1", "C2"); CategoryItemEntity e2 = new CategoryItemEntity(new Rectangle2D.Double( 1.0, 2.0, 3.0, 4.0), "ToolTip", "URL", d, "R1", "C2"); assertEquals(e1, e2); e1.setArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); assertFalse(e1.equals(e2)); e2.setArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); assertEquals(e1, e2); e1.setToolTipText("New ToolTip"); assertFalse(e1.equals(e2)); e2.setToolTipText("New ToolTip"); assertEquals(e1, e2); e1.setURLText("New URL"); assertFalse(e1.equals(e2)); e2.setURLText("New URL"); assertEquals(e1, e2); e1.setColumnKey("C1"); assertFalse(e1.equals(e2)); e2.setColumnKey("C1"); assertEquals(e1, e2); e1.setRowKey("R2"); assertFalse(e1.equals(e2)); e2.setRowKey("R2"); assertEquals(e1, e2); } /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { DefaultCategoryDataset d = new DefaultCategoryDataset(); d.addValue(1.0, "R1", "C1"); d.addValue(2.0, "R1", "C2"); d.addValue(3.0, "R2", "C1"); d.addValue(4.0, "R2", "C2"); CategoryItemEntity e1 = new CategoryItemEntity(new Rectangle2D.Double( 1.0, 2.0, 3.0, 4.0), "ToolTip", "URL", d, "R1", "C2"); CategoryItemEntity e2 = (CategoryItemEntity) e1.clone(); assertNotSame(e1, e2); assertSame(e1.getClass(), e2.getClass()); assertEquals(e1, e2); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { DefaultCategoryDataset d = new DefaultCategoryDataset(); d.addValue(1.0, "R1", "C1"); d.addValue(2.0, "R1", "C2"); d.addValue(3.0, "R2", "C1"); d.addValue(4.0, "R2", "C2"); CategoryItemEntity e1 = new CategoryItemEntity(new Rectangle2D.Double( 1.0, 2.0, 3.0, 4.0), "ToolTip", "URL", d, "R1", "C2"); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(e1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); CategoryItemEntity e2 = (CategoryItemEntity) in.readObject(); in.close(); assertEquals(e1, e2); } }
5,260
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
DynamicDriveToolTipTagFragmentGeneratorTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/imagemap/DynamicDriveToolTipTagFragmentGeneratorTest.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.] * * ------------------------------------------------- * DynamicDriveToolTipTagFragmentGeneratorTests.java * ------------------------------------------------- * (C) Copyright 2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 25-Mar-2009 : Version 1 (DG); * */ package org.jfree.chart.imagemap; import org.junit.Test; import static org.junit.Assert.assertEquals; /** * Tests for the {@link DynamicDriveToolTipTagFragmentGenerator} class. */ public class DynamicDriveToolTipTagFragmentGeneratorTest { /** * Some checks for the generateURLFragment() method. */ @Test public void testGenerateURLFragment() { OverLIBToolTipTagFragmentGenerator g = new OverLIBToolTipTagFragmentGenerator(); assertEquals(" onMouseOver=\"return overlib('abc');\"" + " onMouseOut=\"return nd();\"", g.generateToolTipFragment("abc")); assertEquals(" onMouseOver=\"return overlib(" + "'It\\'s \\\"A\\\", 100.0');\" onMouseOut=\"return nd();\"", g.generateToolTipFragment("It\'s \"A\", 100.0")); } }
2,466
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
StandardToolTipTagFragmentGeneratorTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/imagemap/StandardToolTipTagFragmentGeneratorTest.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.] * * --------------------------------------------- * StandardToolTipTagFragmentGeneratorTests.java * --------------------------------------------- * (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 05-Dec-2007 : Version 1 (DG); * */ package org.jfree.chart.imagemap; import org.junit.Test; import static org.junit.Assert.assertEquals; /** * Tests for the {@link StandardToolTipTagFragmentGenerator} class. */ public class StandardToolTipTagFragmentGeneratorTest { /** * Some checks for the generateURLFragment() method. */ @Test public void testGenerateURLFragment() { StandardToolTipTagFragmentGenerator g = new StandardToolTipTagFragmentGenerator(); assertEquals(" title=\"abc\" alt=\"\"", g.generateToolTipFragment("abc")); assertEquals(" title=\"Series "A", 100.0\" alt=\"\"", g.generateToolTipFragment("Series \"A\", 100.0")); } }
2,329
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
OverLIBToolTipTagFragmentGeneratorTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/imagemap/OverLIBToolTipTagFragmentGeneratorTest.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.] * * -------------------------------------------- * OverLIBToolTipTagFragmentGeneratorTests.java * -------------------------------------------- * (C) Copyright 2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 25-Mar-2009 : Version 1 (DG); * */ package org.jfree.chart.imagemap; import org.junit.Test; import static org.junit.Assert.assertEquals; /** * Tests for the {@link OverLIBToolTipTagFragmentGenerator} class. */ public class OverLIBToolTipTagFragmentGeneratorTest { /** * Some checks for the generateURLFragment() method. */ @Test public void testGenerateURLFragment() { OverLIBToolTipTagFragmentGenerator g = new OverLIBToolTipTagFragmentGenerator(); assertEquals(" onMouseOver=\"return overlib('abc');\"" + " onMouseOut=\"return nd();\"", g.generateToolTipFragment("abc")); assertEquals(" onMouseOver=\"return overlib(" + "'It\\'s \\\"A\\\", 100.0');\" onMouseOut=\"return nd();\"", g.generateToolTipFragment("It\'s \"A\", 100.0")); } }
2,441
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
StandardURLTagFragmentGeneratorTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/imagemap/StandardURLTagFragmentGeneratorTest.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.] * * ----------------------------------------- * StandardURLTagFragmentGeneratorTests.java * ----------------------------------------- * (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 05-Dec-2007 : Version 1 (DG); * */ package org.jfree.chart.imagemap; import org.junit.Test; import static org.junit.Assert.assertEquals; /** * Tests for the {@link StandardURLTagFragmentGenerator} class. */ public class StandardURLTagFragmentGeneratorTest { /** * Some checks for the generateURLFragment() method. */ @Test public void testGenerateURLFragment() { StandardURLTagFragmentGenerator g = new StandardURLTagFragmentGenerator(); assertEquals(" href=\"abc\"", g.generateURLFragment("abc")); assertEquals(" href=\"images/abc.png\"", g.generateURLFragment("images/abc.png")); assertEquals(" href=\"http://www.jfree.org/images/abc.png\"", g.generateURLFragment("http://www.jfree.org/images/abc.png")); } }
2,388
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
ImageMapUtilitiesTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/imagemap/ImageMapUtilitiesTest.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.] * * --------------------------- * ImageMapUtilitiesTests.java * --------------------------- * (C) Copyright 2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 25-Mar-2009 : Version 1 (DG); * */ package org.jfree.chart.imagemap; import org.junit.Test; import static org.junit.Assert.assertEquals; /** * Tests for the {@link ImageMapUtilities} class. */ public class ImageMapUtilitiesTest { /** * Some checks for the htmlEscape() method. */ @Test public void testHTMLEscape() { assertEquals("", ImageMapUtilities.htmlEscape("")); assertEquals("abc", ImageMapUtilities.htmlEscape("abc")); assertEquals("&amp;", ImageMapUtilities.htmlEscape("&")); assertEquals("&quot;", ImageMapUtilities.htmlEscape("\"")); assertEquals("&lt;", ImageMapUtilities.htmlEscape("<")); assertEquals("&gt;", ImageMapUtilities.htmlEscape(">")); assertEquals("&#39;", ImageMapUtilities.htmlEscape("\'")); assertEquals("&#092;abc", ImageMapUtilities.htmlEscape("\\abc")); assertEquals("abc\n", ImageMapUtilities.htmlEscape("abc\n")); } /** * Some checks for the javascriptEscape() method. */ @Test public void testJavascriptEscape() { assertEquals("", ImageMapUtilities.javascriptEscape("")); assertEquals("abc", ImageMapUtilities.javascriptEscape("abc")); assertEquals("\\\'", ImageMapUtilities.javascriptEscape("\'")); assertEquals("\\\"", ImageMapUtilities.javascriptEscape("\"")); assertEquals("\\\\", ImageMapUtilities.javascriptEscape("\\")); } }
2,956
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
CategoryTickTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/axis/CategoryTickTest.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.] * * ---------------------- * CategoryTickTests.java * ---------------------- * (C) Copyright 2004-2012, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 13-May-2004 : Version 1 (DG); * 07-Jan-2005 : Added test for hashCode() (DG); * 17-Jun-2012 : Removed JCommon dependencies (DG); * */ package org.jfree.chart.axis; import org.jfree.chart.text.TextBlock; import org.jfree.chart.text.TextBlockAnchor; import org.jfree.chart.text.TextLine; import org.jfree.chart.ui.TextAnchor; 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 CategoryTick} class. */ public class CategoryTickTest { /** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { Comparable c1 = "C1"; Comparable c2 = "C2"; TextBlock tb1 = new TextBlock(); tb1.addLine(new TextLine("Block 1")); TextBlock tb2 = new TextBlock(); tb1.addLine(new TextLine("Block 2")); TextBlockAnchor tba1 = TextBlockAnchor.CENTER; TextBlockAnchor tba2 = TextBlockAnchor.BOTTOM_CENTER; TextAnchor ta1 = TextAnchor.CENTER; TextAnchor ta2 = TextAnchor.BASELINE_LEFT; CategoryTick t1 = new CategoryTick(c1, tb1, tba1, ta1, 1.0f); CategoryTick t2 = new CategoryTick(c1, tb1, tba1, ta1, 1.0f); assertEquals(t1, t2); t1 = new CategoryTick(c2, tb1, tba1, ta1, 1.0f); assertFalse(t1.equals(t2)); t2 = new CategoryTick(c2, tb1, tba1, ta1, 1.0f); assertEquals(t1, t2); t1 = new CategoryTick(c2, tb2, tba1, ta1, 1.0f); assertFalse(t1.equals(t2)); t2 = new CategoryTick(c2, tb2, tba1, ta1, 1.0f); assertEquals(t1, t2); t1 = new CategoryTick(c2, tb2, tba2, ta1, 1.0f); assertFalse(t1.equals(t2)); t2 = new CategoryTick(c2, tb2, tba2, ta1, 1.0f); assertEquals(t1, t2); t1 = new CategoryTick(c2, tb2, tba2, ta2, 1.0f); assertFalse(t1.equals(t2)); t2 = new CategoryTick(c2, tb2, tba2, ta2, 1.0f); assertEquals(t1, t2); t1 = new CategoryTick(c2, tb2, tba2, ta2, 2.0f); assertFalse(t1.equals(t2)); t2 = new CategoryTick(c2, tb2, tba2, ta2, 2.0f); assertEquals(t1, t2); } /** * Two objects that are equal are required to return the same hashCode. */ @Test public void testHashCode() { Comparable c1 = "C1"; TextBlock tb1 = new TextBlock(); tb1.addLine(new TextLine("Block 1")); tb1.addLine(new TextLine("Block 2")); TextBlockAnchor tba1 = TextBlockAnchor.CENTER; TextAnchor ta1 = TextAnchor.CENTER; CategoryTick t1 = new CategoryTick(c1, tb1, tba1, ta1, 1.0f); CategoryTick t2 = new CategoryTick(c1, tb1, tba1, ta1, 1.0f); assertEquals(t1, t2); int h1 = t1.hashCode(); int h2 = t2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { CategoryTick t1 = new CategoryTick( "C1", new TextBlock(), TextBlockAnchor.CENTER, TextAnchor.CENTER, 1.5f ); CategoryTick t2 = (CategoryTick) 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 { CategoryTick t1 = new CategoryTick("C1", new TextBlock(), TextBlockAnchor.CENTER, TextAnchor.CENTER, 1.5f); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(t1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); CategoryTick t2 = (CategoryTick) in.readObject(); in.close(); assertEquals(t1, t2); } }
5,850
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
ExtendedCategoryAxisTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/axis/ExtendedCategoryAxisTest.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.] * * ------------------------------ * ExtendedCategoryAxisTests.java * ------------------------------ * (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 21-Mar-2007 : Version 1 (DG); * */ package org.jfree.chart.axis; 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 ExtendedCategoryAxis} class. */ public class ExtendedCategoryAxisTest { /** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { ExtendedCategoryAxis a1 = new ExtendedCategoryAxis("Test"); ExtendedCategoryAxis a2 = new ExtendedCategoryAxis("Test"); assertEquals(a1, a2); a1.addSubLabel("C1", "C1-sublabel"); assertFalse(a1.equals(a2)); a2.addSubLabel("C1", "C1-sublabel"); assertEquals(a1, a2); a1.setSubLabelFont(new Font("Dialog", Font.BOLD, 8)); assertFalse(a1.equals(a2)); a2.setSubLabelFont(new Font("Dialog", Font.BOLD, 8)); assertEquals(a1, a2); a1.setSubLabelPaint(Color.RED); assertFalse(a1.equals(a2)); a2.setSubLabelPaint(Color.RED); assertEquals(a1, a2); } /** * Two objects that are equal are required to return the same hashCode. */ @Test public void testHashCode() { ExtendedCategoryAxis a1 = new ExtendedCategoryAxis("Test"); ExtendedCategoryAxis a2 = new ExtendedCategoryAxis("Test"); assertEquals(a1, a2); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { ExtendedCategoryAxis a1 = new ExtendedCategoryAxis("Test"); ExtendedCategoryAxis a2 = (ExtendedCategoryAxis) a1.clone(); assertNotSame(a1, a2); assertSame(a1.getClass(), a2.getClass()); assertEquals(a1, a2); // check independence a1.addSubLabel("C1", "ABC"); assertFalse(a1.equals(a2)); a2.addSubLabel("C1", "ABC"); assertEquals(a1, a2); } /** * Confirm that cloning works. This test customises the font and paint * per category label. */ @Test public void testCloning2() throws CloneNotSupportedException { ExtendedCategoryAxis a1 = new ExtendedCategoryAxis("Test"); a1.setTickLabelFont("C1", new Font("Dialog", Font.PLAIN, 15)); a1.setTickLabelPaint("C1", new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.WHITE)); ExtendedCategoryAxis a2 = (ExtendedCategoryAxis) a1.clone(); assertNotSame(a1, a2); assertSame(a1.getClass(), a2.getClass()); assertEquals(a1, a2); // check that changing a tick label font in a1 doesn't change a2 a1.setTickLabelFont("C1", null); assertFalse(a1.equals(a2)); a2.setTickLabelFont("C1", null); assertEquals(a1, a2); // check that changing a tick label paint in a1 doesn't change a2 a1.setTickLabelPaint("C1", Color.yellow); assertFalse(a1.equals(a2)); a2.setTickLabelPaint("C1", Color.yellow); assertEquals(a1, a2); // check that changing a category label tooltip in a1 doesn't change a2 a1.addCategoryLabelToolTip("C1", "XYZ"); assertFalse(a1.equals(a2)); a2.addCategoryLabelToolTip("C1", "XYZ"); assertEquals(a1, a2); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { ExtendedCategoryAxis a1 = new ExtendedCategoryAxis("Test"); a1.setSubLabelPaint(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(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); ExtendedCategoryAxis a2 = (ExtendedCategoryAxis) in.readObject(); in.close(); assertEquals(a1, a2); } }
6,094
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
PeriodAxisLabelInfoTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/axis/PeriodAxisLabelInfoTest.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.] * * ----------------------------- * PeriodAxisLabelInfoTests.java * ----------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 10-Jun-2003 : Version 1 (DG); * 07-Jan-2005 : Added test for hashCode() (DG); * */ package org.jfree.chart.axis; import org.jfree.chart.ui.RectangleInsets; import org.jfree.data.time.Day; import org.jfree.data.time.Month; import org.junit.Test; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; import java.awt.Paint; 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 java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; import java.util.TimeZone; 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 PeriodAxisLabelInfo} class. */ public class PeriodAxisLabelInfoTest { /** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { PeriodAxisLabelInfo info1 = new PeriodAxisLabelInfo(Day.class, new SimpleDateFormat("d")); PeriodAxisLabelInfo info2 = new PeriodAxisLabelInfo(Day.class, new SimpleDateFormat("d")); assertEquals(info1, info2); assertEquals(info2, info1); Class c1 = Day.class; Class c2 = Month.class; DateFormat df1 = new SimpleDateFormat("d"); DateFormat df2 = new SimpleDateFormat("MMM"); RectangleInsets sp1 = new RectangleInsets(1, 1, 1, 1); RectangleInsets sp2 = new RectangleInsets(2, 2, 2, 2); Font lf1 = new Font("SansSerif", Font.PLAIN, 10); Font lf2 = new Font("SansSerif", Font.BOLD, 9); Paint lp1 = Color.BLACK; Paint lp2 = Color.BLUE; boolean b1 = true; boolean b2 = false; Stroke s1 = new BasicStroke(0.5f); Stroke s2 = new BasicStroke(0.25f); Paint dp1 = Color.RED; Paint dp2 = Color.green; info1 = new PeriodAxisLabelInfo(c2, df1, sp1, lf1, lp1, b1, s1, dp1); info2 = new PeriodAxisLabelInfo(c1, df1, sp1, lf1, lp1, b1, s1, dp1); assertFalse(info1.equals(info2)); info2 = new PeriodAxisLabelInfo(c2, df1, sp1, lf1, lp1, b1, s1, dp1); assertEquals(info1, info2); info1 = new PeriodAxisLabelInfo(c2, df2, sp1, lf1, lp1, b1, s1, dp1); assertFalse(info1.equals(info2)); info2 = new PeriodAxisLabelInfo(c2, df2, sp1, lf1, lp1, b1, s1, dp1); assertEquals(info1, info2); info1 = new PeriodAxisLabelInfo(c2, df2, sp2, lf1, lp1, b1, s1, dp1); assertFalse(info1.equals(info2)); info2 = new PeriodAxisLabelInfo(c2, df2, sp2, lf1, lp1, b1, s1, dp1); assertEquals(info1, info2); info1 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp1, b1, s1, dp1); assertFalse(info1.equals(info2)); info2 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp1, b1, s1, dp1); assertEquals(info1, info2); info1 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp2, b1, s1, dp1); assertFalse(info1.equals(info2)); info2 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp2, b1, s1, dp1); assertEquals(info1, info2); info1 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp2, b2, s1, dp1); assertFalse(info1.equals(info2)); info2 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp2, b2, s1, dp1); assertEquals(info1, info2); info1 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp2, b2, s2, dp1); assertFalse(info1.equals(info2)); info2 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp2, b2, s2, dp1); assertEquals(info1, info2); info1 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp2, b2, s2, dp2); assertFalse(info1.equals(info2)); info2 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp2, b2, s2, dp2); assertEquals(info1, info2); } /** * Two objects that are equal are required to return the same hashCode. */ @Test public void testHashCode() { PeriodAxisLabelInfo info1 = new PeriodAxisLabelInfo(Day.class, new SimpleDateFormat("d")); PeriodAxisLabelInfo info2 = new PeriodAxisLabelInfo(Day.class, new SimpleDateFormat("d")); assertEquals(info1, info2); int h1 = info1.hashCode(); int h2 = info2.hashCode(); assertEquals(h1, h2); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { PeriodAxisLabelInfo info1 = new PeriodAxisLabelInfo(Day.class, new SimpleDateFormat("d")); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(info1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); PeriodAxisLabelInfo info2 = (PeriodAxisLabelInfo) in.readObject(); in.close(); assertEquals(info1, info2); } /** * A test for the createInstance() method. */ @Test public void testCreateInstance() { PeriodAxisLabelInfo info = new PeriodAxisLabelInfo(Day.class, new SimpleDateFormat("d")); Day d = (Day) info.createInstance(new Date(0L), TimeZone.getTimeZone("GMT"), Locale.UK); assertEquals(new Day(1, 1, 1970), d); } }
7,251
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
PeriodAxisTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/axis/PeriodAxisTest.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.] * * -------------------- * PeriodAxisTests.java * -------------------- * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 10-Jun-2003 : Version 1 (DG); * 07-Jan-2005 : Added test for hashCode() method (DG); * 08-Apr-2008 : Added test1932146() (DG); * 16-Jan-2009 : Added test2490803() (DG); * 02-Mar-2009 : Added testEqualsWithLocale (DG); * */ package org.jfree.chart.axis; import org.jfree.chart.event.AxisChangeEvent; import org.jfree.chart.event.AxisChangeListener; import org.jfree.data.Range; import org.jfree.data.time.DateRange; import org.jfree.data.time.Day; import org.jfree.data.time.Minute; import org.jfree.data.time.Month; import org.jfree.data.time.Quarter; import org.jfree.data.time.Second; import org.jfree.data.time.Year; import org.junit.Test; import java.awt.BasicStroke; import java.awt.Color; 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 java.text.SimpleDateFormat; import java.util.GregorianCalendar; import java.util.Locale; import java.util.SimpleTimeZone; import java.util.TimeZone; 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 PeriodAxis} class. */ public class PeriodAxisTest implements AxisChangeListener { /** The last event received. */ private AxisChangeEvent lastEvent; /** * Receives and records an {@link AxisChangeEvent}. * * @param event the event. */ @Override public void axisChanged(AxisChangeEvent event) { this.lastEvent = event; } /** * Confirm that the equals() method can distinguish all the required fields. */ @Test public void testEquals() { PeriodAxis a1 = new PeriodAxis("Test"); PeriodAxis a2 = new PeriodAxis("Test"); assertEquals(a1, a2); assertEquals(a2, a1); a1.setFirst(new Year(2000)); assertFalse(a1.equals(a2)); a2.setFirst(new Year(2000)); assertEquals(a1, a2); a1.setLast(new Year(2004)); assertFalse(a1.equals(a2)); a2.setLast(new Year(2004)); assertEquals(a1, a2); a1.setTimeZone(TimeZone.getTimeZone("Pacific/Auckland")); assertFalse(a1.equals(a2)); a2.setTimeZone(TimeZone.getTimeZone("Pacific/Auckland")); assertEquals(a1, a2); a1.setAutoRangeTimePeriodClass(Quarter.class); assertFalse(a1.equals(a2)); a2.setAutoRangeTimePeriodClass(Quarter.class); assertEquals(a1, a2); PeriodAxisLabelInfo info[] = new PeriodAxisLabelInfo[1]; info[0] = new PeriodAxisLabelInfo(Month.class, new SimpleDateFormat("MMM")); a1.setLabelInfo(info); assertFalse(a1.equals(a2)); a2.setLabelInfo(info); assertEquals(a1, a2); a1.setMajorTickTimePeriodClass(Minute.class); assertFalse(a1.equals(a2)); a2.setMajorTickTimePeriodClass(Minute.class); assertEquals(a1, a2); a1.setMinorTickMarksVisible(!a1.isMinorTickMarksVisible()); assertFalse(a1.equals(a2)); a2.setMinorTickMarksVisible(a1.isMinorTickMarksVisible()); assertEquals(a1, a2); a1.setMinorTickTimePeriodClass(Minute.class); assertFalse(a1.equals(a2)); a2.setMinorTickTimePeriodClass(Minute.class); assertEquals(a1, a2); Stroke s = new BasicStroke(1.23f); a1.setMinorTickMarkStroke(s); assertFalse(a1.equals(a2)); a2.setMinorTickMarkStroke(s); assertEquals(a1, a2); a1.setMinorTickMarkPaint(Color.BLUE); assertFalse(a1.equals(a2)); a2.setMinorTickMarkPaint(Color.BLUE); assertEquals(a1, a2); } /** * Confirm that the equals() method can distinguish the locale field (which * is new in version 1.0.13). */ @Test public void testEqualsWithLocale() { PeriodAxis a1 = new PeriodAxis("Test", new Year(2000), new Year(2009), TimeZone.getDefault(), Locale.JAPAN); PeriodAxis a2 = new PeriodAxis("Test", new Year(2000), new Year(2009), TimeZone.getDefault(), Locale.JAPAN); assertEquals(a1, a2); assertEquals(a2, a1); a1 = new PeriodAxis("Test", new Year(2000), new Year(2009), TimeZone.getDefault(), Locale.UK); assertFalse(a1.equals(a2)); a2 = new PeriodAxis("Test", new Year(2000), new Year(2009), TimeZone.getDefault(), Locale.UK); assertEquals(a1, a2); } /** * Two objects that are equal are required to return the same hashCode. */ @Test public void testHashCode() { PeriodAxis a1 = new PeriodAxis("Test"); PeriodAxis a2 = new PeriodAxis("Test"); assertEquals(a1, a2); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { PeriodAxis a1 = new PeriodAxis("Test"); PeriodAxis a2 = (PeriodAxis) a1.clone(); assertNotSame(a1, a2); assertSame(a1.getClass(), a2.getClass()); assertEquals(a1, a2); // some checks that the clone is independent of the original a1.setLabel("New Label"); assertFalse(a1.equals(a2)); a2.setLabel("New Label"); assertEquals(a1, a2); a1.setFirst(new Year(1920)); assertFalse(a1.equals(a2)); a2.setFirst(new Year(1920)); assertEquals(a1, a2); a1.setLast(new Year(2020)); assertFalse(a1.equals(a2)); a2.setLast(new Year(2020)); assertEquals(a1, a2); PeriodAxisLabelInfo[] info = new PeriodAxisLabelInfo[2]; info[0] = new PeriodAxisLabelInfo(Day.class, new SimpleDateFormat("d")); info[1] = new PeriodAxisLabelInfo(Year.class, new SimpleDateFormat("yyyy")); a1.setLabelInfo(info); assertFalse(a1.equals(a2)); a2.setLabelInfo(info); assertEquals(a1, a2); a1.setAutoRangeTimePeriodClass(Second.class); assertFalse(a1.equals(a2)); a2.setAutoRangeTimePeriodClass(Second.class); assertEquals(a1, a2); a1.setTimeZone(new SimpleTimeZone(123, "Bogus")); assertFalse(a1.equals(a2)); a2.setTimeZone(new SimpleTimeZone(123, "Bogus")); assertEquals(a1, a2); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { PeriodAxis a1 = new PeriodAxis("Test Axis"); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); PeriodAxis a2 = (PeriodAxis) in.readObject(); in.close(); assertEquals(a1, a2); } /** * A test for bug 1932146. */ @Test public void test1932146() { PeriodAxis axis = new PeriodAxis("TestAxis"); axis.addChangeListener(this); this.lastEvent = null; axis.setRange(new DateRange(0L, 1000L)); assertNotSame(this.lastEvent, null); } private static final double EPSILON = 0.0000000001; /** * A test for the setRange() method (because the axis shows whole time * periods, the range set for the axis will most likely be wider than the * one specified). */ @Test public void test2490803() { Locale savedLocale = Locale.getDefault(); TimeZone savedTimeZone = TimeZone.getDefault(); try { Locale.setDefault(Locale.FRANCE); TimeZone.setDefault(TimeZone.getTimeZone("Europe/Paris")); GregorianCalendar c0 = new GregorianCalendar(); c0.clear(); /* c0.set(2009, Calendar.JANUARY, 16, 12, 34, 56); System.out.println(c0.getTime().getTime()); c0.clear(); c0.set(2009, Calendar.JANUARY, 17, 12, 34, 56); System.out.println(c0.getTime().getTime()); */ PeriodAxis axis = new PeriodAxis("TestAxis"); axis.setRange(new Range(1232105696000L, 1232192096000L), false, false); Range r = axis.getRange(); Day d0 = new Day(16, 1, 2009); Day d1 = new Day(17, 1, 2009); assertEquals(d0.getFirstMillisecond(), r.getLowerBound(), EPSILON); assertEquals(d1.getLastMillisecond() + 1.0, r.getUpperBound(), EPSILON); } finally { TimeZone.setDefault(savedTimeZone); Locale.setDefault(savedLocale); } } }
10,511
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
package-info.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/axis/package-info.java
/** * Tests for the axis classes and interfaces. */ package org.jfree.chart.axis;
84
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
NumberAxisTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/axis/NumberAxisTest.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.] * * -------------------- * NumberAxisTests.java * -------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 26-Mar-2003 : Version 1 (DG); * 14-Aug-2003 : Added tests for equals() method (DG); * 05-Oct-2004 : Added tests to pick up a bug in the auto-range calculation for * a domain axis on an XYPlot using an XYSeriesCollection (DG); * 07-Jan-2005 : Added test for hashCode() (DG); * 11-Jan-2006 : Fixed testAutoRange2() and testAutoRange3() following changes * to BarRenderer (DG); * 20-Feb-2006 : Added rangeType field to equals() test (DG); * */ package org.jfree.chart.axis; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.category.BarRenderer; import org.jfree.chart.ui.RectangleEdge; import org.jfree.data.Range; import org.jfree.data.RangeType; import org.jfree.data.category.DefaultCategoryDataset; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; import org.junit.Ignore; 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 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.fail; /** * Tests for the {@link NumberAxis} class. */ public class NumberAxisTest { /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { NumberAxis a1 = new NumberAxis("Test"); NumberAxis a2 = (NumberAxis) a1.clone(); assertNotSame(a1, a2); assertSame(a1.getClass(), a2.getClass()); assertEquals(a1, a2); } /** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { NumberAxis a1 = new NumberAxis("Test"); NumberAxis a2 = new NumberAxis("Test"); assertEquals(a1, a2); //private boolean autoRangeIncludesZero; a1.setAutoRangeIncludesZero(false); assertFalse(a1.equals(a2)); a2.setAutoRangeIncludesZero(false); assertEquals(a1, a2); //private boolean autoRangeStickyZero; a1.setAutoRangeStickyZero(false); assertFalse(a1.equals(a2)); a2.setAutoRangeStickyZero(false); assertEquals(a1, a2); //private NumberTickUnit tickUnit; a1.setTickUnit(new NumberTickUnit(25.0)); assertFalse(a1.equals(a2)); a2.setTickUnit(new NumberTickUnit(25.0)); assertEquals(a1, a2); //private NumberFormat numberFormatOverride; a1.setNumberFormatOverride(new DecimalFormat("0.00")); assertFalse(a1.equals(a2)); a2.setNumberFormatOverride(new DecimalFormat("0.00")); assertEquals(a1, a2); a1.setRangeType(RangeType.POSITIVE); assertFalse(a1.equals(a2)); a2.setRangeType(RangeType.POSITIVE); assertEquals(a1, a2); } /** * Two objects that are equal are required to return the same hashCode. */ @Test public void testHashCode() { NumberAxis a1 = new NumberAxis("Test"); NumberAxis a2 = new NumberAxis("Test"); assertEquals(a1, a2); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } private static final double EPSILON = 0.0000001; /** * Test the translation of Java2D values to data values. */ @Test public void testTranslateJava2DToValue() { NumberAxis axis = new NumberAxis(); axis.setRange(50.0, 100.0); Rectangle2D dataArea = new Rectangle2D.Double(10.0, 50.0, 400.0, 300.0); double y1 = axis.java2DToValue(75.0, dataArea, RectangleEdge.LEFT); assertEquals(y1, 95.8333333, EPSILON); double y2 = axis.java2DToValue(75.0, dataArea, RectangleEdge.RIGHT); assertEquals(y2, 95.8333333, EPSILON); double x1 = axis.java2DToValue(75.0, dataArea, RectangleEdge.TOP); assertEquals(x1, 58.125, EPSILON); double x2 = axis.java2DToValue(75.0, dataArea, RectangleEdge.BOTTOM); assertEquals(x2, 58.125, EPSILON); axis.setInverted(true); double y3 = axis.java2DToValue(75.0, dataArea, RectangleEdge.LEFT); assertEquals(y3, 54.1666667, EPSILON); double y4 = axis.java2DToValue(75.0, dataArea, RectangleEdge.RIGHT); assertEquals(y4, 54.1666667, EPSILON); double x3 = axis.java2DToValue(75.0, dataArea, RectangleEdge.TOP); assertEquals(x3, 91.875, EPSILON); double x4 = axis.java2DToValue(75.0, dataArea, RectangleEdge.BOTTOM); assertEquals(x4, 91.875, EPSILON); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { NumberAxis a1 = new NumberAxis("Test Axis"); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); NumberAxis a2 = (NumberAxis) in.readObject(); in.close(); assertEquals(a1, a2); } /** * A simple test for the auto-range calculation looking at a * NumberAxis used as the range axis for a CategoryPlot. */ @Test public void testAutoRange1() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.setValue(100.0, "Row 1", "Column 1"); dataset.setValue(200.0, "Row 1", "Column 2"); JFreeChart chart = ChartFactory.createBarChart("Test", "Categories", "Value", dataset); CategoryPlot plot = (CategoryPlot) chart.getPlot(); NumberAxis axis = (NumberAxis) plot.getRangeAxis(); assertEquals(axis.getLowerBound(), 0.0, EPSILON); assertEquals(axis.getUpperBound(), 210.0, EPSILON); } /** * A simple test for the auto-range calculation looking at a * NumberAxis used as the range axis for a CategoryPlot. In this * case, the 'autoRangeIncludesZero' flag is set to false. */ @Test public void testAutoRange2() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.setValue(100.0, "Row 1", "Column 1"); dataset.setValue(200.0, "Row 1", "Column 2"); JFreeChart chart = ChartFactory.createLineChart("Test", "Categories", "Value", dataset); CategoryPlot plot = (CategoryPlot) chart.getPlot(); NumberAxis axis = (NumberAxis) plot.getRangeAxis(); axis.setAutoRangeIncludesZero(false); assertEquals(axis.getLowerBound(), 95.0, EPSILON); assertEquals(axis.getUpperBound(), 205.0, EPSILON); } /** * A simple test for the auto-range calculation looking at a * NumberAxis used as the range axis for a CategoryPlot. In this * case, the 'autoRangeIncludesZero' flag is set to false AND the * original dataset is replaced with a new dataset. */ @Test public void testAutoRange3() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.setValue(100.0, "Row 1", "Column 1"); dataset.setValue(200.0, "Row 1", "Column 2"); JFreeChart chart = ChartFactory.createLineChart("Test", "Categories", "Value", dataset); CategoryPlot plot = (CategoryPlot) chart.getPlot(); NumberAxis axis = (NumberAxis) plot.getRangeAxis(); axis.setAutoRangeIncludesZero(false); assertEquals(axis.getLowerBound(), 95.0, EPSILON); assertEquals(axis.getUpperBound(), 205.0, EPSILON); // now replacing the dataset should update the axis range... DefaultCategoryDataset dataset2 = new DefaultCategoryDataset(); dataset2.setValue(900.0, "Row 1", "Column 1"); dataset2.setValue(1000.0, "Row 1", "Column 2"); plot.setDataset(dataset2); assertEquals(axis.getLowerBound(), 895.0, EPSILON); assertEquals(axis.getUpperBound(), 1005.0, EPSILON); } /** * A check for the interaction between the 'autoRangeIncludesZero' flag * and the base setting in the BarRenderer. */ @Test public void testAutoRange4() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.setValue(100.0, "Row 1", "Column 1"); dataset.setValue(200.0, "Row 1", "Column 2"); JFreeChart chart = ChartFactory.createBarChart("Test", "Categories", "Value", dataset); CategoryPlot plot = (CategoryPlot) chart.getPlot(); NumberAxis axis = (NumberAxis) plot.getRangeAxis(); axis.setAutoRangeIncludesZero(false); BarRenderer br = (BarRenderer) plot.getRenderer(); br.setIncludeBaseInRange(false); assertEquals(95.0, axis.getLowerBound(), EPSILON); assertEquals(205.0, axis.getUpperBound(), EPSILON); br.setIncludeBaseInRange(true); assertEquals(0.0, axis.getLowerBound(), EPSILON); assertEquals(210.0, axis.getUpperBound(), EPSILON); axis.setAutoRangeIncludesZero(true); assertEquals(0.0, axis.getLowerBound(), EPSILON); assertEquals(210.0, axis.getUpperBound(), EPSILON); br.setIncludeBaseInRange(true); assertEquals(0.0, axis.getLowerBound(), EPSILON); assertEquals(210.0, axis.getUpperBound(), EPSILON); // now replacing the dataset should update the axis range... DefaultCategoryDataset dataset2 = new DefaultCategoryDataset(); dataset2.setValue(900.0, "Row 1", "Column 1"); dataset2.setValue(1000.0, "Row 1", "Column 2"); plot.setDataset(dataset2); assertEquals(0.0, axis.getLowerBound(), EPSILON); assertEquals(1050.0, axis.getUpperBound(), EPSILON); br.setIncludeBaseInRange(false); assertEquals(0.0, axis.getLowerBound(), EPSILON); assertEquals(1050.0, axis.getUpperBound(), EPSILON); axis.setAutoRangeIncludesZero(false); assertEquals(895.0, axis.getLowerBound(), EPSILON); assertEquals(1005.0, axis.getUpperBound(), EPSILON); } /** * Checks that the auto-range for the domain axis on an XYPlot is * working as expected. */ @Test public void testXYAutoRange1() { XYSeries series = new XYSeries("Series 1"); 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); JFreeChart chart = ChartFactory.createScatterPlot("Test", "X", "Y", dataset); XYPlot plot = (XYPlot) chart.getPlot(); NumberAxis axis = (NumberAxis) plot.getDomainAxis(); axis.setAutoRangeIncludesZero(false); assertEquals(0.9, axis.getLowerBound(), EPSILON); assertEquals(3.1, axis.getUpperBound(), EPSILON); } /** * Checks that the auto-range for the range axis on an XYPlot is * working as expected. */ @Test public void testXYAutoRange2() { XYSeries series = new XYSeries("Series 1"); 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); JFreeChart chart = ChartFactory.createScatterPlot("Test", "X", "Y", dataset); XYPlot plot = (XYPlot) chart.getPlot(); NumberAxis axis = (NumberAxis) plot.getRangeAxis(); axis.setAutoRangeIncludesZero(false); assertEquals(0.9, axis.getLowerBound(), EPSILON); assertEquals(3.1, axis.getUpperBound(), EPSILON); } /** * Some checks for the setRangeType() method. */ @Ignore("This was previously commented out") @Test public void testSetRangeType() { NumberAxis axis = new NumberAxis("X"); axis.setRangeType(RangeType.POSITIVE); assertEquals(RangeType.POSITIVE, axis.getRangeType()); // test a change to RangeType.POSITIVE axis.setRangeType(RangeType.FULL); axis.setRange(-5.0, 5.0); axis.setRangeType(RangeType.POSITIVE); assertEquals(new Range(0.0, 5.0), axis.getRange()); axis.setRangeType(RangeType.FULL); axis.setRange(-10.0, -5.0); axis.setRangeType(RangeType.POSITIVE); assertEquals(new Range(0.0, axis.getAutoRangeMinimumSize()), axis.getRange()); // test a change to RangeType.NEGATIVE axis.setRangeType(RangeType.FULL); axis.setRange(-5.0, 5.0); axis.setRangeType(RangeType.NEGATIVE); assertEquals(new Range(-5.0, 0.0), axis.getRange()); axis.setRangeType(RangeType.FULL); axis.setRange(5.0, 10.0); axis.setRangeType(RangeType.NEGATIVE); assertEquals(new Range(-axis.getAutoRangeMinimumSize(), 0.0), axis.getRange()); // try null try { axis.setRangeType(null); fail("IllegalArgumentException should have been thrown on null parameter"); } catch (IllegalArgumentException e) { assertEquals("Null 'rangeType' argument.", e.getMessage()); } } /** * Some checks for the setLowerBound() method. */ @Test public void testSetLowerBound() { NumberAxis axis = new NumberAxis("X"); axis.setRange(0.0, 10.0); axis.setLowerBound(5.0); assertEquals(5.0, axis.getLowerBound(), EPSILON); axis.setLowerBound(10.0); assertEquals(10.0, axis.getLowerBound(), EPSILON); assertEquals(11.0, axis.getUpperBound(), EPSILON); //axis.setRangeType(RangeType.POSITIVE); //axis.setLowerBound(-5.0); //assertEquals(0.0, axis.getLowerBound(), EPSILON); } }
15,741
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
TickUnitsTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/axis/TickUnitsTest.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.] * * ------------------- * TickUnitsTests.java * ------------------- * (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 02-Aug-2007 : Version 1 (DG); * */ package org.jfree.chart.axis; 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; /** * Tests for the {@link TickUnits} class. */ public class TickUnitsTest { /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { TickUnits t1 = (TickUnits) NumberAxis.createIntegerTickUnits(); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(t1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); TickUnits t2 = (TickUnits) in.readObject(); in.close(); assertEquals(t1, t2); } /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { TickUnits t1 = (TickUnits) NumberAxis.createIntegerTickUnits(); TickUnits t2 = (TickUnits) t1.clone(); assertNotSame(t1, t2); assertSame(t1.getClass(), t2.getClass()); assertEquals(t1, t2); } /** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { TickUnits t1 = (TickUnits) NumberAxis.createIntegerTickUnits(); TickUnits t2 = (TickUnits) NumberAxis.createIntegerTickUnits(); assertEquals(t1, t2); assertEquals(t2, t1); } }
3,393
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
StandardTickUnitSourceTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/axis/StandardTickUnitSourceTest.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.] * * -------------------------------- * StandardTickUnitSourceTests.java * -------------------------------- * (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 25-Oct-2007 : Version 1 (DG); * */ package org.jfree.chart.axis; 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 StandardTickUnitSource} class. */ public class StandardTickUnitSourceTest { /** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { StandardTickUnitSource t1 = new StandardTickUnitSource(); StandardTickUnitSource t2 = new StandardTickUnitSource(); assertEquals(t1, t2); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { StandardTickUnitSource t1 = new StandardTickUnitSource(); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(t1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); StandardTickUnitSource t2 = (StandardTickUnitSource) in.readObject(); in.close(); assertEquals(t1, t2); } }
2,983
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
CategoryAnchorTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/axis/CategoryAnchorTest.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.] * * ------------------------ * CategoryAnchorTests.java * ------------------------ * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 13-May-2004 : Version 1 (DG); * 07-Jan-2005 : Added hashCode() test (DG); * */ package org.jfree.chart.axis; 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 CategoryAnchor} class. */ public class CategoryAnchorTest { /** * Check that the equals() method distinguishes known instances. */ @Test public void testEquals() { assertEquals(CategoryAnchor.START, CategoryAnchor.START); assertEquals(CategoryAnchor.MIDDLE, CategoryAnchor.MIDDLE); assertEquals(CategoryAnchor.END, CategoryAnchor.END); assertFalse(CategoryAnchor.START.equals(CategoryAnchor.END)); assertFalse(CategoryAnchor.MIDDLE.equals(CategoryAnchor.END)); } /** * Two objects that are equal are required to return the same hashCode. */ @Test public void testHashCode() { CategoryAnchor a1 = CategoryAnchor.START; CategoryAnchor a2 = CategoryAnchor.START; assertEquals(a1, a2); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { CategoryAnchor a1 = CategoryAnchor.MIDDLE; ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); CategoryAnchor a2 = (CategoryAnchor) in.readObject(); in.close(); assertEquals(a1, a2); assertSame(a1, a2); } }
3,600
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
MonthDateFormatTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/axis/MonthDateFormatTest.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.] * * ------------------------- * MonthDateFormatTests.java * ------------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 10-May-2005 : Version 1 (DG); * */ package org.jfree.chart.axis; 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 java.util.Locale; import java.util.TimeZone; 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 MonthDateFormat} class. */ public class MonthDateFormatTest { /** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { MonthDateFormat mf1 = new MonthDateFormat(); MonthDateFormat mf2 = new MonthDateFormat(); assertEquals(mf1, mf2); assertEquals(mf2, mf1); boolean[] showYear1 = new boolean [12]; showYear1[0] = true; boolean[] showYear2 = new boolean [12]; showYear1[1] = true; // time zone mf1 = new MonthDateFormat(TimeZone.getTimeZone("PST"), Locale.US, 1, showYear1, new SimpleDateFormat("yy")); assertFalse(mf1.equals(mf2)); mf2 = new MonthDateFormat(TimeZone.getTimeZone("PST"), Locale.US, 1, showYear1, new SimpleDateFormat("yy")); assertEquals(mf1, mf2); // locale mf1 = new MonthDateFormat(TimeZone.getTimeZone("PST"), Locale.FRANCE, 1, showYear1, new SimpleDateFormat("yy")); assertFalse(mf1.equals(mf2)); mf2 = new MonthDateFormat(TimeZone.getTimeZone("PST"), Locale.FRANCE, 1, showYear1, new SimpleDateFormat("yy")); assertEquals(mf1, mf2); // chars mf1 = new MonthDateFormat(TimeZone.getTimeZone("PST"), Locale.FRANCE, 2, showYear1, new SimpleDateFormat("yy")); assertFalse(mf1.equals(mf2)); mf2 = new MonthDateFormat(TimeZone.getTimeZone("PST"), Locale.FRANCE, 2, showYear1, new SimpleDateFormat("yy")); assertEquals(mf1, mf2); // showYear[] mf1 = new MonthDateFormat(TimeZone.getTimeZone("PST"), Locale.FRANCE, 2, showYear2, new SimpleDateFormat("yy")); assertFalse(mf1.equals(mf2)); mf2 = new MonthDateFormat(TimeZone.getTimeZone("PST"), Locale.FRANCE, 2, showYear2, new SimpleDateFormat("yy")); assertEquals(mf1, mf2); // yearFormatter mf1 = new MonthDateFormat(TimeZone.getTimeZone("PST"), Locale.FRANCE, 2, showYear2, new SimpleDateFormat("yyyy")); assertFalse(mf1.equals(mf2)); mf2 = new MonthDateFormat(TimeZone.getTimeZone("PST"), Locale.FRANCE, 2, showYear2, new SimpleDateFormat("yyyy")); assertEquals(mf1, mf2); } /** * Two objects that are equal are required to return the same hashCode. */ @Test public void testHashCode() { MonthDateFormat mf1 = new MonthDateFormat(); MonthDateFormat mf2 = new MonthDateFormat(); assertEquals(mf1, mf2); int h1 = mf1.hashCode(); int h2 = mf2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { MonthDateFormat mf1 = new MonthDateFormat(); MonthDateFormat mf2 = (MonthDateFormat) mf1.clone(); assertNotSame(mf1, mf2); assertSame(mf1.getClass(), mf2.getClass()); assertEquals(mf1, mf2); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { MonthDateFormat mf1 = new MonthDateFormat(); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(mf1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); MonthDateFormat mf2 = (MonthDateFormat) in.readObject(); in.close(); assertEquals(mf1, mf2); } }
5,835
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
ValueAxisTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/axis/ValueAxisTest.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.] * * ------------------- * ValueAxisTests.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); * 22-Mar-2007 : Extended testEquals() for new field (DG); * */ package org.jfree.chart.axis; import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartRenderingInfo; import org.jfree.chart.JFreeChart; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.ui.RectangleInsets; import org.jfree.data.Range; import org.jfree.data.category.DefaultCategoryDataset; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; import org.junit.Test; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Graphics2D; import java.awt.Stroke; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import static junit.framework.Assert.assertNotSame; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertSame; /** * Tests for the {@link ValueAxis} class. */ public class ValueAxisTest { private static final double EPSILON = 0.000000001; /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { ValueAxis a1 = new NumberAxis("Test"); ValueAxis a2 = (NumberAxis) a1.clone(); assertNotSame(a1, a2); assertSame(a1.getClass(), a2.getClass()); assertEquals(a1, a2); } /** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { NumberAxis a1 = new NumberAxis("Test"); NumberAxis a2 = new NumberAxis("Test"); assertEquals(a1, a2); // axis line visible flag... a1.setAxisLineVisible(false); assertFalse(a1.equals(a2)); a2.setAxisLineVisible(false); assertEquals(a1, a2); // positiveArrowVisible; a1.setPositiveArrowVisible(true); assertFalse(a1.equals(a2)); a2.setPositiveArrowVisible(true); assertEquals(a1, a2); // negativeArrowVisible; a1.setNegativeArrowVisible(true); assertFalse(a1.equals(a2)); a2.setNegativeArrowVisible(true); assertEquals(a1, a2); //private Shape upArrow; //private Shape downArrow; //private Shape leftArrow; //private Shape rightArrow; // axisLinePaint a1.setAxisLinePaint(Color.BLUE); assertFalse(a1.equals(a2)); a2.setAxisLinePaint(Color.BLUE); assertEquals(a1, a2); // axisLineStroke Stroke stroke = new BasicStroke(2.0f); a1.setAxisLineStroke(stroke); assertFalse(a1.equals(a2)); a2.setAxisLineStroke(stroke); assertEquals(a1, a2); // inverted a1.setInverted(true); assertFalse(a1.equals(a2)); a2.setInverted(true); assertEquals(a1, a2); // range a1.setRange(new Range(50.0, 75.0)); assertFalse(a1.equals(a2)); a2.setRange(new Range(50.0, 75.0)); assertEquals(a1, a2); // autoRange a1.setAutoRange(true); assertFalse(a1.equals(a2)); a2.setAutoRange(true); assertEquals(a1, a2); // autoRangeMinimumSize a1.setAutoRangeMinimumSize(3.33); assertFalse(a1.equals(a2)); a2.setAutoRangeMinimumSize(3.33); assertEquals(a1, a2); a1.setDefaultAutoRange(new Range(1.2, 3.4)); assertFalse(a1.equals(a2)); a2.setDefaultAutoRange(new Range(1.2, 3.4)); assertEquals(a1, a2); // upperMargin a1.setUpperMargin(0.09); assertFalse(a1.equals(a2)); a2.setUpperMargin(0.09); assertEquals(a1, a2); // lowerMargin a1.setLowerMargin(0.09); assertFalse(a1.equals(a2)); a2.setLowerMargin(0.09); assertEquals(a1, a2); //private double fixedAutoRange; a1.setFixedAutoRange(50.0); assertFalse(a1.equals(a2)); a2.setFixedAutoRange(50.0); assertEquals(a1, a2); //private boolean autoTickUnitSelection; a1.setAutoTickUnitSelection(false); assertFalse(a1.equals(a2)); a2.setAutoTickUnitSelection(false); assertEquals(a1, a2); //private TickUnits standardTickUnits; a1.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); assertFalse(a1.equals(a2)); a2.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); assertEquals(a1, a2); // verticalTickLabels a1.setVerticalTickLabels(true); assertFalse(a1.equals(a2)); a2.setVerticalTickLabels(true); assertEquals(a1, a2); //private int autoTickIndex; //protected double reservedForTickLabels; //protected double reservedForAxisLabel; } /** * Tests the the lower and upper margin settings produce the expected * results. */ @Test public void testAxisMargins() { XYSeries series = new XYSeries("S1"); series.add(100.0, 1.1); series.add(200.0, 2.2); XYSeriesCollection dataset = new XYSeriesCollection(series); dataset.setIntervalWidth(0.0); JFreeChart chart = ChartFactory.createScatterPlot( "Title", "X", "Y", dataset); ValueAxis domainAxis = ((XYPlot) chart.getPlot()).getDomainAxis(); Range r = domainAxis.getRange(); assertEquals(110.0, r.getLength(), EPSILON); domainAxis.setLowerMargin(0.10); domainAxis.setUpperMargin(0.10); r = domainAxis.getRange(); assertEquals(120.0, r.getLength(), EPSILON); } /** * A test for bug 3555275 (where the fixed axis space is calculated * incorrectly). */ @Test public void test3555275() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); JFreeChart chart = ChartFactory.createLineChart("Title", "X", "Y", dataset); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setInsets(RectangleInsets.ZERO_INSETS); plot.setAxisOffset(RectangleInsets.ZERO_INSETS); ValueAxis yAxis = plot.getRangeAxis(); yAxis.setFixedDimension(100.0); BufferedImage image = new BufferedImage(500, 300, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); ChartRenderingInfo info = new ChartRenderingInfo(); chart.draw(g2, new Rectangle2D.Double(0, 0, 500, 300), info); g2.dispose(); Rectangle2D rect = info.getPlotInfo().getDataArea(); double x = rect.getMinX(); assertEquals(100.0, x, 1.0); } }
8,172
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
DateAxisTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/axis/DateAxisTest.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.] * * ------------------ * DateAxisTests.java * ------------------ * (C) Copyright 2003-2012, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 22-Apr-2003 : Version 1 (DG); * 07-Jan-2005 : Added test for hashCode() method (DG); * 25-Sep-2005 : New tests for bug 1564977 (DG); * 19-Apr-2007 : Added further checks for setMinimumDate() and * setMaximumDate() (DG); * 03-May-2007 : Replaced the tests for the previousStandardDate() method with * new tests that check that the previousStandardDate and the * next standard date do in fact span the reference date (DG); * 25-Nov-2008 : Added testBug2201869 (DG); * 08-Feb-2012 : Added testBug3484403 (MH); * 17-Jun-2012 : Removed JCommon dependencies (DG); * */ package org.jfree.chart.axis; import org.jfree.chart.ui.RectangleEdge; import org.jfree.data.time.DateRange; import org.jfree.data.time.Day; import org.jfree.data.time.Hour; import org.jfree.data.time.Millisecond; import org.jfree.data.time.Month; import org.jfree.data.time.Second; import org.jfree.data.time.Year; 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 java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.List; import java.util.Locale; import java.util.TimeZone; 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 DateAxis} class. */ public class DateAxisTest { static class MyDateAxis extends DateAxis { /** * Creates a new instance. * * @param label the label. */ public MyDateAxis(String label) { super(label); } @Override public Date previousStandardDate(Date d, DateTickUnit unit) { return super.previousStandardDate(d, unit); } } /** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { DateAxis a1 = new DateAxis("Test"); DateAxis a2 = new DateAxis("Test"); assertEquals(a1, a2); assertFalse(a1.equals(null)); assertFalse(a1.equals("Some non-DateAxis object")); // tickUnit a1.setTickUnit(new DateTickUnit(DateTickUnitType.DAY, 7)); assertFalse(a1.equals(a2)); a2.setTickUnit(new DateTickUnit(DateTickUnitType.DAY, 7)); assertEquals(a1, a2); // dateFormatOverride a1.setDateFormatOverride(new SimpleDateFormat("yyyy")); assertFalse(a1.equals(a2)); a2.setDateFormatOverride(new SimpleDateFormat("yyyy")); assertEquals(a1, a2); // tickMarkPosition a1.setTickMarkPosition(DateTickMarkPosition.END); assertFalse(a1.equals(a2)); a2.setTickMarkPosition(DateTickMarkPosition.END); assertEquals(a1, a2); } /** * A test for bug report 1472942. The DateFormat.equals() method is not * checking the range attribute. */ @Test public void test1472942() { DateAxis a1 = new DateAxis("Test"); DateAxis a2 = new DateAxis("Test"); assertEquals(a1, a2); // range a1.setRange(new Date(1L), new Date(2L)); assertFalse(a1.equals(a2)); a2.setRange(new Date(1L), new Date(2L)); assertEquals(a1, a2); } /** * Two objects that are equal are required to return the same hashCode. */ @Test public void testHashCode() { DateAxis a1 = new DateAxis("Test"); DateAxis a2 = new DateAxis("Test"); assertEquals(a1, a2); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { DateAxis a1 = new DateAxis("Test"); DateAxis a2 = (DateAxis) a1.clone(); assertNotSame(a1, a2); assertSame(a1.getClass(), a2.getClass()); assertEquals(a1, a2); } /** * Test that the setRange() method works. */ @Test public void testSetRange() { DateAxis axis = new DateAxis("Test Axis"); Calendar calendar = Calendar.getInstance(); calendar.set(1999, Calendar.JANUARY, 3); Date d1 = calendar.getTime(); calendar.set(1999, Calendar.JANUARY, 31); Date d2 = calendar.getTime(); axis.setRange(d1, d2); DateRange range = (DateRange) axis.getRange(); assertEquals(d1, range.getLowerDate()); assertEquals(d2, range.getUpperDate()); } /** * Test that the setMaximumDate() method works. */ @Test public void testSetMaximumDate() { DateAxis axis = new DateAxis("Test Axis"); Date date = new Date(); axis.setMaximumDate(date); assertEquals(date, axis.getMaximumDate()); // check that setting the max date to something on or before the // current min date works... Date d1 = new Date(); Date d2 = new Date(d1.getTime() + 1); Date d0 = new Date(d1.getTime() - 1); axis.setMaximumDate(d2); axis.setMinimumDate(d1); axis.setMaximumDate(d1); assertEquals(d0, axis.getMinimumDate()); } /** * Test that the setMinimumDate() method works. */ @Test public void testSetMinimumDate() { DateAxis axis = new DateAxis("Test Axis"); Date d1 = new Date(); Date d2 = new Date(d1.getTime() + 1); axis.setMaximumDate(d2); axis.setMinimumDate(d1); assertEquals(d1, axis.getMinimumDate()); // check that setting the min date to something on or after the // current min date works... Date d3 = new Date(d2.getTime() + 1); axis.setMinimumDate(d2); assertEquals(d3, axis.getMaximumDate()); } /** * Tests two doubles for 'near enough' equality. * * @param d1 number 1. * @param d2 number 2. * @param tolerance maximum tolerance. * * @return A boolean. */ private boolean same(double d1, double d2, double tolerance) { return (Math.abs(d1 - d2) < tolerance); } /** * Test the translation of Java2D values to data values. */ @Test public void testJava2DToValue() { DateAxis axis = new DateAxis(); axis.setRange(50.0, 100.0); Rectangle2D dataArea = new Rectangle2D.Double(10.0, 50.0, 400.0, 300.0); double y1 = axis.java2DToValue(75.0, dataArea, RectangleEdge.LEFT); assertTrue(same(y1, 95.8333333, 1.0)); double y2 = axis.java2DToValue(75.0, dataArea, RectangleEdge.RIGHT); assertTrue(same(y2, 95.8333333, 1.0)); double x1 = axis.java2DToValue(75.0, dataArea, RectangleEdge.TOP); assertTrue(same(x1, 58.125, 1.0)); double x2 = axis.java2DToValue(75.0, dataArea, RectangleEdge.BOTTOM); assertTrue(same(x2, 58.125, 1.0)); axis.setInverted(true); double y3 = axis.java2DToValue(75.0, dataArea, RectangleEdge.LEFT); assertTrue(same(y3, 54.1666667, 1.0)); double y4 = axis.java2DToValue(75.0, dataArea, RectangleEdge.RIGHT); assertTrue(same(y4, 54.1666667, 1.0)); double x3 = axis.java2DToValue(75.0, dataArea, RectangleEdge.TOP); assertTrue(same(x3, 91.875, 1.0)); double x4 = axis.java2DToValue(75.0, dataArea, RectangleEdge.BOTTOM); assertTrue(same(x4, 91.875, 1.0)); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { DateAxis a1 = new DateAxis("Test Axis"); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); DateAxis a2 = (DateAxis) in.readObject(); in.close(); boolean b = a1.equals(a2); assertTrue(b); } /** * A basic check for the testPreviousStandardDate() method when the * tick unit is 1 year. */ @Test public void testPreviousStandardDateYearA() { TimeZone tz = TimeZone.getDefault(); MyDateAxis axis = new MyDateAxis("Year"); Year y2006 = new Year(2006); Year y2007 = new Year(2007); // five dates to check... Date d0 = new Date(y2006.getFirstMillisecond()); Date d1 = new Date(y2006.getFirstMillisecond() + 500L); Date d2 = new Date(y2006.getMiddleMillisecond()); Date d3 = new Date(y2006.getMiddleMillisecond() + 500L); Date d4 = new Date(y2006.getLastMillisecond()); Date end = new Date(y2007.getLastMillisecond()); DateTickUnit unit = new DateTickUnit(DateTickUnitType.YEAR, 1); axis.setTickUnit(unit); // START: check d0 and d1 axis.setTickMarkPosition(DateTickMarkPosition.START); axis.setRange(d0, end); Date psd = axis.previousStandardDate(d0, unit); Date nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); axis.setRange(d1, end); psd = axis.previousStandardDate(d1, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d1.getTime()); assertTrue(nsd.getTime() >= d1.getTime()); // MIDDLE: check d1, d2 and d3 axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); axis.setRange(d1, end); psd = axis.previousStandardDate(d1, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d1.getTime()); assertTrue(nsd.getTime() >= d1.getTime()); axis.setRange(d2, end); psd = axis.previousStandardDate(d2, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d2.getTime()); assertTrue(nsd.getTime() >= d2.getTime()); axis.setRange(d3, end); psd = axis.previousStandardDate(d3, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d3.getTime()); assertTrue(nsd.getTime() >= d3.getTime()); // END: check d3 and d4 axis.setTickMarkPosition(DateTickMarkPosition.END); axis.setRange(d3, end); psd = axis.previousStandardDate(d3, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d3.getTime()); assertTrue(nsd.getTime() >= d3.getTime()); axis.setRange(d4, end); psd = axis.previousStandardDate(d4, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d4.getTime()); assertTrue(nsd.getTime() >= d4.getTime()); } /** * A basic check for the testPreviousStandardDate() method when the * tick unit is 10 years (just for the sake of having a multiple). */ @Test public void testPreviousStandardDateYearB() { TimeZone tz = TimeZone.getDefault(); MyDateAxis axis = new MyDateAxis("Year"); Year y2006 = new Year(2006); Year y2007 = new Year(2007); // five dates to check... Date d0 = new Date(y2006.getFirstMillisecond()); Date d1 = new Date(y2006.getFirstMillisecond() + 500L); Date d2 = new Date(y2006.getMiddleMillisecond()); Date d3 = new Date(y2006.getMiddleMillisecond() + 500L); Date d4 = new Date(y2006.getLastMillisecond()); Date end = new Date(y2007.getLastMillisecond()); DateTickUnit unit = new DateTickUnit(DateTickUnitType.YEAR, 10); axis.setTickUnit(unit); // START: check d0 and d1 axis.setTickMarkPosition(DateTickMarkPosition.START); axis.setRange(d0, end); Date psd = axis.previousStandardDate(d0, unit); Date nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); axis.setRange(d1, end); psd = axis.previousStandardDate(d1, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d1.getTime()); assertTrue(nsd.getTime() >= d1.getTime()); // MIDDLE: check d1, d2 and d3 axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); axis.setRange(d1, end); psd = axis.previousStandardDate(d1, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d1.getTime()); assertTrue(nsd.getTime() >= d1.getTime()); axis.setRange(d2, end); psd = axis.previousStandardDate(d2, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d2.getTime()); assertTrue(nsd.getTime() >= d2.getTime()); axis.setRange(d3, end); psd = axis.previousStandardDate(d3, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d3.getTime()); assertTrue(nsd.getTime() >= d3.getTime()); // END: check d3 and d4 axis.setTickMarkPosition(DateTickMarkPosition.END); axis.setRange(d3, end); psd = axis.previousStandardDate(d3, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d3.getTime()); assertTrue(nsd.getTime() >= d3.getTime()); axis.setRange(d4, end); psd = axis.previousStandardDate(d4, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d4.getTime()); assertTrue(nsd.getTime() >= d4.getTime()); } /** * A basic check for the testPreviousStandardDate() method when the * tick unit is 1 month. */ @Test public void testPreviousStandardDateMonthA() { TimeZone tz = TimeZone.getDefault(); MyDateAxis axis = new MyDateAxis("Month"); Month nov2006 = new Month(11, 2006); Month dec2006 = new Month(12, 2006); // five dates to check... Date d0 = new Date(nov2006.getFirstMillisecond()); Date d1 = new Date(nov2006.getFirstMillisecond() + 500L); Date d2 = new Date(nov2006.getMiddleMillisecond()); Date d3 = new Date(nov2006.getMiddleMillisecond() + 500L); Date d4 = new Date(nov2006.getLastMillisecond()); Date end = new Date(dec2006.getLastMillisecond()); DateTickUnit unit = new DateTickUnit(DateTickUnitType.MONTH, 1); axis.setTickUnit(unit); // START: check d0 and d1 axis.setTickMarkPosition(DateTickMarkPosition.START); axis.setRange(d0, end); Date psd = axis.previousStandardDate(d0, unit); Date nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); axis.setRange(d1, end); psd = axis.previousStandardDate(d1, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d1.getTime()); assertTrue(nsd.getTime() >= d1.getTime()); // MIDDLE: check d1, d2 and d3 axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); axis.setRange(d1, end); psd = axis.previousStandardDate(d1, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d1.getTime()); assertTrue(nsd.getTime() >= d1.getTime()); axis.setRange(d2, end); psd = axis.previousStandardDate(d2, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d2.getTime()); assertTrue(nsd.getTime() >= d2.getTime()); axis.setRange(d3, end); psd = axis.previousStandardDate(d3, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d3.getTime()); assertTrue(nsd.getTime() >= d3.getTime()); // END: check d3 and d4 axis.setTickMarkPosition(DateTickMarkPosition.END); axis.setRange(d3, end); psd = axis.previousStandardDate(d3, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d3.getTime()); assertTrue(nsd.getTime() >= d3.getTime()); axis.setRange(d4, end); psd = axis.previousStandardDate(d4, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d4.getTime()); assertTrue(nsd.getTime() >= d4.getTime()); } /** * A basic check for the testPreviousStandardDate() method when the * tick unit is 3 months (just for the sake of having a multiple). */ @Test public void testPreviousStandardDateMonthB() { TimeZone tz = TimeZone.getDefault(); MyDateAxis axis = new MyDateAxis("Month"); Month nov2006 = new Month(11, 2006); Month dec2006 = new Month(12, 2006); // five dates to check... Date d0 = new Date(nov2006.getFirstMillisecond()); Date d1 = new Date(nov2006.getFirstMillisecond() + 500L); Date d2 = new Date(nov2006.getMiddleMillisecond()); Date d3 = new Date(nov2006.getMiddleMillisecond() + 500L); Date d4 = new Date(nov2006.getLastMillisecond()); Date end = new Date(dec2006.getLastMillisecond()); DateTickUnit unit = new DateTickUnit(DateTickUnitType.MONTH, 3); axis.setTickUnit(unit); // START: check d0 and d1 axis.setTickMarkPosition(DateTickMarkPosition.START); axis.setRange(d0, end); Date psd = axis.previousStandardDate(d0, unit); Date nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); axis.setRange(d1, end); psd = axis.previousStandardDate(d1, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d1.getTime()); assertTrue(nsd.getTime() >= d1.getTime()); // MIDDLE: check d1, d2 and d3 axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); axis.setRange(d1, end); psd = axis.previousStandardDate(d1, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d1.getTime()); assertTrue(nsd.getTime() >= d1.getTime()); axis.setRange(d2, end); psd = axis.previousStandardDate(d2, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d2.getTime()); assertTrue(nsd.getTime() >= d2.getTime()); axis.setRange(d3, end); psd = axis.previousStandardDate(d3, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d3.getTime()); assertTrue(nsd.getTime() >= d3.getTime()); // END: check d3 and d4 axis.setTickMarkPosition(DateTickMarkPosition.END); axis.setRange(d3, end); psd = axis.previousStandardDate(d3, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d3.getTime()); assertTrue(nsd.getTime() >= d3.getTime()); axis.setRange(d4, end); psd = axis.previousStandardDate(d4, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d4.getTime()); assertTrue(nsd.getTime() >= d4.getTime()); } /** * A basic check for the testPreviousStandardDate() method when the * tick unit is 1 day. */ @Test public void testPreviousStandardDateDayA() { TimeZone tz = TimeZone.getDefault(); MyDateAxis axis = new MyDateAxis("Day"); Day apr12007 = new Day(1, 4, 2007); Day apr22007 = new Day(2, 4, 2007); // five dates to check... Date d0 = new Date(apr12007.getFirstMillisecond()); Date d1 = new Date(apr12007.getFirstMillisecond() + 500L); Date d2 = new Date(apr12007.getMiddleMillisecond()); Date d3 = new Date(apr12007.getMiddleMillisecond() + 500L); Date d4 = new Date(apr12007.getLastMillisecond()); Date end = new Date(apr22007.getLastMillisecond()); DateTickUnit unit = new DateTickUnit(DateTickUnitType.DAY, 1); axis.setTickUnit(unit); // START: check d0 and d1 axis.setTickMarkPosition(DateTickMarkPosition.START); axis.setRange(d0, end); Date psd = axis.previousStandardDate(d0, unit); Date nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); axis.setRange(d1, end); psd = axis.previousStandardDate(d1, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d1.getTime()); assertTrue(nsd.getTime() >= d1.getTime()); // MIDDLE: check d1, d2 and d3 axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); axis.setRange(d1, end); psd = axis.previousStandardDate(d1, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d1.getTime()); assertTrue(nsd.getTime() >= d1.getTime()); axis.setRange(d2, end); psd = axis.previousStandardDate(d2, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d2.getTime()); assertTrue(nsd.getTime() >= d2.getTime()); axis.setRange(d3, end); psd = axis.previousStandardDate(d3, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d3.getTime()); assertTrue(nsd.getTime() >= d3.getTime()); // END: check d3 and d4 axis.setTickMarkPosition(DateTickMarkPosition.END); axis.setRange(d3, end); psd = axis.previousStandardDate(d3, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d3.getTime()); assertTrue(nsd.getTime() >= d3.getTime()); axis.setRange(d4, end); psd = axis.previousStandardDate(d4, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d4.getTime()); assertTrue(nsd.getTime() >= d4.getTime()); } /** * A basic check for the testPreviousStandardDate() method when the * tick unit is 7 days (just for the sake of having a multiple). */ @Test public void testPreviousStandardDateDayB() { TimeZone tz = TimeZone.getDefault(); MyDateAxis axis = new MyDateAxis("Day"); Day apr12007 = new Day(1, 4, 2007); Day apr22007 = new Day(2, 4, 2007); // five dates to check... Date d0 = new Date(apr12007.getFirstMillisecond()); Date d1 = new Date(apr12007.getFirstMillisecond() + 500L); Date d2 = new Date(apr12007.getMiddleMillisecond()); Date d3 = new Date(apr12007.getMiddleMillisecond() + 500L); Date d4 = new Date(apr12007.getLastMillisecond()); Date end = new Date(apr22007.getLastMillisecond()); DateTickUnit unit = new DateTickUnit(DateTickUnitType.DAY, 7); axis.setTickUnit(unit); // START: check d0 and d1 axis.setTickMarkPosition(DateTickMarkPosition.START); axis.setRange(d0, end); Date psd = axis.previousStandardDate(d0, unit); Date nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); axis.setRange(d1, end); psd = axis.previousStandardDate(d1, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d1.getTime()); assertTrue(nsd.getTime() >= d1.getTime()); // MIDDLE: check d1, d2 and d3 axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); axis.setRange(d1, end); psd = axis.previousStandardDate(d1, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d1.getTime()); assertTrue(nsd.getTime() >= d1.getTime()); axis.setRange(d2, end); psd = axis.previousStandardDate(d2, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d2.getTime()); assertTrue(nsd.getTime() >= d2.getTime()); axis.setRange(d3, end); psd = axis.previousStandardDate(d3, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d3.getTime()); assertTrue(nsd.getTime() >= d3.getTime()); // END: check d3 and d4 axis.setTickMarkPosition(DateTickMarkPosition.END); axis.setRange(d3, end); psd = axis.previousStandardDate(d3, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d3.getTime()); assertTrue(nsd.getTime() >= d3.getTime()); axis.setRange(d4, end); psd = axis.previousStandardDate(d4, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d4.getTime()); assertTrue(nsd.getTime() >= d4.getTime()); } /** * A basic check for the testPreviousStandardDate() method when the * tick unit is 1 hour. */ @Test public void testPreviousStandardDateHourA() { TimeZone tz = TimeZone.getDefault(); MyDateAxis axis = new MyDateAxis("Hour"); Hour h0 = new Hour(12, 1, 4, 2007); Hour h1 = new Hour(13, 1, 4, 2007); // five dates to check... Date d0 = new Date(h0.getFirstMillisecond()); Date d1 = new Date(h0.getFirstMillisecond() + 500L); Date d2 = new Date(h0.getMiddleMillisecond()); Date d3 = new Date(h0.getMiddleMillisecond() + 500L); Date d4 = new Date(h0.getLastMillisecond()); Date end = new Date(h1.getLastMillisecond()); DateTickUnit unit = new DateTickUnit(DateTickUnitType.HOUR, 1); axis.setTickUnit(unit); // START: check d0 and d1 axis.setTickMarkPosition(DateTickMarkPosition.START); axis.setRange(d0, end); Date psd = axis.previousStandardDate(d0, unit); Date nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); axis.setRange(d1, end); psd = axis.previousStandardDate(d1, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d1.getTime()); assertTrue(nsd.getTime() >= d1.getTime()); // MIDDLE: check d1, d2 and d3 axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); axis.setRange(d1, end); psd = axis.previousStandardDate(d1, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d1.getTime()); assertTrue(nsd.getTime() >= d1.getTime()); axis.setRange(d2, end); psd = axis.previousStandardDate(d2, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d2.getTime()); assertTrue(nsd.getTime() >= d2.getTime()); axis.setRange(d3, end); psd = axis.previousStandardDate(d3, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d3.getTime()); assertTrue(nsd.getTime() >= d3.getTime()); // END: check d3 and d4 axis.setTickMarkPosition(DateTickMarkPosition.END); axis.setRange(d3, end); psd = axis.previousStandardDate(d3, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d3.getTime()); assertTrue(nsd.getTime() >= d3.getTime()); axis.setRange(d4, end); psd = axis.previousStandardDate(d4, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d4.getTime()); assertTrue(nsd.getTime() >= d4.getTime()); } /** * A basic check for the testPreviousStandardDate() method when the * tick unit is 6 hours (just for the sake of having a multiple). */ @Test public void testPreviousStandardDateHourB() { TimeZone tz = TimeZone.getDefault(); MyDateAxis axis = new MyDateAxis("Hour"); Hour h0 = new Hour(12, 1, 4, 2007); Hour h1 = new Hour(13, 1, 4, 2007); // five dates to check... Date d0 = new Date(h0.getFirstMillisecond()); Date d1 = new Date(h0.getFirstMillisecond() + 500L); Date d2 = new Date(h0.getMiddleMillisecond()); Date d3 = new Date(h0.getMiddleMillisecond() + 500L); Date d4 = new Date(h0.getLastMillisecond()); Date end = new Date(h1.getLastMillisecond()); DateTickUnit unit = new DateTickUnit(DateTickUnitType.HOUR, 6); axis.setTickUnit(unit); // START: check d0 and d1 axis.setTickMarkPosition(DateTickMarkPosition.START); axis.setRange(d0, end); Date psd = axis.previousStandardDate(d0, unit); Date nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); axis.setRange(d1, end); psd = axis.previousStandardDate(d1, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d1.getTime()); assertTrue(nsd.getTime() >= d1.getTime()); // MIDDLE: check d1, d2 and d3 axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); axis.setRange(d1, end); psd = axis.previousStandardDate(d1, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d1.getTime()); assertTrue(nsd.getTime() >= d1.getTime()); axis.setRange(d2, end); psd = axis.previousStandardDate(d2, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d2.getTime()); assertTrue(nsd.getTime() >= d2.getTime()); axis.setRange(d3, end); psd = axis.previousStandardDate(d3, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d3.getTime()); assertTrue(nsd.getTime() >= d3.getTime()); // END: check d3 and d4 axis.setTickMarkPosition(DateTickMarkPosition.END); axis.setRange(d3, end); psd = axis.previousStandardDate(d3, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d3.getTime()); assertTrue(nsd.getTime() >= d3.getTime()); axis.setRange(d4, end); psd = axis.previousStandardDate(d4, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d4.getTime()); assertTrue(nsd.getTime() >= d4.getTime()); } /** * A basic check for the testPreviousStandardDate() method when the * tick unit is 1 second. */ @Test public void testPreviousStandardDateSecondA() { TimeZone tz = TimeZone.getDefault(); MyDateAxis axis = new MyDateAxis("Second"); Second s0 = new Second(58, 31, 12, 1, 4, 2007); Second s1 = new Second(59, 31, 12, 1, 4, 2007); // five dates to check... Date d0 = new Date(s0.getFirstMillisecond()); Date d1 = new Date(s0.getFirstMillisecond() + 50L); Date d2 = new Date(s0.getMiddleMillisecond()); Date d3 = new Date(s0.getMiddleMillisecond() + 50L); Date d4 = new Date(s0.getLastMillisecond()); Date end = new Date(s1.getLastMillisecond()); DateTickUnit unit = new DateTickUnit(DateTickUnitType.SECOND, 1); axis.setTickUnit(unit); // START: check d0 and d1 axis.setTickMarkPosition(DateTickMarkPosition.START); axis.setRange(d0, end); Date psd = axis.previousStandardDate(d0, unit); Date nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); axis.setRange(d1, end); psd = axis.previousStandardDate(d1, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d1.getTime()); assertTrue(nsd.getTime() >= d1.getTime()); // MIDDLE: check d1, d2 and d3 axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); axis.setRange(d1, end); psd = axis.previousStandardDate(d1, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d1.getTime()); assertTrue(nsd.getTime() >= d1.getTime()); axis.setRange(d2, end); psd = axis.previousStandardDate(d2, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d2.getTime()); assertTrue(nsd.getTime() >= d2.getTime()); axis.setRange(d3, end); psd = axis.previousStandardDate(d3, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d3.getTime()); assertTrue(nsd.getTime() >= d3.getTime()); // END: check d3 and d4 axis.setTickMarkPosition(DateTickMarkPosition.END); axis.setRange(d3, end); psd = axis.previousStandardDate(d3, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d3.getTime()); assertTrue(nsd.getTime() >= d3.getTime()); axis.setRange(d4, end); psd = axis.previousStandardDate(d4, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d4.getTime()); assertTrue(nsd.getTime() >= d4.getTime()); } /** * A basic check for the testPreviousStandardDate() method when the * tick unit is 5 seconds (just for the sake of having a multiple). */ @Test public void testPreviousStandardDateSecondB() { TimeZone tz = TimeZone.getDefault(); MyDateAxis axis = new MyDateAxis("Second"); Second s0 = new Second(58, 31, 12, 1, 4, 2007); Second s1 = new Second(59, 31, 12, 1, 4, 2007); // five dates to check... Date d0 = new Date(s0.getFirstMillisecond()); Date d1 = new Date(s0.getFirstMillisecond() + 50L); Date d2 = new Date(s0.getMiddleMillisecond()); Date d3 = new Date(s0.getMiddleMillisecond() + 50L); Date d4 = new Date(s0.getLastMillisecond()); Date end = new Date(s1.getLastMillisecond()); DateTickUnit unit = new DateTickUnit(DateTickUnitType.SECOND, 5); axis.setTickUnit(unit); // START: check d0 and d1 axis.setTickMarkPosition(DateTickMarkPosition.START); axis.setRange(d0, end); Date psd = axis.previousStandardDate(d0, unit); Date nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); axis.setRange(d1, end); psd = axis.previousStandardDate(d1, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d1.getTime()); assertTrue(nsd.getTime() >= d1.getTime()); // MIDDLE: check d1, d2 and d3 axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); axis.setRange(d1, end); psd = axis.previousStandardDate(d1, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d1.getTime()); assertTrue(nsd.getTime() >= d1.getTime()); axis.setRange(d2, end); psd = axis.previousStandardDate(d2, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d2.getTime()); assertTrue(nsd.getTime() >= d2.getTime()); axis.setRange(d3, end); psd = axis.previousStandardDate(d3, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d3.getTime()); assertTrue(nsd.getTime() >= d3.getTime()); // END: check d3 and d4 axis.setTickMarkPosition(DateTickMarkPosition.END); axis.setRange(d3, end); psd = axis.previousStandardDate(d3, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d3.getTime()); assertTrue(nsd.getTime() >= d3.getTime()); axis.setRange(d4, end); psd = axis.previousStandardDate(d4, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d4.getTime()); assertTrue(nsd.getTime() >= d4.getTime()); } /** * A basic check for the testPreviousStandardDate() method when the * tick unit is 1 millisecond. */ @Test public void testPreviousStandardDateMillisecondA() { TimeZone tz = TimeZone.getDefault(); MyDateAxis axis = new MyDateAxis("Millisecond"); Millisecond m0 = new Millisecond(458, 58, 31, 12, 1, 4, 2007); Millisecond m1 = new Millisecond(459, 58, 31, 12, 1, 4, 2007); Date d0 = new Date(m0.getFirstMillisecond()); Date end = new Date(m1.getLastMillisecond()); DateTickUnit unit = new DateTickUnit(DateTickUnitType.MILLISECOND, 1); axis.setTickUnit(unit); // START: check d0 axis.setTickMarkPosition(DateTickMarkPosition.START); axis.setRange(d0, end); Date psd = axis.previousStandardDate(d0, unit); Date nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); // MIDDLE: check d0 axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); axis.setRange(d0, end); psd = axis.previousStandardDate(d0, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); // END: check d0 axis.setTickMarkPosition(DateTickMarkPosition.END); axis.setRange(d0, end); psd = axis.previousStandardDate(d0, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); } /** * A basic check for the testPreviousStandardDate() method when the * tick unit is 10 milliseconds (just for the sake of having a multiple). */ @Test public void testPreviousStandardDateMillisecondB() { TimeZone tz = TimeZone.getDefault(); MyDateAxis axis = new MyDateAxis("Millisecond"); Millisecond m0 = new Millisecond(458, 58, 31, 12, 1, 4, 2007); Millisecond m1 = new Millisecond(459, 58, 31, 12, 1, 4, 2007); Date d0 = new Date(m0.getFirstMillisecond()); Date end = new Date(m1.getLastMillisecond()); DateTickUnit unit = new DateTickUnit(DateTickUnitType.MILLISECOND, 10); axis.setTickUnit(unit); // START: check d0 axis.setTickMarkPosition(DateTickMarkPosition.START); axis.setRange(d0, end); Date psd = axis.previousStandardDate(d0, unit); Date nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); // MIDDLE: check d0 axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); axis.setRange(d0, end); psd = axis.previousStandardDate(d0, unit); nsd = unit.addToDate(psd, tz); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); // END: check d0 axis.setTickMarkPosition(DateTickMarkPosition.END); axis.setRange(d0, end); psd = axis.previousStandardDate(d0, unit); nsd = unit.addToDate(psd, TimeZone.getDefault()); assertTrue(psd.getTime() < d0.getTime()); assertTrue(nsd.getTime() >= d0.getTime()); } /** * A test to reproduce bug 2201869. */ @Test public void testBug2201869() { TimeZone tz = TimeZone.getTimeZone("GMT"); GregorianCalendar c = new GregorianCalendar(tz, Locale.UK); DateAxis axis = new DateAxis("Date", tz, Locale.UK); SimpleDateFormat sdf = new SimpleDateFormat("d-MMM-yyyy", Locale.UK); sdf.setCalendar(c); axis.setTickUnit(new DateTickUnit(DateTickUnitType.MONTH, 1, sdf)); Day d1 = new Day(1, 3, 2008); d1.peg(c); Day d2 = new Day(30, 6, 2008); d2.peg(c); axis.setRange(d1.getStart(), d2.getEnd()); BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = image.createGraphics(); Rectangle2D area = new Rectangle2D.Double(0.0, 0.0, 200, 100); axis.setTickMarkPosition(DateTickMarkPosition.END); List ticks = axis.refreshTicks(g2, new AxisState(), area, RectangleEdge.BOTTOM); assertEquals(3, ticks.size()); DateTick t1 = (DateTick) ticks.get(0); assertEquals("31-Mar-2008", t1.getText()); DateTick t2 = (DateTick) ticks.get(1); assertEquals("30-Apr-2008", t2.getText()); DateTick t3 = (DateTick) ticks.get(2); assertEquals("31-May-2008", t3.getText()); // now repeat for a vertical axis ticks = axis.refreshTicks(g2, new AxisState(), area, RectangleEdge.LEFT); assertEquals(3, ticks.size()); t1 = (DateTick) ticks.get(0); assertEquals("31-Mar-2008", t1.getText()); t2 = (DateTick) ticks.get(1); assertEquals("30-Apr-2008", t2.getText()); t3 = (DateTick) ticks.get(2); assertEquals("31-May-2008", t3.getText()); } }
42,691
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
MarkerAxisBandTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/axis/MarkerAxisBandTest.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.] * * ------------------------ * MarkerAxisBandTests.java * ------------------------ * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 26-Mar-2003 : Version 1 (DG); * 07-Jan-2005 : Added tests for equals() and hashCode() (DG); * */ package org.jfree.chart.axis; import org.junit.Test; 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; /** * Tests for the {@link MarkerAxisBand} class. */ public class MarkerAxisBandTest { /** * Test that the equals() method can distinguish all fields. */ @Test public void testEquals() { Font font1 = new Font("SansSerif", Font.PLAIN, 12); Font font2 = new Font("SansSerif", Font.PLAIN, 14); MarkerAxisBand a1 = new MarkerAxisBand(null, 1.0, 1.0, 1.0, 1.0, font1); MarkerAxisBand a2 = new MarkerAxisBand(null, 1.0, 1.0, 1.0, 1.0, font1); assertEquals(a1, a2); a1 = new MarkerAxisBand(null, 2.0, 1.0, 1.0, 1.0, font1); assertFalse(a1.equals(a2)); a2 = new MarkerAxisBand(null, 2.0, 1.0, 1.0, 1.0, font1); assertEquals(a1, a2); a1 = new MarkerAxisBand(null, 2.0, 3.0, 1.0, 1.0, font1); assertFalse(a1.equals(a2)); a2 = new MarkerAxisBand(null, 2.0, 3.0, 1.0, 1.0, font1); assertEquals(a1, a2); a1 = new MarkerAxisBand(null, 2.0, 3.0, 4.0, 1.0, font1); assertFalse(a1.equals(a2)); a2 = new MarkerAxisBand(null, 2.0, 3.0, 4.0, 1.0, font1); assertEquals(a1, a2); a1 = new MarkerAxisBand(null, 2.0, 3.0, 4.0, 5.0, font1); assertFalse(a1.equals(a2)); a2 = new MarkerAxisBand(null, 2.0, 3.0, 4.0, 5.0, font1); assertEquals(a1, a2); a1 = new MarkerAxisBand(null, 2.0, 3.0, 4.0, 5.0, font2); assertFalse(a1.equals(a2)); a2 = new MarkerAxisBand(null, 2.0, 3.0, 4.0, 5.0, font2); assertEquals(a1, a2); } /** * Two objects that are equal are required to return the same hashCode. */ @Test public void testHashCode() { Font font1 = new Font("SansSerif", Font.PLAIN, 12); MarkerAxisBand a1 = new MarkerAxisBand(null, 1.0, 1.0, 1.0, 1.0, font1); MarkerAxisBand a2 = new MarkerAxisBand(null, 1.0, 1.0, 1.0, 1.0, font1); assertEquals(a1, a2); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { MarkerAxisBand a1 = new MarkerAxisBand(null, 1.0, 1.0, 1.0, 1.0, null); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); MarkerAxisBand a2 = (MarkerAxisBand) in.readObject(); in.close(); assertEquals(a1, a2); } }
4,691
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
SubCategoryAxisTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/axis/SubCategoryAxisTest.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.] * * ------------------------- * SubCategoryAxisTests.java * ------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 12-May-2004 : Version 1 (DG); * 07-Jan-2005 : Added test for hashCode() (DG); * 13-Nov-2008 : Added test2275695() (DG); * */ package org.jfree.chart.axis; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.plot.CategoryPlot; import org.junit.Test; import java.awt.Color; import java.awt.Font; 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.assertSame; /** * Tests for the {@link SubCategoryAxis} class. */ public class SubCategoryAxisTest { /** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { SubCategoryAxis a1 = new SubCategoryAxis("Test"); SubCategoryAxis a2 = new SubCategoryAxis("Test"); assertEquals(a1, a2); assertEquals(a2, a1); // subcategories a1.addSubCategory("Sub 1"); assertFalse(a1.equals(a2)); a2.addSubCategory("Sub 1"); assertEquals(a1, a2); // subLabelFont a1.setSubLabelFont(new Font("Serif", Font.BOLD, 15)); assertFalse(a1.equals(a2)); a2.setSubLabelFont(new Font("Serif", Font.BOLD, 15)); assertEquals(a1, a2); // subLabelPaint a1.setSubLabelPaint(Color.RED); assertFalse(a1.equals(a2)); a2.setSubLabelPaint(Color.RED); assertEquals(a1, a2); } /** * Two objects that are equal are required to return the same hashCode. */ @Test public void testHashCode() { SubCategoryAxis a1 = new SubCategoryAxis("Test"); SubCategoryAxis a2 = new SubCategoryAxis("Test"); assertEquals(a1, a2); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { SubCategoryAxis a1 = new SubCategoryAxis("Test"); a1.addSubCategory("SubCategoryA"); SubCategoryAxis a2 = (SubCategoryAxis) a1.clone(); assertNotSame(a1, a2); assertSame(a1.getClass(), a2.getClass()); assertEquals(a1, a2); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { SubCategoryAxis a1 = new SubCategoryAxis("Test Axis"); a1.addSubCategory("SubCategoryA"); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); SubCategoryAxis a2 = (SubCategoryAxis) in.readObject(); in.close(); assertEquals(a1, a2); } /** * A check for the NullPointerException in bug 2275695. */ @Test public void test2275695() { JFreeChart chart = ChartFactory.createStackedBarChart("Test", "Category", "Value", null); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setDomainAxis(new SubCategoryAxis("SubCategoryAxis")); 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(); //FIXME we should be asserting a value here } }
5,497
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
NumberAxis3DTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/axis/NumberAxis3DTest.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.] * * ---------------------- * NumberAxis3DTests.java * ---------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 26-Mar-2003 : Version 1 (DG); * */ package org.jfree.chart.axis; 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 NumberAxis3D} class. */ public class NumberAxis3DTest { /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { NumberAxis3D a1 = new NumberAxis3D("Test Axis"); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); NumberAxis3D a2 = (NumberAxis3D) in.readObject(); in.close(); assertEquals(a1, a2); } }
2,598
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
DateTickUnitTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/axis/DateTickUnitTest.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.] * * ---------------------- * DateTickUnitTests.java * ---------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 26-Mar-2003 : Version 1 (DG); * 07-Jan-2005 : Added test for hashCode() (DG); * */ package org.jfree.chart.axis; 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 DateTickUnit} class. */ public class DateTickUnitTest { /** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { DateTickUnit t1 = new DateTickUnit(DateTickUnitType.DAY, 1); DateTickUnit t2 = new DateTickUnit(DateTickUnitType.DAY, 1); assertEquals(t1, t2); } /** * Two objects that are equal are required to return the same hashCode. */ @Test public void testHashCode() { DateTickUnit t1 = new DateTickUnit(DateTickUnitType.DAY, 1); DateTickUnit t2 = new DateTickUnit(DateTickUnitType.DAY, 1); assertEquals(t1, t2); int h1 = t1.hashCode(); int h2 = t2.hashCode(); assertEquals(h1, h2); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { DateTickUnit a1 = new DateTickUnit(DateTickUnitType.DAY, 7); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); DateTickUnit a2 = (DateTickUnit) in.readObject(); in.close(); assertEquals(a1, a2); } }
3,374
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
CategoryAxisTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/axis/CategoryAxisTest.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.] * * ---------------------- * CategoryAxisTests.java * ---------------------- * (C) Copyright 2003-2013, 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() test (DG); * 07-Jan-2005 : Added hashCode() test (DG); * */ package org.jfree.chart.axis; 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 CategoryAxis} class. */ public class CategoryAxisTest { /** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { CategoryAxis a1 = new CategoryAxis("Test"); CategoryAxis a2 = new CategoryAxis("Test"); assertEquals(a1, a2); // lowerMargin a1.setLowerMargin(0.15); assertFalse(a1.equals(a2)); a2.setLowerMargin(0.15); assertEquals(a1, a2); // upperMargin a1.setUpperMargin(0.15); assertFalse(a1.equals(a2)); a2.setUpperMargin(0.15); assertEquals(a1, a2); // categoryMargin a1.setCategoryMargin(0.15); assertFalse(a1.equals(a2)); a2.setCategoryMargin(0.15); assertEquals(a1, a2); // maxCategoryLabelWidthRatio a1.setMaximumCategoryLabelWidthRatio(0.98f); assertFalse(a1.equals(a2)); a2.setMaximumCategoryLabelWidthRatio(0.98f); assertEquals(a1, a2); // categoryLabelPositionOffset a1.setCategoryLabelPositionOffset(11); assertFalse(a1.equals(a2)); a2.setCategoryLabelPositionOffset(11); assertEquals(a1, a2); // categoryLabelPositions a1.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45); assertFalse(a1.equals(a2)); a2.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45); assertEquals(a1, a2); // categoryLabelToolTips a1.addCategoryLabelToolTip("Test", "Check"); assertFalse(a1.equals(a2)); a2.addCategoryLabelToolTip("Test", "Check"); assertEquals(a1, a2); // categoryLabelURLs a1.addCategoryLabelURL("Test", "http://www.jfree.org/"); assertFalse(a1.equals(a2)); a2.addCategoryLabelURL("Test", "http://www.jfree.org/"); assertEquals(a1, a2); // tickLabelFont a1.setTickLabelFont("C1", new Font("Dialog", Font.PLAIN, 21)); assertFalse(a1.equals(a2)); a2.setTickLabelFont("C1", new Font("Dialog", Font.PLAIN, 21)); assertEquals(a1, a2); // tickLabelPaint a1.setTickLabelPaint("C1", Color.RED); assertFalse(a1.equals(a2)); a2.setTickLabelPaint("C1", Color.RED); assertEquals(a1, a2); // tickLabelPaint2 a1.setTickLabelPaint("C1", new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.yellow)); assertFalse(a1.equals(a2)); a2.setTickLabelPaint("C1", new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.yellow)); assertEquals(a1, a2); } /** * Two objects that are equal are required to return the same hashCode. */ @Test public void testHashCode() { CategoryAxis a1 = new CategoryAxis("Test"); CategoryAxis a2 = new CategoryAxis("Test"); assertEquals(a1, a2); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { CategoryAxis a1 = new CategoryAxis("Test"); CategoryAxis a2 = (CategoryAxis) a1.clone(); assertNotSame(a1, a2); assertSame(a1.getClass(), a2.getClass()); assertEquals(a1, a2); } /** * Confirm that cloning works. This test customises the font and paint * per category label. */ @Test public void testCloning2() throws CloneNotSupportedException { CategoryAxis a1 = new CategoryAxis("Test"); a1.setTickLabelFont("C1", new Font("Dialog", Font.PLAIN, 15)); a1.setTickLabelPaint("C1", new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.WHITE)); CategoryAxis a2 = (CategoryAxis) a1.clone(); assertNotSame(a1, a2); assertSame(a1.getClass(), a2.getClass()); assertEquals(a1, a2); // check that changing a tick label font in a1 doesn't change a2 a1.setTickLabelFont("C1", null); assertFalse(a1.equals(a2)); a2.setTickLabelFont("C1", null); assertEquals(a1, a2); // check that changing a tick label paint in a1 doesn't change a2 a1.setTickLabelPaint("C1", Color.yellow); assertFalse(a1.equals(a2)); a2.setTickLabelPaint("C1", Color.yellow); assertEquals(a1, a2); // check that changing a category label tooltip in a1 doesn't change a2 a1.addCategoryLabelToolTip("C1", "XYZ"); assertFalse(a1.equals(a2)); a2.addCategoryLabelToolTip("C1", "XYZ"); assertEquals(a1, a2); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { CategoryAxis a1 = new CategoryAxis("Test Axis"); a1.setTickLabelPaint("C1", 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(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); CategoryAxis a2 = (CategoryAxis) in.readObject(); in.close(); assertEquals(a1, a2); } }
7,684
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
CategoryLabelWidthTypeTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/axis/CategoryLabelWidthTypeTest.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.] * * -------------------------------- * CategoryLabelWidthTypeTests.java * -------------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 13-May-2004 : Version 1 (DG); * */ package org.jfree.chart.axis; 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 CategoryLabelWidthType} class. */ public class CategoryLabelWidthTypeTest { /** * Confirm that the equals() method distinguishes the known values. */ @Test public void testEquals() { assertEquals(CategoryLabelWidthType.CATEGORY, CategoryLabelWidthType.CATEGORY); assertEquals(CategoryLabelWidthType.RANGE, CategoryLabelWidthType.RANGE); } /** * Two objects that are equal are required to return the same hashCode. */ @Test public void testHashCode() { CategoryLabelWidthType a1 = CategoryLabelWidthType.CATEGORY; CategoryLabelWidthType a2 = CategoryLabelWidthType.CATEGORY; assertEquals(a1, a2); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { CategoryLabelWidthType w1 = CategoryLabelWidthType.RANGE; ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(w1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); CategoryLabelWidthType w2 = (CategoryLabelWidthType) in.readObject(); in.close(); assertSame(w1, w2); } }
3,458
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
ModuloAxisTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/axis/ModuloAxisTest.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.] * * -------------------- * ModuloAxisTests.java * -------------------- * (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 13-Nov-2007 : Version 1 (DG); * */ package org.jfree.chart.axis; import org.jfree.data.Range; 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 ModuloAxis} class. */ public class ModuloAxisTest { /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { ModuloAxis a1 = new ModuloAxis("Test", new Range(0.0, 1.0)); ModuloAxis a2 = (ModuloAxis) a1.clone(); assertNotSame(a1, a2); assertSame(a1.getClass(), a2.getClass()); assertEquals(a1, a2); } /** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { ModuloAxis a1 = new ModuloAxis("Test", new Range(0.0, 1.0)); ModuloAxis a2 = new ModuloAxis("Test", new Range(0.0, 1.0)); assertEquals(a1, a2); a1.setDisplayRange(0.1, 1.1); assertFalse(a1.equals(a2)); a2.setDisplayRange(0.1, 1.1); assertEquals(a1, a2); } /** * Two objects that are equal are required to return the same hashCode. */ @Test public void testHashCode() { ModuloAxis a1 = new ModuloAxis("Test", new Range(0.0, 1.0)); ModuloAxis a2 = new ModuloAxis("Test", new Range(0.0, 1.0)); assertEquals(a1, a2); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { ModuloAxis a1 = new ModuloAxis("Test", new Range(0.0, 1.0)); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); ModuloAxis a2 = (ModuloAxis) in.readObject(); in.close(); assertEquals(a1, a2); } }
3,975
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
AxisSpaceTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/axis/AxisSpaceTest.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.] * * ------------------- * AxisSpaceTests.java * ------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 14-Aug-2003 : Version 1 (DG); * 07-Jan-2005 : Added hashCode test (DG); * */ package org.jfree.chart.axis; import org.junit.Test; 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 AxisSpace} class. */ public class AxisSpaceTest { /** * Check that the equals() method can distinguish all fields. */ @Test public void testEquals() { AxisSpace a1 = new AxisSpace(); AxisSpace a2 = new AxisSpace(); assertEquals(a1, a2); a1.setTop(1.11); assertFalse(a1.equals(a2)); a2.setTop(1.11); assertEquals(a1, a2); a1.setBottom(2.22); assertFalse(a1.equals(a2)); a2.setBottom(2.22); assertEquals(a1, a2); a1.setLeft(3.33); assertFalse(a1.equals(a2)); a2.setLeft(3.33); assertEquals(a1, a2); a1.setRight(4.44); assertFalse(a1.equals(a2)); a2.setRight(4.44); assertEquals(a1, a2); } /** * Two objects that are equal are required to return the same hashCode. */ @Test public void testHashCode() { AxisSpace s1 = new AxisSpace(); AxisSpace s2 = new AxisSpace(); assertEquals(s1, s2); int h1 = s1.hashCode(); int h2 = s2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { AxisSpace s1 = new AxisSpace(); AxisSpace s2 = (AxisSpace) s1.clone(); assertNotSame(s1, s2); assertSame(s1.getClass(), s2.getClass()); assertEquals(s1, s2); } }
3,289
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
AxisLocationTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/axis/AxisLocationTest.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.] * * ---------------------- * AxisLocationTests.java * ---------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 10-Jul-2003 : Version 1 (DG); * 07-Jan-2005 : Added hashCode() test (DG); * */ package org.jfree.chart.axis; 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 AxisLocation} class. */ public class AxisLocationTest { /** * Some checks for the equals() method. */ @Test public void testEquals() { assertEquals(AxisLocation.TOP_OR_RIGHT, AxisLocation.TOP_OR_RIGHT); assertEquals(AxisLocation.BOTTOM_OR_RIGHT, AxisLocation.BOTTOM_OR_RIGHT); assertEquals(AxisLocation.TOP_OR_LEFT, AxisLocation.TOP_OR_LEFT); assertEquals(AxisLocation.BOTTOM_OR_LEFT, AxisLocation.BOTTOM_OR_LEFT); } /** * Two objects that are equal are required to return the same hashCode. */ @Test public void testHashCode() { AxisLocation a1 = AxisLocation.TOP_OR_RIGHT; AxisLocation a2 = AxisLocation.TOP_OR_RIGHT; assertEquals(a1, a2); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { AxisLocation location1 = AxisLocation.BOTTOM_OR_RIGHT; ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(location1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); AxisLocation location2 = (AxisLocation) in.readObject(); in.close(); assertSame(location1, location2); } }
3,555
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
NumberTickUnitTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/axis/NumberTickUnitTest.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.] * * ------------------------ * NumberTickUnitTests.java * ------------------------ * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 5-Jul-2005 : Version 1 (DG); * */ package org.jfree.chart.axis; 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; /** * Some tests for the {@link NumberTickUnit} class. */ public class NumberTickUnitTest { /** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { NumberTickUnit t1 = new NumberTickUnit(1.23, new DecimalFormat("0.00")); NumberTickUnit t2 = new NumberTickUnit(1.23, new DecimalFormat("0.00")); assertEquals(t1, t2); assertEquals(t2, t1); t1 = new NumberTickUnit(3.21, new DecimalFormat("0.00")); assertFalse(t1.equals(t2)); t2 = new NumberTickUnit(3.21, new DecimalFormat("0.00")); assertEquals(t1, t2); t1 = new NumberTickUnit(3.21, new DecimalFormat("0.000")); assertFalse(t1.equals(t2)); t2 = new NumberTickUnit(3.21, new DecimalFormat("0.000")); assertEquals(t1, t2); } /** * Two objects that are equal are required to return the same hashCode. */ @Test public void testHashCode() { NumberTickUnit t1 = new NumberTickUnit(1.23, new DecimalFormat("0.00")); NumberTickUnit t2 = new NumberTickUnit(1.23, new DecimalFormat("0.00")); int h1 = t1.hashCode(); int h2 = t2.hashCode(); assertEquals(h1, h2); } /** * This is an immutable class so it doesn't need to be cloneable. */ @Test public void testCloning() throws CloneNotSupportedException { NumberTickUnit t1 = new NumberTickUnit(1.23, new DecimalFormat("0.00")); assertFalse(t1 instanceof Cloneable); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { NumberTickUnit t1 = new NumberTickUnit(1.23, new DecimalFormat("0.00")); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(t1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); NumberTickUnit t2 = (NumberTickUnit) in.readObject(); in.close(); assertEquals(t1, t2); } }
4,173
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
CategoryAxis3DTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/axis/CategoryAxis3DTest.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.] * * ------------------------ * CategoryAxis3DTests.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); * */ package org.jfree.chart.axis; 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; /** * Tests for the {@link CategoryAxis3D} class. */ public class CategoryAxis3DTest { /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { CategoryAxis3D a1 = new CategoryAxis3D("Test"); CategoryAxis3D a2 = (CategoryAxis3D) a1.clone(); assertNotSame(a1, a2); assertSame(a1.getClass(), a2.getClass()); assertEquals(a1, a2); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { CategoryAxis3D a1 = new CategoryAxis3D("Test Axis"); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); CategoryAxis3D a2 = (CategoryAxis3D) in.readObject(); in.close(); assertEquals(a1, a2); } }
3,063
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
CategoryLabelPositionsTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/axis/CategoryLabelPositionsTest.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.] * * -------------------------------- * CategoryLabelPositionsTests.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); * 07-Jan-2005 : Added test for hashCode() (DG); * 17-Jun-2012 : Removed JCommon dependencies (DG); * */ package org.jfree.chart.axis; import org.jfree.chart.text.TextBlockAnchor; import org.jfree.chart.ui.RectangleAnchor; 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 CategoryLabelPositions} class. */ public class CategoryLabelPositionsTest { private static final RectangleAnchor RA_TOP = RectangleAnchor.TOP; private static final RectangleAnchor RA_BOTTOM = RectangleAnchor.BOTTOM; /** * Check that the equals method distinguishes all fields. */ @Test public void testEquals() { CategoryLabelPositions p1 = new CategoryLabelPositions( new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER)); CategoryLabelPositions p2 = new CategoryLabelPositions( new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER)); assertEquals(p1, p2); p1 = new CategoryLabelPositions( new CategoryLabelPosition(RA_BOTTOM, TextBlockAnchor.TOP_CENTER), new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER)); assertFalse(p1.equals(p2)); p2 = new CategoryLabelPositions( new CategoryLabelPosition(RA_BOTTOM, TextBlockAnchor.TOP_CENTER), new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER)); assertEquals(p1, p2); p1 = new CategoryLabelPositions( new CategoryLabelPosition(RA_BOTTOM, TextBlockAnchor.TOP_CENTER), new CategoryLabelPosition(RA_BOTTOM, TextBlockAnchor.TOP_CENTER), new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER)); assertFalse(p1.equals(p2)); p2 = new CategoryLabelPositions( new CategoryLabelPosition(RA_BOTTOM, TextBlockAnchor.TOP_CENTER), new CategoryLabelPosition(RA_BOTTOM, TextBlockAnchor.TOP_CENTER), new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER)); assertEquals(p1, p2); p1 = new CategoryLabelPositions( new CategoryLabelPosition(RA_BOTTOM, TextBlockAnchor.TOP_CENTER), new CategoryLabelPosition(RA_BOTTOM, TextBlockAnchor.TOP_CENTER), new CategoryLabelPosition(RA_BOTTOM, TextBlockAnchor.TOP_CENTER), new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER)); assertFalse(p1.equals(p2)); p2 = new CategoryLabelPositions( new CategoryLabelPosition(RA_BOTTOM, TextBlockAnchor.TOP_CENTER), new CategoryLabelPosition(RA_BOTTOM, TextBlockAnchor.TOP_CENTER), new CategoryLabelPosition(RA_BOTTOM, TextBlockAnchor.TOP_CENTER), new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER)); assertEquals(p1, p2); p1 = new CategoryLabelPositions( new CategoryLabelPosition(RA_BOTTOM, TextBlockAnchor.TOP_CENTER), new CategoryLabelPosition(RA_BOTTOM, TextBlockAnchor.TOP_CENTER), new CategoryLabelPosition(RA_BOTTOM, TextBlockAnchor.TOP_CENTER), new CategoryLabelPosition(RA_BOTTOM, TextBlockAnchor.TOP_CENTER)); assertFalse(p1.equals(p2)); p2 = new CategoryLabelPositions( new CategoryLabelPosition(RA_BOTTOM, TextBlockAnchor.TOP_CENTER), new CategoryLabelPosition(RA_BOTTOM, TextBlockAnchor.TOP_CENTER), new CategoryLabelPosition(RA_BOTTOM, TextBlockAnchor.TOP_CENTER), new CategoryLabelPosition(RA_BOTTOM, TextBlockAnchor.TOP_CENTER)); assertEquals(p1, p2); } /** * Two objects that are equal are required to return the same hashCode. */ @Test public void testHashCode() { CategoryLabelPositions p1 = new CategoryLabelPositions( new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER)); CategoryLabelPositions p2 = new CategoryLabelPositions( new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER)); assertEquals(p1, p2); int h1 = p1.hashCode(); int h2 = p2.hashCode(); assertEquals(h1, h2); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { CategoryLabelPositions p1 = CategoryLabelPositions.STANDARD; ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); CategoryLabelPositions p2 = (CategoryLabelPositions) in.readObject(); in.close(); assertEquals(p1, p2); } }
8,542
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
SymbolAxisTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/axis/SymbolAxisTest.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.] * * ---------------------- * SymbolicAxisTests.java * ---------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 26-Mar-2003 : Version 1 (DG); * 25-Jul-2007 : Added new field in testEquals() (DG); * */ package org.jfree.chart.axis; 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 SymbolAxis} class. */ public class SymbolAxisTest { /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { String[] tickLabels = new String[] {"One", "Two", "Three"}; SymbolAxis a1 = new SymbolAxis("Test Axis", tickLabels); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); SymbolAxis a2 = (SymbolAxis) in.readObject(); in.close(); assertEquals(a1, a2); } /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { SymbolAxis a1 = new SymbolAxis("Axis", new String[] {"A", "B"}); SymbolAxis a2 = (SymbolAxis) a1.clone(); assertNotSame(a1, a2); assertSame(a1.getClass(), a2.getClass()); assertEquals(a1, a2); } /** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { SymbolAxis a1 = new SymbolAxis("Axis", new String[] {"A", "B"}); SymbolAxis a2 = new SymbolAxis("Axis", new String[] {"A", "B"}); assertEquals(a1, a2); assertEquals(a2, a1); a1 = new SymbolAxis("Axis 2", new String[] {"A", "B"}); assertFalse(a1.equals(a2)); a2 = new SymbolAxis("Axis 2", new String[] {"A", "B"}); assertEquals(a1, a2); a1 = new SymbolAxis("Axis 2", new String[] {"C", "B"}); assertFalse(a1.equals(a2)); a2 = new SymbolAxis("Axis 2", new String[] {"C", "B"}); assertEquals(a1, a2); a1.setGridBandsVisible(false); assertFalse(a1.equals(a2)); a2.setGridBandsVisible(false); assertEquals(a1, a2); a1.setGridBandPaint(Color.BLACK); assertFalse(a1.equals(a2)); a2.setGridBandPaint(Color.BLACK); assertEquals(a1, a2); a1.setGridBandAlternatePaint(Color.RED); assertFalse(a1.equals(a2)); a2.setGridBandAlternatePaint(Color.RED); assertEquals(a1, a2); } }
4,440
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
CyclicNumberAxisTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/axis/CyclicNumberAxisTest.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.] * * -------------------- * CyclicAxisTests.java * -------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: Nicolas Brodu * Contributor(s): -; * * Changes * ------- * 19-Nov-2003 : First version (NB); * 05-Oct-2004 : Removed extension of NumberAxisTests (DG); * 07-Jan-2004 : Added test for hashCode() (DG); * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); * */ package org.jfree.chart.axis; 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; /** * Tests for the {@link CyclicNumberAxis} class. */ public class CyclicNumberAxisTest { /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { CyclicNumberAxis a1 = new CyclicNumberAxis("Test", 10, 0); CyclicNumberAxis a2 = (CyclicNumberAxis) a1.clone(); assertNotSame(a1, a2); assertSame(a1.getClass(), a2.getClass()); assertEquals(a1, a2); } /** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { CyclicNumberAxis a1 = new CyclicNumberAxis("Test", 10, 0); CyclicNumberAxis a2 = new CyclicNumberAxis("Test", 10, 0); assertEquals(a1, a2); // period a1.setPeriod(5); assertFalse(a1.equals(a2)); a2.setPeriod(5); assertEquals(a1, a2); // offset a1.setOffset(2.0); assertFalse(a1.equals(a2)); a2.setOffset(2.0); assertEquals(a1, a2); // advance line Paint a1.setAdvanceLinePaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.BLACK)); assertFalse(a1.equals(a2)); a2.setAdvanceLinePaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.BLACK)); assertEquals(a1, a2); // advance line Stroke Stroke stroke = new BasicStroke(0.2f); a1.setAdvanceLineStroke(stroke); assertFalse(a1.equals(a2)); a2.setAdvanceLineStroke(stroke); assertEquals(a1, a2); // advance line Visible a1.setAdvanceLineVisible(!a1.isAdvanceLineVisible()); assertFalse(a1.equals(a2)); a2.setAdvanceLineVisible(a1.isAdvanceLineVisible()); assertEquals(a1, a2); // cycle bound mapping a1.setBoundMappedToLastCycle(!a1.isBoundMappedToLastCycle()); assertFalse(a1.equals(a2)); a2.setBoundMappedToLastCycle(a1.isBoundMappedToLastCycle()); assertEquals(a1, a2); } /** * Two objects that are equal are required to return the same hashCode. */ @Test public void testHashCode() { CyclicNumberAxis a1 = new CyclicNumberAxis("Test", 10, 0); CyclicNumberAxis a2 = new CyclicNumberAxis("Test", 10, 0); assertEquals(a1, a2); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { CyclicNumberAxis a1 = new CyclicNumberAxis("Test", 10, 0); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); CyclicNumberAxis a2 = (CyclicNumberAxis) in.readObject(); in.close(); assertEquals(a1, a2); } }
5,378
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
LogAxisTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/axis/LogAxisTest.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.] * * ----------------- * LogAxisTests.java * ----------------- * (C) Copyright 2007-2012, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 11-Jul-2007 : Version 1 (DG); * 08-Apr-2008 : Fixed incorrect testEquals() method (DG); * 28-Oct-2011 : Added test for endless loop, # 3429707 (MH); * 17-Jun-2012 : Removed JCommon dependencies (DG); * */ package org.jfree.chart.axis; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.ui.RectangleEdge; import org.jfree.data.category.DefaultCategoryDataset; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; 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.assertSame; import static org.junit.Assert.assertTrue; /** * Tests for the {@link LogAxis} class. */ public class LogAxisTest { /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { LogAxis a1 = new LogAxis("Test"); LogAxis a2 = (LogAxis) a1.clone(); assertNotSame(a1, a2); assertSame(a1.getClass(), a2.getClass()); assertEquals(a1, a2); } /** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { LogAxis a1 = new LogAxis("Test"); LogAxis a2 = new LogAxis("Test"); assertEquals(a1, a2); a1.setBase(2.0); assertFalse(a1.equals(a2)); a2.setBase(2.0); assertEquals(a1, a2); a1.setSmallestValue(0.1); assertFalse(a1.equals(a2)); a2.setSmallestValue(0.1); assertEquals(a1, a2); a1.setMinorTickCount(8); assertFalse(a1.equals(a2)); a2.setMinorTickCount(8); assertEquals(a1, a2); } /** * Two objects that are equal are required to return the same hashCode. */ @Test public void testHashCode() { LogAxis a1 = new LogAxis("Test"); LogAxis a2 = new LogAxis("Test"); assertEquals(a1, a2); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } private static final double EPSILON = 0.0000001; /** * Test the translation of Java2D values to data values. */ @Test public void testTranslateJava2DToValue() { LogAxis axis = new LogAxis(); axis.setRange(50.0, 100.0); Rectangle2D dataArea = new Rectangle2D.Double(10.0, 50.0, 400.0, 300.0); double y1 = axis.java2DToValue(75.0, dataArea, RectangleEdge.LEFT); assertEquals(94.3874312681693, y1, EPSILON); double y2 = axis.java2DToValue(75.0, dataArea, RectangleEdge.RIGHT); assertEquals(94.3874312681693, y2, EPSILON); double x1 = axis.java2DToValue(75.0, dataArea, RectangleEdge.TOP); assertEquals(55.961246381405, x1, EPSILON); double x2 = axis.java2DToValue(75.0, dataArea, RectangleEdge.BOTTOM); assertEquals(55.961246381405, x2, EPSILON); axis.setInverted(true); double y3 = axis.java2DToValue(75.0, dataArea, RectangleEdge.LEFT); assertEquals(52.9731547179647, y3, EPSILON); double y4 = axis.java2DToValue(75.0, dataArea, RectangleEdge.RIGHT); assertEquals(52.9731547179647, y4, EPSILON); double x3 = axis.java2DToValue(75.0, dataArea, RectangleEdge.TOP); assertEquals(89.3475453695651, x3, EPSILON); double x4 = axis.java2DToValue(75.0, dataArea, RectangleEdge.BOTTOM); assertEquals(89.3475453695651, x4, EPSILON); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { LogAxis a1 = new LogAxis("Test Axis"); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); LogAxis a2 = (LogAxis) in.readObject(); in.close(); assertEquals(a1, a2); } /** * A simple test for the auto-range calculation looking at a * LogAxis used as the range axis for a CategoryPlot. */ @Test public void testAutoRange1() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.setValue(100.0, "Row 1", "Column 1"); dataset.setValue(200.0, "Row 1", "Column 2"); JFreeChart chart = ChartFactory.createBarChart("Test", "Categories", "Value", dataset); CategoryPlot plot = (CategoryPlot) chart.getPlot(); LogAxis axis = new LogAxis("Log(Y)"); plot.setRangeAxis(axis); assertEquals(0.0, axis.getLowerBound(), EPSILON); assertEquals(2.6066426411261268E7, axis.getUpperBound(), EPSILON); } /** * A simple test for the auto-range calculation looking at a * NumberAxis used as the range axis for a CategoryPlot. In this * case, the original dataset is replaced with a new dataset. */ @Test public void testAutoRange3() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.setValue(100.0, "Row 1", "Column 1"); dataset.setValue(200.0, "Row 1", "Column 2"); JFreeChart chart = ChartFactory.createLineChart("Test", "Categories", "Value", dataset); CategoryPlot plot = (CategoryPlot) chart.getPlot(); LogAxis axis = new LogAxis("Log(Y)"); plot.setRangeAxis(axis); assertEquals(96.59363289248458, axis.getLowerBound(), EPSILON); assertEquals(207.0529847682752, axis.getUpperBound(), EPSILON); // now replacing the dataset should update the axis range... DefaultCategoryDataset dataset2 = new DefaultCategoryDataset(); dataset2.setValue(900.0, "Row 1", "Column 1"); dataset2.setValue(1000.0, "Row 1", "Column 2"); plot.setDataset(dataset2); assertEquals(895.2712433374774, axis.getLowerBound(), EPSILON); assertEquals(1005.2819262292991, axis.getUpperBound(), EPSILON); } /** * Checks that the auto-range for the domain axis on an XYPlot is * working as expected. */ @Test public void testXYAutoRange1() { XYSeries series = new XYSeries("Series 1"); 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); JFreeChart chart = ChartFactory.createScatterPlot("Test", "X", "Y", dataset); XYPlot plot = (XYPlot) chart.getPlot(); LogAxis axis = new LogAxis("Log(Y)"); plot.setRangeAxis(axis); assertEquals(0.9465508226401592, axis.getLowerBound(), EPSILON); assertEquals(3.1694019256486126, axis.getUpperBound(), EPSILON); } /** * Checks that the auto-range for the range axis on an XYPlot is * working as expected. */ @Test public void testXYAutoRange2() { XYSeries series = new XYSeries("Series 1"); 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); JFreeChart chart = ChartFactory.createScatterPlot("Test", "X", "Y", dataset); XYPlot plot = (XYPlot) chart.getPlot(); LogAxis axis = new LogAxis("Log(Y)"); plot.setRangeAxis(axis); assertEquals(0.9465508226401592, axis.getLowerBound(), EPSILON); assertEquals(3.1694019256486126, axis.getUpperBound(), EPSILON); } /** * Some checks for the setLowerBound() method. */ @Test public void testSetLowerBound() { LogAxis axis = new LogAxis("X"); axis.setRange(0.0, 10.0); axis.setLowerBound(5.0); assertEquals(5.0, axis.getLowerBound(), EPSILON); axis.setLowerBound(10.0); assertEquals(10.0, axis.getLowerBound(), EPSILON); assertEquals(11.0, axis.getUpperBound(), EPSILON); } /** * Checks the default value for the tickMarksVisible flag. */ @Test public void testTickMarksVisibleDefault() { LogAxis axis = new LogAxis("Log Axis"); assertTrue(axis.isTickMarksVisible()); } /** * Checks that a TickUnit with a size of 0 doesn't crash. */ @Test public void testrefreshTicksWithZeroTickUnit() { LogAxis axis = new LogAxis(); AxisState state = new AxisState(); BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_ARGB); Graphics2D g2 = image.createGraphics(); Rectangle2D area = new Rectangle2D.Double(0.0, 0.0, 200, 100); axis.refreshTicks(g2, state, area, RectangleEdge.TOP); } }
10,859
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
DateTickTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/axis/DateTickTest.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.] * * ------------------ * DateTickTests.java * ------------------ * (C) Copyright 2004-2012, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 13-May-2004 : Version 1 (DG); * 25-Sep-2008 : Extended testEquals() to cover new fields (DG); * 17-Jun-2012 : Removed JCommon dependencies (DG); * */ package org.jfree.chart.axis; import org.jfree.chart.ui.TextAnchor; 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.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; /** * Tests for the {@link DateTick} class. */ public class DateTickTest { /** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { Date d1 = new Date(0L); Date d2 = new Date(1L); String l1 = "Label 1"; String l2 = "Label 2"; TextAnchor ta1 = TextAnchor.CENTER; TextAnchor ta2 = TextAnchor.BASELINE_LEFT; DateTick t1 = new DateTick(d1, l1, ta1, ta1, Math.PI / 2.0); DateTick t2 = new DateTick(d1, l1, ta1, ta1, Math.PI / 2.0); assertEquals(t1, t2); t1 = new DateTick(d2, l1, ta1, ta1, Math.PI / 2.0); assertFalse(t1.equals(t2)); t2 = new DateTick(d2, l1, ta1, ta1, Math.PI / 2.0); assertEquals(t1, t2); t1 = new DateTick(d1, l2, ta1, ta1, Math.PI / 2.0); assertFalse(t1.equals(t2)); t2 = new DateTick(d1, l2, ta1, ta1, Math.PI / 2.0); assertEquals(t1, t2); t1 = new DateTick(d1, l1, ta2, ta1, Math.PI / 2.0); assertFalse(t1.equals(t2)); t2 = new DateTick(d1, l1, ta2, ta1, Math.PI / 2.0); assertEquals(t1, t2); t1 = new DateTick(d1, l1, ta1, ta2, Math.PI / 2.0); assertFalse(t1.equals(t2)); t2 = new DateTick(d1, l1, ta1, ta2, Math.PI / 2.0); assertEquals(t1, t2); t1 = new DateTick(d1, l1, ta1, ta1, Math.PI / 3.0); assertFalse(t1.equals(t2)); t2 = new DateTick(d1, l1, ta1, ta1, Math.PI / 3.0); assertEquals(t1, t2); t1 = new DateTick(TickType.MINOR, d1, l1, ta1, ta1, Math.PI); t2 = new DateTick(TickType.MAJOR, d1, l1, ta1, ta1, Math.PI); assertFalse(t1.equals(t2)); t2 = new DateTick(TickType.MINOR, d1, l1, ta1, ta1, Math.PI); assertEquals(t1, t2); } /** * Two objects that are equal are required to return the same hashCode. */ @Test public void testHashCode() { Date d1 = new Date(0L); String l1 = "Label 1"; TextAnchor ta1 = TextAnchor.CENTER; DateTick t1 = new DateTick(d1, l1, ta1, ta1, Math.PI / 2.0); DateTick t2 = new DateTick(d1, l1, ta1, ta1, Math.PI / 2.0); assertEquals(t1, t2); int h1 = t1.hashCode(); int h2 = t2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { DateTick t1 = new DateTick(new Date(0L), "Label", TextAnchor.CENTER, TextAnchor.CENTER, 10.0); DateTick t2 = (DateTick) 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 { DateTick t1 = new DateTick(new Date(0L), "Label", TextAnchor.CENTER, TextAnchor.CENTER, 10.0); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(t1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); DateTick t2 = (DateTick) in.readObject(); in.close(); assertEquals(t1, t2); } }
5,614
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
CategoryLabelPositionTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/axis/CategoryLabelPositionTest.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.] * * ------------------------------- * CategoryLabelPositionTests.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); * 07-Jan-2005 : Improved testEquals() code and added hashCode() test (DG); * 17-Jun-2012 : Removed JCommon dependencies (DG); * */ package org.jfree.chart.axis; import org.jfree.chart.text.TextBlockAnchor; import org.jfree.chart.ui.RectangleAnchor; import org.jfree.chart.ui.TextAnchor; 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 CategoryLabelPosition} class. */ public class CategoryLabelPositionTest { /** * Check that the equals() method can distinguish all fields. */ @Test public void testEquals() { CategoryLabelPosition p1 = new CategoryLabelPosition( RectangleAnchor.BOTTOM_LEFT, TextBlockAnchor.CENTER_RIGHT, TextAnchor.BASELINE_LEFT, Math.PI / 4.0, CategoryLabelWidthType.RANGE, 0.44f); CategoryLabelPosition p2 = new CategoryLabelPosition( RectangleAnchor.BOTTOM_LEFT, TextBlockAnchor.CENTER_RIGHT, TextAnchor.BASELINE_LEFT, Math.PI / 4.0, CategoryLabelWidthType.RANGE, 0.44f); assertEquals(p1, p2); assertEquals(p2, p1); p1 = new CategoryLabelPosition(RectangleAnchor.TOP, TextBlockAnchor.CENTER_RIGHT, TextAnchor.BASELINE_LEFT, Math.PI / 4.0, CategoryLabelWidthType.RANGE, 0.44f); assertFalse(p1.equals(p2)); p2 = new CategoryLabelPosition(RectangleAnchor.TOP, TextBlockAnchor.CENTER_RIGHT, TextAnchor.BASELINE_LEFT, Math.PI / 4.0, CategoryLabelWidthType.RANGE, 0.44f); assertEquals(p1, p2); p1 = new CategoryLabelPosition(RectangleAnchor.TOP, TextBlockAnchor.CENTER, TextAnchor.BASELINE_LEFT, Math.PI / 4.0, CategoryLabelWidthType.RANGE, 0.44f); assertFalse(p1.equals(p2)); p2 = new CategoryLabelPosition(RectangleAnchor.TOP, TextBlockAnchor.CENTER, TextAnchor.BASELINE_LEFT, Math.PI / 4.0, CategoryLabelWidthType.RANGE, 0.44f); assertEquals(p1, p2); p1 = new CategoryLabelPosition(RectangleAnchor.TOP, TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 4.0, CategoryLabelWidthType.RANGE, 0.44f); assertFalse(p1.equals(p2)); p2 = new CategoryLabelPosition(RectangleAnchor.TOP, TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 4.0, CategoryLabelWidthType.RANGE, 0.44f); assertEquals(p1, p2); p1 = new CategoryLabelPosition(RectangleAnchor.TOP, TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 6.0, CategoryLabelWidthType.RANGE, 0.44f); assertFalse(p1.equals(p2)); p2 = new CategoryLabelPosition(RectangleAnchor.TOP, TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 6.0, CategoryLabelWidthType.RANGE, 0.44f); assertEquals(p1, p2); p1 = new CategoryLabelPosition(RectangleAnchor.TOP, TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 6.0, CategoryLabelWidthType.CATEGORY, 0.44f); assertFalse(p1.equals(p2)); p2 = new CategoryLabelPosition(RectangleAnchor.TOP, TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 6.0, CategoryLabelWidthType.CATEGORY, 0.44f); assertEquals(p1, p2); p1 = new CategoryLabelPosition(RectangleAnchor.TOP, TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 6.0, CategoryLabelWidthType.CATEGORY, 0.55f); assertFalse(p1.equals(p2)); p2 = new CategoryLabelPosition(RectangleAnchor.TOP, TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 6.0, CategoryLabelWidthType.CATEGORY, 0.55f); assertEquals(p1, p2); } /** * Two objects that are equal are required to return the same hashCode. */ @Test public void testHashCode() { CategoryLabelPosition a1 = new CategoryLabelPosition(); CategoryLabelPosition a2 = new CategoryLabelPosition(); assertEquals(a1, a2); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { CategoryLabelPosition p1 = new CategoryLabelPosition(); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); CategoryLabelPosition p2 = (CategoryLabelPosition) in.readObject(); in.close(); assertEquals(p1, p2); } }
6,756
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
AxisTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/axis/AxisTest.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.] * * -------------- * AxisTests.java * -------------- * (C) Copyright 2003-2012, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 13-Aug-2003 : Version 1 (DG); * 06-Jan-2004 : Added tests for axis line attributes (DG); * 07-Jan-2005 : Added hashCode() test (DG); * 25-Sep-2008 : Extended equals() to cover new fields (DG); * 17-Jun-2012 : Removed JCommon dependencies (DG); * */ package org.jfree.chart.axis; import org.jfree.chart.ui.RectangleInsets; import org.junit.Test; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; import java.awt.GradientPaint; import java.awt.font.TextAttribute; import java.text.AttributedString; import org.jfree.chart.TestUtilities; import static org.junit.Assert.*; import static org.hamcrest.CoreMatchers.*; /** * Tests for the {@link Axis} class. */ public class AxisTest { /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { CategoryAxis a1 = new CategoryAxis("Test"); a1.setAxisLinePaint(Color.RED); CategoryAxis a2 = (CategoryAxis) a1.clone(); assertNotSame(a1, a2); assertSame(a1.getClass(), a2.getClass()); assertEquals(a1, a2); } /** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { Axis a1 = new CategoryAxis("Test"); Axis a2 = new CategoryAxis("Test"); assertEquals(a1, a2); // visible flag... a1.setVisible(false); assertThat(a1, not(a2)); a2.setVisible(false); assertEquals(a1, a2); // label... a1.setLabel("New Label"); assertThat(a1, not(a2)); a2.setLabel("New Label"); assertEquals(a1, a2); // label font... a1.setLabelFont(new Font("Dialog", Font.PLAIN, 8)); assertThat(a1, not(a2)); a2.setLabelFont(new Font("Dialog", Font.PLAIN, 8)); assertEquals(a1, a2); // label paint... a1.setLabelPaint(new GradientPaint(1.0f, 2.0f, Color.WHITE, 3.0f, 4.0f, Color.BLACK)); assertThat(a1, not(a2)); a2.setLabelPaint(new GradientPaint(1.0f, 2.0f, Color.WHITE, 3.0f, 4.0f, Color.BLACK)); assertEquals(a1, a2); // attributed label... a1.setLabel(new AttributedString("Hello World!")); assertThat(a1, not(a2)); a2.setLabel(new AttributedString("Hello World!")); assertEquals(a1, a2); AttributedString l1 = a1.getLabel(); l1.addAttribute(TextAttribute.SUPERSCRIPT, TextAttribute.SUPERSCRIPT_SUB, 1, 2); a1.setLabel(l1); assertThat(a1, not(a2)); AttributedString l2 = a2.getLabel(); l2.addAttribute(TextAttribute.SUPERSCRIPT, TextAttribute.SUPERSCRIPT_SUB, 1, 2); a2.setLabel(l2); assertEquals(a1, a2); // label insets... a1.setLabelInsets(new RectangleInsets(10.0, 10.0, 10.0, 10.0)); assertThat(a1, not(a2)); a2.setLabelInsets(new RectangleInsets(10.0, 10.0, 10.0, 10.0)); assertEquals(a1, a2); // label angle... a1.setLabelAngle(1.23); assertThat(a1, not(a2)); a2.setLabelAngle(1.23); assertEquals(a1, a2); // label location... a1.setLabelLocation(AxisLabelLocation.HIGH_END); assertThat(a1, not(a2)); a2.setLabelLocation(AxisLabelLocation.HIGH_END); assertEquals(a1, a2); // axis line visible... a1.setAxisLineVisible(false); assertThat(a1, not(a2)); a2.setAxisLineVisible(false); assertEquals(a1, a2); // axis line stroke... BasicStroke s = new BasicStroke(1.1f); a1.setAxisLineStroke(s); assertThat(a1, not(a2)); a2.setAxisLineStroke(s); assertEquals(a1, a2); // axis line paint... a1.setAxisLinePaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.BLACK)); assertThat(a1, not(a2)); a2.setAxisLinePaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.BLACK)); assertEquals(a1, a2); // tick labels visible flag... a1.setTickLabelsVisible(false); assertThat(a1, not(a2)); a2.setTickLabelsVisible(false); assertEquals(a1, a2); // tick label font... a1.setTickLabelFont(new Font("Dialog", Font.PLAIN, 12)); assertThat(a1, not(a2)); a2.setTickLabelFont(new Font("Dialog", Font.PLAIN, 12)); assertEquals(a1, a2); // tick label paint... a1.setTickLabelPaint(new GradientPaint(1.0f, 2.0f, Color.yellow, 3.0f, 4.0f, Color.BLACK)); assertThat(a1, not(a2)); a2.setTickLabelPaint(new GradientPaint(1.0f, 2.0f, Color.yellow, 3.0f, 4.0f, Color.BLACK)); assertEquals(a1, a2); // tick label insets... a1.setTickLabelInsets(new RectangleInsets(10.0, 10.0, 10.0, 10.0)); assertThat(a1, not(a2)); a2.setTickLabelInsets(new RectangleInsets(10.0, 10.0, 10.0, 10.0)); assertEquals(a1, a2); // tick marks visible flag... a1.setTickMarksVisible(false); assertThat(a1, not(a2)); a2.setTickMarksVisible(false); assertEquals(a1, a2); // tick mark inside length... a1.setTickMarkInsideLength(1.23f); assertThat(a1, not(a2)); a2.setTickMarkInsideLength(1.23f); assertEquals(a1, a2); // tick mark outside length... a1.setTickMarkOutsideLength(1.23f); assertThat(a1, not(a2)); a2.setTickMarkOutsideLength(1.23f); assertEquals(a1, a2); // tick mark stroke... a1.setTickMarkStroke(new BasicStroke(2.0f)); assertThat(a1, not(a2)); a2.setTickMarkStroke(new BasicStroke(2.0f)); assertEquals(a1, a2); // tick mark paint... a1.setTickMarkPaint(new GradientPaint(1.0f, 2.0f, Color.cyan, 3.0f, 4.0f, Color.BLACK)); assertThat(a1, not(a2)); a2.setTickMarkPaint(new GradientPaint(1.0f, 2.0f, Color.cyan, 3.0f, 4.0f, Color.BLACK)); assertEquals(a1, a2); // fixed dimension... a1.setFixedDimension(3.21f); assertThat(a1, not(a2)); a2.setFixedDimension(3.21f); assertEquals(a1, a2); a1.setMinorTickMarksVisible(true); assertThat(a1, not(a2)); a2.setMinorTickMarksVisible(true); assertEquals(a1, a2); a1.setMinorTickMarkInsideLength(1.23f); assertThat(a1, not(a2)); a2.setMinorTickMarkInsideLength(1.23f); assertEquals(a1, a2); a1.setMinorTickMarkOutsideLength(3.21f); assertThat(a1, not(a2)); a2.setMinorTickMarkOutsideLength(3.21f); assertEquals(a1, a2); } /** * Two objects that are equal are required to return the same hashCode. */ @Test public void testHashCode() { Axis a1 = new CategoryAxis("Test"); Axis a2 = new CategoryAxis("Test"); assertEquals(a1, a2); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Checks that serialization works, particularly with the attributed label. */ @Test public void testSerialization() { Axis a1 = new CategoryAxis("Test"); AttributedString label = new AttributedString("Axis Label"); label.addAttribute(TextAttribute.SUPERSCRIPT, TextAttribute.SUPERSCRIPT_SUB, 1, 4); a1.setLabel(label); Axis a2 = (Axis) TestUtilities.serialised(a1); assertEquals(a1, a2); } }
9,157
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
QuarterDateFormatTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/axis/QuarterDateFormatTest.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.] * * --------------------------- * QuarterDateFormatTests.java * --------------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 10-May-2005 : Version 1 (DG); * 08-Jun-2007 : Added check for new field in testEquals() (DG); * */ package org.jfree.chart.axis; 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.TimeZone; 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 QuarterDateFormat} class. */ public class QuarterDateFormatTest { /** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { QuarterDateFormat qf1 = new QuarterDateFormat(TimeZone.getTimeZone( "GMT"), new String[] {"1", "2", "3", "4"}); QuarterDateFormat qf2 = new QuarterDateFormat(TimeZone.getTimeZone( "GMT"), new String[] {"1", "2", "3", "4"}); assertEquals(qf1, qf2); assertEquals(qf2, qf1); qf1 = new QuarterDateFormat(TimeZone.getTimeZone("PST"), new String[] {"1", "2", "3", "4"}); assertFalse(qf1.equals(qf2)); qf2 = new QuarterDateFormat(TimeZone.getTimeZone("PST"), new String[] {"1", "2", "3", "4"}); assertEquals(qf1, qf2); qf1 = new QuarterDateFormat(TimeZone.getTimeZone("PST"), new String[] {"A", "2", "3", "4"}); assertFalse(qf1.equals(qf2)); qf2 = new QuarterDateFormat(TimeZone.getTimeZone("PST"), new String[] {"A", "2", "3", "4"}); assertEquals(qf1, qf2); qf1 = new QuarterDateFormat(TimeZone.getTimeZone("PST"), new String[] {"A", "2", "3", "4"}, true); assertFalse(qf1.equals(qf2)); qf2 = new QuarterDateFormat(TimeZone.getTimeZone("PST"), new String[] {"A", "2", "3", "4"}, true); assertEquals(qf1, qf2); } /** * Two objects that are equal are required to return the same hashCode. */ @Test public void testHashCode() { QuarterDateFormat qf1 = new QuarterDateFormat(TimeZone.getTimeZone( "GMT"), new String[] {"1", "2", "3", "4"}); QuarterDateFormat qf2 = new QuarterDateFormat(TimeZone.getTimeZone( "GMT"), new String[] {"1", "2", "3", "4"}); assertEquals(qf1, qf2); int h1 = qf1.hashCode(); int h2 = qf2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { QuarterDateFormat qf1 = new QuarterDateFormat(TimeZone.getTimeZone( "GMT"), new String[] {"1", "2", "3", "4"}); QuarterDateFormat qf2 = (QuarterDateFormat) qf1.clone(); assertNotSame(qf1, qf2); assertSame(qf1.getClass(), qf2.getClass()); assertEquals(qf1, qf2); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { QuarterDateFormat qf1 = new QuarterDateFormat(TimeZone.getTimeZone( "GMT"), new String[] {"1", "2", "3", "4"}); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(qf1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); QuarterDateFormat qf2 = (QuarterDateFormat) in.readObject(); in.close(); assertEquals(qf1, qf2); } }
5,371
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
DateTickMarkPositionTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/axis/DateTickMarkPositionTest.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.] * * ------------------------------ * DateTickMarkPositionTests.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.axis; 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 DateTickMarkPosition} class. */ public class DateTickMarkPositionTest { /** * Test equals() method. */ @Test public void testEquals() { assertEquals(DateTickMarkPosition.START, DateTickMarkPosition.START); assertEquals(DateTickMarkPosition.MIDDLE, DateTickMarkPosition.MIDDLE); assertEquals(DateTickMarkPosition.END, DateTickMarkPosition.END); assertFalse(DateTickMarkPosition.START.equals(null)); assertFalse(DateTickMarkPosition.START.equals( DateTickMarkPosition.END)); assertFalse(DateTickMarkPosition.MIDDLE.equals( DateTickMarkPosition.END)); } /** * Two objects that are equal are required to return the same hashCode. */ @Test public void testHashCode() { DateTickMarkPosition a1 = DateTickMarkPosition.END; DateTickMarkPosition a2 = DateTickMarkPosition.END; assertEquals(a1, a2); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { DateTickMarkPosition p1 = DateTickMarkPosition.MIDDLE; ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); DateTickMarkPosition p2 = (DateTickMarkPosition) in.readObject(); in.close(); assertSame(p1, p2); } }
3,714
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
CompassFormatTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/axis/CompassFormatTest.java
package org.jfree.chart.axis; import org.junit.Test; import static org.junit.Assert.assertEquals; /** * Tests for the {@link CompassFormat} class. */ public class CompassFormatTest { @Test public void testDefaultConstructor() { final CompassFormat fmt = new CompassFormat(); assertEquals("N", fmt.getDirectionCode(0)); assertEquals("N", fmt.getDirectionCode(360)); } @Test public void testCustomFormat() { final CompassFormat fmt = new CompassFormat(); final CompassFormat fmtCustom = new CompassFormat("N", "O", "S", "W"); assertEquals("E", fmt.getDirectionCode(90)); assertEquals("O", fmtCustom.getDirectionCode(90)); assertEquals("NNO", fmtCustom.getDirectionCode(22.5)); } }
775
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
TextAnchorTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/text/TextAnchorTest.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.] * * ------------------------ * CompositeTitleTests.java * ------------------------ * (C) Copyright 2013, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 31-Jul-2013 : Version 1 (DG); * */ package org.jfree.chart.text; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import org.jfree.chart.ui.TextAnchor; import org.junit.Test; /** * Some tests for the {@link TextAnchor} enum. */ public class TextAnchorTest { @Test public void checkTOP_LEFT() { assertTrue(TextAnchor.TOP_LEFT.isTop()); assertFalse(TextAnchor.TOP_LEFT.isHalfHeight()); assertFalse(TextAnchor.TOP_LEFT.isHalfAscent()); assertFalse(TextAnchor.TOP_LEFT.isBaseline()); assertFalse(TextAnchor.TOP_LEFT.isBottom()); assertTrue(TextAnchor.TOP_LEFT.isHorizontalLeft()); assertFalse(TextAnchor.TOP_LEFT.isHorizontalCenter()); assertFalse(TextAnchor.TOP_LEFT.isHorizontalRight()); } @Test public void checkTOP_CENTER() { assertTrue(TextAnchor.TOP_CENTER.isTop()); assertFalse(TextAnchor.TOP_CENTER.isHalfHeight()); assertFalse(TextAnchor.TOP_CENTER.isHalfAscent()); assertFalse(TextAnchor.TOP_CENTER.isBaseline()); assertFalse(TextAnchor.TOP_CENTER.isBottom()); assertFalse(TextAnchor.TOP_CENTER.isHorizontalLeft()); assertTrue(TextAnchor.TOP_CENTER.isHorizontalCenter()); assertFalse(TextAnchor.TOP_CENTER.isHorizontalRight()); } @Test public void checkTOP_RIGHT() { assertTrue(TextAnchor.TOP_RIGHT.isTop()); assertFalse(TextAnchor.TOP_RIGHT.isHalfHeight()); assertFalse(TextAnchor.TOP_RIGHT.isHalfAscent()); assertFalse(TextAnchor.TOP_RIGHT.isBaseline()); assertFalse(TextAnchor.TOP_RIGHT.isBottom()); assertFalse(TextAnchor.TOP_RIGHT.isHorizontalLeft()); assertFalse(TextAnchor.TOP_RIGHT.isHorizontalCenter()); assertTrue(TextAnchor.TOP_RIGHT.isHorizontalRight()); } @Test public void checkHALF_ASCENT_LEFT() { assertFalse(TextAnchor.HALF_ASCENT_LEFT.isTop()); assertFalse(TextAnchor.HALF_ASCENT_LEFT.isHalfHeight()); assertTrue(TextAnchor.HALF_ASCENT_LEFT.isHalfAscent()); assertFalse(TextAnchor.HALF_ASCENT_LEFT.isBaseline()); assertFalse(TextAnchor.HALF_ASCENT_LEFT.isBottom()); assertTrue(TextAnchor.HALF_ASCENT_LEFT.isHorizontalLeft()); assertFalse(TextAnchor.HALF_ASCENT_LEFT.isHorizontalCenter()); assertFalse(TextAnchor.HALF_ASCENT_LEFT.isHorizontalRight()); } @Test public void checkHALF_ASCENT_CENTER() { assertFalse(TextAnchor.HALF_ASCENT_CENTER.isTop()); assertFalse(TextAnchor.HALF_ASCENT_CENTER.isHalfHeight()); assertTrue(TextAnchor.HALF_ASCENT_CENTER.isHalfAscent()); assertFalse(TextAnchor.HALF_ASCENT_CENTER.isBaseline()); assertFalse(TextAnchor.HALF_ASCENT_CENTER.isBottom()); assertFalse(TextAnchor.HALF_ASCENT_CENTER.isHorizontalLeft()); assertTrue(TextAnchor.HALF_ASCENT_CENTER.isHorizontalCenter()); assertFalse(TextAnchor.HALF_ASCENT_CENTER.isHorizontalRight()); } @Test public void checkHALF_ASCENT_RIGHT() { assertFalse(TextAnchor.HALF_ASCENT_RIGHT.isTop()); assertFalse(TextAnchor.HALF_ASCENT_RIGHT.isHalfHeight()); assertTrue(TextAnchor.HALF_ASCENT_RIGHT.isHalfAscent()); assertFalse(TextAnchor.HALF_ASCENT_RIGHT.isBaseline()); assertFalse(TextAnchor.HALF_ASCENT_RIGHT.isBottom()); assertFalse(TextAnchor.HALF_ASCENT_RIGHT.isHorizontalLeft()); assertFalse(TextAnchor.HALF_ASCENT_RIGHT.isHorizontalCenter()); assertTrue(TextAnchor.HALF_ASCENT_RIGHT.isHorizontalRight()); } @Test public void checkCENTER_LEFT() { assertFalse(TextAnchor.CENTER_LEFT.isTop()); assertTrue(TextAnchor.CENTER_LEFT.isHalfHeight()); assertFalse(TextAnchor.CENTER_LEFT.isHalfAscent()); assertFalse(TextAnchor.CENTER_LEFT.isBaseline()); assertFalse(TextAnchor.CENTER_LEFT.isBottom()); assertTrue(TextAnchor.CENTER_LEFT.isHorizontalLeft()); assertFalse(TextAnchor.CENTER_LEFT.isHorizontalCenter()); assertFalse(TextAnchor.CENTER_LEFT.isHorizontalRight()); } @Test public void checkCENTER() { assertFalse(TextAnchor.CENTER.isTop()); assertTrue(TextAnchor.CENTER.isHalfHeight()); assertFalse(TextAnchor.CENTER.isHalfAscent()); assertFalse(TextAnchor.CENTER.isBaseline()); assertFalse(TextAnchor.CENTER.isBottom()); assertFalse(TextAnchor.CENTER.isHorizontalLeft()); assertTrue(TextAnchor.CENTER.isHorizontalCenter()); assertFalse(TextAnchor.CENTER.isHorizontalRight()); } @Test public void checkCENTER_RIGHT() { assertFalse(TextAnchor.CENTER_RIGHT.isTop()); assertTrue(TextAnchor.CENTER_RIGHT.isHalfHeight()); assertFalse(TextAnchor.CENTER_RIGHT.isHalfAscent()); assertFalse(TextAnchor.CENTER_RIGHT.isBaseline()); assertFalse(TextAnchor.CENTER_RIGHT.isBottom()); assertFalse(TextAnchor.CENTER_RIGHT.isHorizontalLeft()); assertFalse(TextAnchor.CENTER_RIGHT.isHorizontalCenter()); assertTrue(TextAnchor.CENTER_RIGHT.isHorizontalRight()); } @Test public void checkBASELINE_LEFT() { assertFalse(TextAnchor.BASELINE_LEFT.isTop()); assertFalse(TextAnchor.BASELINE_LEFT.isHalfHeight()); assertFalse(TextAnchor.BASELINE_LEFT.isHalfAscent()); assertTrue(TextAnchor.BASELINE_LEFT.isBaseline()); assertFalse(TextAnchor.BASELINE_LEFT.isBottom()); assertTrue(TextAnchor.BASELINE_LEFT.isHorizontalLeft()); assertFalse(TextAnchor.BASELINE_LEFT.isHorizontalCenter()); assertFalse(TextAnchor.BASELINE_LEFT.isHorizontalRight()); } @Test public void checkBASELINE_CENTER() { assertFalse(TextAnchor.BASELINE_CENTER.isTop()); assertFalse(TextAnchor.BASELINE_CENTER.isHalfHeight()); assertFalse(TextAnchor.BASELINE_CENTER.isHalfAscent()); assertTrue(TextAnchor.BASELINE_CENTER.isBaseline()); assertFalse(TextAnchor.BASELINE_CENTER.isBottom()); assertFalse(TextAnchor.BASELINE_CENTER.isHorizontalLeft()); assertTrue(TextAnchor.BASELINE_CENTER.isHorizontalCenter()); assertFalse(TextAnchor.BASELINE_CENTER.isHorizontalRight()); } @Test public void checkBASELINE_RIGHT() { assertFalse(TextAnchor.BASELINE_RIGHT.isTop()); assertFalse(TextAnchor.BASELINE_RIGHT.isHalfHeight()); assertFalse(TextAnchor.BASELINE_RIGHT.isHalfAscent()); assertTrue(TextAnchor.BASELINE_RIGHT.isBaseline()); assertFalse(TextAnchor.BASELINE_RIGHT.isBottom()); assertFalse(TextAnchor.BASELINE_RIGHT.isHorizontalLeft()); assertFalse(TextAnchor.BASELINE_RIGHT.isHorizontalCenter()); assertTrue(TextAnchor.BASELINE_RIGHT.isHorizontalRight()); } @Test public void checkBOTTOM_LEFT() { assertFalse(TextAnchor.BOTTOM_LEFT.isTop()); assertFalse(TextAnchor.BOTTOM_LEFT.isHalfHeight()); assertFalse(TextAnchor.BOTTOM_LEFT.isHalfAscent()); assertFalse(TextAnchor.BOTTOM_LEFT.isBaseline()); assertTrue(TextAnchor.BOTTOM_LEFT.isBottom()); assertTrue(TextAnchor.BOTTOM_LEFT.isHorizontalLeft()); assertFalse(TextAnchor.BOTTOM_LEFT.isHorizontalCenter()); assertFalse(TextAnchor.BOTTOM_LEFT.isHorizontalRight()); } @Test public void checkBOTTOM_CENTER() { assertFalse(TextAnchor.BOTTOM_CENTER.isTop()); assertFalse(TextAnchor.BOTTOM_CENTER.isHalfHeight()); assertFalse(TextAnchor.BOTTOM_CENTER.isHalfAscent()); assertFalse(TextAnchor.BOTTOM_CENTER.isBaseline()); assertTrue(TextAnchor.BOTTOM_CENTER.isBottom()); assertFalse(TextAnchor.BOTTOM_CENTER.isHorizontalLeft()); assertTrue(TextAnchor.BOTTOM_CENTER.isHorizontalCenter()); assertFalse(TextAnchor.BOTTOM_CENTER.isHorizontalRight()); } @Test public void checkBOTTOM_RIGHT() { assertFalse(TextAnchor.BOTTOM_RIGHT.isTop()); assertFalse(TextAnchor.BOTTOM_RIGHT.isHalfHeight()); assertFalse(TextAnchor.BOTTOM_RIGHT.isHalfAscent()); assertFalse(TextAnchor.BOTTOM_RIGHT.isBaseline()); assertTrue(TextAnchor.BOTTOM_RIGHT.isBottom()); assertFalse(TextAnchor.BOTTOM_RIGHT.isHorizontalLeft()); assertFalse(TextAnchor.BOTTOM_RIGHT.isHorizontalCenter()); assertTrue(TextAnchor.BOTTOM_RIGHT.isHorizontalRight()); } }
10,141
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
RelativeDateFormatTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/util/RelativeDateFormatTest.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.] * * ---------------------------- * RelativeDateFormatTests.java * ---------------------------- * (C) Copyright 2006-2011, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 23-Nov-2006 : Version 1 (DG); * 15-Feb-2008 : Added tests for negative dates (DG); * 01-Sep-2008 : Added a test for hours and minutes with leading zeroes (DG); * 06-Oct-2011 : Fixed bug 3418287 (DG); * */ package org.jfree.chart.util; import org.junit.After; import org.junit.Before; import org.junit.Test; import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.Date; import java.util.Locale; 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 RelativeDateFormat} class. */ public class RelativeDateFormatTest { private Locale savedLocale; /** * Set a known locale for the tests. */ @Before public void setUp() throws Exception { this.savedLocale = Locale.getDefault(); Locale.setDefault(Locale.UK); } /** * Restore the default locale after the tests complete. */ @After public void tearDown() throws Exception { Locale.setDefault(this.savedLocale); } /** * Some checks for the formatting. */ @Test public void testFormat() { RelativeDateFormat rdf = new RelativeDateFormat(); String s = rdf.format(new Date(2 * 60L * 60L * 1000L + 122500L)); assertEquals("2h2m2.500s", s); } /** * Test that we can configure the RelativeDateFormat to show * hh:mm:ss. */ @Test public void test2033092() { RelativeDateFormat rdf = new RelativeDateFormat(); rdf.setShowZeroDays(false); rdf.setShowZeroHours(false); rdf.setMinuteSuffix(":"); rdf.setHourSuffix(":"); rdf.setSecondSuffix(""); DecimalFormat hoursFormatter = new DecimalFormat(); hoursFormatter.setMaximumFractionDigits(0); hoursFormatter.setMaximumIntegerDigits(2); hoursFormatter.setMinimumIntegerDigits(2); rdf.setHourFormatter(hoursFormatter); DecimalFormat minsFormatter = new DecimalFormat(); minsFormatter.setMaximumFractionDigits(0); minsFormatter.setMaximumIntegerDigits(2); minsFormatter.setMinimumIntegerDigits(2); rdf.setMinuteFormatter(minsFormatter); DecimalFormat secondsFormatter = new DecimalFormat(); secondsFormatter.setMaximumFractionDigits(0); secondsFormatter.setMaximumIntegerDigits(2); secondsFormatter.setMinimumIntegerDigits(2); rdf.setSecondFormatter(secondsFormatter); String s = rdf.format(new Date(2 * 60L * 60L * 1000L + 122500L)); assertEquals("02:02:02", s); } /** * Check that the equals() method can distinguish all fields. */ @Test public void testEquals() { RelativeDateFormat df1 = new RelativeDateFormat(); RelativeDateFormat df2 = new RelativeDateFormat(); assertEquals(df1, df2); df1.setBaseMillis(123L); assertFalse(df1.equals(df2)); df2.setBaseMillis(123L); assertEquals(df1, df2); df1.setDayFormatter(new DecimalFormat("0%")); assertFalse(df1.equals(df2)); df2.setDayFormatter(new DecimalFormat("0%")); assertEquals(df1, df2); df1.setDaySuffix("D"); assertFalse(df1.equals(df2)); df2.setDaySuffix("D"); assertEquals(df1, df2); df1.setHourFormatter(new DecimalFormat("0%")); assertFalse(df1.equals(df2)); df2.setHourFormatter(new DecimalFormat("0%")); assertEquals(df1, df2); df1.setHourSuffix("H"); assertFalse(df1.equals(df2)); df2.setHourSuffix("H"); assertEquals(df1, df2); df1.setMinuteFormatter(new DecimalFormat("0%")); assertFalse(df1.equals(df2)); df2.setMinuteFormatter(new DecimalFormat("0%")); assertEquals(df1, df2); df1.setMinuteSuffix("M"); assertFalse(df1.equals(df2)); df2.setMinuteSuffix("M"); assertEquals(df1, df2); df1.setSecondSuffix("S"); assertFalse(df1.equals(df2)); df2.setSecondSuffix("S"); assertEquals(df1, df2); df1.setShowZeroDays(!df1.getShowZeroDays()); assertFalse(df1.equals(df2)); df2.setShowZeroDays(!df2.getShowZeroDays()); assertEquals(df1, df2); df1.setSecondFormatter(new DecimalFormat("0.0")); assertFalse(df1.equals(df2)); df2.setSecondFormatter(new DecimalFormat("0.0")); assertEquals(df1, df2); } /** * Two objects that are equal are required to return the same hashCode. */ @Test public void testHashCode() { RelativeDateFormat df1 = new RelativeDateFormat(123L); RelativeDateFormat df2 = new RelativeDateFormat(123L); assertEquals(df1, df2); int h1 = df1.hashCode(); int h2 = df2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { NumberFormat nf = new DecimalFormat("0"); RelativeDateFormat df1 = new RelativeDateFormat(); df1.setSecondFormatter(nf); RelativeDateFormat df2 = null; df2 = (RelativeDateFormat) df1.clone(); assertNotSame(df1, df2); assertSame(df1.getClass(), df2.getClass()); assertEquals(df1, df2); // is the clone independent nf.setMinimumFractionDigits(2); assertFalse(df1.equals(df2)); } /** * Some tests for negative dates. */ @Test public void testNegative() { NumberFormat nf = new DecimalFormat("0"); RelativeDateFormat df1 = new RelativeDateFormat(); df1.setSecondFormatter(nf); assertEquals("-0h0m1s", df1.format(new Date(-1000L))); } }
7,380
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
HMSNumberFormatTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/util/HMSNumberFormatTest.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.] * * ------------------------ * HMSNumberFormatTest.java * ------------------------ * (C) Copyright 2013, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 21-Nov-2013 : Version 1 (DG); * */ package org.jfree.chart.util; import static org.junit.Assert.assertEquals; import org.junit.Test; /** * Tests for the {@link HMSNumberFormat} class. */ public class HMSNumberFormatTest { @Test public void testGeneral() { HMSNumberFormat formatter = new HMSNumberFormat(); assertEquals("00:00:00", formatter.format(0)); assertEquals("00:00:59", formatter.format(59)); assertEquals("00:01:01", formatter.format(61)); assertEquals("00:59:59", formatter.format(3599)); assertEquals("01:00:00", formatter.format(3600)); assertEquals("01:00:01", formatter.format(3601)); } }
2,180
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
LineUtilitiesTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/util/LineUtilitiesTest.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.] * * ----------------------- * LineUtilitiesTests.java * ----------------------- * (C) Copyright 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 05-Nov-2008 : Version 1 (DG); * */ package org.jfree.chart.util; import org.junit.Test; import java.awt.geom.Line2D; import java.awt.geom.Rectangle2D; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; /** * Tests for the {@link LineUtilities} class. */ public class LineUtilitiesTest { private boolean lineEquals(Line2D line, double x1, double y1, double x2, double y2) { boolean result = true; double epsilon = 0.0000000001; if (Math.abs(line.getX1() - x1) > epsilon) { result = false; } if (Math.abs(line.getY1() - y1) > epsilon) { result = false; } if (Math.abs(line.getX2() - x2) > epsilon) { result = false; } if (Math.abs(line.getY2() - y2) > epsilon) { result = false; } return result; } @Test public void testClipLine() { Rectangle2D rect = new Rectangle2D.Double(1.0, 1.0, 1.0, 1.0); Line2D line = new Line2D.Double(); assertFalse(LineUtilities.clipLine(line, rect)); assertTrue(lineEquals(line, 0.0, 0.0, 0.0, 0.0)); line.setLine(0.5, 0.5, 0.6, 0.6); assertFalse(LineUtilities.clipLine(line, rect)); assertTrue(lineEquals(line, 0.5, 0.5, 0.6, 0.6)); line.setLine(0.5, 0.5, 1.6, 0.6); assertFalse(LineUtilities.clipLine(line, rect)); assertTrue(lineEquals(line, 0.5, 0.5, 1.6, 0.6)); line.setLine(0.5, 0.5, 2.6, 0.6); assertFalse(LineUtilities.clipLine(line, rect)); assertTrue(lineEquals(line, 0.5, 0.5, 2.6, 0.6)); line.setLine(0.5, 0.5, 0.6, 1.6); assertFalse(LineUtilities.clipLine(line, rect)); assertTrue(lineEquals(line, 0.5, 0.5, 0.6, 1.6)); line.setLine(0.5, 0.5, 1.6, 1.6); assertTrue(LineUtilities.clipLine(line, rect)); assertTrue(lineEquals(line, 1.0, 1.0, 1.6, 1.6)); line.setLine(0.5, 0.5, 2.6, 1.6); assertTrue(LineUtilities.clipLine(line, rect)); assertTrue(lineEquals(line, 1.4545454545454546, 1.0, 2.0, 1.2857142857142858)); line.setLine(0.5, 0.5, 0.5, 2.6); assertFalse(LineUtilities.clipLine(line, rect)); assertTrue(lineEquals(line, 0.5, 0.5, 0.5, 2.6)); line.setLine(0.5, 0.5, 1.5, 2.6); assertTrue(LineUtilities.clipLine(line, rect)); assertTrue(lineEquals(line, 1.0, 1.55, 1.2142857142857142, 2.0)); line.setLine(0.5, 0.5, 2.5, 2.6); assertTrue(LineUtilities.clipLine(line, rect)); assertTrue(lineEquals(line, 1.0, 1.025, 1.9285714285714284, 2.0)); line.setLine(0.5, 0.5, 1.5, 1.5); assertTrue(LineUtilities.clipLine(line, rect)); assertTrue(lineEquals(line, 1.0, 1.0, 1.5, 1.5)); line.setLine(2.5, 1.0, 1.5, 1.5); assertTrue(LineUtilities.clipLine(line, rect)); assertTrue(lineEquals(line, 2.0, 1.25, 1.5, 1.5)); line.setLine(1.5, 1.5, 2.5, 1.0); assertTrue(LineUtilities.clipLine(line, rect)); assertTrue(lineEquals(line, 1.5, 1.5, 2.0, 1.25)); } }
4,573
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
LogFormatTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/util/LogFormatTest.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.] * * ------------------- * LogFormatTests.java * ------------------- * (C) Copyright 2008, 2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 08-Feb-2008 : Version 1 (DG); * 14-Jan-2009 : Updated testEquals() for new field (DG); * */ package org.jfree.chart.util; 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; /** * Tests for the {@link LogFormat} class. */ public class LogFormatTest { /** * Check that the equals() method distinguishes all fields. */ @Test public void testEquals() { LogFormat f1 = new LogFormat(10.0, "10", true); LogFormat f2 = new LogFormat(10.0, "10", true); assertEquals(f1, f2); f1 = new LogFormat(11.0, "10", true); assertFalse(f1.equals(f2)); f2 = new LogFormat(11.0, "10", true); assertEquals(f1, f2); f1 = new LogFormat(11.0, "11", true); assertFalse(f1.equals(f2)); f2 = new LogFormat(11.0, "11", true); assertEquals(f1, f2); f1 = new LogFormat(11.0, "11", false); assertFalse(f1.equals(f2)); f2 = new LogFormat(11.0, "11", false); assertEquals(f1, f2); f1.setExponentFormat(new DecimalFormat("0.000")); assertFalse(f1.equals(f2)); f2.setExponentFormat(new DecimalFormat("0.000")); assertEquals(f1, f2); } /** * Two objects that are equal are required to return the same hashCode. */ @Test public void testHashcode() { LogFormat f1 = new LogFormat(10.0, "10", true); LogFormat f2 = new LogFormat(10.0, "10", true); assertEquals(f1, f2); int h1 = f1.hashCode(); int h2 = f2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { LogFormat f1 = new LogFormat(10.0, "10", true); LogFormat f2 = (LogFormat) f1.clone(); assertNotSame(f1, f2); assertSame(f1.getClass(), f2.getClass()); assertEquals(f1, f2); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { LogFormat f1 = new LogFormat(10.0, "10", true); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(f1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); LogFormat f2 = (LogFormat) in.readObject(); in.close(); assertEquals(f1, f2); } }
4,488
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
TextAnnotationTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/annotations/TextAnnotationTest.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.] * * ------------------------ * TextAnnotationTests.java * ------------------------ * (C) Copyright 2003-2012, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): Martin Hoeller; * * Changes * ------- * 19-Aug-2003 : Version 1 (DG); * 07-Jan-2005 : Added testHashCode() method (DG); * 28-Oct-2011 : Added testSetRotationAnchor() method for bug #3428870 (MH); * 17-Jun-2012 : Removed JCommon dependencies (DG); * */ package org.jfree.chart.annotations; import org.jfree.chart.ui.TextAnchor; import org.junit.Test; import java.awt.Color; import java.awt.Font; import java.awt.GradientPaint; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.fail; /** * Tests for the {@link TextAnnotation} class. */ public class TextAnnotationTest { /** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { TextAnnotation a1 = new CategoryTextAnnotation("Test", "Category", 1.0); TextAnnotation a2 = new CategoryTextAnnotation("Test", "Category", 1.0); assertEquals(a1, a2); // text a1.setText("Text"); assertFalse(a1.equals(a2)); a2.setText("Text"); assertEquals(a1, a2); // font a1.setFont(new Font("Serif", Font.BOLD, 18)); assertFalse(a1.equals(a2)); a2.setFont(new Font("Serif", Font.BOLD, 18)); assertEquals(a1, a2); // paint a1.setPaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.pink)); assertFalse(a1.equals(a2)); a2.setPaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.pink)); assertEquals(a1, a2); // textAnchor a1.setTextAnchor(TextAnchor.BOTTOM_LEFT); assertFalse(a1.equals(a2)); a2.setTextAnchor(TextAnchor.BOTTOM_LEFT); assertEquals(a1, a2); // rotationAnchor a1.setRotationAnchor(TextAnchor.BOTTOM_LEFT); assertFalse(a1.equals(a2)); a2.setRotationAnchor(TextAnchor.BOTTOM_LEFT); assertEquals(a1, a2); // rotationAngle a1.setRotationAngle(Math.PI); assertFalse(a1.equals(a2)); a2.setRotationAngle(Math.PI); assertEquals(a1, a2); } /** * Two objects that are equal are required to return the same hashCode. */ @Test public void testHashCode() { TextAnnotation a1 = new CategoryTextAnnotation("Test", "Category", 1.0); TextAnnotation a2 = new CategoryTextAnnotation("Test", "Category", 1.0); assertEquals(a1, a2); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Test null-argument (Bug #3428870). */ @Test public void testSetRotationAnchor() { TextAnnotation a = new CategoryTextAnnotation("Test", "Category", 1.0); try { a.setRotationAnchor(null); fail("Should have thrown Exception."); } catch (IllegalArgumentException e) { assertEquals("Null 'anchor' argument.", e.getMessage()); } } }
4,504
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
package-info.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/annotations/package-info.java
/** * Tests for the classes in the <code>org.jfree.chart.annotations</code> package. */ package org.jfree.chart.annotations;
127
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
XYTextAnnotationTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/annotations/XYTextAnnotationTest.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.] * * -------------------------- * XYTextAnnotationTests.java * -------------------------- * (C) Copyright 2003-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 19-Aug-2003 : Version 1 (DG); * 07-Jan-2005 : Added hashCode() test (DG); * 26-Jan-2006 : Extended equals() test (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * 12-Feb-2009 : Updated testEquals() (DG); * */ package org.jfree.chart.annotations; import org.jfree.chart.ui.TextAnchor; import org.jfree.chart.util.PublicCloneable; import org.junit.Test; import java.awt.BasicStroke; 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; import static org.junit.Assert.assertTrue; /** * Tests for the {@link XYTextAnnotation} class. */ public class XYTextAnnotationTest { /** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { XYTextAnnotation a1 = new XYTextAnnotation("Text", 10.0, 20.0); XYTextAnnotation a2 = new XYTextAnnotation("Text", 10.0, 20.0); assertEquals(a1, a2); // text a1 = new XYTextAnnotation("ABC", 10.0, 20.0); assertFalse(a1.equals(a2)); a2 = new XYTextAnnotation("ABC", 10.0, 20.0); assertEquals(a1, a2); // x a1 = new XYTextAnnotation("ABC", 11.0, 20.0); assertFalse(a1.equals(a2)); a2 = new XYTextAnnotation("ABC", 11.0, 20.0); assertEquals(a1, a2); // y a1 = new XYTextAnnotation("ABC", 11.0, 22.0); assertFalse(a1.equals(a2)); a2 = new XYTextAnnotation("ABC", 11.0, 22.0); assertEquals(a1, a2); // font a1.setFont(new Font("Serif", Font.PLAIN, 23)); assertFalse(a1.equals(a2)); a2.setFont(new Font("Serif", Font.PLAIN, 23)); assertEquals(a1, a2); // paint GradientPaint gp1 = new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.yellow); GradientPaint gp2 = new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.yellow); a1.setPaint(gp1); assertFalse(a1.equals(a2)); a2.setPaint(gp2); assertEquals(a1, a2); // rotation anchor a1.setRotationAnchor(TextAnchor.BASELINE_RIGHT); assertFalse(a1.equals(a2)); a2.setRotationAnchor(TextAnchor.BASELINE_RIGHT); assertEquals(a1, a2); // rotation angle a1.setRotationAngle(12.3); assertFalse(a1.equals(a2)); a2.setRotationAngle(12.3); assertEquals(a1, a2); // text anchor a1.setTextAnchor(TextAnchor.BASELINE_RIGHT); assertFalse(a1.equals(a2)); a2.setTextAnchor(TextAnchor.BASELINE_RIGHT); assertEquals(a1, a2); a1.setBackgroundPaint(gp1); assertFalse(a1.equals(a2)); a2.setBackgroundPaint(gp1); assertEquals(a1, a2); a1.setOutlinePaint(gp1); assertFalse(a1.equals(a2)); a2.setOutlinePaint(gp1); assertEquals(a1, a2); a1.setOutlineStroke(new BasicStroke(1.2f)); assertFalse(a1.equals(a2)); a2.setOutlineStroke(new BasicStroke(1.2f)); assertEquals(a1, a2); a1.setOutlineVisible(!a1.isOutlineVisible()); assertFalse(a1.equals(a2)); a2.setOutlineVisible(a1.isOutlineVisible()); assertEquals(a1, a2); } /** * Two objects that are equal are required to return the same hashCode. */ @Test public void testHashCode() { XYTextAnnotation a1 = new XYTextAnnotation("Text", 10.0, 20.0); XYTextAnnotation a2 = new XYTextAnnotation("Text", 10.0, 20.0); assertEquals(a1, a2); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { XYTextAnnotation a1 = new XYTextAnnotation("Text", 10.0, 20.0); XYTextAnnotation a2 = (XYTextAnnotation) a1.clone(); assertNotSame(a1, a2); assertSame(a1.getClass(), a2.getClass()); assertEquals(a1, a2); } /** * Checks that this class implements PublicCloneable. */ @Test public void testPublicCloneable() { XYTextAnnotation a1 = new XYTextAnnotation("Text", 10.0, 20.0); assertTrue(a1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { XYTextAnnotation a1 = new XYTextAnnotation("Text", 10.0, 20.0); a1.setOutlinePaint(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(a1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); XYTextAnnotation a2 = (XYTextAnnotation) in.readObject(); in.close(); assertEquals(a1, a2); } }
6,970
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
CategoryPointerAnnotationTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/annotations/CategoryPointerAnnotationTest.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.] * * ----------------------------------- * CategoryPointerAnnotationTests.java * ----------------------------------- * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 02-Oct-2006 : Version 1 (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.annotations; import org.jfree.chart.util.PublicCloneable; import org.junit.Test; import java.awt.BasicStroke; import java.awt.Color; 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 CategoryPointerAnnotation} class. */ public class CategoryPointerAnnotationTest { /** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { CategoryPointerAnnotation a1 = new CategoryPointerAnnotation("Label", "Key 1", 20.0, Math.PI); CategoryPointerAnnotation a2 = new CategoryPointerAnnotation("Label", "Key 1", 20.0, Math.PI); assertEquals(a1, a2); a1 = new CategoryPointerAnnotation("Label2", "Key 1", 20.0, Math.PI); assertFalse(a1.equals(a2)); a2 = new CategoryPointerAnnotation("Label2", "Key 1", 20.0, Math.PI); assertEquals(a1, a2); a1.setCategory("Key 2"); assertFalse(a1.equals(a2)); a2.setCategory("Key 2"); assertEquals(a1, a2); a1.setValue(22.0); assertFalse(a1.equals(a2)); a2.setValue(22.0); assertEquals(a1, a2); //private double angle; a1.setAngle(Math.PI / 4.0); assertFalse(a1.equals(a2)); a2.setAngle(Math.PI / 4.0); assertEquals(a1, a2); //private double tipRadius; a1.setTipRadius(20.0); assertFalse(a1.equals(a2)); a2.setTipRadius(20.0); assertEquals(a1, a2); //private double baseRadius; a1.setBaseRadius(5.0); assertFalse(a1.equals(a2)); a2.setBaseRadius(5.0); assertEquals(a1, a2); //private double arrowLength; a1.setArrowLength(33.0); assertFalse(a1.equals(a2)); a2.setArrowLength(33.0); assertEquals(a1, a2); //private double arrowWidth; a1.setArrowWidth(9.0); assertFalse(a1.equals(a2)); a2.setArrowWidth(9.0); assertEquals(a1, a2); //private Stroke arrowStroke; Stroke stroke = new BasicStroke(1.5f); a1.setArrowStroke(stroke); assertFalse(a1.equals(a2)); a2.setArrowStroke(stroke); assertEquals(a1, a2); //private Paint arrowPaint; a1.setArrowPaint(Color.BLUE); assertFalse(a1.equals(a2)); a2.setArrowPaint(Color.BLUE); assertEquals(a1, a2); //private double labelOffset; a1.setLabelOffset(10.0); assertFalse(a1.equals(a2)); a2.setLabelOffset(10.0); assertEquals(a1, a2); } /** * Two objects that are equal are required to return the same hashCode. */ @Test public void testHashCode() { CategoryPointerAnnotation a1 = new CategoryPointerAnnotation("Label", "A", 20.0, Math.PI); CategoryPointerAnnotation a2 = new CategoryPointerAnnotation("Label", "A", 20.0, Math.PI); assertEquals(a1, a2); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { CategoryPointerAnnotation a1 = new CategoryPointerAnnotation("Label", "A", 20.0, Math.PI); CategoryPointerAnnotation a2 = (CategoryPointerAnnotation) a1.clone(); assertNotSame(a1, a2); assertSame(a1.getClass(), a2.getClass()); assertEquals(a1, a2); } /** * Checks that this class implements PublicCloneable. */ @Test public void testPublicCloneable() { CategoryPointerAnnotation a1 = new CategoryPointerAnnotation("Label", "A", 20.0, Math.PI); assertTrue(a1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { CategoryPointerAnnotation a1 = new CategoryPointerAnnotation("Label", "A", 20.0, Math.PI); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); CategoryPointerAnnotation a2 = (CategoryPointerAnnotation) in.readObject(); in.close(); assertEquals(a1, a2); } }
6,636
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
XYLineAnnotationTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/annotations/XYLineAnnotationTest.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.] * * -------------------------- * XYLineAnnotationTests.java * -------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 19-Aug-2003 : Version 1 (DG); * 07-Jan-2005 : Added hashCode() test (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.annotations; import org.jfree.chart.util.PublicCloneable; 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 XYLineAnnotation} class. */ public class XYLineAnnotationTest { /** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { Stroke stroke = new BasicStroke(2.0f); XYLineAnnotation a1 = new XYLineAnnotation(10.0, 20.0, 100.0, 200.0, stroke, Color.BLUE); XYLineAnnotation a2 = new XYLineAnnotation(10.0, 20.0, 100.0, 200.0, stroke, Color.BLUE); assertEquals(a1, a2); assertEquals(a2, a1); a1 = new XYLineAnnotation(11.0, 20.0, 100.0, 200.0, stroke, Color.BLUE); assertFalse(a1.equals(a2)); a2 = new XYLineAnnotation(11.0, 20.0, 100.0, 200.0, stroke, Color.BLUE); assertEquals(a1, a2); a1 = new XYLineAnnotation(11.0, 21.0, 100.0, 200.0, stroke, Color.BLUE); assertFalse(a1.equals(a2)); a2 = new XYLineAnnotation(11.0, 21.0, 100.0, 200.0, stroke, Color.BLUE); assertEquals(a1, a2); a1 = new XYLineAnnotation(11.0, 21.0, 101.0, 200.0, stroke, Color.BLUE); assertFalse(a1.equals(a2)); a2 = new XYLineAnnotation(11.0, 21.0, 101.0, 200.0, stroke, Color.BLUE); assertEquals(a1, a2); a1 = new XYLineAnnotation(11.0, 21.0, 101.0, 201.0, stroke, Color.BLUE); assertFalse(a1.equals(a2)); a2 = new XYLineAnnotation(11.0, 21.0, 101.0, 201.0, stroke, Color.BLUE); assertEquals(a1, a2); Stroke stroke2 = new BasicStroke(0.99f); a1 = new XYLineAnnotation(11.0, 21.0, 101.0, 200.0, stroke2, Color.BLUE); assertFalse(a1.equals(a2)); a2 = new XYLineAnnotation(11.0, 21.0, 101.0, 200.0, stroke2, Color.BLUE); assertEquals(a1, a2); GradientPaint g1 = new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.WHITE); GradientPaint g2 = new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.WHITE); a1 = new XYLineAnnotation(11.0, 21.0, 101.0, 200.0, stroke2, g1); assertFalse(a1.equals(a2)); a2 = new XYLineAnnotation(11.0, 21.0, 101.0, 200.0, stroke2, g2); assertEquals(a1, a2); } /** * Two objects that are equal are required to return the same hashCode. */ @Test public void testHashCode() { Stroke stroke = new BasicStroke(2.0f); XYLineAnnotation a1 = new XYLineAnnotation(10.0, 20.0, 100.0, 200.0, stroke, Color.BLUE); XYLineAnnotation a2 = new XYLineAnnotation(10.0, 20.0, 100.0, 200.0, stroke, Color.BLUE); assertEquals(a1, a2); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { Stroke stroke = new BasicStroke(2.0f); XYLineAnnotation a1 = new XYLineAnnotation(10.0, 20.0, 100.0, 200.0, stroke, Color.BLUE); XYLineAnnotation a2 = (XYLineAnnotation) a1.clone(); assertNotSame(a1, a2); assertSame(a1.getClass(), a2.getClass()); assertEquals(a1, a2); } /** * Checks that this class implements PublicCloneable. */ @Test public void testPublicCloneable() { Stroke stroke = new BasicStroke(2.0f); XYLineAnnotation a1 = new XYLineAnnotation(10.0, 20.0, 100.0, 200.0, stroke, Color.BLUE); assertTrue(a1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { Stroke stroke = new BasicStroke(2.0f); XYLineAnnotation a1 = new XYLineAnnotation(10.0, 20.0, 100.0, 200.0, stroke, Color.BLUE); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); XYLineAnnotation a2 = (XYLineAnnotation) in.readObject(); in.close(); assertEquals(a1, a2); } }
6,621
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
CategoryLineAnnotationTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/annotations/CategoryLineAnnotationTest.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.] * * -------------------------------- * CategoryLineAnnotationTests.java * -------------------------------- * (C) Copyright 2005-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 29-Jul-2005 : Version 1 (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.annotations; import org.jfree.chart.util.PublicCloneable; 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.assertSame; import static org.junit.Assert.assertTrue; /** * Tests for the {@link CategoryLineAnnotationTest} class. */ public class CategoryLineAnnotationTest { /** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { BasicStroke s1 = new BasicStroke(1.0f); BasicStroke s2 = new BasicStroke(2.0f); CategoryLineAnnotation a1 = new CategoryLineAnnotation("Category 1", 1.0, "Category 2", 2.0, Color.RED, s1); CategoryLineAnnotation a2 = new CategoryLineAnnotation("Category 1", 1.0, "Category 2", 2.0, Color.RED, s1); assertEquals(a1, a2); assertEquals(a2, a1); // category 1 a1.setCategory1("Category A"); assertFalse(a1.equals(a2)); a2.setCategory1("Category A"); assertEquals(a1, a2); // value 1 a1.setValue1(0.15); assertFalse(a1.equals(a2)); a2.setValue1(0.15); assertEquals(a1, a2); // category 2 a1.setCategory2("Category B"); assertFalse(a1.equals(a2)); a2.setCategory2("Category B"); assertEquals(a1, a2); // value 2 a1.setValue2(0.25); assertFalse(a1.equals(a2)); a2.setValue2(0.25); assertEquals(a1, a2); // paint a1.setPaint(Color.yellow); assertFalse(a1.equals(a2)); a2.setPaint(Color.yellow); assertEquals(a1, a2); // stroke a1.setStroke(s2); assertFalse(a1.equals(a2)); a2.setStroke(s2); assertEquals(a1, a2); } /** * Two objects that are equal are required to return the same hashCode. */ @Test public void testHashcode() { CategoryLineAnnotation a1 = new CategoryLineAnnotation("Category 1", 1.0, "Category 2", 2.0, Color.RED, new BasicStroke(1.0f)); CategoryLineAnnotation a2 = new CategoryLineAnnotation("Category 1", 1.0, "Category 2", 2.0, Color.RED, new BasicStroke(1.0f)); assertEquals(a1, a2); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { CategoryLineAnnotation a1 = new CategoryLineAnnotation("Category 1", 1.0, "Category 2", 2.0, Color.RED, new BasicStroke(1.0f)); CategoryLineAnnotation a2 = (CategoryLineAnnotation) a1.clone(); assertNotSame(a1, a2); assertSame(a1.getClass(), a2.getClass()); assertEquals(a1, a2); } /** * Checks that this class implements PublicCloneable. */ @Test public void testPublicCloneable() { CategoryLineAnnotation a1 = new CategoryLineAnnotation( "Category 1", 1.0, "Category 2", 2.0, Color.RED, new BasicStroke(1.0f)); assertTrue(a1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { CategoryLineAnnotation a1 = new CategoryLineAnnotation("Category 1", 1.0, "Category 2", 2.0, Color.RED, new BasicStroke(1.0f)); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); CategoryLineAnnotation a2 = (CategoryLineAnnotation) in.readObject(); in.close(); assertEquals(a1, a2); } }
5,966
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
XYBoxAnnotationTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/annotations/XYBoxAnnotationTest.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.] * * ------------------------- * XYBoxAnnotationTests.java * ------------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 19-Jan-2005 : Version 1 (DG); * 26-Feb-2008 : Added testDrawWithNullInfo() method (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.annotations; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; import org.jfree.chart.util.PublicCloneable; import org.jfree.data.xy.DefaultTableXYDataset; import org.jfree.data.xy.XYSeries; 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; /** * Some tests for the {@link XYBoxAnnotation} class. */ public class XYBoxAnnotationTest { /** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { XYBoxAnnotation a1 = new XYBoxAnnotation(1.0, 2.0, 3.0, 4.0, new BasicStroke(1.2f), Color.RED, Color.BLUE); XYBoxAnnotation a2 = new XYBoxAnnotation(1.0, 2.0, 3.0, 4.0, new BasicStroke(1.2f), Color.RED, Color.BLUE); assertEquals(a1, a2); assertEquals(a2, a1); // x0 a1 = new XYBoxAnnotation(2.0, 2.0, 3.0, 4.0, new BasicStroke(1.2f), Color.RED, Color.BLUE); assertFalse(a1.equals(a2)); a2 = new XYBoxAnnotation(2.0, 2.0, 3.0, 4.0, new BasicStroke(1.2f), Color.RED, Color.BLUE); assertEquals(a1, a2); // stroke a1 = new XYBoxAnnotation(1.0, 2.0, 3.0, 4.0, new BasicStroke(2.3f), Color.RED, Color.BLUE); assertFalse(a1.equals(a2)); a2 = new XYBoxAnnotation(1.0, 2.0, 3.0, 4.0, new BasicStroke(2.3f), Color.RED, Color.BLUE); assertEquals(a1, a2); GradientPaint gp1a = new GradientPaint(1.0f, 2.0f, Color.BLUE, 3.0f, 4.0f, Color.RED); GradientPaint gp1b = new GradientPaint(1.0f, 2.0f, Color.BLUE, 3.0f, 4.0f, Color.RED); GradientPaint gp2a = new GradientPaint(5.0f, 6.0f, Color.pink, 7.0f, 8.0f, Color.WHITE); GradientPaint gp2b = new GradientPaint(5.0f, 6.0f, Color.pink, 7.0f, 8.0f, Color.WHITE); // outlinePaint a1 = new XYBoxAnnotation(1.0, 2.0, 3.0, 4.0, new BasicStroke(2.3f), gp1a, Color.BLUE); assertFalse(a1.equals(a2)); a2 = new XYBoxAnnotation(1.0, 2.0, 3.0, 4.0, new BasicStroke(2.3f), gp1b, Color.BLUE); assertEquals(a1, a2); // fillPaint a1 = new XYBoxAnnotation(1.0, 2.0, 3.0, 4.0, new BasicStroke(2.3f), gp1a, gp2a); assertFalse(a1.equals(a2)); a2 = new XYBoxAnnotation(1.0, 2.0, 3.0, 4.0, new BasicStroke(2.3f), gp1b, gp2b); assertEquals(a1, a2); } /** * Two objects that are equal are required to return the same hashCode. */ @Test public void testHashCode() { XYBoxAnnotation a1 = new XYBoxAnnotation(1.0, 2.0, 3.0, 4.0, new BasicStroke(1.2f), Color.RED, Color.BLUE); XYBoxAnnotation a2 = new XYBoxAnnotation(1.0, 2.0, 3.0, 4.0, new BasicStroke(1.2f), Color.RED, Color.BLUE); assertEquals(a1, a2); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { XYBoxAnnotation a1 = new XYBoxAnnotation(1.0, 2.0, 3.0, 4.0, new BasicStroke(1.2f), Color.RED, Color.BLUE); XYBoxAnnotation a2 = (XYBoxAnnotation) a1.clone(); assertNotSame(a1, a2); assertSame(a1.getClass(), a2.getClass()); assertEquals(a1, a2); } /** * Checks that this class implements PublicCloneable. */ @Test public void testPublicCloneable() { XYBoxAnnotation a1 = new XYBoxAnnotation(1.0, 2.0, 3.0, 4.0, new BasicStroke(1.2f), Color.RED, Color.BLUE); assertTrue(a1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { XYBoxAnnotation a1 = new XYBoxAnnotation(1.0, 2.0, 3.0, 4.0, new BasicStroke(1.2f), Color.RED, Color.BLUE); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); XYBoxAnnotation a2 = (XYBoxAnnotation) in.readObject(); in.close(); assertEquals(a1, a2); } /** * Draws the chart with a <code>null</code> info object to make sure that * no exceptions are thrown. */ @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 XYLineAndShapeRenderer()); plot.addAnnotation(new XYBoxAnnotation(10.0, 12.0, 3.0, 4.0, new BasicStroke(1.2f), Color.RED, Color.BLUE)); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, null); //FIXME we should really assert a value here } }
8,027
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
XYTitleAnnotationTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/annotations/XYTitleAnnotationTest.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.] * * --------------------------- * XYTitleAnnotationTests.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); * 26-Feb-2008 : Added testDrawWithNullInfo() (DG); * */ package org.jfree.chart.annotations; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; import org.jfree.chart.title.TextTitle; 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; /** * Tests for the {@link XYTitleAnnotation} class. */ public class XYTitleAnnotationTest { /** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { TextTitle t = new TextTitle("Title"); XYTitleAnnotation a1 = new XYTitleAnnotation(1.0, 2.0, t); XYTitleAnnotation a2 = new XYTitleAnnotation(1.0, 2.0, t); assertEquals(a1, a2); a1 = new XYTitleAnnotation(1.1, 2.0, t); assertFalse(a1.equals(a2)); a2 = new XYTitleAnnotation(1.1, 2.0, t); assertEquals(a1, a2); a1 = new XYTitleAnnotation(1.1, 2.2, t); assertFalse(a1.equals(a2)); a2 = new XYTitleAnnotation(1.1, 2.2, t); assertEquals(a1, a2); TextTitle t2 = new TextTitle("Title 2"); a1 = new XYTitleAnnotation(1.1, 2.2, t2); assertFalse(a1.equals(a2)); a2 = new XYTitleAnnotation(1.1, 2.2, t2); assertEquals(a1, a2); } /** * Two objects that are equal are required to return the same hashCode. */ @Test public void testHashCode() { TextTitle t = new TextTitle("Title"); XYTitleAnnotation a1 = new XYTitleAnnotation(1.0, 2.0, t); XYTitleAnnotation a2 = new XYTitleAnnotation(1.0, 2.0, t); assertEquals(a1, a2); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { TextTitle t = new TextTitle("Title"); XYTitleAnnotation a1 = new XYTitleAnnotation(1.0, 2.0, t); XYTitleAnnotation a2 = (XYTitleAnnotation) a1.clone(); assertNotSame(a1, a2); assertSame(a1.getClass(), a2.getClass()); assertEquals(a1, a2); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { TextTitle t = new TextTitle("Title"); XYTitleAnnotation a1 = new XYTitleAnnotation(1.0, 2.0, t); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); XYTitleAnnotation a2 = (XYTitleAnnotation) in.readObject(); in.close(); assertEquals(a1, a2); } /** * Draws the chart with a <code>null</code> info object to make sure that * no exceptions are thrown. */ @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 XYLineAndShapeRenderer()); plot.addAnnotation(new XYTitleAnnotation(5.0, 6.0, new TextTitle("Hello World!"))); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, null); //FIXME we should really assert a value here } }
6,173
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
XYShapeAnnotationTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/annotations/XYShapeAnnotationTest.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.] * * --------------------------- * XYShapeAnnotationTests.java * --------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 29-Sep-2004 : Version 1 (DG); * 07-Jan-2005 : Added hashCode() test (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.annotations; import org.jfree.chart.util.PublicCloneable; import org.junit.Test; import java.awt.BasicStroke; import java.awt.Color; 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; import static org.junit.Assert.assertTrue; /** * Some tests for the {@link XYShapeAnnotation} class. */ public class XYShapeAnnotationTest { /** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { XYShapeAnnotation a1 = new XYShapeAnnotation( new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(1.2f), Color.RED, Color.BLUE); XYShapeAnnotation a2 = new XYShapeAnnotation( new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(1.2f), Color.RED, Color.BLUE); assertEquals(a1, a2); assertEquals(a2, a1); // shape a1 = new XYShapeAnnotation( new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), new BasicStroke(1.2f), Color.RED, Color.BLUE); assertFalse(a1.equals(a2)); a2 = new XYShapeAnnotation( new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), new BasicStroke(1.2f), Color.RED, Color.BLUE); assertEquals(a1, a2); // stroke a1 = new XYShapeAnnotation( new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), new BasicStroke(2.3f), Color.RED, Color.BLUE); assertFalse(a1.equals(a2)); a2 = new XYShapeAnnotation( new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), new BasicStroke(2.3f), Color.RED, Color.BLUE); assertEquals(a1, a2); GradientPaint gp1a = new GradientPaint(1.0f, 2.0f, Color.BLUE, 3.0f, 4.0f, Color.RED); GradientPaint gp1b = new GradientPaint(1.0f, 2.0f, Color.BLUE, 3.0f, 4.0f, Color.RED); GradientPaint gp2a = new GradientPaint(5.0f, 6.0f, Color.pink, 7.0f, 8.0f, Color.WHITE); GradientPaint gp2b = new GradientPaint(5.0f, 6.0f, Color.pink, 7.0f, 8.0f, Color.WHITE); // outlinePaint a1 = new XYShapeAnnotation( new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), new BasicStroke(2.3f), gp1a, Color.BLUE); assertFalse(a1.equals(a2)); a2 = new XYShapeAnnotation( new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), new BasicStroke(2.3f), gp1b, Color.BLUE); assertEquals(a1, a2); // fillPaint a1 = new XYShapeAnnotation( new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), new BasicStroke(2.3f), gp1a, gp2a); assertFalse(a1.equals(a2)); a2 = new XYShapeAnnotation( new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), new BasicStroke(2.3f), gp1b, gp2b); assertEquals(a1, a2); } /** * Two objects that are equal are required to return the same hashCode. */ @Test public void testHashCode() { XYShapeAnnotation a1 = new XYShapeAnnotation( new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(1.2f), Color.RED, Color.BLUE); XYShapeAnnotation a2 = new XYShapeAnnotation( new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(1.2f), Color.RED, Color.BLUE); assertEquals(a1, a2); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { XYShapeAnnotation a1 = new XYShapeAnnotation( new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(1.2f), Color.RED, Color.BLUE); XYShapeAnnotation a2 = (XYShapeAnnotation) a1.clone(); assertNotSame(a1, a2); assertSame(a1.getClass(), a2.getClass()); assertEquals(a1, a2); } /** * Checks that this class implements PublicCloneable. */ @Test public void testPublicCloneable() { XYShapeAnnotation a1 = new XYShapeAnnotation( new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(1.2f), Color.RED, Color.BLUE); assertTrue(a1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { XYShapeAnnotation a1 = new XYShapeAnnotation( new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(1.2f), Color.RED, Color.BLUE); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); XYShapeAnnotation a2 = (XYShapeAnnotation) in.readObject(); in.close(); assertEquals(a1, a2); } }
7,257
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
CategoryTextAnnotationTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/annotations/CategoryTextAnnotationTest.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.] * * -------------------------------- * CategoryTextAnnotationTests.java * -------------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 19-Aug-2003 : Version 1 (DG); * 07-Jan-2005 : Added hashCode() test (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.annotations; import org.jfree.chart.axis.CategoryAnchor; 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 CategoryTextAnnotation} class. */ public class CategoryTextAnnotationTest { /** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { CategoryTextAnnotation a1 = new CategoryTextAnnotation("Test", "Category", 1.0); CategoryTextAnnotation a2 = new CategoryTextAnnotation("Test", "Category", 1.0); assertEquals(a1, a2); // category a1.setCategory("Category 2"); assertFalse(a1.equals(a2)); a2.setCategory("Category 2"); assertEquals(a1, a2); // categoryAnchor a1.setCategoryAnchor(CategoryAnchor.START); assertFalse(a1.equals(a2)); a2.setCategoryAnchor(CategoryAnchor.START); assertEquals(a1, a2); // value a1.setValue(0.15); assertFalse(a1.equals(a2)); a2.setValue(0.15); assertEquals(a1, a2); } /** * Two objects that are equal are required to return the same hashCode. */ @Test public void testHashcode() { CategoryTextAnnotation a1 = new CategoryTextAnnotation("Test", "Category", 1.0); CategoryTextAnnotation a2 = new CategoryTextAnnotation("Test", "Category", 1.0); assertEquals(a1, a2); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { CategoryTextAnnotation a1 = new CategoryTextAnnotation( "Test", "Category", 1.0); CategoryTextAnnotation a2 = (CategoryTextAnnotation) a1.clone(); assertNotSame(a1, a2); assertSame(a1.getClass(), a2.getClass()); assertEquals(a1, a2); } /** * Checks that this class implements PublicCloneable. */ @Test public void testPublicCloneable() { CategoryTextAnnotation a1 = new CategoryTextAnnotation( "Test", "Category", 1.0); assertTrue(a1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { CategoryTextAnnotation a1 = new CategoryTextAnnotation("Test", "Category", 1.0); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); CategoryTextAnnotation a2 = (CategoryTextAnnotation) in.readObject(); in.close(); assertEquals(a1, a2); } }
5,157
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
XYImageAnnotationTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/annotations/XYImageAnnotationTest.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.] * * --------------------------- * XYImageAnnotationTests.java * --------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 17-May-2004 : Version 1 (DG); * 01-Dec-2006 : Updated testEquals() for new field (DG); * 09-Jan-2007 : Comment out failing test (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.annotations; import org.jfree.chart.JFreeChart; import org.jfree.chart.ui.RectangleAnchor; import org.jfree.chart.util.PublicCloneable; import org.junit.Ignore; import org.junit.Test; import java.awt.Image; 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.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; import static org.junit.Assert.assertTrue; /** * Tests for the {@link XYImageAnnotation} class. */ public class XYImageAnnotationTest { 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; } /** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { Image image = getTestImage(); XYImageAnnotation a1 = new XYImageAnnotation(10.0, 20.0, image); XYImageAnnotation a2 = new XYImageAnnotation(10.0, 20.0, image); assertEquals(a1, a2); a1 = new XYImageAnnotation(10.0, 20.0, image, RectangleAnchor.LEFT); assertFalse(a1.equals(a2)); a2 = new XYImageAnnotation(10.0, 20.0, image, RectangleAnchor.LEFT); assertEquals(a1, a2); } /** * Two objects that are equal are required to return the same hashCode. */ @Test public void testHashCode() { Image image = getTestImage(); XYImageAnnotation a1 = new XYImageAnnotation(10.0, 20.0, image); XYImageAnnotation a2 = new XYImageAnnotation(10.0, 20.0, image); assertEquals(a1, a2); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { XYImageAnnotation a1 = new XYImageAnnotation(10.0, 20.0, getTestImage()); XYImageAnnotation a2 = (XYImageAnnotation) a1.clone(); assertNotSame(a1, a2); assertSame(a1.getClass(), a2.getClass()); assertEquals(a1, a2); } /** * Checks that this class implements PublicCloneable. */ @Test public void testPublicCloneable() { XYImageAnnotation a1 = new XYImageAnnotation(10.0, 20.0, getTestImage()); assertTrue(a1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ @Ignore("Previously commented out, marking as ignore so it's picked up") @Test public void testSerialization() throws IOException, ClassNotFoundException { XYImageAnnotation a1 = new XYImageAnnotation(10.0, 20.0, getTestImage()); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); XYImageAnnotation a2 = (XYImageAnnotation) in.readObject(); in.close(); assertEquals(a1, a2); } }
5,509
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
XYPolygonAnnotationTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/annotations/XYPolygonAnnotationTest.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.] * * ----------------------------- * XYPolygonAnnotationTests.java * ----------------------------- * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 10-Jul-2006 : Version 1 (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.annotations; import org.jfree.chart.util.PublicCloneable; 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 XYPolygonAnnotation} class. */ public class XYPolygonAnnotationTest { /** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { Stroke stroke1 = new BasicStroke(2.0f); Stroke stroke2 = new BasicStroke(2.5f); XYPolygonAnnotation a1 = new XYPolygonAnnotation(new double[] {1.0, 2.0, 3.0, 4.0, 5.0, 6.0}, stroke1, Color.RED, Color.BLUE); XYPolygonAnnotation a2 = new XYPolygonAnnotation(new double[] {1.0, 2.0, 3.0, 4.0, 5.0, 6.0}, stroke1, Color.RED, Color.BLUE); assertEquals(a1, a2); assertEquals(a2, a1); a1 = new XYPolygonAnnotation(new double[] {99.0, 2.0, 3.0, 4.0, 5.0, 6.0}, stroke1, Color.RED, Color.BLUE); assertFalse(a1.equals(a2)); a2 = new XYPolygonAnnotation(new double[] {99.0, 2.0, 3.0, 4.0, 5.0, 6.0}, stroke1, Color.RED, Color.BLUE); assertEquals(a1, a2); a1 = new XYPolygonAnnotation(new double[] {99.0, 2.0, 3.0, 4.0, 5.0, 6.0}, stroke2, Color.RED, Color.BLUE); assertFalse(a1.equals(a2)); a2 = new XYPolygonAnnotation(new double[] {99.0, 2.0, 3.0, 4.0, 5.0, 6.0}, stroke2, Color.RED, Color.BLUE); assertEquals(a1, a2); GradientPaint gp1 = new GradientPaint(1.0f, 2.0f, Color.yellow, 3.0f, 4.0f, Color.WHITE); GradientPaint gp2 = new GradientPaint(1.0f, 2.0f, Color.yellow, 3.0f, 4.0f, Color.WHITE); a1 = new XYPolygonAnnotation(new double[] {99.0, 2.0, 3.0, 4.0, 5.0, 6.0}, stroke2, gp1, Color.BLUE); assertFalse(a1.equals(a2)); a2 = new XYPolygonAnnotation(new double[] {99.0, 2.0, 3.0, 4.0, 5.0, 6.0}, stroke2, gp2, Color.BLUE); assertEquals(a1, a2); GradientPaint gp3 = new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.WHITE); GradientPaint gp4 = new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.WHITE); a1 = new XYPolygonAnnotation(new double[] {99.0, 2.0, 3.0, 4.0, 5.0, 6.0}, stroke2, gp1, gp3); assertFalse(a1.equals(a2)); a2 = new XYPolygonAnnotation(new double[] {99.0, 2.0, 3.0, 4.0, 5.0, 6.0}, stroke2, gp2, gp4); assertEquals(a1, a2); } /** * Two objects that are equal are required to return the same hashCode. */ @Test public void testHashCode() { Stroke stroke = new BasicStroke(2.0f); XYPolygonAnnotation a1 = new XYPolygonAnnotation(new double[] {1.0, 2.0, 3.0, 4.0, 5.0, 6.0}, stroke, Color.RED, Color.BLUE); XYPolygonAnnotation a2 = new XYPolygonAnnotation(new double[] {1.0, 2.0, 3.0, 4.0, 5.0, 6.0}, stroke, Color.RED, Color.BLUE); assertEquals(a1, a2); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { Stroke stroke1 = new BasicStroke(2.0f); XYPolygonAnnotation a1 = new XYPolygonAnnotation(new double[] {1.0, 2.0, 3.0, 4.0, 5.0, 6.0}, stroke1, Color.RED, Color.BLUE); XYPolygonAnnotation a2 = (XYPolygonAnnotation) a1.clone(); assertNotSame(a1, a2); assertSame(a1.getClass(), a2.getClass()); assertEquals(a1, a2); } /** * Checks that this class implements PublicCloneable. */ @Test public void testPublicCloneable() { Stroke stroke1 = new BasicStroke(2.0f); XYPolygonAnnotation a1 = new XYPolygonAnnotation(new double[] {1.0, 2.0, 3.0, 4.0, 5.0, 6.0}, stroke1, Color.RED, Color.BLUE); assertTrue(a1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { Stroke stroke1 = new BasicStroke(2.0f); XYPolygonAnnotation a1 = new XYPolygonAnnotation(new double[] {1.0, 2.0, 3.0, 4.0, 5.0, 6.0}, stroke1, Color.RED, Color.BLUE); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); XYPolygonAnnotation a2 = (XYPolygonAnnotation) in.readObject(); in.close(); assertEquals(a1, a2); } }
7,064
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
XYDrawableAnnotationTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/annotations/XYDrawableAnnotationTest.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.] * * ------------------------------ * XYDrawableAnnotationTests.java * ------------------------------ * (C) Copyright 2003-2012, by Object Refinery Limited. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 19-Aug-2003 : Version 1 (DG); * 01-Oct-2004 : Fixed bugs in tests (DG); * 07-Jan-2005 : Added hashCode() test (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * 17-Jun-2012 : Removed JCommon dependencies (DG); * */ package org.jfree.chart.annotations; import org.jfree.chart.ui.Drawable; import org.jfree.chart.util.PublicCloneable; import org.junit.Test; import java.awt.Graphics2D; 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 java.io.Serializable; 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 XYDrawableAnnotation} class. */ public class XYDrawableAnnotationTest { static class TestDrawable implements Drawable, Cloneable, Serializable { /** * Default constructor. */ public TestDrawable() { } /** * Draws something. * @param g2 the graphics device. * @param area the area in which to draw. */ @Override public void draw(Graphics2D g2, Rectangle2D area) { // do nothing } /** * Tests this object for equality with an arbitrary object. * @param obj the object to test against (<code>null</code> permitted). * @return A boolean. */ @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof TestDrawable)) { return false; } return true; } /** * Returns a clone. * * @return A clone. * * @throws CloneNotSupportedException if there is a problem cloning. */ @Override public Object clone() throws CloneNotSupportedException { return super.clone(); } } /** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { XYDrawableAnnotation a1 = new XYDrawableAnnotation(10.0, 20.0, 100.0, 200.0, new TestDrawable()); XYDrawableAnnotation a2 = new XYDrawableAnnotation(10.0, 20.0, 100.0, 200.0, new TestDrawable()); assertEquals(a1, a2); a1 = new XYDrawableAnnotation(11.0, 20.0, 100.0, 200.0, new TestDrawable()); assertFalse(a1.equals(a2)); a2 = new XYDrawableAnnotation(11.0, 20.0, 100.0, 200.0, new TestDrawable()); assertEquals(a1, a2); a1 = new XYDrawableAnnotation(11.0, 22.0, 100.0, 200.0, new TestDrawable()); assertFalse(a1.equals(a2)); a2 = new XYDrawableAnnotation(11.0, 22.0, 100.0, 200.0, new TestDrawable()); assertEquals(a1, a2); a1 = new XYDrawableAnnotation(11.0, 22.0, 101.0, 200.0, new TestDrawable()); assertFalse(a1.equals(a2)); a2 = new XYDrawableAnnotation(11.0, 22.0, 101.0, 200.0, new TestDrawable()); assertEquals(a1, a2); a1 = new XYDrawableAnnotation(11.0, 22.0, 101.0, 202.0, new TestDrawable()); assertFalse(a1.equals(a2)); a2 = new XYDrawableAnnotation(11.0, 22.0, 101.0, 202.0, new TestDrawable()); assertEquals(a1, a2); a1 = new XYDrawableAnnotation(11.0, 22.0, 101.0, 202.0, 2.0, new TestDrawable()); assertFalse(a1.equals(a2)); a2 = new XYDrawableAnnotation(11.0, 22.0, 101.0, 202.0, 2.0, new TestDrawable()); assertEquals(a1, a2); } /** * Two objects that are equal are required to return the same hashCode. */ @Test public void testHashCode() { XYDrawableAnnotation a1 = new XYDrawableAnnotation(10.0, 20.0, 100.0, 200.0, new TestDrawable()); XYDrawableAnnotation a2 = new XYDrawableAnnotation(10.0, 20.0, 100.0, 200.0, new TestDrawable()); assertEquals(a1, a2); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { XYDrawableAnnotation a1 = new XYDrawableAnnotation(10.0, 20.0, 100.0, 200.0, new TestDrawable()); XYDrawableAnnotation a2 = (XYDrawableAnnotation) a1.clone(); assertNotSame(a1, a2); assertSame(a1.getClass(), a2.getClass()); assertEquals(a1, a2); } /** * Checks that this class implements PublicCloneable. */ @Test public void testPublicCloneable() { XYDrawableAnnotation a1 = new XYDrawableAnnotation(10.0, 20.0, 100.0, 200.0, new TestDrawable()); assertTrue(a1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { XYDrawableAnnotation a1 = new XYDrawableAnnotation(10.0, 20.0, 100.0, 200.0, new TestDrawable()); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); XYDrawableAnnotation a2 = (XYDrawableAnnotation) in.readObject(); in.close(); assertEquals(a1, a2); } }
7,487
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
XYPointerAnnotationTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/annotations/XYPointerAnnotationTest.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.] * * ----------------------------- * XYPointerAnnotationTests.java * ----------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 19-Aug-2003 : Version 1 (DG); * 13-Oct-2003 : Expanded test for equals() method (DG); * 07-Jan-2005 : Added hashCode() test (DG); * 20-Feb-2006 : Added 'x' and 'y' checks to testEquals() (DG); * 23-Apr-2008 : Added testPublicCloneable() (DG); * */ package org.jfree.chart.annotations; import org.jfree.chart.util.PublicCloneable; import org.junit.Test; import java.awt.BasicStroke; import java.awt.Color; 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 XYPointerAnnotation} class. */ public class XYPointerAnnotationTest { /** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { XYPointerAnnotation a1 = new XYPointerAnnotation("Label", 10.0, 20.0, Math.PI); XYPointerAnnotation a2 = new XYPointerAnnotation("Label", 10.0, 20.0, Math.PI); assertEquals(a1, a2); a1 = new XYPointerAnnotation("Label2", 10.0, 20.0, Math.PI); assertFalse(a1.equals(a2)); a2 = new XYPointerAnnotation("Label2", 10.0, 20.0, Math.PI); assertEquals(a1, a2); a1.setX(11.0); assertFalse(a1.equals(a2)); a2.setX(11.0); assertEquals(a1, a2); a1.setY(22.0); assertFalse(a1.equals(a2)); a2.setY(22.0); assertEquals(a1, a2); //private double angle; a1.setAngle(Math.PI / 4.0); assertFalse(a1.equals(a2)); a2.setAngle(Math.PI / 4.0); assertEquals(a1, a2); //private double tipRadius; a1.setTipRadius(20.0); assertFalse(a1.equals(a2)); a2.setTipRadius(20.0); assertEquals(a1, a2); //private double baseRadius; a1.setBaseRadius(5.0); assertFalse(a1.equals(a2)); a2.setBaseRadius(5.0); assertEquals(a1, a2); //private double arrowLength; a1.setArrowLength(33.0); assertFalse(a1.equals(a2)); a2.setArrowLength(33.0); assertEquals(a1, a2); //private double arrowWidth; a1.setArrowWidth(9.0); assertFalse(a1.equals(a2)); a2.setArrowWidth(9.0); assertEquals(a1, a2); //private Stroke arrowStroke; Stroke stroke = new BasicStroke(1.5f); a1.setArrowStroke(stroke); assertFalse(a1.equals(a2)); a2.setArrowStroke(stroke); assertEquals(a1, a2); //private Paint arrowPaint; a1.setArrowPaint(Color.BLUE); assertFalse(a1.equals(a2)); a2.setArrowPaint(Color.BLUE); assertEquals(a1, a2); //private double labelOffset; a1.setLabelOffset(10.0); assertFalse(a1.equals(a2)); a2.setLabelOffset(10.0); assertEquals(a1, a2); } /** * Two objects that are equal are required to return the same hashCode. */ @Test public void testHashCode() { XYPointerAnnotation a1 = new XYPointerAnnotation("Label", 10.0, 20.0, Math.PI); XYPointerAnnotation a2 = new XYPointerAnnotation("Label", 10.0, 20.0, Math.PI); assertEquals(a1, a2); int h1 = a1.hashCode(); int h2 = a2.hashCode(); assertEquals(h1, h2); } /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { XYPointerAnnotation a1 = new XYPointerAnnotation("Label", 10.0, 20.0, Math.PI); XYPointerAnnotation a2 = (XYPointerAnnotation) a1.clone(); assertNotSame(a1, a2); assertSame(a1.getClass(), a2.getClass()); assertEquals(a1, a2); } /** * Checks that this class implements PublicCloneable. */ @Test public void testPublicCloneable() { XYPointerAnnotation a1 = new XYPointerAnnotation("Label", 10.0, 20.0, Math.PI); assertTrue(a1 instanceof PublicCloneable); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { XYPointerAnnotation a1 = new XYPointerAnnotation("Label", 10.0, 20.0, Math.PI); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(a1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); XYPointerAnnotation a2 = (XYPointerAnnotation) in.readObject(); in.close(); assertEquals(a1, a2); } }
6,616
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
BorderArrangementTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/block/BorderArrangementTest.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.] * * --------------------------- * BorderArrangementTests.java * --------------------------- * (C) Copyright 2004-2012, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 22-Oct-2004 : Version 1 (DG); * 17-Jun-2012 : Removed JCommon dependencies (DG); * */ package org.jfree.chart.block; import org.jfree.chart.ui.RectangleEdge; import org.jfree.chart.ui.Size2D; import org.jfree.data.Range; import org.junit.Test; import java.awt.Graphics2D; 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; /** * Tests for the {@link BorderArrangement} class. */ public class BorderArrangementTest { private static final double EPSILON = 0.0000000001; /** * Confirm that the equals() method can distinguish all the required fields. */ @Test public void testEquals() { BorderArrangement b1 = new BorderArrangement(); BorderArrangement b2 = new BorderArrangement(); assertEquals(b1, b2); assertEquals(b2, b1); b1.add(new EmptyBlock(99.0, 99.0), null); assertFalse(b1.equals(b2)); b2.add(new EmptyBlock(99.0, 99.0), null); assertEquals(b1, b2); b1.add(new EmptyBlock(1.0, 1.0), RectangleEdge.LEFT); assertFalse(b1.equals(b2)); b2.add(new EmptyBlock(1.0, 1.0), RectangleEdge.LEFT); assertEquals(b1, b2); b1.add(new EmptyBlock(2.0, 2.0), RectangleEdge.RIGHT); assertFalse(b1.equals(b2)); b2.add(new EmptyBlock(2.0, 2.0), RectangleEdge.RIGHT); assertEquals(b1, b2); b1.add(new EmptyBlock(3.0, 3.0), RectangleEdge.TOP); assertFalse(b1.equals(b2)); b2.add(new EmptyBlock(3.0, 3.0), RectangleEdge.TOP); assertEquals(b1, b2); b1.add(new EmptyBlock(4.0, 4.0), RectangleEdge.BOTTOM); assertFalse(b1.equals(b2)); b2.add(new EmptyBlock(4.0, 4.0), RectangleEdge.BOTTOM); assertEquals(b1, b2); } /** * Immutable - cloning is not necessary. */ @Test public void testCloning() throws CloneNotSupportedException { BorderArrangement b1 = new BorderArrangement(); assertFalse(b1 instanceof Cloneable); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { BorderArrangement b1 = new BorderArrangement(); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(b1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); BorderArrangement b2 = (BorderArrangement) in.readObject(); in.close(); assertEquals(b1, b2); } /** * Run some checks on sizing. */ @Test public void testSizing() { BlockContainer container = new BlockContainer(new BorderArrangement()); BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); // TBLRC // 00000 - no items Size2D size = container.arrange(g2); assertEquals(0.0, size.width, EPSILON); assertEquals(0.0, size.height, EPSILON); // TBLRC // 00001 - center item only container.add(new EmptyBlock(123.4, 567.8)); size = container.arrange(g2); assertEquals(123.4, size.width, EPSILON); assertEquals(567.8, size.height, EPSILON); // TBLRC // 00010 - right item only container.clear(); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.RIGHT); size = container.arrange(g2); assertEquals(12.3, size.width, EPSILON); assertEquals(45.6, size.height, EPSILON); // TBLRC // 00011 - right and center items container.clear(); container.add(new EmptyBlock(10.0, 20.0)); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.RIGHT); size = container.arrange(g2); assertEquals(22.3, size.width, EPSILON); assertEquals(45.6, size.height, EPSILON); // try case where right item is shorter than center item container.clear(); Block rb = new EmptyBlock(12.3, 15.6); container.add(new EmptyBlock(10.0, 20.0)); container.add(rb, RectangleEdge.RIGHT); size = container.arrange(g2); assertEquals(22.3, size.width, EPSILON); assertEquals(20.0, size.height, EPSILON); assertEquals(20.0, rb.getBounds().getHeight(), EPSILON); // TBLRC // 00100 - left item only container.clear(); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.LEFT); size = container.arrange(g2); assertEquals(12.3, size.width, EPSILON); assertEquals(45.6, size.height, EPSILON); // TBLRC // 00101 - left and center items container.clear(); container.add(new EmptyBlock(10.0, 20.0)); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.LEFT); size = container.arrange(g2); assertEquals(22.3, size.width, EPSILON); assertEquals(45.6, size.height, EPSILON); // try case where left item is shorter than center item container.clear(); Block lb = new EmptyBlock(12.3, 15.6); container.add(new EmptyBlock(10.0, 20.0)); container.add(lb, RectangleEdge.LEFT); size = container.arrange(g2); assertEquals(22.3, size.width, EPSILON); assertEquals(20.0, size.height, EPSILON); assertEquals(20.0, lb.getBounds().getHeight(), EPSILON); // TBLRC // 00110 - left and right items container.clear(); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.RIGHT); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.LEFT); size = container.arrange(g2); assertEquals(22.3, size.width, EPSILON); assertEquals(45.6, size.height, EPSILON); // TBLRC // 00111 - left, right and center items container.clear(); container.add(new EmptyBlock(10.0, 20.0)); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.LEFT); container.add(new EmptyBlock(5.4, 3.2), RectangleEdge.RIGHT); size = container.arrange(g2); assertEquals(27.7, size.width, EPSILON); assertEquals(45.6, size.height, EPSILON); // TBLRC // 01000 - bottom item only container.clear(); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); size = container.arrange(g2); assertEquals(12.3, size.width, EPSILON); assertEquals(45.6, size.height, EPSILON); // TBLRC // 01001 - bottom and center only container.clear(); container.add(new EmptyBlock(10.0, 20.0)); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); size = container.arrange(g2); assertEquals(12.3, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 01010 - bottom and right only container.clear(); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.RIGHT); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); size = container.arrange(g2); assertEquals(12.3, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 01011 - bottom, right and center container.clear(); container.add(new EmptyBlock(21.0, 12.3)); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.RIGHT); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); size = container.arrange(g2); assertEquals(31.0, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 01100 container.clear(); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.LEFT); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); size = container.arrange(g2); assertEquals(12.3, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 01101 - bottom, left and center container.clear(); container.add(new EmptyBlock(21.0, 12.3)); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.LEFT); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); size = container.arrange(g2); assertEquals(31.0, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 01110 - bottom. left and right container.clear(); container.add(new EmptyBlock(21.0, 12.3), RectangleEdge.RIGHT); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.LEFT); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); size = container.arrange(g2); assertEquals(31.0, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 01111 container.clear(); container.add(new EmptyBlock(3.0, 4.0), RectangleEdge.BOTTOM); container.add(new EmptyBlock(5.0, 6.0), RectangleEdge.LEFT); container.add(new EmptyBlock(7.0, 8.0), RectangleEdge.RIGHT); container.add(new EmptyBlock(9.0, 10.0)); size = container.arrange(g2); assertEquals(21.0, size.width, EPSILON); assertEquals(14.0, size.height, EPSILON); // TBLRC // 10000 - top item only container.clear(); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.TOP); size = container.arrange(g2); assertEquals(12.3, size.width, EPSILON); assertEquals(45.6, size.height, EPSILON); // TBLRC // 10001 - top and center only container.clear(); container.add(new EmptyBlock(10.0, 20.0)); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.TOP); size = container.arrange(g2); assertEquals(12.3, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 10010 - right and top only container.clear(); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.RIGHT); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.TOP); size = container.arrange(g2); assertEquals(12.3, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 10011 - top, right and center container.clear(); container.add(new EmptyBlock(21.0, 12.3)); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.RIGHT); size = container.arrange(g2); assertEquals(33.3, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 10100 - top and left only container.clear(); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.LEFT); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.TOP); size = container.arrange(g2); assertEquals(12.3, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 10101 - top, left and center container.clear(); container.add(new EmptyBlock(21.0, 12.3)); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.LEFT); size = container.arrange(g2); assertEquals(33.3, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 10110 - top, left and right container.clear(); container.add(new EmptyBlock(21.0, 12.3), RectangleEdge.RIGHT); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.LEFT); size = container.arrange(g2); assertEquals(33.3, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 10111 container.clear(); container.add(new EmptyBlock(1.0, 2.0), RectangleEdge.TOP); container.add(new EmptyBlock(5.0, 6.0), RectangleEdge.LEFT); container.add(new EmptyBlock(7.0, 8.0), RectangleEdge.RIGHT); container.add(new EmptyBlock(9.0, 10.0)); size = container.arrange(g2); assertEquals(21.0, size.width, EPSILON); assertEquals(12.0, size.height, EPSILON); // TBLRC // 11000 - top and bottom only container.clear(); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); size = container.arrange(g2); assertEquals(12.3, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 11001 container.clear(); container.add(new EmptyBlock(21.0, 12.3)); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); size = container.arrange(g2); assertEquals(21.0, size.width, EPSILON); assertEquals(77.9, size.height, EPSILON); // TBLRC // 11010 - top, bottom and right container.clear(); container.add(new EmptyBlock(21.0, 12.3), RectangleEdge.RIGHT); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); size = container.arrange(g2); assertEquals(21.0, size.width, EPSILON); assertEquals(77.9, size.height, EPSILON); // TBLRC // 11011 container.clear(); container.add(new EmptyBlock(1.0, 2.0), RectangleEdge.TOP); container.add(new EmptyBlock(3.0, 4.0), RectangleEdge.BOTTOM); container.add(new EmptyBlock(7.0, 8.0), RectangleEdge.RIGHT); container.add(new EmptyBlock(9.0, 10.0)); size = container.arrange(g2); assertEquals(16.0, size.width, EPSILON); assertEquals(16.0, size.height, EPSILON); // TBLRC // 11100 container.clear(); container.add(new EmptyBlock(21.0, 12.3), RectangleEdge.LEFT); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); size = container.arrange(g2); assertEquals(21.0, size.width, EPSILON); assertEquals(77.9, size.height, EPSILON); // TBLRC // 11101 container.clear(); container.add(new EmptyBlock(1.0, 2.0), RectangleEdge.TOP); container.add(new EmptyBlock(3.0, 4.0), RectangleEdge.BOTTOM); container.add(new EmptyBlock(5.0, 6.0), RectangleEdge.LEFT); container.add(new EmptyBlock(9.0, 10.0)); size = container.arrange(g2); assertEquals(14.0, size.width, EPSILON); assertEquals(16.0, size.height, EPSILON); // TBLRC // 11110 container.clear(); container.add(new EmptyBlock(1.0, 2.0), RectangleEdge.TOP); container.add(new EmptyBlock(3.0, 4.0), RectangleEdge.BOTTOM); container.add(new EmptyBlock(5.0, 6.0), RectangleEdge.LEFT); container.add(new EmptyBlock(7.0, 8.0), RectangleEdge.RIGHT); size = container.arrange(g2); assertEquals(12.0, size.width, EPSILON); assertEquals(14.0, size.height, EPSILON); // TBLRC // 11111 - all container.clear(); container.add(new EmptyBlock(1.0, 2.0), RectangleEdge.TOP); container.add(new EmptyBlock(3.0, 4.0), RectangleEdge.BOTTOM); container.add(new EmptyBlock(5.0, 6.0), RectangleEdge.LEFT); container.add(new EmptyBlock(7.0, 8.0), RectangleEdge.RIGHT); container.add(new EmptyBlock(9.0, 10.0)); size = container.arrange(g2); assertEquals(21.0, size.width, EPSILON); assertEquals(16.0, size.height, EPSILON); } /** * Run some checks on sizing when there is a fixed width constraint. */ @Test public void testSizingWithWidthConstraint() { RectangleConstraint constraint = new RectangleConstraint( 10.0, new Range(10.0, 10.0), LengthConstraintType.FIXED, 0.0, new Range(0.0, 0.0), LengthConstraintType.NONE); BlockContainer container = new BlockContainer(new BorderArrangement()); BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); // TBLRC // 00001 - center item only container.add(new EmptyBlock(5.0, 6.0)); Size2D size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(6.0, size.height, EPSILON); container.clear(); container.add(new EmptyBlock(15.0, 16.0)); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(16.0, size.height, EPSILON); // TBLRC // 00010 - right item only container.clear(); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.RIGHT); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(45.6, size.height, EPSILON); // TBLRC // 00011 - right and center items container.clear(); container.add(new EmptyBlock(7.0, 20.0)); container.add(new EmptyBlock(8.0, 45.6), RectangleEdge.RIGHT); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(45.6, size.height, EPSILON); // TBLRC // 00100 - left item only container.clear(); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.LEFT); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(45.6, size.height, EPSILON); // TBLRC // 00101 - left and center items container.clear(); container.add(new EmptyBlock(10.0, 20.0)); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.LEFT); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(45.6, size.height, EPSILON); // TBLRC // 00110 - left and right items container.clear(); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.RIGHT); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.LEFT); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(45.6, size.height, EPSILON); // TBLRC // 00111 - left, right and center items container.clear(); container.add(new EmptyBlock(10.0, 20.0)); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.LEFT); container.add(new EmptyBlock(5.4, 3.2), RectangleEdge.RIGHT); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(45.6, size.height, EPSILON); // TBLRC // 01000 - bottom item only container.clear(); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(45.6, size.height, EPSILON); // TBLRC // 01001 - bottom and center only container.clear(); container.add(new EmptyBlock(10.0, 20.0)); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 01010 - bottom and right only container.clear(); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.RIGHT); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 01011 - bottom, right and center container.clear(); container.add(new EmptyBlock(21.0, 12.3)); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.RIGHT); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 01100 container.clear(); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.LEFT); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 01101 - bottom, left and center container.clear(); container.add(new EmptyBlock(21.0, 12.3)); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.LEFT); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 01110 - bottom. left and right container.clear(); container.add(new EmptyBlock(21.0, 12.3), RectangleEdge.RIGHT); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.LEFT); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 01111 container.clear(); container.add(new EmptyBlock(3.0, 4.0), RectangleEdge.BOTTOM); container.add(new EmptyBlock(5.0, 6.0), RectangleEdge.LEFT); container.add(new EmptyBlock(7.0, 8.0), RectangleEdge.RIGHT); container.add(new EmptyBlock(9.0, 10.0)); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(14.0, size.height, EPSILON); // TBLRC // 10000 - top item only container.clear(); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.TOP); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(45.6, size.height, EPSILON); // TBLRC // 10001 - top and center only container.clear(); container.add(new EmptyBlock(10.0, 20.0)); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.TOP); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 10010 - right and top only container.clear(); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.RIGHT); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.TOP); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 10011 - top, right and center container.clear(); container.add(new EmptyBlock(21.0, 12.3)); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.RIGHT); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 10100 - top and left only container.clear(); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.LEFT); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.TOP); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 10101 - top, left and center container.clear(); container.add(new EmptyBlock(21.0, 12.3)); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.LEFT); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 10110 - top, left and right container.clear(); container.add(new EmptyBlock(21.0, 12.3), RectangleEdge.RIGHT); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.LEFT); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 10111 container.clear(); container.add(new EmptyBlock(1.0, 2.0), RectangleEdge.TOP); container.add(new EmptyBlock(5.0, 6.0), RectangleEdge.LEFT); container.add(new EmptyBlock(7.0, 8.0), RectangleEdge.RIGHT); container.add(new EmptyBlock(9.0, 10.0)); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(12.0, size.height, EPSILON); // TBLRC // 11000 - top and bottom only container.clear(); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(65.6, size.height, EPSILON); // TBLRC // 11001 container.clear(); container.add(new EmptyBlock(21.0, 12.3)); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(77.9, size.height, EPSILON); // TBLRC // 11010 - top, bottom and right container.clear(); container.add(new EmptyBlock(21.0, 12.3), RectangleEdge.RIGHT); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(77.9, size.height, EPSILON); // TBLRC // 11011 container.clear(); container.add(new EmptyBlock(1.0, 2.0), RectangleEdge.TOP); container.add(new EmptyBlock(3.0, 4.0), RectangleEdge.BOTTOM); container.add(new EmptyBlock(7.0, 8.0), RectangleEdge.RIGHT); container.add(new EmptyBlock(9.0, 10.0)); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(16.0, size.height, EPSILON); // TBLRC // 11100 container.clear(); container.add(new EmptyBlock(21.0, 12.3), RectangleEdge.LEFT); container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(77.9, size.height, EPSILON); // TBLRC // 11101 container.clear(); container.add(new EmptyBlock(1.0, 2.0), RectangleEdge.TOP); container.add(new EmptyBlock(3.0, 4.0), RectangleEdge.BOTTOM); container.add(new EmptyBlock(5.0, 6.0), RectangleEdge.LEFT); container.add(new EmptyBlock(9.0, 10.0)); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(16.0, size.height, EPSILON); // TBLRC // 11110 container.clear(); container.add(new EmptyBlock(1.0, 2.0), RectangleEdge.TOP); container.add(new EmptyBlock(3.0, 4.0), RectangleEdge.BOTTOM); container.add(new EmptyBlock(5.0, 6.0), RectangleEdge.LEFT); container.add(new EmptyBlock(7.0, 8.0), RectangleEdge.RIGHT); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(14.0, size.height, EPSILON); // TBLRC // 11111 - all container.clear(); container.add(new EmptyBlock(1.0, 2.0), RectangleEdge.TOP); container.add(new EmptyBlock(3.0, 4.0), RectangleEdge.BOTTOM); container.add(new EmptyBlock(5.0, 6.0), RectangleEdge.LEFT); container.add(new EmptyBlock(7.0, 8.0), RectangleEdge.RIGHT); container.add(new EmptyBlock(9.0, 10.0)); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(16.0, size.height, EPSILON); // TBLRC // 00000 - no items container.clear(); size = container.arrange(g2, constraint); assertEquals(10.0, size.width, EPSILON); assertEquals(0.0, size.height, EPSILON); } /** * This test is for a particular bug that arose just prior to the release * of JFreeChart 1.0.10. A BorderArrangement with LEFT, CENTRE and RIGHT * blocks that is too wide, by default, for the available space, wasn't * shrinking the centre block as expected. */ @Test public void testBugX() { RectangleConstraint constraint = new RectangleConstraint( new Range(0.0, 200.0), new Range(0.0, 100.0)); BlockContainer container = new BlockContainer(new BorderArrangement()); BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); container.add(new EmptyBlock(10.0, 6.0), RectangleEdge.LEFT); container.add(new EmptyBlock(20.0, 6.0), RectangleEdge.RIGHT); container.add(new EmptyBlock(30.0, 6.0)); Size2D size = container.arrange(g2, constraint); assertEquals(60.0, size.width, EPSILON); assertEquals(6.0, size.height, EPSILON); container.clear(); container.add(new EmptyBlock(10.0, 6.0), RectangleEdge.LEFT); container.add(new EmptyBlock(20.0, 6.0), RectangleEdge.RIGHT); container.add(new EmptyBlock(300.0, 6.0)); size = container.arrange(g2, constraint); assertEquals(200.0, size.width, EPSILON); assertEquals(6.0, size.height, EPSILON); } }
32,672
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
ColorBlockTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/block/ColorBlockTest.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.] * * -------------------- * ColorBlockTests.java * -------------------- * (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 16-Mar-2007 : Version 1 (DG); * */ package org.jfree.chart.block; import org.junit.Test; import java.awt.Color; 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; /** * Tests for the {@link ColorBlock} class. */ public class ColorBlockTest { /** * Confirm that the equals() method can distinguish all the required fields. */ @Test public void testEquals() { ColorBlock b1 = new ColorBlock(Color.RED, 1.0, 2.0); ColorBlock b2 = new ColorBlock(Color.RED, 1.0, 2.0); assertEquals(b1, b2); assertEquals(b2, b2); b1 = new ColorBlock(Color.BLUE, 1.0, 2.0); assertFalse(b1.equals(b2)); b2 = new ColorBlock(Color.BLUE, 1.0, 2.0); assertEquals(b1, b2); b1 = new ColorBlock(Color.BLUE, 1.1, 2.0); assertFalse(b1.equals(b2)); b2 = new ColorBlock(Color.BLUE, 1.1, 2.0); assertEquals(b1, b2); b1 = new ColorBlock(Color.BLUE, 1.1, 2.2); assertFalse(b1.equals(b2)); b2 = new ColorBlock(Color.BLUE, 1.1, 2.2); assertEquals(b1, b2); } /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { GradientPaint gp = new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.BLUE); Rectangle2D bounds1 = new Rectangle2D.Double(10.0, 20.0, 30.0, 40.0); ColorBlock b1 = new ColorBlock(gp, 1.0, 2.0); b1.setBounds(bounds1); ColorBlock b2 = (ColorBlock) b1.clone(); assertNotSame(b1, b2); assertSame(b1.getClass(), b2.getClass()); assertEquals(b1, b2); // check independence bounds1.setRect(1.0, 2.0, 3.0, 4.0); assertFalse(b1.equals(b2)); b2.setBounds(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); assertEquals(b1, b2); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { GradientPaint gp = new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.BLUE); ColorBlock b1 = new ColorBlock(gp, 1.0, 2.0); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(b1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); ColorBlock b2 = (ColorBlock) in.readObject(); in.close(); assertEquals(b1, b2); } }
4,520
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
FlowArrangementTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/block/FlowArrangementTest.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.] * * ------------------------- * FlowArrangementTests.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); * 17-Jun-2012 : Remove JCommon dependencies (DG); * */ package org.jfree.chart.block; import org.jfree.chart.ui.HorizontalAlignment; import org.jfree.chart.ui.VerticalAlignment; 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 FlowArrangement} class. */ public class FlowArrangementTest { /** * Confirm that the equals() method can distinguish all the required fields. */ @Test public void testEquals() { FlowArrangement f1 = new FlowArrangement(HorizontalAlignment.LEFT, VerticalAlignment.TOP, 1.0, 2.0); FlowArrangement f2 = new FlowArrangement(HorizontalAlignment.LEFT, VerticalAlignment.TOP, 1.0, 2.0); assertEquals(f1, f2); assertEquals(f2, f1); f1 = new FlowArrangement(HorizontalAlignment.RIGHT, VerticalAlignment.TOP, 1.0, 2.0); assertFalse(f1.equals(f2)); f2 = new FlowArrangement(HorizontalAlignment.RIGHT, VerticalAlignment.TOP, 1.0, 2.0); assertEquals(f1, f2); f1 = new FlowArrangement(HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, 1.0, 2.0); assertFalse(f1.equals(f2)); f2 = new FlowArrangement(HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, 1.0, 2.0); assertEquals(f1, f2); f1 = new FlowArrangement(HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, 1.1, 2.0); assertFalse(f1.equals(f2)); f2 = new FlowArrangement(HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, 1.1, 2.0); assertEquals(f1, f2); f1 = new FlowArrangement(HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, 1.1, 2.2); assertFalse(f1.equals(f2)); f2 = new FlowArrangement(HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, 1.1, 2.2); assertEquals(f1, f2); } /** * Immutable - cloning is not necessary. */ @Test public void testCloning() throws CloneNotSupportedException { FlowArrangement f1 = new FlowArrangement(); assertFalse(f1 instanceof Cloneable); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { FlowArrangement f1 = new FlowArrangement(HorizontalAlignment.LEFT, VerticalAlignment.TOP, 1.0, 2.0); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(f1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); FlowArrangement f2 = (FlowArrangement) in.readObject(); in.close(); assertEquals(f1, f2); } }
4,736
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
EmptyBlockTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/block/EmptyBlockTest.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.] * * -------------------- * EmptyBlockTests.java * -------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 04-Feb-2005 : Version 1 (DG); * */ package org.jfree.chart.block; 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 EmptyBlock} class. */ public class EmptyBlockTest { /** * Confirm that the equals() method can distinguish all the required fields. */ @Test public void testEquals() { EmptyBlock b1 = new EmptyBlock(1.0, 2.0); EmptyBlock b2 = new EmptyBlock(1.0, 2.0); assertEquals(b1, b2); assertEquals(b2, b2); b1 = new EmptyBlock(1.1, 2.0); assertFalse(b1.equals(b2)); b2 = new EmptyBlock(1.1, 2.0); assertEquals(b1, b2); b1 = new EmptyBlock(1.1, 2.2); assertFalse(b1.equals(b2)); b2 = new EmptyBlock(1.1, 2.2); assertEquals(b1, b2); } /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { EmptyBlock b1 = new EmptyBlock(1.0, 2.0); EmptyBlock b2 = (EmptyBlock) b1.clone(); assertNotSame(b1, b2); assertSame(b1.getClass(), b2.getClass()); assertEquals(b1, b2); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { EmptyBlock b1 = new EmptyBlock(1.0, 2.0); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(b1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); EmptyBlock b2 = (EmptyBlock) in.readObject(); in.close(); assertEquals(b1, b2); } }
3,650
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
BlockContainerTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/block/BlockContainerTest.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.] * * ------------------------ * BlockContainerTests.java * ------------------------ * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 04-Feb-2005 : Version 1 (DG); * */ package org.jfree.chart.block; 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 BlockContainer} class. */ public class BlockContainerTest { /** * Confirm that the equals() method can distinguish all the required fields. */ @Test public void testEquals() { BlockContainer c1 = new BlockContainer(new FlowArrangement()); BlockContainer c2 = new BlockContainer(new FlowArrangement()); assertEquals(c1, c2); assertEquals(c2, c2); c1.setArrangement(new ColumnArrangement()); assertFalse(c1.equals(c2)); c2.setArrangement(new ColumnArrangement()); assertEquals(c1, c2); c1.add(new EmptyBlock(1.2, 3.4)); assertFalse(c1.equals(c2)); c2.add(new EmptyBlock(1.2, 3.4)); assertEquals(c1, c2); } /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { BlockContainer c1 = new BlockContainer(new FlowArrangement()); c1.add(new EmptyBlock(1.2, 3.4)); BlockContainer c2 = (BlockContainer) c1.clone(); assertNotSame(c1, c2); assertSame(c1.getClass(), c2.getClass()); assertEquals(c1, c2); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { BlockContainer c1 = new BlockContainer(); c1.add(new EmptyBlock(1.2, 3.4)); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(c1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); BlockContainer c2 = (BlockContainer) in.readObject(); in.close(); assertEquals(c1, c2); } }
3,870
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
GridArrangementTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/block/GridArrangementTest.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.] * * ------------------------- * GridArrangementTests.java * ------------------------- * (C) Copyright 2005-2012, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 08-Mar-2005 : Version 1 (DG); * 03-Dec-2008 : Added more tests (DG); * 17-Jun-2012 : Removed JCommon dependencies (DG); * */ package org.jfree.chart.block; import org.jfree.chart.ui.Size2D; import org.jfree.data.Range; 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 GridArrangement} class. */ public class GridArrangementTest { /** * Confirm that the equals() method can distinguish all the required fields. */ @Test public void testEquals() { GridArrangement f1 = new GridArrangement(11, 22); GridArrangement f2 = new GridArrangement(11, 22); assertEquals(f1, f2); assertEquals(f2, f1); f1 = new GridArrangement(33, 22); assertFalse(f1.equals(f2)); f2 = new GridArrangement(33, 22); assertEquals(f1, f2); f1 = new GridArrangement(33, 44); assertFalse(f1.equals(f2)); f2 = new GridArrangement(33, 44); assertEquals(f1, f2); } /** * Immutable - cloning is not necessary. */ @Test public void testCloning() throws CloneNotSupportedException { GridArrangement f1 = new GridArrangement(1, 2); assertFalse(f1 instanceof Cloneable); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { GridArrangement f1 = new GridArrangement(33, 44); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(f1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); GridArrangement f2 = (GridArrangement) in.readObject(); in.close(); assertEquals(f1, f2); } private static final double EPSILON = 0.000000001; /** * Test arrangement with no constraints. */ @Test public void testNN() { BlockContainer c = createTestContainer1(); Size2D s = c.arrange(null, RectangleConstraint.NONE); assertEquals(90.0, s.width, EPSILON); assertEquals(33.0, s.height, EPSILON); } /** * Test arrangement with a fixed width and no height constraint. */ @Test public void testFN() { BlockContainer c = createTestContainer1(); RectangleConstraint constraint = new RectangleConstraint(100.0, null, LengthConstraintType.FIXED, 0.0, null, LengthConstraintType.NONE); Size2D s = c.arrange(null, constraint); assertEquals(100.0, s.width, EPSILON); assertEquals(33.0, s.height, EPSILON); } /** * Test arrangement with a fixed height and no width constraint. */ @Test public void testNF() { BlockContainer c = createTestContainer1(); RectangleConstraint constraint = RectangleConstraint.NONE.toFixedHeight( 100.0); Size2D s = c.arrange(null, constraint); assertEquals(90.0, s.width, EPSILON); assertEquals(100.0, s.height, EPSILON); } /** * Test arrangement with a range for the width and a fixed height. */ @Test public void testRF() { BlockContainer c = createTestContainer1(); RectangleConstraint constraint = new RectangleConstraint(new Range(40.0, 60.0), 100.0); Size2D s = c.arrange(null, constraint); assertEquals(60.0, s.width, EPSILON); assertEquals(100.0, s.height, EPSILON); } /** * Test arrangement with a range for the width and height. */ @Test public void testRR() { BlockContainer c = createTestContainer1(); RectangleConstraint constraint = new RectangleConstraint(new Range(40.0, 60.0), new Range(50.0, 70.0)); Size2D s = c.arrange(null, constraint); assertEquals(60.0, s.width, EPSILON); assertEquals(50.0, s.height, EPSILON); } /** * Test arrangement with a range for the width and no height constraint. */ @Test public void testRN() { BlockContainer c = createTestContainer1(); RectangleConstraint constraint = RectangleConstraint.NONE.toRangeWidth( new Range(40.0, 60.0)); Size2D s = c.arrange(null, constraint); assertEquals(60.0, s.width, EPSILON); assertEquals(33.0, s.height, EPSILON); } /** * Test arrangement with a range for the height and no width constraint. */ @Test public void testNR() { BlockContainer c = createTestContainer1(); RectangleConstraint constraint = RectangleConstraint.NONE.toRangeHeight( new Range(40.0, 60.0)); Size2D s = c.arrange(null, constraint); assertEquals(90.0, s.width, EPSILON); assertEquals(40.0, s.height, EPSILON); } private BlockContainer createTestContainer1() { Block b1 = new EmptyBlock(10, 11); Block b2 = new EmptyBlock(20, 22); Block b3 = new EmptyBlock(30, 33); BlockContainer result = new BlockContainer(new GridArrangement(1, 3)); result.add(b1); result.add(b2); result.add(b3); return result; } /** * The arrangement should be able to handle null blocks in the layout. */ @Test public void testNullBlock_FF() { BlockContainer c = new BlockContainer(new GridArrangement(1, 1)); c.add(null); Size2D s = c.arrange(null, new RectangleConstraint(20, 10)); assertEquals(20.0, s.getWidth(), EPSILON); assertEquals(10.0, s.getHeight(), EPSILON); } /** * The arrangement should be able to handle null blocks in the layout. */ @Test public void testNullBlock_FN() { BlockContainer c = new BlockContainer(new GridArrangement(1, 1)); c.add(null); Size2D s = c.arrange(null, RectangleConstraint.NONE.toFixedWidth(10)); assertEquals(10.0, s.getWidth(), EPSILON); assertEquals(0.0, s.getHeight(), EPSILON); } /** * The arrangement should be able to handle null blocks in the layout. */ @Test public void testNullBlock_FR() { BlockContainer c = new BlockContainer(new GridArrangement(1, 1)); c.add(null); Size2D s = c.arrange(null, new RectangleConstraint(30.0, new Range(5.0, 10.0))); assertEquals(30.0, s.getWidth(), EPSILON); assertEquals(5.0, s.getHeight(), EPSILON); } /** * The arrangement should be able to handle null blocks in the layout. */ @Test public void testNullBlock_NN() { BlockContainer c = new BlockContainer(new GridArrangement(1, 1)); c.add(null); Size2D s = c.arrange(null, RectangleConstraint.NONE); assertEquals(0.0, s.getWidth(), EPSILON); assertEquals(0.0, s.getHeight(), EPSILON); } /** * The arrangement should be able to handle less blocks than grid spaces. */ @Test public void testGridNotFull_FF() { Block b1 = new EmptyBlock(5, 5); BlockContainer c = new BlockContainer(new GridArrangement(2, 3)); c.add(b1); Size2D s = c.arrange(null, new RectangleConstraint(200, 100)); assertEquals(200.0, s.getWidth(), EPSILON); assertEquals(100.0, s.getHeight(), EPSILON); } /** * The arrangement should be able to handle less blocks than grid spaces. */ @Test public void testGridNotFull_FN() { Block b1 = new EmptyBlock(5, 5); BlockContainer c = new BlockContainer(new GridArrangement(2, 3)); c.add(b1); Size2D s = c.arrange(null, RectangleConstraint.NONE.toFixedWidth(30.0)); assertEquals(30.0, s.getWidth(), EPSILON); assertEquals(10.0, s.getHeight(), EPSILON); } /** * The arrangement should be able to handle less blocks than grid spaces. */ @Test public void testGridNotFull_FR() { Block b1 = new EmptyBlock(5, 5); BlockContainer c = new BlockContainer(new GridArrangement(2, 3)); c.add(b1); Size2D s = c.arrange(null, new RectangleConstraint(30.0, new Range(5.0, 10.0))); assertEquals(30.0, s.getWidth(), EPSILON); assertEquals(10.0, s.getHeight(), EPSILON); } /** * The arrangement should be able to handle less blocks than grid spaces. */ @Test public void testGridNotFull_NN() { Block b1 = new EmptyBlock(5, 5); BlockContainer c = new BlockContainer(new GridArrangement(2, 3)); c.add(b1); Size2D s = c.arrange(null, RectangleConstraint.NONE); assertEquals(15.0, s.getWidth(), EPSILON); assertEquals(10.0, s.getHeight(), EPSILON); } }
10,671
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
LineBorderTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/block/LineBorderTest.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.] * * -------------------- * LineBorderTests.java * -------------------- * (C) Copyright 2007-2012, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 16-Mar-2007 : Version 1 (DG); * 17-Jun-2012 : Remove JCommon dependencies (DG); * */ package org.jfree.chart.block; import org.jfree.chart.ui.RectangleInsets; 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; /** * Tests for the {@link LineBorder} class. */ public class LineBorderTest { /** * Confirm that the equals() method can distinguish all the required fields. */ @Test public void testEquals() { LineBorder b1 = new LineBorder(Color.RED, new BasicStroke(1.0f), new RectangleInsets(1.0, 1.0, 1.0, 1.0)); LineBorder b2 = new LineBorder(Color.RED, new BasicStroke(1.0f), new RectangleInsets(1.0, 1.0, 1.0, 1.0)); assertEquals(b1, b2); assertEquals(b2, b2); b1 = new LineBorder(Color.BLUE, new BasicStroke(1.0f), new RectangleInsets(1.0, 1.0, 1.0, 1.0)); assertFalse(b1.equals(b2)); b2 = new LineBorder(Color.BLUE, new BasicStroke(1.0f), new RectangleInsets(1.0, 1.0, 1.0, 1.0)); assertEquals(b1, b2); b1 = new LineBorder(Color.BLUE, new BasicStroke(1.1f), new RectangleInsets(1.0, 1.0, 1.0, 1.0)); assertFalse(b1.equals(b2)); b2 = new LineBorder(Color.BLUE, new BasicStroke(1.1f), new RectangleInsets(1.0, 1.0, 1.0, 1.0)); assertEquals(b1, b2); b1 = new LineBorder(Color.BLUE, new BasicStroke(1.1f), new RectangleInsets(1.0, 2.0, 3.0, 4.0)); assertFalse(b1.equals(b2)); b2 = new LineBorder(Color.BLUE, new BasicStroke(1.1f), new RectangleInsets(1.0, 2.0, 3.0, 4.0)); assertEquals(b1, b2); } /** * Immutable - cloning not necessary. */ @Test public void testCloning() throws CloneNotSupportedException { LineBorder b1 = new LineBorder(); assertFalse(b1 instanceof Cloneable); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { LineBorder b1 = new LineBorder(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.yellow), new BasicStroke(1.0f), new RectangleInsets(1.0, 1.0, 1.0, 1.0)); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(b1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); LineBorder b2 = (LineBorder) in.readObject(); in.close(); assertEquals(b1, b2); } }
4,574
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
LabelBlockTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/block/LabelBlockTest.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.] * * -------------------- * LabelBlockTests.java * -------------------- * (C) Copyright 2005-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 01-Sep-2005 : Version 1 (DG); * 16-Mar-2007 : Check GradientPaint in testSerialization() (DG); * 10-Feb-2009 : Added new fields to testEquals() (DG); * */ package org.jfree.chart.block; import org.jfree.chart.text.TextBlockAnchor; import org.jfree.chart.ui.RectangleAnchor; 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; /** * Some tests for the {@link LabelBlock} class. */ public class LabelBlockTest { /** * Confirm that the equals() method can distinguish all the required fields. */ @Test public void testEquals() { LabelBlock b1 = new LabelBlock("ABC", new Font("Dialog", Font.PLAIN, 12), Color.RED); LabelBlock b2 = new LabelBlock("ABC", new Font("Dialog", Font.PLAIN, 12), Color.RED); assertEquals(b1, b2); assertEquals(b2, b2); b1 = new LabelBlock("XYZ", new Font("Dialog", Font.PLAIN, 12), Color.RED); assertFalse(b1.equals(b2)); b2 = new LabelBlock("XYZ", new Font("Dialog", Font.PLAIN, 12), Color.RED); assertEquals(b1, b2); b1 = new LabelBlock("XYZ", new Font("Dialog", Font.BOLD, 12), Color.RED); assertFalse(b1.equals(b2)); b2 = new LabelBlock("XYZ", new Font("Dialog", Font.BOLD, 12), Color.RED); assertEquals(b1, b2); b1 = new LabelBlock("XYZ", new Font("Dialog", Font.BOLD, 12), Color.BLUE); assertFalse(b1.equals(b2)); b2 = new LabelBlock("XYZ", new Font("Dialog", Font.BOLD, 12), Color.BLUE); assertEquals(b1, b2); b1.setToolTipText("Tooltip"); assertFalse(b1.equals(b2)); b2.setToolTipText("Tooltip"); assertEquals(b1, b2); b1.setURLText("URL"); assertFalse(b1.equals(b2)); b2.setURLText("URL"); assertEquals(b1, b2); b1.setContentAlignmentPoint(TextBlockAnchor.CENTER_RIGHT); assertFalse(b1.equals(b2)); b2.setContentAlignmentPoint(TextBlockAnchor.CENTER_RIGHT); assertEquals(b1, b2); b1.setTextAnchor(RectangleAnchor.BOTTOM_RIGHT); assertFalse(b1.equals(b2)); b2.setTextAnchor(RectangleAnchor.BOTTOM_RIGHT); assertEquals(b1, b2); } /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { LabelBlock b1 = new LabelBlock("ABC", new Font("Dialog", Font.PLAIN, 12), Color.RED); LabelBlock b2 = (LabelBlock) b1.clone(); assertNotSame(b1, b2); assertSame(b1.getClass(), b2.getClass()); assertEquals(b1, b2); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { GradientPaint gp = new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.BLUE); LabelBlock b1 = new LabelBlock("ABC", new Font("Dialog", Font.PLAIN, 12), gp); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(b1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); LabelBlock b2 = (LabelBlock) in.readObject(); in.close(); assertEquals(b1, b2); } }
5,433
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
ColumnArrangementTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/block/ColumnArrangementTest.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.] * * --------------------------- * ColumnArrangementTests.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); * 17-Jun-2012 : Removed JCommon dependencies (DG); * */ package org.jfree.chart.block; import org.jfree.chart.ui.HorizontalAlignment; import org.jfree.chart.ui.VerticalAlignment; 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 ColumnArrangement} class. */ public class ColumnArrangementTest { /** * Confirm that the equals() method can distinguish all the required fields. */ @Test public void testEquals() { ColumnArrangement c1 = new ColumnArrangement(HorizontalAlignment.LEFT, VerticalAlignment.TOP, 1.0, 2.0); ColumnArrangement c2 = new ColumnArrangement(HorizontalAlignment.LEFT, VerticalAlignment.TOP, 1.0, 2.0); assertEquals(c1, c2); assertEquals(c2, c1); c1 = new ColumnArrangement(HorizontalAlignment.RIGHT, VerticalAlignment.TOP, 1.0, 2.0); assertFalse(c1.equals(c2)); c2 = new ColumnArrangement(HorizontalAlignment.RIGHT, VerticalAlignment.TOP, 1.0, 2.0); assertEquals(c1, c2); c1 = new ColumnArrangement(HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, 1.0, 2.0); assertFalse(c1.equals(c2)); c2 = new ColumnArrangement(HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, 1.0, 2.0); assertEquals(c1, c2); c1 = new ColumnArrangement(HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, 1.1, 2.0); assertFalse(c1.equals(c2)); c2 = new ColumnArrangement(HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, 1.1, 2.0); assertEquals(c1, c2); c1 = new ColumnArrangement(HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, 1.1, 2.2); assertFalse(c1.equals(c2)); c2 = new ColumnArrangement(HorizontalAlignment.RIGHT, VerticalAlignment.BOTTOM, 1.1, 2.2); assertEquals(c1, c2); } /** * Immutable - cloning is not necessary. */ @Test public void testCloning() throws CloneNotSupportedException { FlowArrangement f1 = new FlowArrangement(); assertFalse(f1 instanceof Cloneable); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { FlowArrangement f1 = new FlowArrangement(HorizontalAlignment.LEFT, VerticalAlignment.TOP, 1.0, 2.0); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(f1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); FlowArrangement f2 = (FlowArrangement) in.readObject(); in.close(); assertEquals(f1, f2); } }
4,802
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
AbstractBlockTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/block/AbstractBlockTest.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.] * * ----------------------- * AbstractBlockTests.java * ----------------------- * (C) Copyright 2007-2012, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 16-Mar-2007 : Version 1 (DG); * 17-Jun-2012 : Removed JCommon dependencies (DG); * */ package org.jfree.chart.block; import org.jfree.chart.ui.RectangleInsets; import org.junit.Test; import java.awt.Color; 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 AbstractBlock} class. */ public class AbstractBlockTest { /** * Confirm that the equals() method can distinguish all the required fields. */ @Test public void testEquals() { EmptyBlock b1 = new EmptyBlock(1.0, 2.0); EmptyBlock b2 = new EmptyBlock(1.0, 2.0); assertEquals(b1, b2); assertEquals(b2, b2); b1.setID("Test"); assertFalse(b1.equals(b2)); b2.setID("Test"); assertEquals(b1, b2); b1.setMargin(new RectangleInsets(1.0, 2.0, 3.0, 4.0)); assertFalse(b1.equals(b2)); b2.setMargin(new RectangleInsets(1.0, 2.0, 3.0, 4.0)); assertEquals(b1, b2); b1.setFrame(new BlockBorder(Color.RED)); assertFalse(b1.equals(b2)); b2.setFrame(new BlockBorder(Color.RED)); assertEquals(b1, b2); b1.setPadding(new RectangleInsets(2.0, 4.0, 6.0, 8.0)); assertFalse(b1.equals(b2)); b2.setPadding(new RectangleInsets(2.0, 4.0, 6.0, 8.0)); assertEquals(b1, b2); b1.setWidth(1.23); assertFalse(b1.equals(b2)); b2.setWidth(1.23); assertEquals(b1, b2); b1.setHeight(4.56); assertFalse(b1.equals(b2)); b2.setHeight(4.56); assertEquals(b1, b2); b1.setBounds(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); assertFalse(b1.equals(b2)); b2.setBounds(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); assertEquals(b1, b2); b1 = new EmptyBlock(1.1, 2.0); assertFalse(b1.equals(b2)); b2 = new EmptyBlock(1.1, 2.0); assertEquals(b1, b2); b1 = new EmptyBlock(1.1, 2.2); assertFalse(b1.equals(b2)); b2 = new EmptyBlock(1.1, 2.2); assertEquals(b1, b2); } /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { EmptyBlock b1 = new EmptyBlock(1.0, 2.0); Rectangle2D bounds1 = new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0); b1.setBounds(bounds1); EmptyBlock b2 = (EmptyBlock) b1.clone(); assertNotSame(b1, b2); assertSame(b1.getClass(), b2.getClass()); assertEquals(b1, b2); bounds1.setFrame(2.0, 4.0, 6.0, 8.0); assertFalse(b1.equals(b2)); b2.setBounds(new Rectangle2D.Double(2.0, 4.0, 6.0, 8.0)); assertEquals(b1, b2); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { EmptyBlock b1 = new EmptyBlock(1.0, 2.0); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(b1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); EmptyBlock b2 = (EmptyBlock) in.readObject(); in.close(); assertEquals(b1, b2); } }
5,214
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
RectangleConstraintTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/block/RectangleConstraintTest.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.] * * ----------------------------- * RectangleConstraintTests.java * ----------------------------- * (C) Copyright 2004-2012, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 25-Oct-2004 : Version 1 (DG); * 17-Jun-2012 : Removed JCommon dependencies (DG); * */ package org.jfree.chart.block; import org.jfree.chart.ui.Size2D; import org.jfree.data.Range; import org.junit.Test; import static org.junit.Assert.assertEquals; /** * Tests for the {@link RectangleConstraint} class. */ public class RectangleConstraintTest { private static final double EPSILON = 0.0000000001; /** * Run some checks on the constrained size calculation. */ @Test public void testCalculateConstrainedSize() { Size2D s; // NONE / NONE RectangleConstraint c1 = RectangleConstraint.NONE; s = c1.calculateConstrainedSize(new Size2D(1.2, 3.4)); assertEquals(s.width, 1.2, EPSILON); assertEquals(s.height, 3.4, EPSILON); // NONE / RANGE RectangleConstraint c2 = new RectangleConstraint( 0.0, new Range(0.0, 0.0), LengthConstraintType.NONE, 0.0, new Range(2.0, 3.0), LengthConstraintType.RANGE ); s = c2.calculateConstrainedSize(new Size2D(1.2, 3.4)); assertEquals(s.width, 1.2, EPSILON); assertEquals(s.height, 3.0, EPSILON); // NONE / FIXED RectangleConstraint c3 = new RectangleConstraint( 0.0, null, LengthConstraintType.NONE, 9.9, null, LengthConstraintType.FIXED ); s = c3.calculateConstrainedSize(new Size2D(1.2, 3.4)); assertEquals(s.width, 1.2, EPSILON); assertEquals(s.height, 9.9, EPSILON); // RANGE / NONE RectangleConstraint c4 = new RectangleConstraint( 0.0, new Range(2.0, 3.0), LengthConstraintType.RANGE, 0.0, new Range(0.0, 0.0), LengthConstraintType.NONE ); s = c4.calculateConstrainedSize(new Size2D(1.2, 3.4)); assertEquals(s.width, 2.0, EPSILON); assertEquals(s.height, 3.4, EPSILON); // RANGE / RANGE RectangleConstraint c5 = new RectangleConstraint( 0.0, new Range(2.0, 3.0), LengthConstraintType.RANGE, 0.0, new Range(2.0, 3.0), LengthConstraintType.RANGE ); s = c5.calculateConstrainedSize(new Size2D(1.2, 3.4)); assertEquals(s.width, 2.0, EPSILON); assertEquals(s.height, 3.0, EPSILON); // RANGE / FIXED RectangleConstraint c6 = new RectangleConstraint( 0.0, null, LengthConstraintType.NONE, 9.9, null, LengthConstraintType.FIXED ); s = c6.calculateConstrainedSize(new Size2D(1.2, 3.4)); assertEquals(s.width, 1.2, EPSILON); assertEquals(s.height, 9.9, EPSILON); // FIXED / NONE RectangleConstraint c7 = RectangleConstraint.NONE; s = c7.calculateConstrainedSize(new Size2D(1.2, 3.4)); assertEquals(s.width, 1.2, EPSILON); assertEquals(s.height, 3.4, EPSILON); // FIXED / RANGE RectangleConstraint c8 = new RectangleConstraint( 0.0, new Range(0.0, 0.0), LengthConstraintType.NONE, 0.0, new Range(2.0, 3.0), LengthConstraintType.RANGE ); s = c8.calculateConstrainedSize(new Size2D(1.2, 3.4)); assertEquals(s.width, 1.2, EPSILON); assertEquals(s.height, 3.0, EPSILON); // FIXED / FIXED RectangleConstraint c9 = new RectangleConstraint( 0.0, null, LengthConstraintType.NONE, 9.9, null, LengthConstraintType.FIXED ); s = c9.calculateConstrainedSize(new Size2D(1.2, 3.4)); assertEquals(s.width, 1.2, EPSILON); assertEquals(s.height, 9.9, EPSILON); } }
5,132
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
BlockBorderTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/block/BlockBorderTest.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.] * * --------------------- * BlockBorderTests.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); * 23-Feb-2005 : Extended equals() test (DG); * 17-Jun-2012 : Removed JCommon dependencies (DG); * */ package org.jfree.chart.block; import org.jfree.chart.ui.RectangleInsets; import org.jfree.chart.util.UnitType; 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; /** * Tests for the {@link BlockBorder} class. */ public class BlockBorderTest { /** * Confirm that the equals() method can distinguish all the required fields. */ @Test public void testEquals() { BlockBorder b1 = new BlockBorder(new RectangleInsets(1.0, 2.0, 3.0, 4.0), Color.RED); BlockBorder b2 = new BlockBorder(new RectangleInsets(1.0, 2.0, 3.0, 4.0), Color.RED); assertEquals(b1, b2); assertEquals(b2, b2); // insets b1 = new BlockBorder(new RectangleInsets(UnitType.RELATIVE, 1.0, 2.0, 3.0, 4.0), Color.RED); assertFalse(b1.equals(b2)); b2 = new BlockBorder(new RectangleInsets(UnitType.RELATIVE, 1.0, 2.0, 3.0, 4.0), Color.RED); assertEquals(b1, b2); // paint b1 = new BlockBorder(new RectangleInsets(1.0, 2.0, 3.0, 4.0), Color.BLUE); assertFalse(b1.equals(b2)); b2 = new BlockBorder(new RectangleInsets(1.0, 2.0, 3.0, 4.0), Color.BLUE); assertEquals(b1, b2); } /** * Immutable - cloning not necessary. */ @Test public void testCloning() throws CloneNotSupportedException { BlockBorder b1 = new BlockBorder(); assertFalse(b1 instanceof Cloneable); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { BlockBorder b1 = new BlockBorder(new RectangleInsets(1.0, 2.0, 3.0, 4.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(b1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); BlockBorder b2 = (BlockBorder) in.readObject(); in.close(); assertEquals(b1, b2); } }
4,249
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
CombinedRangeXYPlotTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/plot/CombinedRangeXYPlotTest.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.] * * ----------------------------- * CombinedRangeXYPlotTests.java * ----------------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 21-Aug-2003 : Version 1 (DG); * 03-Jan-2008 : Added testNotification (DG); * */ package org.jfree.chart.plot; import org.jfree.chart.JFreeChart; import org.jfree.chart.annotations.XYTextAnnotation; import org.jfree.chart.axis.AxisLocation; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.event.ChartChangeEvent; import org.jfree.chart.event.ChartChangeListener; import org.jfree.chart.renderer.xy.StandardXYItemRenderer; import org.jfree.chart.renderer.xy.XYItemRenderer; import org.jfree.data.xy.XYDataset; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; import org.junit.Test; import java.awt.Font; 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.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 CombinedRangeXYPlot} class. */ public class CombinedRangeXYPlotTest implements ChartChangeListener { /** A list of the events received. */ private List<ChartChangeEvent> events = new java.util.ArrayList<ChartChangeEvent>(); /** * Receives a chart change event. * * @param event the event. */ @Override public void chartChanged(ChartChangeEvent event) { this.events.add(event); } /** * Test the equals method. */ @Test public void testEquals() { CombinedRangeXYPlot plot1 = createPlot(); CombinedRangeXYPlot plot2 = createPlot(); assertEquals(plot1, plot2); assertEquals(plot2, plot1); } /** * This is a test to replicate the bug report 987080. */ @Test public void testRemoveSubplot() { CombinedRangeXYPlot plot = new CombinedRangeXYPlot(); XYPlot plot1 = new XYPlot(); XYPlot plot2 = new XYPlot(); plot.add(plot1); plot.add(plot2); // remove plot2, but plot1 is removed instead plot.remove(plot2); List plots = plot.getSubplots(); assertSame(plots.get(0), plot1); } /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { CombinedRangeXYPlot plot1 = createPlot(); CombinedRangeXYPlot plot2 = (CombinedRangeXYPlot) plot1.clone(); assertNotSame(plot1, plot2); assertSame(plot1.getClass(), plot2.getClass()); assertEquals(plot1, plot2); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { CombinedRangeXYPlot plot1 = createPlot(); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(plot1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); CombinedRangeXYPlot plot2 = (CombinedRangeXYPlot) in.readObject(); in.close(); assertEquals(plot1, plot2); } /** * Check that only one chart change event is generated by a change to a * subplot. */ @Test public void testNotification() { CombinedRangeXYPlot plot = createPlot(); JFreeChart chart = new JFreeChart(plot); chart.addChangeListener(this); XYPlot subplot1 = (XYPlot) plot.getSubplots().get(0); NumberAxis xAxis = (NumberAxis) subplot1.getDomainAxis(); xAxis.setAutoRangeIncludesZero(!xAxis.getAutoRangeIncludesZero()); assertEquals(1, this.events.size()); // a redraw should NOT trigger another change event BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); this.events.clear(); chart.draw(g2, new Rectangle2D.Double(0.0, 0.0, 200.0, 100.0)); assertTrue(this.events.isEmpty()); } /** * Creates a sample dataset. * * @return Series 1. */ private XYDataset createDataset1() { XYSeries series1 = new XYSeries("Series 1"); series1.add(10.0, 12353.3); series1.add(20.0, 13734.4); series1.add(30.0, 14525.3); series1.add(40.0, 13984.3); series1.add(50.0, 12999.4); series1.add(60.0, 14274.3); series1.add(70.0, 15943.5); series1.add(80.0, 14845.3); series1.add(90.0, 14645.4); series1.add(100.0, 16234.6); series1.add(110.0, 17232.3); series1.add(120.0, 14232.2); series1.add(130.0, 13102.2); series1.add(140.0, 14230.2); series1.add(150.0, 11235.2); XYSeries series2 = new XYSeries("Series 2"); series2.add(10.0, 15000.3); series2.add(20.0, 11000.4); series2.add(30.0, 17000.3); series2.add(40.0, 15000.3); series2.add(50.0, 14000.4); series2.add(60.0, 12000.3); series2.add(70.0, 11000.5); series2.add(80.0, 12000.3); series2.add(90.0, 13000.4); series2.add(100.0, 12000.6); series2.add(110.0, 13000.3); series2.add(120.0, 17000.2); series2.add(130.0, 18000.2); series2.add(140.0, 16000.2); series2.add(150.0, 17000.2); XYSeriesCollection collection = new XYSeriesCollection(); collection.addSeries(series1); collection.addSeries(series2); return collection; } /** * Creates a sample dataset. * * @return Series 2. */ private XYDataset createDataset2() { // create dataset 2... XYSeries series2 = new XYSeries("Series 3"); series2.add(10.0, 16853.2); series2.add(20.0, 19642.3); series2.add(30.0, 18253.5); series2.add(40.0, 15352.3); series2.add(50.0, 13532.0); series2.add(100.0, 12635.3); series2.add(110.0, 13998.2); series2.add(120.0, 11943.2); series2.add(130.0, 16943.9); series2.add(140.0, 17843.2); series2.add(150.0, 16495.3); series2.add(160.0, 17943.6); series2.add(170.0, 18500.7); series2.add(180.0, 19595.9); return new XYSeriesCollection(series2); } /** * Creates a sample plot. * * @return A sample plot. */ private CombinedRangeXYPlot createPlot() { // create subplot 1... XYDataset data1 = createDataset1(); XYItemRenderer renderer1 = new StandardXYItemRenderer(); NumberAxis xAxis1 = new NumberAxis("X1"); XYPlot subplot1 = new XYPlot(data1, xAxis1, null, renderer1); subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); XYTextAnnotation annotation = new XYTextAnnotation("Hello!", 50.0, 10000.0); annotation.setFont(new Font("SansSerif", Font.PLAIN, 9)); annotation.setRotationAngle(Math.PI / 4.0); subplot1.addAnnotation(annotation); // create subplot 2... XYDataset data2 = createDataset2(); XYItemRenderer renderer2 = new StandardXYItemRenderer(); NumberAxis xAxis2 = new NumberAxis("X2"); xAxis2.setAutoRangeIncludesZero(false); XYPlot subplot2 = new XYPlot(data2, xAxis2, null, renderer2); subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); // parent plot... CombinedRangeXYPlot plot = new CombinedRangeXYPlot(new NumberAxis( "Range")); plot.setGap(10.0); // add the subplots... plot.add(subplot1, 1); plot.add(subplot2, 1); plot.setOrientation(PlotOrientation.VERTICAL); return plot; } }
9,579
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
ValueMarkerTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/plot/ValueMarkerTest.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.] * * --------------------- * ValueMarkerTests.java * --------------------- * (C) Copyright 2003-2012, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 18-Aug-2003 : Version 1 (DG); * 14-Jun-2004 : Renamed MarkerTests --> ValueMarkerTests (DG); * 01-Jun-2005 : Strengthened equals() test (DG); * 05-Sep-2006 : Added checks for MarkerChangeEvent generation (DG); * 26-Sep-2007 : Added test1802195() method (DG); * 08-Oct-2007 : Added test1808376() method (DG); * 17-Jun-2012 : Removed JCommon dependencies (DG); * */ package org.jfree.chart.plot; import org.jfree.chart.event.MarkerChangeEvent; import org.jfree.chart.event.MarkerChangeListener; import org.jfree.chart.ui.LengthAdjustmentType; import org.jfree.chart.ui.RectangleAnchor; import org.jfree.chart.ui.RectangleInsets; 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.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 ValueMarker} class. */ public class ValueMarkerTest implements MarkerChangeListener { MarkerChangeEvent lastEvent; /** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { Marker m1 = new ValueMarker(45.0); Marker m2 = new ValueMarker(45.0); assertEquals(m1, m2); assertEquals(m2, m1); m1.setPaint(new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.RED)); assertFalse(m1.equals(m2)); m2.setPaint(new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.RED)); assertEquals(m1, m2); BasicStroke stroke = new BasicStroke(2.2f); m1.setStroke(stroke); assertFalse(m1.equals(m2)); m2.setStroke(stroke); assertEquals(m1, m2); m1.setOutlinePaint(new GradientPaint(4.0f, 3.0f, Color.yellow, 2.0f, 1.0f, Color.WHITE)); assertFalse(m1.equals(m2)); m2.setOutlinePaint(new GradientPaint(4.0f, 3.0f, Color.yellow, 2.0f, 1.0f, Color.WHITE)); assertEquals(m1, m2); m1.setOutlineStroke(stroke); assertFalse(m1.equals(m2)); m2.setOutlineStroke(stroke); assertEquals(m1, m2); m1.setAlpha(0.1f); assertFalse(m1.equals(m2)); m2.setAlpha(0.1f); assertEquals(m1, m2); m1.setLabel("New Label"); assertFalse(m1.equals(m2)); m2.setLabel("New Label"); assertEquals(m1, m2); m1.setLabelFont(new Font("SansSerif", Font.PLAIN, 10)); assertFalse(m1.equals(m2)); m2.setLabelFont(new Font("SansSerif", Font.PLAIN, 10)); assertEquals(m1, m2); m1.setLabelPaint(new GradientPaint(1.0f, 2.0f, Color.BLUE, 3.0f, 4.0f, Color.yellow)); assertFalse(m1.equals(m2)); m2.setLabelPaint(new GradientPaint(1.0f, 2.0f, Color.BLUE, 3.0f, 4.0f, Color.yellow)); assertEquals(m1, m2); m1.setLabelAnchor(RectangleAnchor.TOP_RIGHT); assertFalse(m1.equals(m2)); m2.setLabelAnchor(RectangleAnchor.TOP_RIGHT); assertEquals(m1, m2); m1.setLabelTextAnchor(TextAnchor.BASELINE_RIGHT); assertFalse(m1.equals(m2)); m2.setLabelTextAnchor(TextAnchor.BASELINE_RIGHT); assertEquals(m1, m2); m1.setLabelOffset(new RectangleInsets(10.0, 10.0, 10.0, 10.0)); assertFalse(m1.equals(m2)); m2.setLabelOffset(new RectangleInsets(10.0, 10.0, 10.0, 10.0)); assertEquals(m1, m2); m1.setLabelOffsetType(LengthAdjustmentType.EXPAND); assertFalse(m1.equals(m2)); m2.setLabelOffsetType(LengthAdjustmentType.EXPAND); assertEquals(m1, m2); m1 = new ValueMarker(12.3); m2 = new ValueMarker(45.6); assertFalse(m1.equals(m2)); m2 = new ValueMarker(12.3); assertEquals(m1, m2); } /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { ValueMarker m1 = new ValueMarker(25.0); ValueMarker m2 = (ValueMarker) m1.clone(); assertNotSame(m1, m2); assertSame(m1.getClass(), m2.getClass()); assertEquals(m1, m2); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { ValueMarker m1 = new ValueMarker(25.0); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(m1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); ValueMarker m2 = (ValueMarker) in.readObject(); in.close(); boolean b = m1.equals(m2); assertTrue(b); } private static final double EPSILON = 0.000000001; /** * Some checks for the getValue() and setValue() methods. */ @Test public void testGetSetValue() { ValueMarker m = new ValueMarker(1.1); m.addChangeListener(this); this.lastEvent = null; assertEquals(1.1, m.getValue(), EPSILON); m.setValue(33.3); assertEquals(33.3, m.getValue(), EPSILON); assertEquals(m, this.lastEvent.getMarker()); } /** * Records the last event. * * @param event the last event. */ @Override public void markerChanged(MarkerChangeEvent event) { this.lastEvent = event; } /** * A test for bug 1802195. */ @Test public void test1802195() throws IOException, ClassNotFoundException { ValueMarker m1 = new ValueMarker(25.0); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(m1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); ValueMarker m2 = (ValueMarker) in.readObject(); in.close(); assertEquals(m1, m2); m2.setValue(-10.0); } /** * A test for bug report 1808376. */ @Test public void test1808376() { Stroke stroke = new BasicStroke(1.0f); Stroke outlineStroke = new BasicStroke(2.0f); ValueMarker m = new ValueMarker(1.0, Color.RED, stroke, Color.BLUE, outlineStroke, 0.5f); assertEquals(1.0, m.getValue(), EPSILON); assertEquals(Color.RED, m.getPaint()); assertEquals(stroke, m.getStroke()); assertEquals(Color.BLUE, m.getOutlinePaint()); assertEquals(outlineStroke, m.getOutlineStroke()); assertEquals(0.5f, m.getAlpha(), EPSILON); } }
8,765
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
PiePlotTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/plot/PiePlotTest.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.] * * ----------------- * PiePlotTests.java * ----------------- * (C) Copyright 2003-2014, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 18-Mar-2003 : Version 1 (DG); * 10-May-2005 : Strengthened equals() test (DG); * 27-Sep-2006 : Added tests for the getBaseSectionPaint() method (DG); * 23-Nov-2006 : Additional equals() and clone() tests (DG); * 17-Apr-2007 : Added check for label generator that returns a null label (DG); * 31-Mar-2008 : Updated testEquals() (DG); * 10-Jul-2009 : Updated testEquals() (DG); * 10-Mar-2014 : Removed LegendItemCollection (DG); * */ package org.jfree.chart.plot; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; import org.jfree.chart.labels.PieSectionLabelGenerator; import org.jfree.chart.labels.StandardPieSectionLabelGenerator; import org.jfree.chart.labels.StandardPieToolTipGenerator; import org.jfree.chart.urls.CustomPieURLGenerator; import org.jfree.chart.urls.StandardPieURLGenerator; import org.jfree.chart.util.DefaultShadowGenerator; import org.jfree.chart.util.Rotation; import org.jfree.data.general.DefaultPieDataset; import org.jfree.data.general.PieDataset; import org.junit.Test; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; import java.awt.GradientPaint; import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.Stroke; 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.text.AttributedString; 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.assertSame; import static org.junit.Assert.fail; /** * Some tests for the {@link PiePlot} class. */ public class PiePlotTest { /** * Test the equals() method. */ @Test public void testEquals() { PiePlot plot1 = new PiePlot(); PiePlot plot2 = new PiePlot(); assertEquals(plot1, plot2); assertEquals(plot2, plot1); // pieIndex... plot1.setPieIndex(99); assertFalse(plot1.equals(plot2)); plot2.setPieIndex(99); assertEquals(plot1, plot2); // interiorGap... plot1.setInteriorGap(0.15); assertFalse(plot1.equals(plot2)); plot2.setInteriorGap(0.15); assertEquals(plot1, plot2); // circular plot1.setCircular(!plot1.isCircular()); assertFalse(plot1.equals(plot2)); plot2.setCircular(false); assertEquals(plot1, plot2); // startAngle plot1.setStartAngle(Math.PI); assertFalse(plot1.equals(plot2)); plot2.setStartAngle(Math.PI); assertEquals(plot1, plot2); // direction plot1.setDirection(Rotation.ANTICLOCKWISE); assertFalse(plot1.equals(plot2)); plot2.setDirection(Rotation.ANTICLOCKWISE); assertEquals(plot1, plot2); // ignoreZeroValues plot1.setIgnoreZeroValues(true); plot2.setIgnoreZeroValues(false); assertFalse(plot1.equals(plot2)); plot2.setIgnoreZeroValues(true); assertEquals(plot1, plot2); // ignoreNullValues plot1.setIgnoreNullValues(true); plot2.setIgnoreNullValues(false); assertFalse(plot1.equals(plot2)); plot2.setIgnoreNullValues(true); assertEquals(plot1, plot2); // sectionPaintMap plot1.setSectionPaint("A", new GradientPaint(1.0f, 2.0f, Color.BLUE, 3.0f, 4.0f, Color.WHITE)); assertFalse(plot1.equals(plot2)); plot2.setSectionPaint("A", new GradientPaint(1.0f, 2.0f, Color.BLUE, 3.0f, 4.0f, Color.WHITE)); assertEquals(plot1, plot2); // baseSectionPaint plot1.setBaseSectionPaint(new GradientPaint(1.0f, 2.0f, Color.BLACK, 3.0f, 4.0f, Color.WHITE)); assertFalse(plot1.equals(plot2)); plot2.setBaseSectionPaint(new GradientPaint(1.0f, 2.0f, Color.BLACK, 3.0f, 4.0f, Color.WHITE)); assertEquals(plot1, plot2); // sectionOutlinesVisible plot1.setSectionOutlinesVisible(false); assertFalse(plot1.equals(plot2)); plot2.setSectionOutlinesVisible(false); assertEquals(plot1, plot2); // sectionOutlinePaintList plot1.setSectionOutlinePaint("A", new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.WHITE)); assertFalse(plot1.equals(plot2)); plot2.setSectionOutlinePaint("A", new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.WHITE)); assertEquals(plot1, plot2); // baseSectionOutlinePaint plot1.setBaseSectionOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.gray, 3.0f, 4.0f, Color.WHITE)); assertFalse(plot1.equals(plot2)); plot2.setBaseSectionOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.gray, 3.0f, 4.0f, Color.WHITE)); assertEquals(plot1, plot2); // sectionOutlineStrokeList plot1.setSectionOutlineStroke("A", new BasicStroke(1.0f)); assertFalse(plot1.equals(plot2)); plot2.setSectionOutlineStroke("A", new BasicStroke(1.0f)); assertEquals(plot1, plot2); // baseSectionOutlineStroke plot1.setBaseSectionOutlineStroke(new BasicStroke(1.0f)); assertFalse(plot1.equals(plot2)); plot2.setBaseSectionOutlineStroke(new BasicStroke(1.0f)); assertEquals(plot1, plot2); // shadowPaint plot1.setShadowPaint(new GradientPaint(1.0f, 2.0f, Color.orange, 3.0f, 4.0f, Color.WHITE)); assertFalse(plot1.equals(plot2)); plot2.setShadowPaint(new GradientPaint(1.0f, 2.0f, Color.orange, 3.0f, 4.0f, Color.WHITE)); assertEquals(plot1, plot2); // shadowXOffset plot1.setShadowXOffset(4.4); assertFalse(plot1.equals(plot2)); plot2.setShadowXOffset(4.4); assertEquals(plot1, plot2); // shadowYOffset plot1.setShadowYOffset(4.4); assertFalse(plot1.equals(plot2)); plot2.setShadowYOffset(4.4); assertEquals(plot1, plot2); // labelFont plot1.setLabelFont(new Font("Serif", Font.PLAIN, 18)); assertFalse(plot1.equals(plot2)); plot2.setLabelFont(new Font("Serif", Font.PLAIN, 18)); assertEquals(plot1, plot2); // labelPaint plot1.setLabelPaint(new GradientPaint(1.0f, 2.0f, Color.darkGray, 3.0f, 4.0f, Color.WHITE)); assertFalse(plot1.equals(plot2)); plot2.setLabelPaint(new GradientPaint(1.0f, 2.0f, Color.darkGray, 3.0f, 4.0f, Color.WHITE)); assertEquals(plot1, plot2); // labelBackgroundPaint plot1.setLabelBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.WHITE)); assertFalse(plot1.equals(plot2)); plot2.setLabelBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.WHITE)); assertEquals(plot1, plot2); // labelOutlinePaint plot1.setLabelOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.BLUE, 3.0f, 4.0f, Color.WHITE)); assertFalse(plot1.equals(plot2)); plot2.setLabelOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.BLUE, 3.0f, 4.0f, Color.WHITE)); assertEquals(plot1, plot2); // labelOutlineStroke Stroke s = new BasicStroke(1.1f); plot1.setLabelOutlineStroke(s); assertFalse(plot1.equals(plot2)); plot2.setLabelOutlineStroke(s); assertEquals(plot1, plot2); // labelShadowPaint plot1.setLabelShadowPaint(new GradientPaint(1.0f, 2.0f, Color.yellow, 3.0f, 4.0f, Color.WHITE)); assertFalse(plot1.equals(plot2)); plot2.setLabelShadowPaint(new GradientPaint(1.0f, 2.0f, Color.yellow, 3.0f, 4.0f, Color.WHITE)); assertEquals(plot1, plot2); // explodePercentages plot1.setExplodePercent("A", 0.33); assertFalse(plot1.equals(plot2)); plot2.setExplodePercent("A", 0.33); assertEquals(plot1, plot2); // labelGenerator plot1.setLabelGenerator(new StandardPieSectionLabelGenerator( "{2}{1}{0}")); assertFalse(plot1.equals(plot2)); plot2.setLabelGenerator(new StandardPieSectionLabelGenerator( "{2}{1}{0}")); assertEquals(plot1, plot2); // labelFont Font f = new Font("SansSerif", Font.PLAIN, 20); plot1.setLabelFont(f); assertFalse(plot1.equals(plot2)); plot2.setLabelFont(f); assertEquals(plot1, plot2); // labelPaint plot1.setLabelPaint(new GradientPaint(1.0f, 2.0f, Color.magenta, 3.0f, 4.0f, Color.WHITE)); assertFalse(plot1.equals(plot2)); plot2.setLabelPaint(new GradientPaint(1.0f, 2.0f, Color.magenta, 3.0f, 4.0f, Color.WHITE)); assertEquals(plot1, plot2); // maximumLabelWidth plot1.setMaximumLabelWidth(0.33); assertFalse(plot1.equals(plot2)); plot2.setMaximumLabelWidth(0.33); assertEquals(plot1, plot2); // labelGap plot1.setLabelGap(0.11); assertFalse(plot1.equals(plot2)); plot2.setLabelGap(0.11); assertEquals(plot1, plot2); // links visible plot1.setLabelLinksVisible(false); assertFalse(plot1.equals(plot2)); plot2.setLabelLinksVisible(false); assertEquals(plot1, plot2); plot1.setLabelLinkStyle(PieLabelLinkStyle.QUAD_CURVE); assertFalse(plot1.equals(plot2)); plot2.setLabelLinkStyle(PieLabelLinkStyle.QUAD_CURVE); assertEquals(plot1, plot2); // linkMargin plot1.setLabelLinkMargin(0.11); assertFalse(plot1.equals(plot2)); plot2.setLabelLinkMargin(0.11); assertEquals(plot1, plot2); // labelLinkPaint plot1.setLabelLinkPaint(new GradientPaint(1.0f, 2.0f, Color.magenta, 3.0f, 4.0f, Color.WHITE)); assertFalse(plot1.equals(plot2)); plot2.setLabelLinkPaint(new GradientPaint(1.0f, 2.0f, Color.magenta, 3.0f, 4.0f, Color.WHITE)); assertEquals(plot1, plot2); // labelLinkStroke plot1.setLabelLinkStroke(new BasicStroke(1.0f)); assertFalse(plot1.equals(plot2)); plot2.setLabelLinkStroke(new BasicStroke(1.0f)); assertEquals(plot1, plot2); // toolTipGenerator plot1.setToolTipGenerator( new StandardPieToolTipGenerator("{2}{1}{0}") ); assertFalse(plot1.equals(plot2)); plot2.setToolTipGenerator( new StandardPieToolTipGenerator("{2}{1}{0}") ); assertEquals(plot1, plot2); // urlGenerator plot1.setURLGenerator(new StandardPieURLGenerator("xx")); assertFalse(plot1.equals(plot2)); plot2.setURLGenerator(new StandardPieURLGenerator("xx")); assertEquals(plot1, plot2); // minimumArcAngleToDraw plot1.setMinimumArcAngleToDraw(1.0); assertFalse(plot1.equals(plot2)); plot2.setMinimumArcAngleToDraw(1.0); assertEquals(plot1, plot2); // legendItemShape plot1.setLegendItemShape(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); assertFalse(plot1.equals(plot2)); plot2.setLegendItemShape(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); assertEquals(plot1, plot2); // legendLabelGenerator plot1.setLegendLabelGenerator(new StandardPieSectionLabelGenerator( "{0} --> {1}")); assertFalse(plot1.equals(plot2)); plot2.setLegendLabelGenerator(new StandardPieSectionLabelGenerator( "{0} --> {1}")); assertEquals(plot1, plot2); // legendLabelToolTipGenerator plot1.setLegendLabelToolTipGenerator( new StandardPieSectionLabelGenerator("{0} is {1}")); assertFalse(plot1.equals(plot2)); plot2.setLegendLabelToolTipGenerator( new StandardPieSectionLabelGenerator("{0} is {1}")); assertEquals(plot1, plot2); // legendLabelURLGenerator plot1.setLegendLabelURLGenerator(new StandardPieURLGenerator( "index.html")); assertFalse(plot1.equals(plot2)); plot2.setLegendLabelURLGenerator(new StandardPieURLGenerator( "index.html")); assertEquals(plot1, plot2); // autoPopulateSectionPaint plot1.setAutoPopulateSectionPaint(false); assertFalse(plot1.equals(plot2)); plot2.setAutoPopulateSectionPaint(false); assertEquals(plot1, plot2); // autoPopulateSectionOutlinePaint plot1.setAutoPopulateSectionOutlinePaint(true); assertFalse(plot1.equals(plot2)); plot2.setAutoPopulateSectionOutlinePaint(true); assertEquals(plot1, plot2); // autoPopulateSectionOutlineStroke plot1.setAutoPopulateSectionOutlineStroke(true); assertFalse(plot1.equals(plot2)); plot2.setAutoPopulateSectionOutlineStroke(true); assertEquals(plot1, plot2); // shadowGenerator plot1.setShadowGenerator(new DefaultShadowGenerator(5, Color.gray, 0.6f, 4, -Math.PI / 4)); assertFalse(plot1.equals(plot2)); plot2.setShadowGenerator(new DefaultShadowGenerator(5, Color.gray, 0.6f, 4, -Math.PI / 4)); assertEquals(plot1, plot2); plot1.setShadowGenerator(null); assertFalse(plot1.equals(plot2)); plot2.setShadowGenerator(null); assertEquals(plot1, plot2); } /** * Some basic checks for the clone() method. * @throws CloneNotSupportedException */ @Test public void testCloning() throws CloneNotSupportedException { PiePlot p1 = new PiePlot(); PiePlot p2 = (PiePlot) p1.clone(); assertNotSame(p1, p2); assertSame(p1.getClass(), p2.getClass()); assertEquals(p1, p2); } /** * Check cloning of the urlGenerator field. * @throws CloneNotSupportedException */ @Test public void testCloning_URLGenerator() throws CloneNotSupportedException { CustomPieURLGenerator generator = new CustomPieURLGenerator(); PiePlot p1 = new PiePlot(); p1.setURLGenerator(generator); PiePlot p2 = (PiePlot) p1.clone(); assertNotSame(p1, p2); assertSame(p1.getClass(), p2.getClass()); assertEquals(p1, p2); // check that the URL generator has been cloned assertNotSame(p1.getURLGenerator(), p2.getURLGenerator()); } /** * Check cloning of the legendItemShape field. * @throws CloneNotSupportedException */ @Test public void testCloning_LegendItemShape() throws CloneNotSupportedException { Rectangle shape = new Rectangle(-4, -4, 8, 8); PiePlot p1 = new PiePlot(); p1.setLegendItemShape(shape); PiePlot p2 = (PiePlot) p1.clone(); assertNotSame(p1, p2); assertSame(p1.getClass(), p2.getClass()); assertEquals(p1, p2); // change the shape and make sure it only affects p1 shape.setRect(1.0, 2.0, 3.0, 4.0); assertFalse(p1.equals(p2)); } /** * Check cloning of the legendLabelGenerator field. * @throws CloneNotSupportedException */ @Test public void testCloning_LegendLabelGenerator() throws CloneNotSupportedException { StandardPieSectionLabelGenerator generator = new StandardPieSectionLabelGenerator(); PiePlot p1 = new PiePlot(); p1.setLegendLabelGenerator(generator); PiePlot p2 = (PiePlot) p1.clone(); assertNotSame(p1, p2); assertSame(p1.getClass(), p2.getClass()); assertEquals(p1, p2); // change the generator and make sure it only affects p1 generator.getNumberFormat().setMinimumFractionDigits(2); assertFalse(p1.equals(p2)); } /** * Check cloning of the legendLabelToolTipGenerator field. * @throws CloneNotSupportedException */ @Test public void testCloning_LegendLabelToolTipGenerator() throws CloneNotSupportedException { StandardPieSectionLabelGenerator generator = new StandardPieSectionLabelGenerator(); PiePlot p1 = new PiePlot(); p1.setLegendLabelToolTipGenerator(generator); PiePlot p2 = (PiePlot) p1.clone(); assertNotSame(p1, p2); assertSame(p1.getClass(), p2.getClass()); assertEquals(p1, p2); // change the generator and make sure it only affects p1 generator.getNumberFormat().setMinimumFractionDigits(2); assertFalse(p1.equals(p2)); } /** * Check cloning of the legendLabelURLGenerator field. * @throws CloneNotSupportedException */ @Test public void testCloning_LegendLabelURLGenerator() throws CloneNotSupportedException { CustomPieURLGenerator generator = new CustomPieURLGenerator(); PiePlot p1 = new PiePlot(); p1.setLegendLabelURLGenerator(generator); PiePlot p2 = (PiePlot) p1.clone(); assertNotSame(p1, p2); assertSame(p1.getClass(), p2.getClass()); assertEquals(p1, p2); // check that the URL generator has been cloned assertNotSame(p1.getLegendLabelURLGenerator(), p2.getLegendLabelURLGenerator()); } /** * Serialize an instance, restore it, and check for equality. * @throws IOException * @throws ClassNotFoundException */ @Test public void testSerialization() throws IOException, ClassNotFoundException { PiePlot p1 = new PiePlot(null); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); PiePlot p2 = (PiePlot) in.readObject(); in.close(); assertEquals(p1, p2); } /** * Some checks for the getLegendItems() method. */ @Test public void testGetLegendItems() { DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue("Item 1", 1.0); dataset.setValue("Item 2", 2.0); dataset.setValue("Item 3", 0.0); dataset.setValue("Item 4", null); PiePlot plot = new PiePlot(dataset); plot.setIgnoreNullValues(false); plot.setIgnoreZeroValues(false); List<LegendItem> items = plot.getLegendItems(); assertEquals(4, items.size()); // check that null items are ignored if requested plot.setIgnoreNullValues(true); items = plot.getLegendItems(); assertEquals(3, items.size()); // check that zero items are ignored if requested plot.setIgnoreZeroValues(true); items = plot.getLegendItems(); assertEquals(2, items.size()); // check that negative items are always ignored dataset.setValue("Item 5", -1.0); items = plot.getLegendItems(); assertEquals(2, items.size()); } /** * Check that the default base section paint is not null, and that you * can never set it to null. */ @Test public void testGetBaseSectionPaint() { PiePlot plot = new PiePlot(); assertNotNull(plot.getBaseSectionPaint()); try { plot.setBaseSectionPaint(null); fail("Should have thrown a NullPointerException on null parameter"); } catch (IllegalArgumentException e) { assertEquals("Null 'paint' argument.", e.getMessage()); } } static class NullLegendLabelGenerator implements PieSectionLabelGenerator { @Override public AttributedString generateAttributedSectionLabel( PieDataset dataset, Comparable key) { return null; } @Override public String generateSectionLabel(PieDataset dataset, Comparable key) { return null; } } /** * Draws a pie chart where the label generator returns null. */ @Test public void testDrawWithNullLegendLabels() { DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue("L1", 12.0); dataset.setValue("L2", 11.0); JFreeChart chart = ChartFactory.createPieChart("Test", dataset); PiePlot plot = (PiePlot) chart.getPlot(); plot.setLegendLabelGenerator(new NullLegendLabelGenerator()); 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(); } }
22,802
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
package-info.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/plot/package-info.java
/** * JUnit tests for the plot classes. */ package org.jfree.chart.plot;
75
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
PolarPlotTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/plot/PolarPlotTest.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.] * * ------------------- * PolarPlotTests.java * ------------------- * (C) Copyright 2005-2014, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 23-Feb-2005 : Version 1 (DG); * 08-Jun-2005 : Extended testEquals() (DG); * 07-Feb-2007 : Extended testEquals() and testCloning() (DG); * 17-Feb-2008 : Tests for new angleTickUnit field (DG); * 09-Dec-2009 : Added new tests (DG); * 12-Nov-2011 : Added tests for translateToJava2D (MH); * 17-Dec-2011 : Updated testEquals() (DG); * */ package org.jfree.chart.plot; import org.jfree.chart.LegendItem; import org.jfree.chart.axis.LogAxis; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.axis.NumberTickUnit; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.renderer.DefaultPolarItemRenderer; import org.jfree.data.xy.DefaultXYDataset; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; import org.junit.Test; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; import java.awt.GradientPaint; import java.awt.Point; import java.awt.Stroke; 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 java.util.ArrayList; 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; /** * Some tests for the {@link PolarPlot} class. */ public class PolarPlotTest { /** * Some checks for the getLegendItems() method. */ @Test public void testGetLegendItems() { XYSeriesCollection d = new XYSeriesCollection(); d.addSeries(new XYSeries("A")); d.addSeries(new XYSeries("B")); DefaultPolarItemRenderer r = new DefaultPolarItemRenderer(); PolarPlot plot = new PolarPlot(); plot.setDataset(d); plot.setRenderer(r); List<LegendItem> items = plot.getLegendItems(); assertEquals(2, items.size()); LegendItem item1 = items.get(0); assertEquals("A", item1.getLabel()); LegendItem item2 = items.get(1); assertEquals("B", item2.getLabel()); } /** * Some checks for the getLegendItems() method with multiple datasets. */ @Test public void testGetLegendItems2() { XYSeriesCollection d1 = new XYSeriesCollection(); d1.addSeries(new XYSeries("A")); d1.addSeries(new XYSeries("B")); XYSeriesCollection d2 = new XYSeriesCollection(); d2.addSeries(new XYSeries("C")); d2.addSeries(new XYSeries("D")); DefaultPolarItemRenderer r = new DefaultPolarItemRenderer(); PolarPlot plot = new PolarPlot(); plot.setDataset(d1); plot.setDataset(1, d2); plot.setRenderer(r); plot.setRenderer(1, new DefaultPolarItemRenderer()); List<LegendItem> items = plot.getLegendItems(); assertEquals(4, items.size()); LegendItem item1 = items.get(0); assertEquals("A", item1.getLabel()); LegendItem item2 = items.get(1); assertEquals("B", item2.getLabel()); LegendItem item3 = items.get(2); assertEquals("C", item3.getLabel()); LegendItem item4 = items.get(3); assertEquals("D", item4.getLabel()); } /** * Some checks for the equals() method. */ @Test public void testEquals() { PolarPlot plot1 = new PolarPlot(); PolarPlot plot2 = new PolarPlot(); assertEquals(plot1, plot2); assertEquals(plot2, plot1); plot1.setAngleGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.BLUE)); assertFalse(plot1.equals(plot2)); plot2.setAngleGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.BLUE)); assertEquals(plot1, plot2); Stroke s = new BasicStroke(1.23f); plot1.setAngleGridlineStroke(s); assertFalse(plot1.equals(plot2)); plot2.setAngleGridlineStroke(s); assertEquals(plot1, plot2); plot1.setAngleTickUnit(new NumberTickUnit(11.0)); assertFalse(plot1.equals(plot2)); plot2.setAngleTickUnit(new NumberTickUnit(11.0)); assertEquals(plot1, plot2); plot1.setAngleGridlinesVisible(false); assertFalse(plot1.equals(plot2)); plot2.setAngleGridlinesVisible(false); assertEquals(plot1, plot2); plot1.setAngleLabelFont(new Font("Serif", Font.PLAIN, 9)); assertFalse(plot1.equals(plot2)); plot2.setAngleLabelFont(new Font("Serif", Font.PLAIN, 9)); assertEquals(plot1, plot2); plot1.setAngleLabelPaint(new GradientPaint(9.0f, 8.0f, Color.BLUE, 7.0f, 6.0f, Color.RED)); assertFalse(plot1.equals(plot2)); plot2.setAngleLabelPaint(new GradientPaint(9.0f, 8.0f, Color.BLUE, 7.0f, 6.0f, Color.RED)); assertEquals(plot1, plot2); plot1.setAngleLabelsVisible(false); assertFalse(plot1.equals(plot2)); plot2.setAngleLabelsVisible(false); assertEquals(plot1, plot2); plot1.setAxis(new NumberAxis("Test")); assertFalse(plot1.equals(plot2)); plot2.setAxis(new NumberAxis("Test")); assertEquals(plot1, plot2); plot1.setRadiusGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.WHITE, 3.0f, 4.0f, Color.BLACK)); assertFalse(plot1.equals(plot2)); plot2.setRadiusGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.WHITE, 3.0f, 4.0f, Color.BLACK)); assertEquals(plot1, plot2); plot1.setRadiusGridlineStroke(s); assertFalse(plot1.equals(plot2)); plot2.setRadiusGridlineStroke(s); assertEquals(plot1, plot2); plot1.setRadiusGridlinesVisible(false); assertFalse(plot1.equals(plot2)); plot2.setRadiusGridlinesVisible(false); assertEquals(plot1, plot2); plot1.setRadiusMinorGridlinesVisible(false); assertFalse(plot1.equals(plot2)); plot2.setRadiusMinorGridlinesVisible(false); assertEquals(plot1, plot2); plot1.addCornerTextItem("XYZ"); assertFalse(plot1.equals(plot2)); plot2.addCornerTextItem("XYZ"); assertEquals(plot1, plot2); plot1.setMargin(6); assertFalse(plot1.equals(plot2)); plot2.setMargin(6); assertEquals(plot1, plot2); List<LegendItem> lic1 = new ArrayList<LegendItem>(); lic1.add(new LegendItem("XYZ", Color.RED)); plot1.setFixedLegendItems(lic1); assertFalse(plot1.equals(plot2)); List<LegendItem> lic2 = new ArrayList<LegendItem>(); lic2.add(new LegendItem("XYZ", Color.RED)); plot2.setFixedLegendItems(lic2); assertEquals(plot1, plot2); } /** * Some basic checks for the clone() method. * @throws CloneNotSupportedException */ @Test public void testCloning() throws CloneNotSupportedException { PolarPlot p1 = new PolarPlot(); PolarPlot p2 = (PolarPlot) p1.clone(); assertNotSame(p1, p2); assertSame(p1.getClass(), p2.getClass()); assertEquals(p1, p2); // check independence p1.addCornerTextItem("XYZ"); assertFalse(p1.equals(p2)); p2.addCornerTextItem("XYZ"); assertEquals(p1, p2); p1 = new PolarPlot(new DefaultXYDataset(), new NumberAxis("A1"), new DefaultPolarItemRenderer()); p2 = (PolarPlot) p1.clone(); assertNotSame(p1, p2); assertSame(p1.getClass(), p2.getClass()); assertEquals(p1, p2); // check independence p1.getAxis().setLabel("ABC"); assertFalse(p1.equals(p2)); p2.getAxis().setLabel("ABC"); assertEquals(p1, p2); } /** * Serialize an instance, restore it, and check for equality. * @throws IOException * @throws ClassNotFoundException */ @Test public void testSerialization() throws IOException, ClassNotFoundException { PolarPlot p1 = new PolarPlot(); p1.setAngleGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.BLUE)); p1.setAngleLabelPaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.BLUE)); p1.setRadiusGridlinePaint(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(p1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); PolarPlot p2 = (PolarPlot) in.readObject(); in.close(); assertEquals(p1, p2); } @Test public void testTranslateToJava2D_NumberAxis() { Rectangle2D dataArea = new Rectangle2D.Double(0.0, 0.0, 100.0, 100.0); ValueAxis axis = new NumberAxis(); axis.setRange(0.0, 20.0); PolarPlot plot = new PolarPlot(null, axis, null); plot.setMargin(0); plot.setAngleOffset(0.0); Point point = plot.translateToJava2D(0.0, 10.0, axis, dataArea ); assertEquals(75.0, point.getX(), 0.5); assertEquals(50.0, point.getY(), 0.5); point = plot.translateToJava2D(90.0, 5.0, axis, dataArea ); assertEquals(50.0, point.getX(), 0.5); assertEquals(62.5, point.getY(), 0.5); point = plot.translateToJava2D(45.0, 20.0, axis, dataArea ); assertEquals(85.0, point.getX(), 0.5); assertEquals(85.0, point.getY(), 0.5); point = plot.translateToJava2D(135.0, 20.0, axis, dataArea ); assertEquals(15.0, point.getX(), 0.5); assertEquals(85.0, point.getY(), 0.5); point = plot.translateToJava2D(225.0, 15.0, axis, dataArea ); assertEquals(23.0, point.getX(), 0.5); assertEquals(23.0, point.getY(), 0.5); point = plot.translateToJava2D(315.0, 15.0, axis, dataArea ); assertEquals(77.0, point.getX(), 0.5); assertEquals(23.0, point.getY(), 0.5); point = plot.translateToJava2D(21.0, 11.5, axis, dataArea ); assertEquals(77.0, point.getX(), 0.5); assertEquals(60.0, point.getY(), 0.5); point = plot.translateToJava2D(162.0, 7.0, axis, dataArea ); assertEquals(33.0, point.getX(), 0.5); assertEquals(55.0, point.getY(), 0.5); } @Test public void testTranslateToJava2D_NumberAxisAndMargin() { Rectangle2D dataArea = new Rectangle2D.Double(10.0, 10.0, 80.0, 80.0); ValueAxis axis = new NumberAxis(); axis.setRange(-2.0, 2.0); PolarPlot plot = new PolarPlot(null, axis, null); plot.setAngleOffset(0.0); Point point = plot.translateToJava2D(0.0, 10.0, axis, dataArea ); assertEquals(110.0, point.getX(), 0.5); assertEquals(50.0, point.getY(), 0.5); point = plot.translateToJava2D(90.0, 5.0, axis, dataArea ); assertEquals(50.0, point.getX(), 0.5); assertEquals(85.0, point.getY(), 0.5); point = plot.translateToJava2D(45.0, 20.0, axis, dataArea ); assertEquals(128.0, point.getX(), 0.5); assertEquals(128.0, point.getY(), 0.5); point = plot.translateToJava2D(135.0, 20.0, axis, dataArea ); assertEquals(-28.0, point.getX(), 0.5); assertEquals(128.0, point.getY(), 0.5); point = plot.translateToJava2D(225.0, 15.0, axis, dataArea ); assertEquals(-10.0, point.getX(), 0.5); assertEquals(-10.0, point.getY(), 0.5); point = plot.translateToJava2D(315.0, 15.0, axis, dataArea ); assertEquals(110.0, point.getX(), 0.5); assertEquals(-10.0, point.getY(), 0.5); point = plot.translateToJava2D(21.0, 11.5, axis, dataArea ); assertEquals(113.0, point.getX(), 0.5); assertEquals(74.0, point.getY(), 0.5); point = plot.translateToJava2D(162.0, 7.0, axis, dataArea ); assertEquals(7.0, point.getX(), 0.5); assertEquals(64.0, point.getY(), 0.5); } @Test public void testTranslateToJava2D_LogAxis() { Rectangle2D dataArea = new Rectangle2D.Double(0.0, 0.0, 100.0, 100.0); ValueAxis axis = new LogAxis(); axis.setRange(1.0, 100.0); PolarPlot plot = new PolarPlot(null, axis, null); plot.setMargin(0); plot.setAngleOffset(0.0); Point point = plot.translateToJava2D(0.0, 10.0, axis, dataArea ); assertEquals(75.0, point.getX(), 0.5); assertEquals(50.0, point.getY(), 0.5); point = plot.translateToJava2D(90.0, 5.0, axis, dataArea ); assertEquals(50.0, point.getX(), 0.5); assertEquals(67.5, point.getY(), 0.5); point = plot.translateToJava2D(45.0, 20.0, axis, dataArea ); assertEquals(73.0, point.getX(), 0.5); assertEquals(73.0, point.getY(), 0.5); } }
14,618
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
PlotOrientationTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/plot/PlotOrientationTest.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.] * * ------------------------- * PlotOrientationTests.java * ------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 19-Apr-2004 : Version 1 (DG); * */ package org.jfree.chart.plot; 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 PlotOrientation} class. * */ public class PlotOrientationTest { /** * Some checks for the equals() method. */ @Test public void testEquals() { assertEquals(PlotOrientation.HORIZONTAL, PlotOrientation.HORIZONTAL); assertEquals(PlotOrientation.VERTICAL, PlotOrientation.VERTICAL); assertFalse( PlotOrientation.HORIZONTAL.equals(PlotOrientation.VERTICAL) ); assertFalse( PlotOrientation.VERTICAL.equals(PlotOrientation.HORIZONTAL) ); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { PlotOrientation orientation1 = PlotOrientation.HORIZONTAL; ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(orientation1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); PlotOrientation orientation2 = (PlotOrientation) in.readObject(); in.close(); assertEquals(orientation1, orientation2); boolean same = orientation1 == orientation2; assertEquals(true, same); } }
3,307
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
CompassPlotTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/plot/CompassPlotTest.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.] * * --------------------- * CompassPlotTests.java * --------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 27-Mar-2003 : Version 1 (DG); * 20-Mar-2007 : Extended serialization tests (DG); * */ package org.jfree.chart.plot; import org.jfree.data.general.DefaultValueDataset; 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 CompassPlot} class. */ public class CompassPlotTest { /** * Test the equals() method. */ @Test public void testEquals() { CompassPlot plot1 = new CompassPlot(); CompassPlot plot2 = new CompassPlot(); assertEquals(plot1, plot2); // labelType... plot1.setLabelType(CompassPlot.VALUE_LABELS); assertFalse(plot1.equals(plot2)); plot2.setLabelType(CompassPlot.VALUE_LABELS); assertEquals(plot1, plot2); // labelFont plot1.setLabelFont(new Font("Serif", Font.PLAIN, 10)); assertFalse(plot1.equals(plot2)); plot2.setLabelFont(new Font("Serif", Font.PLAIN, 10)); assertEquals(plot1, plot2); // drawBorder plot1.setDrawBorder(true); assertFalse(plot1.equals(plot2)); plot2.setDrawBorder(true); assertEquals(plot1, plot2); // rosePaint plot1.setRosePaint(new GradientPaint(1.0f, 2.0f, Color.BLUE, 3.0f, 4.0f, Color.yellow)); assertFalse(plot1.equals(plot2)); plot2.setRosePaint(new GradientPaint(1.0f, 2.0f, Color.BLUE, 3.0f, 4.0f, Color.yellow)); assertEquals(plot1, plot2); // roseCenterPaint plot1.setRoseCenterPaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.yellow)); assertFalse(plot1.equals(plot2)); plot2.setRoseCenterPaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.yellow)); assertEquals(plot1, plot2); // roseHighlightPaint plot1.setRoseHighlightPaint(new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.yellow)); assertFalse(plot1.equals(plot2)); plot2.setRoseHighlightPaint(new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.yellow)); assertEquals(plot1, plot2); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { CompassPlot p1 = new CompassPlot(null); p1.setRosePaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.BLUE)); p1.setRoseCenterPaint(new GradientPaint(4.0f, 3.0f, Color.RED, 2.0f, 1.0f, Color.green)); p1.setRoseHighlightPaint(new GradientPaint(4.0f, 3.0f, Color.RED, 2.0f, 1.0f, Color.green)); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); CompassPlot p2 = (CompassPlot) in.readObject(); in.close(); assertEquals(p1, p2); } /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { CompassPlot p1 = new CompassPlot(new DefaultValueDataset(15.0)); CompassPlot p2 = (CompassPlot) p1.clone(); assertNotSame(p1, p2); assertSame(p1.getClass(), p2.getClass()); assertEquals(p1, p2); } }
5,459
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
CategoryMarkerTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/plot/CategoryMarkerTest.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.] * * ------------------------ * CategoryMarkerTests.java * ------------------------ * (C) Copyright 2005-2007, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 22-Mar-2005 : Version 1 (DG); * */ package org.jfree.chart.plot; import org.jfree.chart.event.MarkerChangeEvent; import org.jfree.chart.event.MarkerChangeListener; 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.fail; /** * Some tests for the {@link CategoryMarker} class. */ public class CategoryMarkerTest implements MarkerChangeListener { MarkerChangeEvent lastEvent; /** * Records the last event. * * @param event the last event. */ @Override public void markerChanged(MarkerChangeEvent event) { this.lastEvent = event; } /** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { CategoryMarker m1 = new CategoryMarker("A"); CategoryMarker m2 = new CategoryMarker("A"); assertEquals(m1, m2); assertEquals(m2, m1); //key m1 = new CategoryMarker("B"); assertFalse(m1.equals(m2)); m2 = new CategoryMarker("B"); assertEquals(m1, m2); //paint m1 = new CategoryMarker("A", new GradientPaint(1.0f, 2.0f, Color.WHITE, 3.0f, 4.0f, Color.yellow), new BasicStroke(1.1f)); assertFalse(m1.equals(m2)); m2 = new CategoryMarker("A", new GradientPaint(1.0f, 2.0f, Color.WHITE, 3.0f, 4.0f, Color.yellow), new BasicStroke(1.1f)); assertEquals(m1, m2); //stroke m1 = new CategoryMarker("A", new GradientPaint(1.0f, 2.0f, Color.WHITE, 3.0f, 4.0f, Color.yellow), new BasicStroke(2.2f)); assertFalse(m1.equals(m2)); m2 = new CategoryMarker("A", new GradientPaint(1.0f, 2.0f, Color.WHITE, 3.0f, 4.0f, Color.yellow), new BasicStroke(2.2f)); assertEquals(m1, m2); //outlinePaint m1 = new CategoryMarker("A", new GradientPaint(1.0f, 2.0f, Color.WHITE, 3.0f, 4.0f, Color.yellow), new BasicStroke(2.2f), Color.RED, new BasicStroke(1.0f), 1.0f); assertFalse(m1.equals(m2)); m2 = new CategoryMarker("A", new GradientPaint(1.0f, 2.0f, Color.WHITE, 3.0f, 4.0f, Color.yellow), new BasicStroke(2.2f), Color.RED, new BasicStroke(1.0f), 1.0f); assertEquals(m1, m2); //outlineStroke m1 = new CategoryMarker("A", new GradientPaint(1.0f, 2.0f, Color.WHITE, 3.0f, 4.0f, Color.yellow), new BasicStroke(2.2f), Color.RED, new BasicStroke(3.3f), 1.0f); assertFalse(m1.equals(m2)); m2 = new CategoryMarker("A", new GradientPaint(1.0f, 2.0f, Color.WHITE, 3.0f, 4.0f, Color.yellow), new BasicStroke(2.2f), Color.RED, new BasicStroke(3.3f), 1.0f); assertEquals(m1, m2); //alpha m1 = new CategoryMarker("A", new GradientPaint(1.0f, 2.0f, Color.WHITE, 3.0f, 4.0f, Color.yellow), new BasicStroke(2.2f), Color.RED, new BasicStroke(1.0f), 0.5f); assertFalse(m1.equals(m2)); m2 = new CategoryMarker("A", new GradientPaint(1.0f, 2.0f, Color.WHITE, 3.0f, 4.0f, Color.yellow), new BasicStroke(2.2f), Color.RED, new BasicStroke(1.0f), 0.5f); assertEquals(m1, m2); } /** * Check cloning. */ @Test public void testCloning() throws CloneNotSupportedException { CategoryMarker m1 = new CategoryMarker("A", new GradientPaint(1.0f, 2.0f, Color.WHITE, 3.0f, 4.0f, Color.yellow), new BasicStroke(1.1f)); CategoryMarker m2 = (CategoryMarker) m1.clone(); assertNotSame(m1, m2); assertSame(m1.getClass(), m2.getClass()); assertEquals(m1, m2); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { CategoryMarker m1 = new CategoryMarker("A", new GradientPaint(1.0f, 2.0f, Color.WHITE, 3.0f, 4.0f, Color.yellow), new BasicStroke(1.1f)); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(m1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); CategoryMarker m2 = (CategoryMarker) in.readObject(); in.close(); assertEquals(m1, m2); } /** * Some checks for the getKey() and setKey() methods. */ @Test public void testGetSetKey() { CategoryMarker m = new CategoryMarker("X"); m.addChangeListener(this); this.lastEvent = null; assertEquals("X", m.getKey()); m.setKey("Y"); assertEquals("Y", m.getKey()); assertEquals(m, this.lastEvent.getMarker()); // check null argument... try { m.setKey(null); fail("Expected an IllegalArgumentException for null."); } catch (IllegalArgumentException e) { assertEquals("Null 'key' argument.", e.getMessage()); } } /** * Some checks for the getDrawAsLine() and setDrawAsLine() methods. */ @Test public void testGetSetDrawAsLine() { CategoryMarker m = new CategoryMarker("X"); m.addChangeListener(this); this.lastEvent = null; assertEquals(false, m.getDrawAsLine()); m.setDrawAsLine(true); assertEquals(true, m.getDrawAsLine()); assertEquals(m, this.lastEvent.getMarker()); } }
7,649
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
MeterIntervalTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/plot/MeterIntervalTest.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.] * * ----------------------- * MeterIntervalTests.java * ----------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 22-Mar-2005 : Version 1 (DG); * */ package org.jfree.chart.plot; import org.jfree.data.Range; 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.assertTrue; /** * Tests for the {@link MeterInterval} class. */ public class MeterIntervalTest { /** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { MeterInterval m1 = new MeterInterval( "Label 1", new Range(1.2, 3.4), Color.RED, new BasicStroke(1.0f), Color.BLUE ); MeterInterval m2 = new MeterInterval( "Label 1", new Range(1.2, 3.4), Color.RED, new BasicStroke(1.0f), Color.BLUE ); assertEquals(m1, m2); assertEquals(m2, m1); m1 = new MeterInterval( "Label 2", new Range(1.2, 3.4), Color.RED, new BasicStroke(1.0f), Color.BLUE ); assertFalse(m1.equals(m2)); m2 = new MeterInterval( "Label 2", new Range(1.2, 3.4), Color.RED, new BasicStroke(1.0f), Color.BLUE ); assertEquals(m1, m2); } /** * This class is immutable so cloning isn't required. */ @Test public void testCloning() throws CloneNotSupportedException { MeterInterval m1 = new MeterInterval("X", new Range(1.0, 2.0)); assertFalse(m1 instanceof Cloneable); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { MeterInterval m1 = new MeterInterval("X", new Range(1.0, 2.0)); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(m1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); MeterInterval m2 = (MeterInterval) in.readObject(); in.close(); boolean b = m1.equals(m2); assertTrue(b); } }
4,003
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
CombinedDomainCategoryPlotTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/plot/CombinedDomainCategoryPlotTest.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.] * * ------------------------------------ * CombinedDomainCategoryPlotTests.java * ------------------------------------ * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 19-Aug-2003 : Version 1 (DG); * 03-Jan-2008 : Added testNotification() (DG); * */ package org.jfree.chart.plot; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.event.ChartChangeEvent; import org.jfree.chart.event.ChartChangeListener; import org.jfree.chart.labels.StandardCategoryToolTipGenerator; import org.jfree.chart.renderer.category.BarRenderer; import org.jfree.chart.renderer.category.LineAndShapeRenderer; import org.jfree.data.category.CategoryDataset; import org.jfree.data.category.DefaultCategoryDataset; 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 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 CombinedDomainCategoryPlot} class. */ public class CombinedDomainCategoryPlotTest implements ChartChangeListener { /** A list of the events received. */ private List<ChartChangeEvent> events = new java.util.ArrayList<ChartChangeEvent>(); /** * Receives a chart change event. * * @param event the event. */ @Override public void chartChanged(ChartChangeEvent event) { this.events.add(event); } /** * This is a test to replicate the bug report 987080. */ @Test public void testRemoveSubplot() { CombinedDomainCategoryPlot plot = new CombinedDomainCategoryPlot(); CategoryPlot plot1 = new CategoryPlot(); CategoryPlot plot2 = new CategoryPlot(); plot.add(plot1); plot.add(plot2); // remove plot2, but plot1 is removed instead plot.remove(plot2); List plots = plot.getSubplots(); assertSame(plots.get(0), plot1); assertEquals(1, plots.size()); } /** * Some checks for the equals() method. */ @Test public void testEquals() { CombinedDomainCategoryPlot plot1 = createPlot(); CombinedDomainCategoryPlot plot2 = createPlot(); assertEquals(plot1, plot2); } /** * Some checks for cloning. */ @Test public void testCloning() throws CloneNotSupportedException { CombinedDomainCategoryPlot plot1 = createPlot(); CombinedDomainCategoryPlot plot2 = (CombinedDomainCategoryPlot) plot1.clone(); assertNotSame(plot1, plot2); assertSame(plot1.getClass(), plot2.getClass()); assertEquals(plot1, plot2); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { CombinedDomainCategoryPlot plot1 = createPlot(); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(plot1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); CombinedDomainCategoryPlot plot2 = (CombinedDomainCategoryPlot) in.readObject(); in.close(); assertEquals(plot1, plot2); } /** * Check that only one chart change event is generated by a change to a * subplot. */ @Test public void testNotification() { CombinedDomainCategoryPlot plot = createPlot(); JFreeChart chart = new JFreeChart(plot); chart.addChangeListener(this); CategoryPlot subplot1 = plot.getSubplots().get(0); NumberAxis yAxis = (NumberAxis) subplot1.getRangeAxis(); yAxis.setAutoRangeIncludesZero(!yAxis.getAutoRangeIncludesZero()); assertEquals(1, this.events.size()); // a redraw should NOT trigger another change event BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); this.events.clear(); chart.draw(g2, new Rectangle2D.Double(0.0, 0.0, 200.0, 100.0)); assertTrue(this.events.isEmpty()); } /** * Creates a dataset. * * @return A dataset. */ public CategoryDataset createDataset1() { DefaultCategoryDataset result = new DefaultCategoryDataset(); // row keys... String series1 = "First"; String series2 = "Second"; // column keys... String type1 = "Type 1"; String type2 = "Type 2"; String type3 = "Type 3"; String type4 = "Type 4"; String type5 = "Type 5"; String type6 = "Type 6"; String type7 = "Type 7"; String type8 = "Type 8"; result.addValue(1.0, series1, type1); result.addValue(4.0, series1, type2); result.addValue(3.0, series1, type3); result.addValue(5.0, series1, type4); result.addValue(5.0, series1, type5); result.addValue(7.0, series1, type6); result.addValue(7.0, series1, type7); result.addValue(8.0, series1, type8); result.addValue(5.0, series2, type1); result.addValue(7.0, series2, type2); result.addValue(6.0, series2, type3); result.addValue(8.0, series2, type4); result.addValue(4.0, series2, type5); result.addValue(4.0, series2, type6); result.addValue(2.0, series2, type7); result.addValue(1.0, series2, type8); return result; } /** * Creates a dataset. * * @return A dataset. */ public CategoryDataset createDataset2() { DefaultCategoryDataset result = new DefaultCategoryDataset(); // row keys... String series1 = "Third"; String series2 = "Fourth"; // column keys... String type1 = "Type 1"; String type2 = "Type 2"; String type3 = "Type 3"; String type4 = "Type 4"; String type5 = "Type 5"; String type6 = "Type 6"; String type7 = "Type 7"; String type8 = "Type 8"; result.addValue(11.0, series1, type1); result.addValue(14.0, series1, type2); result.addValue(13.0, series1, type3); result.addValue(15.0, series1, type4); result.addValue(15.0, series1, type5); result.addValue(17.0, series1, type6); result.addValue(17.0, series1, type7); result.addValue(18.0, series1, type8); result.addValue(15.0, series2, type1); result.addValue(17.0, series2, type2); result.addValue(16.0, series2, type3); result.addValue(18.0, series2, type4); result.addValue(14.0, series2, type5); result.addValue(14.0, series2, type6); result.addValue(12.0, series2, type7); result.addValue(11.0, series2, type8); return result; } /** * Creates a sample plot. * * @return A sample plot. */ private CombinedDomainCategoryPlot createPlot() { CategoryDataset dataset1 = createDataset1(); NumberAxis rangeAxis1 = new NumberAxis("Value"); rangeAxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); LineAndShapeRenderer renderer1 = new LineAndShapeRenderer(); renderer1.setDefaultToolTipGenerator( new StandardCategoryToolTipGenerator() ); CategoryPlot subplot1 = new CategoryPlot( dataset1, null, rangeAxis1, renderer1 ); subplot1.setDomainGridlinesVisible(true); CategoryDataset dataset2 = createDataset2(); NumberAxis rangeAxis2 = new NumberAxis("Value"); rangeAxis2.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); BarRenderer renderer2 = new BarRenderer(); renderer2.setDefaultToolTipGenerator( new StandardCategoryToolTipGenerator() ); CategoryPlot subplot2 = new CategoryPlot( dataset2, null, rangeAxis2, renderer2 ); subplot2.setDomainGridlinesVisible(true); CategoryAxis domainAxis = new CategoryAxis("Category"); CombinedDomainCategoryPlot plot = new CombinedDomainCategoryPlot(domainAxis); plot.add(subplot1, 2); plot.add(subplot2, 1); return plot; } }
10,164
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
PlotTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/plot/PlotTest.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.] * * -------------- * PlotTests.java * -------------- * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 06-Jun-2005 : Version 1 (DG); * 30-Jun-2006 : Extended equals() test to cover new field (DG); * 11-May-2007 : Another new field in testEquals() (DG); * 17-Jun-2012 : Remove JCommon dependencies (DG); * */ package org.jfree.chart.plot; import org.jfree.chart.JFreeChart; import org.jfree.chart.ui.Align; import org.jfree.chart.ui.RectangleInsets; import org.junit.Test; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; import java.awt.GradientPaint; import java.awt.Image; import java.awt.Paint; import java.awt.Rectangle; import java.awt.Shape; import java.awt.Stroke; import java.net.URL; import javax.swing.ImageIcon; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; /** * Some tests for the {@link Plot} class. */ public class PlotTest { 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 can distinguish all fields (note that * the dataset is NOT considered in the equals() method). */ @Test public void testEquals() { PiePlot plot1 = new PiePlot(); PiePlot plot2 = new PiePlot(); assertEquals(plot1, plot2); assertEquals(plot2, plot1); // noDataMessage plot1.setNoDataMessage("No data XYZ"); assertFalse(plot1.equals(plot2)); plot2.setNoDataMessage("No data XYZ"); assertEquals(plot1, plot2); // noDataMessageFont plot1.setNoDataMessageFont(new Font("SansSerif", Font.PLAIN, 13)); assertFalse(plot1.equals(plot2)); plot2.setNoDataMessageFont(new Font("SansSerif", Font.PLAIN, 13)); assertEquals(plot1, plot2); // noDataMessagePaint plot1.setNoDataMessagePaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.BLUE)); assertFalse(plot1.equals(plot2)); plot2.setNoDataMessagePaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.BLUE)); assertEquals(plot1, plot2); // insets plot1.setInsets(new RectangleInsets(1.0, 2.0, 3.0, 4.0)); assertFalse(plot1.equals(plot2)); plot2.setInsets(new RectangleInsets(1.0, 2.0, 3.0, 4.0)); assertEquals(plot1, plot2); // outlineVisible plot1.setOutlineVisible(false); assertFalse(plot1.equals(plot2)); plot2.setOutlineVisible(false); assertEquals(plot1, plot2); // outlineStroke BasicStroke s = new BasicStroke(1.23f); plot1.setOutlineStroke(s); assertFalse(plot1.equals(plot2)); plot2.setOutlineStroke(s); assertEquals(plot1, plot2); // outlinePaint plot1.setOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.yellow, 3.0f, 4.0f, Color.green)); assertFalse(plot1.equals(plot2)); plot2.setOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.yellow, 3.0f, 4.0f, Color.green)); assertEquals(plot1, plot2); // backgroundPaint plot1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.cyan, 3.0f, 4.0f, Color.green)); assertFalse(plot1.equals(plot2)); plot2.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.cyan, 3.0f, 4.0f, Color.green)); assertEquals(plot1, plot2); // backgroundImage plot1.setBackgroundImage(getTestImage()); assertFalse(plot1.equals(plot2)); plot2.setBackgroundImage(getTestImage()); assertEquals(plot1, plot2); // backgroundImageAlignment plot1.setBackgroundImageAlignment(Align.BOTTOM_RIGHT); assertFalse(plot1.equals(plot2)); plot2.setBackgroundImageAlignment(Align.BOTTOM_RIGHT); assertEquals(plot1, plot2); // backgroundImageAlpha plot1.setBackgroundImageAlpha(0.77f); assertFalse(plot1.equals(plot2)); plot2.setBackgroundImageAlpha(0.77f); assertEquals(plot1, plot2); // foregroundAlpha plot1.setForegroundAlpha(0.99f); assertFalse(plot1.equals(plot2)); plot2.setForegroundAlpha(0.99f); assertEquals(plot1, plot2); // backgroundAlpha plot1.setBackgroundAlpha(0.99f); assertFalse(plot1.equals(plot2)); plot2.setBackgroundAlpha(0.99f); assertEquals(plot1, plot2); // drawingSupplier plot1.setDrawingSupplier(new DefaultDrawingSupplier( new Paint[] {Color.BLUE}, new Paint[] {Color.RED}, new Stroke[] {new BasicStroke(1.1f)}, new Stroke[] {new BasicStroke(9.9f)}, new Shape[] {new Rectangle(1, 2, 3, 4)})); assertFalse(plot1.equals(plot2)); plot2.setDrawingSupplier(new DefaultDrawingSupplier( new Paint[] {Color.BLUE}, new Paint[] {Color.RED}, new Stroke[] {new BasicStroke(1.1f)}, new Stroke[] {new BasicStroke(9.9f)}, new Shape[] {new Rectangle(1, 2, 3, 4)})); assertEquals(plot1, plot2); } }
6,974
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
PlotRenderingInfoTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/plot/PlotRenderingInfoTest.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.] * * --------------------------- * PlotRenderingInfoTests.java * --------------------------- * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 20-May-2004 : Version 1 (DG); * */ package org.jfree.chart.plot; import org.jfree.chart.ChartRenderingInfo; import org.junit.Test; import java.awt.Rectangle; 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 PlotRenderingInfo} class. */ public class PlotRenderingInfoTest { /** * Test the equals() method. */ @Test public void testEquals() { PlotRenderingInfo p1 = new PlotRenderingInfo(new ChartRenderingInfo()); PlotRenderingInfo p2 = new PlotRenderingInfo(new ChartRenderingInfo()); assertEquals(p1, p2); assertEquals(p2, p1); p1.setPlotArea(new Rectangle(2, 3, 4, 5)); assertFalse(p1.equals(p2)); p2.setPlotArea(new Rectangle(2, 3, 4, 5)); assertEquals(p1, p2); p1.setDataArea(new Rectangle(2, 4, 6, 8)); assertFalse(p1.equals(p2)); p2.setDataArea(new Rectangle(2, 4, 6, 8)); assertEquals(p1, p2); p1.addSubplotInfo(new PlotRenderingInfo(null)); assertFalse(p1.equals(p2)); p2.addSubplotInfo(new PlotRenderingInfo(null)); assertEquals(p1, p2); p1.getSubplotInfo(0).setDataArea(new Rectangle(1, 2, 3, 4)); assertFalse(p1.equals(p2)); p2.getSubplotInfo(0).setDataArea(new Rectangle(1, 2, 3, 4)); assertEquals(p1, p2); } /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { PlotRenderingInfo p1 = new PlotRenderingInfo(new ChartRenderingInfo()); p1.setPlotArea(new Rectangle2D.Double()); PlotRenderingInfo p2 = (PlotRenderingInfo) p1.clone(); assertNotSame(p1, p2); assertSame(p1.getClass(), p2.getClass()); assertEquals(p1, p2); // check independence p1.getPlotArea().setRect(1.0, 2.0, 3.0, 4.0); assertFalse(p1.equals(p2)); p2.getPlotArea().setRect(1.0, 2.0, 3.0, 4.0); assertEquals(p1, p2); p1.getDataArea().setRect(4.0, 3.0, 2.0, 1.0); assertFalse(p1.equals(p2)); p2.getDataArea().setRect(4.0, 3.0, 2.0, 1.0); assertEquals(p1, p2); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { PlotRenderingInfo p1 = new PlotRenderingInfo(new ChartRenderingInfo()); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); PlotRenderingInfo p2 = (PlotRenderingInfo) in.readObject(); in.close(); assertEquals(p1, p2); } }
4,787
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
ThermometerPlotTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/plot/ThermometerPlotTest.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.] * * ------------------------- * ThermometerPlotTests.java * ------------------------- * (C) Copyright 2003-2012, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 26-Mar-2003 : Version 1 (DG); * 30-Apr-2007 : Added new serialization test (DG); * 03-May-2007 : Added cloning test (DG); * 08-Oct-2007 : Updated testEquals() for new fields (DG); * 17-Jun-2012 : Removed JCommon dependencies (DG); * */ package org.jfree.chart.plot; import org.jfree.chart.ui.RectangleInsets; import org.junit.Test; import java.awt.BasicStroke; 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 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; /** * Tests for the {@link ThermometerPlot} class. */ public class ThermometerPlotTest { /** * Some checks for the equals() method. */ @Test public void testEquals() { ThermometerPlot p1 = new ThermometerPlot(); ThermometerPlot p2 = new ThermometerPlot(); assertEquals(p1, p2); assertEquals(p2, p1); // padding p1.setPadding(new RectangleInsets(1.0, 2.0, 3.0, 4.0)); assertFalse(p1.equals(p2)); p2.setPadding(new RectangleInsets(1.0, 2.0, 3.0, 4.0)); assertEquals(p2, p1); // thermometerStroke BasicStroke s = new BasicStroke(1.23f); p1.setThermometerStroke(s); assertFalse(p1.equals(p2)); p2.setThermometerStroke(s); assertEquals(p2, p1); // thermometerPaint p1.setThermometerPaint(new GradientPaint(1.0f, 2.0f, Color.BLUE, 3.0f, 4.0f, Color.RED)); assertFalse(p1.equals(p2)); p2.setThermometerPaint(new GradientPaint(1.0f, 2.0f, Color.BLUE, 3.0f, 4.0f, Color.RED)); assertEquals(p2, p1); // units p1.setUnits(ThermometerPlot.UNITS_KELVIN); assertFalse(p1.equals(p2)); p2.setUnits(ThermometerPlot.UNITS_KELVIN); assertEquals(p2, p1); // valueLocation p1.setValueLocation(ThermometerPlot.LEFT); assertFalse(p1.equals(p2)); p2.setValueLocation(ThermometerPlot.LEFT); assertEquals(p2, p1); // axisLocation p1.setAxisLocation(ThermometerPlot.RIGHT); assertFalse(p1.equals(p2)); p2.setAxisLocation(ThermometerPlot.RIGHT); assertEquals(p2, p1); // valueFont p1.setValueFont(new Font("Serif", Font.PLAIN, 9)); assertFalse(p1.equals(p2)); p2.setValueFont(new Font("Serif", Font.PLAIN, 9)); assertEquals(p2, p1); // valuePaint p1.setValuePaint(new GradientPaint(4.0f, 5.0f, Color.RED, 6.0f, 7.0f, Color.WHITE)); assertFalse(p1.equals(p2)); p2.setValuePaint(new GradientPaint(4.0f, 5.0f, Color.RED, 6.0f, 7.0f, Color.WHITE)); assertEquals(p2, p1); // valueFormat p1.setValueFormat(new DecimalFormat("0.0000")); assertFalse(p1.equals(p2)); p2.setValueFormat(new DecimalFormat("0.0000")); assertEquals(p2, p1); // mercuryPaint p1.setMercuryPaint(new GradientPaint(9.0f, 8.0f, Color.RED, 7.0f, 6.0f, Color.BLUE)); assertFalse(p1.equals(p2)); p2.setMercuryPaint(new GradientPaint(9.0f, 8.0f, Color.RED, 7.0f, 6.0f, Color.BLUE)); assertEquals(p2, p1); p1.setSubrange(1, 1.0, 2.0); assertFalse(p1.equals(p2)); p2.setSubrange(1, 1.0, 2.0); assertEquals(p2, p1); p1.setSubrangePaint(1, new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.yellow)); assertFalse(p1.equals(p2)); p2.setSubrangePaint(1, new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.yellow)); assertEquals(p2, p1); p1.setBulbRadius(9); assertFalse(p1.equals(p2)); p2.setBulbRadius(9); assertEquals(p2, p1); p1.setColumnRadius(8); assertFalse(p1.equals(p2)); p2.setColumnRadius(8); assertEquals(p2, p1); p1.setGap(7); assertFalse(p1.equals(p2)); p2.setGap(7); assertEquals(p2, p1); } /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { ThermometerPlot p1 = new ThermometerPlot(); ThermometerPlot p2 = (ThermometerPlot) p1.clone(); assertNotSame(p1, p2); assertSame(p1.getClass(), p2.getClass()); assertEquals(p1, p2); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { ThermometerPlot p1 = new ThermometerPlot(); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); ThermometerPlot p2 = (ThermometerPlot) in.readObject(); in.close(); assertEquals(p1, p2); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization2() throws IOException, ClassNotFoundException { ThermometerPlot p1 = new ThermometerPlot(); p1.setSubrangePaint(1, 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(p1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); ThermometerPlot p2 = (ThermometerPlot) in.readObject(); in.close(); assertEquals(p1, p2); } }
7,727
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
FastScatterPlotTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/plot/FastScatterPlotTest.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.] * * ------------------------- * FastScatterPlotTests.java * ------------------------- * (C) Copyright 2003-2009, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 18-Mar-2003 : Version 1 (DG); * 29-Jan-2009 : Updated testEquals() (DG); * 26-Mar-2009 : Updated testEquals() for new panning fields (DG); * */ package org.jfree.chart.plot; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.axis.ValueAxis; 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; /** * Tests for the {@link FastScatterPlot} class. */ public class FastScatterPlotTest { /** * Some checks for the equals() method. */ @Test public void testEquals() { FastScatterPlot plot1 = new FastScatterPlot(); FastScatterPlot plot2 = new FastScatterPlot(); assertEquals(plot1, plot2); assertEquals(plot2, plot1); plot1.setPaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.yellow)); assertFalse(plot1.equals(plot2)); plot2.setPaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.yellow)); assertEquals(plot1, plot2); plot1.setDomainGridlinesVisible(false); assertFalse(plot1.equals(plot2)); plot2.setDomainGridlinesVisible(false); assertEquals(plot1, plot2); plot1.setDomainGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.BLUE, 3.0f, 4.0f, Color.yellow)); assertFalse(plot1.equals(plot2)); plot2.setDomainGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.BLUE, 3.0f, 4.0f, Color.yellow)); assertEquals(plot1, plot2); Stroke s = new BasicStroke(1.5f); plot1.setDomainGridlineStroke(s); assertFalse(plot1.equals(plot2)); plot2.setDomainGridlineStroke(s); assertEquals(plot1, plot2); plot1.setRangeGridlinesVisible(false); assertFalse(plot1.equals(plot2)); plot2.setRangeGridlinesVisible(false); assertEquals(plot1, plot2); plot1.setRangeGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.yellow)); assertFalse(plot1.equals(plot2)); plot2.setRangeGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.yellow)); assertEquals(plot1, plot2); Stroke s2 = new BasicStroke(1.5f); plot1.setRangeGridlineStroke(s2); assertFalse(plot1.equals(plot2)); plot2.setRangeGridlineStroke(s2); assertEquals(plot1, plot2); plot1.setDomainPannable(true); assertFalse(plot1.equals(plot2)); plot2.setDomainPannable(true); assertEquals(plot1, plot2); plot1.setRangePannable(true); assertFalse(plot1.equals(plot2)); plot2.setRangePannable(true); assertEquals(plot1, plot2); } /** * Some tests for the data array equality in the equals() method. */ @Test public void testEquals2() { FastScatterPlot plot1 = new FastScatterPlot(); FastScatterPlot plot2 = new FastScatterPlot(); assertEquals(plot1, plot2); assertEquals(plot2, plot1); float[][] a = new float[2][]; float[][] b = new float[2][]; plot1.setData(a); assertFalse(plot1.equals(plot2)); plot2.setData(b); assertEquals(plot1, plot2); a[0] = new float[6]; assertFalse(plot1.equals(plot2)); b[0] = new float[6]; assertEquals(plot1, plot2); a[0][0] = 1.0f; assertFalse(plot1.equals(plot2)); b[0][0] = 1.0f; assertEquals(plot1, plot2); a[0][1] = Float.NaN; assertFalse(plot1.equals(plot2)); b[0][1] = Float.NaN; assertEquals(plot1, plot2); a[0][2] = Float.POSITIVE_INFINITY; assertFalse(plot1.equals(plot2)); b[0][2] = Float.POSITIVE_INFINITY; assertEquals(plot1, plot2); a[0][3] = Float.NEGATIVE_INFINITY; assertFalse(plot1.equals(plot2)); b[0][3] = Float.NEGATIVE_INFINITY; assertEquals(plot1, plot2); } /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { FastScatterPlot p1 = new FastScatterPlot(); FastScatterPlot p2 = (FastScatterPlot) p1.clone(); assertNotSame(p1, p2); assertSame(p1.getClass(), p2.getClass()); assertEquals(p1, p2); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { float[][] data = createData(); ValueAxis domainAxis = new NumberAxis("X"); ValueAxis rangeAxis = new NumberAxis("Y"); FastScatterPlot p1 = new FastScatterPlot(data, domainAxis, rangeAxis); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); FastScatterPlot p2 = (FastScatterPlot) in.readObject(); in.close(); assertEquals(p1, p2); } /** * Draws the chart with a <code>null</code> info object to make sure that * no exceptions are thrown. */ @Test public void testDrawWithNullInfo() { float[][] data = createData(); ValueAxis domainAxis = new NumberAxis("X"); ValueAxis rangeAxis = new NumberAxis("Y"); FastScatterPlot plot = new FastScatterPlot(data, domainAxis, rangeAxis); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, null); //FIXME we should really be asserting a value here } /** * Populates the data array with random values. * * @return Random data. */ private float[][] createData() { float[][] result = new float[2][1000]; for (int i = 0; i < result[0].length; i++) { float x = (float) i + 100; result[0][i] = x; result[1][i] = 100 + (float) Math.random() * 1000; } return result; } }
8,206
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
DefaultDrawingSupplierTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/plot/DefaultDrawingSupplierTest.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.] * * -------------------------------- * DefaultDrawingSupplierTests.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); * */ package org.jfree.chart.plot; import org.junit.Test; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Paint; import java.awt.Shape; import java.awt.Stroke; 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 DefaultDrawingSupplier} class. */ public class DefaultDrawingSupplierTest { /** * Check that the equals() method can distinguish all required fields. */ @Test public void testEquals() { DefaultDrawingSupplier r1 = new DefaultDrawingSupplier(); DefaultDrawingSupplier r2 = new DefaultDrawingSupplier(); assertEquals(r1, r2); assertEquals(r2, r1); // set up some objects... Paint[] ps1A = new Paint[] {Color.RED, Color.BLUE}; Paint[] ps2A = new Paint[] {Color.green, Color.yellow, Color.WHITE}; Paint[] ops1A = new Paint[] {Color.lightGray, Color.BLUE}; Paint[] ops2A = new Paint[] {Color.BLACK, Color.yellow, Color.cyan}; Stroke[] ss1A = new Stroke[] {new BasicStroke(1.1f)}; Stroke[] ss2A = new Stroke[] {new BasicStroke(2.2f), new BasicStroke(3.3f)}; Stroke[] oss1A = new Stroke[] {new BasicStroke(4.4f)}; Stroke[] oss2A = new Stroke[] {new BasicStroke(5.5f), new BasicStroke(6.6f)}; Shape[] shapes1A = new Shape[] { new Rectangle2D.Double(1.0, 1.0, 1.0, 1.0) }; Shape[] shapes2A = new Shape[] { new Rectangle2D.Double(2.0, 2.0, 2.0, 2.0), new Rectangle2D.Double(2.0, 2.0, 2.0, 2.0) }; Paint[] ps1B = new Paint[] {Color.RED, Color.BLUE}; Paint[] ps2B = new Paint[] {Color.green, Color.yellow, Color.WHITE}; Paint[] ops1B = new Paint[] {Color.lightGray, Color.BLUE}; Paint[] ops2B = new Paint[] {Color.BLACK, Color.yellow, Color.cyan}; Stroke[] ss1B = new Stroke[] {new BasicStroke(1.1f)}; Stroke[] ss2B = new Stroke[] {new BasicStroke(2.2f), new BasicStroke(3.3f)}; Stroke[] oss1B = new Stroke[] {new BasicStroke(4.4f)}; Stroke[] oss2B = new Stroke[] {new BasicStroke(5.5f), new BasicStroke(6.6f)}; Shape[] shapes1B = new Shape[] { new Rectangle2D.Double(1.0, 1.0, 1.0, 1.0) }; Shape[] shapes2B = new Shape[] { new Rectangle2D.Double(2.0, 2.0, 2.0, 2.0), new Rectangle2D.Double(2.0, 2.0, 2.0, 2.0) }; r1 = new DefaultDrawingSupplier(ps1A, ops1A, ss1A, oss1A, shapes1A); r2 = new DefaultDrawingSupplier(ps1B, ops1B, ss1B, oss1B, shapes1B); assertEquals(r1, r2); // paint sequence r1 = new DefaultDrawingSupplier(ps2A, ops1A, ss1A, oss1A, shapes1A); assertFalse(r1.equals(r2)); r2 = new DefaultDrawingSupplier(ps2B, ops1B, ss1B, oss1B, shapes1B); assertEquals(r1, r2); // outline paint sequence r1 = new DefaultDrawingSupplier(ps2A, ops2A, ss1A, oss1A, shapes1A); assertFalse(r1.equals(r2)); r2 = new DefaultDrawingSupplier(ps2B, ops2B, ss1B, oss1B, shapes1B); assertEquals(r1, r2); // stroke sequence r1 = new DefaultDrawingSupplier(ps2A, ops2A, ss2A, oss1A, shapes1A); assertFalse(r1.equals(r2)); r2 = new DefaultDrawingSupplier(ps2B, ops2B, ss2B, oss1B, shapes1B); assertEquals(r1, r2); // outline stroke sequence r1 = new DefaultDrawingSupplier(ps2A, ops2A, ss2A, oss2A, shapes1A); assertFalse(r1.equals(r2)); r2 = new DefaultDrawingSupplier(ps2B, ops2B, ss2B, oss2B, shapes1B); assertEquals(r1, r2); // shape sequence r1 = new DefaultDrawingSupplier(ps2A, ops2A, ss2A, oss2A, shapes2A); assertFalse(r1.equals(r2)); r2 = new DefaultDrawingSupplier(ps2B, ops2B, ss2B, oss2B, shapes2B); assertEquals(r1, r2); // paint index r1.getNextPaint(); assertFalse(r1.equals(r2)); r2.getNextPaint(); assertEquals(r1, r2); // outline paint index r1.getNextOutlinePaint(); assertFalse(r1.equals(r2)); r2.getNextOutlinePaint(); assertEquals(r1, r2); // stroke index r1.getNextStroke(); assertFalse(r1.equals(r2)); r2.getNextStroke(); assertEquals(r1, r2); // outline stroke index r1.getNextOutlineStroke(); assertFalse(r1.equals(r2)); r2.getNextOutlineStroke(); assertEquals(r1, r2); // shape index r1.getNextShape(); assertFalse(r1.equals(r2)); r2.getNextShape(); assertEquals(r1, r2); } /** * Some basic checks for the clone() method. */ @Test public void testCloning() throws CloneNotSupportedException { DefaultDrawingSupplier r1 = new DefaultDrawingSupplier(); DefaultDrawingSupplier r2 = (DefaultDrawingSupplier) 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 { DefaultDrawingSupplier r1 = new DefaultDrawingSupplier(); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(r1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray()) ); DefaultDrawingSupplier r2 = (DefaultDrawingSupplier) in.readObject(); in.close(); assertEquals(r1, r2); } }
7,681
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
MeterPlotTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/plot/MeterPlotTest.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.] * * ------------------- * MeterPlotTests.java * ------------------- * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 27-Mar-2003 : Version 1 (DG); * 12-May-2004 : Updated testEquals() (DG); * 29-Nov-2007 : Updated testEquals() and testSerialization1() for * dialOutlinePaint (DG) * */ package org.jfree.chart.plot; import org.jfree.data.Range; import org.jfree.data.general.DefaultValueDataset; 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 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; /** * Tests for the {@link MeterPlot} class. */ public class MeterPlotTest { /** * Test the equals method to ensure that it can distinguish the required * fields. Note that the dataset is NOT considered in the equals test. */ @Test public void testEquals() { MeterPlot plot1 = new MeterPlot(); MeterPlot plot2 = new MeterPlot(); assertEquals(plot1, plot2); // units plot1.setUnits("mph"); assertFalse(plot1.equals(plot2)); plot2.setUnits("mph"); assertEquals(plot1, plot2); // range plot1.setRange(new Range(50.0, 70.0)); assertFalse(plot1.equals(plot2)); plot2.setRange(new Range(50.0, 70.0)); assertEquals(plot1, plot2); // interval plot1.addInterval(new MeterInterval("Normal", new Range(55.0, 60.0))); assertFalse(plot1.equals(plot2)); plot2.addInterval(new MeterInterval("Normal", new Range(55.0, 60.0))); assertEquals(plot1, plot2); // dial outline paint plot1.setDialOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.BLUE)); assertFalse(plot1.equals(plot2)); plot2.setDialOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.BLUE)); assertEquals(plot1, plot2); // dial shape plot1.setDialShape(DialShape.CHORD); assertFalse(plot1.equals(plot2)); plot2.setDialShape(DialShape.CHORD); assertEquals(plot1, plot2); // dial background paint plot1.setDialBackgroundPaint(new GradientPaint(9.0f, 8.0f, Color.RED, 7.0f, 6.0f, Color.BLUE)); assertFalse(plot1.equals(plot2)); plot2.setDialBackgroundPaint(new GradientPaint(9.0f, 8.0f, Color.RED, 7.0f, 6.0f, Color.BLUE)); assertEquals(plot1, plot2); // dial outline paint plot1.setDialOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.RED)); assertFalse(plot1.equals(plot2)); plot2.setDialOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, Color.RED)); assertEquals(plot1, plot2); // needle paint plot1.setNeedlePaint(new GradientPaint(9.0f, 8.0f, Color.RED, 7.0f, 6.0f, Color.BLUE)); assertFalse(plot1.equals(plot2)); plot2.setNeedlePaint(new GradientPaint(9.0f, 8.0f, Color.RED, 7.0f, 6.0f, Color.BLUE)); assertEquals(plot1, plot2); // value font plot1.setValueFont(new Font("Serif", Font.PLAIN, 6)); assertFalse(plot1.equals(plot2)); plot2.setValueFont(new Font("Serif", Font.PLAIN, 6)); assertEquals(plot1, plot2); // value paint plot1.setValuePaint(new GradientPaint(1.0f, 2.0f, Color.BLACK, 3.0f, 4.0f, Color.WHITE)); assertFalse(plot1.equals(plot2)); plot2.setValuePaint(new GradientPaint(1.0f, 2.0f, Color.BLACK, 3.0f, 4.0f, Color.WHITE)); assertEquals(plot1, plot2); // tick labels visible plot1.setTickLabelsVisible(false); assertFalse(plot1.equals(plot2)); plot2.setTickLabelsVisible(false); assertEquals(plot1, plot2); // tick label font plot1.setTickLabelFont(new Font("Serif", Font.PLAIN, 6)); assertFalse(plot1.equals(plot2)); plot2.setTickLabelFont(new Font("Serif", Font.PLAIN, 6)); assertEquals(plot1, plot2); // tick label paint plot1.setTickLabelPaint(Color.RED); assertFalse(plot1.equals(plot2)); plot2.setTickLabelPaint(Color.RED); assertEquals(plot1, plot2); // tick label format plot1.setTickLabelFormat(new DecimalFormat("0")); assertFalse(plot1.equals(plot2)); plot2.setTickLabelFormat(new DecimalFormat("0")); assertEquals(plot1, plot2); // tick paint plot1.setTickPaint(Color.green); assertFalse(plot1.equals(plot2)); plot2.setTickPaint(Color.green); assertEquals(plot1, plot2); // tick size plot1.setTickSize(1.23); assertFalse(plot1.equals(plot2)); plot2.setTickSize(1.23); assertEquals(plot1, plot2); // draw border plot1.setDrawBorder(!plot1.getDrawBorder()); assertFalse(plot1.equals(plot2)); plot2.setDrawBorder(plot1.getDrawBorder()); assertEquals(plot1, plot2); // meter angle plot1.setMeterAngle(22); assertFalse(plot1.equals(plot2)); plot2.setMeterAngle(22); assertEquals(plot1, plot2); } /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { MeterPlot p1 = new MeterPlot(); MeterPlot p2 = (MeterPlot) p1.clone(); assertNotSame(p1, p2); assertSame(p1.getClass(), p2.getClass()); assertEquals(p1, p2); // the clone and the original share a reference to the SAME dataset assertSame(p1.getDataset(), p2.getDataset()); // try a few checks to ensure that the clone is independent of the // original p1.getTickLabelFormat().setMinimumIntegerDigits(99); assertFalse(p1.equals(p2)); p2.getTickLabelFormat().setMinimumIntegerDigits(99); assertEquals(p1, p2); p1.addInterval(new MeterInterval("Test", new Range(1.234, 5.678))); assertFalse(p1.equals(p2)); p2.addInterval(new MeterInterval("Test", new Range(1.234, 5.678))); assertEquals(p1, p2); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization1() throws IOException, ClassNotFoundException { MeterPlot p1 = new MeterPlot(null); p1.setDialBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.BLUE)); p1.setDialOutlinePaint(new GradientPaint(4.0f, 3.0f, Color.RED, 2.0f, 1.0f, Color.BLUE)); p1.setNeedlePaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.BLUE)); p1.setTickLabelPaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.BLUE)); p1.setTickPaint(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(p1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); MeterPlot p2 = (MeterPlot) in.readObject(); in.close(); assertEquals(p1, p2); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization2() throws IOException, ClassNotFoundException { MeterPlot p1 = new MeterPlot(new DefaultValueDataset(1.23)); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); MeterPlot p2 = (MeterPlot) in.readObject(); in.close(); assertEquals(p1, p2); } }
9,899
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
SpiderWebPlotTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/plot/SpiderWebPlotTest.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.] * * ----------------------- * SpiderWebPlotTests.java * ----------------------- * (C) Copyright 2005-2014, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 10-Jun-2005 : Version 1 (DG); * 01-Jun-2006 : Added testDrawWithNullInfo() method (DG); * 05-Feb-2007 : Added more checks to testCloning (DG); * 01-Jun-2009 : Added test for getLegendItems() bug, series key is not * set (DG); * 10-Mar-2014 : Removed LegendItemCollection (DG); * */ package org.jfree.chart.plot; import org.jfree.chart.JFreeChart; import org.jfree.chart.LegendItem; import org.jfree.chart.labels.StandardCategoryItemLabelGenerator; import org.jfree.chart.labels.StandardCategoryToolTipGenerator; import org.jfree.chart.urls.StandardCategoryURLGenerator; import org.jfree.chart.util.Rotation; import org.jfree.chart.util.TableOrder; import org.jfree.data.category.DefaultCategoryDataset; import org.junit.Test; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; import java.awt.GradientPaint; import java.awt.Graphics2D; import java.awt.Rectangle; 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.text.DecimalFormat; 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; /** * Tests for the {@link SpiderWebPlot} class. */ public class SpiderWebPlotTest { /** * Some checks for the equals() method. */ @Test public void testEquals() { SpiderWebPlot p1 = new SpiderWebPlot(new DefaultCategoryDataset()); SpiderWebPlot p2 = new SpiderWebPlot(new DefaultCategoryDataset()); assertEquals(p1, p2); assertEquals(p2, p1); // dataExtractOrder p1.setDataExtractOrder(TableOrder.BY_COLUMN); assertFalse(p1.equals(p2)); p2.setDataExtractOrder(TableOrder.BY_COLUMN); assertEquals(p1, p2); // headPercent p1.setHeadPercent(0.321); assertFalse(p1.equals(p2)); p2.setHeadPercent(0.321); assertEquals(p1, p2); // interiorGap p1.setInteriorGap(0.123); assertFalse(p1.equals(p2)); p2.setInteriorGap(0.123); assertEquals(p1, p2); // startAngle p1.setStartAngle(0.456); assertFalse(p1.equals(p2)); p2.setStartAngle(0.456); assertEquals(p1, p2); // direction p1.setDirection(Rotation.ANTICLOCKWISE); assertFalse(p1.equals(p2)); p2.setDirection(Rotation.ANTICLOCKWISE); assertEquals(p1, p2); // maxValue p1.setMaxValue(123.4); assertFalse(p1.equals(p2)); p2.setMaxValue(123.4); assertEquals(p1, p2); // legendItemShape p1.setLegendItemShape(new Rectangle(1, 2, 3, 4)); assertFalse(p1.equals(p2)); p2.setLegendItemShape(new Rectangle(1, 2, 3, 4)); assertEquals(p1, p2); // seriesPaint p1.setSeriesPaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.WHITE)); assertFalse(p1.equals(p2)); p2.setSeriesPaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.WHITE)); assertEquals(p1, p2); // seriesPaintList p1.setSeriesPaint(1, new GradientPaint(1.0f, 2.0f, Color.yellow, 3.0f, 4.0f, Color.WHITE)); assertFalse(p1.equals(p2)); p2.setSeriesPaint(1, new GradientPaint(1.0f, 2.0f, Color.yellow, 3.0f, 4.0f, Color.WHITE)); assertEquals(p1, p2); // baseSeriesPaint p1.setBaseSeriesPaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.BLACK)); assertFalse(p1.equals(p2)); p2.setBaseSeriesPaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.BLACK)); assertEquals(p1, p2); // seriesOutlinePaint p1.setSeriesOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.BLUE, 3.0f, 4.0f, Color.BLACK)); assertFalse(p1.equals(p2)); p2.setSeriesOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.BLUE, 3.0f, 4.0f, Color.BLACK)); assertEquals(p1, p2); // seriesOutlinePaintList p1.setSeriesOutlinePaint(1, new GradientPaint(1.0f, 2.0f, Color.BLUE, 3.0f, 4.0f, Color.green)); assertFalse(p1.equals(p2)); p2.setSeriesOutlinePaint(1, new GradientPaint(1.0f, 2.0f, Color.BLUE, 3.0f, 4.0f, Color.green)); assertEquals(p1, p2); // baseSeriesOutlinePaint p1.setBaseSeriesOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.cyan, 3.0f, 4.0f, Color.green)); assertFalse(p1.equals(p2)); p2.setBaseSeriesOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.cyan, 3.0f, 4.0f, Color.green)); assertEquals(p1, p2); // seriesOutlineStroke BasicStroke s = new BasicStroke(1.23f); p1.setSeriesOutlineStroke(s); assertFalse(p1.equals(p2)); p2.setSeriesOutlineStroke(s); assertEquals(p1, p2); // seriesOutlineStrokeList p1.setSeriesOutlineStroke(1, s); assertFalse(p1.equals(p2)); p2.setSeriesOutlineStroke(1, s); assertEquals(p1, p2); // baseSeriesOutlineStroke p1.setBaseSeriesOutlineStroke(s); assertFalse(p1.equals(p2)); p2.setBaseSeriesOutlineStroke(s); assertEquals(p1, p2); // webFilled p1.setWebFilled(false); assertFalse(p1.equals(p2)); p2.setWebFilled(false); assertEquals(p1, p2); // axisLabelGap p1.setAxisLabelGap(0.11); assertFalse(p1.equals(p2)); p2.setAxisLabelGap(0.11); assertEquals(p1, p2); // labelFont p1.setLabelFont(new Font("Serif", Font.PLAIN, 9)); assertFalse(p1.equals(p2)); p2.setLabelFont(new Font("Serif", Font.PLAIN, 9)); assertEquals(p1, p2); // labelPaint p1.setLabelPaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.BLUE)); assertFalse(p1.equals(p2)); p2.setLabelPaint(new GradientPaint(1.0f, 2.0f, Color.RED, 3.0f, 4.0f, Color.BLUE)); assertEquals(p1, p2); // labelGenerator p1.setLabelGenerator(new StandardCategoryItemLabelGenerator("XYZ: {0}", new DecimalFormat("0.000"))); assertFalse(p1.equals(p2)); p2.setLabelGenerator(new StandardCategoryItemLabelGenerator("XYZ: {0}", new DecimalFormat("0.000"))); assertEquals(p1, p2); // toolTipGenerator p1.setToolTipGenerator(new StandardCategoryToolTipGenerator()); assertFalse(p1.equals(p2)); p2.setToolTipGenerator(new StandardCategoryToolTipGenerator()); assertEquals(p1, p2); // urlGenerator p1.setURLGenerator(new StandardCategoryURLGenerator()); assertFalse(p1.equals(p2)); p2.setURLGenerator(new StandardCategoryURLGenerator()); assertEquals(p1, p2); // axisLinePaint p1.setAxisLinePaint(Color.RED); assertFalse(p1.equals(p2)); p2.setAxisLinePaint(Color.RED); assertEquals(p1, p2); // axisLineStroke p1.setAxisLineStroke(new BasicStroke(1.1f)); assertFalse(p1.equals(p2)); p2.setAxisLineStroke(new BasicStroke(1.1f)); assertEquals(p1, p2); } /** * Confirm that cloning works. * @throws CloneNotSupportedException */ @Test public void testCloning() throws CloneNotSupportedException { SpiderWebPlot p1 = new SpiderWebPlot(new DefaultCategoryDataset()); Rectangle2D legendShape = new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0); p1.setLegendItemShape(legendShape); SpiderWebPlot p2 = (SpiderWebPlot) p1.clone(); assertNotSame(p1, p2); assertSame(p1.getClass(), p2.getClass()); assertEquals(p1, p2); // change the legendItemShape legendShape.setRect(4.0, 3.0, 2.0, 1.0); assertFalse(p1.equals(p2)); p2.setLegendItemShape(legendShape); assertEquals(p1, p2); // change a series paint p1.setSeriesPaint(1, Color.BLACK); assertFalse(p1.equals(p2)); p2.setSeriesPaint(1, Color.BLACK); assertEquals(p1, p2); // change a series outline paint p1.setSeriesOutlinePaint(0, Color.RED); assertFalse(p1.equals(p2)); p2.setSeriesOutlinePaint(0, Color.RED); assertEquals(p1, p2); // change a series outline stroke p1.setSeriesOutlineStroke(0, new BasicStroke(1.1f)); assertFalse(p1.equals(p2)); p2.setSeriesOutlineStroke(0, new BasicStroke(1.1f)); assertEquals(p1, p2); } /** * Serialize an instance, restore it, and check for equality. * @throws IOException * @throws ClassNotFoundException */ @Test public void testSerialization() throws IOException, ClassNotFoundException { SpiderWebPlot p1 = new SpiderWebPlot(new DefaultCategoryDataset()); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); SpiderWebPlot p2 = (SpiderWebPlot) in.readObject(); in.close(); assertEquals(p1, p2); } /** * Draws the chart with a null info object to make sure that no exceptions * are thrown. */ @Test public void testDrawWithNullInfo() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(35.0, "S1", "C1"); dataset.addValue(45.0, "S1", "C2"); dataset.addValue(55.0, "S1", "C3"); dataset.addValue(15.0, "S1", "C4"); dataset.addValue(25.0, "S1", "C5"); SpiderWebPlot plot = new SpiderWebPlot(dataset); 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, null); g2.dispose(); } /** * Fetches the legend items and checks the values. */ @Test public void testGetLegendItems() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(35.0, "S1", "C1"); dataset.addValue(45.0, "S1", "C2"); dataset.addValue(55.0, "S2", "C1"); dataset.addValue(15.0, "S2", "C2"); SpiderWebPlot plot = new SpiderWebPlot(dataset); List<LegendItem> legendItems = plot.getLegendItems(); assertEquals(2, legendItems.size()); LegendItem item1 = legendItems.get(0); assertEquals("S1", item1.getLabel()); assertEquals("S1", item1.getSeriesKey()); assertEquals(0, item1.getSeriesIndex()); assertEquals(dataset, item1.getDataset()); assertEquals(0, item1.getDatasetIndex()); LegendItem item2 = legendItems.get(1); assertEquals("S2", item2.getLabel()); assertEquals("S2", item2.getSeriesKey()); assertEquals(1, item2.getSeriesIndex()); assertEquals(dataset, item2.getDataset()); assertEquals(0, item2.getDatasetIndex()); } }
13,179
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
MarkerTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/plot/MarkerTest.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.] * * ---------------- * MarkerTests.java * ---------------- * (C) Copyright 2006-2012, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 05-Sep-2006 : Version 1 (DG); * 17-Jun-2012 : Removed JCommon dependencies (DG); * */ package org.jfree.chart.plot; import org.jfree.chart.event.MarkerChangeEvent; import org.jfree.chart.event.MarkerChangeListener; import org.jfree.chart.ui.LengthAdjustmentType; import org.jfree.chart.ui.RectangleAnchor; import org.jfree.chart.ui.RectangleInsets; import org.jfree.chart.ui.TextAnchor; import org.junit.Test; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; import java.util.Arrays; import java.util.EventListener; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; /** * Tests for the {@link Marker} class. */ public class MarkerTest implements MarkerChangeListener { MarkerChangeEvent lastEvent; /** * Some checks for the getPaint() and setPaint() methods. */ @Test public void testGetSetPaint() { // we use ValueMarker for the tests, because we need a concrete // subclass... ValueMarker m = new ValueMarker(1.1); m.addChangeListener(this); this.lastEvent = null; assertEquals(Color.gray, m.getPaint()); m.setPaint(Color.BLUE); assertEquals(Color.BLUE, m.getPaint()); assertEquals(m, this.lastEvent.getMarker()); // check null argument... try { m.setPaint(null); fail("Expected an IllegalArgumentException for null."); } catch (IllegalArgumentException e) { assertEquals("Null 'paint' argument.", e.getMessage()); } } /** * Some checks for the getStroke() and setStroke() methods. */ @Test public void testGetSetStroke() { // we use ValueMarker for the tests, because we need a concrete // subclass... ValueMarker m = new ValueMarker(1.1); m.addChangeListener(this); this.lastEvent = null; assertEquals(new BasicStroke(0.5f), m.getStroke()); m.setStroke(new BasicStroke(1.1f)); assertEquals(new BasicStroke(1.1f), m.getStroke()); assertEquals(m, this.lastEvent.getMarker()); // check null argument... try { m.setStroke(null); fail("Expected an IllegalArgumentException for null."); } catch (IllegalArgumentException e) { assertEquals("Null 'stroke' argument.", e.getMessage()); } } /** * Some checks for the getOutlinePaint() and setOutlinePaint() methods. */ @Test public void testGetSetOutlinePaint() { // we use ValueMarker for the tests, because we need a concrete // subclass... ValueMarker m = new ValueMarker(1.1); m.addChangeListener(this); this.lastEvent = null; assertEquals(Color.gray, m.getOutlinePaint()); m.setOutlinePaint(Color.yellow); assertEquals(Color.yellow, m.getOutlinePaint()); assertEquals(m, this.lastEvent.getMarker()); // check null argument... m.setOutlinePaint(null); assertEquals(null, m.getOutlinePaint()); } /** * Some checks for the getOutlineStroke() and setOutlineStroke() methods. */ @Test public void testGetSetOutlineStroke() { // we use ValueMarker for the tests, because we need a concrete // subclass... ValueMarker m = new ValueMarker(1.1); m.addChangeListener(this); this.lastEvent = null; assertEquals(new BasicStroke(0.5f), m.getOutlineStroke()); m.setOutlineStroke(new BasicStroke(1.1f)); assertEquals(new BasicStroke(1.1f), m.getOutlineStroke()); assertEquals(m, this.lastEvent.getMarker()); // check null argument... m.setOutlineStroke(null); assertEquals(null, m.getOutlineStroke()); } private static final float EPSILON = 0.000000001f; /** * Some checks for the getAlpha() and setAlpha() methods. */ @Test public void testGetSetAlpha() { // we use ValueMarker for the tests, because we need a concrete // subclass... ValueMarker m = new ValueMarker(1.1); m.addChangeListener(this); this.lastEvent = null; assertEquals(0.8f, m.getAlpha(), EPSILON); m.setAlpha(0.5f); assertEquals(0.5f, m.getAlpha(), EPSILON); assertEquals(m, this.lastEvent.getMarker()); } /** * Some checks for the getLabel() and setLabel() methods. */ @Test public void testGetSetLabel() { // we use ValueMarker for the tests, because we need a concrete // subclass... ValueMarker m = new ValueMarker(1.1); m.addChangeListener(this); this.lastEvent = null; assertEquals(null, m.getLabel()); m.setLabel("XYZ"); assertEquals("XYZ", m.getLabel()); assertEquals(m, this.lastEvent.getMarker()); // check null argument... m.setLabel(null); assertEquals(null, m.getLabel()); } /** * Some checks for the getLabelFont() and setLabelFont() methods. */ @Test public void testGetSetLabelFont() { // we use ValueMarker for the tests, because we need a concrete // subclass... ValueMarker m = new ValueMarker(1.1); m.addChangeListener(this); this.lastEvent = null; assertEquals(new Font("SansSerif", Font.PLAIN, 9), m.getLabelFont()); m.setLabelFont(new Font("SansSerif", Font.BOLD, 10)); assertEquals(new Font("SansSerif", Font.BOLD, 10), m.getLabelFont()); assertEquals(m, this.lastEvent.getMarker()); // check null argument... try { m.setLabelFont(null); fail("Expected an IllegalArgumentException for null."); } catch (IllegalArgumentException e) { assertEquals("Null 'font' argument.", e.getMessage()); } } /** * Some checks for the getLabelPaint() and setLabelPaint() methods. */ @Test public void testGetSetLabelPaint() { // we use ValueMarker for the tests, because we need a concrete // subclass... ValueMarker m = new ValueMarker(1.1); m.addChangeListener(this); this.lastEvent = null; assertEquals(Color.BLACK, m.getLabelPaint()); m.setLabelPaint(Color.RED); assertEquals(Color.RED, m.getLabelPaint()); assertEquals(m, this.lastEvent.getMarker()); // check null argument... try { m.setLabelPaint(null); fail("Expected an IllegalArgumentException for null."); } catch (IllegalArgumentException e) { assertEquals("Null 'paint' argument.", e.getMessage()); } } /** * Some checks for the getLabelAnchor() and setLabelAnchor() methods. */ @Test public void testGetSetLabelAnchor() { // we use ValueMarker for the tests, because we need a concrete // subclass... ValueMarker m = new ValueMarker(1.1); m.addChangeListener(this); this.lastEvent = null; assertEquals(RectangleAnchor.TOP_LEFT, m.getLabelAnchor()); m.setLabelAnchor(RectangleAnchor.TOP); assertEquals(RectangleAnchor.TOP, m.getLabelAnchor()); assertEquals(m, this.lastEvent.getMarker()); // check null argument... try { m.setLabelAnchor(null); fail("Expected an IllegalArgumentException for null."); } catch (IllegalArgumentException e) { assertEquals("Null 'anchor' argument.", e.getMessage()); } } /** * Some checks for the getLabelOffset() and setLabelOffset() methods. */ @Test public void testGetSetLabelOffset() { // we use ValueMarker for the tests, because we need a concrete // subclass... ValueMarker m = new ValueMarker(1.1); m.addChangeListener(this); this.lastEvent = null; assertEquals(new RectangleInsets(3, 3, 3, 3), m.getLabelOffset()); m.setLabelOffset(new RectangleInsets(1, 2, 3, 4)); assertEquals(new RectangleInsets(1, 2, 3, 4), m.getLabelOffset()); assertEquals(m, this.lastEvent.getMarker()); // check null argument... try { m.setLabelOffset(null); fail("Expected an IllegalArgumentException for null."); } catch (IllegalArgumentException e) { assertEquals("Null 'offset' argument.", e.getMessage()); } } /** * Some checks for the getLabelOffsetType() and setLabelOffsetType() * methods. */ @Test public void testGetSetLabelOffsetType() { // we use ValueMarker for the tests, because we need a concrete // subclass... ValueMarker m = new ValueMarker(1.1); m.addChangeListener(this); this.lastEvent = null; assertEquals(LengthAdjustmentType.CONTRACT, m.getLabelOffsetType()); m.setLabelOffsetType(LengthAdjustmentType.EXPAND); assertEquals(LengthAdjustmentType.EXPAND, m.getLabelOffsetType()); assertEquals(m, this.lastEvent.getMarker()); // check null argument... try { m.setLabelOffsetType(null); fail("Expected an IllegalArgumentException for null."); } catch (IllegalArgumentException e) { assertEquals("Null 'adj' argument.", e.getMessage()); } } /** * Some checks for the getLabelTextAnchor() and setLabelTextAnchor() * methods. */ @Test public void testGetSetLabelTextAnchor() { // we use ValueMarker for the tests, because we need a concrete // subclass... ValueMarker m = new ValueMarker(1.1); m.addChangeListener(this); this.lastEvent = null; assertEquals(TextAnchor.CENTER, m.getLabelTextAnchor()); m.setLabelTextAnchor(TextAnchor.BASELINE_LEFT); assertEquals(TextAnchor.BASELINE_LEFT, m.getLabelTextAnchor()); assertEquals(m, this.lastEvent.getMarker()); // check null argument... try { m.setLabelTextAnchor(null); fail("Expected an IllegalArgumentException for null."); } catch (IllegalArgumentException e) { assertEquals("Null 'anchor' argument.", e.getMessage()); } } /** * Checks that a CategoryPlot deregisters listeners when clearing markers. */ @Test public void testListenersWithCategoryPlot() { CategoryPlot plot = new CategoryPlot(); CategoryMarker marker1 = new CategoryMarker("X"); ValueMarker marker2 = new ValueMarker(1.0); plot.addDomainMarker(marker1); plot.addRangeMarker(marker2); EventListener[] listeners1 = marker1.getListeners( MarkerChangeListener.class); assertTrue(Arrays.asList(listeners1).contains(plot)); EventListener[] listeners2 = marker1.getListeners( MarkerChangeListener.class); assertTrue(Arrays.asList(listeners2).contains(plot)); plot.clearDomainMarkers(); plot.clearRangeMarkers(); listeners1 = marker1.getListeners(MarkerChangeListener.class); assertFalse(Arrays.asList(listeners1).contains(plot)); listeners2 = marker1.getListeners(MarkerChangeListener.class); assertFalse(Arrays.asList(listeners2).contains(plot)); } /** * Checks that an XYPlot deregisters listeners when clearing markers. */ @Test public void testListenersWithXYPlot() { XYPlot plot = new XYPlot(); ValueMarker marker1 = new ValueMarker(1.0); ValueMarker marker2 = new ValueMarker(2.0); plot.addDomainMarker(marker1); plot.addRangeMarker(marker2); EventListener[] listeners1 = marker1.getListeners( MarkerChangeListener.class); assertTrue(Arrays.asList(listeners1).contains(plot)); EventListener[] listeners2 = marker1.getListeners( MarkerChangeListener.class); assertTrue(Arrays.asList(listeners2).contains(plot)); plot.clearDomainMarkers(); plot.clearRangeMarkers(); listeners1 = marker1.getListeners(MarkerChangeListener.class); assertFalse(Arrays.asList(listeners1).contains(plot)); listeners2 = marker1.getListeners(MarkerChangeListener.class); assertFalse(Arrays.asList(listeners2).contains(plot)); } /** * Records the last event. * * @param event the event. */ @Override public void markerChanged(MarkerChangeEvent event) { this.lastEvent = event; } }
14,217
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
RingPlotTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/plot/RingPlotTest.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.] * * ----------------- * RingPlotTest.java * ----------------- * (C) Copyright 2004-2014, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 09-Nov-2004 : Version 1 (DG); * 12-Oct-2006 : Updated testEquals() (DG); * 28-Feb-2014 : Add tests for new fields (DG); * */ package org.jfree.chart.plot; import static org.junit.Assert.assertTrue; 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 org.junit.Test; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; import java.awt.GradientPaint; import java.awt.Stroke; import java.io.IOException; import java.text.DecimalFormat; import org.jfree.chart.TestUtilities; /** * Tests for the {@link RingPlot} class. */ public class RingPlotTest { /** * Some checks for the equals() method. */ @Test public void testEquals() { RingPlot plot1 = new RingPlot(null); RingPlot plot2 = new RingPlot(null); assertEquals(plot1, plot2); assertEquals(plot2, plot1); plot1.setCenterTextMode(CenterTextMode.FIXED); assertFalse(plot1.equals(plot2)); plot2.setCenterTextMode(CenterTextMode.FIXED); assertTrue(plot1.equals(plot2)); plot1.setCenterText("ABC"); assertFalse(plot1.equals(plot2)); plot2.setCenterText("ABC"); assertTrue(plot1.equals(plot2)); plot1.setCenterTextColor(Color.RED); assertFalse(plot1.equals(plot2)); plot2.setCenterTextColor(Color.RED); assertTrue(plot1.equals(plot2)); plot1.setCenterTextFont(new Font(Font.SERIF, Font.PLAIN, 7)); assertFalse(plot1.equals(plot2)); plot2.setCenterTextFont(new Font(Font.SERIF, Font.PLAIN, 7)); assertTrue(plot1.equals(plot2)); plot1.setCenterTextFormatter(new DecimalFormat("0.000")); assertFalse(plot1.equals(plot2)); plot2.setCenterTextFormatter(new DecimalFormat("0.000")); assertTrue(plot1.equals(plot2)); // separatorsVisible plot1.setSeparatorsVisible(false); assertFalse(plot1.equals(plot2)); plot2.setSeparatorsVisible(false); assertEquals(plot1, plot2); // separatorStroke Stroke s = new BasicStroke(1.1f); plot1.setSeparatorStroke(s); assertFalse(plot1.equals(plot2)); plot2.setSeparatorStroke(s); assertEquals(plot1, plot2); // separatorPaint plot1.setSeparatorPaint(new GradientPaint(1.0f, 2.0f, Color.RED, 2.0f, 1.0f, Color.BLUE)); assertFalse(plot1.equals(plot2)); plot2.setSeparatorPaint(new GradientPaint(1.0f, 2.0f, Color.RED, 2.0f, 1.0f, Color.BLUE)); assertEquals(plot1, plot2); // innerSeparatorExtension plot1.setInnerSeparatorExtension(0.01); assertFalse(plot1.equals(plot2)); plot2.setInnerSeparatorExtension(0.01); assertEquals(plot1, plot2); // outerSeparatorExtension plot1.setOuterSeparatorExtension(0.02); assertFalse(plot1.equals(plot2)); plot2.setOuterSeparatorExtension(0.02); assertEquals(plot1, plot2); // sectionDepth plot1.setSectionDepth(0.12); assertFalse(plot1.equals(plot2)); plot2.setSectionDepth(0.12); assertEquals(plot1, plot2); } /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { RingPlot p1 = new RingPlot(null); GradientPaint gp = new GradientPaint(1.0f, 2.0f, Color.yellow, 3.0f, 4.0f, Color.RED); p1.setSeparatorPaint(gp); RingPlot p2 = (RingPlot) p1.clone(); assertNotSame(p1, p2); assertSame(p1.getClass(), p2.getClass()); assertEquals(p1, p2); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { RingPlot p1 = new RingPlot(null); GradientPaint gp = new GradientPaint(1.0f, 2.0f, Color.yellow, 3.0f, 4.0f, Color.RED); p1.setSeparatorPaint(gp); RingPlot p2 = (RingPlot) TestUtilities.serialised(p1); assertEquals(p1, p2); } }
5,741
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
IntervalMarkerTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/plot/IntervalMarkerTest.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.] * * ------------------------ * IntervalMarkerTests.java * ------------------------ * (C) Copyright 2004-2012, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 14-Jun-2004 : Version 1 (DG); * 05-Sep-2006 : Added checks for MarkerChangeEvents (DG); * 17-Jun-2012 : Removed JCommon dependencies (DG); * */ package org.jfree.chart.plot; import org.jfree.chart.event.MarkerChangeEvent; import org.jfree.chart.event.MarkerChangeListener; import org.jfree.chart.ui.GradientPaintTransformType; import org.jfree.chart.ui.GradientPaintTransformer; import org.jfree.chart.ui.StandardGradientPaintTransformer; 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 IntervalMarker} class. */ public class IntervalMarkerTest implements MarkerChangeListener { MarkerChangeEvent lastEvent; /** * Records the last event. * * @param event the last event. */ @Override public void markerChanged(MarkerChangeEvent event) { this.lastEvent = event; } /** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { IntervalMarker m1 = new IntervalMarker(45.0, 50.0); IntervalMarker m2 = new IntervalMarker(45.0, 50.0); assertEquals(m1, m2); assertEquals(m2, m1); m1 = new IntervalMarker(44.0, 50.0); assertFalse(m1.equals(m2)); m2 = new IntervalMarker(44.0, 50.0); assertEquals(m1, m2); m1 = new IntervalMarker(44.0, 55.0); assertFalse(m1.equals(m2)); m2 = new IntervalMarker(44.0, 55.0); assertEquals(m1, m2); GradientPaintTransformer t = new StandardGradientPaintTransformer( GradientPaintTransformType.HORIZONTAL); m1.setGradientPaintTransformer(t); assertFalse(m1.equals(m2)); m2.setGradientPaintTransformer(t); assertEquals(m1, m2); } /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { IntervalMarker m1 = new IntervalMarker(45.0, 50.0); IntervalMarker m2 = (IntervalMarker) m1.clone(); assertNotSame(m1, m2); assertSame(m1.getClass(), m2.getClass()); assertEquals(m1, m2); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { IntervalMarker m1 = new IntervalMarker(45.0, 50.0); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(m1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); IntervalMarker m2 = (IntervalMarker) in.readObject(); in.close(); assertEquals(m1, m2); } private static final double EPSILON = 0.0000000001; /** * Some checks for the getStartValue() and setStartValue() methods. */ @Test public void testGetSetStartValue() { IntervalMarker m = new IntervalMarker(1.0, 2.0); m.addChangeListener(this); this.lastEvent = null; assertEquals(1.0, m.getStartValue(), EPSILON); m.setStartValue(0.5); assertEquals(0.5, m.getStartValue(), EPSILON); assertEquals(m, this.lastEvent.getMarker()); } /** * Some checks for the getEndValue() and setEndValue() methods. */ @Test public void testGetSetEndValue() { IntervalMarker m = new IntervalMarker(1.0, 2.0); m.addChangeListener(this); this.lastEvent = null; assertEquals(2.0, m.getEndValue(), EPSILON); m.setEndValue(0.5); assertEquals(0.5, m.getEndValue(), EPSILON); assertEquals(m, this.lastEvent.getMarker()); } }
5,647
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
CombinedRangeCategoryPlotTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/plot/CombinedRangeCategoryPlotTest.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.] * * ------------------------------------ * CombinedRangeCategoryPlotTests.java * ------------------------------------ * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 21-Aug-2003 : Version 1 (DG); * 03-Jan-2008 : Added testNotification() (DG); * */ package org.jfree.chart.plot; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.event.ChartChangeEvent; import org.jfree.chart.event.ChartChangeListener; import org.jfree.chart.labels.StandardCategoryToolTipGenerator; import org.jfree.chart.renderer.category.BarRenderer; import org.jfree.chart.renderer.category.LineAndShapeRenderer; import org.jfree.data.category.CategoryDataset; import org.jfree.data.category.DefaultCategoryDataset; 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 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 CombinedRangeCategoryPlot} class. */ public class CombinedRangeCategoryPlotTest implements ChartChangeListener { /** A list of the events received. */ private List<ChartChangeEvent> events = new java.util.ArrayList<ChartChangeEvent>(); /** * Receives a chart change event. * * @param event the event. */ @Override public void chartChanged(ChartChangeEvent event) { this.events.add(event); } /** * Test the equals() method. */ @Test public void testEquals() { CombinedRangeCategoryPlot plot1 = createPlot(); CombinedRangeCategoryPlot plot2 = createPlot(); assertEquals(plot1, plot2); } /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { CombinedRangeCategoryPlot plot1 = createPlot(); CombinedRangeCategoryPlot plot2 = (CombinedRangeCategoryPlot) plot1.clone(); assertNotSame(plot1, plot2); assertSame(plot1.getClass(), plot2.getClass()); assertEquals(plot1, plot2); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { CombinedRangeCategoryPlot plot1 = createPlot(); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(plot1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); CombinedRangeCategoryPlot plot2 = (CombinedRangeCategoryPlot) in.readObject(); in.close(); assertEquals(plot1, plot2); } /** * This is a test to replicate the bug report 1121172. */ @Test public void testRemoveSubplot() { CombinedRangeCategoryPlot plot = new CombinedRangeCategoryPlot(); CategoryPlot plot1 = new CategoryPlot(); CategoryPlot plot2 = new CategoryPlot(); CategoryPlot plot3 = new CategoryPlot(); plot.add(plot1); plot.add(plot2); plot.add(plot3); plot.remove(plot2); List plots = plot.getSubplots(); assertEquals(2, plots.size()); } /** * Check that only one chart change event is generated by a change to a * subplot. */ @Test public void testNotification() { CombinedRangeCategoryPlot plot = createPlot(); JFreeChart chart = new JFreeChart(plot); chart.addChangeListener(this); CategoryPlot subplot1 = plot.getSubplots().get(0); NumberAxis yAxis = (NumberAxis) subplot1.getRangeAxis(); yAxis.setAutoRangeIncludesZero(!yAxis.getAutoRangeIncludesZero()); assertEquals(1, this.events.size()); // a redraw should NOT trigger another change event BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); this.events.clear(); chart.draw(g2, new Rectangle2D.Double(0.0, 0.0, 200.0, 100.0)); assertTrue(this.events.isEmpty()); } /** * Creates a dataset. * * @return A dataset. */ public CategoryDataset createDataset1() { DefaultCategoryDataset result = new DefaultCategoryDataset(); // row keys... String series1 = "First"; String series2 = "Second"; // column keys... String type1 = "Type 1"; String type2 = "Type 2"; String type3 = "Type 3"; String type4 = "Type 4"; String type5 = "Type 5"; String type6 = "Type 6"; String type7 = "Type 7"; String type8 = "Type 8"; result.addValue(1.0, series1, type1); result.addValue(4.0, series1, type2); result.addValue(3.0, series1, type3); result.addValue(5.0, series1, type4); result.addValue(5.0, series1, type5); result.addValue(7.0, series1, type6); result.addValue(7.0, series1, type7); result.addValue(8.0, series1, type8); result.addValue(5.0, series2, type1); result.addValue(7.0, series2, type2); result.addValue(6.0, series2, type3); result.addValue(8.0, series2, type4); result.addValue(4.0, series2, type5); result.addValue(4.0, series2, type6); result.addValue(2.0, series2, type7); result.addValue(1.0, series2, type8); return result; } /** * Creates a dataset. * * @return A dataset. */ public CategoryDataset createDataset2() { DefaultCategoryDataset result = new DefaultCategoryDataset(); // row keys... String series1 = "Third"; String series2 = "Fourth"; // column keys... String type1 = "Type 1"; String type2 = "Type 2"; String type3 = "Type 3"; String type4 = "Type 4"; String type5 = "Type 5"; String type6 = "Type 6"; String type7 = "Type 7"; String type8 = "Type 8"; result.addValue(11.0, series1, type1); result.addValue(14.0, series1, type2); result.addValue(13.0, series1, type3); result.addValue(15.0, series1, type4); result.addValue(15.0, series1, type5); result.addValue(17.0, series1, type6); result.addValue(17.0, series1, type7); result.addValue(18.0, series1, type8); result.addValue(15.0, series2, type1); result.addValue(17.0, series2, type2); result.addValue(16.0, series2, type3); result.addValue(18.0, series2, type4); result.addValue(14.0, series2, type5); result.addValue(14.0, series2, type6); result.addValue(12.0, series2, type7); result.addValue(11.0, series2, type8); return result; } /** * Creates a sample plot. * * @return A plot. */ private CombinedRangeCategoryPlot createPlot() { CategoryDataset dataset1 = createDataset1(); CategoryAxis catAxis1 = new CategoryAxis("Category"); LineAndShapeRenderer renderer1 = new LineAndShapeRenderer(); renderer1.setDefaultToolTipGenerator( new StandardCategoryToolTipGenerator()); CategoryPlot subplot1 = new CategoryPlot(dataset1, catAxis1, null, renderer1); subplot1.setDomainGridlinesVisible(true); CategoryDataset dataset2 = createDataset2(); CategoryAxis catAxis2 = new CategoryAxis("Category"); BarRenderer renderer2 = new BarRenderer(); renderer2.setDefaultToolTipGenerator( new StandardCategoryToolTipGenerator()); CategoryPlot subplot2 = new CategoryPlot(dataset2, catAxis2, null, renderer2); subplot2.setDomainGridlinesVisible(true); NumberAxis rangeAxis = new NumberAxis("Value"); CombinedRangeCategoryPlot plot = new CombinedRangeCategoryPlot( rangeAxis); plot.add(subplot1, 2); plot.add(subplot2, 1); return plot; } }
9,937
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
MyPlotChangeListener.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/plot/MyPlotChangeListener.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.] * * ------------------------- * MyPlotChangeListener.java * ------------------------- * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 21-Mar-2005 : Version 1 (DG); * */ package org.jfree.chart.plot; import org.jfree.chart.event.PlotChangeEvent; import org.jfree.chart.event.PlotChangeListener; /** * A utility class for testing plot events. */ public class MyPlotChangeListener implements PlotChangeListener { private PlotChangeEvent event; /** * Creates a new instance. */ public MyPlotChangeListener() { this.event = null; } /** * Returns the last event received by the listener. * * @return The event. */ public PlotChangeEvent getEvent() { return this.event; } /** * Sets the event for the listener. * * @param e the event. */ public void setEvent(PlotChangeEvent e) { this.event = e; } /** * Receives notification of a plot change event. * * @param e the event. */ @Override public void plotChanged(PlotChangeEvent e) { this.event = e; } }
2,488
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
PieLabelRecordTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/plot/PieLabelRecordTest.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.] * * ------------------------ * PieLabelRecordTests.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.plot; import org.jfree.chart.text.TextBox; 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.assertTrue; /** * Some tests for the {@link CategoryMarker} class. */ public class PieLabelRecordTest { /** * Confirm that the equals method can distinguish all the required fields. */ @Test public void testEquals() { PieLabelRecord p1 = new PieLabelRecord("A", 1.0, 2.0, new TextBox("B"), 3.0, 4.0, 5.0); PieLabelRecord p2 = new PieLabelRecord("A", 1.0, 2.0, new TextBox("B"), 3.0, 4.0, 5.0); assertEquals(p1, p2); assertEquals(p2, p1); p1 = new PieLabelRecord("B", 1.0, 2.0, new TextBox("B"), 3.0, 4.0, 5.0); assertFalse(p1.equals(p2)); p2 = new PieLabelRecord("B", 1.0, 2.0, new TextBox("B"), 3.0, 4.0, 5.0); assertEquals(p1, p2); p1 = new PieLabelRecord("B", 1.1, 2.0, new TextBox("B"), 3.0, 4.0, 5.0); assertFalse(p1.equals(p2)); p2 = new PieLabelRecord("B", 1.1, 2.0, new TextBox("B"), 3.0, 4.0, 5.0); assertEquals(p1, p2); p1 = new PieLabelRecord("B", 1.1, 2.2, new TextBox("B"), 3.0, 4.0, 5.0); assertFalse(p1.equals(p2)); p2 = new PieLabelRecord("B", 1.1, 2.2, new TextBox("B"), 3.0, 4.0, 5.0); assertEquals(p1, p2); p1 = new PieLabelRecord("B", 1.1, 2.2, new TextBox("C"), 3.0, 4.0, 5.0); assertFalse(p1.equals(p2)); p2 = new PieLabelRecord("B", 1.1, 2.2, new TextBox("C"), 3.0, 4.0, 5.0); assertEquals(p1, p2); p1 = new PieLabelRecord("B", 1.1, 2.2, new TextBox("C"), 3.3, 4.0, 5.0); assertFalse(p1.equals(p2)); p2 = new PieLabelRecord("B", 1.1, 2.2, new TextBox("C"), 3.3, 4.0, 5.0); assertEquals(p1, p2); p1 = new PieLabelRecord("B", 1.1, 2.2, new TextBox("C"), 3.3, 4.4, 5.0); assertFalse(p1.equals(p2)); p2 = new PieLabelRecord("B", 1.1, 2.2, new TextBox("C"), 3.3, 4.4, 5.0); assertEquals(p1, p2); p1 = new PieLabelRecord("B", 1.1, 2.2, new TextBox("C"), 3.3, 4.4, 5.5); assertFalse(p1.equals(p2)); p2 = new PieLabelRecord("B", 1.1, 2.2, new TextBox("C"), 3.3, 4.4, 5.5); assertEquals(p1, p2); } /** * Confirm that cloning is not implemented. */ @Test public void testCloning() throws CloneNotSupportedException { PieLabelRecord p1 = new PieLabelRecord("A", 1.0, 2.0, new TextBox("B"), 3.0, 4.0, 5.0); assertFalse(p1 instanceof Cloneable); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { PieLabelRecord p1 = new PieLabelRecord("A", 1.0, 2.0, new TextBox("B"), 3.0, 4.0, 5.0); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); PieLabelRecord p2 = (PieLabelRecord) in.readObject(); in.close(); boolean b = p1.equals(p2); assertTrue(b); } }
5,187
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
CombinedDomainXYPlotTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/plot/CombinedDomainXYPlotTest.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.] * * ------------------------------ * CombinedDomainXYPlotTests.java * ------------------------------ * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. * * Original Author: David Gilbert (for Object Refinery Limited); * Contributor(s): -; * * Changes * ------- * 21-Aug-2003 : Version 1 (DG); * 03-Jan-2008 : Added testNotification() (DG); * */ package org.jfree.chart.plot; import org.jfree.chart.JFreeChart; import org.jfree.chart.annotations.XYTextAnnotation; import org.jfree.chart.axis.AxisLocation; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.event.ChartChangeEvent; import org.jfree.chart.event.ChartChangeListener; import org.jfree.chart.renderer.xy.StandardXYItemRenderer; import org.jfree.chart.renderer.xy.XYItemRenderer; import org.jfree.data.xy.XYDataset; import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; import org.junit.Test; import java.awt.Font; 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.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 CombinedDomainXYPlot} class. */ public class CombinedDomainXYPlotTest implements ChartChangeListener { /** A list of the events received. */ private List<ChartChangeEvent> events = new java.util.ArrayList<ChartChangeEvent>(); /** * Receives a chart change event. * * @param event the event. */ @Override public void chartChanged(ChartChangeEvent event) { this.events.add(event); } /** * Confirm that the constructor will accept a null axis. */ @Test public void testConstructor1() { CombinedDomainXYPlot plot = new CombinedDomainXYPlot(null); assertEquals(null, plot.getDomainAxis()); } /** * This is a test to replicate the bug report 987080. */ @Test public void testRemoveSubplot() { CombinedDomainXYPlot plot = new CombinedDomainXYPlot(); XYPlot plot1 = new XYPlot(); XYPlot plot2 = new XYPlot(); plot.add(plot1); plot.add(plot2); // remove plot2, but plot1 is removed instead plot.remove(plot2); List plots = plot.getSubplots(); assertSame(plots.get(0), plot1); } /** * Tests the equals() method. */ @Test public void testEquals() { CombinedDomainXYPlot plot1 = createPlot(); CombinedDomainXYPlot plot2 = createPlot(); assertEquals(plot1, plot2); assertEquals(plot2, plot1); } /** * Confirm that cloning works. */ @Test public void testCloning() throws CloneNotSupportedException { CombinedDomainXYPlot plot1 = createPlot(); CombinedDomainXYPlot plot2 = (CombinedDomainXYPlot) plot1.clone(); assertNotSame(plot1, plot2); assertSame(plot1.getClass(), plot2.getClass()); assertEquals(plot1, plot2); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { CombinedDomainXYPlot plot1 = createPlot(); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(plot1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( buffer.toByteArray())); CombinedDomainXYPlot plot2 = (CombinedDomainXYPlot) in.readObject(); in.close(); assertEquals(plot1, plot2); } /** * Check that only one chart change event is generated by a change to a * subplot. */ @Test public void testNotification() { CombinedDomainXYPlot plot = createPlot(); JFreeChart chart = new JFreeChart(plot); chart.addChangeListener(this); XYPlot subplot1 = plot.getSubplots().get(0); NumberAxis yAxis = (NumberAxis) subplot1.getRangeAxis(); yAxis.setAutoRangeIncludesZero(!yAxis.getAutoRangeIncludesZero()); assertEquals(1, this.events.size()); // a redraw should NOT trigger another change event BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); this.events.clear(); chart.draw(g2, new Rectangle2D.Double(0.0, 0.0, 200.0, 100.0)); assertTrue(this.events.isEmpty()); } /** * Creates a sample dataset. * * @return Series 1. */ private XYDataset createDataset1() { // create dataset 1... XYSeries series1 = new XYSeries("Series 1"); series1.add(10.0, 12353.3); series1.add(20.0, 13734.4); series1.add(30.0, 14525.3); series1.add(40.0, 13984.3); series1.add(50.0, 12999.4); series1.add(60.0, 14274.3); series1.add(70.0, 15943.5); series1.add(80.0, 14845.3); series1.add(90.0, 14645.4); series1.add(100.0, 16234.6); series1.add(110.0, 17232.3); series1.add(120.0, 14232.2); series1.add(130.0, 13102.2); series1.add(140.0, 14230.2); series1.add(150.0, 11235.2); XYSeries series2 = new XYSeries("Series 2"); series2.add(10.0, 15000.3); series2.add(20.0, 11000.4); series2.add(30.0, 17000.3); series2.add(40.0, 15000.3); series2.add(50.0, 14000.4); series2.add(60.0, 12000.3); series2.add(70.0, 11000.5); series2.add(80.0, 12000.3); series2.add(90.0, 13000.4); series2.add(100.0, 12000.6); series2.add(110.0, 13000.3); series2.add(120.0, 17000.2); series2.add(130.0, 18000.2); series2.add(140.0, 16000.2); series2.add(150.0, 17000.2); XYSeriesCollection collection = new XYSeriesCollection(); collection.addSeries(series1); collection.addSeries(series2); return collection; } /** * Creates a sample dataset. * * @return Series 2. */ private XYDataset createDataset2() { XYSeries series2 = new XYSeries("Series 3"); series2.add(10.0, 16853.2); series2.add(20.0, 19642.3); series2.add(30.0, 18253.5); series2.add(40.0, 15352.3); series2.add(50.0, 13532.0); series2.add(100.0, 12635.3); series2.add(110.0, 13998.2); series2.add(120.0, 11943.2); series2.add(130.0, 16943.9); series2.add(140.0, 17843.2); series2.add(150.0, 16495.3); series2.add(160.0, 17943.6); series2.add(170.0, 18500.7); series2.add(180.0, 19595.9); return new XYSeriesCollection(series2); } /** * Creates a sample plot. * * @return A sample plot. */ private CombinedDomainXYPlot createPlot() { // create subplot 1... XYDataset data1 = createDataset1(); XYItemRenderer renderer1 = new StandardXYItemRenderer(); NumberAxis rangeAxis1 = new NumberAxis("Range 1"); XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1); subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); XYTextAnnotation annotation = new XYTextAnnotation("Hello!", 50.0, 10000.0); annotation.setFont(new Font("SansSerif", Font.PLAIN, 9)); annotation.setRotationAngle(Math.PI / 4.0); subplot1.addAnnotation(annotation); // create subplot 2... XYDataset data2 = createDataset2(); XYItemRenderer renderer2 = new StandardXYItemRenderer(); NumberAxis rangeAxis2 = new NumberAxis("Range 2"); rangeAxis2.setAutoRangeIncludesZero(false); XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2); subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); // parent plot... CombinedDomainXYPlot plot = new CombinedDomainXYPlot( new NumberAxis("Domain")); plot.setGap(10.0); // add the subplots... plot.add(subplot1, 1); plot.add(subplot2, 1); plot.setOrientation(PlotOrientation.VERTICAL); return plot; } }
9,872
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z
PiePlot3DTest.java
/FileExtraction/Java_unseen/akardapolov_ASH-Viewer/jfreechart-fse/src/test/java/org/jfree/chart/plot/PiePlot3DTest.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.] * * ------------------- * Pie3DPlotTests.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); * 22-Mar-2007 : Added testEquals() (DG); * 05-Oct-2007 : Modified testEquals() for new field (DG); * 19-Mar-2008 : Added test for null dataset (DG); * */ package org.jfree.chart.plot; import org.jfree.chart.ChartFactory; import org.jfree.chart.JFreeChart; 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; /** * Tests for the {@link PiePlot3D} class. */ public class PiePlot3DTest { /** * Some checks for the equals() method. */ @Test public void testEquals() { PiePlot3D p1 = new PiePlot3D(); PiePlot3D p2 = new PiePlot3D(); assertEquals(p1, p2); assertEquals(p2, p1); p1.setDepthFactor(1.23); assertFalse(p1.equals(p2)); p2.setDepthFactor(1.23); assertEquals(p1, p2); p1.setDarkerSides(true); assertFalse(p1.equals(p2)); p2.setDarkerSides(true); assertEquals(p1, p2); } /** * Serialize an instance, restore it, and check for equality. */ @Test public void testSerialization() throws IOException, ClassNotFoundException { PiePlot3D p1 = new PiePlot3D(null); ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(p1); out.close(); ObjectInput in = new ObjectInputStream( new ByteArrayInputStream(buffer.toByteArray())); PiePlot3D p2 = (PiePlot3D) in.readObject(); in.close(); assertEquals(p1, p2); } /** * Draws a pie chart where the label generator returns null. */ @Test public void testDrawWithNullDataset() { JFreeChart chart = ChartFactory.createPieChart3D("Test", null); 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(); } }
3,958
Java
.java
akardapolov/ASH-Viewer
156
72
35
2011-05-25T05:22:11Z
2023-12-04T11:03:40Z