Beispiel #1
0
 protected internal virtual double estimateMaximumTickLabelHeight(Graphics2D g2)
 {
   RectangleInsets tickLabelInsets = this.getTickLabelInsets();
   return tickLabelInsets.getTop() + tickLabelInsets.getBottom() + (double) this.getTickLabelFont().getLineMetrics("123", g2.getFontRenderContext()).getHeight();
 }
 public static Rectangle2D getTextBounds(string text, Graphics2D g2, FontMetrics fm)
 {
   Rectangle2D rectangle2D;
   if (TextUtilities.useFontMetricsGetStringBounds)
   {
     rectangle2D = fm.getStringBounds(text, (Graphics) g2);
     LineMetrics lineMetrics = fm.getFont().getLineMetrics(text, g2.getFontRenderContext());
     rectangle2D.setRect(((RectangularShape) rectangle2D).getX(), ((RectangularShape) rectangle2D).getY(), ((RectangularShape) rectangle2D).getWidth(), (double) lineMetrics.getHeight());
   }
   else
   {
     double num1 = (double) fm.stringWidth(text);
     double num2 = (double) fm.getHeight();
     if (TextUtilities.__\u003C\u003Elogger.isDebugEnabled())
       TextUtilities.__\u003C\u003Elogger.debug((object) new StringBuffer().append("Height = ").append(num2).toString());
     rectangle2D = (Rectangle2D) new Rectangle2D.Double(0.0, (double) -fm.getAscent(), num1, num2);
   }
   return rectangle2D;
 }
Beispiel #3
0
 protected internal virtual double estimateMaximumTickLabelWidth(Graphics2D g2, TickUnit unit)
 {
   RectangleInsets tickLabelInsets = this.getTickLabelInsets();
   double num1 = tickLabelInsets.getLeft() + tickLabelInsets.getRight();
   double num2;
   if (this.isVerticalTickLabels())
   {
     LineMetrics lineMetrics = this.getTickLabelFont().getLineMetrics("0", g2.getFontRenderContext());
     num2 = num1 + (double) lineMetrics.getHeight();
   }
   else
   {
     FontMetrics fontMetrics = ((Graphics) g2).getFontMetrics(this.getTickLabelFont());
     Range range = this.getRange();
     double lowerBound = range.getLowerBound();
     double upperBound = range.getUpperBound();
     NumberFormat numberFormatOverride = this.getNumberFormatOverride();
     string str1;
     string str2;
     if (numberFormatOverride != null)
     {
       str1 = numberFormatOverride.format(lowerBound);
       str2 = numberFormatOverride.format(upperBound);
     }
     else
     {
       str1 = unit.valueToString(lowerBound);
       str2 = unit.valueToString(upperBound);
     }
     double num3 = (double) fontMetrics.stringWidth(str1);
     double num4 = (double) fontMetrics.stringWidth(str2);
     num2 = num1 + Math.max(num3, num4);
   }
   return num2;
 }
 public static void drawRotatedString(string text, Graphics2D g2, float textX, float textY, double angle, float rotateX, float rotateY)
 {
   if (text == null || String.instancehelper_equals(text, (object) ""))
     return;
   AffineTransform transform = g2.getTransform();
   AffineTransform rotateInstance = AffineTransform.getRotateInstance(angle, (double) rotateX, (double) rotateY);
   g2.transform(rotateInstance);
   if (TextUtilities.useDrawRotatedStringWorkaround)
   {
     TextLayout.__\u003Cclinit\u003E();
     new TextLayout(text, ((Graphics) g2).getFont(), g2.getFontRenderContext()).draw(g2, textX, textY);
   }
   else
     g2.drawString(text, textX, textY);
   g2.setTransform(transform);
 }