?? pieplottests.java
字號:
plot1.setShadowXOffset(4.4);
assertFalse(plot1.equals(plot2));
plot2.setShadowXOffset(4.4);
assertTrue(plot1.equals(plot2));
// shadowYOffset
plot1.setShadowYOffset(4.4);
assertFalse(plot1.equals(plot2));
plot2.setShadowYOffset(4.4);
assertTrue(plot1.equals(plot2));
// labelFont
plot1.setLabelFont(new Font("Serif", Font.PLAIN, 18));
assertFalse(plot1.equals(plot2));
plot2.setLabelFont(new Font("Serif", Font.PLAIN, 18));
assertTrue(plot1.equals(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));
assertTrue(plot1.equals(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));
assertTrue(plot1.equals(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));
assertTrue(plot1.equals(plot2));
// labelOutlineStroke
Stroke s = new BasicStroke(1.1f);
plot1.setLabelOutlineStroke(s);
assertFalse(plot1.equals(plot2));
plot2.setLabelOutlineStroke(s);
assertTrue(plot1.equals(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));
assertTrue(plot1.equals(plot2));
// explodePercentages
plot1.setExplodePercent(3, 0.33);
assertFalse(plot1.equals(plot2));
plot2.setExplodePercent(3, 0.33);
assertTrue(plot1.equals(plot2));
// labelGenerator
plot1.setLabelGenerator(new StandardPieSectionLabelGenerator("{2}{1}{0}"));
assertFalse(plot1.equals(plot2));
plot2.setLabelGenerator(new StandardPieSectionLabelGenerator("{2}{1}{0}"));
assertTrue(plot1.equals(plot2));
// labelFont
Font f = new Font("SansSerif", Font.PLAIN, 20);
plot1.setLabelFont(f);
assertFalse(plot1.equals(plot2));
plot2.setLabelFont(f);
assertTrue(plot1.equals(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));
assertTrue(plot1.equals(plot2));
// maximumLabelWidth
plot1.setMaximumLabelWidth(0.33);
assertFalse(plot1.equals(plot2));
plot2.setMaximumLabelWidth(0.33);
assertTrue(plot1.equals(plot2));
// labelGap
plot1.setLabelGap(0.11);
assertFalse(plot1.equals(plot2));
plot2.setLabelGap(0.11);
assertTrue(plot1.equals(plot2));
// links visible
plot1.setLabelLinksVisible(false);
assertFalse(plot1.equals(plot2));
plot2.setLabelLinksVisible(false);
assertTrue(plot1.equals(plot2));
// linkMargin
plot1.setLabelLinkMargin(0.11);
assertFalse(plot1.equals(plot2));
plot2.setLabelLinkMargin(0.11);
assertTrue(plot1.equals(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));
assertTrue(plot1.equals(plot2));
// labelLinkStroke
plot1.setLabelLinkStroke(new BasicStroke(1.0f));
assertFalse(plot1.equals(plot2));
plot2.setLabelLinkStroke(new BasicStroke(1.0f));
assertTrue(plot1.equals(plot2));
// toolTipGenerator
plot1.setToolTipGenerator(
new StandardPieToolTipGenerator("{2}{1}{0}")
);
assertFalse(plot1.equals(plot2));
plot2.setToolTipGenerator(
new StandardPieToolTipGenerator("{2}{1}{0}")
);
assertTrue(plot1.equals(plot2));
// urlGenerator
plot1.setURLGenerator(new StandardPieURLGenerator("xx"));
assertFalse(plot1.equals(plot2));
plot2.setURLGenerator(new StandardPieURLGenerator("xx"));
assertTrue(plot1.equals(plot2));
// minimumArcAngleToDraw
plot1.setMinimumArcAngleToDraw(1.0);
assertFalse(plot1.equals(plot2));
plot2.setMinimumArcAngleToDraw(1.0);
assertTrue(plot1.equals(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));
assertTrue(plot1.equals(plot2));
}
/**
* Some basic checks for the clone() method.
*/
public void testCloning() {
PiePlot p1 = new PiePlot();
PiePlot p2 = null;
try {
p2 = (PiePlot) p1.clone();
}
catch (CloneNotSupportedException e) {
e.printStackTrace();
System.err.println("Failed to clone.");
}
assertTrue(p1 != p2);
assertTrue(p1.getClass() == p2.getClass());
assertTrue(p1.equals(p2));
}
/**
* Serialize an instance, restore it, and check for equality.
*/
public void testSerialization() {
PiePlot p1 = new PiePlot(null);
PiePlot p2 = null;
try {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
ObjectOutput out = new ObjectOutputStream(buffer);
out.writeObject(p1);
out.close();
ObjectInput in = new ObjectInputStream(
new ByteArrayInputStream(buffer.toByteArray())
);
p2 = (PiePlot) in.readObject();
in.close();
}
catch (Exception e) {
e.printStackTrace();
}
assertEquals(p1, p2);
}
/**
* Some checks for the getLegendItems() method.
*/
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);
LegendItemCollection items = plot.getLegendItems();
assertEquals(4, items.getItemCount());
// check that null items are ignored if requested
plot.setIgnoreNullValues(true);
items = plot.getLegendItems();
assertEquals(3, items.getItemCount());
// check that zero items are ignored if requested
plot.setIgnoreZeroValues(true);
items = plot.getLegendItems();
assertEquals(2, items.getItemCount());
// check that negative items are always ignored
dataset.setValue("Item 5", -1.0);
items = plot.getLegendItems();
assertEquals(2, items.getItemCount());
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -