Пример #1
0
 private Rectangle fieldBounds(Figure figure) {
   Rectangle box = figure.displayBox();
   int nChars = Math.max(20, getURL(figure).length());
   Dimension d = fTextField.getPreferredSize(nChars);
   box.x = Math.max(0, box.x + (box.width - d.width) / 2);
   box.y = Math.max(0, box.y + (box.height - d.height) / 2);
   return new Rectangle(box.x, box.y, d.width, d.height);
 }
Пример #2
0
 public Point locate() {
   LineConnection line = ownerConnection();
   int segment = Math.min(fSegment, line.pointCount() - 2);
   Point p1 = line.pointAt(segment);
   Point p2 = line.pointAt(segment + 1);
   return new Point((p1.x + p2.x) / 2, (p1.y + p2.y) / 2);
 }
Пример #3
0
 private void addPointRelative(Polygon shape, int x, int y, double radius, double angle) {
   shape.addPoint(x + (int) (radius * Math.cos(angle)), y + (int) (radius * Math.sin(angle)));
 }
Пример #4
0
 /** Calculates the outline of an arrow tip. */
 public Polygon outline(int x1, int y1, int x2, int y2) {
   double dir = Math.PI / 2 - Math.atan2(x2 - x1, y2 - y1);
   return outline(x1, y1, dir);
 }
Пример #5
0
 /**
  * Gets the number of columns to be used by the text overlay.
  *
  * @see CH.ifa.draw.util.FloatingTextField
  */
 public final int overlayColumns() {
   return Math.max(4, getText().length());
 }