use of org.jfree.chart.ChartRenderingInfo in project SIMVA-SoS by SESoS.
the class PlotRenderingInfoTest method testCloning.
/**
* 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();
assertTrue(p1 != p2);
assertTrue(p1.getClass() == p2.getClass());
assertTrue(p1.equals(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);
assertTrue(p1.equals(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);
assertTrue(p1.equals(p2));
}
use of org.jfree.chart.ChartRenderingInfo in project SIMVA-SoS by SESoS.
the class PlotRenderingInfoTest method testSerialization.
/**
* Serialize an instance, restore it, and check for equality.
*/
@Test
public void testSerialization() {
PlotRenderingInfo p1 = new PlotRenderingInfo(new ChartRenderingInfo());
PlotRenderingInfo p2 = (PlotRenderingInfo) TestUtilities.serialised(p1);
assertEquals(p1, p2);
}
use of org.jfree.chart.ChartRenderingInfo in project SIMVA-SoS by SESoS.
the class PlotRenderingInfoTest method testEquals.
/**
* Test the equals() method.
*/
@Test
public void testEquals() {
PlotRenderingInfo p1 = new PlotRenderingInfo(new ChartRenderingInfo());
PlotRenderingInfo p2 = new PlotRenderingInfo(new ChartRenderingInfo());
assertTrue(p1.equals(p2));
assertTrue(p2.equals(p1));
p1.setPlotArea(new Rectangle(2, 3, 4, 5));
assertFalse(p1.equals(p2));
p2.setPlotArea(new Rectangle(2, 3, 4, 5));
assertTrue(p1.equals(p2));
p1.setDataArea(new Rectangle(2, 4, 6, 8));
assertFalse(p1.equals(p2));
p2.setDataArea(new Rectangle(2, 4, 6, 8));
assertTrue(p1.equals(p2));
p1.addSubplotInfo(new PlotRenderingInfo(null));
assertFalse(p1.equals(p2));
p2.addSubplotInfo(new PlotRenderingInfo(null));
assertTrue(p1.equals(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));
assertTrue(p1.equals(p2));
}
use of org.jfree.chart.ChartRenderingInfo in project gephi by gephi.
the class ChartUtils method renderChart.
public static String renderChart(JFreeChart chart, String fileName) {
String imageFile = "";
try {
final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
TempDir tempDir = TempDirUtils.createTempDir();
File file1 = tempDir.createFile(fileName);
imageFile = "<IMG SRC=\"file:" + file1.getAbsolutePath() + "\" " + "WIDTH=\"600\" HEIGHT=\"400\" BORDER=\"0\" USEMAP=\"#chart\"></IMG>";
ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info);
} catch (IOException e) {
}
return imageFile;
}
use of org.jfree.chart.ChartRenderingInfo in project jfreechart-fx by jfree.
the class ScrollHandlerFX method handleZoomable.
/**
* Handle the case where a plot implements the {@link Zoomable} interface.
*
* @param zoomable the zoomable plot.
* @param e the mouse wheel event.
*/
private void handleZoomable(ChartCanvas canvas, Zoomable zoomable, ScrollEvent e) {
// don't zoom unless the mouse pointer is in the plot's data area
ChartRenderingInfo info = canvas.getRenderingInfo();
PlotRenderingInfo pinfo = info.getPlotInfo();
Point2D p = new Point2D.Double(e.getX(), e.getY());
if (pinfo.getDataArea().contains(p)) {
Plot plot = (Plot) zoomable;
// do not notify while zooming each axis
boolean notifyState = plot.isNotify();
plot.setNotify(false);
int clicks = (int) e.getDeltaY();
double zf = 1.0 + this.zoomFactor;
if (clicks < 0) {
zf = 1.0 / zf;
}
if (canvas.isDomainZoomable()) {
zoomable.zoomDomainAxes(zf, pinfo, p, true);
}
if (canvas.isRangeZoomable()) {
zoomable.zoomRangeAxes(zf, pinfo, p, true);
}
// this generates the change event too
plot.setNotify(notifyState);
}
}
Aggregations