Exemple #1
0
 @Override
 protected void drawText(java.awt.Graphics2D g) {
   if (getText() != null || isEditable()) {
     TextLayout layout = getTextLayout();
     layout.draw(g, (float) origin.x, (float) (origin.y + layout.getAscent()));
   }
 }
Exemple #2
0
 @Override
 public Rectangle2D.Double getBounds() {
   TextLayout layout = getTextLayout();
   Rectangle2D.Double r =
       new Rectangle2D.Double(
           origin.x, origin.y, layout.getAdvance(), layout.getAscent() + layout.getDescent());
   return r;
 }
Exemple #3
0
 /** Gets the drawing area without taking the decorator into account. */
 @Override
 protected Rectangle2D.Double getFigureDrawingArea() {
   if (getText() == null) {
     return getBounds();
   } else {
     TextLayout layout = getTextLayout();
     Rectangle2D.Double r =
         new Rectangle2D.Double(origin.x, origin.y, layout.getAdvance(), layout.getAscent());
     Rectangle2D lBounds = layout.getBounds();
     if (!lBounds.isEmpty() && !Double.isNaN(lBounds.getX())) {
       r.add(
           new Rectangle2D.Double(
               lBounds.getX() + origin.x,
               (lBounds.getY() + origin.y + layout.getAscent()),
               lBounds.getWidth(),
               lBounds.getHeight()));
     }
     // grow by two pixels to take antialiasing into account
     Geom.grow(r, 2d, 2d);
     return r;
   }
 }
Exemple #4
0
 @Override
 public double getBaseline() {
   TextLayout layout = getTextLayout();
   return origin.y + layout.getAscent() - getBounds().y;
 }