Package java.awt.font

Examples of java.awt.font.TextLayout.draw()


            if (text != null && text.length() > 0) {
                FontRenderContext context = g2.getFontRenderContext();
                TextLayout layout = new TextLayout(text, getFont(), context);
                Rectangle2D bounds = layout.getBounds();
                g2.setColor(getForeground());
                layout.draw(g2, (float) (width - bounds.getWidth()) / 2,
                        (float) (maxY + layout.getLeading() + 2 * layout.getAscent()));
            }
        }
    }
   
View Full Code Here


           
            // Move the labels in the left half circle a bit left, so the upper right corner touches the axis
            if (lRotation <= 0)
                lX -= lLabel.getBounds().getWidth();
           
      lLabel.draw(g, (float)lX,  (float)lY);
    }

    // reset rendering hint       
        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, rh);
    }   
View Full Code Here

    public void paintDefault(Graphics2D g) {
        g.setColor(Color.black);
        TextLayout layout = new TextLayout(getText(), getFont(),
                                           new FontRenderContext(null, true, false));
       
        layout.draw(g, 0f, (float)getPreferredSize().getHeight() - layout.getDescent());
    }
   
    /** Returns the preferred size needed for the renderer.
     * @return a non-null Dimension object
     */
 
View Full Code Here

       
        // draw X-Axis label right below the Arrow ?!
        g.setColor(Color.black);
        TextLayout layoutX = new TextLayout(getXAxisUnit(), getFont(),
                                           new FontRenderContext(null, true, false));
    layoutX.draw(g, (float)x.getX2() + (float)ARROWLENGTH / 3(float)x.getY2() + (float)layoutX.getBounds().getHeight() + 5);
       
        // draw Y-Axis Arrow
    if(shouldDrawArrows) {
      g.drawLine((int)y.getX1(), (int)y.getY1(), (int)y.getX1(), (int)y.getY1() - ARROWLENGTH);
      g.fillPolygon(new int[] {(int)(y.getX1() - 3),
View Full Code Here

        // draw Y-Axis label right below the Arrow ?!
        g.setColor(Color.black);
        TextLayout layoutY = new TextLayout(getYAxisUnit(), getFont(),
                                           new FontRenderContext(null, true, false));
        layoutY.draw(g, (float)y.getX1()-6-(float)layoutY.getBounds().getWidth(),
                        (float)y.getY1() - layoutX.getDescent() - 3);
       
        if(getSecondYAxis() != null) {
            Line2D y2 = c.getSecondYAxisLine2D();
            g.draw(y2);
View Full Code Here

        float y = (float) (buttonTile.getHeight() / 2.0 - bounds.getHeight() / 2.0) - 1;

        if (!isOSXPanther) {
            // Workaround for broken TextLayout on Panther
            y += layout.getAscent() - layout.getDescent();
            layout.draw(g, x, y);
        } else {
            g.setFont(font);
            FontMetrics fm = g.getFontMetrics();
            bounds = fm.getStringBounds(text, g);
            y += fm.getAscent() - layout.getDescent();
View Full Code Here

        if (useDrawRotatedStringWorkaround) {
            // workaround for JDC bug ID 4312117 and others...
            final TextLayout tl = new TextLayout(text, g2.getFont(),
                    g2.getFontRenderContext());
            tl.draw(g2, textX, textY);
        }
        else {
            AttributedString as = new AttributedString(text,
                    g2.getFont().getAttributes());
          g2.drawString(as.getIterator(), textX, textY);
View Full Code Here

            case GContext.ALIGN_LEFT:
                tx = x;
                ty = (float)(y+layout.getBounds().getHeight()*0.5);
                break;
        }
        layout.draw(getG2D(), tx, ty-1);
    }

    public void drawSpline(float x0, float y0, float x1, float y1, float startOffset, float endOffset, float flateness, boolean arrow) {
        link_arc.setStart(x0, y0);
        link_arc.setEnd(x1, y1);
View Full Code Here

                        xx += (width-layout.getAdvance())/2;
                    } else if (align == ALIGN_JUSTIFY && lbm.getPosition() < length()) {
                        layout = layout.getJustifiedLayout((float)width);
                    }
                    y += layout.getAscent();
                    layout.draw(g, (float)xx, (float)y);
                    y += layout.getDescent();
                    if (lbm.getPosition() >= length()) {
                        break;
                    }
                    y += layout.getLeading();
View Full Code Here

                TextLayout layout = lbm.nextLayout(width);
                if (lbm.getPosition() < textBuilder.length()) {
                    layout = layout.getJustifiedLayout(width);
                }
                y += layout.getAscent();
                layout.draw(g2d, x, y);
                y += layout.getDescent() + layout.getLeading();
            }
        }
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.