示例#1
0
    private boolean resetDisplayBox() {
      FigureEnumeration fe = getAffectedFigures();
      if (!fe.hasMoreElements()) {
        return false;
      }
      Figure currentFigure = fe.nextFigure();

      Rectangle figureDisplayBox = currentFigure.displayBox();
      currentFigure.displayBox(getOldDisplayBox());
      setOldDisplayBox(figureDisplayBox);
      return true;
    }
示例#2
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);
 }
示例#3
0
 /** Finds a top level Figure that intersects the given rectangle. */
 public Figure findFigure(Rectangle r) {
   FigureEnumeration k = figuresReverse();
   while (k.hasMoreElements()) {
     Figure figure = k.nextFigure();
     Rectangle fr = figure.displayBox();
     if (r.intersects(fr)) return figure;
   }
   return null;
 }
示例#4
0
 /**
  * Finds a top level Figure that intersects the given rectangle. It supresses the passed in
  * figure. Use this method to ignore a figure that is temporarily inserted into the drawing.
  */
 public Figure findFigure(Rectangle r, Figure without) {
   if (without == null) return findFigure(r);
   FigureEnumeration k = figuresReverse();
   while (k.hasMoreElements()) {
     Figure figure = k.nextFigure();
     Rectangle fr = figure.displayBox();
     if (r.intersects(fr) && !figure.includes(without)) return figure;
   }
   return null;
 }
示例#5
0
  private int constrainY(int y) {
    LineConnection line = ownerConnection();
    Figure startFigure = line.getStartConnector().owner();
    Figure endFigure = line.getEndConnector().owner();
    Rectangle start = startFigure.displayBox();
    Rectangle end = endFigure.displayBox();
    Insets i1 = startFigure.connectionInsets();
    Insets i2 = endFigure.connectionInsets();

    int r1y, r1height, r2y, r2height;
    r1y = start.y + i1.top;
    r1height = start.height - i1.top - i1.bottom - 1;
    r2y = end.y + i2.top;
    r2height = end.height - i2.top - i2.bottom - 1;

    if (fSegment == 0) {
      y = Geom.range(r1y, r1y + r1height, y);
    }
    if (fSegment == line.pointCount() - 2) {
      y = Geom.range(r2y, r2y + r2height, y);
    }
    return y;
  }
示例#6
0
  private int constrainX(int x) {
    LineConnection line = ownerConnection();
    Figure startFigure = line.getStartConnector().owner();
    Figure endFigure = line.getEndConnector().owner();
    Rectangle start = startFigure.displayBox();
    Rectangle end = endFigure.displayBox();
    Insets i1 = startFigure.connectionInsets();
    Insets i2 = endFigure.connectionInsets();

    int r1x, r1width, r2x, r2width;
    r1x = start.x + i1.left;
    r1width = start.width - i1.left - i1.right - 1;

    r2x = end.x + i2.left;
    r2width = end.width - i2.left - i2.right - 1;

    if (fSegment == 0) {
      x = Geom.range(r1x, r1x + r1width, x);
    }
    if (fSegment == line.pointCount() - 2) {
      x = Geom.range(r2x, r2x + r2width, x);
    }
    return x;
  }
 public Point locate(Figure owner) {
   Rectangle r = owner.displayBox();
   return new Point(r.x + (int) (r.width * fRelativeX), r.y + (int) (r.height * fRelativeY));
 }