Example #1
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;
  }
  /**
   * 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);
  }