Search in sources :

Example 16 with ChartRenderingInfo

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));
}
Also used : ChartRenderingInfo(org.jfree.chart.ChartRenderingInfo) Rectangle2D(java.awt.geom.Rectangle2D) Test(org.junit.Test)

Example 17 with ChartRenderingInfo

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);
}
Also used : ChartRenderingInfo(org.jfree.chart.ChartRenderingInfo) Test(org.junit.Test)

Example 18 with ChartRenderingInfo

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));
}
Also used : ChartRenderingInfo(org.jfree.chart.ChartRenderingInfo) Rectangle(java.awt.Rectangle) Test(org.junit.Test)

Example 19 with ChartRenderingInfo

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;
}
Also used : TempDir(org.gephi.utils.TempDirUtils.TempDir) StandardEntityCollection(org.jfree.chart.entity.StandardEntityCollection) ChartRenderingInfo(org.jfree.chart.ChartRenderingInfo) IOException(java.io.IOException) File(java.io.File)

Example 20 with ChartRenderingInfo

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);
    }
}
Also used : PlotRenderingInfo(org.jfree.chart.plot.PlotRenderingInfo) Point2D(java.awt.geom.Point2D) Plot(org.jfree.chart.plot.Plot) PiePlot(org.jfree.chart.plot.PiePlot) ChartRenderingInfo(org.jfree.chart.ChartRenderingInfo)

Aggregations

ChartRenderingInfo (org.jfree.chart.ChartRenderingInfo)36 Test (org.junit.Test)15 JFreeChart (org.jfree.chart.JFreeChart)14 CategoryAxis (org.jfree.chart.axis.CategoryAxis)11 NumberAxis (org.jfree.chart.axis.NumberAxis)11 CategoryPlot (org.jfree.chart.plot.CategoryPlot)11 DefaultBoxAndWhiskerCategoryDataset (org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset)10 StandardEntityCollection (org.jfree.chart.entity.StandardEntityCollection)8 BoxAndWhiskerItem (org.jfree.data.statistics.BoxAndWhiskerItem)8 BufferedImage (java.awt.image.BufferedImage)7 PrintWriter (java.io.PrintWriter)7 StringWriter (java.io.StringWriter)7 Element (org.dom4j.Element)7 IPentahoRequestContext (org.pentaho.platform.api.engine.IPentahoRequestContext)7 Rectangle2D (java.awt.geom.Rectangle2D)6 Document (org.dom4j.Document)6 Graphics2D (java.awt.Graphics2D)5 Rectangle (java.awt.Rectangle)4 UnsupportedEncodingException (java.io.UnsupportedEncodingException)4 ChartEntity (org.jfree.chart.entity.ChartEntity)4