Exemplo n.º 1
0
 public void invokeStep(int x, int y, int anchorX, int anchorY, DrawingView view) {
   Rectangle r = owner().displayBox();
   owner()
       .displayBox(
           new Point(Math.min(r.x + r.width, x), Math.min(r.y + r.height, y)),
           new Point(r.x + r.width, r.y + r.height));
 }
Exemplo n.º 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);
 }
 /**
  * Return the size of the area occupied by the contained figures inside the drawing. This method
  * is called by checkMinimumSize().
  */
 protected Dimension getDrawingSize() {
   FigureEnumeration fe = drawing().figures();
   Dimension d = new Dimension(0, 0);
   while (fe.hasNextFigure()) {
     Rectangle r = fe.nextFigure().displayBox();
     d.width = Math.max(d.width, r.x + r.width);
     d.height = Math.max(d.height, r.y + r.height);
   }
   return d;
 }
Exemplo n.º 4
0
  public void mouseDrag(MouseEvent e, int x, int y) {
    super.mouseDrag(e, x, y);
    fMoved = (Math.abs(x - fAnchorX) > 4) || (Math.abs(y - fAnchorY) > 4);

    if (fMoved) {
      FigureEnumeration figures = getUndoActivity().getAffectedFigures();
      while (figures.hasMoreElements()) {
        figures.nextFigure().moveBy(x - fLastX, y - fLastY);
      }
    }
    fLastX = x;
    fLastY = y;
  }
Exemplo n.º 5
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);
 }
 /** Called when a drag operation is ongoing on the DropTarget. */
 public void dragOver(DropTargetDragEvent dtde) {
   // log("DropTargetDragEvent-dragOver");
   if (supportDropTargetDragEvent(dtde) == true) {
     int x = dtde.getLocation().x;
     int y = dtde.getLocation().y;
     if ((Math.abs(x - fLastX) > 0) || (Math.abs(y - fLastY) > 0)) {
       // FigureEnumeration fe = view().selectionElements();
       // while (fe.hasNextFigure()) {
       //	fe.nextFigure().moveBy(x - fLastX, y - fLastY);
       //	System.out.println("moving Figures " + view());
       // }
       // view().drawing().update();
       fLastX = x;
       fLastY = y;
     }
   }
 }
Exemplo n.º 7
0
 public void invokeStep(int x, int y, int anchorX, int anchorY, DrawingView view) {
   Rectangle r = owner().displayBox();
   owner().displayBox(new Point(r.x, r.y), new Point(r.x + r.width, Math.max(r.y, y)));
 }
Exemplo n.º 8
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)));
 }
Exemplo n.º 9
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);
 }
Exemplo n.º 10
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());
 }