Esempio n. 1
0
  /**
   * Gets the bounding rect for the string based on the font
   *
   * @param string
   * @return Rectangle
   */
  public Rectangle2D getBounds(String string) {
    Rectangle2D rect;

    String[] rows = string.split("\n");

    float height = rows.length * this.size;
    float width = this.longestString(rows) * this.size;

    rect = new Rectangle.Float(0, 0, width, height);

    return rect.getBounds2D();
  }
Esempio n. 2
0
 @Override
 public Rectangle2D getBounds() {
   Rectangle2D rect = null;
   if (picture != null) {
     double h = picture.getHeight(null);
     double w = picture.getWidth(null);
     rect = new Rectangle2D.Double(loc.getX() - w / 2, loc.getY() - h / 2, w, h);
   } else if (rShape[shapeForBox] != null) {
     rect = rShape[shapeForBox].getBounds2D();
     double h = rect.getHeight();
     double w = rect.getBounds2D().getWidth();
     rect = new Rectangle2D.Double(loc.getX() - w / 2, loc.getY() - h / 2, w, h);
   }
   return rect;
 }