/**
   * Return a Fig that can be used to represent the given node.
   *
   * <p>
   *
   * @param gm The graph model for which we are rendering.
   * @param lay The layer in the graph on which we want this figure.
   * @param node The node to be rendered (an model element object)
   * @param styleAttributes an optional map of attributes to style the fig
   * @return The fig to be used, or <code>null</code> if we can't create one.
   */
  public FigNode getFigNodeFor(GraphModel gm, Layer lay, Object node, Map styleAttributes) {

    FigNodeModelElement figNode = null;

    // Create a new version of the relevant fig

    if (Model.getFacade().isAActor(node)) {
      figNode = new FigActor(gm, node);
    } else if (Model.getFacade().isAUseCase(node)) {
      figNode = new FigUseCase(gm, node);
    } else if (Model.getFacade().isAComment(node)) {
      figNode = new FigComment(gm, node);
    } else if (Model.getFacade().isAPackage(node)) {
      figNode = new FigPackage(gm, node);
    } else {
      LOG.debug(
          this.getClass().toString()
              + ": getFigNodeFor("
              + gm.toString()
              + ", "
              + lay.toString()
              + ", "
              + node.toString()
              + ") - cannot create this sort of node.");
      return null;
      // TODO: Shouldn't we throw an excdeption here?!?!
    }

    lay.add(figNode);
    figNode.setDiElement(GraphChangeAdapter.getInstance().createElement(gm, node));

    return figNode;
  }
 /** Handle changes in the shadowfield. */
 public void setTargetShadow() {
   int i = shadowField.getSelectedIndex();
   if (getPanelTarget() == null || !(getPanelTarget() instanceof FigNodeModelElement)) {
     return;
   }
   FigNodeModelElement nodeTarget = (FigNodeModelElement) getPanelTarget();
   nodeTarget.setShadowSize(i);
   getPanelTarget().endTrans();
 }
  protected void modelChanged() {
    super.modelChanged();
    MComponentInstance coi = (MComponentInstance) getOwner();
    if (coi == null) return;
    String nameStr = "";
    if (coi.getName() != null) {
      nameStr = coi.getName().trim();
    }

    // construct bases string (comma separated)
    String baseStr = "";
    Collection col = coi.getClassifiers();
    if (col != null && col.size() > 0) {
      Iterator it = col.iterator();
      baseStr = ((MClassifier) it.next()).getName();
      while (it.hasNext()) {
        baseStr += ", " + ((MClassifier) it.next()).getName();
      }
    }
    if (_readyToEdit) {
      if (nameStr == "" && baseStr == "") _name.setText("");
      else _name.setText(nameStr.trim() + " : " + baseStr);
    }
    Dimension nameMin = _name.getMinimumSize();
    Rectangle r = getBounds();
    setBounds(r.x, r.y, r.width, r.height);

    updateStereotypeText();
  }
Ejemplo n.º 4
0
 /**
  * Rerenders the fig if needed. This functionality was originally the functionality of
  * modelChanged but modelChanged takes the event now into account.
  */
 public void renderingChanged() {
   if (getOwner() != null) {
     updateAbstract();
   }
   super.renderingChanged();
   damage();
 }
Ejemplo n.º 5
0
  @Override
  protected final void updateLayout(UmlChangeEvent mee) {
    super.updateLayout(mee);

    if (mee instanceof AttributeChangeEvent && mee.getPropertyName().equals("body")) {

      bodyTextFig.setText(mee.getNewValue().toString());
      calcBounds();
      setBounds(getBounds());
      damage();
    } else if (mee instanceof RemoveAssociationEvent
        && mee.getPropertyName().equals("annotatedElement")) {
      /* Remove the commentedge.
       * If there are more then one comment-edges between
       * the 2 objects, then delete them all. */
      Collection<FigEdgeNote> toRemove = new ArrayList<FigEdgeNote>();
      Collection c = getFigEdges(); // all connected edges
      for (Iterator i = c.iterator(); i.hasNext(); ) {
        FigEdgeNote fen = (FigEdgeNote) i.next();
        Object otherEnd = fen.getDestination(); // the UML object
        if (otherEnd == getOwner()) { // wrong end of the edge
          otherEnd = fen.getSource();
        }
        if (otherEnd == mee.getOldValue()) {
          toRemove.add(fen);
        }
      }

      for (FigEdgeNote fen : toRemove) {
        fen.removeFromDiagram();
      }
    }
  }
Ejemplo n.º 6
0
 /*
  * @see org.tigris.gef.presentation.Fig#setOwner(java.lang.Object)
  */
 @SuppressWarnings("deprecation")
 @Deprecated
 @Override
 public void setOwner(Object own) {
   super.setOwner(own);
   updateBody();
 }
Ejemplo n.º 7
0
 /** Updates the name if modelchanged receives an "isAbstract" event. */
 protected void updateAbstract() {
   Rectangle rect = getBounds();
   if (getOwner() == null) {
     return;
   }
   Object cls = getOwner();
   if (Model.getFacade().isAbstract(cls)) {
     getNameFig().setFont(getItalicLabelFont());
   } else {
     getNameFig().setFont(getLabelFont());
   }
   super.updateNameText();
   setBounds(rect.x, rect.y, rect.width, rect.height);
 }
Ejemplo n.º 8
0
 /*
  * @see org.argouml.uml.diagram.ui.FigNodeModelElement#updateStereotypeText()
  */
 protected void updateStereotypeText() {
   super.updateStereotypeText();
   if (!Model.getFacade().getStereotypes(getOwner()).isEmpty()) {
     Dimension stereoMin = getStereotypeFig().getMinimumSize();
     getStereotypeFig()
         .setBounds(
             (getBigPort().getCenter().x - getStereotypeFig().getWidth() / 2),
             (getBigPort().getY() + getBigPort().getHeight() + MIN_VERT_PADDING),
             stereoMin.width,
             stereoMin.height);
   } else {
     getStereotypeFig().setBounds(getBigPort().getCenter().x, getBigPort().getCenter().y, 0, 0);
   }
   damage();
 }
Ejemplo n.º 9
0
 /*
  * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
  */
 @Override
 public void propertyChange(PropertyChangeEvent pve) {
   Object src = pve.getSource();
   String pName = pve.getPropertyName();
   if (pName.equals("editing") && Boolean.FALSE.equals(pve.getNewValue())) {
     // parse the text that was edited
     textEdited((FigText) src);
     // resize the FigNode to accomodate the new text
     Rectangle bbox = getBounds();
     Dimension minSize = getMinimumSize();
     bbox.width = Math.max(bbox.width, minSize.width);
     bbox.height = Math.max(bbox.height, minSize.height);
     setBounds(bbox.x, bbox.y, bbox.width, bbox.height);
     endTrans();
   } else {
     super.propertyChange(pve);
   }
 }
Ejemplo n.º 10
0
  /*
   * @see org.argouml.uml.diagram.ui.FigNodeModelElement#modelChanged(java.beans.PropertyChangeEvent)
   */
  @Override
  protected void modelChanged(PropertyChangeEvent mee) {
    //      name updating
    super.modelChanged(mee);

    boolean damage = false;
    if (getOwner() == null) {
      return;
    }

    if (mee == null
        || mee.getPropertyName().equals("stereotype")
        || Model.getFacade().getStereotypes(getOwner()).contains(mee.getSource())) {
      updateStereotypeText();
      damage = true;
    }

    if (damage) {
      damage();
    }
  }
Ejemplo n.º 11
0
 public void setOwner(Object node) {
   super.setOwner(node);
   bindPort(node, _bigPort);
 }
  public void setEnclosingFig(Fig encloser) {

    if (encloser != null && encloser.getOwner() instanceof MNodeInstance && getOwner() != null) {
      MNodeInstance node = (MNodeInstance) encloser.getOwner();
      MComponentInstance comp = (MComponentInstance) getOwner();
      if (comp.getNodeInstance() != node) {
        comp.setNodeInstance(node);
      }
      super.setEnclosingFig(encloser);

      Vector figures = getEnclosedFigs();

      if (getLayer() != null) {
        // elementOrdering(figures);
        Vector contents = getLayer().getContents();
        int contentsSize = contents.size();
        for (int j = 0; j < contentsSize; j++) {
          Object o = contents.elementAt(j);
          if (o instanceof FigEdgeModelElement) {
            FigEdgeModelElement figedge = (FigEdgeModelElement) o;
            figedge.getLayer().bringToFront(figedge);
          }
        }
      }
    } else if (encloser == null && getEnclosingFig() != null) {
      if (getEnclosingFig() instanceof FigNodeModelElement)
        ((FigNodeModelElement) getEnclosingFig()).getEnclosedFigs().removeElement(this);
      _encloser = null;
    }
    /*
    super.setEnclosingFig(encloser);

    Vector figures = getEnclosedFigs();

    if (getLayer() != null) {
      // elementOrdering(figures);
      Vector contents = getLayer().getContents();
      int contentsSize = contents.size();
      for (int j=0; j<contentsSize; j++) {
        Object o = contents.elementAt(j);
        if (o instanceof FigEdgeModelElement) {
          FigEdgeModelElement figedge = (FigEdgeModelElement) o;
          figedge.getLayer().bringToFront(figedge);
        }
      }
    }

    if (!(getOwner() instanceof MModelElement)) return;
    if (getOwner() instanceof MComponentInstance) {
      MComponentInstance me = (MComponentInstance) getOwner();
      MNodeInstance mnode = null;

      if (encloser != null && (encloser.getOwner() instanceof MNodeInstance)) {
        mnode = (MNodeInstance) encloser.getOwner();
      }
      if (encloser != null && (encloser.getOwner() instanceof MComponentInstance)) {
        MComponentInstance comp = (MComponentInstance) encloser.getOwner();
        mnode = (MNodeInstance) comp.getNodeInstance();
      }
      try {
        if(mnode != null) {
          me.setNodeInstance(mnode);
        }
        else {
          if (me.getNodeInstance() != null) {
            me.setNodeInstance(null);
          }
        }
        setNode(figures);
      }
      catch (Exception e) {
        cat.error("could not set package", e);

      }
    }
    */
  }
 public void mousePressed(MouseEvent me) {
   super.mousePressed(me);
   Editor ce = Globals.curEditor();
   Selection sel = ce.getSelectionManager().findSelectionFor(this);
   if (sel instanceof SelectionComponentInstance) ((SelectionComponentInstance) sel).hideButtons();
 }
 public void mouseClicked(MouseEvent me) {
   super.mouseClicked(me);
   setLineColor(Color.black);
 }
Ejemplo n.º 15
0
 /*
  * @see org.tigris.gef.presentation.Fig#setEnclosingFig(org.tigris.gef.presentation.Fig)
  */
 @Override
 public void setEnclosingFig(Fig encloser) {
   super.setEnclosingFig(encloser);
 }