Example #1
0
 /*
  * @see org.tigris.gef.presentation.Fig#setLineWidth(int)
  */
 @Override
 public void setLineWidth(int w) {
   bodyTextFig.setLineWidth(0); // Make a seamless integration of the text
   // in the note figure.
   outlineFig.setLineWidth(w);
   urCorner.setLineWidth(w);
 }
Example #2
0
  /**
   * Constructor.
   *
   * @param edge the Edge to layout
   */
  public ClassdiagramEdge(FigEdge edge) {
    currentEdge = edge;
    underlyingFig = new FigPoly();
    underlyingFig.setLineColor(edge.getFig().getLineColor());

    destFigNode = edge.getDestFigNode();
    sourceFigNode = edge.getSourceFigNode();
  }
Example #3
0
  /*
   * @see org.tigris.gef.presentation.Fig#setBounds(int, int, int, int)
   */
  @Override
  protected void setStandardBounds(int px, int py, int w, int h) {
    if (bodyTextFig == null) {
      return;
    }

    Dimension stereoMin = getStereotypeFig().getMinimumSize();

    int stereotypeHeight = 0;
    if (getStereotypeFig().isVisible()) {
      stereotypeHeight = stereoMin.height;
    }

    Rectangle oldBounds = getBounds();

    // Resize the text figure
    bodyTextFig.setBounds(
        px + 2, py + 2 + stereotypeHeight, w - 4 - dogear, h - 4 - stereotypeHeight);

    getStereotypeFig().setBounds(px + 2, py + 2, w - 4 - dogear, stereoMin.height);

    // Resize the big port around the figure
    getBigPort().setBounds(px, py, w, h);

    // Since this is a complex polygon, there's no easy way to resize it.
    Polygon newPoly = new Polygon();
    newPoly.addPoint(px, py);
    newPoly.addPoint(px + w - 1 - dogear, py);
    newPoly.addPoint(px + w - 1, py + dogear);
    newPoly.addPoint(px + w - 1, py + h - 1);
    newPoly.addPoint(px, py + h - 1);
    newPoly.addPoint(px, py);
    outlineFig.setPolygon(newPoly);

    // Just move the corner to it's new position.
    urCorner.setBounds(px + w - 1 - dogear, py, dogear, dogear);

    calcBounds(); // _x = x; _y = y; _w = w; _h = h;
    firePropChange("bounds", oldBounds, getBounds());
  }
  /**
   * helper method for updateClassifiers() in order to automatically layout an edge that is now from
   * and to the same node type.
   *
   * <p>adapted from SelectionWButtons from line 280
   */
  private void layoutThisToSelf() {

    FigPoly edgeShape = new FigPoly();
    // newFC = _content;
    Point fcCenter = new Point(getSourceFigNode().getX() / 2, getSourceFigNode().getY() / 2);
    Point centerRight =
        new Point((int) (fcCenter.x + getSourceFigNode().getSize().getWidth() / 2), fcCenter.y);

    int yoffset = (int) ((getSourceFigNode().getSize().getHeight() / 2));
    edgeShape.addPoint(fcCenter.x, fcCenter.y);
    edgeShape.addPoint(centerRight.x, centerRight.y);
    edgeShape.addPoint(centerRight.x + 30, centerRight.y);
    edgeShape.addPoint(centerRight.x + 30, centerRight.y + yoffset);
    edgeShape.addPoint(centerRight.x, centerRight.y + yoffset);

    // place the edge on the layer and update the diagram
    this.setBetweenNearestPoints(true);
    edgeShape.setLineColor(Color.black);
    edgeShape.setFilled(false);
    edgeShape.setComplete(true);
    this.setFig(edgeShape);
  }
Example #5
0
 /*
  * @see org.tigris.gef.presentation.Fig#getLineWidth()
  */
 @Override
 public int getLineWidth() {
   return outlineFig.getLineWidth();
 }
Example #6
0
 @Override
 public boolean isFilled() {
   return outlineFig.isFilled();
 }
Example #7
0
 /*
  * @see org.tigris.gef.presentation.Fig#setFilled(boolean)
  */
 @Override
 public void setFilled(boolean f) {
   bodyTextFig.setFilled(false); // The text is always opaque.
   outlineFig.setFilled(f);
   urCorner.setFilled(f);
 }
Example #8
0
 /*
  * @see org.tigris.gef.presentation.Fig#getFillColor()
  */
 @Override
 public Color getFillColor() {
   return outlineFig.getFillColor();
 }
Example #9
0
 /*
  * @see org.tigris.gef.presentation.Fig#setFillColor(java.awt.Color)
  */
 @Override
 public void setFillColor(Color col) {
   outlineFig.setFillColor(col);
   urCorner.setFillColor(col);
 }
Example #10
0
 /*
  * @see org.tigris.gef.presentation.Fig#setLineColor(java.awt.Color)
  */
 @Override
 public void setLineColor(Color col) {
   // The text element has no border, so the line color doesn't matter.
   outlineFig.setLineColor(col);
   urCorner.setLineColor(col);
 }
Example #11
0
  private void initialize() {
    Color fg = super.getLineColor(); // Use super because not fully init'd
    Color fill = super.getFillColor();

    outlineFig = new FigPoly(fg, fill);
    outlineFig.addPoint(0, 0);
    outlineFig.addPoint(width - 1 - dogear, 0);
    outlineFig.addPoint(width - 1, dogear);
    outlineFig.addPoint(width - 1, height - 1);
    outlineFig.addPoint(0, height - 1);
    outlineFig.addPoint(0, 0);
    outlineFig.setFilled(true);
    outlineFig.setLineWidth(LINE_WIDTH);

    urCorner = new FigPoly(fg, fill);
    urCorner.addPoint(width - 1 - dogear, 0);
    urCorner.addPoint(width - 1, dogear);
    urCorner.addPoint(width - 1 - dogear, dogear);
    urCorner.addPoint(width - 1 - dogear, 0);
    urCorner.setFilled(true);
    Color col = outlineFig.getFillColor();
    urCorner.setFillColor(col.darker());
    urCorner.setLineWidth(LINE_WIDTH);

    setBigPort(new FigRect(0, 0, width, height, null, null));
    getBigPort().setFilled(false);
    getBigPort().setLineWidth(0);

    // add Figs to the FigNode in back-to-front order
    addFig(getBigPort());
    addFig(outlineFig);
    addFig(urCorner);
    addFig(getStereotypeFig());
    addFig(bodyTextFig);

    col = outlineFig.getFillColor();
    urCorner.setFillColor(col.darker());

    setBlinkPorts(false); // make port invisible unless mouse enters
    Rectangle r = getBounds();
    setBounds(r.x, r.y, r.width, r.height);
    updateEdges();

    readyToEdit = false;
    // Mark this as newly created. This is to get round the problem with
    // creating figs for loaded comments that had stereotypes. They are
    // saved with their dimensions INCLUDING the stereotype, but since we
    // pretend the stereotype is not visible, we add height the first time
    // we render such a comment. This is a complete fudge, and really we
    // ought to address how comment objects with stereotypes are saved. But
    // that will be hard work.
    newlyCreated = true;
  }