Ejemplo n.º 1
0
  private void constructFigs(int x, int y, int w, int h) {
    bigPort = new FigRect(x, y, w, h, LINE_COLOR, FILL_COLOR);
    bigPort.setFilled(true);
    setFilled(true);

    bigPort.setLineWidth(0);
    setLineWidth(0);
    addFig(bigPort);
  }
Ejemplo n.º 2
0
 /** Change the line. */
 public void setTargetLine() {
   Fig target = getPanelTarget();
   Object c = lineField.getSelectedItem();
   if (target == null || c == null) {
     return;
   }
   if (c instanceof Color) {
     target.setLineColor((Color) c);
   }
   target.setLineWidth((c instanceof Color) ? 1 : 0);
   target.endTrans();
 }
Ejemplo n.º 3
0
  /**
   * Main constructor for a {@link FigClass}.
   *
   * <p>Parent {@link FigNodeModelElement} will have created the main box {@link #getBigPort()} and
   * its name {@link #getNameFig()} and stereotype (@link #getStereotypeFig()}. This constructor
   * creates a box for the attributes and operations.
   *
   * <p>The properties of all these graphic elements are adjusted appropriately. The main boxes are
   * all filled and have outlines.
   *
   * <p>For reasons I don't understand the stereotype is created in a box with lines. So we have to
   * created a blanking rectangle to overlay the bottom line, and avoid four compartments showing.
   *
   * <p>There is some complex logic to allow for the possibility that stereotypes may not be
   * displayed (unlike operations and attributes this is not a standard thing for UML). Some care is
   * needed to ensure that additional space is not added, each time a stereotyped class is loaded.
   *
   * <p>There is a particular problem when loading diagrams with stereotyped classes. Because we
   * create a FigClass indicating the stereotype is not displayed, we then add extra space for such
   * classes when they are first rendered. This ought to be fixed by correctly saving the class
   * dimensions, but that needs more work. The solution here is to use a simple flag to indicate the
   * FigClass has just been created.
   *
   * <p><em>Warning</em>. Much of the graphics positioning is hard coded. The overall figure is
   * placed at location (10,10). The name compartment (in the parent {@link FigNodeModelElement} is
   * 21 pixels high. The stereotype compartment is created 15 pixels high in the parent, but we
   * change it to 19 pixels, 1 more than ({@link #STEREOHEIGHT} here. The attribute and operations
   * boxes are created at 19 pixels, 2 more than {@link #ROWHEIGHT}.
   *
   * <p>CAUTION: This constructor (with no arguments) is the only one that does
   * enableSizeChecking(false), all others must set it true. This is because this constructor is the
   * only one called when loading a project. In this case, the parsed size must be maintained.
   *
   * <p>
   */
  public FigClass() {

    getBigPort().setLineWidth(0);
    getBigPort().setFillColor(Color.white);

    // Attributes inside. First one is the attribute box itself.
    attributesFigCompartment = new FigAttributesCompartment(10, 30, 60, ROWHEIGHT + 2);

    // The operations compartment is built in the ancestor FigClassifierBox

    // Set properties of the stereotype box. Make it 1 pixel higher than
    // before, so it overlaps the name box, and the blanking takes out both
    // lines. Initially not set to be displayed, but this will be changed
    // when we try to render it, if we find we have a stereotype.
    getStereotypeFig().setFilled(false);
    getStereotypeFig().setHeight(STEREOHEIGHT + 1);
    // +1 to have 1 pixel overlap with getNameFig()
    getStereotypeFig().setVisible(true);

    borderFig = new FigEmptyRect(10, 10, 0, 0);
    borderFig.setLineWidth(1);
    borderFig.setLineColor(Color.black);

    getStereotypeFig().setLineWidth(0);

    // Mark this as newly created. This is to get round the problem with
    // creating figs for loaded classes 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 class. This is a complete fudge, and really we
    // ought to address how class objects with stereotypes are saved. But
    // that will be hard work.
    newlyCreated = true;

    // Put all the bits together, suppressing bounds calculations until
    // we're all done for efficiency.
    enableSizeChecking(false);
    setSuppressCalcBounds(true);
    addFig(getBigPort());
    addFig(getStereotypeFig());
    addFig(getNameFig());
    addFig(operationsFig);
    addFig(attributesFigCompartment);
    addFig(borderFig);

    setSuppressCalcBounds(false);
    // Set the bounds of the figure to the total of the above (hardcoded)
    setBounds(10, 10, 60, 22 + 2 * ROWHEIGHT);
  }
Ejemplo n.º 4
0
 /*
  * @see org.tigris.gef.presentation.Fig#setLineWidth(int)
  */
 @Override
 public void setLineWidth(int width) {
   // Miss out the text fix, this should have no line
   for (int i = HEAD_POSN; i < RIGHT_LEG_POSN; i++) {
     Fig f = getFigAt(i);
     if (f != null) {
       f.setLineWidth(width);
     }
   }
   getFigAt(HEAD_POSN).setLineWidth(width);
   getFigAt(BODY_POSN).setLineWidth(width);
   getFigAt(ARMS_POSN).setLineWidth(width);
   getFigAt(LEFT_LEG_POSN).setLineWidth(width);
   getFigAt(RIGHT_LEG_POSN).setLineWidth(width);
 }
Ejemplo n.º 5
0
 /** @see org.tigris.gef.presentation.Fig#setLineWidth(int) */
 public void setLineWidth(int w) {
   borderFig.setLineWidth(w);
 }