public void draw(DrawingContext context){
  boolean wordWrap=isWordWrapEnabled();
  Shape labelShape=getCachedOutline(wordWrap);
  if (labelShape == null) {
    return;
  }
  Rectangle2D textBounds=labelShape.getBounds2D();
  double rotation=getRotation();
  if (MathUtils.isCalculatable(rotation) && rotation != 0.0) {
    AffineTransform txLabelText=AffineTransform.getRotateInstance(Math.toRadians(-rotation),textBounds.getCenterX(),textBounds.getCenterY());
    labelShape=txLabelText.createTransformedShape(labelShape);
    textBounds=labelShape.getBounds2D();
  }
  Graphics2D graphics=context.getGraphics();
  AffineTransform txOld=graphics.getTransform();
  Paint background=getBackground();
  if (background != null) {
    GraphicsUtils.fillPaintedShape(graphics,getBounds(),background,null);
  }
  double shapePosX=getX() - textBounds.getX();
  double shapePosY=getY() - textBounds.getY();
  double alignmentX=getAlignmentX();
  double alignmentY=getAlignmentY();
  shapePosX+=alignmentX * (getWidth() - textBounds.getWidth());
  shapePosY+=alignmentY * (getHeight() - textBounds.getHeight());
  graphics.translate(shapePosX,shapePosY);
  Paint paint=getColor();
  GraphicsUtils.fillPaintedShape(graphics,labelShape,paint,null);
  graphics.setTransform(txOld);
}

public void draw ( DrawingContext context ) { boolean wordWrap = isWordWrapEnabled ( ) ; Shape labelShape = getCachedOutline ( wordWrap ) ; if ( labelShape == null ) { return ; } Rectangle2D textBounds = labelShape . getBounds2D ( ) ; double rotation = getRotation ( ) ; if ( MathUtils . isCalculatable ( rotation ) && rotation != 0.0 ) { AffineTransform txLabelText = AffineTransform . getRotateInstance ( Math . toRadians ( - rotation ) , textBounds . getCenterX ( ) , textBounds . getCenterY ( ) ) ; labelShape = txLabelText . createTransformedShape ( labelShape ) ; textBounds = labelShape . getBounds2D ( ) ; } Graphics2D graphics = context . getGraphics ( ) ; AffineTransform txOld = graphics . getTransform ( ) ; Paint background = getBackground ( ) ; if ( background != null ) { GraphicsUtils . fillPaintedShape ( graphics , getBounds ( ) , background , null ) ; } double shapePosX = getX ( ) - textBounds . getX ( ) ; double shapePosY = getY ( ) - textBounds . getY ( ) ; double alignmentX = getAlignmentX ( ) ; double alignmentY = getAlignmentY ( ) ; shapePosX += alignmentX * ( getWidth ( ) - textBounds . getWidth ( ) ) ; shapePosY += alignmentY * ( getHeight ( ) - textBounds . getHeight ( ) ) ; graphics . translate ( shapePosX , shapePosY ) ; Paint paint = getColor ( ) ; GraphicsUtils . fillPaintedShape ( graphics , labelShape , paint , null ) ; graphics . setTransform ( txOld ) ; }
draws the object with the specified drawing context .
