Package org.jfree.chart.plot

Examples of org.jfree.chart.plot.PlotRenderingInfo


    /**
     * Confirm that cloning works.
     */
    public void testCloning() {
        PlotRenderingInfo p1 = new PlotRenderingInfo(new ChartRenderingInfo());
        p1.setPlotArea(new Rectangle2D.Double());
        PlotRenderingInfo p2 = null;
        try {
            p2 = (PlotRenderingInfo) p1.clone();
        }
        catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        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));
    }
View Full Code Here


    /**
     * Serialize an instance, restore it, and check for equality.
     */
    public void testSerialization() {

        PlotRenderingInfo p1 = new PlotRenderingInfo(new ChartRenderingInfo());
        PlotRenderingInfo p2 = null;

        try {
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
            ObjectOutput out = new ObjectOutputStream(buffer);
            out.writeObject(p1);
View Full Code Here

        return getTooltipAtPoint(e.getPoint());
    }

    protected String getTooltipAtPoint(Point point) {
        XYPlot plot = (XYPlot) getChart().getPlot();
        PlotRenderingInfo info = getChartRenderingInfo().getPlotInfo();
        double x0 = point.getX();
        double x1 = x0 - 2 * getScaleX();
        double x2 = x0 + 4 * getScaleX();

        ValueAxis domainAxis = plot.getDomainAxis();
        Rectangle2D screenArea = scale(info.getDataArea());
        double tx1 = domainAxis.java2DToValue(x1, screenArea, BOTTOM);
        double tx2 = domainAxis.java2DToValue(x2, screenArea, BOTTOM);

        for (int datasetIndex = 0; datasetIndex < plot.getDatasetCount(); datasetIndex++) {
            XYDataset dataset = plot.getDataset(datasetIndex);
View Full Code Here

     *
     * @param entities  an entity collection (<code>null</code> permitted).
     */
    public ChartRenderingInfo(EntityCollection entities) {
        this.chartArea = new Rectangle2D.Double();
        this.plotInfo = new PlotRenderingInfo(this);
        this.entities = entities;
    }
View Full Code Here

    /**
     * Clears the information recorded by this object.
     */
    public void clear() {
        this.chartArea.setRect(0.0, 0.0, 0.0, 0.0);
        this.plotInfo = new PlotRenderingInfo(this);
        if (this.entities != null) {
            this.entities.clear();
        }
    }
View Full Code Here

     * @param e  the mouse wheel event.
     */
    private void handleZoomable(Zoomable zoomable, MouseWheelEvent e) {
        // don't zoom unless the mouse pointer is in the plot's data area
        ChartRenderingInfo info = this.chartPanel.getChartRenderingInfo();
        PlotRenderingInfo pinfo = info.getPlotInfo();
        Point2D p = this.chartPanel.translateScreenToJava2D(e.getPoint());
        if (!pinfo.getDataArea().contains(p)) {
            return;
        }

        Plot plot = (Plot) zoomable;
        // do not notify while zooming each axis
View Full Code Here

        // get the origin of the zoom selection in the Java2D space used for
        // drawing the chart (that is, before any scaling to fit the panel)
        Point2D selectOrigin = translateScreenToJava2D(new Point(
                (int) Math.ceil(selection.getX()),
                (int) Math.ceil(selection.getY())));
        PlotRenderingInfo plotInfo = this.info.getPlotInfo();
        Rectangle2D scaledDataArea = getScreenDataArea(
                (int) selection.getCenterX(), (int) selection.getCenterY());
        if ((selection.getHeight() > 0) && (selection.getWidth() > 0)) {

            double hLower = (selection.getMinX() - scaledDataArea.getMinX())
View Full Code Here

     * @param y  the y-coordinate (for subplot selection).
     *
     * @return The scaled data area.
     */
    public Rectangle2D getScreenDataArea(int x, int y) {
        PlotRenderingInfo plotInfo = this.info.getPlotInfo();
        Rectangle2D result;
        if (plotInfo.getSubplotCount() == 0) {
            result = getScreenDataArea();
        }
        else {
            // get the origin of the zoom selection in the Java2D space used for
            // drawing the chart (that is, before any scaling to fit the panel)
            Point2D selectOrigin = translateScreenToJava2D(new Point(x, y));
            int subplotIndex = plotInfo.getSubplotIndex(selectOrigin);
            if (subplotIndex == -1) {
                return null;
            }
            result = scale(plotInfo.getSubplotInfo(subplotIndex).getDataArea());
        }
        return result;
    }
View Full Code Here

        double wPercent = -dx / this.panW;
        double hPercent = dy / this.panH;
        boolean old = chart.getPlot().isNotify();
        chart.getPlot().setNotify(false);
        Pannable p = (Pannable) chart.getPlot();
        PlotRenderingInfo info = canvas.getRenderingInfo().getPlotInfo();
        if (p.getOrientation().isVertical()) {
            p.panDomainAxes(wPercent, info, this.panLast);
            p.panRangeAxes(hPercent, info, this.panLast);
        }
        else {
View Full Code Here

                - this.startPoint.getX()) >= 10;
        boolean zoomTrigger2 = vZoom && Math.abs(e.getY()
                - this.startPoint.getY()) >= 10;
        if (zoomTrigger1 || zoomTrigger2) {
            Point2D endPoint = new Point2D.Double(e.getX(), e.getY());
            PlotRenderingInfo pri = canvas.getRenderingInfo().getPlotInfo();
            if ((hZoom && (e.getX() < this.startPoint.getX()))
                    || (vZoom && (e.getY() < this.startPoint.getY()))) {
                boolean saved = p.isNotify();
                p.setNotify(false);
                z.zoomDomainAxes(0, pri, endPoint);
                z.zoomRangeAxes(0, pri, endPoint);
                p.setNotify(saved);
            } else {
                double x = this.startPoint.getX();
                double y = this.startPoint.getY();
                double w = e.getX() - x;
                double h = e.getY() - y;
                Rectangle2D dataArea = canvas.findDataArea(this.startPoint);
                double maxX = dataArea.getMaxX();
                double maxY = dataArea.getMaxY();
                // for mouseReleased event, (horizontalZoom || verticalZoom)
                // will be true, so we can just test for either being false;
                // otherwise both are true
                if (!vZoom) {
                    y = dataArea.getMinY();
                    w = Math.min(w, maxX - this.startPoint.getX());
                    h = dataArea.getHeight();
                }
                else if (!hZoom) {
                    x = dataArea.getMinX();
                    w = dataArea.getWidth();
                    h = Math.min(h, maxY - this.startPoint.getY());
                }
                else {
                    w = Math.min(w, maxX - this.startPoint.getX());
                    h = Math.min(h, maxY - this.startPoint.getY());
                }
                Rectangle2D zoomArea = new Rectangle2D.Double(x, y, w, h);
               
                boolean saved = p.isNotify();
                p.setNotify(false);
                double pw0 = percentW(x, dataArea);
                double pw1 = percentW(x + w, dataArea);
                double ph0 = percentH(y, dataArea);
                double ph1 = percentH(y + h, dataArea);
                PlotRenderingInfo info
                        = this.viewer.getRenderingInfo().getPlotInfo();
                if (z.getOrientation().isVertical()) {
                    z.zoomDomainAxes(pw0, pw1, info, endPoint);
                    z.zoomRangeAxes(1 - ph1, 1 - ph0, info, endPoint);
                } else {
View Full Code Here

TOP

Related Classes of org.jfree.chart.plot.PlotRenderingInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.