Package org.jfree.chart.plot

Examples of org.jfree.chart.plot.IntervalMarker


       
    /**
     * Confirm that cloning works.
     */
    public void testCloning() {
        IntervalMarker m1 = new IntervalMarker(45.0, 50.0);
        IntervalMarker m2 = null;
        try {
            m2 = (IntervalMarker) m1.clone();
        }
        catch (CloneNotSupportedException e) {
            System.err.println("Failed to clone.");
        }
        assertTrue(m1 != m2);
        assertTrue(m1.getClass() == m2.getClass());
        assertTrue(m1.equals(m2));
    }
View Full Code Here


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

        IntervalMarker m1 = new IntervalMarker(45.0, 50.0);
        IntervalMarker m2 = null;
        try {
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
            ObjectOutput out = new ObjectOutputStream(buffer);
            out.writeObject(m1);
            out.close();
View Full Code Here

            true,
            false
        );
        XYPlot plot = (XYPlot) chart.getPlot();
        plot.addDomainMarker(new ValueMarker(1.0), Layer.FOREGROUND);
        plot.addDomainMarker(new IntervalMarker(2.0, 3.0), Layer.BACKGROUND);
        plot.addRangeMarker(new ValueMarker(4.0), Layer.FOREGROUND);
        plot.addRangeMarker(new IntervalMarker(5.0, 6.0), Layer.BACKGROUND);
        JFreeChart chart2 = null;
       
        // serialize and deserialize the chart....
        try {
            ByteArrayOutputStream buffer = new ByteArrayOutputStream();
View Full Code Here

                );
            }
        }
        else if (marker instanceof IntervalMarker) {
           
            IntervalMarker im = (IntervalMarker) marker;
            double start = im.getStartValue();
            double end = im.getEndValue();
            Range range = axis.getRange();
            if (!(range.intersects(start, end))) {
                return;
            }
           
            // don't draw beyond the axis range...
            start = range.constrain(start);
            end = range.constrain(end);
           
            double v0 = axis.valueToJava2D(
                start, dataArea, plot.getRangeAxisEdge()
            );
            double v1 = axis.valueToJava2D(
                end, dataArea, plot.getRangeAxisEdge()
            );
           
            PlotOrientation orientation = plot.getOrientation();
            Rectangle2D rect = null;
            if (orientation == PlotOrientation.HORIZONTAL) {
                rect = new Rectangle2D.Double(
                    v0, dataArea.getMinY(), v1 - v0, dataArea.getHeight()
                );           
            }
            else if (orientation == PlotOrientation.VERTICAL) {
                rect = new Rectangle2D.Double(
                    dataArea.getMinX(), Math.min(v0, v1),
                    dataArea.getWidth(), Math.abs(v1 - v0)
                );
            }
            Paint p = marker.getPaint();
            if (p instanceof GradientPaint) {
                GradientPaint gp = (GradientPaint) p;
                GradientPaintTransformer t = im.getGradientPaintTransformer();
                if (t != null) {
                    gp = t.transform(gp, rect)
                }
                g2.setPaint(gp);
            }
View Full Code Here

                    marker.getLabelTextAnchor()
                );
            }
        }
        else if (marker instanceof IntervalMarker) {
            IntervalMarker im = (IntervalMarker) marker;
            double start = im.getStartValue();
            double end = im.getEndValue();
            Range range = domainAxis.getRange();
            if (!(range.intersects(start, end))) {
                return;
            }

            // don't draw beyond the axis range...
            start = range.constrain(start);
            end = range.constrain(end);

            double v0 = domainAxis.valueToJava2D(
                start, dataArea, plot.getDomainAxisEdge()
            );
            double v1 = domainAxis.valueToJava2D(
                end, dataArea, plot.getDomainAxisEdge()
            );

            PlotOrientation orientation = plot.getOrientation();
            Rectangle2D rect = null;
            if (orientation == PlotOrientation.HORIZONTAL) {
                rect = new Rectangle2D.Double(
                    dataArea.getMinX(), Math.min(v0, v1),
                    dataArea.getWidth(), Math.abs(v1 - v0)
                );
            }
            else if (orientation == PlotOrientation.VERTICAL) {
                rect = new Rectangle2D.Double(
                    Math.min(v0, v1), dataArea.getMinY(),
                    Math.abs(v1 - v0), dataArea.getHeight()
                );
            }

            Paint p = marker.getPaint();
            if (p instanceof GradientPaint) {
                GradientPaint gp = (GradientPaint) p;
                GradientPaintTransformer t = im.getGradientPaintTransformer();
                if (t != null) {
                    gp = t.transform(gp, rect)
                }
                g2.setPaint(gp);
            }
View Full Code Here

                );
            }
        }
        else if (marker instanceof IntervalMarker) {
           
            IntervalMarker im = (IntervalMarker) marker;
            double start = im.getStartValue();
            double end = im.getEndValue();
            Range range = rangeAxis.getRange();
            if (!(range.intersects(start, end))) {
                return;
            }

            // don't draw beyond the axis range...
            start = range.constrain(start);
            end = range.constrain(end);
           
            double v0 = rangeAxis.valueToJava2D(
                start, dataArea, plot.getRangeAxisEdge()
            );
            double v1 = rangeAxis.valueToJava2D(
                end, dataArea, plot.getRangeAxisEdge()
            );

            PlotOrientation orientation = plot.getOrientation();
            Rectangle2D rect = null;
            if (orientation == PlotOrientation.HORIZONTAL) {
                rect = new Rectangle2D.Double(
                    Math.min(v0, v1), dataArea.getMinY(),
                    Math.abs(v1 - v0), dataArea.getHeight()
                );
            }
            else if (orientation == PlotOrientation.VERTICAL) {
                rect = new Rectangle2D.Double(
                    dataArea.getMinX(), Math.min(v0, v1),
                    dataArea.getWidth(), Math.abs(v0 - v1)
                );
            }

            Paint p = marker.getPaint();
            if (p instanceof GradientPaint) {
                GradientPaint gp = (GradientPaint) p;
                GradientPaintTransformer t = im.getGradientPaintTransformer();
                if (t != null) {
                    gp = t.transform(gp, rect)
                }
                g2.setPaint(gp);
            }
View Full Code Here

                     double x, double y) {

        double h = getHeight(g2);
        Iterator iterator = this.markers.iterator();
        while (iterator.hasNext()) {
            IntervalMarker marker = (IntervalMarker) iterator.next();
            double start =  Math.max(
                marker.getStartValue(), this.axis.getRange().getLowerBound()
            );
            double end = Math.min(
                marker.getEndValue(), this.axis.getRange().getUpperBound()
            );
            double s = this.axis.valueToJava2D(
                start, dataArea, RectangleEdge.BOTTOM
            );
            double e = this.axis.valueToJava2D(
                end, dataArea, RectangleEdge.BOTTOM
            );
            Rectangle2D r = new Rectangle2D.Double(
                s, y + this.topOuterGap, e - s,
                h - this.topOuterGap - this.bottomOuterGap
            );

            Composite originalComposite = g2.getComposite();
            g2.setComposite(AlphaComposite.getInstance(
                AlphaComposite.SRC_OVER, marker.getAlpha())
            );
            g2.setPaint(marker.getPaint());
            g2.fill(r);
            g2.setPaint(marker.getOutlinePaint());
            g2.draw(r);
            g2.setComposite(originalComposite);

            g2.setPaint(Color.black);
            drawStringInRect(g2, r, this.font, marker.getLabel());
        }

    }
View Full Code Here

TOP

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

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.