Author: tfmorris
Date: 2008-11-22 15:54:28-0800
New Revision: 16142
Added:
trunk/src/argouml-app/src/org/argouml/uml/diagram/DiagramFactoryInterface2.java (contents, props changed)
Modified:
trunk/src/argouml-app/src/org/argouml/persistence/ArgoParser.java
trunk/src/argouml-app/src/org/argouml/persistence/DiagramMemberFilePersister.java
trunk/src/argouml-app/src/org/argouml/persistence/PGMLStackParser.java
trunk/src/argouml-app/src/org/argouml/uml/diagram/ArgoDiagram.java
trunk/src/argouml-app/src/org/argouml/uml/diagram/ArgoDiagramImpl.java
trunk/src/argouml-app/src/org/argouml/uml/diagram/DiagramFactory.java
trunk/src/argouml-app/src/org/argouml/uml/diagram/DiagramFactoryInterface.java (contents, props changed)
trunk/src/argouml-app/src/org/argouml/uml/diagram/DiagramUndoManager.java
trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ArgoFig.java
trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ArgoFigGroup.java
trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ArgoFigText.java
trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigAssociation.java
trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigAssociationEnd.java
trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigEdgeAssociationClass.java
trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigEdgeModelElement.java
trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigNodeModelElement.java
trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/UMLDiagram.java
trunk/src/argouml-app/src/org/argouml/uml/diagram/use_case/ui/FigExtend.java
trunk/src/argouml-app/src/org/argouml/uml/ui/ActionAddDiagram.java
Log:
Issue 5500: Add DiagramSettings to diagrams. Update APIs for Figs and Diagrams to reflect refactored functionality.
Modified: trunk/src/argouml-app/src/org/argouml/persistence/ArgoParser.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/persistence/ArgoParser.java?view=diff&rev=16142&p1=trunk/src/argouml-app/src/org/argouml/persistence/ArgoParser.java&p2=trunk/src/argouml-app/src/org/argouml/persistence/ArgoParser.java&r1=16141&r2=16142
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/persistence/ArgoParser.java (original)
+++ trunk/src/argouml-app/src/org/argouml/persistence/ArgoParser.java 2008-11-22 15:54:28-0800
@@ -31,6 +31,7 @@
import org.apache.log4j.Logger;
import org.argouml.kernel.Project;
import org.argouml.kernel.ProjectSettings;
+import org.argouml.uml.diagram.DiagramSettings;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
@@ -48,6 +49,8 @@
private Project project;
private ProjectSettings ps;
+
+ private DiagramSettings diagramDefaults;
private ArgoTokenTable tokens = new ArgoTokenTable();
@@ -112,6 +115,7 @@
LOG.info("== READING PROJECT " + theProject);
project = theProject;
ps = project.getProjectSettings();
+ diagramDefaults = ps.getDefaultDiagramSettings();
}
private void logError(String projectName, SAXException e) {
@@ -361,7 +365,7 @@
*/
protected void handleShowBoldNames(XMLElement e) {
String ug = e.getText().trim();
- ps.setShowBoldNames(ug);
+ diagramDefaults.setShowBoldNames(Boolean.getBoolean(ug));
}
/**
@@ -377,7 +381,7 @@
*/
protected void handleShowVisibility(XMLElement e) {
String showVisibility = e.getText().trim();
- ps.setShowVisibility(showVisibility);
+ diagramDefaults.setShowVisibility(Boolean.getBoolean(showVisibility));
}
/**
@@ -385,7 +389,8 @@
*/
protected void handleShowMultiplicity(XMLElement e) {
String showMultiplicity = e.getText().trim();
- ps.setShowMultiplicity(showMultiplicity);
+ diagramDefaults.setShowMultiplicity(
+ Boolean.getBoolean(showMultiplicity));
}
/**
@@ -393,7 +398,8 @@
*/
protected void handleShowInitialValue(XMLElement e) {
String showInitialValue = e.getText().trim();
- ps.setShowInitialValue(showInitialValue);
+ diagramDefaults.setShowInitialValue(
+ Boolean.getBoolean(showInitialValue));
}
/**
@@ -401,7 +407,7 @@
*/
protected void handleShowProperties(XMLElement e) {
String showproperties = e.getText().trim();
- ps.setShowProperties(showproperties);
+ diagramDefaults.setShowProperties(Boolean.getBoolean(showproperties));
}
/**
@@ -409,7 +415,7 @@
*/
protected void handleShowTypes(XMLElement e) {
String showTypes = e.getText().trim();
- ps.setShowTypes(showTypes);
+ diagramDefaults.setShowTypes(Boolean.getBoolean(showTypes));
}
/**
@@ -417,7 +423,7 @@
*/
protected void handleShowStereotypes(XMLElement e) {
String showStereotypes = e.getText().trim();
- ps.setShowStereotypes(showStereotypes);
+ diagramDefaults.setShowStereotypes(Boolean.getBoolean(showStereotypes));
}
/**
@@ -425,7 +431,8 @@
*/
protected void handleShowSingularMultiplicities(XMLElement e) {
String showSingularMultiplicities = e.getText().trim();
- ps.setShowSingularMultiplicities(showSingularMultiplicities);
+ diagramDefaults.setShowSingularMultiplicities(
+ Boolean.getBoolean(showSingularMultiplicities));
}
/**
@@ -433,7 +440,7 @@
*/
protected void handleDefaultShadowWidth(XMLElement e) {
String dsw = e.getText().trim();
- ps.setDefaultShadowWidth(dsw);
+ diagramDefaults.setDefaultShadowWidth(Integer.parseInt(dsw));
}
/**
@@ -441,7 +448,7 @@
*/
protected void handleFontName(XMLElement e) {
String dsw = e.getText().trim();
- ps.setFontName(dsw);
+ diagramDefaults.setFontName(dsw);
}
/**
@@ -450,7 +457,7 @@
protected void handleFontSize(XMLElement e) {
String dsw = e.getText().trim();
try {
- ps.setFontSize(Integer.parseInt(dsw));
+ diagramDefaults.setFontSize(Integer.parseInt(dsw));
} catch (NumberFormatException e1) {
LOG.error("NumberFormatException while parsing Font Size", e1);
}
@@ -461,7 +468,8 @@
*/
protected void handleShowAssociationNames(XMLElement e) {
String showAssociationNames = e.getText().trim();
- ps.setShowAssociationNames(showAssociationNames);
+ diagramDefaults.setShowAssociationNames(
+ Boolean.getBoolean(showAssociationNames));
}
/**
@@ -469,7 +477,10 @@
*/
protected void handleHideBidirectionalArrows(XMLElement e) {
String hideBidirectionalArrows = e.getText().trim();
- ps.setHideBidirectionalArrows(hideBidirectionalArrows);
+ // NOTE: For historical reasons true == hide, so we need to invert
+ // the sense of this
+ diagramDefaults.setShowBidirectionalArrows(!
+ Boolean.getBoolean(hideBidirectionalArrows));
}
Modified: trunk/src/argouml-app/src/org/argouml/persistence/DiagramMemberFilePersister.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/persistence/DiagramMemberFilePersister.java?view=diff&rev=16142&p1=trunk/src/argouml-app/src/org/argouml/persistence/DiagramMemberFilePersister.java&p2=trunk/src/argouml-app/src/org/argouml/persistence/DiagramMemberFilePersister.java&r1=16141&r2=16142
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/persistence/DiagramMemberFilePersister.java (original)
+++ trunk/src/argouml-app/src/org/argouml/persistence/DiagramMemberFilePersister.java 2008-11-22 15:54:28-0800
@@ -38,8 +38,9 @@
import org.argouml.application.api.Argo;
import org.argouml.kernel.Project;
import org.argouml.kernel.ProjectMember;
+import org.argouml.uml.diagram.ArgoDiagram;
+import org.argouml.uml.diagram.DiagramSettings;
import org.argouml.uml.diagram.ProjectMemberDiagram;
-import org.tigris.gef.base.Diagram;
import org.tigris.gef.ocl.ExpansionException;
import org.tigris.gef.ocl.OCLExpander;
import org.tigris.gef.ocl.TemplateReader;
@@ -65,8 +66,12 @@
// keyed by their UUID. This is used to allocate
// figs to their owner using the "href" attribute
// in PGML.
- PGMLStackParser parser = new PGMLStackParser(project.getUUIDRefs());
- Diagram d = parser.readDiagram(inputStream, false);
+ DiagramSettings defaultSettings =
+ project.getProjectSettings().getDefaultDiagramSettings();
+ // TODO: We need the project specific diagram settings here
+ PGMLStackParser parser = new PGMLStackParser(project.getUUIDRefs(),
+ defaultSettings);
+ ArgoDiagram d = parser.readArgoDiagram(inputStream, false);
inputStream.close();
project.addMember(d);
} catch (Exception e) {
Modified: trunk/src/argouml-app/src/org/argouml/persistence/PGMLStackParser.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/persistence/PGMLStackParser.java?view=diff&rev=16142&p1=trunk/src/argouml-app/src/org/argouml/persistence/PGMLStackParser.java&p2=trunk/src/argouml-app/src/org/argouml/persistence/PGMLStackParser.java&r1=16141&r2=16142
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/persistence/PGMLStackParser.java (original)
+++ trunk/src/argouml-app/src/org/argouml/persistence/PGMLStackParser.java 2008-11-22 15:54:28-0800
@@ -26,6 +26,8 @@
import java.awt.Rectangle;
import java.io.InputStream;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
@@ -34,13 +36,14 @@
import java.util.StringTokenizer;
import org.apache.log4j.Logger;
+import org.argouml.uml.diagram.ArgoDiagram;
import org.argouml.uml.diagram.AttributesCompartmentContainer;
+import org.argouml.uml.diagram.DiagramSettings;
import org.argouml.uml.diagram.ExtensionsCompartmentContainer;
import org.argouml.uml.diagram.OperationsCompartmentContainer;
import org.argouml.uml.diagram.PathContainer;
import org.argouml.uml.diagram.StereotypeContainer;
import org.argouml.uml.diagram.VisibilityContainer;
-import org.argouml.uml.diagram.activity.ui.FigPool;
import org.argouml.uml.diagram.ui.FigEdgeModelElement;
import org.argouml.uml.diagram.ui.FigEdgePort;
import org.tigris.gef.base.Diagram;
@@ -76,12 +79,17 @@
private LinkedHashMap<FigEdge, Object> modelElementsByFigEdge =
new LinkedHashMap<FigEdge, Object>(50);
+
+ private DiagramSettings diagramSettings;
/**
* Constructor.
* @param modelElementsByUuid a map of model elements indexed
* by a unique string identifier.
+ * @deprecated for 0.27.2 by tfmorris. Use
+ * {@link #PGMLStackParser(Map, DiagramSettings)}/
*/
+ @Deprecated
public PGMLStackParser(Map modelElementsByUuid) {
super(modelElementsByUuid);
// TODO: Use stylesheet to convert or wait till we use Fig
@@ -111,6 +119,22 @@
"org.argouml.uml.diagram.deployment.ui.FigMNodeInstance",
"org.argouml.uml.diagram.deployment.ui.FigNodeInstance");
}
+
+ /**
+ * Construct a PGML parser with the given HREF/Object map and default
+ * diagram settings.
+ *
+ * @param modelElementsByUuid map of HREF ids to objects used to associate
+ * Figs with their owning model elements
+ * @param defaultSettings default diagram settings to use for newly created
+ * diagram and its contained Figs
+ */
+ public PGMLStackParser(Map<String, Object> modelElementsByUuid,
+ DiagramSettings defaultSettings) {
+ // TODO: Move addTranslation here when deprecated constructor is removed
+ this(modelElementsByUuid);
+ diagramSettings = defaultSettings;
+ }
/*
* @see org.tigris.gef.persistence.pgml.HandlerFactory#getHandler(
@@ -295,9 +319,29 @@
}
}
}
+
+ /**
+ * Read and parse the input stream to create a new diagram and return it.
+ *
+ * @param is the input stream
+ * @param closeStream true to close the stream when parsing is complete
+ * @return the diagram created as a result of the parse
+ * @throws SAXException
+ */
+ public ArgoDiagram readArgoDiagram(InputStream is, boolean closeStream)
+ throws SAXException {
+
+ return (ArgoDiagram) readDiagram(is, closeStream);
+ }
+ @Override
public Diagram readDiagram(InputStream is, boolean closeStream)
throws SAXException {
+
+ // TODO: we really want to be able replace the initial content handler
+ // which is passed to SAX, but we can't do this without cloning a
+ // whole bunch of code because it's private in the super class.
+
Diagram d = super.readDiagram(is, closeStream);
attachEdges(d);
@@ -527,21 +571,119 @@
}
}
+ /**
+ * Construct a new instance of the named Fig with the owner represented
+ * by the given href and the bounds parsed from the PGML file. We look
+ * for constructors of the form Fig(Object owner, Rectangle
+ * bounds, DiagramSettings settings) which is typically used for subclasses
+ * of FigNodeModelElement, then Fig(Object owner, DiagramSettings settings)
+ * which is used for subclasses of FigEdgeModelElement.
+ * <p>
+ * If we fail to find any of the constructors that we know about, we'll
+ * call GEF's version of this method to see if it can find a constructor.
+ *
+ * @param className fully qualified name of class to instantiate
+ * @param href string representing UUID of owning element
+ * @param bounds position and size of figure
+ * @return
+ * @throws SAXException
+ * @see org.tigris.gef.persistence.pgml.PGMLStackParser#constructFig(java.lang.String, java.lang.String, java.awt.Rectangle)
+ */
@Override
protected Fig constructFig(String className, String href, Rectangle bounds)
throws SAXException {
Fig f = null;
-
- // TODO: This low level parser shouldn't have a dependency on a specific
- // activity diagram fig. Whatever is special about FigPool needs to
- // be represented by a core interface that we can look for. - tfm
- if (className.equals(FigPool.class.getName())) {
- f = new FigPool(bounds);
- } else {
+
+ try {
+ Class figClass = Class.forName(className);
+ for (Constructor constructor : figClass.getConstructors()) {
+ Class[] parameterTypes = constructor.getParameterTypes();
+ // FigNodeModelElements should match here
+ if (parameterTypes.length == 3
+ && parameterTypes[0].equals(Object.class)
+ && parameterTypes[1].equals(Rectangle.class)
+ && parameterTypes[2].equals(DiagramSettings.class)
+ ) {
+ Object parameters[] = new Object[3];
+ Object owner = null;
+ if (href != null) {
+ owner = findOwner(href);
+ }
+ parameters[0] = owner;
+ parameters[1] = bounds;
+ parameters[2] =
+ ((ArgoDiagram) getDiagram()).getDiagramSettings();
+
+ f = (Fig) constructor.newInstance(parameters);
+ }
+ // FigEdgeModelElements should match here (they have no bounds)
+ if (parameterTypes.length == 2
+ && parameterTypes[0].equals(Object.class)
+ && parameterTypes[1].equals(DiagramSettings.class)
+ ) {
+ Object parameters[] = new Object[2];
+ Object owner = null;
+ if (href != null) {
+ owner = findOwner(href);
+ }
+ parameters[0] = owner;
+ parameters[1] =
+ ((ArgoDiagram) getDiagram()).getDiagramSettings();
+
+ f = (Fig) constructor.newInstance(parameters);
+ }
+ }
+ } catch (ClassNotFoundException e) {
+ throw new SAXException(e);
+ } catch (IllegalAccessException e) {
+ throw new SAXException(e);
+ } catch (InstantiationException e) {
+ throw new SAXException(e);
+ } catch (InvocationTargetException e) {
+ throw new SAXException(e);
+ }
+
+ // Fall back to GEF's handling if we couldn't find an appropriate
+ // constructor
+ if (f == null) {
+ // TODO: Convert this to a warning or error when all the Figs
+ // have been upgraded.
+ LOG.debug("No ArgoUML constructor found for " + className
+ + " falling back to GEF's default constructors");
f = super.constructFig(className, href, bounds);
}
-
+
return f;
}
+
+ /**
+ * Save the newly created Diagram for use by the parser. We take the
+ * opportunity to attach our default diagram settings to it so we'll have
+ * them if needed when constructing Figs.
+ * <p>
+ * Diagrams are created in GEF's PGMLHandler.initDiagram() which is private
+ * and can't be overridden. Initialization sequence is:<ul>
+ * <li>load diagram class using name in PGML file
+ * <li>instantiate using 0-arg constructor
+ * <li>invoke this method (setDiagram(<newDiagramInstance))
+ * <li>invoke diagram's initialize(Object owner) method
+ * <li>diagram.setName()
+ * <li>diagram.setScale()
+ * <li>diagram.setShowSingleMultiplicity()
+ * (?!why does GEF care about multiplicity?!)
+ * </ul>
+ * @param diagram the new diagram
+ * @see org.tigris.gef.persistence.pgml.PGMLStackParser#setDiagram(org.tigris.gef.base.Diagram)
+ */
+ @Override
+ public void setDiagram(Diagram diagram) {
+ // TODO: We could generalize this to initialize more stuff if needed
+ ((ArgoDiagram) diagram).setDiagramSettings(diagramSettings);
+ super.setDiagram(diagram);
+ }
+
+ public DiagramSettings getDiagramSettings() {
+ return diagramSettings;
+ }
}
Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/ArgoDiagram.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/ArgoDiagram.java?view=diff&rev=16142&p1=trunk/src/argouml-app/src/org/argouml/uml/diagram/ArgoDiagram.java&p2=trunk/src/argouml-app/src/org/argouml/uml/diagram/ArgoDiagram.java&r1=16141&r2=16142
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/ArgoDiagram.java (original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/ArgoDiagram.java 2008-11-22 15:54:28-0800
@@ -32,6 +32,8 @@
import java.util.Iterator;
import java.util.List;
+import org.argouml.application.events.ArgoDiagramAppearanceEventListener;
+import org.argouml.application.events.ArgoNotationEventListener;
import org.argouml.kernel.Project;
import org.argouml.util.ItemUID;
import org.tigris.gef.base.LayerPerspective;
@@ -52,8 +54,21 @@
* @author Tom Morris <[email protected]>
* @since 0.25.4 when it replaced the implementation class of the same name
*/
-public interface ArgoDiagram {
+public interface ArgoDiagram extends ArgoNotationEventListener,
+ ArgoDiagramAppearanceEventListener {
+ /**
+ * Set the rendering settings for this diagram.
+ *
+ * @param settings the new diagram settings
+ */
+ public void setDiagramSettings(DiagramSettings settings);
+
+ /**
+ * @return the current DiagramSettings object
+ */
+ public DiagramSettings getDiagramSettings();
+
/*
* @see org.tigris.gef.base.Diagram#setName(java.lang.String)
*/
@@ -268,6 +283,7 @@
*/
@Deprecated
public Enumeration elements();
+
/**
* @param listener
* @see org.tigris.gef.base.Diagram#addVetoableChangeListener(VetoableChangeListener)
Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/ArgoDiagramImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/ArgoDiagramImpl.java?view=diff&rev=16142&p1=trunk/src/argouml-app/src/org/argouml/uml/diagram/ArgoDiagramImpl.java&p2=trunk/src/argouml-app/src/org/argouml/uml/diagram/ArgoDiagramImpl.java&r1=16141&r2=16142
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/ArgoDiagramImpl.java (original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/ArgoDiagramImpl.java 2008-11-22 15:54:28-0800
@@ -32,13 +32,20 @@
import java.util.List;
import org.apache.log4j.Logger;
+import org.argouml.application.events.ArgoDiagramAppearanceEvent;
+import org.argouml.application.events.ArgoEventPump;
+import org.argouml.application.events.ArgoEventTypes;
+import org.argouml.application.events.ArgoNotationEvent;
import org.argouml.kernel.Project;
+import org.argouml.kernel.ProjectManager;
import org.argouml.model.CoreHelper;
import org.argouml.model.DeleteInstanceEvent;
+import org.argouml.model.InvalidElementException;
import org.argouml.model.Model;
import org.argouml.model.ModelManagementHelper;
import org.argouml.uml.diagram.activity.ui.FigPool;
import org.argouml.uml.diagram.static_structure.ui.FigComment;
+import org.argouml.uml.diagram.ui.ArgoFig;
import org.argouml.uml.diagram.ui.FigEdgeModelElement;
import org.argouml.uml.diagram.ui.FigNodeModelElement;
import org.argouml.util.EnumerationIterator;
@@ -46,6 +53,8 @@
import org.argouml.util.ItemUID;
import org.tigris.gef.base.Diagram;
import org.tigris.gef.base.Editor;
+import org.tigris.gef.base.LayerPerspective;
+import org.tigris.gef.graph.GraphModel;
import org.tigris.gef.graph.MutableGraphSupport;
import org.tigris.gef.presentation.Fig;
import org.tigris.gef.presentation.FigEdge;
@@ -82,52 +91,99 @@
private ItemUID id;
/**
- * Logger.
+ * The project this diagram is contained in.
*/
+ private Project project;
+
+ protected Object namespace;
+
+ private DiagramSettings settings;
+
private static final Logger LOG = Logger.getLogger(ArgoDiagramImpl.class);
/**
- * The constructor.
+ * Default constructor. Used by PGML parser when diagram is first created.
+ * @deprecated for 0.27.2 by tfmorris. The 0-arg constructor of our sub
+ * classes will get called by the PGML parser, but this should not get
+ * propagated up the hierarchy. The GEF Diagram constructor implementation
+ * is going to provide defaults for all missing args anyway, so we should
+ * always use the fully specified 3-arg constructor.
*/
+ @Deprecated
public ArgoDiagramImpl() {
super();
- if (!(UndoManager.getInstance() instanceof DiagramUndoManager)) {
- UndoManager.setInstance(new DiagramUndoManager());
- LOG.info("Setting Diagram undo manager");
- } else {
- LOG.info("Diagram undo manager already set");
- }
+
+ // TODO: What is this trying to do? It's never going to get called - tfm
// really dirty hack to remove unwanted listeners
getLayer().getGraphModel().removeGraphEventListener(getLayer());
+
+ constructorInit();
}
-
- /**
- * The project this diagram is contained in.
- */
- private Project project;
- protected Object namespace;
/**
* The constructor.
*
* @param diagramName the name of the diagram
+ * @deprecated for 0.27.2 by tfmorris. Use
+ * {@link #ArgoDiagramImpl(String, GraphModel, LayerPerspective)}.
*/
+ @Deprecated
public ArgoDiagramImpl(String diagramName) {
// next line patch to issue 596 (hopefully)
super(diagramName);
+ try {
+ setName(diagramName);
+ } catch (PropertyVetoException pve) { }
+ constructorInit();
+ }
+
+ /**
+ * Construct a new ArgoUML diagram. This is the preferred form of the
+ * constructor. If you don't know the name yet, make one up (because that's
+ * what the super classes constructors are going to do anyway).
+ *
+ * @param name the name of the new diagram
+ * @param graphModel graph model to associate with diagram
+ * @param layer layer to associate with diagram
+ * (use new LayerPerspective(name, graphModel)) if you need a default
+ */
+ public ArgoDiagramImpl(String name, GraphModel graphModel,
+ LayerPerspective layer) {
+ super(name, graphModel, layer);
+ // TODO: Do we really need to do this? Carried over from old behavior
+ try {
+ setName(name);
+ } catch (PropertyVetoException pve) {
+ }
+ constructorInit();
+ }
+
+ /**
+ * Finish initialization which is common to multiple constructors which
+ * don't invoke each other.
+ */
+ private void constructorInit() {
+ // TODO: These should get replaced immediately by the creating
+ // initialization code, but make sure we've got a default just in case.
+ settings = ProjectManager.getManager().getCurrentProject()
+ .getProjectSettings().getDefaultDiagramSettings();
+ // TODO: we should be given an Undo manager to use rather than looking
+ // for a global one
if (!(UndoManager.getInstance() instanceof DiagramUndoManager)) {
UndoManager.setInstance(new DiagramUndoManager());
LOG.info("Setting Diagram undo manager");
} else {
LOG.info("Diagram undo manager already set");
}
- try {
- setName(diagramName);
- } catch (PropertyVetoException pve) { }
- }
-
+ // Register for notification of any global changes that would affect
+ // our rendering
+ ArgoEventPump.addListener(ArgoEventTypes.ANY_NOTATION_EVENT, this);
+ ArgoEventPump.addListener(
+ ArgoEventTypes.ANY_DIAGRAM_APPEARANCE_EVENT, this);
+ }
+
public void setName(String n) throws PropertyVetoException {
super.setName(n);
@@ -546,4 +602,65 @@
return new EnumerationIterator(elements());
}
+ public void setDiagramSettings(DiagramSettings settings) {
+ settings = settings;
+ }
+
+ public DiagramSettings getDiagramSettings() {
+ return settings;
+ }
+
+ /**
+ * Handles a global change to the diagram font.
+ * @param e the event
+ * @see org.argouml.application.events.ArgoDiagramAppearanceEventListener#diagramFontChanged(org.argouml.application.events.ArgoDiagramAppearanceEvent)
+ */
+ public void diagramFontChanged(ArgoDiagramAppearanceEvent e) {
+ renderingChanged();
+ }
+
+ /**
+ * Rerender the entire diagram based on new global rendering settings.
+ * <p>
+ * NOTE: Figs which define their own presentation listeners will get
+ * re-rendered twice
+ */
+ public void renderingChanged() {
+ for (Object fig : getLayer().getContents()) {
+ try {
+ // This should always be true, but just in case...
+ if (fig instanceof ArgoFig) {
+ ((ArgoFig) fig).renderingChanged();
+ } else {
+ LOG.warn("Diagram " + getName() + " contains non-ArgoFig "
+ + fig);
+ }
+ } catch (InvalidElementException e) {
+ LOG.error("Tried to refresh deleted element ", e);
+ }
+ }
+ damage();
+ }
+
+ public void notationChanged(ArgoNotationEvent e) {
+ renderingChanged();
+ }
+
+ public void notationAdded(ArgoNotationEvent e) {
+ // Do nothing
+ }
+
+ public void notationProviderAdded(ArgoNotationEvent e) {
+ // Do nothing
+ }
+
+ public void notationProviderRemoved(ArgoNotationEvent e) {
+ // Do nothing
+ }
+
+
+ public void notationRemoved(ArgoNotationEvent e) {
+ // Do nothing
+ }
+
}
Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/DiagramFactory.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/DiagramFactory.java?view=diff&rev=16142&p1=trunk/src/argouml-app/src/org/argouml/uml/diagram/DiagramFactory.java&p2=trunk/src/argouml-app/src/org/argouml/uml/diagram/DiagramFactory.java&r1=16141&r2=16142
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/DiagramFactory.java (original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/DiagramFactory.java 2008-11-22 15:54:28-0800
@@ -28,6 +28,7 @@
import java.util.HashMap;
import java.util.Map;
+import org.argouml.kernel.ProjectManager;
import org.argouml.model.ActivityDiagram;
import org.argouml.model.ClassDiagram;
import org.argouml.model.CollaborationDiagram;
@@ -78,8 +79,11 @@
Class, UseCase, State, Deployment, Collaboration, Activity, Sequence
}
- private Map<DiagramType, DiagramFactoryInterface> factories =
- new EnumMap<DiagramType, DiagramFactoryInterface>(DiagramType.class);
+ private Map<DiagramType, Object> factories =
+ new EnumMap<DiagramType, Object>(DiagramType.class);
+ // TODO: This can be typed again when the deprecation period has expired
+// private Map<DiagramType, DiagramFactoryInterface2> factories =
+// new EnumMap<DiagramType, DiagramFactoryInterface2>(DiagramType.class);
private DiagramFactory() {
super();
@@ -122,20 +126,66 @@
* @param machine The StateMachine for the diagram
* (only: statemachine - activitygraph)
* @return the newly instantiated class diagram
+ * @deprecated for 0.27.3 by tfmorris. Use
+ * {@link #createDiagram(DiagramType, Object, Object, DiagramSettings)}.
*/
- public ArgoDiagram createDiagram(
- final DiagramType type,
- final Object namespace,
- final Object machine) {
+ @Deprecated
+ public ArgoDiagram createDiagram(final DiagramType type,
+ final Object namespace, final Object machine) {
+
+ DiagramSettings settings = ProjectManager.getManager()
+ .getCurrentProject().getProjectSettings()
+ .getDefaultDiagramSettings();
- DiagramFactoryInterface factory = factories.get(type);
+ final ArgoDiagram diagram;
+
+ Object factory = factories.get(type);
if (factory != null) {
- final ArgoDiagram diagram =
- factory.createDiagram(namespace, machine);
- return diagram;
+ if (factory instanceof DiagramFactoryInterface2) {
+ diagram = ((DiagramFactoryInterface2) factory).createDiagram(
+ machine, null, settings);
+ } else {
+ diagram = ((DiagramFactoryInterface) factory).createDiagram(
+ namespace, machine);
+ diagram.setDiagramSettings(settings);
+ }
+ } else {
+ diagram = createDiagram(diagramClasses.get(type), namespace,
+ machine);
+ diagram.setDiagramSettings(settings);
+ }
+
+ return diagram;
+ }
+
+ /**
+ * Factory method to create a new instance of an ArgoDiagram.
+ *
+ * @param type The class of rendering diagram to create
+ * @param owner the owning UML element. For most diagrams this is a
+ * namespace, but for the state diagram it is the state machine
+ * and for the activity diagram it is the context.
+ * @param settings default rendering settings for the diagram
+ * @return the newly instantiated class diagram
+ */
+ public ArgoDiagram createDiagram(
+ final DiagramType type,
+ final Object owner,
+ final DiagramSettings settings) {
+
+ final ArgoDiagram diagram;
+
+ Object factory = factories.get(type);
+ if (factory != null && factory instanceof DiagramFactoryInterface2) {
+ diagram = ((DiagramFactoryInterface2) factory).createDiagram(owner,
+ null, settings);
} else {
- return createDiagram(diagramClasses.get(type), namespace, machine);
+ // TODO: Convert all to use standard factory registration
+ diagram = createDiagram(diagramClasses.get(type), owner, null);
+ diagram.setDiagramSettings(settings);
}
+
+ return diagram;
}
/**
@@ -148,7 +198,7 @@
* (only: statemachine - activitygraph)
* @return the newly instantiated class diagram
* @deprecated for 0.25.4 by tfmorris. Use
- * {@link #createDiagram(DiagramType, Object, Object)}.
+ * {@link #createDiagram(DiagramType, Object, Object, DiagramSettings)}.
*/
@Deprecated
public ArgoDiagram createDiagram(Class type, Object namespace,
@@ -157,6 +207,7 @@
ArgoDiagram diagram = null;
Class diType = null;
+ // TODO: Convert all to use standard factory registration
if (type == UMLClassDiagram.class) {
diagram = new UMLClassDiagram(namespace);
diType = ClassDiagram.class;
@@ -202,10 +253,10 @@
}
/**
- * Factory method to create a new instance of a Class Diagram.
+ * Factory method to remove a diagram.
*
* @param diagram the diagram
- * @return the newly instantiated class diagram
+ * @return the diagram that was removed
*/
public ArgoDiagram removeDiagram(ArgoDiagram diagram) {
@@ -236,10 +287,25 @@
* specific diagram type
* @param type the diagram type
* @param factory the factory instance
+ * @deprecated for 0.27.3 by tfmorris. Use
+ * {@link #registerDiagramFactory(DiagramType, DiagramFactoryInterface2)}.
*/
+ @Deprecated
public void registerDiagramFactory(
final DiagramType type,
final DiagramFactoryInterface factory) {
factories.put(type, factory);
}
+
+ /**
+ * Register a specific factory class to create diagram instances for a
+ * specific diagram type
+ * @param type the diagram type
+ * @param factory the factory instance
+ */
+ public void registerDiagramFactory(
+ final DiagramType type,
+ final DiagramFactoryInterface2 factory) {
+ factories.put(type, factory);
+ }
}
Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/DiagramFactoryInterface.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/DiagramFactoryInterface.java?view=diff&rev=16142&p1=trunk/src/argouml-app/src/org/argouml/uml/diagram/DiagramFactoryInterface.java&p2=trunk/src/argouml-app/src/org/argouml/uml/diagram/DiagramFactoryInterface.java&r1=16141&r2=16142
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/DiagramFactoryInterface.java (original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/DiagramFactoryInterface.java 2008-11-22 15:54:28-0800
@@ -1,44 +1,51 @@
-// $Id: SequenceDiagramFactory.java 14988 2008-06-17 19:38:48Z bobtarling $
-// 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.uml.diagram;
-
-/**
- * An interface to be implemented by an factories for a specific diagram type.
- *
- * @author Bob Tarling
- */
-public interface DiagramFactoryInterface {
-
- /**
- * Factory method to create a new instance of an ArgoDiagram.
- *
- * @param namespace The namespace that (in)directly
- * owns the elements on the diagram
- * @param machine The StateMachine for the diagram
- * (only: statemachine - activitygraph)
- * @return the newly instantiated diagram
- */
- public ArgoDiagram createDiagram(Object namespace, final Object machine);
-}
+// $Id$
+// 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.uml.diagram;
+
+/**
+ * An interface to be implemented by an factories for a specific diagram type.
+ *
+ * @author Bob Tarling
+ * @deprecated for 0.27.3 by tfmorris. Use {@link DiagramFactoryInterface2}
+ * which provides the default diagram settings to the factory when
+ * the create method is invoked..
+ */
+@Deprecated
+public interface DiagramFactoryInterface {
+
+ /**
+ * Factory method to create a new instance of an ArgoDiagram.
+ *
+ * @param namespace The namespace that (in)directly
+ * owns the elements on the diagram
+ * @param machine The StateMachine for the diagram
+ * (only: statemachine - activitygraph)
+ * @return the newly instantiated diagram
+ * @deprecated for 0.27.3 by tfmorris. Use
+ * {@link DiagramFactoryInterface2#createDiagram(Object, Object, DiagramSettings)}.
+ */
+ @Deprecated
+ public ArgoDiagram createDiagram(Object namespace, final Object machine);
+}
Added: trunk/src/argouml-app/src/org/argouml/uml/diagram/DiagramFactoryInterface2.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/DiagramFactoryInterface2.java?view=auto&rev=16142
==============================================================================
--- (empty file)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/DiagramFactoryInterface2.java 2008-11-22 15:54:28-0800
@@ -0,0 +1,47 @@
+// $Id$
+// 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.uml.diagram;
+
+/**
+ * An interface to be implemented by factories for a specific diagram type.
+ *
+ * @since 0.27.3 when it replaced DiagramFactoryInterface
+ */
+public interface DiagramFactoryInterface2 {
+
+ /**
+ * Factory method to create a new instance of an ArgoDiagram.
+ *
+ * @param owner the owning element. This can be the owning namespace for a
+ * Class diagram or an owning Statemachine for a State Diagram or
+ * any other interpretation that the diagram type wants to apply.
+ * @param name the name of the diagram. This may be null if the caller would
+ * like the factory to provide a default name.
+ * @param settings default rendering settings for the diagram
+ * @return the newly instantiated diagram
+ */
+ public ArgoDiagram createDiagram(final Object owner, final String name,
+ DiagramSettings settings);
+}
Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/DiagramUndoManager.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/DiagramUndoManager.java?view=diff&rev=16142&p1=trunk/src/argouml-app/src/org/argouml/uml/diagram/DiagramUndoManager.java&p2=trunk/src/argouml-app/src/org/argouml/uml/diagram/DiagramUndoManager.java&r1=16141&r2=16142
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/DiagramUndoManager.java (original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/DiagramUndoManager.java 2008-11-22 15:54:28-0800
@@ -36,7 +36,9 @@
* This class is a temporary wrapper around the GEF UndoManager.
* This will be changed when GEF is modified to create commands and
* provide an observer interface for ArgoUML to receive them.
- *
+ * <p>
+ * TODO: How does this relate to {@link org.argouml.kernel.DefaultUndoManager}?
+ *
* @author Bob Tarling
*/
public class DiagramUndoManager extends UndoManager {
@@ -54,24 +56,39 @@
startChain = true;
}
+
+ @Override
+ public boolean isGenerateMementos() {
+ // TODO: This shouldn't depend on the current project, but for now
+ // just make sure it's defined and that we have an undo manager
+ Project p = ProjectManager.getManager().getCurrentProject();
+ return super.isGenerateMementos() && p != null
+ && p.getUndoManager() != null;
+ }
+
/**
* @param memento the GEF memento
* @see org.tigris.gef.undo.UndoManager#addMemento(org.tigris.gef.undo.Memento)
*/
@Override
public void addMemento(final Memento memento) {
+ // TODO: This shouldn't be referencing the current project. Instead
+ // the appropriate UndoManager should have already been retrieved from
+ // the correct project.
Project p = ProjectManager.getManager().getCurrentProject();
- org.argouml.kernel.UndoManager undo = p.getUndoManager();
+ if (p != null) {
+ org.argouml.kernel.UndoManager undo = p.getUndoManager();
+ if (undo != null) {
+ if (startChain) {
+ //TODO i18n: GEF needs to pass us back the description
+ // of what is being done.
+ undo.startInteraction("Diagram Interaction");
+ }
+ undo.addCommand(new DiagramCommand(memento));
- if (startChain) {
- //TODO i18n: GEF needs to pass us back the description of what is
- // being done.
- undo.startInteraction("Diagram Interaction");
+ startChain = false;
+ }
}
-
- undo.addCommand(new DiagramCommand(memento));
-
- startChain = false;
}
public void addPropertyChangeListener(PropertyChangeListener listener) {
Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ArgoFig.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ArgoFig.java?view=diff&rev=16142&p1=trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ArgoFig.java&p2=trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ArgoFig.java&r1=16141&r2=16142
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ArgoFig.java (original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ArgoFig.java 2008-11-22 15:54:28-0800
@@ -25,6 +25,7 @@
package org.argouml.uml.diagram.ui;
import org.argouml.kernel.Project;
+import org.argouml.uml.diagram.DiagramSettings;
/**
* An interface that all ArgoUML Figs are required to interface. It provides a
@@ -53,8 +54,34 @@
/**
* Get the owning project for this fig.
*
- * @return the project
+ * @return the owning project
+ * @deprecated for 0.27.2 by tfmorris. Implementations should have all the
+ * information that they require in the DiagramSettings object.
*/
+ @Deprecated
public Project getProject();
+
+ /**
+ * Rerender the entire fig.
+ * <p>
+ * This may be an expensive operation for subclasses which are complex,
+ * so should be used sparingly. It is only intended to be used when
+ * some global change to the rendering defaults is made at the ArgoDiagram
+ * level.
+ */
+ public void renderingChanged();
+ /**
+ * @return the rendering settings for the Fig
+ */
+ public DiagramSettings getSettings();
+
+ /**
+ * Set the rendering settings to be used for this fig. Currently this
+ * normally will be a diagram-wide or project-wide settings object that is
+ * shared by all Figs.
+ *
+ * @param settings the rendering settings to use
+ */
+ public void setSettings(DiagramSettings settings);
}
Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ArgoFigGroup.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ArgoFigGroup.java?view=diff&rev=16142&p1=trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ArgoFigGroup.java&p2=trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ArgoFigGroup.java&r1=16141&r2=16142
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ArgoFigGroup.java (original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ArgoFigGroup.java 2008-11-22 15:54:28-0800
@@ -27,35 +27,66 @@
import java.util.List;
import org.argouml.kernel.Project;
+import org.argouml.uml.diagram.DiagramSettings;
+import org.tigris.gef.presentation.Fig;
import org.tigris.gef.presentation.FigGroup;
/**
* A Fig which contains other Figs. ArgoUMLs version of GEF's FigGroup. <p>
*
- * It implements the additional methods of the ArgoFig interface, which is
- * currently just a helper to figure out which project the Fig belongs to
- * (based on the GraphModel that contains it).t belongs to.
+ * It implements the additional methods of the ArgoFig interface.
*
* @author Tom Morris <[email protected]>
*/
public abstract class ArgoFigGroup extends FigGroup implements ArgoFig {
+ private DiagramSettings settings;
+
/**
- * The constructor. Create a FigGroup that knows about its Project.
+ * Default constructor.
+ * @deprecated for 0.27.3 by tfmorris. Use
+ * {@link #ArgoFigGroup(DiagramSettings)}.
*/
+ @Deprecated
public ArgoFigGroup() {
super();
}
/**
- * The constructor. Create a FigGroup that knows about its Project.
+ * Construct an empty FigGroup with the given DiagramSettings.
+ * object.
+ * @param renderSettings render settings to use
+ */
+ public ArgoFigGroup(DiagramSettings renderSettings) {
+ super();
+ settings = renderSettings;
+ }
+
+ /**
+ * Construct a FigGroup which contains the listed figs.
+ *
* @param arg0 the Figs that make up the Group
+ * @deprecated for 0.27.3 by tfmorris. Use
+ * {@link #ArgoFigGroup(List, DiagramSettings)}.
*/
- public ArgoFigGroup(List arg0) {
+ @Deprecated
+ public ArgoFigGroup(List<ArgoFig> arg0) {
super(arg0);
}
/**
+ * Construct a FigGroup with the given list of Figs and DiagramSettings
+ * object.
+ *
+ * @param figs the Figs that make up the Group
+ * @param renderSettings render settings to use
+ */
+ public ArgoFigGroup(List<ArgoFig> figs, DiagramSettings renderSettings) {
+ super(figs);
+ settings = renderSettings;
+ }
+
+ /**
* This optional method is not implemented. It will throw an
* {@link UnsupportedOperationException} if used. Figs are
* added to a GraphModel which is, in turn, owned by a project.<p>
@@ -70,13 +101,43 @@
}
/**
- * This method is identical to the one in FigNodeModelElement.
+ * @deprecated for 0.27.2 by tfmorris. Implementations should have all
+ * the information that they require in the DiagramSettings object.
*
- * @return the project
+ * @return the owning project
* @see org.argouml.uml.diagram.ui.ArgoFig#getProject()
*/
+ @SuppressWarnings("deprecation")
+ @Deprecated
public Project getProject() {
return ArgoFigUtil.getProject(this);
}
+
+ public void renderingChanged() {
+ // Get all our sub Figs and hit them with the big stick too
+ for (Fig fig : (List<Fig>) getFigs()) {
+ if (fig instanceof ArgoFig) {
+ ((ArgoFig) fig).renderingChanged();
+ }
+ }
+ }
+
+
+ public DiagramSettings getSettings() {
+ // TODO: This is a temporary crutch to use until all Figs are updated
+ // to use the constructor that accepts a DiagramSettings object
+ if (settings == null) {
+ Project p = getProject();
+ if (p != null) {
+ return p.getProjectSettings().getDefaultDiagramSettings();
+ }
+ }
+ return settings;
+ }
+
+ public void setSettings(DiagramSettings renderSettings) {
+ settings = renderSettings;
+ renderingChanged();
+ }
}
Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ArgoFigText.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ArgoFigText.java?view=diff&rev=16142&p1=trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ArgoFigText.java&p2=trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ArgoFigText.java&r1=16141&r2=16142
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ArgoFigText.java (original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/ArgoFigText.java 2008-11-22 15:54:28-0800
@@ -25,6 +25,7 @@
package org.argouml.uml.diagram.ui;
import java.awt.Font;
+import java.awt.Rectangle;
import java.beans.PropertyChangeEvent;
import javax.management.ListenerNotFoundException;
@@ -38,6 +39,7 @@
import org.argouml.application.events.ArgoDiagramAppearanceEvent;
import org.argouml.kernel.Project;
import org.argouml.model.Model;
+import org.argouml.uml.diagram.DiagramSettings;
import org.tigris.gef.presentation.FigText;
/**
@@ -51,6 +53,8 @@
private NotificationBroadcasterSupport notifier =
new NotificationBroadcasterSupport();
+ private DiagramSettings settings;
+
/**
* The constructor.
*
@@ -58,7 +62,10 @@
* @param y initial location
* @param w initial width
* @param h initial height
+ * @deprecated 0.27.2 by tfmorris. Uses one of the constructors which takes
+ * a DiagramSettings.
*/
+ @Deprecated
public ArgoFigText(int x, int y, int w, int h) {
super(x, y, w, h);
setFontFamily("dialog");
@@ -72,12 +79,33 @@
* @param w initial width
* @param h initial height
* @param expandOnly true if this fig is supposed to grow only
+ * @deprecated 0.27.2 by tfmorris. Uses one of the constructors which takes
+ * a DiagramSettings.
*/
+ @Deprecated
public ArgoFigText(int x, int y, int w, int h, boolean expandOnly) {
super(x, y, w, h, expandOnly);
setFontFamily("dialog"); /* TODO: Is this needed?*/
}
+ /**
+ * Construct a text fig owned by the given UML element.
+ *
+ * @param owner owning model element or null
+ * @param bounds rectangle describing bounds of figure
+ * @param renderSettings render settings
+ * @param expandOnly true if Fig should never shrink
+ */
+ public ArgoFigText(Object owner, Rectangle bounds,
+ DiagramSettings renderSettings, boolean expandOnly) {
+ this(bounds.x, bounds.y, bounds.width, bounds.height, expandOnly);
+ settings = renderSettings;
+ setFontFamily(settings.getFontName());
+ setFontSize(settings.getFontSize());
+ super.setOwner(owner);
+ Model.getPump().addModelEventListener(this, owner, "remove");
+ }
+
/*
* @see org.tigris.gef.presentation.Fig#deleteFromModel()
*/
@@ -135,19 +163,33 @@
throw new UnsupportedOperationException();
}
+ /**
+ * @return the owning project
+ * @see org.argouml.uml.diagram.ui.ArgoFig#getProject()
+ * @deprecated for 0.27.2 by tfmorris. Implementations should have all
+ * the information that they require in the DiagramSettings object.
+ */
+ @SuppressWarnings("deprecation")
+ @Deprecated
public Project getProject() {
return ArgoFigUtil.getProject(this);
}
+ public void renderingChanged() {
+ updateFont();
+ setBounds(getBounds());
+ damage();
+ }
+
/**
* Handles diagram font changing.
* @param e the event
+ * @deprecated for 0.27.2 by tfmorris. Use {@link #renderingChanged()}.
*/
+ @Deprecated
public void diagramFontChanged(
@SuppressWarnings("unused") ArgoDiagramAppearanceEvent e) {
- updateFont();
- setBounds(getBounds());
- damage();
+ renderingChanged();
}
/**
@@ -156,12 +198,7 @@
* and apply it by calling FigText.setFont().
*/
protected void updateFont() {
- int style = getFigFontStyle();
- Project p = getProject();
- if (p != null) {
- Font f = getProject().getProjectSettings().getFont(style);
- setFont(f);
- }
+ setFont(getSettings().getFont(getFigFontStyle()));
}
/**
@@ -176,12 +213,31 @@
return Font.PLAIN;
}
+ /**
+ * Set owning UML element.
+ *
+ * @param own uml element
+ * @see org.tigris.gef.presentation.Fig#setOwner(java.lang.Object)
+ * @deprecated for 0.27.3 by tfmorris. The owner must be specified in the
+ * constructor and never changed.
+ */
@Override
+ @Deprecated
public void setOwner(Object own) {
super.setOwner(own);
updateListeners(null, own);
}
+ /**
+ * Update listeners for a new owner. Obsolete since owner is not allow to
+ * change.
+ *
+ * @param oldOwner the old owner
+ * @param newOwner the new owner
+ * @deprecated for 0.27.3 by tfmorris. The owner must be specified in the
+ * constructor and never changed.
+ */
+ @Deprecated
protected void updateListeners(Object oldOwner, Object newOwner) {
if (oldOwner == newOwner) {
return;
@@ -202,5 +258,23 @@
deleteFromModel();
}
}
+
+
+ public DiagramSettings getSettings() {
+ // TODO: This is a temporary crutch to use until all Figs are updated
+ // to use the constructor that accepts a DiagramSettings object
+ if (settings == null) {
+ Project p = getProject();
+ if (p != null) {
+ return p.getProjectSettings().getDefaultDiagramSettings();
+ }
+ }
+ return settings;
+ }
+
+ public void setSettings(DiagramSettings renderSettings) {
+ settings = renderSettings;
+ renderingChanged();
+ }
}
Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigAssociation.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigAssociation.java?view=diff&rev=16142&p1=trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigAssociation.java&p2=trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigAssociation.java&r1=16141&r2=16142
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigAssociation.java (original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigAssociation.java 2008-11-22 15:54:28-0800
@@ -173,7 +173,7 @@
* @see org.argouml.uml.diagram.ui.FigEdgeModelElement#renderingChanged()
*/
@Override
- protected void renderingChanged() {
+ public void renderingChanged() {
/* This fixes issue 4987: */
srcMult.update();
destMult.update();
Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigAssociationEnd.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigAssociationEnd.java?view=diff&rev=16142&p1=trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigAssociationEnd.java&p2=trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigAssociationEnd.java&r1=16141&r2=16142
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigAssociationEnd.java (original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigAssociationEnd.java 2008-11-22 15:54:28-0800
@@ -254,7 +254,7 @@
* @see org.argouml.uml.diagram.ui.FigEdgeModelElement#renderingChanged()
*/
@Override
- protected void renderingChanged() {
+ public void renderingChanged() {
updateEnd(srcMult, srcOrdering);
srcMult.calcBounds();
srcGroup.calcBounds();
Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigEdgeAssociationClass.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigEdgeAssociationClass.java?view=diff&rev=16142&p1=trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigEdgeAssociationClass.java&p2=trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigEdgeAssociationClass.java&r1=16141&r2=16142
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigEdgeAssociationClass.java (original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigEdgeAssociationClass.java 2008-11-22 15:54:28-0800
@@ -169,6 +169,6 @@
super.setSourceFigNode(fn);
}
- protected void renderingChanged() {
+ public void renderingChanged() {
}
-} /* end class FigEdgeAssociationClass */
+}
Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigEdgeModelElement.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigEdgeModelElement.java?view=diff&rev=16142&p1=trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigEdgeModelElement.java&p2=trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigEdgeModelElement.java&r1=16141&r2=16142
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigEdgeModelElement.java (original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigEdgeModelElement.java 2008-11-22 15:54:28-0800
@@ -65,7 +65,6 @@
import org.argouml.kernel.DelayedChangeNotify;
import org.argouml.kernel.DelayedVChangeListener;
import org.argouml.kernel.Project;
-import org.argouml.kernel.ProjectSettings;
import org.argouml.model.AddAssociationEvent;
import org.argouml.model.AssociationChangeEvent;
import org.argouml.model.AttributeChangeEvent;
@@ -81,6 +80,7 @@
import org.argouml.ui.ProjectActions;
import org.argouml.ui.targetmanager.TargetManager;
import org.argouml.uml.StereotypeUtility;
+import org.argouml.uml.diagram.DiagramSettings;
import org.argouml.uml.ui.ActionDeleteModelElements;
import org.argouml.util.IItemUID;
import org.argouml.util.ItemUID;
@@ -101,6 +101,11 @@
* look like lines.
* This Fig is prepared to show a (possibly editable) name,
* and/or multiple stereotypes.
+ * <p>
+ * NOTE: This will drop the ArgoNotationEventListener and
+ * ArgoDiagramAppearanceEventListener
+ * interfaces in the next release. The corresponding methods have been marked
+ * as deprecated.
*/
public abstract class FigEdgeModelElement
extends FigEdgePoly
@@ -133,12 +138,12 @@
**/
private static int popupAddOffset;
- ////////////////////////////////////////////////////////////////
- // instance variables
private NotationProvider notationProviderName;
- private HashMap<String, Object> npArguments = new HashMap<String, Object>();
-
+ // TODO: Having a HashMap per Fig, each containing two string entries, just
+ // to store what is basically just a boolean (useGuillmets) is expensive
+ // Also, the opaqueness of the string keys prevents us finding uses
+ private HashMap<String, Object> npArguments;
/**
* The Fig that displays the name of this model element.
* Use getNameFig(), no setter should be required.
@@ -159,15 +164,34 @@
*/
private Set<Object[]> listeners = new HashSet<Object[]>();
- ////////////////////////////////////////////////////////////////
- // constructors
-
- /**
- * Partially construct a new FigEdge. This method creates the
- * name element that holds the name of the model element and adds
- * itself as a listener. Also a stereotype is constructed.
+ private DiagramSettings settings;
+
+ /**
+ * Construct a default FigEdgeElement.
+ *
+ * @deprecated for 0.27.2 by tfmorris. The default constructor will become
+ * private so that it can't be used externally. All concrete
+ * subclasses must invoke an explicit constructor which passes
+ * an owner and render s settings
+ * {@link #FigEdgeModelElement(Object, DiagramSettings)}.
*/
public FigEdgeModelElement() {
+ this(null, null);
+ }
+
+ /**
+ * Construct a new FigEdge. This method creates the name element that holds
+ * the name of the model element and adds itself as a listener. Also a
+ * stereotype is constructed.
+ * <p>
+ * This constructor is only intended for use by concrete subclasses.
+ *
+ * @param element owning uml element
+ * @param renderSettings rendering settings
+ */
+ protected FigEdgeModelElement(Object element,
+ DiagramSettings renderSettings) {
+ settings = renderSettings;
nameFig = new FigNameWithAbstract(10, 30, 90, 20, false);
nameFig.setTextFilled(false);
@@ -176,18 +200,39 @@
setBetweenNearestPoints(true);
- ArgoEventPump.addListener(ArgoEventTypes.ANY_NOTATION_EVENT, this);
- ArgoEventPump.addListener(
- ArgoEventTypes.ANY_DIAGRAM_APPEARANCE_EVENT, this);
+ if (element != null) {
+ if (!Model.getFacade().isAUMLElement(element)) {
+ throw new IllegalArgumentException(
+ "The owner must be a model element - got a "
+ + element.getClass().getName());
+ }
+ super.setOwner(element);
+ nameFig.setOwner(element); // for setting abstract
+ if (edgePort != null) {
+ edgePort.setOwner(getOwner());
+ }
+ stereotypeFig.setOwner(element); // this fixes issue 5414
+ notationProviderName =
+ NotationProviderFactory2.getInstance().getNotationProvider(
+ getNotationProviderType(), element, this);
+ // TODO: defer setting this up until needed
+ // (or just use value from settings)
+ putNotationArgument("useGuillemets",
+ Boolean.valueOf(getSettings().isUseGuillemets()));
+ addElementListener(element, "remove");
+ }
+
}
/**
* The constructor that hooks the Fig into the UML model element.
*
* @param edge the UML element
+ * @deprecated for 0.27.2 by tfmorris. Use
+ * {@link #FigEdgeModelElement(Object, DiagramSettings)}.
*/
public FigEdgeModelElement(Object edge) {
- this();
+ this(null, null);
setOwner(edge);
}
@@ -622,7 +667,8 @@
protected void textEditStarted(FigText ft) {
if (ft == getNameFig()) {
showHelp(notationProviderName.getParsingHelp());
- ft.setText(notationProviderName.toString(getOwner(), npArguments));
+ ft.setText(notationProviderName.toString(getOwner(),
+ getNotationArguments()));
}
}
@@ -667,7 +713,8 @@
return;
}
notationProviderName.parse(getOwner(), ft.getText());
- ft.setText(notationProviderName.toString(getOwner(), npArguments));
+ ft.setText(notationProviderName.toString(getOwner(),
+ getNotationArguments()));
}
}
@@ -772,7 +819,7 @@
* Rerenders the attached elements of the fig. <p>
*
* Warning: The purpose of this function is NOT
- * to redraw the whole Fig everytime
+ * to redraw the whole Fig every time
* something changes. That would be inefficient.<p>
*
* Instead, this function should only be called
@@ -783,7 +830,10 @@
* Overrule this function for subclasses that add extra
* or remove graphical parts.
*/
- protected void renderingChanged() {
+ public void renderingChanged() {
+ // TODO: This needs to use a different method than that used by the
+ // constructor if it wants to allow the method to be overridden
+ initNotationProviders(getOwner());
updateNameText();
updateStereotypeText();
damage();
@@ -829,12 +879,9 @@
}
if (notationProviderName != null) {
String nameStr = notationProviderName.toString(
- getOwner(), npArguments);
+ getOwner(), getNotationArguments());
nameFig.setText(nameStr);
- Project p = getProject();
- if (p != null) {
- updateFont();
- }
+ updateFont();
calcBounds();
setBounds(getBounds());
}
@@ -865,10 +912,8 @@
* @throws IllegalArgumentException if the owner given is not a model
* element
* @see org.tigris.gef.presentation.Fig#setOwner(java.lang.Object)
- */
- /*
- * TODO: It is planned to refactor so that there is only one Fig
- * constructor. When this is achieved this method can be refactored out.
+ * @deprecated for 0.27.3 by tfmorris. Owner must be specified in the
+ * constructor and can't be changed afterwards.
*/
@Override
public void setOwner(Object owner) {
@@ -894,35 +939,37 @@
updateListeners(null, owner);
// TODO: The following is redundant. It's done when setLayer is
// called after initialization complete
- renderingChanged();
+// renderingChanged();
}
+
+
/**
* Create the NotationProviders.
*
* @param own the current owner
+ * @deprecated for 0.27.3 by tfmorris. Separate initialization of
+ * notation providers from any later updates which are required.
+ * Initialization must be done in the constructor using methods which
+ * can't be overriden.
*/
protected void initNotationProviders(Object own) {
if (notationProviderName != null) {
notationProviderName.cleanListener(this, own);
}
/* This should NOT be looking for a NamedElement,
- * since this is not always about the name of this
- * modelelement alone.*/
+ * since this is not always about the name of this
+ * modelelement alone.*/
if (Model.getFacade().isAModelElement(own)) {
notationProviderName =
NotationProviderFactory2.getInstance().getNotationProvider(
getNotationProviderType(), own, this);
- Project p = getProject();
- if (p != null) {
- npArguments.put("rightGuillemot",
- p.getProjectSettings().getRightGuillemot());
- npArguments.put("leftGuillemot",
- p.getProjectSettings().getLeftGuillemot());
- }
+ putNotationArgument("useGuillemets",
+ Boolean.valueOf(getSettings().isUseGuillemets()));
}
}
+
/**
* Overrule this for subclasses
* that need a different NotationProvider.
@@ -1008,41 +1055,51 @@
super.deleteFromModel();
}
- /*
+ /**
* @see org.argouml.application.events.ArgoNotationEventListener#notationChanged(org.argouml.application.events.ArgoNotationEvent)
+ * @deprecated for 0.27.2 by tfmorris. Changes to notatation provider are
+ * now handled by the owning diagram.
*/
+ @Deprecated
public void notationChanged(ArgoNotationEvent event) {
if (getOwner() == null) {
return;
}
- initNotationProviders(getOwner());
renderingChanged();
}
- /*
+ /**
* @see org.argouml.application.events.ArgoNotationEventListener#notationAdded(org.argouml.application.events.ArgoNotationEvent)
+ * @deprecated for 0.27.2 by tfmorris.
*/
+ @Deprecated
public void notationAdded(ArgoNotationEvent event) {
// Default implementation is to do nothing
}
- /*
+ /**
* @see org.argouml.application.events.ArgoNotationEventListener#notationRemoved(org.argouml.application.events.ArgoNotationEvent)
+ * @deprecated for 0.27.2 by tfmorris.
*/
+ @Deprecated
public void notationRemoved(ArgoNotationEvent event) {
// Default implementation is to do nothing
}
- /*
+ /**
* @see org.argouml.application.events.ArgoNotationEventListener#notationProviderAdded(org.argouml.application.events.ArgoNotationEvent)
+ * @deprecated for 0.27.2 by tfmorris.
*/
+ @Deprecated
public void notationProviderAdded(ArgoNotationEvent event) {
// Default implementation is to do nothing
}
- /*
+ /**
* @see org.argouml.application.events.ArgoNotationEventListener#notationProviderRemoved(org.argouml.application.events.ArgoNotationEvent)
+ * @deprecated for 0.27.2 by tfmorris.
*/
+ @Deprecated
public void notationProviderRemoved(ArgoNotationEvent event) {
// Default implementation is to do nothing
}
@@ -1096,7 +1153,6 @@
if (o != null) {
removeElementListener(o);
}
- ArgoEventPump.removeListener(this);
if (notationProviderName != null) {
notationProviderName.cleanListener(this, getOwner());
}
@@ -1268,33 +1324,6 @@
return null;
}
- /*
- * @see org.tigris.gef.presentation.Fig#postLoad()
- */
- @Override
- public void postLoad() {
- ArgoEventPump.addListener(this);
- }
-
- /**
- * @deprecated by mvw for 0.25.4. Use {@link ProjectSettings#getFontPlain()}
- * et al.
- * @return Returns the plain font.
- */
- @Deprecated
- public Font getLabelFont() {
- return getProject().getProjectSettings().getFontPlain();
- }
-
- /**
- * @deprecated by mvw for 0.25.4. Use {@link ProjectSettings#getFontPlain()}
- * et al.
- * @return Returns the italic font.
- */
- @Deprecated
- public Font getItalicLabelFont() {
- return getProject().getProjectSettings().getFontItalic();
- }
/**
* @param allowed true if the function RemoveFromDiagram is allowed
@@ -1441,10 +1470,23 @@
addElementListeners(adds);
}
+ /**
+ * @return the current notation arguments or null if none have been set
+ */
protected HashMap<String, Object> getNotationArguments() {
return npArguments;
}
+ protected void putNotationArgument(String key, Object element) {
+ if (notationProviderName != null) {
+ // Lazily initialize if not done yet
+ if (npArguments == null) {
+ npArguments = new HashMap<String, Object>();
+ }
+ npArguments.put(key, element);
+ }
+ }
+
/**
* This optional method is not implemented. It will throw an
* {@link UnsupportedOperationException} if used. Figs are
@@ -1458,22 +1500,28 @@
throw new UnsupportedOperationException();
}
+ /**
+ * @deprecated for 0.27.2 by tfmorris. Implementations should have all
+ * the information that they require in the DiagramSettings object.
+ *
+ * @return the owning project
+ * @see org.argouml.uml.diagram.ui.ArgoFig#getProject()
+ */
+ @Deprecated
public Project getProject() {
return ArgoFigUtil.getProject(this);
}
/**
* Handles diagram font changing.
+ *
* @param e the event
* @see org.argouml.application.events.ArgoDiagramAppearanceEventListener#diagramFontChanged(org.argouml.application.events.ArgoDiagramAppearanceEvent)
+ * @deprecated for 0.27.2 by tfmorris. Global rendering changes are now
+ * managed at the diagram level.
*/
+ @Deprecated
public void diagramFontChanged(ArgoDiagramAppearanceEvent e) {
- if (getProject() == null) {
- /* Temporary fix related to issue 5434.
- * TODO: However I think this can be removed. See issue 5500 - Bob
- */
- return;
- }
updateFont();
calcBounds(); //TODO: Does this help?
redraw();
@@ -1485,12 +1533,8 @@
* and apply it by calling FigText.setFont().
*/
protected void updateFont() {
- Project p = getProject();
- if (p == null) {
- return;
- }
int style = getNameFigFontStyle();
- Font f = p.getProjectSettings().getFont(style);
+ Font f = getSettings().getFont(style);
nameFig.setFont(f);
deepUpdateFont(this);
}
@@ -1508,7 +1552,7 @@
}
private void deepUpdateFont(FigEdge fe) {
- Font f = getProject().getProjectSettings().getFont(Font.PLAIN);
+ Font f = getSettings().getFont(Font.PLAIN);
for (Object pathFig : fe.getPathItemFigs()) {
deepUpdateFontRecursive(f, pathFig);
}
@@ -1537,4 +1581,22 @@
}
}
}
+
+
+ public DiagramSettings getSettings() {
+ // TODO: This is a temporary crutch to use until all Figs are updated
+ // to use the constructor that accepts a DiagramSettings object
+ if (settings == null) {
+ Project p = getProject();
+ if (p != null) {
+ return p.getProjectSettings().getDefaultDiagramSettings();
+ }
+ }
+ return settings;
+ }
+
+ public void setSettings(DiagramSettings renderSettings) {
+ settings = renderSettings;
+ renderingChanged();
+ }
}
Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigNodeModelElement.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigNodeModelElement.java?view=diff&rev=16142&p1=trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigNodeModelElement.java&p2=trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigNodeModelElement.java&r1=16141&r2=16142
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigNodeModelElement.java (original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigNodeModelElement.java 2008-11-22 15:54:28-0800
@@ -54,7 +54,6 @@
import javax.swing.SwingUtilities;
import org.apache.log4j.Logger;
-import org.argouml.application.api.ArgoEventListener;
import org.argouml.application.events.ArgoDiagramAppearanceEvent;
import org.argouml.application.events.ArgoDiagramAppearanceEventListener;
import org.argouml.application.events.ArgoEventPump;
@@ -71,8 +70,6 @@
import org.argouml.kernel.DelayedChangeNotify;
import org.argouml.kernel.DelayedVChangeListener;
import org.argouml.kernel.Project;
-import org.argouml.kernel.ProjectManager;
-import org.argouml.kernel.ProjectSettings;
import org.argouml.model.AssociationChangeEvent;
import org.argouml.model.AttributeChangeEvent;
import org.argouml.model.DeleteInstanceEvent;
@@ -90,7 +87,9 @@
import org.argouml.uml.StereotypeUtility;
import org.argouml.uml.diagram.ArgoDiagram;
import org.argouml.uml.diagram.DiagramAppearance;
+import org.argouml.uml.diagram.DiagramSettings;
import org.argouml.uml.diagram.PathContainer;
+import org.argouml.uml.diagram.DiagramSettings.StereotypeStyle;
import org.argouml.uml.ui.ActionDeleteModelElements;
import org.argouml.util.IItemUID;
import org.argouml.util.ItemUID;
@@ -111,6 +110,10 @@
* Abstract class to display diagram icons for UML ModelElements that
* look like nodes and that have editable names and can be
* resized.
+ * <p>
+ * NOTE: This will drop the ArgoNotationEventListener and
+ * ArgoDiagramAppearanceEventListener interfaces in the next release.
+ * The corresponding methods have been marked as deprecated.
*
* @author abonner
*/
@@ -139,7 +142,8 @@
private DiElement diElement;
private NotationProvider notationProviderName;
- private HashMap<String, Object> npArguments = new HashMap<String, Object>();
+ // TODO: Use lazy initialization and/or remove
+ private HashMap<String, Object> npArguments;
/**
* True if an instance is allowed to be
@@ -226,7 +230,8 @@
* @see DiagramAppearance#STEREOTYPE_VIEW_SMALL_ICON
* @see DiagramAppearance#STEREOTYPE_VIEW_BIG_ICON
*/
- private int stereotypeView = DiagramAppearance.STEREOTYPE_VIEW_TEXTUAL;
+ private DiagramSettings.StereotypeStyle stereotypeStyle =
+ DiagramSettings.StereotypeStyle.TEXTUAL;
/**
* The width of the profile icons when viewed at the small icon mode.
@@ -287,14 +292,28 @@
// TODO: A more strongly typed data structure could be used here.
private Set<Object[]> listeners = new HashSet<Object[]>();
+ /**
+ * Settings which affect rendering (color, font, line width, etc);
+ */
+ private DiagramSettings settings;
/**
- * The main constructor. <p>
- *
- * The owner nor the Layer (which has a 1..1 relation to the Diagram)
- * are set in this stage of the creation of the Fig.
+ * The default constructor. <p>
+ * @deprecated for 0.27.2 by tfmorris. Use
+ * {@link #FigNodeModelElement(Object, Rectangle, DiagramSettings)}.
*/
+ @Deprecated
protected FigNodeModelElement() {
+ // We'll fall back to using the project settings during the transition
+ this(null);
+ }
+
+ /**
+ * Construct an unplaced Fig with no owner using the given
+ * rendering settings.
+ */
+ private FigNodeModelElement(DiagramSettings renderSettings) {
+ settings = renderSettings;
// this rectangle marks the whole modelelement figure; everything
// is inside it:
bigPort = new FigRect(10, 10, 0, 0, Color.cyan, Color.cyan);
@@ -310,31 +329,24 @@
stereotypeFig = new FigStereotypesGroup(10, 10, 90, 15);
readyToEdit = false;
- ArgoEventPump.addListener(ArgoEventTypes.ANY_NOTATION_EVENT, this);
- ArgoEventPump.addListener(
- ArgoEventTypes.ANY_DIAGRAM_APPEARANCE_EVENT, this);
-
-
- Project project = getProject();
- ProjectSettings ps = project.getProjectSettings();
- setShadowSize(ps.getDefaultShadowWidthValue());
+ setShadowSize(getSettings().getDefaultShadowWidth());
/* TODO: how to handle changes in shadowsize
* from the project properties? */
- stereotypeView = ps.getDefaultStereotypeViewValue();
+ stereotypeStyle = getSettings().getDefaultStereotypeView();
}
/**
* Construct a figure at a specific position for a given model element. <p>
*
- * The Layer (which has a 1..1 relation to the Diagram)
- * is not yet set in this stage of the creation of the Fig.
- *
* @param element ModelElement associated with figure
* @param x horizontal location
* @param y vertical location
+ * @deprecated for 0.27.2 by tfmorris. Use
+ * {@link #FigNodeModelElement(Object, Rectangle, DiagramSettings)}.
*/
+ @Deprecated
protected FigNodeModelElement(Object element, int x, int y) {
this();
setOwner(element);
@@ -344,6 +356,62 @@
}
/**
+ * Construct a figure at a specific position for a given model element
+ * with the given settings. This is the constructor used by the PGML
+ * parser when loading a diagram from a file.<p>
+ *
+ * @param element ModelElement associated with figure
+ * @param bounds x & y are used to set position, width & height are ignored
+ * @param renderSettings the rendering settings to use for the Fig
+ */
+ protected FigNodeModelElement(Object element, Rectangle bounds,
+ DiagramSettings renderSettings) {
+ this(renderSettings);
+ if (element == null) {
+ throw new IllegalArgumentException("An owner must be supplied");
+ }
+ if (!Model.getFacade().isAUMLElement(element)) {
+ throw new IllegalArgumentException(
+ "The owner must be a model element - got a "
+ + element.getClass().getName());
+ }
+ super.setOwner(element);
+ nameFig.setOwner(element); // for setting abstract
+ nameFig.setText(placeString());
+ stereotypeFig.setOwner(element);
+
+ notationProviderName =
+ NotationProviderFactory2.getInstance().getNotationProvider(
+ getNotationProviderType(), element, this);
+ putNotationArgument("pathVisible",
+ Boolean.valueOf(isPathVisible()));
+
+ /* This next line presumes that the 1st fig with this owner
+ * is the previous port - and consequently nullifies the owner
+ * of this 1st fig. */
+ bindPort(element, bigPort);
+
+ // Add a listener for changes to any property
+ addElementListener(element);
+
+ if (bounds != null) {
+ setLocation(bounds.x, bounds.y);
+ }
+
+ // TODO: The following is carried over from setOwner, but probably
+ // isn't needed
+// renderingChanged();
+ // It does the following (add as needed):
+// updateNameText();
+// updateStereotypeText();
+// updateStereotypeIcon();
+// updateBounds();
+// damage();
+
+ readyToEdit = true;
+ }
+
+ /**
* This is the final call at creation time of the Fig, i.e. here
* it is put on a Diagram.
*
@@ -356,16 +424,6 @@
determineDefaultPathVisible();
}
- /*
- * @see java.lang.Object#finalize()
- */
- @Override
- protected void finalize() throws Throwable {
- ArgoEventPump.removeListener(ArgoEventTypes.ANY_NOTATION_EVENT, this);
- ArgoEventPump.removeListener(
- ArgoEventTypes.ANY_DIAGRAM_APPEARANCE_EVENT, this);
- super.finalize();
- }
/**
* Clone this figure. After the base clone method has been called determine
@@ -1098,13 +1156,14 @@
protected void textEditStarted(FigText ft) {
if (ft == getNameFig()) {
showHelp(notationProviderName.getParsingHelp());
- ft.setText(notationProviderName.toString(getOwner(), npArguments));
+ ft.setText(notationProviderName.toString(getOwner(),
+ getNotationArguments()));
}
if (ft instanceof CompartmentFigText) {
final CompartmentFigText figText = (CompartmentFigText) ft;
showHelp(figText.getNotationProvider().getParsingHelp());
figText.setText(figText.getNotationProvider().toString(
- figText.getOwner(), npArguments));
+ figText.getOwner(), getNotationArguments()));
}
}
@@ -1142,13 +1201,14 @@
return;
}
notationProviderName.parse(getOwner(), ft.getText());
- ft.setText(notationProviderName.toString(getOwner(), npArguments));
+ ft.setText(notationProviderName.toString(getOwner(),
+ getNotationArguments()));
}
if (ft instanceof CompartmentFigText) {
final CompartmentFigText figText = (CompartmentFigText) ft;
figText.getNotationProvider().parse(ft.getOwner(), ft.getText());
ft.setText(figText.getNotationProvider().toString(
- ft.getOwner(), npArguments));
+ ft.getOwner(), getNotationArguments()));
}
}
@@ -1162,9 +1222,11 @@
*
* @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
*/
+ @Override
public void mouseClicked(MouseEvent me) {
if (!readyToEdit) {
if (Model.getFacade().isAModelElement(getOwner())) {
+ // TODO: Why is this clearing the name?!?! - tfm
Model.getCoreHelper().setName(getOwner(), "");
readyToEdit = true;
} else {
@@ -1396,6 +1458,8 @@
* @throws IllegalArgumentException if the owner given is not a model
* element
* @see org.tigris.gef.presentation.Fig#setOwner(java.lang.Object)
+ * @deprecated for 0.27.3 by tfmorris. Owner must be provided in
+ * constructor and may not be changed afterwards.
*/
public void setOwner(Object owner) {
if (owner == null) {
@@ -1427,7 +1491,12 @@
/**
* Create the NotationProviders.
*
- * @param own the current owner
+ * @param own owning UML element
+ * @deprecated for 0.27.3 by tfmorris. Initialization of notation providers
+ * and any later needed updates must be separated.
+ * Initialization must be done in a way that can't be overridden
+ * since the subclasses constructors won't have completed by the
+ * time the subclass implementation is run.
*/
protected void initNotationProviders(Object own) {
if (notationProviderName != null) {
@@ -1437,17 +1506,12 @@
notationProviderName =
NotationProviderFactory2.getInstance().getNotationProvider(
getNotationProviderType(), own, this);
- npArguments.put("pathVisible", Boolean.valueOf(isPathVisible()));
- Project p = getProject();
- if (p != null) {
- npArguments.put("rightGuillemot",
- p.getProjectSettings().getRightGuillemot());
- npArguments.put("leftGuillemot",
- p.getProjectSettings().getLeftGuillemot());
- }
+ putNotationArgument("pathVisible",
+ Boolean.valueOf(isPathVisible()));
}
}
+
/**
* Overrule this for subclasses
* that need a different NotationProvider.
@@ -1481,11 +1545,9 @@
}
if (notationProviderName != null) {
nameFig.setText(notationProviderName.toString(
- getOwner(), npArguments));
- Project p = getProject();
- if (p != null) {
- updateFont();
- }
+ getOwner(), getNotationArguments()));
+ // TODO: Why does the font need updating? - tfm
+ updateFont();
updateBounds();
}
}
@@ -1511,7 +1573,7 @@
firePropChange("pathVisible", !visible, visible);
pathVisible = visible;
if (notationProviderName != null) {
- npArguments.put("pathVisible", Boolean.valueOf(visible));
+ putNotationArgument("pathVisible", Boolean.valueOf(visible));
}
if (readyToEdit) {
renderingChanged();
@@ -1544,8 +1606,9 @@
Object elementNs = Model.getFacade().getNamespace(modelElement);
Object diagramNs = diagram.getNamespace();
if (elementNs != null) {
- boolean visible = elementNs != diagramNs;
- npArguments.put("pathVisible", Boolean.valueOf(visible));
+ boolean visible = elementNs != diagramNs;
+ // TODO: Pass argument directly
+ putNotationArgument("pathVisible", Boolean.valueOf(visible));
pathVisible = visible;
renderingChanged();
damage();
@@ -1611,14 +1674,16 @@
}
- /*
+ /**
* @see org.argouml.application.events.ArgoNotationEventListener#notationChanged(org.argouml.application.events.ArgoNotationEvent)
+ * @deprecated for 0.27.2 by tfmorris. Changes to notatation provider are
+ * now handled by the owning diagram.
*/
+ @Deprecated
public void notationChanged(ArgoNotationEvent event) {
if (getOwner() == null) {
return;
}
- initNotationProviders(getOwner());
try {
renderingChanged();
} catch (Exception e) {
@@ -1626,44 +1691,52 @@
}
}
- /*
+ /**
* @see org.argouml.application.events.ArgoNotationEventListener#notationAdded(org.argouml.application.events.ArgoNotationEvent)
+ * @deprecated for 0.27.2 by tfmorris.
*/
+ @Deprecated
public void notationAdded(ArgoNotationEvent event) {
// Default is to do nothing
}
- /*
+ /**
* @see org.argouml.application.events.ArgoNotationEventListener#notationRemoved(org.argouml.application.events.ArgoNotationEvent)
+ * @deprecated for 0.27.2 by tfmorris.
*/
+ @Deprecated
public void notationRemoved(ArgoNotationEvent event) {
// Default is to do nothing
}
- /*
+ /**
* @see org.argouml.application.events.ArgoNotationEventListener#notationProviderAdded(org.argouml.application.events.ArgoNotationEvent)
+ * @deprecated for 0.27.2 by tfmorris.
*/
+ @Deprecated
public void notationProviderAdded(ArgoNotationEvent event) {
// Default is to do nothing
}
- /*
+ /**
* @see org.argouml.application.events.ArgoNotationEventListener#notationProviderRemoved(org.argouml.application.events.ArgoNotationEvent)
+ * @deprecated for 0.27.2 by tfmorris.
*/
+ @Deprecated
public void notationProviderRemoved(ArgoNotationEvent event) {
// Default is to do nothing
}
/**
- * Rerenders the entire fig.
+ * Rerender the entire fig.
* <p>
* This is may be an expensive operation for subclasses which are complex,
* so should be used sparingly. This functionality was originally the
* functionality of modelChanged but modelChanged takes the event now into
- * account. <p>
- * TODO: Does this have to be public?
+ * account.
*/
public void renderingChanged() {
+ initNotationProviders(getOwner());
updateNameText();
updateStereotypeText();
updateStereotypeIcon();
@@ -1713,8 +1786,8 @@
if (stereos.size() == 1) {
Object stereo = stereos.iterator().next();
- // TODO: Should we not use getProject here?
- replaceIcon = ProjectManager.getManager().getCurrentProject()
+ // TODO: Find a way to replace this dependency on Project
+ replaceIcon = getProject()
.getProfileConfiguration().getFigNodeStrategy()
.getIconForStereotype(stereo);
}
@@ -1747,8 +1820,8 @@
int i = this.getX() + this.getWidth() - ICON_WIDTH - 2;
for (Object stereo : stereos) {
- // TODO: Should we not use getProject here?
- Image icon = ProjectManager.getManager().getCurrentProject()
+ // TODO: Find a way to replace this dependency on Project
+ Image icon = getProject()
.getProfileConfiguration().getFigNodeStrategy()
.getIconForStereotype(stereo);
if (icon != null) {
@@ -1845,28 +1918,11 @@
if (notationProviderName != null) { //This test needed for a FigPool
notationProviderName.cleanListener(this, getOwner());
}
- ArgoEventPump.removeListener(this);
removeAllElementListeners();
setShadowSize(0);
super.removeFromDiagram();
}
- /*
- * @see org.tigris.gef.presentation.Fig#postLoad()
- */
- @Override
- public void postLoad() {
- ArgoEventPump.addListener(this);
- for (Object fig : getFigs()) {
- if (fig instanceof ArgoEventListener) {
- // cannot do the adding of listeners recursive since
- // some are not children of FigNodeModelELement or
- // FigEdgeModelElement
- ArgoEventPump.addListener((ArgoEventListener) fig);
- }
- }
- }
-
/**
* Get the Fig containing the stereotype(s).
*
@@ -1876,23 +1932,6 @@
return stereotypeFig;
}
- /**
- * @deprecated by MVW in V0.25.4. Use ProjectSettings instead.
- * @return the diagram font
- */
- @Deprecated
- public Font getLabelFont() {
- return getProject().getProjectSettings().getFontPlain();
- }
-
- /**
- * @deprecated by MVW in V0.25.4. Use ProjectSettings instead.
- * @return the italic diagram font
- */
- @Deprecated
- public Font getItalicLabelFont() {
- return getProject().getProjectSettings().getFontItalic();
- }
/**
* @param bp the bigPort, which is the port where edges connect to this node
@@ -2155,12 +2194,20 @@
addElementListeners(adds);
}
+ /**
+ * @return the current notation arguments or null if none are set
+ */
protected HashMap<String, Object> getNotationArguments() {
return npArguments;
}
+
protected void putNotationArgument(String key, Object value) {
if (notationProviderName != null) {
+ // Lazily initialize if not done yet
+ if (npArguments == null) {
+ npArguments = new HashMap<String, Object>();
+ }
npArguments.put(key, value);
}
}
@@ -2180,11 +2227,13 @@
}
/**
- * This method is identical to the one in ArgoFigGroup.
+ * @deprecated for 0.27.2 by tfmorris. Implementations should have all
+ * the information that they require in the DiagramSettings object.
*
- * @return the project
+ * @return the owning project
* @see org.argouml.uml.diagram.ui.ArgoFig#getProject()
*/
+ @Deprecated
public Project getProject() {
return ArgoFigUtil.getProject(this);
}
@@ -2202,9 +2251,17 @@
/**
* @return current stereotype view
+ * @deprecated for 0.27.2 by tfmorris. Use {@link #getStereotypeStyle()}.
*/
public int getStereotypeView() {
- return stereotypeView;
+ return stereotypeStyle.ordinal();
+ }
+
+ /**
+ * @return the rendering style for stereotypes
+ */
+ public StereotypeStyle getStereotypeStyle() {
+ return stereotypeStyle;
}
/**
@@ -2228,6 +2285,8 @@
&& (stereos == null
|| stereos.size() != 1
|| (stereos.size() == 1
+ // TODO: Find a way to replace
+ // this dependency on Project
&& getProject().getProfileConfiguration()
.getFigNodeStrategy().getIconForStereotype(
stereos.iterator().next())
@@ -2242,14 +2301,21 @@
* Sets the stereotype view.
*
* @param s the stereotype view to be set
+ * @deprecated for 0.27.2 by tfmorris. Use
+ * {@link #setStereotypeStyle(StereotypeStyle)}.
*/
public void setStereotypeView(int s) {
- this.stereotypeView = s;
- try {
- renderingChanged();
- } catch (Exception e) {
- // TODO: Why is this ignored?
- }
+ setStereotypeStyle(StereotypeStyle.getEnum(s));
+ }
+
+ /**
+ * Set the stereotype style to be used for rendering this fig.
+ *
+ * @param style the stereotype style to be set
+ */
+ public void setStereotypeStyle(StereotypeStyle style) {
+ stereotypeStyle = style;
+ renderingChanged();
}
/**
@@ -2261,6 +2327,7 @@
*
* {@inheritDoc}
*/
+ @Override
protected void setBoundsImpl(final int x, final int y, final int w,
final int h) {
@@ -2310,14 +2377,10 @@
* Handles diagram font changing.
* @param e the event or null
* @see org.argouml.application.events.ArgoDiagramAppearanceEventListener#diagramFontChanged(org.argouml.application.events.ArgoDiagramAppearanceEvent)
+ * @deprecated for 0.27.2 by tfmorris. The owning diagram manages global
+ * changes to rendering defaults.
*/
public void diagramFontChanged(ArgoDiagramAppearanceEvent e) {
- if (getProject() == null) {
- /* Temporary fix related to issue 5434.
- * TODO: However I think this can be removed. See issue 5500 - Bob
- */
- return;
- }
updateFont();
updateBounds();
damage();
@@ -2333,7 +2396,7 @@
*/
protected void updateFont() {
int style = getNameFigFontStyle();
- Font f = getProject().getProjectSettings().getFont(style);
+ Font f = getSettings().getFont(style);
nameFig.setFont(f);
deepUpdateFont(this);
}
@@ -2347,18 +2410,9 @@
* @return the font style for the nameFig.
*/
protected int getNameFigFontStyle() {
- showBoldName = false;
- Project p = getProject();
-
- /**
- * When and why p could be NULL?
- * See issue 4911.
- */
- if (p != null) {
- ProjectSettings ps = p.getProjectSettings();
- showBoldName = ps.getShowBoldNamesValue();
- }
-
+ // TODO: Why do we need this when we can just change the font and
+ // achieve the same effect?
+ showBoldName = getSettings().isShowBoldNames();
return showBoldName ? Font.BOLD : Font.PLAIN;
}
@@ -2389,4 +2443,23 @@
fg.calcBounds();
}
}
+
+
+ public DiagramSettings getSettings() {
+ // TODO: This is a temporary crutch to use until all Figs are updated
+ // to use the constructor that accepts a DiagramSettings object
+ if (settings == null) {
+ Project p = getProject();
+ if (p != null) {
+ return p.getProjectSettings().getDefaultDiagramSettings();
+ }
+ }
+ return settings;
+ }
+
+ public void setSettings(DiagramSettings renderSettings) {
+ settings = renderSettings;
+ renderingChanged();
+ }
+
}
Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/UMLDiagram.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/UMLDiagram.java?view=diff&rev=16142&p1=trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/UMLDiagram.java&p2=trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/UMLDiagram.java&r1=16141&r2=16142
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/UMLDiagram.java (original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/UMLDiagram.java 2008-11-22 15:54:28-0800
@@ -50,11 +50,13 @@
import org.argouml.uml.diagram.Relocatable;
import org.argouml.uml.diagram.UMLMutableGraphSupport;
import org.argouml.util.ToolBarUtility;
+import org.tigris.gef.base.LayerPerspective;
import org.tigris.gef.base.ModeBroom;
import org.tigris.gef.base.ModeCreatePolyEdge;
import org.tigris.gef.base.ModePlace;
import org.tigris.gef.base.ModeSelect;
import org.tigris.gef.graph.GraphFactory;
+import org.tigris.gef.graph.GraphModel;
import org.tigris.gef.presentation.FigNode;
import org.tigris.toolbar.ToolBarFactory;
import org.tigris.toolbar.ToolBarManager;
@@ -93,14 +95,14 @@
extends ArgoDiagramImpl
implements Relocatable {
- /**
- * Logger.
- */
private static final Logger LOG = Logger.getLogger(UMLDiagram.class);
/**
* The serial number for new diagrams.
* Used to create an unique number for the name of the diagram.
+ * <p>
+ * TODO: How is this going to work if it's not static and this isn't a
+ * singleton class?
*/
private int diagramSerial = 1;
@@ -160,31 +162,42 @@
private Action selectedAction;
- ////////////////////////////////////////////////////////////////
- // constructors
-
/**
- * The constructor.
+ * Default constructor will become protected. All subclasses should have
+ * their constructors invoke the 3-arg version of the constructor.
+ * @deprecated for 0.27.2 by tfmorris.
+ * Use {@link #UMLDiagram(String, Object, GraphModel)} or another explicit
+ * constructor.
*/
+ @Deprecated
public UMLDiagram() {
super();
}
/**
* @param ns the UML namespace of this diagram
+ * @deprecated for 0.27.2 by tfmorris. Use
+ * {@link #UMLDiagram(Object, GraphModel)}.
*/
+ @Deprecated
public UMLDiagram(Object ns) {
this();
if (!Model.getFacade().isANamespace(ns)) {
throw new IllegalArgumentException();
}
+ // TODO: Should we require a GraphModel in the constructor since
+ // our implementations of setNamespace are going to try and set
+ // the namespace on the graphmodel as well?
setNamespace(ns);
}
-
+
/**
* @param name the name of the diagram
* @param ns the UML namespace of this diagram
+ * @deprecated for 0.27.2 by tfmorris. Use
+ * {@link #UMLDiagram(String, Object, GraphModel)}.
*/
+ @Deprecated
public UMLDiagram(String name, Object ns) {
this(ns);
try {
@@ -194,15 +207,43 @@
}
}
+
+ /**
+ * Construct a new ArgoUML diagram. This is the fully specified form
+ * of the constructor typically used by subclasses.
+ *
+ * @param name the name of the new diagram
+ * @param graphModel graph model to associate with diagram
+ * (use new LayerPerspective(name, graphModel)) if you need a default
+ * @param ns the namespace which will "own" the diagram
+ */
+ public UMLDiagram(String name, Object ns, GraphModel graphModel) {
+ super(name, graphModel, new LayerPerspective(name, graphModel));
+ setNamespace(ns);
+ }
+
/**
- * Method called by PGML parser to initialize a diagram after it's been
- * constructed. Order of method invocations currently is: <ul>
+ * Construct an unnamed diagram using the given GraphModel.
+ *
+ * @param graphModel graph model to associate with diagram
+ * (use new LayerPerspective(name, graphModel)) if you need a default
+ */
+ public UMLDiagram(GraphModel graphModel) {
+ super("", graphModel, new LayerPerspective("", graphModel));
+ }
+
+ /**
+ * Method called by PGML parser during diagram load to initialize a diagram
+ * after it's been constructed. Order of method invocations currently is:
+ * <ul>
* <li>0-arg constructor
+ * <li>setDiagramSettings
* <li>initialize(Object) // UML element representing owner/home model
* <li>setName(String)
* <li>setScale(double)
* <li>setShowSingleMultiplicity(boolean)
* <ul>
+ *
* @param owner UML model element representing owner/namespace/home model
* @see org.tigris.gef.base.Diagram#initialize(java.lang.Object)
*/
@@ -216,9 +257,6 @@
setNamespace(owner);
}
}
-
- ////////////////////////////////////////////////////////////////
- // accessors
/*
* @see org.tigris.gef.base.Diagram#getClassAndModelID()
Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/use_case/ui/FigExtend.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/use_case/ui/FigExtend.java?view=diff&rev=16142&p1=trunk/src/argouml-app/src/org/argouml/uml/diagram/use_case/ui/FigExtend.java&p2=trunk/src/argouml-app/src/org/argouml/uml/diagram/use_case/ui/FigExtend.java&r1=16141&r2=16142
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/use_case/ui/FigExtend.java (original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/use_case/ui/FigExtend.java 2008-11-22 15:54:28-0800
@@ -229,7 +229,7 @@
* @see org.argouml.uml.diagram.ui.FigEdgeModelElement#renderingChanged()
*/
@Override
- protected void renderingChanged() {
+ public void renderingChanged() {
if (getOwner() != null) {
updateConditionText();
updateLabel();
Modified: trunk/src/argouml-app/src/org/argouml/uml/ui/ActionAddDiagram.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/ui/ActionAddDiagram.java?view=diff&rev=16142&p1=trunk/src/argouml-app/src/org/argouml/uml/ui/ActionAddDiagram.java&p2=trunk/src/argouml-app/src/org/argouml/uml/ui/ActionAddDiagram.java&r1=16141&r2=16142
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/ui/ActionAddDiagram.java (original)
+++ trunk/src/argouml-app/src/org/argouml/uml/ui/ActionAddDiagram.java 2008-11-22 15:54:28-0800
@@ -38,6 +38,7 @@
import org.argouml.ui.explorer.ExplorerEventAdaptor;
import org.argouml.ui.targetmanager.TargetManager;
import org.argouml.uml.diagram.ArgoDiagram;
+import org.argouml.uml.diagram.DiagramSettings;
import org.tigris.gef.undo.UndoableAction;
/**
@@ -81,7 +82,13 @@
if (ns != null && isValidNamespace(ns)) {
super.actionPerformed(e);
+ DiagramSettings settings =
+ p.getProjectSettings().getDefaultDiagramSettings();
+ // TODO: We should really be passing the default settings to
+ // the diagram factory so they get set at creation time
ArgoDiagram diagram = createDiagram(ns);
+ diagram.setDiagramSettings(settings);
+
p.addMember(diagram);
//TODO: make the explorer listen to project member property
//changes... to eliminate coupling on gui.
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.