svn commit: r16443 - trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui
Michiel van der Wulp <[email protected]>
| Newsgroups | gmane.comp.lang.uml.argouml.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: mvw
Date: 2008-12-27 09:45:59-0800
New Revision: 16443
Modified:
trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/FigTransition.java
trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/StateDiagramRenderer.java
Log:
Made the state diagram renderer use the new Fig constructors.
Made more conform Class diagrams.
Still to do: Comment Edge, other classes that construct Figs.
Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/FigTransition.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/FigTransition.java?view=diff&pathrev=16443&r1=16442&r2=16443
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/FigTransition.java (original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/FigTransition.java 2008-12-27 09:45:59-0800
@@ -35,6 +35,7 @@
import org.argouml.notation.NotationProviderFactory2;
import org.argouml.ui.ArgoJMenu;
import org.argouml.ui.targetmanager.TargetManager;
+import org.argouml.uml.diagram.DiagramSettings;
import org.argouml.uml.diagram.ui.FigEdgeModelElement;
import org.argouml.uml.diagram.ui.PathConvPercent2;
import org.argouml.uml.ui.behavior.common_behavior.ActionNewActionSequence;
@@ -69,14 +70,16 @@
/**
* The main constructor.
+ *
+ * @deprecated for 0.27.3 by mvw. Use
+ * {@link #FigTransition(Object, DiagramSettings)}.
*/
+ @SuppressWarnings("deprecation")
+ @Deprecated
public FigTransition() {
super();
- addPathItem(getNameFig(),
- new PathConvPercent2(this, getNameFig(), 50, 10));
- getFig().setLineColor(Color.black);
- setDestArrowHead(endArrow);
- allowRemoveFromDiagram(false);
+
+ initializeTransition();
}
/**
@@ -87,13 +90,17 @@
*
* @param edge the UML element
* @param lay the layer
+ *
+ * @deprecated for 0.27.3 by mvw. Use
+ * {@link #FigTransition(Object, DiagramSettings)}.
*/
+ @SuppressWarnings("deprecation")
+ @Deprecated
public FigTransition(Object edge, Layer lay) {
this();
if (Model.getFacade().isATransition(edge)) {
- Object tr = /* (MTransition) */edge;
- Object sourceSV = Model.getFacade().getSource(tr);
- Object destSV = Model.getFacade().getTarget(tr);
+ Object sourceSV = Model.getFacade().getSource(edge);
+ Object destSV = Model.getFacade().getTarget(edge);
FigNode sourceFN = (FigNode) lay.presentationFor(sourceSV);
FigNode destFN = (FigNode) lay.presentationFor(destSV);
setSourcePortFig(sourceFN);
@@ -104,6 +111,43 @@
setLayer(lay);
setOwner(edge);
}
+
+ /**
+ * Constructor used by PGML parser.
+ *
+ * @param owner owning uml element
+ * @param settings rendering settings
+ */
+ public FigTransition(Object owner, DiagramSettings settings) {
+ super(owner, settings);
+
+ initializeTransition();
+ }
+
+ private void initializeTransition() {
+ addPathItem(getNameFig(),
+ new PathConvPercent2(this, getNameFig(), 50, 10));
+ getFig().setLineColor(Color.black);
+ setDestArrowHead(endArrow);
+ allowRemoveFromDiagram(false);
+ }
+
+ @Override
+ public void setLayer(Layer lay) {
+ super.setLayer(lay);
+
+ /* This presumes that the layer is set after the owner: */
+ assert getOwner() != null;
+
+ Object sourceSV = Model.getFacade().getSource(getOwner());
+ Object destSV = Model.getFacade().getTarget(getOwner());
+ FigNode sourceFN = (FigNode) lay.presentationFor(sourceSV);
+ FigNode destFN = (FigNode) lay.presentationFor(destSV);
+ setSourcePortFig(sourceFN);
+ setSourceFigNode(sourceFN);
+ setDestPortFig(destFN);
+ setDestFigNode(destFN);
+ }
/*
* The Transition has a name text box. It contains:
@@ -223,8 +267,7 @@
*/
protected Object getDestination() {
if (getOwner() != null) {
- return Model.getStateMachinesHelper().getDestination(
- /* (Transition) */getOwner());
+ return Model.getStateMachinesHelper().getDestination(getOwner());
}
return null;
}
@@ -234,8 +277,7 @@
*/
protected Object getSource() {
if (getOwner() != null) {
- return Model.getStateMachinesHelper().getSource(
- /* (Transition) */getOwner());
+ return Model.getStateMachinesHelper().getSource(getOwner());
}
return null;
}
@@ -256,9 +298,4 @@
super.paintClarifiers(g);
}
- /**
- * The UID.
- */
- private static final long serialVersionUID = 2938247797781036110L;
-
} /* end class FigTransition */
Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/StateDiagramRenderer.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/StateDiagramRenderer.java?view=diff&pathrev=16443&r1=16442&r2=16443
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/StateDiagramRenderer.java (original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/state/ui/StateDiagramRenderer.java 2008-12-27 09:45:59-0800
@@ -29,6 +29,8 @@
import org.apache.log4j.Logger;
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.UmlDiagramRenderer;
import org.argouml.uml.diagram.static_structure.ui.FigEdgeNote;
import org.argouml.uml.diagram.ui.UMLDiagram;
@@ -80,6 +82,8 @@
public FigNode getFigNodeFor(GraphModel gm, Layer lay, Object node,
Map styleAttributes) {
+ assert node != null;
+
FigNode figNode = null;
// Although not generally true for GEF, for Argo we know that the layer
// is a LayerPerspective which knows the associated diagram
@@ -89,9 +93,11 @@
figNode = ((UMLDiagram) diag).drop(node, null);
} else {
LOG.debug("TODO: StateDiagramRenderer getFigNodeFor");
- return null;
+ throw new IllegalArgumentException(
+ "Node is not a recognised type. Received "
+ + node.getClass().getName());
}
-
+
lay.add(figNode);
return figNode;
}
@@ -103,22 +109,25 @@
*/
public FigEdge getFigEdgeFor(GraphModel gm, Layer lay, Object edge,
Map styleAttributes) {
- FigEdge figEdge = null;
+ assert edge != null;
+ assert lay instanceof LayerPerspective;
+
+ ArgoDiagram diag = (ArgoDiagram) ((LayerPerspective) lay).getDiagram();
+ DiagramSettings settings = diag.getDiagramSettings();
+ FigEdge newEdge = null;
if (Model.getFacade().isATransition(edge)) {
- figEdge = new FigTransition(edge, lay);
+ newEdge = new FigTransition(edge, settings);
} else if (edge instanceof CommentEdge) {
- figEdge = new FigEdgeNote(edge, lay);
- } else {
+ newEdge = new FigEdgeNote(edge, lay); // TODO -> settings
+ }
+ if (newEdge == null) {
LOG.debug("TODO: StateDiagramRenderer getFigEdgeFor");
return null;
}
-
- lay.add(figEdge);
- return figEdge;
- }
-
- static final long serialVersionUID = 8448809085349795886L;
+ lay.add(newEdge);
+ return newEdge;
+ }
}
------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=993805
To unsubscribe from this discussion, e-mail: [[email protected]].