svn commit: r17206 - trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2: . diagram
Bob Tarling <[email protected]>
| Newsgroups | gmane.comp.lang.uml.argouml.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: bobtarling
Date: 2009-08-01 10:33:47-0700
New Revision: 17206
Added:
trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/ClassDiagramPropPanelFactory.java
trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/ClassDiagramRenderer.java
trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/FigClass.java
trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/FigComment.java
trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/FigDataType.java
trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/FigEdgeNote.java
trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/FigEnumeration.java
trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/FigException.java
trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/FigInterface.java
trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/FigModel.java
trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/FigPackage.java
trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/FigSignal.java
trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/FigStereotypeDeclaration.java
trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/FigSubsystem.java
trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/SelectionClass.java
trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/SelectionDataType.java
trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/SelectionEnumeration.java
trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/SelectionException.java
trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/SelectionInterface.java
trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/SelectionSignal.java
trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/SelectionStereotype.java
trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/UMLClassDiagram.java
Modified:
trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/ClassDiagramModule.java
trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/ClassDiagramFactory.java
Log:
Copy old diagram and Figs here in preparation for UML2
Modified: trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/ClassDiagramModule.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/ClassDiagramModule.java?view=diff&pathrev=17206&r1=17205&r2=17206
==============================================================================
--- trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/ClassDiagramModule.java (original)
+++ trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/ClassDiagramModule.java 2009-08-01 10:33:47-0700
@@ -24,7 +24,13 @@
package org.argouml.class2;
+import org.apache.log4j.Logger;
import org.argouml.moduleloader.ModuleInterface;
+import org.argouml.class2.diagram.ClassDiagramFactory;
+import org.argouml.uml.diagram.DiagramFactory;
+import org.argouml.uml.diagram.DiagramFactoryInterface2;
+import org.argouml.uml.diagram.DiagramFactory.DiagramType;
+import org.argouml.uml.ui.PropPanelFactoryManager;
/**
* The Class Diagram Module description.
@@ -33,14 +39,39 @@
*/
public class ClassDiagramModule implements ModuleInterface {
+ private static final Logger LOG =
+ Logger.getLogger(ClassDiagramModule.class);
+
+ private ClassDiagramPropPanelFactory propPanelFactory;
+
public boolean enable() {
+
+ propPanelFactory =
+ new ClassDiagramPropPanelFactory();
+ PropPanelFactoryManager.addPropPanelFactory(propPanelFactory);
+ // TODO: Remove the casting to DiagramFactoryInterface2
+ // as soon as DiagramFactoryInterface is removed.
+ DiagramFactory.getInstance().registerDiagramFactory(
+ DiagramType.Class,
+ (DiagramFactoryInterface2) new ClassDiagramFactory());
+
+ LOG.info("ClassDiagram Module enabled.");
return true;
}
public boolean disable() {
+
+ PropPanelFactoryManager.removePropPanelFactory(propPanelFactory);
+
+ // TODO: Remove the casting to DiagramFactoryInterface2
+ // as soon as DiagramFactoryInterface is removed.
+ DiagramFactory.getInstance().registerDiagramFactory(
+ DiagramType.Class, (DiagramFactoryInterface2) null);
+
+ LOG.info("ClassDiagram Module disabled.");
return true;
}
-
+
public String getName() {
return "ArgoUML-Class";
}
Added: trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/ClassDiagramPropPanelFactory.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/ClassDiagramPropPanelFactory.java?view=markup&pathrev=17206
==============================================================================
--- (empty file)
+++ trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/ClassDiagramPropPanelFactory.java 2009-08-01 10:33:47-0700
@@ -0,0 +1,61 @@
+// $Id: DiagramPropPanelFactory.java 14530 2008-04-30 12:26:50Z mvw $
+// Copyright (c) 2008 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.class2;
+
+import org.argouml.i18n.Translator;
+import org.argouml.class2.diagram.UMLClassDiagram;
+import org.argouml.uml.diagram.ui.PropPanelDiagram;
+import org.argouml.uml.ui.PropPanel;
+import org.argouml.uml.ui.PropPanelFactory;
+
+/**
+ * Factory implementation for create a sequence diagram prop panel.
+ *
+ * @author Bob Tarling
+ */
+class ClassDiagramPropPanelFactory implements PropPanelFactory {
+
+ public PropPanel createPropPanel(Object object) {
+ if (object instanceof UMLClassDiagram) {
+ return new PropPanelUMLClassDiagram();
+ }
+ return null;
+ }
+
+ /**
+ * The properties panel for a class diagram.
+ */
+ class PropPanelUMLClassDiagram extends PropPanelDiagram {
+
+ /**
+ * Constructor for PropPanelUMLClassDiagram.
+ */
+ public PropPanelUMLClassDiagram() {
+ super(Translator.localize("label.class-diagram"),
+ lookupIcon("ClassDiagram"));
+ }
+
+ }
+}
Modified: trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/ClassDiagramFactory.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/ClassDiagramFactory.java?view=diff&pathrev=17206&r1=17205&r2=17206
==============================================================================
--- trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/ClassDiagramFactory.java (original)
+++ trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/ClassDiagramFactory.java 2009-08-01 10:33:47-0700
@@ -24,6 +24,9 @@
package org.argouml.class2.diagram;
+import java.beans.PropertyVetoException;
+
+import org.apache.log4j.Logger;
import org.argouml.uml.diagram.ArgoDiagram;
import org.argouml.uml.diagram.DiagramFactoryInterface2;
import org.argouml.uml.diagram.DiagramSettings;
@@ -35,6 +38,12 @@
public class ClassDiagramFactory implements DiagramFactoryInterface2 {
/**
+ * Logger.
+ */
+ private static final Logger LOG =
+ Logger.getLogger(ClassDiagramFactory.class);
+
+ /**
* Factory method to create a new instance of an ArgoDiagram.
*
* @param owner the owning element. This can be the owning namespace for a
@@ -47,6 +56,15 @@
*/
public ArgoDiagram createDiagram(Object owner, String name,
DiagramSettings settings) {
- return null;
+ final ArgoDiagram diagram = new UMLClassDiagram(owner);
+ if (name != null) {
+ try {
+ diagram.setName(name);
+ } catch (PropertyVetoException e) {
+ LOG.error("Cannot set the name " + name +
+ " to the diagram just created: "+ diagram.getName(), e);
+ }
+ }
+ return diagram;
}
}
Added: trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/ClassDiagramRenderer.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/ClassDiagramRenderer.java?view=markup&pathrev=17206
==============================================================================
--- (empty file)
+++ trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/ClassDiagramRenderer.java 2009-08-01 10:33:47-0700
@@ -0,0 +1,265 @@
+// $Id: ClassDiagramRenderer.java 17112 2009-04-13 19:02:54Z tfmorris $
+// Copyright (c) 1996-2008 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.class2.diagram;
+
+import java.util.Collection;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+import org.argouml.model.CoreFactory;
+import org.argouml.model.Model;
+import org.argouml.uml.CommentEdge;
+import org.argouml.uml.diagram.ArgoDiagram;
+import org.argouml.uml.diagram.DiagramSettings;
+import org.argouml.uml.diagram.GraphChangeAdapter;
+import org.argouml.uml.diagram.UmlDiagramRenderer;
+import org.argouml.uml.diagram.static_structure.ui.FigEdgeNote;
+import org.argouml.uml.diagram.static_structure.ui.FigLink;
+import org.argouml.uml.diagram.ui.FigAbstraction;
+import org.argouml.uml.diagram.ui.FigAssociation;
+import org.argouml.uml.diagram.ui.FigAssociationClass;
+import org.argouml.uml.diagram.ui.FigAssociationEnd;
+import org.argouml.uml.diagram.ui.FigDependency;
+import org.argouml.uml.diagram.ui.FigGeneralization;
+import org.argouml.uml.diagram.ui.FigNodeModelElement;
+import org.argouml.uml.diagram.ui.FigPermission;
+import org.argouml.uml.diagram.ui.FigUsage;
+import org.argouml.uml.diagram.ui.UMLDiagram;
+import org.tigris.gef.base.Diagram;
+import org.tigris.gef.base.Layer;
+import org.tigris.gef.base.LayerPerspective;
+import org.tigris.gef.graph.GraphModel;
+import org.tigris.gef.presentation.FigEdge;
+import org.tigris.gef.presentation.FigNode;
+
+/**
+ * This class defines a renderer object for UML Class Diagrams. In a
+ * Class Diagram the following UML objects are displayed with the
+ * following Figs: <p>
+ *
+ * <pre>
+ * UML Object --- Fig
+ * ---------------------------------------
+ * Class --- FigClass
+ * Interface --- FigInterface
+ * Instance --- FigInstance
+ * Model --- FigModel
+ * Subsystem --- FigSubsystem
+ * Package --- FigPackage
+ * Comment --- FigComment
+ * (CommentEdge) --- FigEdgeNote
+ * Generalization --- FigGeneralization
+ * Realization --- FigRealization
+ * Permission --- FigPermission
+ * Usage --- FigUsage
+ * Dependency --- FigDependency
+ * Association --- FigAssociation
+ * AssociationClass --- FigAssociationClass
+ * Dependency --- FigDependency
+ * Link --- FigLink
+ * DataType --- FigDataType
+ * Stereotype --- FigStereotypeDeclaration
+ * </pre>
+ *
+ * @author jrobbins
+ */
+public class ClassDiagramRenderer extends UmlDiagramRenderer {
+
+ /**
+ * The UID.
+ */
+ static final long serialVersionUID = 675407719309039112L;
+
+ /**
+ * Logger.
+ */
+ private static final Logger LOG =
+ Logger.getLogger(ClassDiagramRenderer.class);
+
+ /*
+ * @see org.tigris.gef.graph.GraphNodeRenderer#getFigNodeFor(
+ * org.tigris.gef.graph.GraphModel,
+ * org.tigris.gef.base.Layer, java.lang.Object, java.util.Map)
+ */
+ public FigNode getFigNodeFor(GraphModel gm, Layer lay,
+ Object node, Map styleAttributes) {
+
+ FigNodeModelElement figNode = null;
+
+ if (node == null) {
+ throw new IllegalArgumentException("A node must be supplied");
+ }
+ // Although not generally true for GEF, for Argo we know that the layer
+ // is a LayerPerspective which knows the associated diagram
+ Diagram diag = ((LayerPerspective) lay).getDiagram();
+ if (diag instanceof UMLDiagram
+ && ((UMLDiagram) diag).doesAccept(node)) {
+ figNode = (FigNodeModelElement) ((UMLDiagram) diag)
+ .drop(node, null);
+ } else {
+ LOG.error("TODO: ClassDiagramRenderer getFigNodeFor " + node);
+ throw new IllegalArgumentException(
+ "Node is not a recognised type. Received "
+ + node.getClass().getName());
+ }
+
+ lay.add(figNode);
+ figNode.setDiElement(
+ GraphChangeAdapter.getInstance().createElement(gm, node));
+
+
+ return figNode;
+
+ }
+
+ /**
+ * Return a Fig that can be used to represent the given edge.
+ * Throws IllegalArgumentException if the edge is not of an expected type.
+ * Throws IllegalStateException if the edge generated has no source
+ * or dest port.
+ * {@inheritDoc}
+ */
+ public FigEdge getFigEdgeFor(GraphModel gm, Layer lay,
+ Object edge, Map styleAttribute) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("making figedge for " + edge);
+ }
+ if (edge == null) {
+ throw new IllegalArgumentException("A model edge must be supplied");
+ }
+
+ assert lay instanceof LayerPerspective;
+ ArgoDiagram diag = (ArgoDiagram) ((LayerPerspective) lay).getDiagram();
+ DiagramSettings settings = diag.getDiagramSettings();
+
+ FigEdge newEdge = null;
+ if (Model.getFacade().isAAssociationClass(edge)) {
+ newEdge = new FigAssociationClass(edge, settings);
+ } else if (Model.getFacade().isAAssociationEnd(edge)) {
+ FigAssociationEnd asend = new FigAssociationEnd(edge, settings);
+ Model.getFacade().getAssociation(edge);
+ FigNode associationFN =
+ (FigNode) lay.presentationFor(
+ Model.getFacade().getAssociation(edge));
+ FigNode classifierFN =
+ (FigNode) lay.presentationFor(Model.getFacade().getType(edge));
+
+ asend.setSourcePortFig(associationFN);
+ asend.setSourceFigNode(associationFN);
+ asend.setDestPortFig(classifierFN);
+ asend.setDestFigNode(classifierFN);
+ newEdge = asend;
+ } else if (Model.getFacade().isAAssociation(edge)) {
+ newEdge = new FigAssociation(edge, settings);
+ } else if (Model.getFacade().isALink(edge)) {
+ FigLink lnkFig = new FigLink(edge, settings);
+ Collection linkEndsColn = Model.getFacade().getConnections(edge);
+
+ Object[] linkEnds = linkEndsColn.toArray();
+ Object fromInst = Model.getFacade().getInstance(linkEnds[0]);
+ Object toInst = Model.getFacade().getInstance(linkEnds[1]);
+
+ FigNode fromFN = (FigNode) lay.presentationFor(fromInst);
+ FigNode toFN = (FigNode) lay.presentationFor(toInst);
+ lnkFig.setSourcePortFig(fromFN);
+ lnkFig.setSourceFigNode(fromFN);
+ lnkFig.setDestPortFig(toFN);
+ lnkFig.setDestFigNode(toFN);
+ lnkFig.getFig().setLayer(lay);
+ newEdge = lnkFig;
+ } else if (Model.getFacade().isAGeneralization(edge)) {
+ newEdge = new FigGeneralization(edge, settings);
+ } else if (Model.getFacade().isAPackageImport(edge)) {
+ newEdge = new FigPermission(edge, settings);
+ } else if (Model.getFacade().isAUsage(edge)) {
+ newEdge = new FigUsage(edge, settings);
+ } else if (Model.getFacade().isAAbstraction(edge)) {
+ newEdge = new FigAbstraction(edge, settings);
+ } else if (Model.getFacade().isADependency(edge)) {
+
+ String name = "";
+ for (Object stereotype : Model.getFacade().getStereotypes(edge)) {
+ name = Model.getFacade().getName(stereotype);
+ if (CoreFactory.REALIZE_STEREOTYPE.equals(name)) {
+ break;
+ }
+ }
+ if (CoreFactory.REALIZE_STEREOTYPE.equals(name)) {
+ // TODO: This code doesn't look like it will get reached because
+ // any abstraction/realization is going to take the
+ // isAAbstraction leg of the if before it gets to this more
+ // general case. - tfm 20080508
+ FigAbstraction realFig = new FigAbstraction(edge, settings);
+
+ Object supplier =
+ ((Model.getFacade().getSuppliers(edge).toArray())[0]);
+ Object client =
+ ((Model.getFacade().getClients(edge).toArray())[0]);
+
+ FigNode supFN = (FigNode) lay.presentationFor(supplier);
+ FigNode cliFN = (FigNode) lay.presentationFor(client);
+
+ realFig.setSourcePortFig(cliFN);
+ realFig.setSourceFigNode(cliFN);
+ realFig.setDestPortFig(supFN);
+ realFig.setDestFigNode(supFN);
+ realFig.getFig().setLayer(lay);
+ newEdge = realFig;
+ } else {
+ FigDependency depFig = new FigDependency(edge, settings);
+ newEdge = depFig;
+ }
+ } else if (edge instanceof CommentEdge) {
+ newEdge = new FigEdgeNote(edge, settings);
+ }
+
+ if (newEdge == null) {
+ throw new IllegalArgumentException(
+ "Don't know how to create FigEdge for model type "
+ + edge.getClass().getName());
+ }
+
+ setPorts(lay, newEdge);
+
+ assert newEdge != null : "There has been no FigEdge created";
+
+// newEdge.setDiElement(
+// GraphChangeAdapter.getInstance().createElement(gm, edge));
+
+ assert newEdge != null : "There has been no FigEdge created";
+ assert (newEdge.getDestFigNode() != null)
+ : "The FigEdge has no dest node";
+ assert (newEdge.getDestPortFig() != null)
+ : "The FigEdge has no dest port";
+ assert (newEdge.getSourceFigNode() != null)
+ : "The FigEdge has no source node";
+ assert (newEdge.getSourcePortFig() != null)
+ : "The FigEdge has no source port";
+
+ lay.add(newEdge);
+ return newEdge;
+ }
+
+}
Added: trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/FigClass.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/FigClass.java?view=markup&pathrev=17206
==============================================================================
--- (empty file)
+++ trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/FigClass.java 2009-08-01 10:33:47-0700
@@ -0,0 +1,224 @@
+// $Id: FigClass.java 17045 2009-04-05 16:52:52Z mvw $
+// Copyright (c) 1996-2009 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.class2.diagram;
+
+import java.awt.Rectangle;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.argouml.model.Model;
+import org.argouml.uml.diagram.DiagramSettings;
+import org.argouml.uml.diagram.static_structure.ui.FigClassifierBoxWithAttributes;
+import org.tigris.gef.base.Selection;
+import org.tigris.gef.presentation.Fig;
+import org.tigris.gef.presentation.FigGroup;
+import org.tigris.gef.presentation.FigText;
+
+/**
+ * Class to display graphics for a UML Class in a diagram.<p>
+ *
+ * A Class may show compartments for stereotypes,
+ * attributes and operations.
+ */
+public class FigClass extends FigClassifierBoxWithAttributes {
+
+ private void constructFigs() {
+ addFig(getBigPort());
+ addFig(getStereotypeFig());
+ addFig(getNameFig());
+ addFig(getOperationsFig());
+ addFig(getAttributesFig());
+ addFig(borderFig);
+ }
+
+ /**
+ * Constructor for a {@link FigClass} during file load.<p>
+ *
+ * Parent {@link org.argouml.uml.diagram.ui.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>
+ *
+ * <em>Warning</em>. Much of the graphics positioning is hard
+ * coded. The overall figure is placed at location (10,10).
+ * 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>
+ *
+ * @param element model element to be represented by this fig.
+ * @param bounds rectangle describing bounds
+ * @param settings rendering settings
+ */
+ public FigClass(Object element, Rectangle bounds,
+ DiagramSettings settings) {
+ super(element, bounds, settings);
+ constructFigs();
+ Rectangle r = getBounds();
+ setStandardBounds(r.x, r.y, r.width, r.height);
+ }
+
+ /*
+ * @see java.lang.Object#clone()
+ */
+ @Override
+ public Object clone() {
+ FigClass figClone = (FigClass) super.clone();
+ Iterator thisIter = this.getFigs().iterator();
+ Iterator cloneIter = figClone.getFigs().iterator();
+ while (thisIter.hasNext()) {
+ Fig thisFig = (Fig) thisIter.next();
+ Fig cloneFig = (Fig) cloneIter.next();
+ if (thisFig == borderFig) {
+ figClone.borderFig = thisFig;
+ }
+ }
+ return figClone;
+ }
+
+ /*
+ * @see org.tigris.gef.presentation.Fig#makeSelection()
+ */
+ public Selection makeSelection() {
+ return new SelectionClass(this);
+ }
+
+ protected Object buildModifierPopUp() {
+ return buildModifierPopUp(ABSTRACT | LEAF | ROOT | ACTIVE);
+ }
+
+ /*
+ * @see org.tigris.gef.presentation.Fig#getLineWidth()
+ */
+ public int getLineWidth() {
+ return borderFig.getLineWidth();
+ }
+
+ /**
+ * @param fgVec the FigGroup
+ * @param ft the Figtext
+ * @param i get the fig before fig i
+ * @return the FigText
+ */
+ protected FigText getPreviousVisibleFeature(FigGroup fgVec,
+ FigText ft, int i) {
+ if (fgVec == null || i < 1) {
+ return null;
+ }
+ FigText ft2 = null;
+ List figs = fgVec.getFigs();
+ if (i >= figs.size() || !((FigText) figs.get(i)).isVisible()) {
+ return null;
+ }
+ do {
+ i--;
+ while (i < 1) {
+ if (fgVec == getAttributesFig()) {
+ fgVec = getOperationsFig();
+ } else {
+ fgVec = getAttributesFig();
+ }
+ figs = fgVec.getFigs();
+ i = figs.size() - 1;
+ }
+ ft2 = (FigText) figs.get(i);
+ if (!ft2.isVisible()) {
+ ft2 = null;
+ }
+ } while (ft2 == null);
+ return ft2;
+ }
+
+ /**
+ * @param fgVec the FigGroup
+ * @param ft the Figtext
+ * @param i get the fig after fig i
+ * @return the FigText
+ */
+ protected FigText getNextVisibleFeature(FigGroup fgVec, FigText ft, int i) {
+ if (fgVec == null || i < 1) {
+ return null;
+ }
+ FigText ft2 = null;
+ List v = fgVec.getFigs();
+ if (i >= v.size() || !((FigText) v.get(i)).isVisible()) {
+ return null;
+ }
+ do {
+ i++;
+ while (i >= v.size()) {
+ if (fgVec == getAttributesFig()) {
+ fgVec = getOperationsFig();
+ } else {
+ fgVec = getAttributesFig();
+ }
+ v = new ArrayList(fgVec.getFigs());
+ i = 1;
+ }
+ ft2 = (FigText) v.get(i);
+ if (!ft2.isVisible()) {
+ ft2 = null;
+ }
+ } while (ft2 == null);
+ return ft2;
+ }
+
+ public void setEnclosingFig(Fig encloser) {
+ if (encloser == getEncloser()) {
+ return;
+ }
+ if (encloser == null
+ || (encloser != null
+ && !Model.getFacade().isAInstance(encloser.getOwner()))) {
+ super.setEnclosingFig(encloser);
+ }
+ if (!(Model.getFacade().isAUMLElement(getOwner()))) {
+ return;
+ }
+ if (encloser != null
+ && (Model.getFacade().isAComponent(encloser.getOwner()))) {
+ moveIntoComponent(encloser);
+ super.setEnclosingFig(encloser);
+ }
+
+ }
+
+ /*
+ * @see org.argouml.uml.diagram.ui.FigNodeModelElement#updateNameText()
+ */
+ @Override
+ protected void updateNameText() {
+ super.updateNameText();
+ calcBounds();
+ setBounds(getBounds());
+ }
+
+}
Added: trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/FigComment.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/FigComment.java?view=markup&pathrev=17206
==============================================================================
--- (empty file)
+++ trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/FigComment.java 2009-08-01 10:33:47-0700
@@ -0,0 +1,739 @@
+// $Id: FigComment.java 17107 2009-04-13 18:28:43Z tfmorris $
+// Copyright (c) 1996-2009 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.class2.diagram;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Point;
+import java.awt.Polygon;
+import java.awt.Rectangle;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.beans.VetoableChangeListener;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+import javax.swing.SwingUtilities;
+
+import org.apache.log4j.Logger;
+import org.argouml.kernel.DelayedChangeNotify;
+import org.argouml.kernel.DelayedVChangeListener;
+import org.argouml.model.AttributeChangeEvent;
+import org.argouml.model.Model;
+import org.argouml.model.RemoveAssociationEvent;
+import org.argouml.model.UmlChangeEvent;
+import org.argouml.ui.ArgoJMenu;
+import org.argouml.uml.diagram.DiagramSettings;
+import org.argouml.uml.diagram.static_structure.ui.SelectionComment;
+import org.argouml.uml.diagram.ui.FigMultiLineText;
+import org.argouml.uml.diagram.ui.FigNodeModelElement;
+import org.tigris.gef.base.Geometry;
+import org.tigris.gef.base.Selection;
+import org.tigris.gef.presentation.Fig;
+import org.tigris.gef.presentation.FigPoly;
+import org.tigris.gef.presentation.FigRect;
+import org.tigris.gef.presentation.FigText;
+
+/**
+ * Class to display a UML comment in a diagram.
+ *
+ * @author Andreas Rueckert
+ */
+public class FigComment
+ extends FigNodeModelElement
+ implements VetoableChangeListener,
+ DelayedVChangeListener,
+ MouseListener,
+ KeyListener,
+ PropertyChangeListener {
+ /**
+ * Logger.
+ */
+ private static final Logger LOG = Logger.getLogger(FigComment.class);
+
+ ////////////////////////////////////////////////////////////////
+ // constants
+
+ private int width = 80;
+ private int height = 60;
+
+ /**
+ * A dog-ear is a bent corner in a book.
+ */
+ private int dogear = 10;
+
+ private boolean readyToEdit = true;
+
+ // The figure that holds the text of the note.
+ private FigText bodyTextFig;
+
+ private FigPoly outlineFig;
+
+ /**
+ * The upper right corner.
+ */
+ private FigPoly urCorner;
+
+ /**
+ * Flag to indicate that we have just been created. This is to fix the
+ * problem with loading comments that have stereotypes already
+ * defined.<p>
+ */
+ private boolean newlyCreated;
+
+ 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;
+ }
+
+ /**
+ * Construct a comment figure with the given model element, bounds, and
+ * settings. This constructor is used by the PGML parser.
+ *
+ * @param owner owning Comments
+ * @param bounds position and size
+ * @param settings rendering settings
+ */
+ public FigComment(Object owner, Rectangle bounds,
+ DiagramSettings settings) {
+ super(owner, bounds, settings);
+
+ bodyTextFig = new FigMultiLineText(getOwner(),
+ new Rectangle(2, 2, width - 2 - dogear, height - 4),
+ getSettings(), true);
+
+ initialize();
+ updateBody();
+ if (bounds != null) {
+ setLocation(bounds.x, bounds.y);
+ }
+ }
+
+ /**
+ * Get the default text for this figure.
+ *
+ * @return The default text for this figure.
+ */
+ @Override
+ public String placeString() {
+ String placeString = retrieveBody();
+ if (placeString == null) {
+ // TODO: I18N
+ placeString = "new note";
+ }
+ return placeString;
+ }
+
+ /**
+ * Clone this figure.
+ *
+ * @return The cloned figure.
+ */
+ @Override
+ public Object clone() {
+ FigComment figClone = (FigComment) super.clone();
+ Iterator thisIter = this.getFigs().iterator();
+ while (thisIter.hasNext()) {
+ Object thisFig = thisIter.next();
+ if (thisFig == outlineFig) {
+ figClone.outlineFig = (FigPoly) thisFig;
+ }
+ if (thisFig == urCorner) {
+ figClone.urCorner = (FigPoly) thisFig;
+ }
+ if (thisFig == bodyTextFig) {
+ figClone.bodyTextFig = (FigText) thisFig;
+ }
+ }
+ return figClone;
+ }
+
+ private void updateBody() {
+ if (getOwner() != null) {
+ String body = (String) Model.getFacade().getBody(getOwner());
+ if (body != null) {
+ bodyTextFig.setText(body);
+ }
+ }
+ }
+
+
+ /**
+ * See FigNodeModelElement.java for more info on these methods.
+ */
+
+ /**
+ * If the user double clicks on any part of this FigNode, pass it
+ * down to one of the internal Figs. This allows the user to
+ * initiate direct text editing.
+ *
+ * {@inheritDoc}
+ */
+ @Override
+ public void mouseClicked(MouseEvent me) {
+ if (!readyToEdit) {
+ Object owner = getOwner();
+ if (Model.getFacade().isAModelElement(owner)
+ && !Model.getModelManagementHelper().isReadOnly(owner)) {
+ readyToEdit = true;
+ } else {
+ LOG.debug("not ready to edit note");
+ return;
+ }
+ }
+ if (me.isConsumed()) {
+ return;
+ }
+ if (me.getClickCount() >= 2
+ && !(me.isPopupTrigger()
+ || me.getModifiers() == InputEvent.BUTTON3_MASK)) {
+ if (getOwner() == null) {
+ return;
+ }
+ Fig f = hitFig(new Rectangle(me.getX() - 2, me.getY() - 2, 4, 4));
+ if (f instanceof MouseListener) {
+ ((MouseListener) f).mouseClicked(me);
+ }
+ }
+ me.consume();
+ }
+
+ /*
+ * @see java.beans.VetoableChangeListener#vetoableChange(java.beans.PropertyChangeEvent)
+ */
+ @Override
+ public void vetoableChange(PropertyChangeEvent pce) {
+ Object src = pce.getSource();
+ if (src == getOwner()) {
+ DelayedChangeNotify delayedNotify =
+ new DelayedChangeNotify(this, pce);
+ SwingUtilities.invokeLater(delayedNotify);
+ } else {
+ LOG.debug("FigNodeModelElement got vetoableChange"
+ + " from non-owner:" + src);
+ }
+ }
+
+ /*
+ * @see org.argouml.kernel.DelayedVChangeListener#delayedVetoableChange(java.beans.PropertyChangeEvent)
+ */
+ @Override
+ public void delayedVetoableChange(PropertyChangeEvent pce) {
+ // update any text, colors, fonts, etc.
+ renderingChanged();
+ // update the relative sizes and positions of internel Figs
+ endTrans();
+ }
+
+ /*
+ * @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);
+ }
+ }
+
+ /*
+ * @see java.awt.event.KeyListener#keyPressed(java.awt.event.KeyEvent)
+ */
+ @Override
+ public void keyPressed(KeyEvent ke) {
+ // Not used, do nothing.
+ }
+
+ /*
+ * @see java.awt.event.KeyListener#keyReleased(java.awt.event.KeyEvent)
+ */
+ @Override
+ public void keyReleased(KeyEvent ke) {
+ // Not used, do nothing.
+ }
+
+ /*
+ * @see java.awt.event.KeyListener#keyTyped(java.awt.event.KeyEvent)
+ */
+ @Override
+ public void keyTyped(KeyEvent ke) {
+ if (Character.isISOControl(ke.getKeyChar())) {
+ return;
+ }
+ if (!readyToEdit) {
+ Object owner = getOwner();
+ if (Model.getFacade().isAModelElement(owner)
+ && !Model.getModelManagementHelper().isReadOnly(owner)) {
+ storeBody("");
+ readyToEdit = true;
+ } else {
+ LOG.debug("not ready to edit note");
+ return;
+ }
+ }
+ if (ke.isConsumed()) {
+ return;
+ }
+ if (getOwner() == null) {
+ return;
+ }
+ bodyTextFig.keyTyped(ke);
+ }
+
+ ////////////////////////////////////////////////////////////////
+ // Fig accessors
+
+ /**
+ * @return an empty menu
+ * @see org.argouml.uml.diagram.ui.FigNodeModelElement#buildShowPopUp()
+ */
+ @Override
+ protected ArgoJMenu buildShowPopUp() {
+ return new ArgoJMenu("menu.popup.show");
+ }
+
+ /*
+ * @see org.tigris.gef.presentation.Fig#makeSelection()
+ */
+ @Override
+ public Selection makeSelection() {
+ return new SelectionComment(this);
+ }
+
+ /*
+ * @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);
+ }
+
+ /*
+ * @see org.tigris.gef.presentation.Fig#getLineColor()
+ */
+ @Override
+ public Color getLineColor() {
+ return outlineFig.getLineColor();
+ }
+
+ /*
+ * @see org.tigris.gef.presentation.Fig#setFillColor(java.awt.Color)
+ */
+ @Override
+ public void setFillColor(Color col) {
+ outlineFig.setFillColor(col);
+ urCorner.setFillColor(col);
+ }
+
+ /*
+ * @see org.tigris.gef.presentation.Fig#getFillColor()
+ */
+ @Override
+ public Color getFillColor() {
+ return outlineFig.getFillColor();
+ }
+
+ /*
+ * @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);
+ }
+
+ @Override
+ public boolean isFilled() {
+ return outlineFig.isFilled();
+ }
+
+ /*
+ * @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);
+ }
+
+ /*
+ * @see org.tigris.gef.presentation.Fig#getLineWidth()
+ */
+ @Override
+ public int getLineWidth() {
+ return outlineFig.getLineWidth();
+ }
+
+ ////////////////////////////////////////////////////////////////
+ // user interaction methods
+
+ /*
+ * @see org.argouml.uml.diagram.ui.FigNodeModelElement#textEdited(org.tigris.gef.presentation.FigText)
+ */
+ @Override
+ protected void textEdited(FigText ft) {
+ if (ft == bodyTextFig) {
+ storeBody(ft.getText());
+ }
+ }
+
+ /*
+ * @see org.argouml.uml.diagram.ui.FigNodeModelElement#textEditStarted(org.tigris.gef.presentation.FigText)
+ */
+ @Override
+ protected void textEditStarted(FigText ft) {
+ showHelp("parsing.help.comment");
+ }
+
+ /*
+ * @see org.tigris.gef.presentation.Fig#setEnclosingFig(org.tigris.gef.presentation.Fig)
+ */
+ @Override
+ public void setEnclosingFig(Fig encloser) {
+ super.setEnclosingFig(encloser);
+ }
+
+ ////////////////////////////////////////////////////////////////
+ // accessor methods
+
+ /**
+ * Stores the body text in the associated model element.
+ *
+ * @param body The body text to store.
+ */
+ public final void storeBody(String body) {
+ if (getOwner() != null) {
+ Model.getCoreHelper().setBody(getOwner(), body);
+ }
+ }
+
+ /**
+ * Retrieve the body text from the associated model element.
+ *
+ * @return The body from the associated model element.
+ */
+ private String retrieveBody() {
+ return (getOwner() != null)
+ ? (String) Model.getFacade().getBody(getOwner())
+ : null;
+ }
+
+ /*
+ * @see org.tigris.gef.presentation.Fig#getUseTrapRect()
+ */
+ @Override
+ public boolean getUseTrapRect() {
+ return true;
+ }
+
+ /**
+ * Always returns null as the FigComment does not display its name.
+ * @return null
+ */
+ @Override
+ public Rectangle getNameBounds() {
+ return null;
+ }
+
+ /**
+ * Get the minimum size for the note figure.
+ *
+ * @return The minimum size for the note figure.
+ */
+ @Override
+ public Dimension getMinimumSize() {
+
+ // Get the size of the text field.
+ Dimension aSize = bodyTextFig.getMinimumSize();
+
+ // If we have a stereotype displayed, then allow some space for that
+ // (width and height)
+
+ if (getStereotypeFig().isVisible()) {
+ Dimension stereoMin = getStereotypeFig().getMinimumSize();
+ aSize.width =
+ Math.max(aSize.width,
+ stereoMin.width);
+ aSize.height += stereoMin.height;
+ }
+
+ // And add the gaps around the textfield to get the minimum
+ // size of the note.
+ return new Dimension(aSize.width + 4 + dogear,
+ aSize.height + 4);
+ }
+
+ /*
+ * @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());
+ }
+
+ /*
+ * @see org.argouml.uml.diagram.ui.FigNodeModelElement#updateBounds()
+ */
+ @Override
+ protected void updateBounds() {
+ 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);
+ }
+
+ ///////////////////////////////////////////////////////////////////
+ // Internal methods
+
+ @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();
+ }
+ }
+ }
+
+ /*
+ * @see org.argouml.uml.diagram.ui.FigNodeModelElement#updateStereotypeText()
+ */
+ @Override
+ protected void updateStereotypeText() {
+ Object me = getOwner();
+
+ if (me == null) {
+ return;
+ }
+
+ Rectangle rect = getBounds();
+
+ Dimension stereoMin = getStereotypeFig().getMinimumSize();
+
+ if (Model.getFacade().getStereotypes(me).isEmpty()) {
+
+ if (getStereotypeFig().isVisible()) {
+ getStereotypeFig().setVisible(false);
+ rect.y += stereoMin.height;
+ rect.height -= stereoMin.height;
+ setBounds(rect.x, rect.y, rect.width, rect.height);
+ calcBounds();
+ }
+ } else {
+ if (!getStereotypeFig().isVisible()) {
+ getStereotypeFig().setVisible(true);
+
+ // Only adjust the stereotype height if we are not newly
+ // created. This gets round the problem of loading classes with
+ // stereotypes defined, which have the height already including
+ // the stereotype.
+
+ if (!newlyCreated) {
+ rect.y -= stereoMin.height;
+ rect.height += stereoMin.height;
+ rect.width =
+ Math.max(getMinimumSize().width, rect.width);
+ setBounds(rect.x, rect.y, rect.width, rect.height);
+ calcBounds();
+ }
+ }
+ }
+ // Whatever happened we are no longer newly created, so clear the
+ // flag. Then set the bounds for the rectangle we have defined.
+ newlyCreated = false;
+ }
+
+ /**
+ * Get the text body of the comment.
+ * @return the body of the comment
+ */
+ public String getBody() {
+ return bodyTextFig.getText();
+ }
+
+ /*
+ * @see org.tigris.gef.presentation.Fig#getClosestPoint(java.awt.Point)
+ */
+ @Override
+ public Point getClosestPoint(Point anotherPt) {
+ Rectangle r = getBounds();
+ int[] xs = {
+ r.x, r.x + r.width - dogear, r.x + r.width,
+ r.x + r.width, r.x, r.x,
+ };
+ int[] ys = {
+ r.y, r.y, r.y + dogear,
+ r.y + r.height, r.y + r.height, r.y,
+ };
+ Point p =
+ Geometry.ptClosestTo(
+ xs,
+ ys,
+ 6,
+ anotherPt);
+ return p;
+ }
+
+ /**
+ * The UID.
+ */
+ private static final long serialVersionUID = 7242542877839921267L;
+}
Added: trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/FigDataType.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/FigDataType.java?view=markup&pathrev=17206
==============================================================================
--- (empty file)
+++ trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/FigDataType.java 2009-08-01 10:33:47-0700
@@ -0,0 +1,282 @@
+// $Id: FigDataType.java 17045 2009-04-05 16:52:52Z mvw $
+// Copyright (c) 1996-2009 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.class2.diagram;
+
+import java.awt.Dimension;
+import java.awt.Rectangle;
+
+import org.apache.log4j.Logger;
+import org.argouml.model.Model;
+import org.argouml.ui.targetmanager.TargetManager;
+import org.argouml.uml.diagram.ArgoDiagram;
+import org.argouml.uml.diagram.DiagramSettings;
+import org.argouml.uml.diagram.static_structure.ui.FigClassifierBox;
+import org.tigris.gef.base.Selection;
+import org.tigris.gef.presentation.Fig;
+
+/**
+ * Class to display graphics for a UML DataType in a diagram.
+ * (cloned from FigInterface - perhaps they should both specialize
+ * a common supertype).
+ * <p>
+ * A DataType may show compartments for stereotypes
+ * and operations. Attributes are not supported in ArgoUML. <p>
+ *
+ * Every DataType shows a keyword, but it is not
+ * always <<datatype>>, e.g. for an Enumeration.
+ */
+public class FigDataType extends FigClassifierBox {
+
+ private static final Logger LOG = Logger.getLogger(FigDataType.class);
+
+ private static final int MIN_WIDTH = 40;
+
+ private void constructFigs() {
+ getStereotypeFig().setKeyword(getKeyword());
+
+ setSuppressCalcBounds(true);
+ addFig(getBigPort());
+ addFig(getStereotypeFig());
+ addFig(getNameFig());
+ addFig(getOperationsFig());
+ addFig(borderFig);
+
+ setSuppressCalcBounds(false);
+
+ // Set the bounds of the figure to the total of the above
+ enableSizeChecking(true);
+ super.setStandardBounds(X0, Y0, WIDTH, NAME_FIG_HEIGHT + ROWHEIGHT);
+ }
+
+ /**
+ * Primary constructor for a {@link FigDataType}.
+ *
+ * Parent {@link org.argouml.uml.diagram.ui.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 operations.<p>
+ *
+ * The properties of all these graphic elements are adjusted
+ * appropriately. The main boxes are all filled and have outlines.<p>
+ *
+ * <em>Warning</em>. Much of the graphics positioning is hard coded. The
+ * overall figure is placed at location (10,10).
+ * 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 operations box is created at 19 pixels,
+ * 2 more than {@link #ROWHEIGHT}.
+ *
+ * @param owner owning UML element
+ * @param bounds position and size
+ * @param settings render settings
+ */
+ public FigDataType(Object owner, Rectangle bounds,
+ DiagramSettings settings) {
+ super(owner, bounds, settings);
+ constructFigs();
+ }
+
+ /**
+ * This function shall return the keyword to be used by the constructor. <p>
+ *
+ * Subclasses of DataType shall
+ * override this method to set their own keyword.
+ *
+ * @return the string to be used as the keyword
+ */
+ protected String getKeyword() {
+ return "datatype";
+ }
+
+ /*
+ * @see org.tigris.gef.presentation.Fig#makeSelection()
+ */
+ @Override
+ public Selection makeSelection() {
+ return new SelectionDataType(this);
+ }
+
+ /**
+ * Gets the minimum size permitted for a datatype on the diagram.<p>
+ *
+ * Parts of this are hardcoded with magic numbers.<p>
+ *
+ * @return the size of the minimum bounding box.
+ */
+ @Override
+ public Dimension getMinimumSize() {
+ // Use "aSize" to build up the minimum size. Start with the size of the
+ // name compartment and build up.
+
+ Dimension aSize = getNameFig().getMinimumSize();
+
+ aSize.height += NAME_V_PADDING * 2;
+ aSize.height = Math.max(NAME_FIG_HEIGHT, aSize.height);
+
+ // If we have a stereotype displayed, then allow some space for that
+ // (width and height)
+ aSize = addChildDimensions(aSize, getStereotypeFig());
+ aSize = addChildDimensions(aSize, getOperationsFig());
+
+ // we want to maintain a minimum width for datatypes
+ aSize.width = Math.max(MIN_WIDTH, aSize.width);
+
+ return aSize;
+ }
+
+ /*
+ * @see org.tigris.gef.presentation.Fig#getLineWidth()
+ */
+ @Override
+ public int getLineWidth() {
+ return borderFig.getLineWidth();
+ }
+
+ /*
+ * @see org.tigris.gef.presentation.Fig#setEnclosingFig(org.tigris.gef.presentation.Fig)
+ */
+ @Override
+ public void setEnclosingFig(Fig encloser) {
+ Fig oldEncloser = getEnclosingFig();
+
+ if (encloser == null
+ || (encloser != null
+ && !Model.getFacade().isAInstance(encloser.getOwner()))) {
+ super.setEnclosingFig(encloser);
+ }
+ if (!(Model.getFacade().isAUMLElement(getOwner()))) {
+ return;
+ }
+ /* If this fig is not visible, do not adapt the UML model!
+ * This is used for deleting. See issue 3042.
+ */
+ if (!isVisible()) {
+ return;
+ }
+ Object me = getOwner();
+ Object m = null;
+
+ try {
+ // If moved into an Package
+ if (encloser != null
+ && oldEncloser != encloser
+ && Model.getFacade().isAPackage(encloser.getOwner())) {
+ Model.getCoreHelper().setNamespace(me, encloser.getOwner());
+ }
+
+ // If default Namespace is not already set
+ if (Model.getFacade().getNamespace(me) == null
+ && (TargetManager.getInstance().getTarget()
+ instanceof ArgoDiagram)) {
+ m =
+ ((ArgoDiagram) TargetManager.getInstance().getTarget())
+ .getNamespace();
+ Model.getCoreHelper().setNamespace(me, m);
+ }
+ } catch (Exception e) {
+ LOG.error("could not set package due to:" + e
+ + "' at " + encloser, e);
+ }
+
+ }
+
+ /**
+ * USED BY PGML.tee.
+ * @return the class name and bounds together with compartment
+ * visibility.
+ */
+ @Override
+ public String classNameAndBounds() {
+ return super.classNameAndBounds()
+ + "operationsVisible=" + isOperationsVisible();
+ }
+
+
+ /**
+ * Sets the bounds, but the size will be at least the one returned by
+ * {@link #getMinimumSize()}, unless checking of size is disabled.<p>
+ *
+ * If the required height is bigger, then the additional height is
+ * equally distributed among all figs (i.e. compartments), such that the
+ * accumulated height of all visible figs equals the demanded height<p>.
+ *
+ * @param x Desired X coordinate of upper left corner
+ *
+ * @param y Desired Y coordinate of upper left corner
+ *
+ * @param w Desired width of the figure
+ *
+ * @param h Desired height of the figure
+ * @see org.tigris.gef.presentation.Fig#setBoundsImpl(int, int, int, int)
+ */
+ @Override
+ protected void setStandardBounds(final int x, final int y, final int w,
+ final int h) {
+
+ // Save our old boundaries to use in our property message later
+ Rectangle oldBounds = getBounds();
+ // and get minimum size info.
+
+ // set bounds of big box
+ getBigPort().setBounds(x, y, w, h);
+ borderFig.setBounds(x, y, w, h);
+
+ int currentHeight = 0;
+
+ if (getStereotypeFig().isVisible()) {
+ int stereotypeHeight = getStereotypeFig().getMinimumSize().height;
+ getStereotypeFig().setBounds(
+ x,
+ y,
+ w,
+ stereotypeHeight);
+ currentHeight = stereotypeHeight;
+ }
+
+ int nameHeight = getNameFig().getMinimumSize().height;
+ getNameFig().setBounds(x, y + currentHeight, w, nameHeight);
+ currentHeight += nameHeight;
+
+ if (getOperationsFig().isVisible()) {
+ int operationsY = y + currentHeight;
+ int operationsHeight = (h + y) - operationsY - LINE_WIDTH;
+ getOperationsFig().setBounds(
+ x,
+ operationsY,
+ w,
+ operationsHeight);
+ }
+
+ // Now force calculation of the bounds of the figure, update the edges
+ // and trigger anyone who's listening to see if the "bounds" property
+ // has changed.
+
+ calcBounds();
+ updateEdges();
+ firePropChange("bounds", oldBounds, getBounds());
+ }
+
+}
Added: trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/FigEdgeNote.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/FigEdgeNote.java?view=markup&pathrev=17206
==============================================================================
--- (empty file)
+++ trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/FigEdgeNote.java 2009-08-01 10:33:47-0700
@@ -0,0 +1,308 @@
+// $Id: FigEdgeNote.java 17116 2009-04-14 06:28:43Z tfmorris $
+// Copyright (c) 1996-2007 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.class2.diagram;
+
+import java.awt.event.MouseEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import org.apache.log4j.Logger;
+import org.argouml.i18n.Translator;
+import org.argouml.kernel.Project;
+import org.argouml.model.Model;
+import org.argouml.model.RemoveAssociationEvent;
+import org.argouml.uml.CommentEdge;
+import org.argouml.uml.diagram.DiagramSettings;
+import org.argouml.uml.diagram.ui.ArgoFig;
+import org.argouml.uml.diagram.ui.ArgoFigUtil;
+import org.argouml.util.IItemUID;
+import org.argouml.util.ItemUID;
+import org.tigris.gef.presentation.Fig;
+import org.tigris.gef.presentation.FigEdgePoly;
+import org.tigris.gef.presentation.FigNode;
+
+/**
+ * Class to display a UML note connection to a annotated model element.
+ * <p>
+ *
+ * The owner of this fig is always a CommentEdge. Because it is different from
+ * most every other FigEdge in ArgoUML, it doesn't subclass FigEdgeModelElement.
+ *
+ * @author Andreas Rueckert [email protected]
+ * @author [email protected]
+ */
+public class FigEdgeNote extends FigEdgePoly implements ArgoFig, IItemUID,
+ PropertyChangeListener {
+
+ private static final Logger LOG = Logger.getLogger(FigEdgeNote.class);
+
+ private Object comment;
+ private Object annotatedElement;
+
+ private DiagramSettings settings;
+
+ private ItemUID itemUid;
+
+ /**
+ * @param element owning CommentEdge object. This is a special case since it
+ * is not a UML element.
+ * @param theSettings render settings
+ */
+ public FigEdgeNote(Object element, DiagramSettings theSettings) {
+ // element will normally be null when called from PGML parser
+ // It will get it's source & destination set later in attachEdges
+ super();
+ settings = theSettings;
+
+ if (element != null) {
+ super.setOwner(element);
+ } else {
+ super.setOwner(new CommentEdge());
+ }
+
+ setBetweenNearestPoints(true);
+ getFig().setLineWidth(LINE_WIDTH);
+ getFig().setDashed(true);
+
+ // Unfortunately the Fig and it's associated CommentEdge will not be
+ // fully initialized yet here if we're being loaded from a PGML file.
+ // The remainder of the initialization will happen when
+ // set{Dest|Source}FigNode are called from PGMLStackParser.attachEdges()
+ }
+
+ /*
+ * @see org.tigris.gef.presentation.FigEdge#setFig(org.tigris.gef.presentation.Fig)
+ */
+ @Override
+ public void setFig(Fig f) {
+ LOG.info("Setting the internal fig to " + f);
+ super.setFig(f);
+ getFig().setDashed(true);
+ }
+
+
+ /*
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return Translator.localize("misc.comment-edge");
+ }
+
+ /*
+ * Listen for a RemoveAssociationEvent between the comment
+ * and the annotated element. When recieved delete the CommentEdge
+ * and this FigEdgeNote.
+ * @see org.argouml.uml.diagram.ui.FigEdgeModelElement#modelChanged(java.beans.PropertyChangeEvent)
+ */
+ protected void modelChanged(PropertyChangeEvent e) {
+ if (e instanceof RemoveAssociationEvent
+ && e.getOldValue() == annotatedElement) {
+ removeFromDiagram();
+ }
+ }
+
+ /*
+ * @see org.tigris.gef.presentation.Fig#getTipString(java.awt.event.MouseEvent)
+ */
+ @Override
+ public String getTipString(MouseEvent me) {
+ return "Comment Edge"; // TODO: get tip string from comment
+ }
+
+
+ /*
+ * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
+ */
+ @Override
+ public void propertyChange(PropertyChangeEvent pve) {
+ modelChanged(pve);
+ }
+
+
+
+ /*
+ * @see org.tigris.gef.presentation.Fig#removeFromDiagram()
+ */
+ @Override
+ public final void removeFromDiagram() {
+ Object o = getOwner();
+ if (o != null) {
+ removeElementListener(o);
+ }
+
+ super.removeFromDiagram();
+ damage();
+ }
+
+
+ /**
+ * Returns the source of the edge. The source is the owner of the
+ * node the edge travels from in a binary relationship. For
+ * instance: for a classifierrole, this is the sender.
+ * @return MModelElement
+ */
+ protected Object getSource() {
+ Object theOwner = getOwner();
+ if (theOwner != null) {
+ return ((CommentEdge) theOwner).getSource();
+ }
+ return null;
+ }
+ /**
+ * Returns the destination of the edge. The destination is the
+ * owner of the node the edge travels to in a binary
+ * relationship. For instance: for a classifierrole, this is the
+ * receiver.
+ * @return Object
+ */
+ protected Object getDestination() {
+ Object theOwner = getOwner();
+ if (theOwner != null) {
+ return ((CommentEdge) theOwner).getDestination();
+ }
+ return null;
+ }
+
+ /*
+ * @see org.tigris.gef.presentation.FigEdge#setDestFigNode(org.tigris.gef.presentation.FigNode)
+ */
+ @Override
+ public void setDestFigNode(FigNode fn) {
+ // When this is called from PGMLStackParser.attachEdges, we finished
+ // the initialization of owning pseudo element (CommentEdge)
+ if (fn != null && Model.getFacade().isAComment(fn.getOwner())) {
+ Object oldComment = comment;
+ if (oldComment != null) {
+ removeElementListener(oldComment);
+ }
+ comment = fn.getOwner();
+ if (comment != null) {
+ addElementListener(comment);
+ }
+
+ ((CommentEdge) getOwner()).setComment(comment);
+ } else if (fn != null
+ && !Model.getFacade().isAComment(fn.getOwner())) {
+ annotatedElement = fn.getOwner();
+ ((CommentEdge) getOwner()).setAnnotatedElement(annotatedElement);
+ }
+
+ super.setDestFigNode(fn);
+ }
+
+ /*
+ * @see org.tigris.gef.presentation.FigEdge#setSourceFigNode(org.tigris.gef.presentation.FigNode)
+ */
+ @Override
+ public void setSourceFigNode(FigNode fn) {
+ // When this is called from PGMLStackParser.attachEdges, we finished
+ // the initialization of owning pseudo element (CommentEdge)
+ if (fn != null && Model.getFacade().isAComment(fn.getOwner())) {
+ Object oldComment = comment;
+ if (oldComment != null) {
+ removeElementListener(oldComment);
+ }
+ comment = fn.getOwner();
+ if (comment != null) {
+ addElementListener(comment);
+ }
+ ((CommentEdge) getOwner()).setComment(comment);
+ } else if (fn != null
+ && !Model.getFacade().isAComment(fn.getOwner())) {
+ annotatedElement = fn.getOwner();
+ ((CommentEdge) getOwner()).setAnnotatedElement(annotatedElement);
+ }
+ super.setSourceFigNode(fn);
+ }
+
+ private void addElementListener(Object element) {
+ Model.getPump().addModelEventListener(this, element);
+ }
+
+ private void removeElementListener(Object element) {
+ Model.getPump().removeModelEventListener(this, element);
+ }
+
+ @SuppressWarnings("deprecation")
+ @Deprecated
+ public Project getProject() {
+ return ArgoFigUtil.getProject(this);
+ }
+
+ public DiagramSettings getSettings() {
+ return settings;
+ }
+
+ public void renderingChanged() {
+
+ }
+
+ @SuppressWarnings("deprecation")
+ @Deprecated
+ public void setProject(Project project) {
+ // unimplemented
+ }
+
+ public void setSettings(DiagramSettings theSettings) {
+ settings = theSettings;
+ }
+
+ /**
+ * Setter for the UID
+ * @param newId the new UID
+ */
+ public void setItemUID(ItemUID newId) {
+ itemUid = newId;
+ }
+
+ /**
+ * Getter for the UID
+ * @return the UID
+ */
+ public ItemUID getItemUID() {
+ return itemUid;
+ }
+
+
+ /**
+ * Setting the owner of the Fig must be done in the constructor and not
+ * changed afterwards for all ArgoUML figs.
+ *
+ * @param owner owning UML element
+ * @deprecated for 0.27.3 by tfmorris. Set owner in constructor. This method
+ * is implemented in GEF, so we'll leave this implementation
+ * here to block any attempts to use it within ArgoUML.
+ */
+ @SuppressWarnings("deprecation")
+ @Deprecated
+ public void setOwner(Object owner) {
+ if (owner != getOwner()) {
+ throw new UnsupportedOperationException(
+ "Owner must be set in constructor and left unchanged");
+ }
+ }
+
+}
Added: trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/FigEnumeration.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/FigEnumeration.java?view=markup&pathrev=17206
==============================================================================
--- (empty file)
+++ trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/FigEnumeration.java 2009-08-01 10:33:47-0700
@@ -0,0 +1,304 @@
+// $Id: FigEnumeration.java 17045 2009-04-05 16:52:52Z mvw $
+// Copyright (c) 1996-2009 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.class2.diagram;
+
+import java.awt.Dimension;
+import java.awt.Rectangle;
+import java.beans.PropertyChangeEvent;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.swing.Action;
+
+import org.argouml.model.AssociationChangeEvent;
+import org.argouml.model.AttributeChangeEvent;
+import org.argouml.model.Model;
+import org.argouml.ui.ArgoJMenu;
+import org.argouml.uml.diagram.DiagramSettings;
+import org.argouml.uml.diagram.ui.EnumLiteralsCompartmentContainer;
+import org.argouml.uml.diagram.ui.FigEnumLiteralsCompartment;
+import org.argouml.uml.ui.foundation.core.ActionAddEnumerationLiteral;
+import org.tigris.gef.base.Selection;
+
+/**
+ * Class to display graphics for a UML Enumeration in a diagram.
+ * It depends on FigDataType for most of its behavior.<p>
+ *
+ */
+public class FigEnumeration extends FigDataType
+ implements EnumLiteralsCompartmentContainer {
+
+ /**
+ * Serial version (generated)
+ */
+ private static final long serialVersionUID = 3333154292883077250L;
+
+ /**
+ * The Fig that represents the literals compartment.
+ */
+ private FigEnumLiteralsCompartment literalsCompartment;
+
+ /**
+ * Construct a new AbstractFigComponent.
+ *
+ * @param owner owning UML element
+ * @param bounds position and size
+ * @param settings render settings
+ */
+ public FigEnumeration(Object owner, Rectangle bounds,
+ DiagramSettings settings) {
+ super(owner, bounds, settings);
+
+ enableSizeChecking(true);
+ setSuppressCalcBounds(false);
+
+ addFig(getLiteralsCompartment()); // This creates the compartment.
+ setEnumLiteralsVisible(true);
+ literalsCompartment.populate();
+
+ setBounds(getBounds());
+ }
+
+ @Override
+ protected String getKeyword() {
+ return "enumeration";
+ }
+
+ /*
+ * @see org.argouml.uml.diagram.static_structure.ui.FigDataType#makeSelection()
+ */
+ @Override
+ public Selection makeSelection() {
+ return new SelectionEnumeration(this);
+ }
+
+ @Override
+ public Object clone() {
+ FigEnumeration clone = (FigEnumeration) super.clone();
+ clone.literalsCompartment =
+ (FigEnumLiteralsCompartment) literalsCompartment.clone();
+ return clone;
+ }
+
+ /*
+ * @see org.argouml.uml.diagram.static_structure.ui.FigClassifierBox#buildAddMenu()
+ */
+ @Override
+ protected ArgoJMenu buildAddMenu() {
+ ArgoJMenu addMenu = super.buildAddMenu();
+
+ Action addEnumerationLiteral = new ActionAddEnumerationLiteral();
+ addEnumerationLiteral.setEnabled(isSingleTarget());
+ addMenu.add(addEnumerationLiteral);
+ return addMenu;
+ }
+
+ /*
+ * @see org.argouml.uml.diagram.ui.FigNodeModelElement#modelChanged(java.beans.PropertyChangeEvent)
+ */
+ @Override
+ protected void modelChanged(PropertyChangeEvent mee) {
+ super.modelChanged(mee);
+ if (mee instanceof AssociationChangeEvent
+ || mee instanceof AttributeChangeEvent) {
+ renderingChanged();
+ updateListeners(getOwner(), getOwner());
+ }
+ }
+
+ /*
+ * @see org.argouml.uml.diagram.ui.FigNodeModelElement#renderingChanged()
+ */
+ @Override
+ public void renderingChanged() {
+ super.renderingChanged();
+ if (getOwner() != null) {
+ updateEnumLiterals();
+ }
+ }
+
+ /*
+ * @see org.argouml.uml.diagram.ui.FigNodeModelElement#updateListeners(java.lang.Object)
+ */
+ @Override
+ protected void updateListeners(Object oldOwner, Object newOwner) {
+ Set<Object[]> l = new HashSet<Object[]>();
+ if (newOwner != null) {
+ // add the listeners to the newOwner
+ l.add(new Object[] {newOwner, null});
+ // and its stereotypes
+ for (Object stereo : Model.getFacade().getStereotypes(newOwner)) {
+ l.add(new Object[] {stereo, null});
+ }
+ // and its features
+ for (Object feat : Model.getFacade().getFeatures(newOwner)) {
+ l.add(new Object[] {feat, null});
+ // and the stereotypes of its features
+ for (Object stereo : Model.getFacade().getStereotypes(feat)) {
+ l.add(new Object[] {stereo, null});
+ }
+ }
+ // and its enumerationLiterals
+ for (Object literal : Model.getFacade().getEnumerationLiterals(
+ newOwner)) {
+ l.add(new Object[] {literal, null});
+ }
+ }
+ // And now add listeners to them all:
+ updateElementListeners(l);
+
+ }
+
+ /**
+ * Update (i.e. redraw) the compartment with the literals.
+ */
+ protected void updateEnumLiterals() {
+ if (!literalsCompartment.isVisible()) {
+ return;
+ }
+ literalsCompartment.populate();
+
+ // TODO: make setBounds, calcBounds and updateBounds consistent
+ setBounds(getBounds());
+ }
+
+ /*
+ * @see org.argouml.uml.diagram.static_structure.ui.FigDataType#getMinimumSize()
+ */
+ @Override
+ public Dimension getMinimumSize() {
+ // Start with the minimum for our parent
+ Dimension aSize = super.getMinimumSize();
+
+ if (literalsCompartment != null) {
+ aSize = addChildDimensions(aSize, literalsCompartment);
+ }
+
+ return aSize;
+ }
+
+ /*
+ * @see org.tigris.gef.presentation.Fig#setBoundsImpl(int, int, int, int)
+ */
+ @Override
+ protected void setStandardBounds(final int x, final int y, final int width,
+ final int height) {
+
+ // Save our old boundaries so it can be used in property message later
+ Rectangle oldBounds = getBounds();
+
+ int w = Math.max(width, getMinimumSize().width);
+ int h = Math.max(height, getMinimumSize().height);
+
+ // set bounds of big box
+ getBigPort().setBounds(x, y, w, h);
+ borderFig.setBounds(x, y, w, h);
+
+ int currentHeight = 0;
+
+ if (getStereotypeFig().isVisible()) {
+ int stereotypeHeight = getStereotypeFig().getMinimumSize().height;
+ getStereotypeFig().setBounds(
+ x,
+ y,
+ w,
+ stereotypeHeight);
+ currentHeight += stereotypeHeight;
+ }
+
+ int nameHeight = getNameFig().getMinimumSize().height;
+ getNameFig().setBounds(x, y + currentHeight, w, nameHeight);
+ currentHeight += nameHeight;
+
+ int visibleCompartments = getOperationsFig().isVisible() ? 1 : 0;
+ if (getLiteralsCompartment().isVisible()) {
+ visibleCompartments++;
+ int literalsHeight =
+ getLiteralsCompartment().getMinimumSize().height;
+ literalsHeight = Math.max(literalsHeight,
+ (h - currentHeight) / visibleCompartments);
+ getLiteralsCompartment().setBounds(
+ x + LINE_WIDTH,
+ y + currentHeight,
+ w - LINE_WIDTH,
+ literalsHeight);
+ currentHeight += literalsHeight;
+ }
+
+ if (getOperationsFig().isVisible()) {
+ int operationsHeight = getOperationsFig().getMinimumSize().height;
+ operationsHeight = Math.max(operationsHeight, h - currentHeight);
+ getOperationsFig().setBounds(
+ x,
+ y + currentHeight,
+ w,
+ operationsHeight);
+ currentHeight += operationsHeight;
+ }
+
+ // Now force calculation of the bounds of the figure, update the edges
+ // and trigger anyone who's listening to see if the "bounds" property
+ // has changed.
+
+ calcBounds();
+ updateEdges();
+ firePropChange("bounds", oldBounds, getBounds());
+ }
+
+ /**
+ * @return the Fig for the EnumerationLiterals compartment
+ */
+ public FigEnumLiteralsCompartment getLiteralsCompartment() {
+ // Set bounds will be called from our superclass constructor before
+ // our constructor has run, so make sure this gets set up if needed.
+ if (literalsCompartment == null) {
+ literalsCompartment = new FigEnumLiteralsCompartment(getOwner(),
+ DEFAULT_COMPARTMENT_BOUNDS, getSettings());
+ }
+ return literalsCompartment;
+ }
+
+ /**
+ * @return true if the literals compartment is visible
+ */
+ public boolean isEnumLiteralsVisible() {
+ return literalsCompartment.isVisible();
+ }
+
+ /**
+ * @param isVisible true will show the enumeration literal compartment
+ */
+ public void setEnumLiteralsVisible(boolean isVisible) {
+ setCompartmentVisible(literalsCompartment, isVisible);
+ }
+
+ /**
+ * @return the bounds of the EnumerationLiterals compartment
+ */
+ public Rectangle getEnumLiteralsBounds() {
+ return literalsCompartment.getBounds();
+ }
+
+}
Added: trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/FigException.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/FigException.java?view=markup&pathrev=17206
==============================================================================
--- (empty file)
+++ trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/FigException.java 2009-08-01 10:33:47-0700
@@ -0,0 +1,55 @@
+// $Id: FigException.java 17045 2009-04-05 16:52:52Z mvw $
+// Copyright (c) 2007-2009 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.class2.diagram;
+
+import java.awt.Rectangle;
+
+import org.argouml.uml.diagram.DiagramSettings;
+import org.tigris.gef.base.Selection;
+
+/**
+ * Fig representing an Exception.
+ *
+ * @author Tom Morris
+ */
+public class FigException extends FigSignal {
+
+ /**
+ * Construct an Exception fig.
+ *
+ * @param owner owning Exception
+ * @param bounds position and size
+ * @param settings render settings
+ */
+ public FigException(Object owner, Rectangle bounds,
+ DiagramSettings settings) {
+ super(owner, bounds, settings);
+ }
+
+ @Override
+ public Selection makeSelection() {
+ return new SelectionException(this);
+ }
+}
Added: trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/FigInterface.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/FigInterface.java?view=markup&pathrev=17206
==============================================================================
--- (empty file)
+++ trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/FigInterface.java 2009-08-01 10:33:47-0700
@@ -0,0 +1,264 @@
+// $Id: FigInterface.java 17045 2009-04-05 16:52:52Z mvw $
+// Copyright (c) 1996-2009 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.class2.diagram;
+
+import java.awt.Dimension;
+import java.awt.Rectangle;
+
+import org.apache.log4j.Logger;
+import org.argouml.model.Model;
+import org.argouml.ui.targetmanager.TargetManager;
+import org.argouml.uml.diagram.ArgoDiagram;
+import org.argouml.uml.diagram.DiagramSettings;
+import org.argouml.uml.diagram.static_structure.ui.FigClassifierBox;
+import org.tigris.gef.base.Editor;
+import org.tigris.gef.base.Globals;
+import org.tigris.gef.base.Selection;
+import org.tigris.gef.presentation.Fig;
+
+/**
+ * Class to display graphics for a UML Interface in a diagram.
+ * <p>
+ * An Interface may show compartments for stereotypes
+ * and operations. Attributes are not supported in ArgoUML.
+ */
+public class FigInterface extends FigClassifierBox {
+
+ private static final Logger LOG = Logger.getLogger(FigInterface.class);
+
+ /**
+ * Initialization common to multiple constructors. This can be merged back
+ * into the last constructor when the deprecated ones have been removed.
+ */
+ private void initialize() {
+ getStereotypeFig().setKeyword("interface");
+
+ // Put all the bits together, suppressing bounds calculations until
+ // we're all done for efficiency.
+ enableSizeChecking(false);
+ setSuppressCalcBounds(true);
+
+ Dimension size = new Dimension(0, 0);
+
+ addFig(getBigPort());
+ addFig(getStereotypeFig());
+ addChildDimensions(size, getStereotypeFig());
+ addFig(getNameFig());
+ addChildDimensions(size, getNameFig());
+ addFig(getOperationsFig());
+ addChildDimensions(size, getOperationsFig());
+ addFig(borderFig);
+
+ setSuppressCalcBounds(false);
+
+ // Set the bounds of the figure to the total of the above
+ enableSizeChecking(true);
+ setBounds(X0, Y0, size.width, size.height);
+ }
+
+ /**
+ * Construct an Interface fig
+ *
+ * @param owner owning UML element
+ * @param bounds position and size
+ * @param settings rendering settings
+ */
+ public FigInterface(Object owner, Rectangle bounds,
+ DiagramSettings settings) {
+ super(owner, bounds, settings);
+ initialize();
+ }
+
+ /*
+ * @see org.tigris.gef.presentation.Fig#makeSelection()
+ */
+ @Override
+ public Selection makeSelection() {
+ return new SelectionInterface(this);
+ }
+
+
+ /**
+ * Gets the minimum size permitted for an interface on the diagram.<p>
+ *
+ * Parts of this are hardcoded.<p>
+ *
+ * @return the size of the minimum bounding box.
+ */
+ @Override
+ public Dimension getMinimumSize() {
+ // Use "aSize" to build up the minimum size. Start with the size of the
+ // name compartment and build up.
+
+ Dimension aSize = getNameFig().getMinimumSize();
+
+ aSize.height += NAME_V_PADDING * 2;
+ aSize.height = Math.max(NAME_FIG_HEIGHT, aSize.height);
+
+ // If we have a stereotype displayed, then allow some space for that
+ // (width and height)
+ aSize = addChildDimensions(aSize, getStereotypeFig());
+ aSize = addChildDimensions(aSize, getOperationsFig());
+
+ // we want to maintain a minimum width for Interfaces
+ aSize.width = Math.max(WIDTH, aSize.width);
+
+ return aSize;
+ }
+
+
+ /*
+ * @see org.tigris.gef.presentation.Fig#setEnclosingFig(org.tigris.gef.presentation.Fig)
+ */
+ @Override
+ public void setEnclosingFig(Fig encloser) {
+ Fig oldEncloser = getEnclosingFig();
+
+ if (encloser == null
+ || (encloser != null
+ && !Model.getFacade().isAInstance(encloser.getOwner()))) {
+ super.setEnclosingFig(encloser);
+ }
+ if (!(Model.getFacade().isAModelElement(getOwner()))) {
+ return;
+ }
+ /* If this fig is not visible, do not adapt the UML model!
+ * This is used for deleting. See issue 3042.
+ */
+ if (!isVisible()) {
+ return;
+ }
+ Object me = getOwner();
+ Object m = null;
+
+ try {
+ // If moved into an Package
+ if (encloser != null
+ && oldEncloser != encloser
+ && Model.getFacade().isAPackage(encloser.getOwner())) {
+ Model.getCoreHelper().setNamespace(me, encloser.getOwner());
+ }
+
+ // If default Namespace is not already set
+ if (Model.getFacade().getNamespace(me) == null
+ && (TargetManager.getInstance().getTarget()
+ instanceof ArgoDiagram)) {
+ m =
+ ((ArgoDiagram) TargetManager.getInstance().getTarget())
+ .getNamespace();
+ Model.getCoreHelper().setNamespace(me, m);
+ }
+ } catch (Exception e) {
+ LOG.error("could not set package due to:" + e
+ + "' at " + encloser, e);
+ }
+
+ // The next if-clause is important for the Deployment-diagram
+ // it detects if the enclosing fig is a component, in this case
+ // the container will be set for the owning Interface
+ if (encloser != null
+ && (Model.getFacade().isAComponent(encloser.getOwner()))) {
+ moveIntoComponent(encloser);
+ super.setEnclosingFig(encloser);
+ }
+ }
+
+ /**
+ * USED BY PGML.tee.
+ * @return the class name and bounds together with compartment
+ * visibility.
+ */
+ @Override
+ public String classNameAndBounds() {
+ return super.classNameAndBounds()
+ + "operationsVisible=" + isOperationsVisible();
+ }
+
+ /**
+ * Sets the bounds, but the size will be at least the one returned by
+ * {@link #getMinimumSize()}, unless checking of size is disabled.<p>
+ *
+ * If the required height is bigger, then the additional height is
+ * equally distributed among all figs (i.e. compartments), such that the
+ * cumulated height of all visible figs equals the demanded height<p>.
+ *
+ * Some of this has "magic numbers" hardcoded in.<p>
+ *
+ * @param x Desired X coordinate of upper left corner
+ *
+ * @param y Desired Y coordinate of upper left corner
+ *
+ * @param w Desired width of the FigInterface
+ *
+ * @param h Desired height of the FigInterface
+ */
+ @Override
+ protected void setStandardBounds(final int x, final int y, final int w,
+ final int h) {
+
+ // Save our old boundaries (needed later), and get minimum size
+ // info.
+ Rectangle oldBounds = getBounds();
+
+ // set bounds of big box
+ getBigPort().setBounds(x, y, w, h);
+ borderFig.setBounds(x, y, w, h);
+
+ int currentHeight = 0;
+
+ if (getStereotypeFig().isVisible()) {
+ int stereotypeHeight = getStereotypeFig().getMinimumSize().height;
+ getStereotypeFig().setBounds(
+ x,
+ y,
+ w,
+ stereotypeHeight);
+ currentHeight = stereotypeHeight;
+ }
+
+ int nameHeight = getNameFig().getMinimumSize().height;
+ getNameFig().setBounds(x, y + currentHeight, w, nameHeight);
+ currentHeight += nameHeight;
+
+ if (getOperationsFig().isVisible()) {
+ int operationsY = y + currentHeight;
+ int operationsHeight = (h + y) - operationsY - 1;
+ getOperationsFig().setBounds(
+ x,
+ operationsY,
+ w,
+ operationsHeight);
+ }
+
+ // Now force calculation of the bounds of the figure, update the edges
+ // and trigger anyone who's listening to see if the "bounds" property
+ // has changed.
+
+ calcBounds();
+ updateEdges();
+ firePropChange("bounds", oldBounds, getBounds());
+ }
+
+}
\ No newline at end of file
Added: trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/FigModel.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/FigModel.java?view=markup&pathrev=17206
==============================================================================
--- (empty file)
+++ trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/FigModel.java 2009-08-01 10:33:47-0700
@@ -0,0 +1,81 @@
+// $Id: FigModel.java 17045 2009-04-05 16:52:52Z mvw $
+// Copyright (c) 1996-2009 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.class2.diagram;
+
+import java.awt.Polygon;
+import java.awt.Rectangle;
+
+import org.argouml.uml.diagram.DiagramSettings;
+import org.tigris.gef.presentation.FigPoly;
+
+/**
+ * Class to display graphics for a UML model in a class diagram.
+ */
+public class FigModel extends FigPackage {
+
+ private FigPoly figPoly = new FigPoly(LINE_COLOR, SOLID_FILL_COLOR);
+
+ private void constructFigs() {
+ int[] xpoints = {125, 130, 135, 125};
+ int[] ypoints = {45, 40, 45, 45};
+ Polygon polygon = new Polygon(xpoints, ypoints, 4);
+ figPoly.setPolygon(polygon);
+ figPoly.setFilled(false);
+ addFig(figPoly);
+
+ setBounds(getBounds());
+
+ updateEdges();
+ }
+
+ /**
+ * Construct a Model fig
+ *
+ * @param owner owning UML element
+ * @param bounds position and size
+ * @param settings rendering settings
+ */
+ public FigModel(Object owner, Rectangle bounds, DiagramSettings settings) {
+ super(owner, bounds, settings);
+ constructFigs();
+ }
+
+ /*
+ * @see org.tigris.gef.presentation.Fig#setBounds(int, int, int, int)
+ */
+ @Override
+ protected void setStandardBounds(int x, int y, int w, int h) {
+
+ if (figPoly != null) {
+ Rectangle oldBounds = getBounds();
+ figPoly.translate((x - oldBounds.x) + (w - oldBounds.width), y
+ - oldBounds.y);
+
+ }
+ super.setStandardBounds(x, y, w, h);
+ }
+
+
+}
Added: trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/FigPackage.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/FigPackage.java?view=markup&pathrev=17206
==============================================================================
--- (empty file)
+++ trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/FigPackage.java 2009-08-01 10:33:47-0700
@@ -0,0 +1,982 @@
+// $Id: FigPackage.java 17045 2009-04-05 16:52:52Z mvw $
+// Copyright (c) 1996-2009 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.class2.diagram;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.event.ActionEvent;
+import java.awt.event.MouseEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyVetoException;
+import java.util.List;
+import java.util.Vector;
+
+import javax.swing.JOptionPane;
+
+import org.apache.log4j.Logger;
+import org.argouml.application.helpers.ResourceLoaderWrapper;
+import org.argouml.i18n.Translator;
+import org.argouml.kernel.Project;
+import org.argouml.model.Model;
+import org.argouml.model.RemoveAssociationEvent;
+import org.argouml.ui.ArgoJMenu;
+import org.argouml.ui.explorer.ExplorerEventAdaptor;
+import org.argouml.ui.targetmanager.TargetManager;
+import org.argouml.uml.diagram.ArgoDiagram;
+import org.argouml.uml.diagram.DiagramFactory;
+import org.argouml.uml.diagram.DiagramSettings;
+import org.argouml.uml.diagram.StereotypeContainer;
+import org.argouml.uml.diagram.VisibilityContainer;
+import org.argouml.uml.diagram.DiagramFactory.DiagramType;
+import org.argouml.uml.diagram.ui.ArgoFig;
+import org.argouml.uml.diagram.ui.ArgoFigText;
+import org.argouml.uml.diagram.ui.FigNodeModelElement;
+import org.tigris.gef.base.Editor;
+import org.tigris.gef.base.Geometry;
+import org.tigris.gef.base.Globals;
+import org.tigris.gef.base.LayerPerspective;
+import org.tigris.gef.presentation.Fig;
+import org.tigris.gef.presentation.FigRect;
+import org.tigris.gef.presentation.FigText;
+import org.tigris.gef.undo.UndoableAction;
+
+/**
+ * Class to display graphics for a UML package in a class diagram,
+ * consisting of a "tab" and a "body". <p>
+ *
+ * The tab of the Package Fig is build of 2 pieces:
+ * the stereotypes at the top, and the name below it. <p>
+ *
+ * The name box covers the whole tab, i.e. its size
+ * is always equal to the total size of the tab.
+ * It is not transparent, and has a line border.
+ * Its text sits at the bottom of the fig, to leave room for stereotypes. <p>
+ *
+ * The stereotype fig is transparent, and sits at the top
+ * inside the name fig. It is drawn on top of the name fig box. <p>
+ *
+ * The tab of the Package Fig can only be resized by the user horizontally.
+ * The body can be resized horizontally and vertically by the user. <p>
+ *
+ * Double clicking on the body has a special consequence:
+ * the user is asked if he wants to create a new class diagram
+ * for this package. <p>
+ *
+ * ArgoUML does not support the option of showing the name
+ * of the package in the body,
+ * as described in the UML standard (chapter Notation - Package). <p>
+ *
+ * Neither does ArgoUML currently support showing properties in the tab,
+ * see issue 1214. <p>
+ *
+ * In front of the name, ArgoUML may optionally show the visibility.
+ */
+public class FigPackage extends FigNodeModelElement
+ implements StereotypeContainer, VisibilityContainer {
+
+ private static final Logger LOG = Logger.getLogger(FigPackage.class);
+
+ /** The minimal height of the name. */
+ private static final int MIN_HEIGHT = 21;
+ /** The minimal width of the name. */
+ private static final int MIN_WIDTH = 50;
+
+ /** The initial width of the outer box. */
+ private int width = 140;
+ /** The initial height of the outer box. */
+ private int height = 100;
+
+ /** The width of the cut out area at the right top corner. */
+ private int indentX = 50;
+
+ private int textH = 20;
+
+ /**
+ * The total height of the tab.
+ */
+ private int tabHeight = 20;
+
+ private FigText body;
+
+ /**
+ * Flag that indicates if the user wants any stereotype to be shown.
+ * It corresponds to the check-mark on the Presentation tab.
+ * There is no relation with the actual presence of any stereotypes.
+ * This setting has Fig-scope, hence it is saved with the Fig layout data.
+ */
+ private boolean stereotypeVisible = true;
+
+ private void initialize() {
+ body.setEditable(false);
+
+ setBigPort(
+ new PackagePortFigRect(0, 0, width, height, indentX, tabHeight));
+
+ getNameFig().setBounds(0, 0, width - indentX, textH + 2);
+ getNameFig().setJustification(FigText.JUSTIFY_LEFT);
+
+ getBigPort().setFilled(false);
+ getBigPort().setLineWidth(0);
+
+ // Set properties of the stereotype box.
+ // 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().setVisible(false);
+
+ // add Figs to the FigNode in back-to-front order
+ addFig(getBigPort());
+ addFig(getNameFig());
+ addFig(getStereotypeFig());
+ addFig(body);
+
+ setBlinkPorts(false); //make port invisible unless mouse enters
+
+ // Make all the parts match the main fig
+ setFilled(true);
+ setFillColor(FILL_COLOR);
+ setLineColor(LINE_COLOR);
+ setLineWidth(LINE_WIDTH);
+
+ updateEdges();
+ }
+
+ /**
+ * Construct a package figure with the given owner, bounds, and rendering
+ * settings. This constructor is used by the PGML parser.
+ *
+ * @param owner owning model element
+ * @param bounds position and size or null if fig hasn't been placed
+ * @param settings rendering settings
+ */
+ public FigPackage(Object owner, Rectangle bounds,
+ DiagramSettings settings) {
+ super(owner, bounds, settings);
+
+ // Create a Body that reacts to double-clicks and jumps to a diagram.
+ body = new FigPackageFigText(getOwner(),
+ new Rectangle(0, textH, width, height - textH), getSettings());
+
+ initialize();
+
+ if (bounds != null) {
+ setLocation(bounds.x, bounds.y);
+ }
+ setBounds(getBounds());
+ }
+
+ /*
+ * @see java.lang.Object#clone()
+ */
+ @Override
+ public Object clone() {
+ FigPackage figClone = (FigPackage) super.clone();
+ for (Fig thisFig : (List<Fig>) getFigs()) {
+ if (thisFig == body) {
+ figClone.body = (FigText) thisFig;
+ }
+ }
+ return figClone;
+ }
+
+
+ /*
+ * @see org.tigris.gef.presentation.Fig#setLineColor(java.awt.Color)
+ */
+ @Override
+ public void setLineColor(Color col) {
+ super.setLineColor(col);
+ getStereotypeFig().setLineColor(null);
+ getNameFig().setLineColor(col);
+ body.setLineColor(col);
+ }
+
+ /*
+ * @see org.tigris.gef.presentation.Fig#getLineColor()
+ */
+ @Override
+ public Color getLineColor() {
+ return body.getLineColor();
+ }
+
+ /*
+ * @see org.tigris.gef.presentation.Fig#setFillColor(java.awt.Color)
+ */
+ @Override
+ public void setFillColor(Color col) {
+ super.setFillColor(col);
+ getStereotypeFig().setFillColor(null);
+ getNameFig().setFillColor(col);
+ body.setFillColor(col);
+ }
+
+ /*
+ * @see org.tigris.gef.presentation.Fig#getFillColor()
+ */
+ @Override
+ public Color getFillColor() {
+ return body.getFillColor();
+ }
+
+ /*
+ * @see org.tigris.gef.presentation.Fig#setFilled(boolean)
+ */
+ @Override
+ public void setFilled(boolean f) {
+ getStereotypeFig().setFilled(false);
+ getNameFig().setFilled(f);
+ body.setFilled(f);
+ }
+
+
+ @Override
+ public boolean isFilled() {
+ return body.isFilled();
+ }
+
+ /*
+ * @see org.tigris.gef.presentation.Fig#setLineWidth(int)
+ */
+ @Override
+ public void setLineWidth(int w) {
+ // There are 2 boxes showing lines: the tab and the body.
+ getNameFig().setLineWidth(w);
+ body.setLineWidth(w);
+ }
+
+ /*
+ * @see org.tigris.gef.presentation.Fig#getLineWidth()
+ */
+ @Override
+ public int getLineWidth() {
+ return body.getLineWidth();
+ }
+
+ /*
+ * @see org.argouml.uml.diagram.ui.FigNodeModelElement#updateStereotypeText()
+ */
+ @Override
+ protected void updateStereotypeText() {
+ Object modelElement = getOwner();
+
+ if (modelElement == null) {
+ return;
+ }
+
+ Rectangle rect = getBounds();
+
+ /* check if any stereotype is defined */
+ if (Model.getFacade().getStereotypes(modelElement).isEmpty()) {
+ if (getStereotypeFig().isVisible()) {
+ getNameFig().setTopMargin(0);
+ getStereotypeFig().setVisible(false);
+ } // else nothing changed
+ } else {
+ /* we got at least one stereotype */
+ /* This populates the stereotypes area: */
+ super.updateStereotypeText();
+ if (!isStereotypeVisible()) {
+ // the user wants to hide them
+ getNameFig().setTopMargin(0);
+ getStereotypeFig().setVisible(false);
+ } else if (!getStereotypeFig().isVisible()) {
+ getNameFig().setTopMargin(
+ getStereotypeFig().getMinimumSize().height);
+ getStereotypeFig().setVisible(true);
+ } // else nothing changed
+ }
+
+ forceRepaintShadow();
+ setBounds(rect.x, rect.y, rect.width, rect.height);
+ }
+
+ /**
+ * USED BY PGML.tee.
+ * @return the class name and bounds together with compartment
+ * visibility.
+ */
+ @Override
+ public String classNameAndBounds() {
+ return super.classNameAndBounds()
+ + "stereotypeVisible=" + isStereotypeVisible()
+ + ";"
+ + "visibilityVisible=" + isVisibilityVisible();
+ }
+
+
+ /*
+ * @see org.tigris.gef.presentation.Fig#getUseTrapRect()
+ */
+ @Override
+ public boolean getUseTrapRect() {
+ return true;
+ }
+
+ /*
+ * @see org.tigris.gef.presentation.Fig#getMinimumSize()
+ */
+ @Override
+ public Dimension getMinimumSize() {
+ // Use "aSize" to build up the minimum size. Start with the size of the
+ // name fig and build up.
+ Dimension aSize = new Dimension(getNameFig().getMinimumSize());
+ aSize.height = Math.max(aSize.height, MIN_HEIGHT);
+ aSize.width = Math.max(aSize.width, MIN_WIDTH);
+
+ // If we have any number of stereotypes displayed, then allow
+ // some space for that (only width, height is included in nameFig):
+ if (isStereotypeVisible()) {
+ Dimension st = getStereotypeFig().getMinimumSize();
+ aSize.width =
+ Math.max(aSize.width, st.width);
+ }
+
+ // take into account the tab is not as wide as the body:
+ aSize.width += indentX + 1;
+
+ // we want at least some of the package body to be displayed
+ aSize.height += 30;
+
+ // And now aSize has the answer
+ return aSize;
+ }
+
+ /**
+ * Sets the bounds, but the size will be at least the one returned by
+ * {@link #getMinimumSize()}.<p>
+ *
+ * If the required height is bigger, then the additional height is
+ * not distributed among all figs (i.e. compartments),
+ * but goes into the body. Hence, the
+ * accumulated height of all visible figs equals the demanded height<p>.
+ *
+ * Some of this has "magic numbers" hardcoded in. In particular there is
+ * a knowledge that the minimum height of a name compartment is 21
+ * pixels. This height is needed to be able to display the "Clarifier"
+ * inside the name compartment.
+ *
+ * @param xa Desired X coordinate of upper left corner
+ *
+ * @param ya Desired Y coordinate of upper left corner
+ *
+ * @param w Desired width of the FigClass
+ *
+ * @param h Desired height of the FigClass
+ */
+ @Override
+ protected void setStandardBounds(int xa, int ya, int w, int h) {
+ // Save our old boundaries (needed later), and get minimum size
+ // info. "aSize" will be used to maintain a running calculation of our
+ // size at various points.
+
+ Rectangle oldBounds = getBounds();
+
+ // The new size can not be smaller than the minimum.
+ Dimension minimumSize = getMinimumSize();
+ int newW = Math.max(w, minimumSize.width);
+ int newH = Math.max(h, minimumSize.height);
+
+ // Now resize all sub-figs, including not displayed figs. Start by the
+ // name. We override the getMinimumSize if it is less than our view (21
+ // pixels hardcoded!). Add in the shared extra, plus in this case the
+ // correction.
+
+ Dimension nameMin = getNameFig().getMinimumSize();
+ int minNameHeight = Math.max(nameMin.height, MIN_HEIGHT);
+
+ // Now sort out the stereotype display. If the stereotype is displayed,
+ // move the upper boundary of the name compartment up and set new
+ // bounds for the name and the stereotype compartments and the
+ // stereoLineBlinder that blanks out the line between the two
+
+ int currentY = ya;
+
+ int tabWidth = newW - indentX;
+
+ if (isStereotypeVisible()) {
+ Dimension stereoMin = getStereotypeFig().getMinimumSize();
+ getNameFig().setTopMargin(stereoMin.height);
+ getNameFig().setBounds(xa, currentY, tabWidth + 1, minNameHeight);
+
+ getStereotypeFig().setBounds(xa, ya,
+ tabWidth, stereoMin.height + 1);
+
+ if (tabWidth < stereoMin.width + 1) {
+ tabWidth = stereoMin.width + 2;
+ }
+ } else {
+ getNameFig().setBounds(xa, currentY, tabWidth + 1, minNameHeight);
+ }
+
+ // Advance currentY to where the start of the body box is,
+ // remembering that it overlaps the next box by 1 pixel. Calculate the
+ // size of the body box, and update the Y pointer past it if it is
+ // displayed.
+
+ currentY += minNameHeight - 1; // -1 for 1 pixel overlap
+ body.setBounds(xa, currentY, newW, newH + ya - currentY);
+
+ tabHeight = currentY - ya;
+ // set bounds of big box
+
+ getBigPort().setBounds(xa, ya, newW, newH);
+
+ // Now force calculation of the bounds of the figure, update the edges
+ // and trigger anyone who's listening to see if the "bounds" property
+ // has changed.
+
+ calcBounds();
+ updateEdges();
+ firePropChange("bounds", oldBounds, getBounds());
+ }
+
+ /**
+ * Build a collection of menu items relevant for a right-click
+ * popup menu on a Package.
+ *
+ * @param me a mouse event
+ * @return a collection of menu items
+ */
+ @Override
+ public Vector getPopUpActions(MouseEvent me) {
+ Vector popUpActions = super.getPopUpActions(me);
+
+ // Modifier ...
+ popUpActions.add(
+ popUpActions.size() - getPopupAddOffset(),
+ buildModifierPopUp(ABSTRACT | LEAF | ROOT));
+
+ // Visibility ...
+ popUpActions.add(
+ popUpActions.size() - getPopupAddOffset(),
+ buildVisibilityPopUp());
+
+ return popUpActions;
+ }
+
+ @Override
+ protected ArgoJMenu buildShowPopUp() {
+ ArgoJMenu showMenu = super.buildShowPopUp();
+ /* Only show the menuitems if they make sense: */
+ Editor ce = Globals.curEditor();
+ List<Fig> figs = ce.getSelectionManager().getFigs();
+ boolean sOn = false;
+ boolean sOff = false;
+ boolean vOn = false;
+ boolean vOff = false;
+ for (Fig f : figs) {
+ if (f instanceof StereotypeContainer) {
+ boolean v = ((StereotypeContainer) f).isStereotypeVisible();
+ if (v) {
+ sOn = true;
+ } else {
+ sOff = true;
+ }
+ v = ((VisibilityContainer) f).isVisibilityVisible();
+ if (v) {
+ vOn = true;
+ } else {
+ vOff = true;
+ }
+ }
+ }
+
+ if (sOn) {
+ showMenu.add(new HideStereotypeAction());
+ }
+
+ if (sOff) {
+ showMenu.add(new ShowStereotypeAction());
+ }
+
+ if (vOn) {
+ showMenu.add(new HideVisibilityAction());
+ }
+
+ if (vOff) {
+ showMenu.add(new ShowVisibilityAction());
+ }
+
+ return showMenu;
+ }
+
+ /**
+ * Change the visibility of the stereotypes of all Figs.
+ *
+ * @param value true if it needs to become visible
+ */
+ private void doStereotype(boolean value) {
+ Editor ce = Globals.curEditor();
+ List<Fig> figs = ce.getSelectionManager().getFigs();
+ for (Fig f : figs) {
+ if (f instanceof StereotypeContainer) {
+ ((StereotypeContainer) f).setStereotypeVisible(value);
+ }
+ if (f instanceof FigNodeModelElement) {
+ ((FigNodeModelElement) f).forceRepaintShadow();
+ ((ArgoFig) f).renderingChanged();
+ }
+ f.damage();
+ }
+ }
+
+ /**
+ * Change the visibility of the Visibility of all Figs.
+ *
+ * @param value true if it needs to become visible
+ */
+ private void doVisibility(boolean value) {
+ Editor ce = Globals.curEditor();
+ List<Fig> figs = ce.getSelectionManager().getFigs();
+ for (Fig f : figs) {
+ if (f instanceof VisibilityContainer) {
+ ((VisibilityContainer) f).setVisibilityVisible(value);
+ }
+ f.damage();
+ }
+ }
+
+ /**
+ * A text fig for the body of a a Package
+ * which does not contain any text,
+ * but solely exists to trigger a jump to a diagram for
+ * the named package when double clicked.
+ */
+ class FigPackageFigText extends ArgoFigText {
+
+ /**
+ * Construct a text fig for a Package which will jump to diagram for
+ * the named package when double clicked.
+ *
+ * @param owner owning UML element
+ * @param bounds position and size
+ * @param settings render settings
+ */
+ public FigPackageFigText(Object owner, Rectangle bounds,
+ DiagramSettings settings) {
+ super(owner, bounds, settings, false);
+ }
+
+ /**
+ * TODO: mvw: Would it not be better if this code
+ * would go in startTextEditor(), not overruling mouseClicked().
+ * But we made this fig not editable,
+ * to stop it from reacting on key-presses.
+ * Anyhow - this is a hack - abusing a FigText - GEF does
+ * not really support double-clicking on a Fig to trigger some action.
+ */
+ @Override
+ public void mouseClicked(MouseEvent me) {
+
+ String lsDefaultName = "main";
+
+ // TODO: This code appears to be designed to jump to the diagram
+ // containing the contents of the package that was double clicked
+ // but it looks like it's always searching for the name "main"
+ // instead of the package name.
+ // TODO: But in any case, it should be delegating this work to
+ // to something that knows about the diagrams and they contents -tfm
+ if (me.getClickCount() >= 2) {
+ Object lPkg = FigPackage.this.getOwner();
+ if (lPkg != null) {
+ Object lNS = lPkg;
+
+ Project lP = getProject();
+
+ List<ArgoDiagram> diags = lP.getDiagramList();
+ ArgoDiagram lFirst = null;
+ for (ArgoDiagram lDiagram : diags) {
+ Object lDiagramNS = lDiagram.getNamespace();
+ if ((lNS == null && lDiagramNS == null)
+ || (lNS.equals(lDiagramNS))) {
+ /* save first */
+ if (lFirst == null) {
+ lFirst = lDiagram;
+ }
+
+ if (lDiagram.getName() != null
+ && lDiagram.getName().startsWith(
+ lsDefaultName)) {
+ me.consume();
+ super.mouseClicked(me);
+ TargetManager.getInstance().setTarget(lDiagram);
+ return;
+ }
+ }
+ } /*while*/
+
+ /* If we get here then we didn't get the
+ * default diagram.
+ */
+ if (lFirst != null) {
+ me.consume();
+ super.mouseClicked(me);
+
+ TargetManager.getInstance().setTarget(lFirst);
+ return;
+ }
+
+ /* Try to create a new class diagram.
+ */
+ me.consume();
+ super.mouseClicked(me);
+ try {
+ createClassDiagram(lNS, lsDefaultName, lP);
+ } catch (Exception ex) {
+ LOG.error(ex);
+ }
+
+ return;
+
+ } /*if package */
+ } /* if doubleclicks */
+ super.mouseClicked(me);
+ }
+
+ /**
+ * The UID.
+ */
+ private static final long serialVersionUID = -1355316218065323634L;
+ }
+
+ private void createClassDiagram(
+ Object namespace,
+ String defaultName,
+ Project project) throws PropertyVetoException {
+
+ String namespaceDescr;
+ if (namespace != null
+ && Model.getFacade().getName(namespace) != null) {
+ namespaceDescr = Model.getFacade().getName(namespace);
+ } else {
+ namespaceDescr = Translator.localize("misc.name.anon");
+ }
+
+ String dialogText = "Add new class diagram to " + namespaceDescr + "?";
+ int option =
+ JOptionPane.showConfirmDialog(
+ null,
+ dialogText,
+ "Add new class diagram?",
+ JOptionPane.YES_NO_OPTION);
+
+ if (option == JOptionPane.YES_OPTION) {
+
+ ArgoDiagram classDiagram =
+ DiagramFactory.getInstance().
+ createDiagram(DiagramType.Class, namespace, null);
+
+ String diagramName = defaultName + "_" + classDiagram.getName();
+
+ project.addMember(classDiagram);
+
+ TargetManager.getInstance().setTarget(classDiagram);
+ /* change prefix */
+ classDiagram.setName(diagramName);
+ ExplorerEventAdaptor.getInstance().structureChanged();
+ }
+ }
+
+ /*
+ * @see org.argouml.uml.diagram.ui.StereotypeContainer#isStereotypeVisible()
+ */
+ public boolean isStereotypeVisible() {
+ return stereotypeVisible;
+ }
+
+ /*
+ * @see org.argouml.uml.diagram.ui.StereotypeContainer#setStereotypeVisible(boolean)
+ */
+ public void setStereotypeVisible(boolean isVisible) {
+ stereotypeVisible = isVisible;
+ renderingChanged();
+ damage();
+ }
+
+ /*
+ * @see org.argouml.uml.diagram.ui.VisibilityContainer#isVisibilityVisible()
+ */
+ public boolean isVisibilityVisible() {
+ return getNotationSettings().isShowVisibilities();
+ }
+
+ /*
+ * @see org.argouml.uml.diagram.ui.VisibilityContainer#setVisibilityVisible(boolean)
+ */
+ public void setVisibilityVisible(boolean isVisible) {
+ getNotationSettings().setShowVisibilities(isVisible);
+ renderingChanged();
+ damage();
+ }
+
+ /*
+ * @see org.argouml.uml.diagram.ui.FigNodeModelElement#textEditStarted(org.tigris.gef.presentation.FigText)
+ */
+ @Override
+ protected void textEditStarted(FigText ft) {
+
+ if (ft == getNameFig()) {
+ showHelp("parsing.help.fig-package");
+ }
+ }
+
+ /*
+ * @see org.tigris.gef.presentation.Fig#getClosestPoint(java.awt.Point)
+ */
+ @Override
+ public Point getClosestPoint(Point anotherPt) {
+ Rectangle r = getBounds();
+ int[] xs = {
+ r.x, r.x + r.width - indentX, r.x + r.width - indentX,
+ r.x + r.width, r.x + r.width, r.x, r.x,
+ };
+ int[] ys = {
+ r.y, r.y, r.y + tabHeight,
+ r.y + tabHeight, r.y + r.height, r.y + r.height, r.y,
+ };
+ Point p =
+ Geometry.ptClosestTo(
+ xs,
+ ys,
+ 7,
+ anotherPt);
+ return p;
+ }
+
+ @Override
+ protected void modelChanged(PropertyChangeEvent mee) {
+
+ if (mee instanceof RemoveAssociationEvent
+ && "ownedElement".equals(mee.getPropertyName())
+ && mee.getSource() == getOwner()) {
+ // A model element has been removed from this packages namespace
+ // If the Fig representing that model element is on the same
+ // diagram as this package then make sure it is not enclosed by
+ // this package.
+ // TODO: In my view the Fig representing the model element should be
+ // removed from the diagram. Yet to be agreed. Bob.
+ if (LOG.isInfoEnabled() && mee.getNewValue() == null) {
+ LOG.info(Model.getFacade().getName(mee.getOldValue())
+ + " has been removed from the namespace of "
+ + Model.getFacade().getName(getOwner())
+ + " by notice of " + mee.toString());
+ }
+ LayerPerspective layer = (LayerPerspective) getLayer();
+ Fig f = layer.presentationFor(mee.getOldValue());
+ if (f != null && f.getEnclosingFig() == this) {
+ removeEnclosedFig(f);
+ f.setEnclosingFig(null);
+ }
+ }
+ super.modelChanged(mee);
+ }
+
+ /**
+ * The UID.
+ */
+ private static final long serialVersionUID = 3617092272529451041L;
+
+ private class HideStereotypeAction extends UndoableAction {
+ /**
+ * The key for the action name.
+ */
+ private static final String ACTION_KEY =
+ "menu.popup.show.hide-stereotype";
+
+ /**
+ * Constructor.
+ */
+ HideStereotypeAction() {
+ super(Translator.localize(ACTION_KEY),
+ ResourceLoaderWrapper.lookupIcon(ACTION_KEY));
+ }
+ /*
+ * @see java.awt.event.ActionListener#actionPerformed(
+ * java.awt.event.ActionEvent)
+ */
+ @Override
+ public void actionPerformed(ActionEvent ae) {
+ super.actionPerformed(ae);
+ doStereotype(false);
+ }
+
+ /**
+ * The UID.
+ */
+ private static final long serialVersionUID =
+ 1999499813643610674L;
+ }
+
+ private class ShowStereotypeAction extends UndoableAction {
+ /**
+ * The key for the action name.
+ */
+ private static final String ACTION_KEY =
+ "menu.popup.show.show-stereotype";
+
+ /**
+ * Constructor.
+ */
+ ShowStereotypeAction() {
+ super(Translator.localize(ACTION_KEY),
+ ResourceLoaderWrapper.lookupIcon(ACTION_KEY));
+ }
+ /*
+ * @see java.awt.event.ActionListener#actionPerformed(
+ * java.awt.event.ActionEvent)
+ */
+ @Override
+ public void actionPerformed(ActionEvent ae) {
+ super.actionPerformed(ae);
+ doStereotype(true);
+ }
+
+ /**
+ * The UID.
+ */
+ private static final long serialVersionUID =
+ -4327161642276705610L;
+ }
+
+ private class HideVisibilityAction extends UndoableAction {
+ /**
+ * The key for the action name.
+ */
+ private static final String ACTION_KEY =
+ "menu.popup.show.hide-visibility";
+
+ /**
+ * Constructor.
+ */
+ HideVisibilityAction() {
+ super(Translator.localize(ACTION_KEY),
+ ResourceLoaderWrapper.lookupIcon(ACTION_KEY));
+ }
+ /*
+ * @see java.awt.event.ActionListener#actionPerformed(
+ * java.awt.event.ActionEvent)
+ */
+ @Override
+ public void actionPerformed(ActionEvent ae) {
+ super.actionPerformed(ae);
+ doVisibility(false);
+ }
+
+ /**
+ * The UID.
+ */
+ private static final long serialVersionUID =
+ 8574809709777267866L;
+ }
+
+ private class ShowVisibilityAction extends UndoableAction {
+ /**
+ * The key for the action name.
+ */
+ private static final String ACTION_KEY =
+ "menu.popup.show.show-visibility";
+
+ /**
+ * Constructor.
+ */
+ ShowVisibilityAction() {
+ super(Translator.localize(ACTION_KEY),
+ ResourceLoaderWrapper.lookupIcon(ACTION_KEY));
+ }
+ /*
+ * @see java.awt.event.ActionListener#actionPerformed(
+ * java.awt.event.ActionEvent)
+ */
+ @Override
+ public void actionPerformed(ActionEvent ae) {
+ super.actionPerformed(ae);
+ doVisibility(true);
+ }
+
+ /**
+ * The UID.
+ */
+ private static final long serialVersionUID =
+ 7722093402948975834L;
+ }
+
+} /* end class FigPackage */
+
+/**
+ * The bigport needs to overrule the getClosestPoint,
+ * because it is the port of this FigNode.
+ *
+ * @author [email protected]
+ */
+class PackagePortFigRect extends FigRect {
+ private int indentX;
+ private int tabHeight;
+
+ /**
+ * The constructor.
+ *
+ * @param x The x.
+ * @param y The y.
+ * @param w The width.
+ * @param h The height.
+ * @param ix The indent.
+ * @param th The tab height.
+ */
+ public PackagePortFigRect(int x, int y, int w, int h, int ix, int th) {
+ super(x, y, w, h, null, null);
+ this.indentX = ix;
+ tabHeight = th;
+ }
+
+ /*
+ * @see org.tigris.gef.presentation.Fig#getClosestPoint(java.awt.Point)
+ */
+ @Override
+ public Point getClosestPoint(Point anotherPt) {
+ Rectangle r = getBounds();
+ int[] xs = {
+ r.x, r.x + r.width - indentX, r.x + r.width - indentX,
+ r.x + r.width, r.x + r.width, r.x, r.x,
+ };
+ int[] ys = {
+ r.y, r.y, r.y + tabHeight,
+ r.y + tabHeight, r.y + r.height, r.y + r.height, r.y,
+ };
+ Point p =
+ Geometry.ptClosestTo(
+ xs,
+ ys,
+ 7,
+ anotherPt);
+ return p;
+ }
+
+ /**
+ * The UID.
+ */
+ private static final long serialVersionUID = -7083102131363598065L;
+}
Added: trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/FigSignal.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/FigSignal.java?view=markup&pathrev=17206
==============================================================================
--- (empty file)
+++ trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/FigSignal.java 2009-08-01 10:33:47-0700
@@ -0,0 +1,110 @@
+// $Id: FigSignal.java 17045 2009-04-05 16:52:52Z mvw $
+// Copyright (c) 2007-2009 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.class2.diagram;
+
+import java.awt.Rectangle;
+import java.awt.event.MouseEvent;
+import java.beans.PropertyChangeEvent;
+import java.util.Vector;
+
+import org.argouml.model.AssociationChangeEvent;
+import org.argouml.model.AttributeChangeEvent;
+import org.argouml.uml.diagram.DiagramSettings;
+import org.argouml.uml.diagram.static_structure.ui.FigClassifierBoxWithAttributes;
+import org.tigris.gef.base.Selection;
+
+/**
+ * Class to display graphics for a UML Signal in a diagram.
+ * <p>
+ * A Signal may have attributes - the UML standard document
+ * contains an example diagram showing this.
+ * <p>
+ * A Signal may have operations.
+ *
+ * @author Tom Morris
+ */
+public class FigSignal extends FigClassifierBoxWithAttributes {
+
+ private void constructFigs() {
+ getStereotypeFig().setKeyword("signal");
+
+ addFig(getBigPort());
+ addFig(getStereotypeFig());
+ addFig(getNameFig());
+ addFig(getOperationsFig());
+ addFig(getAttributesFig());
+ addFig(borderFig);
+
+ // by default, do not show operations nor attributes:
+ setOperationsVisible(false);
+ setAttributesVisible(false);
+ }
+
+ /**
+ * Construct a Fig representing a Signal.
+ *
+ * @param owner owning Signal
+ * @param bounds position and size
+ * @param settings render settings
+ */
+ public FigSignal(Object owner, Rectangle bounds, DiagramSettings settings) {
+ super(owner, bounds, settings);
+ constructFigs();
+ }
+
+ /*
+ * @see org.argouml.uml.diagram.static_structure.ui.FigDataType#makeSelection()
+ */
+ @Override
+ public Selection makeSelection() {
+ return new SelectionSignal(this);
+ }
+
+ /*
+ * @see org.argouml.uml.diagram.static_structure.ui.FigClassifierBox#getPopUpActions(java.awt.event.MouseEvent)
+ */
+ @Override
+ public Vector getPopUpActions(MouseEvent me) {
+ Vector popUpActions = super.getPopUpActions(me);
+
+ // TODO: Do we have anything to add here?
+
+ return popUpActions;
+ }
+
+ /*
+ * @see org.argouml.uml.diagram.ui.FigNodeModelElement#modelChanged(java.beans.PropertyChangeEvent)
+ */
+ @Override
+ protected void modelChanged(PropertyChangeEvent mee) {
+ super.modelChanged(mee);
+ if (mee instanceof AssociationChangeEvent
+ || mee instanceof AttributeChangeEvent) {
+ renderingChanged();
+ updateListeners(getOwner(), getOwner());
+ }
+ }
+
+}
Added: trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/FigStereotypeDeclaration.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/FigStereotypeDeclaration.java?view=markup&pathrev=17206
==============================================================================
--- (empty file)
+++ trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/FigStereotypeDeclaration.java 2009-08-01 10:33:47-0700
@@ -0,0 +1,265 @@
+// $Id: FigStereotypeDeclaration.java 17045 2009-04-05 16:52:52Z mvw $
+// Copyright (c) 1996-2009 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.class2.diagram;
+
+import java.awt.Dimension;
+import java.awt.Rectangle;
+import java.awt.event.MouseEvent;
+import java.beans.PropertyChangeEvent;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.Vector;
+
+import javax.swing.Action;
+
+import org.argouml.model.AssociationChangeEvent;
+import org.argouml.model.AttributeChangeEvent;
+import org.argouml.model.Model;
+import org.argouml.ui.ArgoJMenu;
+import org.argouml.uml.diagram.DiagramSettings;
+import org.argouml.uml.diagram.ui.ActionAddNote;
+import org.argouml.uml.diagram.ui.ActionCompartmentDisplay;
+import org.argouml.uml.diagram.ui.ActionEdgesDisplay;
+import org.argouml.uml.diagram.ui.CompartmentFigText;
+import org.argouml.uml.diagram.ui.FigCompartmentBox;
+import org.argouml.uml.ui.foundation.extension_mechanisms.ActionNewTagDefinition;
+import org.tigris.gef.base.Selection;
+
+/**
+ * Class to display a Stereotype declaration figure using
+ * Classifier box notation.<p>
+ *
+ * TODO: This is just a placeholder right now! - tfm
+ */
+public class FigStereotypeDeclaration extends FigCompartmentBox {
+
+ private static final long serialVersionUID = -2702539988691983863L;
+
+ private void constructFigs() {
+ getStereotypeFig().setKeyword("stereotype");
+
+ // 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());
+
+ // TODO: Need named Tags and Constraints compartments here
+// addFig(tagsFig);
+// addFig(constraintsFig);
+
+ addFig(getBorderFig());
+
+ setSuppressCalcBounds(false);
+ // Set the bounds of the figure to the total of the above (hardcoded)
+ setBounds(X0, Y0, WIDTH, STEREOHEIGHT + NAME_FIG_HEIGHT);
+ }
+
+ /**
+ * Construct a Fig for a Stereotype on a diagram.
+ *
+ * @param owner owning stereotype
+ * @param bounds position and size
+ * @param settings render settings
+ */
+ public FigStereotypeDeclaration(Object owner, Rectangle bounds,
+ DiagramSettings settings) {
+ super(owner, bounds, settings);
+ constructFigs();
+ enableSizeChecking(true);
+ }
+
+ /*
+ * @see org.tigris.gef.presentation.Fig#makeSelection()
+ */
+ @Override
+ public Selection makeSelection() {
+ return new SelectionStereotype(this);
+ }
+
+ /**
+ * Build a collection of menu items relevant for a right-click
+ * popup menu on a Stereotype.
+ * {@inheritDoc}
+ */
+ @Override
+ public Vector getPopUpActions(MouseEvent me) {
+ Vector popUpActions = super.getPopUpActions(me);
+
+ // Add...
+ ArgoJMenu addMenu = new ArgoJMenu("menu.popup.add");
+ // TODO: Add Tags & Constraints
+// addMenu.add(TargetManager.getInstance().getAddAttributeAction());
+// addMenu.add(TargetManager.getInstance().getAddOperationAction());
+ addMenu.add(new ActionAddNote());
+ addMenu.add(new ActionNewTagDefinition());
+ addMenu.add(ActionEdgesDisplay.getShowEdges());
+ addMenu.add(ActionEdgesDisplay.getHideEdges());
+ popUpActions.add(popUpActions.size() - getPopupAddOffset(), addMenu);
+
+ // Show ...
+ ArgoJMenu showMenu = new ArgoJMenu("menu.popup.show");
+ for (Action action : ActionCompartmentDisplay.getActions()) {
+ showMenu.add(action);
+ }
+ if (showMenu.getComponentCount() > 0) {
+ popUpActions.add(popUpActions.size() - getPopupAddOffset(),
+ showMenu);
+ }
+
+ // Modifiers ...
+ popUpActions.add(popUpActions.size() - getPopupAddOffset(),
+ buildModifierPopUp(ABSTRACT | LEAF | ROOT));
+
+ // Visibility ...
+ popUpActions.add(popUpActions.size() - getPopupAddOffset(),
+ buildVisibilityPopUp());
+
+ return popUpActions;
+ }
+
+ /**
+ * Gets the minimum size permitted for a class on the diagram.<p>
+ *
+ * @return the size of the minimum bounding box.
+ */
+ @Override
+ public Dimension getMinimumSize() {
+ Dimension aSize = getNameFig().getMinimumSize();
+
+ //TODO: Why does this differ from the other Figs?
+ aSize = addChildDimensions(aSize, getStereotypeFig());
+
+ // TODO: Allow space for each of the Tags & Constraints we have
+
+ // we want to maintain a minimum width for the class
+ aSize.width = Math.max(WIDTH, aSize.width);
+
+ return aSize;
+ }
+
+ /**
+ * Sets the bounds, but the size will be at least the one returned by
+ * {@link #getMinimumSize()}, unless checking of size is disabled.<p>
+ *
+ * @param x Desired X coordinate of upper left corner
+ *
+ * @param y Desired Y coordinate of upper left corner
+ *
+ * @param w Desired width of the fig
+ *
+ * @param h Desired height of the fig
+ *
+ * @see org.tigris.gef.presentation.Fig#setBoundsImpl(int, int, int, int)
+ */
+ @Override
+ protected void setStandardBounds(final int x, final int y,
+ final int w, final int h) {
+ Rectangle oldBounds = getBounds();
+
+ // set bounds of big box
+ getBigPort().setBounds(x, y, w, h);
+ getBorderFig().setBounds(x, y, w, h);
+
+ int currentHeight = 0;
+
+ if (getStereotypeFig().isVisible()) {
+ int stereotypeHeight = getStereotypeFig().getMinimumSize().height;
+ getStereotypeFig().setBounds(
+ x,
+ y,
+ w,
+ stereotypeHeight);
+ currentHeight = stereotypeHeight;
+ }
+
+ int nameHeight = getNameFig().getMinimumSize().height;
+ getNameFig().setBounds(x, y + currentHeight, w, nameHeight);
+ currentHeight += nameHeight;
+
+ // TODO: Compute size of Tags and Constraints
+
+
+ // Now force calculation of the bounds of the figure, update the edges
+ // and trigger anyone who's listening to see if the "bounds" property
+ // has changed.
+
+ calcBounds();
+ updateEdges();
+ firePropChange("bounds", oldBounds, getBounds());
+ }
+
+ /*
+ * @see org.argouml.uml.diagram.static_structure.ui.FigCompartmentBox#unhighlight()
+ */
+ @Override
+ protected CompartmentFigText unhighlight() {
+ CompartmentFigText fc = super.unhighlight();
+ if (fc == null) {
+ // TODO: Try unhighlighting our child compartments
+// fc = unhighlight(getAttributesFig());
+ }
+ return fc;
+ }
+
+ /**
+ * Handles changes to the model. Takes into account the event that
+ * occurred. If you need to update the whole fig, consider using
+ * renderingChanged.
+ * {@inheritDoc}
+ * @see org.argouml.uml.diagram.ui.FigNodeModelElement#modelChanged(java.beans.PropertyChangeEvent)
+ */
+ @Override
+ protected void modelChanged(PropertyChangeEvent mee) {
+ super.modelChanged(mee);
+ if (mee instanceof AssociationChangeEvent
+ || mee instanceof AttributeChangeEvent) {
+ renderingChanged();
+ updateListeners(getOwner(), getOwner());
+ damage();
+ }
+ }
+
+ /*
+ * @see org.argouml.uml.diagram.ui.FigNodeModelElement#updateListeners(java.lang.Object)
+ */
+ @Override
+ protected void updateListeners(Object oldOwner, Object newOwner) {
+
+ Set<Object[]> listeners = new HashSet<Object[]>();
+ if (newOwner != null) {
+ listeners.add(new Object[] {newOwner, null});
+ // register for tagdefinitions:
+ for (Object td : Model.getFacade().getTagDefinitions(newOwner)) {
+ listeners.add(new Object[] {td,
+ new String[] {"name", "tagType", "multiplicity"}});
+ }
+ /* TODO: constraints, ... */
+ }
+ updateElementListeners(listeners);
+ }
+}
Added: trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/FigSubsystem.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/FigSubsystem.java?view=markup&pathrev=17206
==============================================================================
--- (empty file)
+++ trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/FigSubsystem.java 2009-08-01 10:33:47-0700
@@ -0,0 +1,80 @@
+// $Id: FigSubsystem.java 17045 2009-04-05 16:52:52Z mvw $
+// Copyright (c) 1996-2009 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.class2.diagram;
+
+import java.awt.Polygon;
+import java.awt.Rectangle;
+
+import org.argouml.uml.diagram.DiagramSettings;
+import org.tigris.gef.presentation.FigPoly;
+
+/** Class to display graphics for a UML subsystem in a class diagram. */
+
+public class FigSubsystem extends FigPackage {
+
+ private FigPoly figPoly = new FigPoly(LINE_COLOR, SOLID_FILL_COLOR);
+
+ private void constructFigs() {
+ int[] xpoints = {125, 125, 130, 130, 130, 135, 135};
+ int[] ypoints = {45, 40, 40, 35, 40, 40, 45};
+ Polygon polygon = new Polygon(xpoints, ypoints, 7);
+ figPoly.setPolygon(polygon);
+ figPoly.setFilled(false);
+ addFig(figPoly);
+ Rectangle r = getBounds();
+ setBounds(r.x, r.y, r.width, r.height);
+ updateEdges();
+ }
+
+ /**
+ * Construct a Subsystem fig.
+ *
+ * @param owner owning UML element
+ * @param bounds position and size
+ * @param settings render settings
+ */
+ public FigSubsystem(Object owner, Rectangle bounds,
+ DiagramSettings settings) {
+ super(owner, bounds, settings);
+ constructFigs();
+ }
+
+ /*
+ * @see org.tigris.gef.presentation.Fig#setBounds(int, int, int, int)
+ */
+ @Override
+ protected void setStandardBounds(int x, int y, int w, int h) {
+
+ if (figPoly != null) {
+ Rectangle oldBounds = getBounds();
+ figPoly.translate((x - oldBounds.x) + (w - oldBounds.width), y
+ - oldBounds.y);
+
+ }
+ super.setStandardBounds(x, y, w, h);
+ }
+
+
+}
Added: trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/SelectionClass.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/SelectionClass.java?view=markup&pathrev=17206
==============================================================================
--- (empty file)
+++ trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/SelectionClass.java 2009-08-01 10:33:47-0700
@@ -0,0 +1,166 @@
+// $Id: SelectionClass.java 15549 2008-08-11 18:59:23Z mvw $
+// Copyright (c) 1996-2008 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.class2.diagram;
+
+import java.awt.event.MouseEvent;
+
+import javax.swing.Icon;
+
+import org.argouml.application.helpers.ResourceLoaderWrapper;
+import org.argouml.model.Model;
+import org.argouml.uml.diagram.deployment.DeploymentDiagramGraphModel;
+import org.argouml.uml.diagram.ui.SelectionNodeClarifiers2;
+import org.tigris.gef.base.Globals;
+import org.tigris.gef.presentation.Fig;
+
+/**
+ * @author [email protected]
+ */
+class SelectionClass extends SelectionNodeClarifiers2 {
+
+ private static Icon inherit =
+ ResourceLoaderWrapper.lookupIconResource("Generalization");
+
+ private static Icon assoc =
+ ResourceLoaderWrapper.lookupIconResource("Association");
+
+ private static Icon compos =
+ ResourceLoaderWrapper.lookupIconResource("CompositeAggregation");
+
+ private static Icon selfassoc =
+ ResourceLoaderWrapper.lookupIconResource("SelfAssociation");
+
+ private boolean useComposite;
+
+ private static Icon icons[] =
+ {inherit,
+ inherit,
+ assoc,
+ assoc,
+ selfassoc,
+ };
+
+ // TODO: I18N required
+ private static String instructions[] =
+ {"Add a superclass",
+ "Add a subclass",
+ "Add an associated class",
+ "Add an associated class",
+ "Add a self association",
+ "Move object(s)",
+ };
+
+ private static Object edgeType[] =
+ {Model.getMetaTypes().getGeneralization(),
+ Model.getMetaTypes().getGeneralization(),
+ Model.getMetaTypes().getAssociation(),
+ Model.getMetaTypes().getAssociation(),
+ Model.getMetaTypes().getAssociation(),
+ };
+
+ /**
+ * Construct a new SelectionClass for the given Fig.
+ *
+ * @param f The given Fig.
+ */
+ public SelectionClass(Fig f) {
+ super(f);
+ }
+
+ @Override
+ protected Icon[] getIcons() {
+ Icon workingIcons[] = new Icon[icons.length];
+ System.arraycopy(icons, 0, workingIcons, 0, icons.length);
+
+ // No Generalizations on Deployment Diagram
+ if (Globals.curEditor().getGraphModel()
+ instanceof DeploymentDiagramGraphModel) {
+ workingIcons[TOP - BASE] = null;
+ workingIcons[BOTTOM - BASE] = null;
+ }
+ if (useComposite) {
+ workingIcons[LEFT - BASE] = compos;
+ workingIcons[RIGHT - BASE] = compos;
+ }
+ // Readonly class: no generalization, no association to self
+ if (Model.getModelManagementHelper().isReadOnly(
+ getContent().getOwner())) {
+ return new Icon[] {null, inherit, null, null, null };
+ }
+ return workingIcons;
+ }
+
+ @Override
+ protected String getInstructions(int index) {
+ return instructions[index - BASE];
+ }
+
+ @Override
+ protected Object getNewNodeType(int i) {
+ return Model.getMetaTypes().getUMLClass();
+ }
+
+ @Override
+ protected Object getNewEdgeType(int i) {
+ if (i == 0) {
+ i = getButton();
+ }
+ return edgeType[i - 10];
+ }
+
+ @Override
+ protected boolean isReverseEdge(int i) {
+ if (i == BOTTOM || i == LEFT) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ protected boolean isDraggableHandle(int index) {
+ // Self-association isn't draggable
+ if (index == LOWER_LEFT) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ protected boolean isEdgePostProcessRequested() {
+ return useComposite;
+ }
+
+ @Override
+ public void mouseEntered(MouseEvent me) {
+ super.mouseEntered(me);
+ useComposite = me.isShiftDown();
+ }
+
+ @Override
+ protected Object getNewNode(int index) {
+ return Model.getCoreFactory().buildClass();
+ }
+
+}
Added: trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/SelectionDataType.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/SelectionDataType.java?view=markup&pathrev=17206
==============================================================================
--- (empty file)
+++ trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/SelectionDataType.java 2009-08-01 10:33:47-0700
@@ -0,0 +1,56 @@
+// $Id: SelectionDataType.java 12062 2007-02-15 21:12:59Z tfmorris $
+// Copyright (c) 2006-2007 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.class2.diagram;
+
+import org.argouml.model.Model;
+import org.argouml.uml.diagram.static_structure.ui.SelectionGeneralizableElement;
+import org.tigris.gef.presentation.Fig;
+
+/**
+ * The buttons on selection for a DataType.
+ *
+ * @author Michiel
+ */
+class SelectionDataType extends SelectionGeneralizableElement {
+
+ /**
+ * Construct a new SelectionClass for the given Fig.
+ *
+ * @param f The given Fig.
+ */
+ public SelectionDataType(Fig f) {
+ super(f);
+ }
+
+ protected Object getNewNode(int buttonCode) {
+ Object ns = Model.getFacade().getNamespace(getContent().getOwner());
+ return Model.getCoreFactory().buildDataType("", ns);
+ }
+
+ protected Object getNewNodeType(int buttonCode) {
+ return Model.getMetaTypes().getDataType();
+ }
+
+}
Added: trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/SelectionEnumeration.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/SelectionEnumeration.java?view=markup&pathrev=17206
==============================================================================
--- (empty file)
+++ trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/SelectionEnumeration.java 2009-08-01 10:33:47-0700
@@ -0,0 +1,71 @@
+// $Id: SelectionEnumeration.java 12589 2007-05-10 16:04:49Z tfmorris $
+// Copyright (c) 2006-2007 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.class2.diagram;
+
+import org.argouml.model.Model;
+import org.tigris.gef.presentation.Fig;
+
+/**
+ * The buttons on selection for an Enumeration.
+ *
+ * @author Michiel
+ */
+class SelectionEnumeration extends SelectionDataType {
+
+ // TODO: I18N
+ private static String[] instructions =
+ {"Add a super-enumeration",
+ "Add a sub-enumeration",
+ null,
+ null,
+ null,
+ "Move object(s)",
+ };
+
+ /**
+ * @param f the given fi
+ */
+ public SelectionEnumeration(Fig f) {
+ super(f);
+ }
+
+ @Override
+ protected String getInstructions(int i) {
+ return instructions[ i - 10];
+
+ }
+
+ @Override
+ protected Object getNewNode(int index) {
+ Object ns = Model.getFacade().getNamespace(getContent().getOwner());
+ return Model.getCoreFactory().buildEnumeration("", ns);
+ }
+
+ @Override
+ protected Object getNewNodeType(int index) {
+ return Model.getMetaTypes().getEnumeration();
+ }
+
+}
Added: trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/SelectionException.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/SelectionException.java?view=markup&pathrev=17206
==============================================================================
--- (empty file)
+++ trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/SelectionException.java 2009-08-01 10:33:47-0700
@@ -0,0 +1,54 @@
+// $Id: SelectionException.java 12589 2007-05-10 16:04:49Z tfmorris $
+// Copyright (c) 2007 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.class2.diagram;
+
+import org.argouml.model.Model;
+import org.argouml.uml.diagram.static_structure.ui.SelectionGeneralizableElement;
+import org.tigris.gef.presentation.Fig;
+
+/**
+ * The buttons on selection for an Exception.
+ */
+class SelectionException extends SelectionGeneralizableElement {
+
+ /**
+ * Construct a new SelectionClass for the given Fig.
+ *
+ * @param f The given Fig.
+ */
+ public SelectionException(Fig f) {
+ super(f);
+ }
+
+ @Override
+ protected Object getNewNode(int buttonCode) {
+ return Model.getCommonBehaviorFactory().createException();
+ }
+
+ @Override
+ protected Object getNewNodeType(int buttonCode) {
+ return Model.getMetaTypes().getException();
+ }
+}
Added: trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/SelectionInterface.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/SelectionInterface.java?view=markup&pathrev=17206
==============================================================================
--- (empty file)
+++ trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/SelectionInterface.java 2009-08-01 10:33:47-0700
@@ -0,0 +1,127 @@
+// $Id: SelectionInterface.java 15549 2008-08-11 18:59:23Z mvw $
+// Copyright (c) 1996-2008 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.class2.diagram;
+
+import javax.swing.Icon;
+
+import org.argouml.application.helpers.ResourceLoaderWrapper;
+import org.argouml.model.Model;
+import org.argouml.uml.diagram.ui.SelectionNodeClarifiers2;
+import org.tigris.gef.presentation.Fig;
+
+/**
+ * @author [email protected]
+ */
+class SelectionInterface extends SelectionNodeClarifiers2 {
+
+ private static Icon realiz =
+ ResourceLoaderWrapper.lookupIconResource("Realization");
+
+ private static Icon inherit =
+ ResourceLoaderWrapper.lookupIconResource("Generalization");
+
+ private static Icon icons[] =
+ {inherit,
+ realiz,
+ null,
+ null,
+ null,
+ };
+
+ private static String instructions[] =
+ {"Add an interface",
+ "Add a realization",
+ null,
+ null,
+ null,
+ "Move object(s)",
+ };
+
+ /**
+ * Construct a new SelectionInterface for the given Fig.
+ *
+ * @param f
+ * The given Fig.
+ */
+ public SelectionInterface(Fig f) {
+ super(f);
+ }
+
+ @Override
+ protected Object getNewNode(int index) {
+ if (index == 0) {
+ index = getButton();
+ }
+ if (index == TOP) {
+ return Model.getCoreFactory().buildInterface();
+ } else {
+ return Model.getCoreFactory().buildClass();
+ }
+ }
+
+ @Override
+ protected Object getNewEdgeType(int index) {
+ if (index == TOP) {
+ return Model.getMetaTypes().getGeneralization();
+ } else if (index == BOTTOM) {
+ return Model.getMetaTypes().getAbstraction();
+ }
+ return null;
+ }
+
+
+ @Override
+ protected Object getNewNodeType(int index) {
+ if (index == TOP) {
+ return Model.getMetaTypes().getInterface();
+ } else if (index == BOTTOM) {
+ return Model.getMetaTypes().getUMLClass();
+ }
+ return null;
+ }
+
+ @Override
+ protected Icon[] getIcons() {
+ if (Model.getModelManagementHelper().isReadOnly(
+ getContent().getOwner())) {
+ return new Icon[] {null, realiz, null, null, null };
+ }
+ return icons;
+ }
+
+ @Override
+ protected String getInstructions(int index) {
+ return instructions[index - BASE];
+ }
+
+ @Override
+ protected boolean isReverseEdge(int index) {
+ if (index == 11) {
+ return true;
+ }
+ return false;
+ }
+
+}
Added: trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/SelectionSignal.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/SelectionSignal.java?view=markup&pathrev=17206
==============================================================================
--- (empty file)
+++ trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/SelectionSignal.java 2009-08-01 10:33:47-0700
@@ -0,0 +1,52 @@
+// $Id: SelectionSignal.java 12589 2007-05-10 16:04:49Z tfmorris $
+// Copyright (c) 2007 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.class2.diagram;
+
+import org.argouml.model.Model;
+import org.argouml.uml.diagram.static_structure.ui.SelectionGeneralizableElement;
+import org.tigris.gef.presentation.Fig;
+
+/**
+ * The buttons on selection for a Signal.
+ */
+class SelectionSignal extends SelectionGeneralizableElement {
+
+ /**
+ * Construct a new SelectionClass for the given Fig.
+ *
+ * @param f The given Fig.
+ */
+ public SelectionSignal(Fig f) {
+ super(f);
+ }
+
+ protected Object getNewNode(int index) {
+ return Model.getCommonBehaviorFactory().createSignal();
+ }
+
+ protected Object getNewNodeType(int index) {
+ return Model.getMetaTypes().getSignal();
+ }
+}
Added: trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/SelectionStereotype.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/SelectionStereotype.java?view=markup&pathrev=17206
==============================================================================
--- (empty file)
+++ trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/SelectionStereotype.java 2009-08-01 10:33:47-0700
@@ -0,0 +1,170 @@
+// $Id: SelectionStereotype.java 15561 2008-08-13 18:54:12Z mvw $
+// Copyright (c) 2006-2008 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.class2.diagram;
+
+import java.awt.event.MouseEvent;
+
+import javax.swing.Icon;
+
+import org.argouml.application.helpers.ResourceLoaderWrapper;
+import org.argouml.model.Model;
+import org.argouml.uml.StereotypeUtility;
+import org.argouml.uml.diagram.deployment.DeploymentDiagramGraphModel;
+import org.argouml.uml.diagram.ui.SelectionNodeClarifiers2;
+import org.tigris.gef.base.Globals;
+import org.tigris.gef.graph.MutableGraphModel;
+import org.tigris.gef.presentation.Fig;
+
+/**
+ * The buttons on selection for a Stereotype. <p>
+ *
+ * TODO: Find a way to hide the OperationsCompartment
+ * on the FigClass of the created metaclass.
+ *
+ * @author michiel
+ */
+class SelectionStereotype extends SelectionNodeClarifiers2 {
+
+ private static Icon inheritIcon =
+ ResourceLoaderWrapper.lookupIconResource("Generalization");
+ private static Icon dependIcon =
+ ResourceLoaderWrapper.lookupIconResource("Dependency");
+
+ private boolean useComposite;
+
+ private static Icon icons[] =
+ {dependIcon,
+ inheritIcon,
+ null,
+ null,
+ null,
+ };
+
+ // TODO: I18N required
+ private static String instructions[] =
+ {"Add a baseClass",
+ "Add a subStereotype",
+ null,
+ null,
+ null,
+ "Move object(s)",
+ };
+
+ /**
+ * Construct a new SelectionStereotype for the given Fig.
+ *
+ * @param f the given fig
+ */
+ public SelectionStereotype(Fig f) {
+ super(f);
+ }
+
+ @Override
+ public void mouseEntered(MouseEvent me) {
+ super.mouseEntered(me);
+ useComposite = me.isShiftDown();
+ }
+
+ @Override
+ protected Object getNewNode(int index) {
+ if (index == 0) {
+ index = getButton();
+ }
+ Object ns = Model.getFacade().getNamespace(getContent().getOwner());
+ switch (index) {
+ case 10:
+ Object clazz = Model.getCoreFactory().buildClass(ns);
+ StereotypeUtility.dealWithStereotypes(clazz, "metaclass", false);
+ return clazz;
+ case 11:
+ Object st =
+ Model.getExtensionMechanismsFactory().createStereotype();
+ Model.getCoreHelper().setNamespace(st, ns);
+ return st;
+ }
+ return null;
+ }
+
+ @Override
+ protected Object getNewNodeType(int index) {
+ switch (index) {
+ case 10:
+ return Model.getMetaTypes().getClass();
+ case 11:
+ return Model.getMetaTypes().getStereotype();
+ }
+ return null;
+ }
+
+ @Override
+ protected Object createEdgeAbove(MutableGraphModel mgm, Object newNode) {
+ Object dep = super.createEdgeAbove(mgm, newNode);
+ StereotypeUtility.dealWithStereotypes(dep, "stereotype", false);
+ return dep;
+ }
+
+ @Override
+ protected Icon[] getIcons() {
+ // In the DeploymentDiagram there are no Generalizations
+ if (Globals.curEditor().getGraphModel()
+ instanceof DeploymentDiagramGraphModel) {
+ return null;
+ }
+ if (Model.getModelManagementHelper().isReadOnly(
+ getContent().getOwner())) {
+ return new Icon[] {null, inheritIcon, null, null, null };
+ }
+ return icons;
+ }
+
+ @Override
+ protected String getInstructions(int index) {
+ return instructions[index - BASE];
+ }
+
+ @Override
+ protected Object getNewEdgeType(int index) {
+ if (index == TOP) {
+ return Model.getMetaTypes().getDependency();
+ } else if (index == BOTTOM) {
+ return Model.getMetaTypes().getGeneralization();
+ }
+ return null;
+ }
+
+ @Override
+ protected boolean isReverseEdge(int index) {
+ if (index == BOTTOM) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ protected boolean isEdgePostProcessRequested() {
+ return useComposite;
+ }
+
+}
Added: trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/UMLClassDiagram.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/UMLClassDiagram.java?view=markup&pathrev=17206
==============================================================================
--- (empty file)
+++ trunk/src/argouml-core-diagrams-class2/src/org/argouml/class2/diagram/UMLClassDiagram.java 2009-08-01 10:33:47-0700
@@ -0,0 +1,720 @@
+// $Id: UMLClassDiagram.java 16702 2009-01-25 20:23:28Z bobtarling $
+// Copyright (c) 1996-2008 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.class2.diagram;
+
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.beans.PropertyVetoException;
+import java.util.Collection;
+
+import javax.swing.Action;
+
+import org.apache.log4j.Logger;
+import org.argouml.i18n.Translator;
+import org.argouml.model.Model;
+import org.argouml.uml.diagram.DiagramSettings;
+import org.argouml.uml.diagram.deployment.ui.FigComponent;
+import org.argouml.uml.diagram.deployment.ui.FigComponentInstance;
+import org.argouml.uml.diagram.deployment.ui.FigMNode;
+import org.argouml.uml.diagram.deployment.ui.FigNodeInstance;
+import org.argouml.uml.diagram.deployment.ui.FigObject;
+import org.argouml.uml.diagram.static_structure.ClassDiagramGraphModel;
+import org.argouml.uml.diagram.ui.ModeCreateDependency;
+import org.argouml.uml.diagram.ui.ModeCreatePermission;
+import org.argouml.uml.diagram.ui.ModeCreateUsage;
+import org.argouml.uml.diagram.ui.UMLDiagram;
+import org.argouml.uml.diagram.use_case.ui.FigActor;
+import org.argouml.uml.diagram.use_case.ui.FigUseCase;
+import org.argouml.uml.ui.foundation.core.ActionAddAttribute;
+import org.argouml.uml.ui.foundation.core.ActionAddOperation;
+import org.argouml.util.ToolBarUtility;
+import org.tigris.gef.base.LayerPerspective;
+import org.tigris.gef.base.LayerPerspectiveMutable;
+import org.tigris.gef.presentation.FigNode;
+
+/**
+ * UML Class Diagram.
+ *
+ * @author [email protected]
+ */
+public class UMLClassDiagram extends UMLDiagram {
+
+ private static final long serialVersionUID = -9192325790126361563L;
+
+ private static final Logger LOG = Logger.getLogger(UMLClassDiagram.class);
+
+ ////////////////
+ // actions for toolbar
+ private Action actionAssociationClass;
+ private Action actionClass;
+ private Action actionInterface;
+ private Action actionDependency;
+ private Action actionPermission;
+ private Action actionUsage;
+ private Action actionLink;
+ private Action actionGeneralization;
+ private Action actionRealization;
+ private Action actionPackage;
+ private Action actionModel;
+ private Action actionSubsystem;
+ private Action actionAssociation;
+ private Action actionAssociationEnd;
+ private Action actionAggregation;
+ private Action actionComposition;
+ private Action actionUniAssociation;
+ private Action actionUniAggregation;
+ private Action actionUniComposition;
+ private Action actionDataType;
+ private Action actionEnumeration;
+ private Action actionStereotype;
+ private Action actionSignal;
+ private Action actionException;
+
+ /**
+ * Construct a Class Diagram. Default constructor used by PGML parser during
+ * diagram load. It should not be used by other callers.
+ * @deprecated only for use by PGML parser
+ */
+ @Deprecated
+ public UMLClassDiagram() {
+ super(new ClassDiagramGraphModel());
+ }
+
+
+ /**
+ * Construct a new class diagram with the given name, owned by the given
+ * namespace.
+ *
+ * @param name the name for the new diagram
+ * @param namespace the namespace for the new diagram
+ */
+ public UMLClassDiagram(String name, Object namespace) {
+ super(name, namespace, new ClassDiagramGraphModel());
+ }
+
+ /**
+ * Construct a Class Diagram owned by the given namespace. A default unique
+ * diagram name is constructed.
+ *
+ * @param m the namespace
+ */
+ public UMLClassDiagram(Object m) {
+ // We're going to change the name immediately, so just use ""
+ super("", m, new ClassDiagramGraphModel());
+ String name = getNewDiagramName();
+ try {
+ setName(name);
+ } catch (PropertyVetoException pve) {
+ LOG.warn("Generated diagram name '" + name
+ + "' was vetoed by setName");
+ }
+ }
+
+ /*
+ * @see org.argouml.uml.diagram.ui.UMLDiagram#setNamespace(java.lang.Object)
+ */
+ public void setNamespace(Object ns) {
+ if (!Model.getFacade().isANamespace(ns)) {
+ LOG.error("Illegal argument. "
+ + "Object " + ns + " is not a namespace");
+ throw new IllegalArgumentException("Illegal argument. "
+ + "Object " + ns
+ + " is not a namespace");
+ }
+ boolean init = (null == getNamespace());
+ super.setNamespace(ns);
+ ClassDiagramGraphModel gm = (ClassDiagramGraphModel) getGraphModel();
+ gm.setHomeModel(ns);
+ if (init) {
+ LayerPerspective lay =
+ new LayerPerspectiveMutable(Model.getFacade().getName(ns), gm);
+ ClassDiagramRenderer rend = new ClassDiagramRenderer(); // singleton
+ lay.setGraphNodeRenderer(rend);
+ lay.setGraphEdgeRenderer(rend);
+ setLayer(lay);
+ }
+ }
+
+ /*
+ * @see org.argouml.uml.diagram.ui.UMLDiagram#getUmlActions()
+ */
+ protected Object[] getUmlActions() {
+ Object[] actions = {
+ getPackageActions(),
+ getActionClass(),
+ null,
+ getAssociationActions(),
+ getAggregationActions(),
+ getCompositionActions(),
+ getActionAssociationEnd(),
+ getActionGeneralization(),
+ null,
+ getActionInterface(),
+ getActionRealization(),
+ null,
+ getDependencyActions(),
+ null,
+ ActionAddAttribute.getTargetFollower(),
+ ActionAddOperation.getTargetFollower(),
+ getActionAssociationClass(),
+ null,
+ getDataTypeActions(),
+ };
+
+ return actions;
+ }
+
+ /**
+ * Return the actions for the miscellaneous pulldown menu.
+ */
+ private Object[] getDataTypeActions() {
+ Object[] actions = {
+ getActionDataType(),
+ getActionEnumeration(),
+ getActionStereotype(),
+ getActionSignal(),
+ getActionException(),
+ };
+ ToolBarUtility.manageDefault(actions, "diagram.class.datatype");
+ return actions;
+ }
+
+ private Object getPackageActions() {
+ // TODO: To enable models and subsystems, change this flag
+ // Work started by Markus I believe where does this stand? - Bob.
+
+ // Status as of Nov. 2008 - Figs created, property panels exist, more
+ // work required on explorer and assumptions about models not being
+ // nested - tfm
+ if (false) {
+ Object[] actions = {
+ getActionPackage(),
+ getActionModel(),
+ getActionSubsystem(),
+ };
+ ToolBarUtility.manageDefault(actions, "diagram.class.package");
+ return actions;
+ } else {
+ return getActionPackage();
+ }
+ }
+
+ /**
+ * Return an array of dependency actions in the
+ * pattern of which to build a popup toolbutton.
+ */
+ private Object[] getDependencyActions() {
+ Object[] actions = {
+ getActionDependency(),
+ getActionPermission(),
+ getActionUsage(),
+ };
+ ToolBarUtility.manageDefault(actions, "diagram.class.dependency");
+ return actions;
+ }
+
+ /**
+ * Return an array of association actions in the
+ * pattern of which to build a popup toolbutton.
+ */
+ private Object[] getAssociationActions() {
+ // This calls the getters to fetch actions even though the
+ // action variables are defined is instances of this class.
+ // This is because any number of action getters could have
+ // been overridden in a descendent and it is the action from
+ // that overridden method that should be returned in the array.
+ Object[] actions = {
+ getActionAssociation(),
+ getActionUniAssociation(),
+ };
+ ToolBarUtility.manageDefault(actions, "diagram.class.association");
+ return actions;
+ }
+
+ private Object[] getAggregationActions() {
+ Object[] actions = {
+ getActionAggregation(),
+ getActionUniAggregation(),
+ };
+ ToolBarUtility.manageDefault(actions, "diagram.class.aggregation");
+ return actions;
+ }
+
+ private Object[] getCompositionActions() {
+ Object[] actions = {
+ getActionComposition(),
+ getActionUniComposition(),
+ };
+ ToolBarUtility.manageDefault(actions, "diagram.class.composition");
+ return actions;
+ }
+
+ /*
+ * @see org.argouml.uml.diagram.ui.UMLDiagram#getLabelName()
+ */
+ public String getLabelName() {
+ return Translator.localize("label.class-diagram");
+ }
+
+ /**
+ * @return Returns the actionAggregation.
+ */
+ protected Action getActionAggregation() {
+ if (actionAggregation == null) {
+ actionAggregation =
+ makeCreateAssociationAction(
+ Model.getAggregationKind().getAggregate(),
+ false,
+ "button.new-aggregation");
+ }
+ return actionAggregation;
+ }
+ /**
+ * @return Returns the actionAssociation.
+ */
+ protected Action getActionAssociation() {
+ if (actionAssociation == null) {
+ actionAssociation =
+ makeCreateAssociationAction(
+ Model.getAggregationKind().getNone(),
+ false, "button.new-association");
+ }
+ return actionAssociation;
+ }
+ /**
+ * @return Returns the actionAssociation.
+ */
+ protected Action getActionAssociationEnd() {
+ if (actionAssociationEnd == null) {
+ actionAssociationEnd =
+ makeCreateAssociationEndAction("button.new-association-end");
+ }
+ return actionAssociationEnd;
+ }
+
+ /**
+ * @return Returns the actionClass.
+ */
+ protected Action getActionClass() {
+ if (actionClass == null) {
+ actionClass =
+ makeCreateNodeAction(Model.getMetaTypes().getUMLClass(),
+ "button.new-class");
+ }
+
+ return actionClass;
+ }
+
+ /**
+ * @return Returns the actionAssociationClass.
+ */
+ protected Action getActionAssociationClass() {
+ if (actionAssociationClass == null) {
+ actionAssociationClass =
+ makeCreateAssociationClassAction(
+ "button.new-associationclass");
+ }
+ return actionAssociationClass;
+ }
+ /**
+ * @return Returns the actionComposition.
+ */
+ protected Action getActionComposition() {
+ if (actionComposition == null) {
+ actionComposition =
+ makeCreateAssociationAction(
+ Model.getAggregationKind().getComposite(),
+ false, "button.new-composition");
+ }
+ return actionComposition;
+ }
+
+ /**
+ * @return Returns the actionDepend.
+ */
+ protected Action getActionDependency() {
+ if (actionDependency == null) {
+ actionDependency = makeCreateDependencyAction(
+ ModeCreateDependency.class,
+ Model.getMetaTypes().getDependency(),
+ "button.new-dependency");
+ }
+ return actionDependency;
+ }
+
+ /**
+ * @return Returns the actionGeneralize.
+ */
+ protected Action getActionGeneralization() {
+ if (actionGeneralization == null) {
+ actionGeneralization = makeCreateGeneralizationAction();
+ }
+
+ return actionGeneralization;
+ }
+
+ /**
+ * @return Returns the actionInterface.
+ */
+ protected Action getActionInterface() {
+ if (actionInterface == null) {
+ actionInterface =
+ makeCreateNodeAction(
+ Model.getMetaTypes().getInterface(),
+ "button.new-interface");
+ }
+ return actionInterface;
+ }
+
+ /**
+ * @return Returns the actionLink.
+ */
+ protected Action getActionLink() {
+ if (actionLink == null) {
+ actionLink =
+ makeCreateEdgeAction(Model.getMetaTypes().getLink(), "Link");
+ }
+
+ return actionLink;
+ }
+ /**
+ * @return Returns the actionModel.
+ */
+ protected Action getActionModel() {
+ if (actionModel == null) {
+ actionModel =
+ makeCreateNodeAction(Model.getMetaTypes().getModel(), "Model");
+ }
+
+ return actionModel;
+ }
+
+ /**
+ * @return Returns the actionPackage.
+ */
+ protected Action getActionPackage() {
+ if (actionPackage == null) {
+ actionPackage =
+ makeCreateNodeAction(Model.getMetaTypes().getPackage(),
+ "button.new-package");
+ }
+
+ return actionPackage;
+ }
+ /**
+ * @return Returns the actionPermission.
+ */
+ protected Action getActionPermission() {
+ if (actionPermission == null) {
+ actionPermission = makeCreateDependencyAction(
+ ModeCreatePermission.class,
+ Model.getMetaTypes().getPackageImport(),
+ "button.new-permission");
+ }
+
+ return actionPermission;
+ }
+
+ /**
+ * @return Returns the actionRealize.
+ */
+ protected Action getActionRealization() {
+ if (actionRealization == null) {
+ actionRealization =
+ makeCreateEdgeAction(
+ Model.getMetaTypes().getAbstraction(),
+ "button.new-realization");
+ }
+
+ return actionRealization;
+ }
+
+ /**
+ * @return Returns the actionSubsystem.
+ */
+ protected Action getActionSubsystem() {
+ if (actionSubsystem == null) {
+ actionSubsystem =
+ makeCreateNodeAction(
+ Model.getMetaTypes().getSubsystem(),
+ "Subsystem");
+ }
+ return actionSubsystem;
+ }
+
+ /**
+ * @return Returns the actionUniAggregation.
+ */
+ protected Action getActionUniAggregation() {
+ if (actionUniAggregation == null) {
+ actionUniAggregation =
+ makeCreateAssociationAction(
+ Model.getAggregationKind().getAggregate(),
+ true,
+ "button.new-uniaggregation");
+ }
+ return actionUniAggregation;
+ }
+
+ /**
+ * @return Returns the actionUniAssociation.
+ */
+ protected Action getActionUniAssociation() {
+ if (actionUniAssociation == null) {
+ actionUniAssociation =
+ makeCreateAssociationAction(
+ Model.getAggregationKind().getNone(),
+ true,
+ "button.new-uniassociation");
+ }
+ return actionUniAssociation;
+ }
+
+ /**
+ * @return Returns the actionUniComposition.
+ */
+ protected Action getActionUniComposition() {
+ if (actionUniComposition == null) {
+ actionUniComposition =
+ makeCreateAssociationAction(
+ Model.getAggregationKind().getComposite(),
+ true,
+ "button.new-unicomposition");
+ }
+ return actionUniComposition;
+ }
+
+ /**
+ * @return Returns the actionUsage.
+ */
+ protected Action getActionUsage() {
+ if (actionUsage == null) {
+ actionUsage = makeCreateDependencyAction(
+ ModeCreateUsage.class,
+ Model.getMetaTypes().getUsage(),
+ "button.new-usage");
+ }
+ return actionUsage;
+ }
+
+ /**
+ * @return Returns the actionDataType.
+ */
+ private Action getActionDataType() {
+ if (actionDataType == null) {
+ actionDataType =
+ makeCreateNodeAction(Model.getMetaTypes().getDataType(),
+ "button.new-datatype");
+ }
+ return actionDataType;
+ }
+
+ /**
+ * @return Returns the actionEnumeration.
+ */
+ private Action getActionEnumeration() {
+ if (actionEnumeration == null) {
+ actionEnumeration =
+ makeCreateNodeAction(Model.getMetaTypes().getEnumeration(),
+ "button.new-enumeration");
+ }
+ return actionEnumeration;
+ }
+
+ /**
+ * @return Returns the actionStereotype.
+ */
+ private Action getActionStereotype() {
+ if (actionStereotype == null) {
+ actionStereotype =
+ makeCreateNodeAction(Model.getMetaTypes().getStereotype(),
+ "button.new-stereotype");
+ }
+ return actionStereotype;
+ }
+
+ /**
+ * @return Returns the actionStereotype.
+ */
+ private Action getActionSignal() {
+ if (actionSignal == null) {
+ actionSignal =
+ makeCreateNodeAction(Model.getMetaTypes().getSignal(),
+ "button.new-signal");
+ }
+ return actionSignal;
+ }
+
+ /**
+ * @return Returns the actionStereotype.
+ */
+ private Action getActionException() {
+ if (actionException == null) {
+ actionException =
+ makeCreateNodeAction(Model.getMetaTypes().getException(),
+ "button.new-exception");
+ }
+ return actionException;
+ }
+ /*
+ * @see org.argouml.uml.diagram.ui.UMLDiagram#isRelocationAllowed(java.lang.Object)
+ */
+ public boolean isRelocationAllowed(Object base) {
+ return Model.getFacade().isANamespace(base);
+ }
+
+ public Collection getRelocationCandidates(Object root) {
+ return
+ Model.getModelManagementHelper().getAllModelElementsOfKindWithModel(
+ root, Model.getMetaTypes().getNamespace());
+ }
+
+ /*
+ * @see org.argouml.uml.diagram.ui.UMLDiagram#relocate(java.lang.Object)
+ */
+ public boolean relocate(Object base) {
+ setNamespace(base);
+ damage();
+ return true;
+ }
+
+ public void encloserChanged(FigNode enclosed, FigNode oldEncloser,
+ FigNode newEncloser) {
+ // Do nothing.
+ }
+
+ @Override
+ public boolean doesAccept(Object objectToAccept) {
+ if (Model.getFacade().isAClass(objectToAccept)) {
+ return true;
+ } else if (Model.getFacade().isAInterface(objectToAccept)) {
+ return true;
+ } else if (Model.getFacade().isAModel(objectToAccept)) {
+ return true;
+ } else if (Model.getFacade().isASubsystem(objectToAccept)) {
+ return true;
+ } else if (Model.getFacade().isAPackage(objectToAccept)) {
+ return true;
+ } else if (Model.getFacade().isAComment(objectToAccept)) {
+ return true;
+ } else if (Model.getFacade().isAAssociation(objectToAccept)) {
+ return true;
+ } else if (Model.getFacade().isAEnumeration(objectToAccept)) {
+ return true;
+ } else if (Model.getFacade().isADataType(objectToAccept)) {
+ return true;
+ } else if (Model.getFacade().isAStereotype(objectToAccept)) {
+ return true;
+ } else if (Model.getFacade().isAException(objectToAccept)) {
+ return true;
+ } else if (Model.getFacade().isASignal(objectToAccept)) {
+ return true;
+ } else if (Model.getFacade().isAActor(objectToAccept)) {
+ return true;
+ } else if (Model.getFacade().isAUseCase(objectToAccept)) {
+ return true;
+ } else if (Model.getFacade().isAObject(objectToAccept)) {
+ return true;
+ } else if (Model.getFacade().isANodeInstance(objectToAccept)) {
+ return true;
+ } else if (Model.getFacade().isAComponentInstance(objectToAccept)) {
+ return true;
+ } else if (Model.getFacade().isANode(objectToAccept)) {
+ return true;
+ } else if (Model.getFacade().isAComponent(objectToAccept)) {
+ return true;
+ }
+ return false;
+
+ }
+
+ @Override
+ public FigNode drop(Object droppedObject, Point location) {
+ FigNode figNode = null;
+
+ // If location is non-null, convert to a rectangle that we can use
+ Rectangle bounds = null;
+ if (location != null) {
+ bounds = new Rectangle(location.x, location.y, 0, 0);
+ }
+
+ DiagramSettings settings = getDiagramSettings();
+
+ if (Model.getFacade().isAAssociation(droppedObject)) {
+ figNode =
+ createNaryAssociationNode(droppedObject, bounds, settings);
+ } else if (Model.getFacade().isAClass(droppedObject)) {
+ figNode = new FigClass(droppedObject, bounds, settings);
+ } else if (Model.getFacade().isAInterface(droppedObject)) {
+ figNode = new FigInterface(droppedObject, bounds, settings);
+ } else if (Model.getFacade().isAModel(droppedObject)) {
+ figNode = new FigModel(droppedObject, bounds, settings);
+ } else if (Model.getFacade().isASubsystem(droppedObject)) {
+ figNode = new FigSubsystem(droppedObject, bounds, settings);
+ } else if (Model.getFacade().isAPackage(droppedObject)) {
+ figNode = new FigPackage(droppedObject, bounds, settings);
+ } else if (Model.getFacade().isAComment(droppedObject)) {
+ figNode = new FigComment(droppedObject, bounds, settings);
+ } else if (Model.getFacade().isAEnumeration(droppedObject)) {
+ figNode = new FigEnumeration(droppedObject, bounds, settings);
+ } else if (Model.getFacade().isADataType(droppedObject)) {
+ figNode = new FigDataType(droppedObject, bounds, settings);
+ } else if (Model.getFacade().isAStereotype(droppedObject)) {
+ figNode = new FigStereotypeDeclaration(droppedObject, bounds,
+ settings);
+ } else if (Model.getFacade().isAException(droppedObject)) {
+ figNode = new FigException(droppedObject, bounds, settings);
+ } else if (Model.getFacade().isASignal(droppedObject)) {
+ figNode = new FigSignal(droppedObject, bounds, settings);
+ } else if (Model.getFacade().isAActor(droppedObject)) {
+ figNode = new FigActor(droppedObject, bounds, settings);
+ } else if (Model.getFacade().isAUseCase(droppedObject)) {
+ figNode = new FigUseCase(droppedObject, bounds, settings);
+ } else if (Model.getFacade().isAObject(droppedObject)) {
+ figNode = new FigObject(droppedObject, bounds, settings);
+ } else if (Model.getFacade().isANodeInstance(droppedObject)) {
+ figNode = new FigNodeInstance(droppedObject, bounds, settings);
+ } else if (Model.getFacade().isAComponentInstance(droppedObject)) {
+ figNode = new FigComponentInstance(droppedObject, bounds, settings);
+ } else if (Model.getFacade().isANode(droppedObject)) {
+ figNode = new FigMNode(droppedObject, bounds, settings);
+ } else if (Model.getFacade().isAComponent(droppedObject)) {
+ figNode = new FigComponent(droppedObject, bounds, settings);
+ }
+
+ if (figNode != null) {
+ // if location is null here the position of the new figNode is set
+ // after in org.tigris.gef.base.ModePlace.mousePressed(MouseEvent e)
+ if (location != null) {
+ figNode.setLocation(location.x, location.y);
+ }
+ LOG.debug("Dropped object " + droppedObject + " converted to "
+ + figNode);
+ } else {
+ LOG.debug("Dropped object NOT added " + droppedObject);
+ }
+ return figNode;
+ }
+}
------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=2377900
To unsubscribe from this discussion, e-mail: [[email protected]].