svn commit: r16534 - trunk/src/argouml-app/src/org/argouml/uml/diagram/ui

Bob Tarling <[email protected]>
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: bobtarling
Date: 2009-01-06 17:27:42-0800
New Revision: 16534

Modified:
   trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigAbstraction.java
   trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigDependency.java

Log:
Issue 5600: Introduce template method to create the correct arrowhead.

Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigAbstraction.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigAbstraction.java?view=diff&pathrev=16534&r1=16533&r2=16534
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigAbstraction.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigAbstraction.java	2009-01-06 17:27:42-0800
@@ -25,6 +25,7 @@
 package org.argouml.uml.diagram.ui;
 
 import org.argouml.uml.diagram.DiagramSettings;
+import org.tigris.gef.presentation.ArrowHead;
 import org.tigris.gef.presentation.ArrowHeadTriangle;
 
 /**
@@ -37,16 +38,6 @@
  */
 public class FigAbstraction extends FigDependency {
 
-    /*
-     * Implementation was copied here from FigRealization and parent type
-     * changed from FigEdgeModelElement to FigDependency to align better with
-     * UML spec and to allow reuse for other abstractions such as Derivation,
-     * Refinement, or Trace. FigRealization is just a shell for backward
-     * compatibility.
-     * 
-     */
-    private ArrowHeadTriangle endArrow;
-
     /**
      * The constructor.
      * 
@@ -57,13 +48,18 @@
     @Deprecated
     public FigAbstraction() {
         super();
-        constructFigs();
+        setDestArrowHead(createEndArrow());
     }
 
-    private void constructFigs() {
-        endArrow = new ArrowHeadTriangle();
-        endArrow.setFillColor(FILL_COLOR);
-        setDestArrowHead(endArrow);
+    /**
+     * Create the arrow head for the abstraction. This overrides the
+     * superclass to create a filled arrow head.
+     * @return the arrow head.
+     */
+    protected ArrowHead createEndArrow() {
+        final ArrowHead arrow = new ArrowHeadTriangle();
+        arrow.setFillColor(FILL_COLOR);
+        return arrow;
     }
 
     /**

Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigDependency.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigDependency.java?view=diff&pathrev=16534&r1=16533&r2=16534
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigDependency.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/FigDependency.java	2009-01-06 17:27:42-0800
@@ -29,6 +29,7 @@
 
 import org.argouml.uml.diagram.DiagramSettings;
 import org.tigris.gef.base.Layer;
+import org.tigris.gef.presentation.ArrowHead;
 import org.tigris.gef.presentation.ArrowHeadGreater;
 import org.tigris.gef.presentation.Fig;
 
@@ -45,8 +46,6 @@
      */
     private static final long serialVersionUID = -1779182458484724448L;
 
-    private ArrowHeadGreater endArrow;
-    
     /*
      * Text group to contain name & stereotype
      */
@@ -71,14 +70,21 @@
         addPathItem(middleGroup,
                 new PathConvPercent2(this, middleGroup, 50, 25));
         
-        endArrow = new ArrowHeadGreater();
-        // TODO: Why is this a different color than everything else? - tfm
-        endArrow.setFillColor(Color.red);
-        setDestArrowHead(endArrow);
+        setDestArrowHead(createEndArrow());
         
         setBetweenNearestPoints(true);
         getFig().setDashed(true);
     }
+    
+    /**
+     * Create the arrow head for the dependency. By default this is a
+     * stick figure arrow head with no fill. Descendants may override this as
+     * required.
+     * @return the arrow head.
+     */
+    protected ArrowHead createEndArrow() {
+        return new ArrowHeadGreater();
+    }
 
     /**
      * Constructor that sets the UML element
@@ -139,15 +145,13 @@
         return false;
     }
 
-    /*
-     * @see org.tigris.gef.presentation.Fig#paint(java.awt.Graphics)
-     */
-    @Override
-    public void paint(Graphics g) {
-        endArrow.setLineColor(getLineColor());
-        super.paint(g);
+    public void setLineColor(Color color) {
+        ArrowHead arrow = getDestArrowHead();
+        if (arrow != null) {
+            arrow.setLineColor(getLineColor());
+        }
     }
-
+    
     @Override
     protected void updateNameText() {
         super.updateNameText();

------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=1009026

To unsubscribe from this discussion, e-mail: [[email protected]].
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.