Package org.jfree.text

Examples of org.jfree.text.G2TextMeasurer


            );

            if (label != null) {
                TextBlock block = TextUtilities.createTextBlock(
                    label, this.labelFont, this.labelPaint,
                    maxLabelWidth, new G2TextMeasurer(g2)
                );
                TextBox labelBox = new TextBox(block);
                labelBox.setBackgroundPaint(this.labelBackgroundPaint);
                labelBox.setOutlinePaint(this.labelOutlinePaint);
                labelBox.setOutlineStroke(this.labelOutlineStroke);
View Full Code Here


    public float getPreferredWidth(Graphics2D g2, float height) {
        float result = 0.0f;
        if (this.text != null && !this.text.equals("")) {
            g2.setFont(this.font);
            TextBlock title = TextUtilities.createTextBlock(
                this.text, this.font, this.paint, height, new G2TextMeasurer(g2)
            );
            Size2D d = title.calculateDimensions(g2);
            result = (float) getSpacer().getAdjustedWidth(d.getHeight());
                                                     // use height here because the title
                                                     // is displayed rotated
View Full Code Here

        float result = 0.0f;
        if (this.text != null && !this.text.equals("")) {
            g2.setFont(this.font);
            float textWidth = (float) getSpacer().trimWidth(width);
            TextBlock title = TextUtilities.createTextBlock(
                this.text, this.font, this.paint, textWidth, new G2TextMeasurer(g2)
            );
            Size2D d = title.calculateDimensions(g2);
            result = (float) getSpacer().getAdjustedHeight(d.getHeight());
        }
        if (LOGGER.isDebugEnabled()) {
View Full Code Here

        Rectangle2D titleArea = (Rectangle2D) area.clone();
        getSpacer().trim(titleArea);
        g2.setFont(this.font);
        g2.setPaint(this.paint);
        TextBlock title = TextUtilities.createTextBlock(
            this.text, this.font, this.paint, (float) titleArea.getWidth(), new G2TextMeasurer(g2)
        );
        TextBlockAnchor anchor = null;
        float x = 0.0f;
        HorizontalAlignment horizontalAlignment = getHorizontalAlignment();
        if (horizontalAlignment == HorizontalAlignment.LEFT) {
View Full Code Here

        Rectangle2D titleArea = (Rectangle2D) area.clone();
        getSpacer().trim(titleArea);
        g2.setFont(this.font);
        g2.setPaint(this.paint);
        TextBlock title = TextUtilities.createTextBlock(
            this.text, this.font, this.paint, (float) titleArea.getHeight(), new G2TextMeasurer(g2)
        );
        TextBlockAnchor anchor = null;
        float y = 0.0f;
        VerticalAlignment verticalAlignment = getVerticalAlignment();
        if (verticalAlignment == VerticalAlignment.TOP) {
View Full Code Here

//            float x = (float) (area.getX() + area.getWidth() / 2 - bounds.getWidth() / 2);
//            float y = (float) (area.getMinY() + (area.getHeight() / 2) - (bounds.getHeight() / 2));
//            g2.drawString(message, x, y);
            TextBlock block = TextUtilities.createTextBlock(
                this.noDataMessage, this.noDataMessageFont, this.noDataMessagePaint,
                0.9f * (float) area.getWidth(), new G2TextMeasurer(g2)
            );
            block.draw(
                g2, (float) area.getCenterX(), (float) area.getCenterY(), TextBlockAnchor.CENTER
            );
        }
View Full Code Here

     */
    protected TextBlock createLabel(Comparable category, float width,
                                    RectangleEdge edge, Graphics2D g2) {
        TextBlock label = TextUtilities.createTextBlock(category.toString(),
                getTickLabelFont(category), getTickLabelPaint(category), width,
                this.maximumCategoryLabelLines, new G2TextMeasurer(g2))
        return label;
    }
View Full Code Here

        RectangleEdge position = getPosition();
        if (position == RectangleEdge.TOP || position == RectangleEdge.BOTTOM) {
            float maxWidth = (float) w;
            g2.setFont(this.font);
            this.content = TextUtilities.createTextBlock(this.text, this.font,
                    this.paint, maxWidth, new G2TextMeasurer(g2));
            this.content.setLineAlignment(this.textAlignment);
            Size2D contentSize = this.content.calculateDimensions(g2);
            if (this.expandToFitSpace) {
                return new Size2D(maxWidth, contentSize.getHeight());
            }
            else {
                return contentSize;
            }
        }
        else if (position == RectangleEdge.LEFT || position
                == RectangleEdge.RIGHT) {
            float maxWidth = Float.MAX_VALUE;
            g2.setFont(this.font);
            this.content = TextUtilities.createTextBlock(this.text, this.font,
                    this.paint, maxWidth, new G2TextMeasurer(g2));
            this.content.setLineAlignment(this.textAlignment);
            Size2D contentSize = this.content.calculateDimensions(g2);
           
            // transpose the dimensions, because the title is rotated
            if (this.expandToFitSpace) {
View Full Code Here

        RectangleEdge position = getPosition();
        if (position == RectangleEdge.TOP || position == RectangleEdge.BOTTOM) {
            float maxWidth = (float) widthRange.getUpperBound();
            g2.setFont(this.font);
            this.content = TextUtilities.createTextBlock(this.text, this.font,
                    this.paint, maxWidth, new G2TextMeasurer(g2));
            this.content.setLineAlignment(this.textAlignment);
            Size2D contentSize = this.content.calculateDimensions(g2);
            if (this.expandToFitSpace) {
                return new Size2D(maxWidth, contentSize.getHeight());
            }
            else {
                return contentSize;
            }
        }
        else if (position == RectangleEdge.LEFT || position
                == RectangleEdge.RIGHT) {
            float maxWidth = (float) heightRange.getUpperBound();
            g2.setFont(this.font);
            this.content = TextUtilities.createTextBlock(this.text, this.font,
                    this.paint, maxWidth, new G2TextMeasurer(g2));
            this.content.setLineAlignment(this.textAlignment);
            Size2D contentSize = this.content.calculateDimensions(g2);
           
            // transpose the dimensions, because the title is rotated
            if (this.expandToFitSpace) {
View Full Code Here

            String label = this.labelGenerator.generateSectionLabel(
                    this.dataset, leftKeys.getKey(i));
            if (label != null) {
                TextBlock block = TextUtilities.createTextBlock(label,
                        this.labelFont, this.labelPaint, maxLabelWidth,
                        new G2TextMeasurer(g2));
                TextBox labelBox = new TextBox(block);
                labelBox.setBackgroundPaint(this.labelBackgroundPaint);
                labelBox.setOutlinePaint(this.labelOutlinePaint);
                labelBox.setOutlineStroke(this.labelOutlineStroke);
                labelBox.setShadowPaint(this.labelShadowPaint);
View Full Code Here

TOP

Related Classes of org.jfree.text.G2TextMeasurer

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.