Package org.jfree.chart.ui

Examples of org.jfree.chart.ui.Size2D


            startX = chartArea.getX() + chartArea.getWidth() - rightSpace - w;
        }
        g2.drawImage(this.image, (int) startX, (int) startY, (int) w, (int) h,
                null);

        return new Size2D(chartArea.getWidth() + leftSpace + rightSpace,
                h + topSpace + bottomSpace);

    }
View Full Code Here


        }

        g2.drawImage(this.image, (int) startX, (int) startY, (int) w, (int) h,
                null);

        return new Size2D(chartArea.getWidth() + leftSpace + rightSpace,
            h + topSpace + bottomSpace);

    }
View Full Code Here

    @Override
    public Size2D arrange(Graphics2D g2, RectangleConstraint constraint) {
        RectangleConstraint cc = toContentConstraint(constraint);
        LengthConstraintType w = cc.getWidthConstraintType();
        LengthConstraintType h = cc.getHeightConstraintType();
        Size2D contentSize = null;
        if (w == LengthConstraintType.NONE) {
            if (h == LengthConstraintType.NONE) {
                contentSize = arrangeNN(g2);
            }
            else if (h == LengthConstraintType.RANGE) {
                throw new RuntimeException("Not yet implemented.");
            }
            else if (h == LengthConstraintType.FIXED) {
                throw new RuntimeException("Not yet implemented.");
            }
        }
        else if (w == LengthConstraintType.RANGE) {
            if (h == LengthConstraintType.NONE) {
                contentSize = arrangeRN(g2, cc.getWidthRange());
            }
            else if (h == LengthConstraintType.RANGE) {
                contentSize = arrangeRR(g2, cc.getWidthRange(),
                        cc.getHeightRange());
            }
            else if (h == LengthConstraintType.FIXED) {
                throw new RuntimeException("Not yet implemented.");
            }
        }
        else if (w == LengthConstraintType.FIXED) {
            if (h == LengthConstraintType.NONE) {
                contentSize = arrangeFN(g2, cc.getWidth());
            }
            else if (h == LengthConstraintType.RANGE) {
                throw new RuntimeException("Not yet implemented.");
            }
            else if (h == LengthConstraintType.FIXED) {
                throw new RuntimeException("Not yet implemented.");
            }
        }
        if (contentSize.width <= 0.0 || contentSize.height <= 0.0) {
            return new Size2D(0.0, 0.0);
        }
        else {
            return new Size2D(calculateTotalWidth(contentSize.getWidth()),
                    calculateTotalHeight(contentSize.getHeight()));
        }
    }
View Full Code Here

     *
     * @return The content size.
     */
    @Override
    protected Size2D arrangeRN(Graphics2D g2, Range widthRange) {
        Size2D s = arrangeNN(g2);
        if (widthRange.contains(s.getWidth())) {
            return s;
        }
        double ww = widthRange.constrain(s.getWidth());
        return arrangeFN(g2, ww);
    }
View Full Code Here

    protected Size2D arrangeFN(Graphics2D g2, double w) {
        g2.setFont(getFont());
        FontMetrics fm = g2.getFontMetrics(getFont());
        Rectangle2D bounds = TextUtilities.getTextBounds(getText(), g2, fm);
        if (bounds.getWidth() <= w) {
            return new Size2D(w, bounds.getHeight());
        }
        else {
            return new Size2D(0.0, 0.0);
        }
    }
View Full Code Here

        g2.setFont(getFont());
        FontMetrics fm = g2.getFontMetrics(getFont());
        Rectangle2D bounds = TextUtilities.getTextBounds(getText(), g2, fm);
        if (bounds.getWidth() <= widthRange.getUpperBound()
                && bounds.getHeight() <= heightRange.getUpperBound()) {
            return new Size2D(bounds.getWidth(), bounds.getHeight());
        }
        else {
            return new Size2D(0.0, 0.0);
        }
    }
View Full Code Here

        }
        double w = fixToRange(valueBounds.getWidth(), minW, maxW);
        double h = fixToRange(valueBounds.getHeight(), minH, maxH);

        // align this rectangle to the frameAnchor
        Rectangle2D bounds = RectangleAnchor.createRectangle(new Size2D(w, h),
                pt.getX(), pt.getY(), this.frameAnchor);

        // add the insets
        Rectangle2D fb = this.insets.createOutsetRectangle(bounds);
View Full Code Here

    /**
     * Run some checks on the constrained size calculation.
     */
    @Test
    public void testCalculateConstrainedSize() {
        Size2D s;

        // NONE / NONE
        RectangleConstraint c1 = RectangleConstraint.NONE;
        s = c1.calculateConstrainedSize(new Size2D(1.2, 3.4));
        assertEquals(s.width, 1.2, EPSILON);
        assertEquals(s.height, 3.4, EPSILON);

        // NONE / RANGE
        RectangleConstraint c2 = new RectangleConstraint(
            0.0, new Range(0.0, 0.0), LengthConstraintType.NONE,
            0.0, new Range(2.0, 3.0), LengthConstraintType.RANGE
        );
        s = c2.calculateConstrainedSize(new Size2D(1.2, 3.4));
        assertEquals(s.width, 1.2, EPSILON);
        assertEquals(s.height, 3.0, EPSILON);

        // NONE / FIXED
        RectangleConstraint c3 = new RectangleConstraint(
            0.0, null, LengthConstraintType.NONE,
            9.9, null, LengthConstraintType.FIXED
        );
        s = c3.calculateConstrainedSize(new Size2D(1.2, 3.4));
        assertEquals(s.width, 1.2, EPSILON);
        assertEquals(s.height, 9.9, EPSILON);

        // RANGE / NONE
        RectangleConstraint c4 = new RectangleConstraint(
            0.0, new Range(2.0, 3.0), LengthConstraintType.RANGE,
            0.0, new Range(0.0, 0.0), LengthConstraintType.NONE
        );
        s = c4.calculateConstrainedSize(new Size2D(1.2, 3.4));
        assertEquals(s.width, 2.0, EPSILON);
        assertEquals(s.height, 3.4, EPSILON);

        // RANGE / RANGE
        RectangleConstraint c5 = new RectangleConstraint(
            0.0, new Range(2.0, 3.0), LengthConstraintType.RANGE,
            0.0, new Range(2.0, 3.0), LengthConstraintType.RANGE
        );
        s = c5.calculateConstrainedSize(new Size2D(1.2, 3.4));
        assertEquals(s.width, 2.0, EPSILON);
        assertEquals(s.height, 3.0, EPSILON);

        // RANGE / FIXED
        RectangleConstraint c6 = new RectangleConstraint(
            0.0, null, LengthConstraintType.NONE,
            9.9, null, LengthConstraintType.FIXED
        );
        s = c6.calculateConstrainedSize(new Size2D(1.2, 3.4));
        assertEquals(s.width, 1.2, EPSILON);
        assertEquals(s.height, 9.9, EPSILON);

        // FIXED / NONE
        RectangleConstraint c7 = RectangleConstraint.NONE;
        s = c7.calculateConstrainedSize(new Size2D(1.2, 3.4));
        assertEquals(s.width, 1.2, EPSILON);
        assertEquals(s.height, 3.4, EPSILON);

        // FIXED / RANGE
        RectangleConstraint c8 = new RectangleConstraint(
            0.0, new Range(0.0, 0.0), LengthConstraintType.NONE,
            0.0, new Range(2.0, 3.0), LengthConstraintType.RANGE
        );
        s = c8.calculateConstrainedSize(new Size2D(1.2, 3.4));
        assertEquals(s.width, 1.2, EPSILON);
        assertEquals(s.height, 3.0, EPSILON);

        // FIXED / FIXED
        RectangleConstraint c9 = new RectangleConstraint(
            0.0, null, LengthConstraintType.NONE,
            9.9, null, LengthConstraintType.FIXED
        );
        s = c9.calculateConstrainedSize(new Size2D(1.2, 3.4));
        assertEquals(s.width, 1.2, EPSILON);
        assertEquals(s.height, 9.9, EPSILON);

    }
View Full Code Here

     * Test arrangement with no constraints.
     */
    @Test
    public void testNN() {
        BlockContainer c = createTestContainer1();
        Size2D s = c.arrange(null, RectangleConstraint.NONE);
        assertEquals(90.0, s.width, EPSILON);
        assertEquals(33.0, s.height, EPSILON);
    }
View Full Code Here

    public void testFN() {
        BlockContainer c = createTestContainer1();
        RectangleConstraint constraint = new RectangleConstraint(100.0, null,
                LengthConstraintType.FIXED, 0.0, null,
                LengthConstraintType.NONE);
        Size2D s = c.arrange(null, constraint);
        assertEquals(100.0, s.width, EPSILON);
        assertEquals(33.0, s.height, EPSILON);
    }
View Full Code Here

TOP

Related Classes of org.jfree.chart.ui.Size2D

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.