Exemplo n.º 1
0
  private void setupAttributes() {
    Color frameColor = (Color) AttributeFigure.getDefaultAttribute("FrameColor");
    Color fillColor = (Color) AttributeFigure.getDefaultAttribute("FillColor");
    Color textColor = (Color) AttributeFigure.getDefaultAttribute("TextColor");
    Integer arrowMode = (Integer) AttributeFigure.getDefaultAttribute("ArrowMode");
    String fontName = (String) AttributeFigure.getDefaultAttribute("FontName");

    FigureEnumeration k = view().selectionElements();
    while (k.hasMoreElements()) {
      Figure f = k.nextFigure();
      frameColor = (Color) f.getAttribute("FrameColor");
      fillColor = (Color) f.getAttribute("FillColor");
      textColor = (Color) f.getAttribute("TextColor");
      arrowMode = (Integer) f.getAttribute("ArrowMode");
      fontName = (String) f.getAttribute("FontName");
    }

    fFrameColor.setSelectedIndex(ColorMap.colorIndex(frameColor));
    fFillColor.setSelectedIndex(ColorMap.colorIndex(fillColor));
    // fTextColor.select(ColorMap.colorIndex(textColor));
    if (arrowMode != null) {
      fArrowChoice.setSelectedIndex(arrowMode.intValue());
    }
    if (fontName != null) {
      fFontChoice.setSelectedItem(fontName);
    }
  }
Exemplo n.º 2
0
 /**
  * Removes all children.
  *
  * @see #remove
  */
 public void removeAll() {
   FigureEnumeration k = figures();
   while (k.hasMoreElements()) {
     Figure figure = k.nextFigure();
     figure.removeFromContainer(this);
   }
   fFigures.removeAllElements();
 }
Exemplo n.º 3
0
 /** Releases the figure and all its children. */
 public void release() {
   super.release();
   FigureEnumeration k = figures();
   while (k.hasMoreElements()) {
     Figure figure = k.nextFigure();
     figure.release();
   }
 }
Exemplo n.º 4
0
 /**
  * Finds a figure but descends into a figure's children. Use this method to implement
  * <i>click-through</i> hit detection, that is, you want to detect the inner most figure
  * containing the given point.
  */
 public Figure findFigureInside(int x, int y) {
   FigureEnumeration k = figuresReverse();
   while (k.hasMoreElements()) {
     Figure figure = k.nextFigure().findFigureInside(x, y);
     if (figure != null) return figure;
   }
   return null;
 }
Exemplo n.º 5
0
 /**
  * Finds a top level Figure. Use this call for hit detection that should not descend into the
  * figure's children.
  */
 public Figure findFigure(int x, int y) {
   FigureEnumeration k = figuresReverse();
   while (k.hasMoreElements()) {
     Figure figure = k.nextFigure();
     if (figure.containsPoint(x, y)) return figure;
   }
   return null;
 }
Exemplo n.º 6
0
 /**
  * Finds a top level Figure, but supresses the passed in figure. Use this method to ignore a
  * figure that is temporarily inserted into the drawing.
  *
  * @param x the x coordinate
  * @param y the y coordinate
  * @param without the figure to be ignored during the find.
  */
 public Figure findFigureWithout(int x, int y, Figure without) {
   if (without == null) return findFigure(x, y);
   FigureEnumeration k = figuresReverse();
   while (k.hasMoreElements()) {
     Figure figure = k.nextFigure();
     if (figure.containsPoint(x, y) && !figure.includes(without)) return figure;
   }
   return null;
 }
Exemplo n.º 7
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;
 }
Exemplo n.º 8
0
  private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException {

    s.defaultReadObject();

    FigureEnumeration k = figures();
    while (k.hasMoreElements()) {
      Figure figure = k.nextFigure();
      figure.addToContainer(this);
    }
  }
Exemplo n.º 9
0
 /**
  * Moves all the given figures by x and y. Doesn't announce any changes. Subclassers override
  * basicMoveBy. Clients usually call moveBy.
  *
  * @see moveBy
  */
 protected void basicMoveBy(int x, int y) {
   FigureEnumeration k = figures();
   while (k.hasMoreElements()) {
     Figure fig = k.nextFigure();
     Figure obsrvd = (Figure) fig.getAttribute("observed.figure");
     if (obsrvd == null || !includes(obsrvd)) {
       fig.moveBy(x, y);
     }
   }
 }
Exemplo n.º 10
0
  /** Checks if the composite figure has the argument as one of its children. */
  public boolean includes(Figure figure) {
    if (super.includes(figure)) return true;

    FigureEnumeration k = figures();
    while (k.hasMoreElements()) {
      Figure f = k.nextFigure();
      if (f.includes(figure)) return true;
    }
    return false;
  }
Exemplo n.º 11
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;
 }
Exemplo n.º 12
0
 /**
  * Finds a figure but descends into a figure's children. It supresses the passed in figure. Use
  * this method to ignore a figure that is temporarily inserted into the drawing.
  */
 public Figure findFigureInsideWithout(int x, int y, Figure without) {
   FigureEnumeration k = figuresReverse();
   while (k.hasMoreElements()) {
     Figure figure = k.nextFigure();
     if (figure != without) {
       Figure found = figure.findFigureInside(x, y);
       if (found != null) return found;
     }
   }
   return null;
 }
Exemplo n.º 13
0
 /**
  * Draws all the contained figures
  *
  * @see Figure#draw
  */
 public void draw(Graphics g, boolean showGuides) {
   FigureEnumeration k = figures();
   while (k.hasMoreElements()) k.nextFigure().draw(g, showGuides);
 }