protected AxisState drawLabel(String label,Graphics2D g2,Rectangle2D plotArea,Rectangle2D dataArea,RectangleEdge edge,AxisState state){
  ParamChecks.nullNotPermitted(state,"state");
  if ((label == null) || (label.equals(""))) {
    return state;
  }
  Font font=getLabelFont();
  RectangleInsets insets=getLabelInsets();
  g2.setFont(font);
  g2.setPaint(getLabelPaint());
  FontMetrics fm=g2.getFontMetrics();
  Rectangle2D labelBounds=TextUtilities.getTextBounds(label,g2,fm);
  if (edge == RectangleEdge.TOP) {
    AffineTransform t=AffineTransform.getRotateInstance(getLabelAngle(),labelBounds.getCenterX(),labelBounds.getCenterY());
    Shape rotatedLabelBounds=t.createTransformedShape(labelBounds);
    labelBounds=rotatedLabelBounds.getBounds2D();
    double labelx=labelLocationX(this.labelLocation,dataArea);
    double labely=state.getCursor() - insets.getBottom() - labelBounds.getHeight() / 2.0;
    TextAnchor anchor=labelAnchorH(this.labelLocation);
    TextUtilities.drawRotatedString(label,g2,(float)labelx,(float)labely,anchor,getLabelAngle(),TextAnchor.CENTER);
    state.cursorUp(insets.getTop() + labelBounds.getHeight() + insets.getBottom());
  }
 else   if (edge == RectangleEdge.BOTTOM) {
    AffineTransform t=AffineTransform.getRotateInstance(getLabelAngle(),labelBounds.getCenterX(),labelBounds.getCenterY());
    Shape rotatedLabelBounds=t.createTransformedShape(labelBounds);
    labelBounds=rotatedLabelBounds.getBounds2D();
    double labelx=labelLocationX(this.labelLocation,dataArea);
    double labely=state.getCursor() + insets.getTop() + labelBounds.getHeight() / 2.0;
    TextAnchor anchor=labelAnchorH(this.labelLocation);
    TextUtilities.drawRotatedString(label,g2,(float)labelx,(float)labely,anchor,getLabelAngle(),TextAnchor.CENTER);
    state.cursorDown(insets.getTop() + labelBounds.getHeight() + insets.getBottom());
  }
 else   if (edge == RectangleEdge.LEFT) {
    AffineTransform t=AffineTransform.getRotateInstance(getLabelAngle() - Math.PI / 2.0,labelBounds.getCenterX(),labelBounds.getCenterY());
    Shape rotatedLabelBounds=t.createTransformedShape(labelBounds);
    labelBounds=rotatedLabelBounds.getBounds2D();
    double labelx=state.getCursor() - insets.getRight() - labelBounds.getWidth() / 2.0;
    double labely=labelLocationY(this.labelLocation,dataArea);
    TextAnchor anchor=labelAnchorV(this.labelLocation);
    TextUtilities.drawRotatedString(label,g2,(float)labelx,(float)labely,anchor,getLabelAngle() - Math.PI / 2.0,anchor);
    state.cursorLeft(insets.getLeft() + labelBounds.getWidth() + insets.getRight());
  }
 else   if (edge == RectangleEdge.RIGHT) {
    AffineTransform t=AffineTransform.getRotateInstance(getLabelAngle() + Math.PI / 2.0,labelBounds.getCenterX(),labelBounds.getCenterY());
    Shape rotatedLabelBounds=t.createTransformedShape(labelBounds);
    labelBounds=rotatedLabelBounds.getBounds2D();
    double labelx=state.getCursor() + insets.getLeft() + labelBounds.getWidth() / 2.0;
    double labely=labelLocationY(this.labelLocation,dataArea);
    TextAnchor anchor=labelAnchorV(this.labelLocation);
    TextUtilities.drawRotatedString(label,g2,(float)labelx,(float)labely,anchor,getLabelAngle() + Math.PI / 2.0,anchor);
    state.cursorRight(insets.getLeft() + labelBounds.getWidth() + insets.getRight());
  }
  return state;
}

protected AxisState drawLabel ( String label , Graphics2D g2 , Rectangle2D plotArea , Rectangle2D dataArea , RectangleEdge edge , AxisState state ) { ParamChecks . nullNotPermitted ( state , "state" ) ; if ( ( label == null ) || ( label . equals ( "" ) ) ) { return state ; } Font font = getLabelFont ( ) ; RectangleInsets insets = getLabelInsets ( ) ; g2 . setFont ( font ) ; g2 . setPaint ( getLabelPaint ( ) ) ; FontMetrics fm = g2 . getFontMetrics ( ) ; Rectangle2D labelBounds = TextUtilities . getTextBounds ( label , g2 , fm ) ; if ( edge == RectangleEdge . TOP ) { AffineTransform t = AffineTransform . getRotateInstance ( getLabelAngle ( ) , labelBounds . getCenterX ( ) , labelBounds . getCenterY ( ) ) ; Shape rotatedLabelBounds = t . createTransformedShape ( labelBounds ) ; labelBounds = rotatedLabelBounds . getBounds2D ( ) ; double labelx = labelLocationX ( this . labelLocation , dataArea ) ; double labely = state . getCursor ( ) - insets . getBottom ( ) - labelBounds . getHeight ( ) / 2.0 ; TextAnchor anchor = labelAnchorH ( this . labelLocation ) ; TextUtilities . drawRotatedString ( label , g2 , ( float ) labelx , ( float ) labely , anchor , getLabelAngle ( ) , TextAnchor . CENTER ) ; state . cursorUp ( insets . getTop ( ) + labelBounds . getHeight ( ) + insets . getBottom ( ) ) ; } else if ( edge == RectangleEdge . BOTTOM ) { AffineTransform t = AffineTransform . getRotateInstance ( getLabelAngle ( ) , labelBounds . getCenterX ( ) , labelBounds . getCenterY ( ) ) ; Shape rotatedLabelBounds = t . createTransformedShape ( labelBounds ) ; labelBounds = rotatedLabelBounds . getBounds2D ( ) ; double labelx = labelLocationX ( this . labelLocation , dataArea ) ; double labely = state . getCursor ( ) + insets . getTop ( ) + labelBounds . getHeight ( ) / 2.0 ; TextAnchor anchor = labelAnchorH ( this . labelLocation ) ; TextUtilities . drawRotatedString ( label , g2 , ( float ) labelx , ( float ) labely , anchor , getLabelAngle ( ) , TextAnchor . CENTER ) ; state . cursorDown ( insets . getTop ( ) + labelBounds . getHeight ( ) + insets . getBottom ( ) ) ; } else if ( edge == RectangleEdge . LEFT ) { AffineTransform t = AffineTransform . getRotateInstance ( getLabelAngle ( ) - Math . PI / 2.0 , labelBounds . getCenterX ( ) , labelBounds . getCenterY ( ) ) ; Shape rotatedLabelBounds = t . createTransformedShape ( labelBounds ) ; labelBounds = rotatedLabelBounds . getBounds2D ( ) ; double labelx = state . getCursor ( ) - insets . getRight ( ) - labelBounds . getWidth ( ) / 2.0 ; double labely = labelLocationY ( this . labelLocation , dataArea ) ; TextAnchor anchor = labelAnchorV ( this . labelLocation ) ; TextUtilities . drawRotatedString ( label , g2 , ( float ) labelx , ( float ) labely , anchor , getLabelAngle ( ) - Math . PI / 2.0 , anchor ) ; state . cursorLeft ( insets . getLeft ( ) + labelBounds . getWidth ( ) + insets . getRight ( ) ) ; } else if ( edge == RectangleEdge . RIGHT ) { AffineTransform t = AffineTransform . getRotateInstance ( getLabelAngle ( ) + Math . PI / 2.0 , labelBounds . getCenterX ( ) , labelBounds . getCenterY ( ) ) ; Shape rotatedLabelBounds = t . createTransformedShape ( labelBounds ) ; labelBounds = rotatedLabelBounds . getBounds2D ( ) ; double labelx = state . getCursor ( ) + insets . getLeft ( ) + labelBounds . getWidth ( ) / 2.0 ; double labely = labelLocationY ( this . labelLocation , dataArea ) ; TextAnchor anchor = labelAnchorV ( this . labelLocation ) ; TextUtilities . drawRotatedString ( label , g2 , ( float ) labelx , ( float ) labely , anchor , getLabelAngle ( ) + Math . PI / 2.0 , anchor ) ; state . cursorRight ( insets . getLeft ( ) + labelBounds . getWidth ( ) + insets . getRight ( ) ) ; } return state ; }
draws the axis label .
