svn commit: r15518 - branches/gsoc2008/feature3_5140_bszanto/src/org/argouml: notation uml/diagram/static_structure/ui

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: bszanto
Date: 2008-08-07 05:12:15-0700
New Revision: 15518

Modified:
   branches/gsoc2008/feature3_5140_bszanto/src/org/argouml/notation/NotationName.java
   branches/gsoc2008/feature3_5140_bszanto/src/org/argouml/notation/NotationNameImpl.java
   branches/gsoc2008/feature3_5140_bszanto/src/org/argouml/uml/diagram/static_structure/ui/FigAttribute.java
   branches/gsoc2008/feature3_5140_bszanto/src/org/argouml/uml/diagram/static_structure/ui/FigOperation.java

Log:
Font size and diagram scale are now taken into consideration for the offset of the visibility cycling.

Modified: branches/gsoc2008/feature3_5140_bszanto/src/org/argouml/notation/NotationName.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/feature3_5140_bszanto/src/org/argouml/notation/NotationName.java?view=diff&rev=15518&p1=branches/gsoc2008/feature3_5140_bszanto/src/org/argouml/notation/NotationName.java&p2=branches/gsoc2008/feature3_5140_bszanto/src/org/argouml/notation/NotationName.java&r1=15517&r2=15518
==============================================================================
--- branches/gsoc2008/feature3_5140_bszanto/src/org/argouml/notation/NotationName.java	(original)
+++ branches/gsoc2008/feature3_5140_bszanto/src/org/argouml/notation/NotationName.java	2008-08-07 05:12:15-0700
@@ -94,4 +94,19 @@
      * @return boolean indicating equality or inequality.
      */
     boolean sameNotationAs(NotationName notationName);
+    
+    /**
+     * @return The witdh in pixels for which the visibility should be cycled.
+     */
+    public int getNotationOffset();
+    
+    /**
+     * Set the offset to the given size. This is used to set the hit zone for 
+     * the visibility cycle feature. This hit zone is different for the 
+     * different notations. Java uses words (public, protected, private) while 
+     * UML 1.4 uses signs (+, -, ~, #). Other notation might use different 
+     * words. This should be set to 0 (zero) to disable visibility cycling.
+     * @param offset The (maximum) number of letters of the visibility word/sign
+     */
+    public void setNotationOffset(int offset);
 }

Modified: branches/gsoc2008/feature3_5140_bszanto/src/org/argouml/notation/NotationNameImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/feature3_5140_bszanto/src/org/argouml/notation/NotationNameImpl.java?view=diff&rev=15518&p1=branches/gsoc2008/feature3_5140_bszanto/src/org/argouml/notation/NotationNameImpl.java&p2=branches/gsoc2008/feature3_5140_bszanto/src/org/argouml/notation/NotationNameImpl.java&r1=15517&r2=15518
==============================================================================
--- branches/gsoc2008/feature3_5140_bszanto/src/org/argouml/notation/NotationNameImpl.java	(original)
+++ branches/gsoc2008/feature3_5140_bszanto/src/org/argouml/notation/NotationNameImpl.java	2008-08-07 05:12:15-0700
@@ -24,6 +24,7 @@
 
 package org.argouml.notation;
 
+import java.io.ObjectInputStream.GetField;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -35,6 +36,8 @@
 import org.argouml.application.events.ArgoEventPump;
 import org.argouml.application.events.ArgoEventTypes;
 import org.argouml.application.events.ArgoNotationEvent;
+import org.argouml.kernel.ProjectManager;
+import org.tigris.gef.base.Globals;
 
 /**
  * This class provides definition and manipulation of notation names.
@@ -58,6 +61,8 @@
     private String version;
     private Icon icon;
 
+    private int offset = 0;
+
     /** The one and only list of notations available 
      * in the running ArgoUML application. */
     private static ArrayList<NotationName> notations = 
@@ -268,5 +273,28 @@
     static NotationName getNotation(String k1, String k2) {
         return findNotation(getNotationNameString(k1, k2));
     }
+    
+    public int getNotationOffset() {
+        
+        /* TODO: the folowing if else should not exist! Each notation should set 
+        the offset using the setNotationOffset(int o) method. */
+        String notation = getConfigurationValue();
+        if (notation.equals("Java")) {
+            offset = 9;
+        } else if (notation.equals("UML 1.4")) {
+            offset = 1;
+        }
+        
+        // zoom scale should be taken into account and font size also (supossing
+        // one letter has roughly the width of (font size) * 3 /4) 
+        int finalOffset = (int) (Globals.curEditor().getScale() * 
+                (offset * ProjectManager.getManager().getCurrentProject()
+                        .getProjectSettings().getFontSize()) * 3 / 4);
+        return finalOffset;
+    }
+    
+    public void setNotationOffset(int o) {
+        offset = o;
+    }
 
 }

Modified: branches/gsoc2008/feature3_5140_bszanto/src/org/argouml/uml/diagram/static_structure/ui/FigAttribute.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/feature3_5140_bszanto/src/org/argouml/uml/diagram/static_structure/ui/FigAttribute.java?view=diff&rev=15518&p1=branches/gsoc2008/feature3_5140_bszanto/src/org/argouml/uml/diagram/static_structure/ui/FigAttribute.java&p2=branches/gsoc2008/feature3_5140_bszanto/src/org/argouml/uml/diagram/static_structure/ui/FigAttribute.java&r1=15517&r2=15518
==============================================================================
--- branches/gsoc2008/feature3_5140_bszanto/src/org/argouml/uml/diagram/static_structure/ui/FigAttribute.java	(original)
+++ branches/gsoc2008/feature3_5140_bszanto/src/org/argouml/uml/diagram/static_structure/ui/FigAttribute.java	2008-08-07 05:12:15-0700
@@ -64,20 +64,14 @@
      * @author bszanto
      */
     public void changeVisibility(Rectangle r) {
-        if (super.hit(r)) {
-            String notation = ProjectManager.getManager().getCurrentProject()
-                    .getProjectSettings().getNotationLanguage();
-            
+        if (super.hit(r)) {            
             // The hit zone is different for the different notations.
             // Java uses words (public, protected, private) while UML 1.4 uses
-            // signs (+, -, ~, #).
-            int offset = 0;
-            if (notation.equals("Java")) {
-                offset = 50;
-            } else if (notation.equals("UML 1.4")) {
-                offset = 10;
-            }
-             
+            // signs (+, -, ~, #), and so on...
+            int offset = ProjectManager.getManager().getCurrentProject()
+                    .getProjectSettings().getNotationName().getNotationOffset();
+            
+            
             if (r.x < (_x + offset)) {
                 Object atttribute = getOwner();
                 Object visibity = Model.getFacade().getVisibility(atttribute);

Modified: branches/gsoc2008/feature3_5140_bszanto/src/org/argouml/uml/diagram/static_structure/ui/FigOperation.java
Url: http://argouml.tigris.org/source/browse/argouml/branches/gsoc2008/feature3_5140_bszanto/src/org/argouml/uml/diagram/static_structure/ui/FigOperation.java?view=diff&rev=15518&p1=branches/gsoc2008/feature3_5140_bszanto/src/org/argouml/uml/diagram/static_structure/ui/FigOperation.java&p2=branches/gsoc2008/feature3_5140_bszanto/src/org/argouml/uml/diagram/static_structure/ui/FigOperation.java&r1=15517&r2=15518
==============================================================================
--- branches/gsoc2008/feature3_5140_bszanto/src/org/argouml/uml/diagram/static_structure/ui/FigOperation.java	(original)
+++ branches/gsoc2008/feature3_5140_bszanto/src/org/argouml/uml/diagram/static_structure/ui/FigOperation.java	2008-08-07 05:12:15-0700
@@ -105,18 +105,11 @@
      */
     public void changeVisibility(Rectangle r) {
         if (super.hit(r)) {         
-            String notation = ProjectManager.getManager().getCurrentProject()
-                    .getProjectSettings().getNotationLanguage();
-            
             // The hit zone is different for the different notations.
             // Java uses words (public, protected, private) while UML 1.4 uses
-            // signs (+, -, ~, #).
-            int offset = 0;
-            if (notation.equals("Java")) {
-                offset = 50;
-            } else if (notation.equals("UML 1.4")) {
-                offset = 10;
-            }
+            // signs (+, -, ~, #), and so on...
+            int offset = ProjectManager.getManager().getCurrentProject()
+                    .getProjectSettings().getNotationName().getNotationOffset();
              
             if (r.x < (_x + offset)) {
                 Object operation = getOwner();
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.