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


        if (inPossibleRecursion) {
            System.err.println("Called itself: drawString(AttributedCharacterIterator)");
        } else {
            inPossibleRecursion = true;
            TextLayout layout = new TextLayout(iterator, getFontRenderContext());
            layout.draw(this, x, y);
            inPossibleRecursion = false;
        }
    }

    /**
 
View Full Code Here

            tx = -advance/2;
            break;
        case TextNode.Anchor.ANCHOR_END:
            tx = -advance;
        }
        layout.draw(g2d, (float)(location.getX() + tx), (float)(location.getY()));
    }

}
View Full Code Here

            offset = (int) ((computedWidth - r.getWidth()) / 2);
        }

        int voffset = (int) ((computedHeight - r.getHeight()) / 2);
        g2d.setColor(Color.black);
        layout.draw(g2d, offset, computedHeight-voffset-layout.getDescent()/2);
    }

    public void addActionListener(ActionListener actionListener) {
        actionListeners.add(actionListener);
    }
View Full Code Here

                  case DRAW_GLYPHV:
                    g2.drawGlyphVector( gv, 0f, 0f );
                    break;
                  case TL_DRAW:
                    TextLayout tl = new TextLayout( new String( charArray ), testFont, frc );
                    tl.draw( g2, 0f, 0f );
                    break;
                  case GV_OUTLINE:
                    r2d2 = gv.getVisualBounds();
                    shiftedX = baseX - (int) ( r2d2.getWidth() / 2 + r2d2.getX() );
                    g2.draw( gv.getOutline( 0f, 0f ));
View Full Code Here

                g2.drawGlyphVector( gv, (float) 0, (float) 0 );
                break;
              case TL_DRAW:
                TextLayout tl = new TextLayout( line, testFont,
                                                g2.getFontRenderContext() );
                tl.draw( g2, (float) 0, (float) 0 );
                break;
              case GV_OUTLINE:
                GlyphVector gvo =
                  testFont.createGlyphVector( g2.getFontRenderContext(), line );
                g2.draw( gvo.getOutline( (float) 0, (float) 0 ));
View Full Code Here

        if (inPossibleRecursion) {
            System.err.println("Called itself: drawString(AttributedCharacterIterator)");
        } else {
            inPossibleRecursion = true;
            TextLayout layout = new TextLayout(iterator, getFontRenderContext());
            layout.draw(this, x, y);
            inPossibleRecursion = false;
        }
    }

    /**
 
View Full Code Here

            tx = -advance/2;
            break;
        case TextNode.Anchor.ANCHOR_END:
            tx = -advance;
        }
        layout.draw(g2d, (float)(location.getX() + tx), (float)(location.getY()));
    }

}
View Full Code Here

     * @see #setClip(Shape)
     */
    public void drawString(AttributedCharacterIterator ati, float x, float y) {
        if ((textAsShapes) || (usesUnsupportedAttributes(ati))) {
            TextLayout layout = new TextLayout(ati, getFontRenderContext());
            layout.draw(this, x, y);
            return;
        }
        // first we want if there is more than one run in this
        // ati. This will be used to decide if we create tspan
        // Elements under the text Element or not
View Full Code Here

     * @see #setClip
     */
    public void drawString(AttributedCharacterIterator iterator,
                           float x, float y) {
        TextLayout layout = new TextLayout(iterator, getFontRenderContext());
        layout.draw(this, x, y);
    }


    /**
     * Fills the interior of a <code>Shape</code> using the settings of the
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.