Fix some (trivial) java warnings 09/7709/2
Sylvestre Ledru [Sun, 24 Jun 2012 13:51:12 +0000 (15:51 +0200)]
Change-Id: Id721bd57dc6a978dd9a18cbfe761262827f103f1

29 files changed:
scilab/modules/console/src/java/org/scilab/modules/console/SciConsole.java
scilab/modules/console/src/java/org/scilab/modules/console/SciDropTargetListener.java
scilab/modules/console/src/java/org/scilab/modules/console/SciInputCommandView.java
scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/graphicObject/GraphicObject.java
scilab/modules/graphic_objects/src/java/org/scilab/modules/graphic_objects/legend/Legend.java
scilab/modules/gui/src/java/org/scilab/modules/gui/events/GlobalKeyEventWatcher.java
scilab/modules/gui/src/java/org/scilab/modules/gui/events/Jxclick.java
scilab/modules/gui/src/java/org/scilab/modules/gui/events/Jxgetmouse.java
scilab/modules/gui/src/java/org/scilab/modules/gui/utils/SciDockingListener.java
scilab/modules/gui/src/java/org/scilab/modules/gui/utils/UnitsConverter.java
scilab/modules/hdf5/src/java/org/scilab/modules/hdf5/read/H5ReadScilabBoolean.java
scilab/modules/helptools/src/java/org/scilab/modules/helptools/BuildDocObject.java
scilab/modules/helptools/src/java/org/scilab/modules/helptools/image/ImageConverter.java
scilab/modules/history_browser/src/java/org/scilab/modules/history_browser/CommandHistory.java
scilab/modules/renderer/src/java/org/scilab/modules/renderer/JoGLView/legend/LegendDrawer.java
scilab/modules/scinotes/src/java/org/scilab/modules/scinotes/ScilabEditorPane.java
scilab/modules/scinotes/src/java/org/scilab/modules/scinotes/actions/CapitalizeAction.java
scilab/modules/scinotes/src/java/org/scilab/modules/scinotes/actions/CommentAction.java
scilab/modules/scinotes/src/java/org/scilab/modules/scinotes/actions/CopyAsHTMLAction.java
scilab/modules/scinotes/src/java/org/scilab/modules/scinotes/actions/CutAction.java
scilab/modules/scinotes/src/java/org/scilab/modules/scinotes/actions/DoubleQuoteStringAction.java
scilab/modules/scinotes/src/java/org/scilab/modules/scinotes/actions/EvaluateSelectionAction.java
scilab/modules/scinotes/src/java/org/scilab/modules/scinotes/actions/ExportAction.java
scilab/modules/scinotes/src/java/org/scilab/modules/scinotes/actions/GenerateHelpFromFunctionAction.java
scilab/modules/scinotes/src/java/org/scilab/modules/scinotes/actions/GotoNextAnchorAction.java
scilab/modules/scinotes/src/java/org/scilab/modules/scinotes/actions/GotoPreviousAnchorAction.java
scilab/modules/scinotes/src/java/org/scilab/modules/scinotes/actions/HelpOnKeywordAction.java
scilab/modules/scinotes/src/java/org/scilab/modules/scinotes/actions/IndentAction.java
scilab/modules/scinotes/src/java/org/scilab/modules/scinotes/actions/NextParagraphAction.java

index 2bb734a..4a0179c 100644 (file)
@@ -635,7 +635,7 @@ public abstract class SciConsole extends JPanel {
             }
 
             /* Update the prompt */
-            ((JLabel) ((SciPromptView) config.getPromptView()).getPromptUI()).setFont(font);
+            ((SciPromptView) config.getPromptView()).getPromptUI().setFont(font);
             config.getPromptView().updatePrompt();
             scilabLinesUpdate();
         }
@@ -647,7 +647,7 @@ public abstract class SciConsole extends JPanel {
      */
     public Font getFont() {
         if (sciConsole != null) {
-            return ((JLabel) ((SciPromptView) config.getPromptView()).getPromptUI()).getFont();
+            return ((SciPromptView) config.getPromptView()).getPromptUI().getFont();
         } else {
             return null;
         }
@@ -698,7 +698,7 @@ public abstract class SciConsole extends JPanel {
             }
 
             /* Update the prompt */
-            ((JLabel) ((SciPromptView) config.getPromptView()).getPromptUI()).setForeground(color);
+            ((SciPromptView) config.getPromptView()).getPromptUI().setForeground(color);
             config.getPromptView().updatePrompt();
         }
     }
index be4366f..5970912 100644 (file)
@@ -32,138 +32,138 @@ import java.util.StringTokenizer;
  */
 public class SciDropTargetListener implements DropTargetListener {
 
-               private SciConsole associatedConsole;
-
-               /**
-                * Constructor
-                * @param sciConsole console object associated to this listener
-                */
-               public SciDropTargetListener(SciConsole sciConsole) {
-                       super();
-                       associatedConsole = sciConsole;
-               }
-
-               /**
-                * Drop handling
-                * @param dtde the drop event
-                * @see java.awt.dnd.DropTargetListener#drop(java.awt.dnd.DropTargetDropEvent)
-                */
-               public void drop(DropTargetDropEvent dtde) {
-
-                       dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
-
-                       Transferable transferable = dtde.getTransferable();
-
-                   // New dataflavor created for tests about the type of the object dropped
-               DataFlavor uriListFlavor = null;
-                       try {
-                               uriListFlavor = new DataFlavor("text/uri-list;class=java.lang.String");
-                       } catch (ClassNotFoundException e1) {
-                               e1.printStackTrace();
-                               dtde.rejectDrop();
-                               dtde.dropComplete(false);
-                       }
-
-                       try {
-
-                               if (transferable.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
-                                       List<File> data = (List<File>) transferable.getTransferData(DataFlavor.javaFileListFlavor);
-                                       // Send file names to Scilab
-
-                                       String[] fileNames = new String[data.size()];
-                                       for (int i = 0; i < data.size(); i++) {
-                                               File tmpfile = (File) data.get(i);
-                                               fileNames[i] = tmpfile.toString();
-                                       }
-                                       DropFiles.dropFiles(fileNames);
-
-                                       // Crappy method to make Scilab parser execute the commands stored by dropFiles
-                                       ((SciOutputView) associatedConsole.getConfiguration().getOutputView())
-                                                                                               .getConsole().sendCommandsToScilab("", false, false);
-                               } else if (transferable.isDataFlavorSupported(uriListFlavor)) {
-
-                                       // --- FILE(S) DROP ---
-
-                                       String data = (String) transferable.getTransferData(uriListFlavor);
-
-                           // Get file names as a list
-                           List<String> listOfFiles = new ArrayList<String>(1);
-                                       for (StringTokenizer st = new StringTokenizer(data, "\r\n"); st.hasMoreTokens();) {
-                                             String s = st.nextToken();
-                                             // Have to test length because of last token which length is 1 and has to be ignored
-                                             if (s.length() > 1) {
-                                                 listOfFiles.add(s);
-                                             }
-                                   }
-
-                                       // Send file names to Scilab
-                                       String[] fileNames = new String[listOfFiles.size()];
-                                       for (int i = 0; i < listOfFiles.size(); i++) {
-                                               fileNames[i] = listOfFiles.get(i);
-                                       }
-                                       DropFiles.dropFiles(fileNames);
-
-                                       // Crappy method to make Scilab parser execute the commands stored by dropFiles
-                                       ((SciInputCommandView) associatedConsole.getConfiguration().getInputCommandView()).setCmdBuffer("", false);
-
-                               } else if (transferable.isDataFlavorSupported(DataFlavor.stringFlavor)) {
-
-                                       // --- TEXT DROP ---
-
-                                       String dropContents = (String) transferable.getTransferData(DataFlavor.stringFlavor);
-
-                                       // Send text to the console and remove prompts in text if there are
-                                       //associatedConsole.sendCommandsToScilab(dropContents, true);
-                                       ((SciInputCommandView) associatedConsole.getConfiguration().getInputCommandView()).append(dropContents);
-                               }
-
-                               // If we made it this far, everything worked.
-                       dtde.dropComplete(true);
-
-                       } catch (UnsupportedFlavorException e) {
-                               e.printStackTrace();
-                               dtde.rejectDrop();
-                               dtde.dropComplete(false);
-                       } catch (IOException e) {
-                               e.printStackTrace();
-                               dtde.rejectDrop();
-                               dtde.dropComplete(false);
-                       }
-               }
-
-               /**
-                * Drag beginning handling
-                * @param dtde the drop event
-                * @see java.awt.dnd.DropTargetListener#dragEnter(java.awt.dnd.DropTargetDragEvent)
-                */
-               public void dragEnter(DropTargetDragEvent dtde) {
-                       // Nothing to do in Scilab Console
-               }
-
-               /**
-                * Drag end handling
-                * @param dtde the drop event
-                * @see java.awt.dnd.DropTargetListener#dragExit(java.awt.dnd.DropTargetEvent)
-                */
-               public void dragExit(DropTargetEvent dtde) {
-                       // Nothing to do in Scilab Console
-               }
-
-               /**
-                * Drag over this object handling
-                * @param dtde the drop event
-                * @see java.awt.dnd.DropTargetListener#dragOver(java.awt.dnd.DropTargetDragEvent)
-                */
-               public void dragOver(DropTargetDragEvent dtde) {
-                       // Nothing to do in Scilab Console
-               }
-
-               /**
-                * Drag action change handling
-                * @param dtde the drop event
-                * @see java.awt.dnd.DropTargetListener#dropActionChanged(java.awt.dnd.DropTargetDragEvent)
-                */
-               public void dropActionChanged(DropTargetDragEvent dtde) {
-                       // Nothing to do in Scilab Console
-               }
-       };
+    private SciConsole associatedConsole;
+
+    /**
+     * Constructor
+     * @param sciConsole console object associated to this listener
+     */
+    public SciDropTargetListener(SciConsole sciConsole) {
+        super();
+        associatedConsole = sciConsole;
+    }
+
+    /**
+     * Drop handling
+     * @param dtde the drop event
+     * @see java.awt.dnd.DropTargetListener#drop(java.awt.dnd.DropTargetDropEvent)
+     */
+    public void drop(DropTargetDropEvent dtde) {
+
+        dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
+
+        Transferable transferable = dtde.getTransferable();
+
+        // New dataflavor created for tests about the type of the object dropped
+        DataFlavor uriListFlavor = null;
+        try {
+            uriListFlavor = new DataFlavor("text/uri-list;class=java.lang.String");
+        } catch (ClassNotFoundException e1) {
+            e1.printStackTrace();
+            dtde.rejectDrop();
+            dtde.dropComplete(false);
+        }
+
+        try {
+
+            if (transferable.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
+                List<File> data = (List<File>) transferable.getTransferData(DataFlavor.javaFileListFlavor);
+                // Send file names to Scilab
+
+                String[] fileNames = new String[data.size()];
+                for (int i = 0; i < data.size(); i++) {
+                    File tmpfile = data.get(i);
+                    fileNames[i] = tmpfile.toString();
+                }
+                DropFiles.dropFiles(fileNames);
+
+                // Crappy method to make Scilab parser execute the commands stored by dropFiles
+                ((SciOutputView) associatedConsole.getConfiguration().getOutputView())
+                .getConsole().sendCommandsToScilab("", false, false);
+            } else if (transferable.isDataFlavorSupported(uriListFlavor)) {
+
+                // --- FILE(S) DROP ---
+
+                String data = (String) transferable.getTransferData(uriListFlavor);
+
+                // Get file names as a list
+                List<String> listOfFiles = new ArrayList<String>(1);
+                for (StringTokenizer st = new StringTokenizer(data, "\r\n"); st.hasMoreTokens();) {
+                    String s = st.nextToken();
+                    // Have to test length because of last token which length is 1 and has to be ignored
+                    if (s.length() > 1) {
+                        listOfFiles.add(s);
+                    }
+                }
+
+                // Send file names to Scilab
+                String[] fileNames = new String[listOfFiles.size()];
+                for (int i = 0; i < listOfFiles.size(); i++) {
+                    fileNames[i] = listOfFiles.get(i);
+                }
+                DropFiles.dropFiles(fileNames);
+
+                // Crappy method to make Scilab parser execute the commands stored by dropFiles
+                ((SciInputCommandView) associatedConsole.getConfiguration().getInputCommandView()).setCmdBuffer("", false);
+
+            } else if (transferable.isDataFlavorSupported(DataFlavor.stringFlavor)) {
+
+                // --- TEXT DROP ---
+
+                String dropContents = (String) transferable.getTransferData(DataFlavor.stringFlavor);
+
+                // Send text to the console and remove prompts in text if there are
+                //associatedConsole.sendCommandsToScilab(dropContents, true);
+                ((SciInputCommandView) associatedConsole.getConfiguration().getInputCommandView()).append(dropContents);
+            }
+
+            // If we made it this far, everything worked.
+            dtde.dropComplete(true);
+
+        } catch (UnsupportedFlavorException e) {
+            e.printStackTrace();
+            dtde.rejectDrop();
+            dtde.dropComplete(false);
+        } catch (IOException e) {
+            e.printStackTrace();
+            dtde.rejectDrop();
+            dtde.dropComplete(false);
+        }
+    }
+
+    /**
+     * Drag beginning handling
+     * @param dtde the drop event
+     * @see java.awt.dnd.DropTargetListener#dragEnter(java.awt.dnd.DropTargetDragEvent)
+     */
+    public void dragEnter(DropTargetDragEvent dtde) {
+        // Nothing to do in Scilab Console
+    }
+
+    /**
+     * Drag end handling
+     * @param dtde the drop event
+     * @see java.awt.dnd.DropTargetListener#dragExit(java.awt.dnd.DropTargetEvent)
+     */
+    public void dragExit(DropTargetEvent dtde) {
+        // Nothing to do in Scilab Console
+    }
+
+    /**
+     * Drag over this object handling
+     * @param dtde the drop event
+     * @see java.awt.dnd.DropTargetListener#dragOver(java.awt.dnd.DropTargetDragEvent)
+     */
+    public void dragOver(DropTargetDragEvent dtde) {
+        // Nothing to do in Scilab Console
+    }
+
+    /**
+     * Drag action change handling
+     * @param dtde the drop event
+     * @see java.awt.dnd.DropTargetListener#dropActionChanged(java.awt.dnd.DropTargetDragEvent)
+     */
+    public void dropActionChanged(DropTargetDragEvent dtde) {
+        // Nothing to do in Scilab Console
+    }
+};
index 61ac8a0..5be16b8 100644 (file)
@@ -286,7 +286,7 @@ public class SciInputCommandView extends ConsoleTextPane implements InputCommand
             int y = 0;
             try {
                 Rectangle rect = modelToView(getCaretPosition());
-                y = (int) (rect.height + rect.y + 1);
+                y = rect.height + rect.y + 1;
             } catch (BadLocationException ex) { }
 
             int sheight = height;
index 9dfab65..78fd23b 100644 (file)
@@ -138,7 +138,7 @@ public abstract class GraphicObject implements Cloneable {
          */
         copy.setSelectedChild("");
 
-        return (GraphicObject) copy;
+        return copy;
     }
 
     abstract public void accept(Visitor visitor) throws ObjectRemovedException;
index d02beaf..4c5d0d5 100644 (file)
@@ -26,65 +26,65 @@ import static org.scilab.modules.graphic_objects.graphicObject.GraphicObjectProp
  * @author Manuel JULIACHS
  */
 public class Legend extends ClippableTextObject {
-       /** Legend properties names */
-       private enum LegendProperty { LINKS, LINKSCOUNT, LEGENDLOCATION, POSITION };
-       
-       /** Legend location */
-       public enum LegendLocation { IN_UPPER_RIGHT, IN_UPPER_LEFT, IN_LOWER_RIGHT, IN_LOWER_LEFT,
-               OUT_UPPER_RIGHT, OUT_UPPER_LEFT, OUT_LOWER_RIGHT, OUT_LOWER_LEFT,
-               UPPER_CAPTION, LOWER_CAPTION, BY_COORDINATES;
-
-               /**
-                * Converts an integer to the corresponding enum
-                * @param intValue the integer value
-                * @return the legend location enum
-                */
-               public static LegendLocation intToEnum(Integer intValue) {
-                       switch (intValue) {
-                               case 0:
-                                       return LegendLocation.IN_UPPER_RIGHT;
-                               case 1:
-                                       return LegendLocation.IN_UPPER_LEFT;
-                               case 2:
-                                       return LegendLocation.IN_LOWER_RIGHT;
-                               case 3:
-                                       return LegendLocation.IN_LOWER_LEFT;
-                               case 4:
-                                       return LegendLocation.OUT_UPPER_RIGHT;
-                               case 5:
-                                       return LegendLocation.OUT_UPPER_LEFT;
-                               case 6:
-                                       return LegendLocation.OUT_LOWER_RIGHT;
-                               case 7:
-                                       return LegendLocation.OUT_LOWER_LEFT;
-                               case 8:
-                                       return LegendLocation.UPPER_CAPTION;
-                               case 9:
-                                       return LegendLocation.LOWER_CAPTION;
-                               case 10:
-                                       return LegendLocation.BY_COORDINATES;
-                               default:
-                                       return null;
-                       }
-               }
-       };
-       
-       /** List of the polylines referred to */
-       private ArrayList <String> links;
-
-       /** Legend location */
-       private LegendLocation legendLocation;
-
-       /** 2D position relative to the parent axes bounds */
-       private double[] position;
-
-       /** Constructor */
-       public Legend() {
-               super();
-               this.links = new ArrayList<String>(0);
-               this.legendLocation = LegendLocation.LOWER_CAPTION;
-               position = new double[2];
-       }
+    /** Legend properties names */
+    private enum LegendProperty { LINKS, LINKSCOUNT, LEGENDLOCATION, POSITION };
+
+    /** Legend location */
+    public enum LegendLocation { IN_UPPER_RIGHT, IN_UPPER_LEFT, IN_LOWER_RIGHT, IN_LOWER_LEFT,
+                                 OUT_UPPER_RIGHT, OUT_UPPER_LEFT, OUT_LOWER_RIGHT, OUT_LOWER_LEFT,
+                                 UPPER_CAPTION, LOWER_CAPTION, BY_COORDINATES;
+
+                                 /**
+                                  * Converts an integer to the corresponding enum
+                                  * @param intValue the integer value
+                                  * @return the legend location enum
+                                  */
+    public static LegendLocation intToEnum(Integer intValue) {
+        switch (intValue) {
+            case 0:
+                return LegendLocation.IN_UPPER_RIGHT;
+            case 1:
+                return LegendLocation.IN_UPPER_LEFT;
+            case 2:
+                return LegendLocation.IN_LOWER_RIGHT;
+            case 3:
+                return LegendLocation.IN_LOWER_LEFT;
+            case 4:
+                return LegendLocation.OUT_UPPER_RIGHT;
+            case 5:
+                return LegendLocation.OUT_UPPER_LEFT;
+            case 6:
+                return LegendLocation.OUT_LOWER_RIGHT;
+            case 7:
+                return LegendLocation.OUT_LOWER_LEFT;
+            case 8:
+                return LegendLocation.UPPER_CAPTION;
+            case 9:
+                return LegendLocation.LOWER_CAPTION;
+            case 10:
+                return LegendLocation.BY_COORDINATES;
+            default:
+                return null;
+        }
+    }
+                               };
+
+    /** List of the polylines referred to */
+    private ArrayList <String> links;
+
+    /** Legend location */
+    private LegendLocation legendLocation;
+
+    /** 2D position relative to the parent axes bounds */
+    private double[] position;
+
+    /** Constructor */
+    public Legend() {
+        super();
+        this.links = new ArrayList<String>(0);
+        this.legendLocation = LegendLocation.LOWER_CAPTION;
+        position = new double[2];
+    }
 
     @Override
     public void accept(Visitor visitor) {
@@ -92,227 +92,227 @@ public class Legend extends ClippableTextObject {
     }
 
     /**
-        * Returns the enum associated to a property name
-        * @param propertyName the property name
-        * @return the property enum
-        */
-       public Object getPropertyFromName(String propertyName) {
-               if (propertyName.equals(__GO_LINKS__)) {
-                       return LegendProperty.LINKS;
-               } else if (propertyName.equals(__GO_LINKS_COUNT__)) {
-                       return LegendProperty.LINKSCOUNT;
-               } else if (propertyName.equals(__GO_LEGEND_LOCATION__)) {
-                       return LegendProperty.LEGENDLOCATION;
-               } else if (propertyName.equals(__GO_POSITION__)) {
-                       return LegendProperty.POSITION;
-               } else {
-                       return super.getPropertyFromName(propertyName);
-               }
-       }
-
-       /**
-        * Fast property get method
-        * @param property the property to get
-        * @return the property value
-        */
-       public Object getProperty(Object property) {
-               if (property == LegendProperty.LINKS) {
-                       return getValidLinks();
-               } else if (property == LegendProperty.LINKSCOUNT) {
-                       return getValidLinksCount();
-               } else if (property == LegendProperty.LEGENDLOCATION) {
-                       return getLegendLocation();
-               } else if (property == LegendProperty.POSITION) {
-                       return getPosition();
-               } else if (property == TextObjectProperty.TEXT_ARRAY_DIMENSIONS) {
-                       return getValidTextArrayDimensions();
-               } else if (property == FormattedText.FormattedTextProperty.TEXT) {
-                       return getValidTextStrings();
-               } else {
-                       return super.getProperty(property);     
-               }
-       }
-
-       /**
-        * Fast property set method
-        * @param property the property to set
-        * @param value the property value
-        * @return true if the property has been set, false otherwise
-        */
-       public UpdateStatus setProperty(Object property, Object value) {
-               if (property == LegendProperty.LINKS) {
-                       setLinks((String[]) value);
-               } else if (property == LegendProperty.LEGENDLOCATION) {
-                       setLegendLocation((Integer) value);
-               } else if (property == LegendProperty.POSITION) {
-                       setPosition((Double[]) value);
-               } else {
-                       return super.setProperty(property, value);
-               }
-
-               return UpdateStatus.Success;
-       }
-
-       /**
-        * @return the legendLocation
-        */
-       public Integer getLegendLocation() {
-               return getLegendLocationAsEnum().ordinal();
-       }
-
-       /**
-        * @return the legendLocation
-        */
-       public LegendLocation getLegendLocationAsEnum() {
-               return legendLocation;
-       }
-
-       /**
-        * @param legendLocation the legendLocation to set
-        */
-       public void setLegendLocation(Integer legendLocation) {
-               setLegendLocationAsEnum(LegendLocation.intToEnum(legendLocation));
-       }
-
-       /**
-        * @param legendLocation the legendLocation to set
-        */
-       public void setLegendLocationAsEnum(LegendLocation legendLocation) {
-               this.legendLocation = legendLocation;
-       }
-
-       /**
-        * @return the valid links
-        */
-       public String[] getValidLinks() {
-               int numValidLinks = 0;
-               ArrayList <String> validLinks = new ArrayList<String>(0);
-
-               for (int i = 0; i < links.size(); i++) {
-                       GraphicObject object = (GraphicObject) GraphicController.getController().getObjectFromId(links.get(i));
-
-                       if (object != null) {
-                               validLinks.add(links.get(i));
-                               numValidLinks++;
-                       }
-               }
-
-               return validLinks.toArray(new String[validLinks.size()]);
-       }
-
-       /**
-        * @return the valid links count
-        */
-       public Integer getValidLinksCount() {
-               int numValidLinks = 0;
-
-               for (int i = 0; i < links.size(); i++) {
-                       GraphicObject object = (GraphicObject) GraphicController.getController().getObjectFromId(links.get(i));
-
-                       if (object != null) {
-                               numValidLinks++;
-                       }
-               }
-
-               return numValidLinks;
-       }
-
-       /**
-        * @return the links
-        */
-       public String[] getLinks() {
-               String[] retLinks = new String[links.size()];
-
-               for (int i = 0; i < links.size(); i++) {
-                       retLinks[i] = links.get(i);
-               }
-
-               return retLinks;
-       }
-
-       /**
-        * @return the links count
-        */
-       public Integer getLinksCount() {
-               return links.size();
-       }
-
-       /**
-        * @param links the links to set
-        */
-       public void setLinks(String[] links) {
-               if (!this.links.isEmpty()) {
-                       this.links.clear();
-               }
-
-               for (int i = 0; i < links.length; i++) {
-                       this.links.add(links[i]);
-               }
-       }
-
-       /**
-        * Returns the dimensions of the text array, taking into account only valid links.
-        * @return the dimensions of the text array
-        */
-       public Integer[] getValidTextArrayDimensions() {
-               return new Integer[]{getValidLinksCount(), 1};
-       }
-
-       /**
-        * Returns the array of valid text strings.
-        * A string if considered valid if its corresponding link is also valid, otherwise it is ignored.
-        * This is used when getting the Legend's TEXT_STRINGS property in order to return only the strings
-        * corresponding to valid links (see also getValidLinks).
-        * @return the valid text strings
-        */
-       public String[] getValidTextStrings() {
-               int numValidLinks = 0;
-               ArrayList <String> validStrings = new ArrayList<String>(0);
-
-               /* Text strings are stored in reverse order relative to links. */
-               for (int i = 0; i < links.size(); i++) {
-                       GraphicObject object = (GraphicObject) GraphicController.getController().getObjectFromId(links.get(links.size()-i-1));
-
-                       if (object != null) {
-                               validStrings.add(text[i].getText());
-                               numValidLinks++;
-                       }
-               }
-
-               return validStrings.toArray(new String[validStrings.size()]);
-       }
-
-       /**
-        * @param links the links to set
-        */
-       public void setLinks(ArrayList<String> links) {
-               this.links = links;
-       }
-
-       /**
-        * @return the position
-        */
-       public Double[] getPosition() {
-               Double[] retPosition = new Double[2];
-               retPosition[0] = position[0];
-               retPosition[1] = position[1];
-
-               return retPosition;
-       }
-
-       /**
-        * @param position the position to set
-        */
-       public void setPosition(Double[] position) {
-               this.position[0] = position[0];
-               this.position[1] = position[1];
-       }
-
-       /**
-        * @return Type as String
-        */
-       public String getType() {
-               return "Legend";
-       }
+     * Returns the enum associated to a property name
+     * @param propertyName the property name
+     * @return the property enum
+     */
+    public Object getPropertyFromName(String propertyName) {
+        if (propertyName.equals(__GO_LINKS__)) {
+            return LegendProperty.LINKS;
+        } else if (propertyName.equals(__GO_LINKS_COUNT__)) {
+            return LegendProperty.LINKSCOUNT;
+        } else if (propertyName.equals(__GO_LEGEND_LOCATION__)) {
+            return LegendProperty.LEGENDLOCATION;
+        } else if (propertyName.equals(__GO_POSITION__)) {
+            return LegendProperty.POSITION;
+        } else {
+            return super.getPropertyFromName(propertyName);
+        }
+    }
+
+    /**
+     * Fast property get method
+     * @param property the property to get
+     * @return the property value
+     */
+    public Object getProperty(Object property) {
+        if (property == LegendProperty.LINKS) {
+            return getValidLinks();
+        } else if (property == LegendProperty.LINKSCOUNT) {
+            return getValidLinksCount();
+        } else if (property == LegendProperty.LEGENDLOCATION) {
+            return getLegendLocation();
+        } else if (property == LegendProperty.POSITION) {
+            return getPosition();
+        } else if (property == TextObjectProperty.TEXT_ARRAY_DIMENSIONS) {
+            return getValidTextArrayDimensions();
+        } else if (property == FormattedText.FormattedTextProperty.TEXT) {
+            return getValidTextStrings();
+        } else {
+            return super.getProperty(property);
+        }
+    }
+
+    /**
+     * Fast property set method
+     * @param property the property to set
+     * @param value the property value
+     * @return true if the property has been set, false otherwise
+     */
+    public UpdateStatus setProperty(Object property, Object value) {
+        if (property == LegendProperty.LINKS) {
+            setLinks((String[]) value);
+        } else if (property == LegendProperty.LEGENDLOCATION) {
+            setLegendLocation((Integer) value);
+        } else if (property == LegendProperty.POSITION) {
+            setPosition((Double[]) value);
+        } else {
+            return super.setProperty(property, value);
+        }
+
+        return UpdateStatus.Success;
+    }
+
+    /**
+     * @return the legendLocation
+     */
+    public Integer getLegendLocation() {
+        return getLegendLocationAsEnum().ordinal();
+    }
+
+    /**
+     * @return the legendLocation
+     */
+    public LegendLocation getLegendLocationAsEnum() {
+        return legendLocation;
+    }
+
+    /**
+     * @param legendLocation the legendLocation to set
+     */
+    public void setLegendLocation(Integer legendLocation) {
+        setLegendLocationAsEnum(LegendLocation.intToEnum(legendLocation));
+    }
+
+    /**
+     * @param legendLocation the legendLocation to set
+     */
+    public void setLegendLocationAsEnum(LegendLocation legendLocation) {
+        this.legendLocation = legendLocation;
+    }
+
+    /**
+     * @return the valid links
+     */
+    public String[] getValidLinks() {
+        int numValidLinks = 0;
+        ArrayList <String> validLinks = new ArrayList<String>(0);
+
+        for (int i = 0; i < links.size(); i++) {
+            GraphicObject object = GraphicController.getController().getObjectFromId(links.get(i));
+
+            if (object != null) {
+                validLinks.add(links.get(i));
+                numValidLinks++;
+            }
+        }
+
+        return validLinks.toArray(new String[validLinks.size()]);
+    }
+
+    /**
+     * @return the valid links count
+     */
+    public Integer getValidLinksCount() {
+        int numValidLinks = 0;
+
+        for (int i = 0; i < links.size(); i++) {
+            GraphicObject object = GraphicController.getController().getObjectFromId(links.get(i));
+
+            if (object != null) {
+                numValidLinks++;
+            }
+        }
+
+        return numValidLinks;
+    }
+
+    /**
+     * @return the links
+     */
+    public String[] getLinks() {
+        String[] retLinks = new String[links.size()];
+
+        for (int i = 0; i < links.size(); i++) {
+            retLinks[i] = links.get(i);
+        }
+
+        return retLinks;
+    }
+
+    /**
+     * @return the links count
+     */
+    public Integer getLinksCount() {
+        return links.size();
+    }
+
+    /**
+     * @param links the links to set
+     */
+    public void setLinks(String[] links) {
+        if (!this.links.isEmpty()) {
+            this.links.clear();
+        }
+
+        for (int i = 0; i < links.length; i++) {
+            this.links.add(links[i]);
+        }
+    }
+
+    /**
+     * Returns the dimensions of the text array, taking into account only valid links.
+     * @return the dimensions of the text array
+     */
+    public Integer[] getValidTextArrayDimensions() {
+        return new Integer[] {getValidLinksCount(), 1};
+    }
+
+    /**
+     * Returns the array of valid text strings.
+     * A string if considered valid if its corresponding link is also valid, otherwise it is ignored.
+     * This is used when getting the Legend's TEXT_STRINGS property in order to return only the strings
+     * corresponding to valid links (see also getValidLinks).
+     * @return the valid text strings
+     */
+    public String[] getValidTextStrings() {
+        int numValidLinks = 0;
+        ArrayList <String> validStrings = new ArrayList<String>(0);
+
+        /* Text strings are stored in reverse order relative to links. */
+        for (int i = 0; i < links.size(); i++) {
+            GraphicObject object = GraphicController.getController().getObjectFromId(links.get(links.size() - i - 1));
+
+            if (object != null) {
+                validStrings.add(text[i].getText());
+                numValidLinks++;
+            }
+        }
+
+        return validStrings.toArray(new String[validStrings.size()]);
+    }
+
+    /**
+     * @param links the links to set
+     */
+    public void setLinks(ArrayList<String> links) {
+        this.links = links;
+    }
+
+    /**
+     * @return the position
+     */
+    public Double[] getPosition() {
+        Double[] retPosition = new Double[2];
+        retPosition[0] = position[0];
+        retPosition[1] = position[1];
+
+        return retPosition;
+    }
+
+    /**
+     * @param position the position to set
+     */
+    public void setPosition(Double[] position) {
+        this.position[0] = position[0];
+        this.position[1] = position[1];
+    }
+
+    /**
+     * @return Type as String
+     */
+    public String getType() {
+        return "Legend";
+    }
 
 }
index 2923b53..7c311ca 100644 (file)
@@ -1,11 +1,11 @@
 /*
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) 2007 - INRIA - Bruno Jofret
- * 
+ *
  * This file must be used under the terms of the CeCILL.
  * This source file is licensed as described in the file COPYING, which
  * you should have received as part of this distribution.  The terms
- * are also available at    
+ * are also available at
  * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
  *
  */
@@ -16,35 +16,35 @@ import java.awt.event.AWTEventListener;
 import java.awt.event.KeyEvent;
 
 import org.scilab.modules.gui.utils.Debug;
+
 /**
  * Global key event watcher.
  * @author Bruno Jofret
  */
 public abstract class GlobalKeyEventWatcher implements AWTEventListener {
 
-       /**
-        *  Constructor.
-        */
-       public GlobalKeyEventWatcher() { }
-       
-       /** 
-        * Global key event watcher.
-        * 
-        * @param event : The Key event caught.
-        * @see java.awt.event.AWTEventListener#eventDispatched(java.awt.AWTEvent)
-        */
-       public void eventDispatched(AWTEvent event) {
-               // DEBUG
-               Debug.DEBUG(this.getClass().getSimpleName(),((AWTEvent) event).toString());
-               keyEventFilter((KeyEvent) event);
-       }
-       
-       /**
-        * Method to filter the event received.
-        * Depends off what kind of function is called.
-        * 
-        * @param keyEvent : the key event caught 
-        */
-       public abstract void keyEventFilter(KeyEvent keyEvent);
+    /**
+     *  Constructor.
+     */
+    public GlobalKeyEventWatcher() { }
+
+    /**
+     * Global key event watcher.
+     *
+     * @param event : The Key event caught.
+     * @see java.awt.event.AWTEventListener#eventDispatched(java.awt.AWTEvent)
+     */
+    public void eventDispatched(AWTEvent event) {
+        // DEBUG
+        Debug.DEBUG(this.getClass().getSimpleName(), event.toString());
+        keyEventFilter((KeyEvent) event);
+    }
+
+    /**
+     * Method to filter the event received.
+     * Depends off what kind of function is called.
+     *
+     * @param keyEvent : the key event caught
+     */
+    public abstract void keyEventFilter(KeyEvent keyEvent);
 }
index ec5603c..47ac3d1 100644 (file)
@@ -1,11 +1,11 @@
 /*
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) 2007 - INRIA - Bruno Jofret
- * 
+ *
  * This file must be used under the terms of the CeCILL.
  * This source file is licensed as described in the file COPYING, which
  * you should have received as part of this distribution.  The terms
- * are also available at    
+ * are also available at
  * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
  *
  */
@@ -27,121 +27,118 @@ import org.scilab.modules.gui.utils.SciTranslator;
  */
 public final class Jxclick {
 
-       private static int keyChar;
+    private static int keyChar;
 
-       /**
-        * PRIVATE constructor
-        * We do not want a Jxclick object.
-        */
-       private Jxclick() { }
+    /**
+     * PRIVATE constructor
+     * We do not want a Jxclick object.
+     */
+    private Jxclick() { }
 
-       /**
-        * Scilab call point for xclick.
-        */
-       public static void xclick() {
-               /*
-                *  Enable the local keyActionFilter function
-                *  to be called when a keyEvent is caught.
-                */     
-               GlobalEventWatcher.enable(new GlobalKeyEventWatcher() {
-                       public void keyEventFilter(KeyEvent keyEvent) {
-                               keyActionFilter(keyEvent);
-                       }
-               });
-               /*
-                *  Enable the local mouseActionFilter function
-                *  to be called when a mouseEvent is caught.
-                */             
-               GlobalEventWatcher.enable(new GlobalMouseEventWatcher(AWTEvent.MOUSE_EVENT_MASK) {
-                       public void mouseEventFilter(MouseEvent mouseEvent,
-                                       String axesUID, int scilabMouseAction, boolean isControlDown) {
-                               mouseActionFilter(mouseEvent, axesUID, scilabMouseAction, isControlDown);       
-                       }
-               });
-               synchronized (ClickInfos.getInstance()) {
-                       try {
-                               ClickInfos.getInstance().init();
-                               ClickInfos.getInstance().wait();
-                       } catch (InterruptedException e) {
-                               e.printStackTrace();
-                       }
-               }
-               GlobalEventWatcher.disable();
-       }
+    /**
+     * Scilab call point for xclick.
+     */
+    public static void xclick() {
+        /*
+         *  Enable the local keyActionFilter function
+         *  to be called when a keyEvent is caught.
+         */
+        GlobalEventWatcher.enable(new GlobalKeyEventWatcher() {
+            public void keyEventFilter(KeyEvent keyEvent) {
+                keyActionFilter(keyEvent);
+            }
+        });
+        /*
+         *  Enable the local mouseActionFilter function
+         *  to be called when a mouseEvent is caught.
+         */
+        GlobalEventWatcher.enable(new GlobalMouseEventWatcher(AWTEvent.MOUSE_EVENT_MASK) {
+            public void mouseEventFilter(MouseEvent mouseEvent,
+            String axesUID, int scilabMouseAction, boolean isControlDown) {
+                mouseActionFilter(mouseEvent, axesUID, scilabMouseAction, isControlDown);
+            }
+        });
+        synchronized (ClickInfos.getInstance()) {
+            try {
+                ClickInfos.getInstance().init();
+                ClickInfos.getInstance().wait();
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+        }
+        GlobalEventWatcher.disable();
+    }
 
-       /**
-        * @return the mouseButtonNumber
-        */
-       public static int getMouseButtonNumber() {
-               return ClickInfos.getInstance().getMouseButtonNumber();
-       }
-       /**
-        * @return the xCoordinate
-        */
-       public static double getXCoordinate() {
-               return ClickInfos.getInstance().getXCoordinate();
-       }
-       /**
-        * @return the yCoordinate
-        */
-       public static double getYCoordinate() {
-               return ClickInfos.getInstance().getYCoordinate();
-       }
-       /**
-        * @return the windowID
-        */
-       public static String getWindowID() {
-               return ClickInfos.getInstance().getWindowID();
-       }
-       /**
-        * @return the menuCallback
-        */
-       public static String getMenuCallback() {
-               return ClickInfos.getInstance().getMenuCallback();
-       }
+    /**
+     * @return the mouseButtonNumber
+     */
+    public static int getMouseButtonNumber() {
+        return ClickInfos.getInstance().getMouseButtonNumber();
+    }
+    /**
+     * @return the xCoordinate
+     */
+    public static double getXCoordinate() {
+        return ClickInfos.getInstance().getXCoordinate();
+    }
+    /**
+     * @return the yCoordinate
+     */
+    public static double getYCoordinate() {
+        return ClickInfos.getInstance().getYCoordinate();
+    }
+    /**
+     * @return the windowID
+     */
+    public static String getWindowID() {
+        return ClickInfos.getInstance().getWindowID();
+    }
+    /**
+     * @return the menuCallback
+     */
+    public static String getMenuCallback() {
+        return ClickInfos.getInstance().getMenuCallback();
+    }
 
-       /**
-        * Manage xclick behaviour for keyboard entry.
-        * 1 - Key has been pressed.
-        * 2 - CTRL + Key has been pressed.
-        * 
-        * @param keyEvent : the Key Event caught
-        */
-       private static void keyActionFilter(KeyEvent keyEvent) {        
-               if (keyEvent.getID() == KeyEvent.KEY_PRESSED) {
-                       if (!Character.isJavaIdentifierStart(keyEvent.getKeyChar())) {
-                               keyChar = keyEvent.getKeyChar(); 
-                       } 
-                       else {
-                               if (keyEvent.isShiftDown()) {
-                                       keyChar = keyEvent.getKeyCode();
-                               } 
-                               else {
-                                       keyChar = Character.toLowerCase(keyEvent.getKeyCode());
-                               }
-                       }
-               } 
-               else if (keyEvent.getID() == KeyEvent.KEY_TYPED) {      
-                       if (keyEvent.getSource().getClass().getCanonicalName().contains("javax.media.opengl")) {
-                               if (GlobalEventWatcher.isActivated()) {
-                                   GlobalEventFilter.filterKey(keyChar, GlobalEventWatcher.getAxesUID(),((KeyEvent) keyEvent).isControlDown());
-                               }
-                       }
-               } 
-       }
-       /**
-        * Manage xclick behaviour for mouse entry.
-        * 
-        * @param mouseEvent : the Mouse Event caught
-        * @param scilabMouseAction : the integer scilab code for mouse action.
-        * @param axes : the axes where action occurs.
-        * @param isControlDown true if the CTRL key has been pressed
-        */
-       private static void mouseActionFilter(MouseEvent mouseEvent, String axesUID, int scilabMouseAction, boolean isControlDown) {    
-               if (scilabMouseAction == SciTranslator.PRESSED
-                               || scilabMouseAction == SciTranslator.CLICKED
-                               || scilabMouseAction == SciTranslator.DCLICKED) {
-                       GlobalEventFilter.filterMouse(mouseEvent, axesUID, scilabMouseAction, isControlDown);
-               }
-       }       
+    /**
+     * Manage xclick behaviour for keyboard entry.
+     * 1 - Key has been pressed.
+     * 2 - CTRL + Key has been pressed.
+     *
+     * @param keyEvent : the Key Event caught
+     */
+    private static void keyActionFilter(KeyEvent keyEvent) {
+        if (keyEvent.getID() == KeyEvent.KEY_PRESSED) {
+            if (!Character.isJavaIdentifierStart(keyEvent.getKeyChar())) {
+                keyChar = keyEvent.getKeyChar();
+            } else {
+                if (keyEvent.isShiftDown()) {
+                    keyChar = keyEvent.getKeyCode();
+                } else {
+                    keyChar = Character.toLowerCase(keyEvent.getKeyCode());
+                }
+            }
+        } else if (keyEvent.getID() == KeyEvent.KEY_TYPED) {
+            if (keyEvent.getSource().getClass().getCanonicalName().contains("javax.media.opengl")) {
+                if (GlobalEventWatcher.isActivated()) {
+                    GlobalEventFilter.filterKey(keyChar, GlobalEventWatcher.getAxesUID(), keyEvent.isControlDown());
+                }
+            }
+        }
+    }
+    /**
+     * Manage xclick behaviour for mouse entry.
+     *
+     * @param mouseEvent : the Mouse Event caught
+     * @param scilabMouseAction : the integer scilab code for mouse action.
+     * @param axes : the axes where action occurs.
+     * @param isControlDown true if the CTRL key has been pressed
+     */
+    private static void mouseActionFilter(MouseEvent mouseEvent, String axesUID, int scilabMouseAction, boolean isControlDown) {
+        if (scilabMouseAction == SciTranslator.PRESSED
+                || scilabMouseAction == SciTranslator.CLICKED
+                || scilabMouseAction == SciTranslator.DCLICKED) {
+            GlobalEventFilter.filterMouse(mouseEvent, axesUID, scilabMouseAction, isControlDown);
+        }
+    }
 }
index 51cefe9..d446bb8 100644 (file)
@@ -1,11 +1,11 @@
 /*
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) 2007 - INRIA - Bruno Jofret
- * 
+ *
  * This file must be used under the terms of the CeCILL.
  * This source file is licensed as described in the file COPYING, which
  * you should have received as part of this distribution.  The terms
- * are also available at    
+ * are also available at
  * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
  *
  */
@@ -27,155 +27,154 @@ import org.scilab.modules.gui.utils.SciTranslator;
  */
 public final class Jxgetmouse {
 
-       private static int keyChar;
-       private static boolean isControlDown;
-       private static boolean watchMotion;
-       private static boolean watchRelease; 
-       private static final int MOVED = -1;
-
-       /**
-        * Tool Class, constructor is private.
-        */
-       private Jxgetmouse() { }
-
-       /**
-        * Default call for xgetmouse.
-        */
-       public static void xgetmouse() {
-               xgetmouse(true, false);
-       }
-
-       /**
-        * Scilab call point for xgetmouse.
-        *
-        * @param withMotion : Means xgetmouse is mouse motion sensitive.
-        * @param withRelease : Means xgetmouse is release sensitive.
-        */
-       public static void xgetmouse(boolean withMotion, boolean withRelease) {
-               watchMotion = withMotion;
-               watchRelease = withRelease;
-               /*
-                *  Enable the local keyActionFilter function
-                *  to be called when a keyEvent is caught.
-                */             
-               GlobalEventWatcher.enable(new GlobalKeyEventWatcher() {
-                       public void keyEventFilter(KeyEvent keyEvent) {
-                               keyActionFilter(keyEvent);
-                       }
-               });
-               long eventMask = AWTEvent.MOUSE_EVENT_MASK;
-               if (watchMotion) {
-                       eventMask += AWTEvent.MOUSE_MOTION_EVENT_MASK;
-               }
-               /*
-                *  Enable the local mouseActionFilter function
-                *  to be called when a mouseEvent is caught.
-                */             
-               GlobalEventWatcher.enable(new GlobalMouseEventWatcher(eventMask)
-               {
-                       public void mouseEventFilter(MouseEvent mouseEvent,
-                                       String axesUID, int scilabMouseAction, boolean isControlDown) {
-                               mouseActionFilter(mouseEvent, axesUID, scilabMouseAction, isControlDown);       
-                       }
-               });
-               synchronized (ClickInfos.getInstance()) {
-                       try {
-                               ClickInfos.getInstance().init();
-                               ClickInfos.getInstance().wait();
-                       } catch (InterruptedException e) {
-                               e.printStackTrace();
-                       }
-               }
-               GlobalEventWatcher.disable();
-       }
-
-       /**
-        * @return the mouseButtonNumber
-        */
-       public static int getMouseButtonNumber() {
-               return ClickInfos.getInstance().getMouseButtonNumber();
-       }
-       /**
-        * @return the xCoordinate
-        */
-       public static double getXCoordinate() {
-               return ClickInfos.getInstance().getXCoordinate();
-       }
-       /**
-        * @return the yCoordinate
-        */
-       public static double getYCoordinate() {
-               return ClickInfos.getInstance().getYCoordinate();
-       }
-       /**
-        * @return the WindowsID
-        */
-       public static String getWindowsID() {
-               return ClickInfos.getInstance().getWindowID();
-       }
-       
-       
-       
-       /**
-        * Manage xgetmouse behaviour for keyboard entry.
-        * 1 - Key has been pressed.
-        * 2 - CTRL + Key has been pressed.
-        * 3 - Key has been released
-        * 
-        * @param keyEvent : the Key Event caught
-        */
-       private static void keyActionFilter(KeyEvent keyEvent) {        
-               /*
-                * If a key is pressed, only remember the key and if CTRL is pressed either.
-                */
-               if (keyEvent.getID() == KeyEvent.KEY_PRESSED) {
-                       if (!Character.isJavaIdentifierStart(keyEvent.getKeyChar())) {
-                               keyChar = keyEvent.getKeyChar(); 
-                       } else {
-                               if (keyEvent.isShiftDown()) {
-                                       keyChar = keyEvent.getKeyCode();
-                               } else {
-                                       keyChar = Character.toLowerCase(keyEvent.getKeyCode());
-                               }
-                       }
-                       isControlDown = ((KeyEvent) keyEvent).isControlDown();
-               } else if (keyEvent.getSource() instanceof SwingScilabAxes) {
-                       /* Now we have have to be sure we are in a Canvas. */
-                       /*
-                        * If a RELEASED is seen use -keyChar
-                        */
-                       if (keyEvent.getID() == KeyEvent.KEY_RELEASED) {
-                           GlobalEventFilter.filterKey(-keyChar, GlobalEventWatcher.getAxesUID(), isControlDown);
-                       } else if (keyEvent.getID() == KeyEvent.KEY_TYPED) {
-                               /*
-                                * Or If a TYPED is seen use keyChar
-                                */
-                           GlobalEventFilter.filterKey(keyChar,GlobalEventWatcher.getAxesUID(), isControlDown);
-                       }       
-               }
-       }
-       /**
-        * Manage xgetmouse behaviour for mouse entry.
-        * 
-        * @param mouseEvent : the Mouse Event caught
-        * @param scilabMouseAction : the integer scilab code for mouse action.
-        * @param axes : the axes where action occurs.
-        * @param isControlDown true if the CTRL key has been pressed
-        */
-       private static void mouseActionFilter(MouseEvent mouseEvent, String axesUID, int scilabMouseAction, boolean isControlDown) {    
-               if (scilabMouseAction != SciTranslator.MOVED
-                               && scilabMouseAction != SciTranslator.RELEASED) {
-                       GlobalEventFilter.filterMouse(mouseEvent, axesUID, scilabMouseAction, isControlDown);
-               } else if (watchMotion && scilabMouseAction == SciTranslator.MOVED) {
-                       // Force false value to isControlDown
-                       // MOVED do not care about CTRL Key...
-                       GlobalEventFilter.filterMouse(mouseEvent, axesUID, MOVED, false);
-               } else if (watchRelease && scilabMouseAction == SciTranslator.RELEASED) {
-                       // Force false value to isControlDown
-                       // RELEASED do not care about CTRL Key...
-                       GlobalEventFilter.filterMouse(mouseEvent, axesUID, scilabMouseAction, false);
-               }
-       }
+    private static int keyChar;
+    private static boolean isControlDown;
+    private static boolean watchMotion;
+    private static boolean watchRelease;
+    private static final int MOVED = -1;
+
+    /**
+     * Tool Class, constructor is private.
+     */
+    private Jxgetmouse() { }
+
+    /**
+     * Default call for xgetmouse.
+     */
+    public static void xgetmouse() {
+        xgetmouse(true, false);
+    }
+
+    /**
+     * Scilab call point for xgetmouse.
+     *
+     * @param withMotion : Means xgetmouse is mouse motion sensitive.
+     * @param withRelease : Means xgetmouse is release sensitive.
+     */
+    public static void xgetmouse(boolean withMotion, boolean withRelease) {
+        watchMotion = withMotion;
+        watchRelease = withRelease;
+        /*
+         *  Enable the local keyActionFilter function
+         *  to be called when a keyEvent is caught.
+         */
+        GlobalEventWatcher.enable(new GlobalKeyEventWatcher() {
+            public void keyEventFilter(KeyEvent keyEvent) {
+                keyActionFilter(keyEvent);
+            }
+        });
+        long eventMask = AWTEvent.MOUSE_EVENT_MASK;
+        if (watchMotion) {
+            eventMask += AWTEvent.MOUSE_MOTION_EVENT_MASK;
+        }
+        /*
+         *  Enable the local mouseActionFilter function
+         *  to be called when a mouseEvent is caught.
+         */
+        GlobalEventWatcher.enable(new GlobalMouseEventWatcher(eventMask) {
+            public void mouseEventFilter(MouseEvent mouseEvent,
+            String axesUID, int scilabMouseAction, boolean isControlDown) {
+                mouseActionFilter(mouseEvent, axesUID, scilabMouseAction, isControlDown);
+            }
+        });
+        synchronized (ClickInfos.getInstance()) {
+            try {
+                ClickInfos.getInstance().init();
+                ClickInfos.getInstance().wait();
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+        }
+        GlobalEventWatcher.disable();
+    }
+
+    /**
+     * @return the mouseButtonNumber
+     */
+    public static int getMouseButtonNumber() {
+        return ClickInfos.getInstance().getMouseButtonNumber();
+    }
+    /**
+     * @return the xCoordinate
+     */
+    public static double getXCoordinate() {
+        return ClickInfos.getInstance().getXCoordinate();
+    }
+    /**
+     * @return the yCoordinate
+     */
+    public static double getYCoordinate() {
+        return ClickInfos.getInstance().getYCoordinate();
+    }
+    /**
+     * @return the WindowsID
+     */
+    public static String getWindowsID() {
+        return ClickInfos.getInstance().getWindowID();
+    }
+
+
+
+    /**
+     * Manage xgetmouse behaviour for keyboard entry.
+     * 1 - Key has been pressed.
+     * 2 - CTRL + Key has been pressed.
+     * 3 - Key has been released
+     *
+     * @param keyEvent : the Key Event caught
+     */
+    private static void keyActionFilter(KeyEvent keyEvent) {
+        /*
+         * If a key is pressed, only remember the key and if CTRL is pressed either.
+         */
+        if (keyEvent.getID() == KeyEvent.KEY_PRESSED) {
+            if (!Character.isJavaIdentifierStart(keyEvent.getKeyChar())) {
+                keyChar = keyEvent.getKeyChar();
+            } else {
+                if (keyEvent.isShiftDown()) {
+                    keyChar = keyEvent.getKeyCode();
+                } else {
+                    keyChar = Character.toLowerCase(keyEvent.getKeyCode());
+                }
+            }
+            isControlDown = keyEvent.isControlDown();
+        } else if (keyEvent.getSource() instanceof SwingScilabAxes) {
+            /* Now we have have to be sure we are in a Canvas. */
+            /*
+             * If a RELEASED is seen use -keyChar
+             */
+            if (keyEvent.getID() == KeyEvent.KEY_RELEASED) {
+                GlobalEventFilter.filterKey(-keyChar, GlobalEventWatcher.getAxesUID(), isControlDown);
+            } else if (keyEvent.getID() == KeyEvent.KEY_TYPED) {
+                /*
+                 * Or If a TYPED is seen use keyChar
+                 */
+                GlobalEventFilter.filterKey(keyChar, GlobalEventWatcher.getAxesUID(), isControlDown);
+            }
+        }
+    }
+    /**
+     * Manage xgetmouse behaviour for mouse entry.
+     *
+     * @param mouseEvent : the Mouse Event caught
+     * @param scilabMouseAction : the integer scilab code for mouse action.
+     * @param axes : the axes where action occurs.
+     * @param isControlDown true if the CTRL key has been pressed
+     */
+    private static void mouseActionFilter(MouseEvent mouseEvent, String axesUID, int scilabMouseAction, boolean isControlDown) {
+        if (scilabMouseAction != SciTranslator.MOVED
+                && scilabMouseAction != SciTranslator.RELEASED) {
+            GlobalEventFilter.filterMouse(mouseEvent, axesUID, scilabMouseAction, isControlDown);
+        } else if (watchMotion && scilabMouseAction == SciTranslator.MOVED) {
+            // Force false value to isControlDown
+            // MOVED do not care about CTRL Key...
+            GlobalEventFilter.filterMouse(mouseEvent, axesUID, MOVED, false);
+        } else if (watchRelease && scilabMouseAction == SciTranslator.RELEASED) {
+            // Force false value to isControlDown
+            // RELEASED do not care about CTRL Key...
+            GlobalEventFilter.filterMouse(mouseEvent, axesUID, scilabMouseAction, false);
+        }
+    }
 
 
 }
index 3b3b4b8..4b5d15f 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (C) 2007 - INRIA - Bruno JOFRET
 <<<<<<< HEAD
  * Copyright (C) 2011 - DIGITEO - Vincent Couvert
- * 
+ *
 =======
  *
 >>>>>>> origin/master
@@ -99,11 +99,11 @@ public class SciDockingListener implements DockingListener {
                 int newX = -offsetX;
                 int newY = -offsetY;
                 if (e.getNewDockingPort() instanceof FloatingDockingPort) {
-                    newX += (int) (((FloatingDockingPort) e.getNewDockingPort()).getParent().getParent().getParent().getX());
-                    newY += (int) (((FloatingDockingPort) e.getNewDockingPort()).getParent().getParent().getParent().getY());
+                    newX += ((FloatingDockingPort) e.getNewDockingPort()).getParent().getParent().getParent().getX();
+                    newY += ((FloatingDockingPort) e.getNewDockingPort()).getParent().getParent().getParent().getY();
                 } else {
-                    newX += (int) (((DefaultDockingPort) e.getNewDockingPort()).getParent().getParent().getParent().getX());
-                    newY += (int) (((DefaultDockingPort) e.getNewDockingPort()).getParent().getParent().getParent().getY());
+                    newX += ((DefaultDockingPort) e.getNewDockingPort()).getParent().getParent().getParent().getX();
+                    newY += ((DefaultDockingPort) e.getNewDockingPort()).getParent().getParent().getParent().getY();
                 }
 
                 SwingScilabWindow newWindow = new SwingScilabWindow();
index f0f2a5b..e7c9b7e 100644 (file)
@@ -89,7 +89,7 @@ public final class UnitsConverter {
 
         switch (newUnit) {
             case POINTS:
-                return (double) value;
+                return value;
             case NORMALIZED:
                 if (parentType.equals(__GO_FIGURE__)) { /* Figure */
                     Integer[] parentSize = (Integer[]) GraphicController.getController().getProperty(parentId, __GO_AXES_SIZE__);
@@ -107,13 +107,13 @@ public final class UnitsConverter {
                         refSize = parentSize[3].intValue();
                     }
                 }
-                return ((double) value) / (refSize * POINT_PER_INCH / CallScilabBridge.getScreenResolution());
+                return value / (refSize * POINT_PER_INCH / CallScilabBridge.getScreenResolution());
             case INCHES:
-                return ((double) value) / POINT_PER_INCH;
+                return value / POINT_PER_INCH;
             case CENTIMETERS:
-                return ((double) value) * CM_PER_INCH / POINT_PER_INCH;
+                return value * CM_PER_INCH / POINT_PER_INCH;
             case PIXELS:
-                return ((double) value) * CallScilabBridge.getScreenResolution() / POINT_PER_INCH;
+                return value * CallScilabBridge.getScreenResolution() / POINT_PER_INCH;
             default:
                 return 0.0;
         }
index b98e566..15be88b 100644 (file)
@@ -1,13 +1,13 @@
 /*
  *  Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  *  Copyright (C) 2009-2009 - DIGITEO - Bruno JOFRET
- * 
+ *
  *  This file must be used under the terms of the CeCILL.
  *  This source file is licensed as described in the file COPYING, which
  *  you should have received as part of this distribution.  The terms
  *  are also available at
  *  http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
- * 
+ *
  */
 
 package org.scilab.modules.hdf5.read;
@@ -27,7 +27,7 @@ public final class H5ReadScilabBoolean {
      * Private Constructor for utility class
      */
     private H5ReadScilabBoolean() { }
-    
+
     /**
      * readData
      * @param dataSetId the dataset ID to read.
@@ -35,7 +35,7 @@ public final class H5ReadScilabBoolean {
      * @throws HDF5Exception .
      */
     public static void readData(int dataSetId, ScilabBoolean data) throws HDF5Exception {
-       data.setData(getBooleanMatrix(dataSetId));
+        data.setData(getBooleanMatrix(dataSetId));
     }
 
     /**
@@ -45,24 +45,24 @@ public final class H5ReadScilabBoolean {
      * @throws HDF5Exception .
      */
     private static boolean[][] getBooleanMatrix(int dataSetId) throws HDF5Exception {
-       int[] nbElems = H5Read.getAllDims(dataSetId); 
-       int[] data = new int[nbElems[0] * nbElems[1]];
-       boolean[][] result = new boolean[(int) nbElems[0]][(int) nbElems[1]];
-       
-       H5.H5Dread_int(dataSetId, HDF5Constants.H5T_NATIVE_INT, H5.H5Dget_space(dataSetId), 
-               HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL, data);
-       
-       for (int i = 0; i < nbElems[0]; ++i) {
-           for (int j = 0; j < nbElems[1]; ++j) {
-               if (data[i + j * nbElems[0]] == 0) {
-               result[i][j] = false;
-               } else {
-                   result[i][j] = true;
-               }
-           }
-       }
-       
-       H5.H5Dclose(dataSetId);
-       return result;
+        int[] nbElems = H5Read.getAllDims(dataSetId);
+        int[] data = new int[nbElems[0] * nbElems[1]];
+        boolean[][] result = new boolean[nbElems[0]][nbElems[1]];
+
+        H5.H5Dread_int(dataSetId, HDF5Constants.H5T_NATIVE_INT, H5.H5Dget_space(dataSetId),
+                       HDF5Constants.H5S_ALL, HDF5Constants.H5S_ALL, data);
+
+        for (int i = 0; i < nbElems[0]; ++i) {
+            for (int j = 0; j < nbElems[1]; ++j) {
+                if (data[i + j * nbElems[0]] == 0) {
+                    result[i][j] = false;
+                } else {
+                    result[i][j] = true;
+                }
+            }
+        }
+
+        H5.H5Dclose(dataSetId);
+        return result;
     }
 }
index 637c880..9cdf13f 100644 (file)
@@ -206,7 +206,7 @@ public class BuildDocObject extends StyleSheet {
      */
     private String preProcessMaster(String masterXML) {
 
-        String filename = (String) new File(masterXML).getName();
+        String filename = new File(masterXML).getName();
         /* Create the output file which will be created by copyconvert.run into the working directory  */
         File masterXMLTransformed = new File(this.outputDirectory
                                              + File.separator + filename.substring(0, filename.lastIndexOf(".")) + "-processed.xml");
@@ -272,12 +272,12 @@ public class BuildDocObject extends StyleSheet {
             File tmpFileForURI = new File(this.styleDoc);
             contentMainStyleDoc = contentMainStyleDoc.replaceAll("STYLE_DOC", tmpFileForURI.toURI().toString());
 
-            File temporaryStyleFile = File.createTempFile("style_",".xsl");
+            File temporaryStyleFile = File.createTempFile("style_", ".xsl");
 
             Helpers.saveString(contentMainStyleDoc, temporaryStyleFile, "UTF-8");
             return temporaryStyleFile;
         } catch (java.io.IOException e) {
-            System.err.println("Could not convert "+mainStyleDoc);
+            System.err.println("Could not convert " + mainStyleDoc);
             return null;
         }
     }
@@ -327,7 +327,7 @@ public class BuildDocObject extends StyleSheet {
                 throw new FileNotFoundException("Could not find CSS stylesheet: " + styleSheet);
             }
             /* Where it will be stored */
-            String out = this.outputDirectory + File.separator + (String) new File(styleSheet).getName();
+            String out = this.outputDirectory + File.separator + new File(styleSheet).getName();
 
             try {
                 Helpers.copyFile(new File(styleSheet), new File(out));
index 764682d..5fd1c55 100644 (file)
@@ -126,7 +126,7 @@ public final class ImageConverter {
      * @return the HTML code to insert the image
      */
     public static String generateCode(Image img, String fileName, Map<String, String> attrs) {
-        String style = (String) attrs.get("style");
+        String style = attrs.get("style");
         String top = "";
         boolean display = style != null && style.equals("display");
 
@@ -134,7 +134,7 @@ public final class ImageConverter {
             top = "top:" + img.descent + "px;";
         }
 
-        String alignAttr = (String) attrs.get("align");
+        String alignAttr = attrs.get("align");
         String align = "";
         String div = "div";
         if (alignAttr != null) {
index 21a7993..49efabc 100644 (file)
@@ -316,7 +316,7 @@ public final class CommandHistory extends SwingScilabTab implements SimpleTab {
             if (numberOfLines + scilabHistoryRootNode.getChildAt(sessionIndex).getChildCount() > lineNumber) {
                 /* The line has to be remove in current session */
                 ((DefaultMutableTreeNode) scilabHistoryRootNode.getChildAt(sessionIndex)).remove(lineNumber - numberOfLines);
-                scilabHistoryTreeModel.nodeStructureChanged((TreeNode) scilabHistoryRootNode.getChildAt(sessionIndex));
+                scilabHistoryTreeModel.nodeStructureChanged(scilabHistoryRootNode.getChildAt(sessionIndex));
                 expandAll();
                 break;
             } else {
index b7b0105..9af9cd1 100644 (file)
@@ -63,629 +63,631 @@ import java.util.concurrent.ConcurrentHashMap;
  */
 public class LegendDrawer {
 
-        /**
-         * Set of properties that affect the legend sprite
-         */
-        private static final Set<String> SPRITE_PROPERTIES = new HashSet<String>(Arrays.asList(
+    /**
+     * Set of properties that affect the legend sprite
+     */
+    private static final Set<String> SPRITE_PROPERTIES = new HashSet<String>(Arrays.asList(
                 GraphicObjectProperties.__GO_FONT_SIZE__,
                 GraphicObjectProperties.__GO_FONT_COLOR__,
                 GraphicObjectProperties.__GO_FONT_STYLE__,
                 GraphicObjectProperties.__GO_FONT_FRACTIONAL__,
                 GraphicObjectProperties.__GO_TEXT_ARRAY_DIMENSIONS__,
                 GraphicObjectProperties.__GO_TEXT_STRINGS__
-        ));
+            ));
+
+    /** The height of a bar relative to the height difference between two lines */
+    private static final float BAR_HEIGHT = 0.5f;
+
+    /** The DrawerVisitor used */
+    private final DrawerVisitor visitor;
+
+    /** The SpriteManager used */
+    private final TextureManager textureManager;
+
+    /** The MarkSpriteManager used */
+    private final MarkSpriteManager markManager;
 
-        /** The height of a bar relative to the height difference between two lines */
-        private static final float BAR_HEIGHT = 0.5f;
+    /** The Legend sprite drawer */
+    private LegendSpriteDrawer legendSpriteDrawer;
 
-        /** The DrawerVisitor used */
-        private final DrawerVisitor visitor;
+    /** The relative line width */
+    private static final double LINE_WIDTH = 0.1;
 
-        /** The SpriteManager used */
-        private final TextureManager textureManager;
+    /** The relative y-offset */
+    private static final double Y_OFFSET = 0.01;
 
-        /** The MarkSpriteManager used */
-        private final MarkSpriteManager markManager;
+    /** The relative tick and label size (arbitrarily chosen) */
+    private static final double TICK_LABEL_SIZE = 0.055;
 
-        /** The Legend sprite drawer */
-        private LegendSpriteDrawer legendSpriteDrawer;
+    /** The z-value corresponding to the frontmost position */
+    private static final float Z_FRONT = 0.99f;
 
-        /** The relative line width */
-        private static final double LINE_WIDTH = 0.1;
+    /** The legend background's vertices */
+    private ElementsBuffer rectangleVertices;
 
-        /** The relative y-offset */
-        private static final double Y_OFFSET = 0.01;
+    /** The vertices used to draw lines */
+    private ElementsBuffer lineVertices;
 
-        /** The relative tick and label size (arbitrarily chosen) */
-        private static final double TICK_LABEL_SIZE = 0.055;
+    /** The vertices used to draw bars */
+    private ElementsBuffer barVertices;
 
-        /** The z-value corresponding to the frontmost position */
-        private static final float Z_FRONT = 0.99f;
+    /** The indices used to draw lines */
+    private IndicesBuffer lineIndices;
 
-        /** The legend background's vertices */
-        private ElementsBuffer rectangleVertices;
+    /** The indices used to draw a rectangle */
+    private IndicesBuffer rectangleIndices;
 
-        /** The vertices used to draw lines */
-        private ElementsBuffer lineVertices;
+    /** The indices used to draw the outline of a rectangle */
+    private IndicesBuffer rectangleOutlineIndices;
 
-        /** The vertices used to draw bars */
-        private ElementsBuffer barVertices;
+    /** The map storing legend text sprites */
+    private Map<String, Texture> textureMap;
 
-        /** The indices used to draw lines */
-        private IndicesBuffer lineIndices;
+    /**
+     * Constructor.
+     * @param visitor the DrawerVisitor {@see DrawerVisitor}.
+     */
+    public LegendDrawer(DrawerVisitor visitor) {
+        this.visitor = visitor;
+        this.textureManager = visitor.getCanvas().getTextureManager();
+        this.markManager = visitor.getMarkManager();
 
-        /** The indices used to draw a rectangle */
-        private IndicesBuffer rectangleIndices;
+        rectangleVertices = visitor.getCanvas().getBuffersManager().createElementsBuffer();
+        lineVertices = visitor.getCanvas().getBuffersManager().createElementsBuffer();
+        barVertices = visitor.getCanvas().getBuffersManager().createElementsBuffer();
+        lineIndices = visitor.getCanvas().getBuffersManager().createIndicesBuffer();
+        rectangleIndices = visitor.getCanvas().getBuffersManager().createIndicesBuffer();
+        rectangleOutlineIndices = visitor.getCanvas().getBuffersManager().createIndicesBuffer();
 
-        /** The indices used to draw the outline of a rectangle */
-        private IndicesBuffer rectangleOutlineIndices;
+        textureMap = new ConcurrentHashMap<String, Texture>();
 
-        /** The map storing legend text sprites */
-        private Map<String, Texture> textureMap;
+        int[] lineIndexData = new int[] {0, 1, 1, 2};
+        lineIndices.setData(lineIndexData);
+    }
 
-        /**
-         * Constructor.
-         * @param visitor the DrawerVisitor {@see DrawerVisitor}.
+    /**
+     * Draws the given Legend.
+     * @param legend the Legend to draw.
+     * @throws SciRendererException if the draw fail.
+     */
+    public void draw(Legend legend) throws SciRendererException {
+        /* The coordinates of the legend box's lower-left corner */
+        double [] legendCorner = new double[] {0.25, 0.75, Z_FRONT};
+
+        DrawingTools drawingTools = visitor.getDrawingTools();
+        ColorMap colorMap = visitor.getColorMap();
+        Canvas canvas = visitor.getCanvas();
+
+        String [] links = legend.getLinks();
+
+        /*
+         * Determine whether any links have become invalid,
+         * force the sprite's update and update the Legend's
+         * links property as needed.
          */
-        public LegendDrawer(DrawerVisitor visitor) {
-                this.visitor = visitor;
-                this.textureManager = visitor.getCanvas().getTextureManager();
-                this.markManager = visitor.getMarkManager();
-
-                rectangleVertices = visitor.getCanvas().getBuffersManager().createElementsBuffer();
-                lineVertices = visitor.getCanvas().getBuffersManager().createElementsBuffer();
-                barVertices = visitor.getCanvas().getBuffersManager().createElementsBuffer();
-                lineIndices = visitor.getCanvas().getBuffersManager().createIndicesBuffer();
-                rectangleIndices = visitor.getCanvas().getBuffersManager().createIndicesBuffer();
-                rectangleOutlineIndices = visitor.getCanvas().getBuffersManager().createIndicesBuffer();
-
-                textureMap = new ConcurrentHashMap<String, Texture>();
-
-                int[] lineIndexData = new int[]{0, 1, 1, 2};
-                lineIndices.setData(lineIndexData);
+        int nbValidLinks = getNumberValidLinks(legend);
+
+        if (nbValidLinks < links.length) {
+            dispose(legend.getIdentifier());
+            updateLinks(legend, nbValidLinks);
         }
 
-        /**
-         * Draws the given Legend.
-         * @param legend the Legend to draw.
-         * @throws SciRendererException if the draw fail.
+        links = legend.getLinks();
+
+        /*
+         * Set the projection and modelview transformations so that coordinates
+         * are specified in the {0,+1,0,+1,0,+1} space.
          */
-        public void draw(Legend legend) throws SciRendererException {
-                /* The coordinates of the legend box's lower-left corner */
-                double [] legendCorner = new double[]{0.25, 0.75, Z_FRONT};
+        TransformationStack modelViewStack = drawingTools.getTransformationManager().getModelViewStack();
+        TransformationStack projectionStack = drawingTools.getTransformationManager().getProjectionStack();
 
-                DrawingTools drawingTools = visitor.getDrawingTools();
-                ColorMap colorMap = visitor.getColorMap();
-                Canvas canvas = visitor.getCanvas();
+        Transformation identity = TransformationFactory.getIdentity();
+        modelViewStack.push(identity);
 
-                String [] links = legend.getLinks();
+        Transformation orthoProj = TransformationFactory.getOrthographic(0.0, 1.0, 0.0, 1.0, -1.0, 0.0);
+        projectionStack.push(orthoProj);
 
-                /*
-                 * Determine whether any links have become invalid,
-                 * force the sprite's update and update the Legend's
-                 * links property as needed.
-                 */
-                int nbValidLinks = getNumberValidLinks(legend);
 
-                if (nbValidLinks < links.length) {
-                        dispose(legend.getIdentifier());
-                        updateLinks(legend, nbValidLinks);
-                }
+        /* First, compute the legend box's position and dimensions from the Axes' parameters and the text sprite's dimensions */
 
-                links = legend.getLinks();
+        String parentAxesID = legend.getParentAxes();
+        Axes parentAxes = (Axes) GraphicController.getController().getObjectFromId(parentAxesID);
 
-                /*
-                 * Set the projection and modelview transformations so that coordinates
-                 * are specified in the {0,+1,0,+1,0,+1} space.
-                 */
-                TransformationStack modelViewStack = drawingTools.getTransformationManager().getModelViewStack();
-                TransformationStack projectionStack = drawingTools.getTransformationManager().getProjectionStack();
+        Double [] axesBounds = parentAxes.getAxesBounds();
+        Double [] margins = parentAxes.getMargins();
+
+        int xAxisLocation = parentAxes.getXAxisLocation();
+        int yAxisLocation = parentAxes.getYAxisLocation();
+
+
+        int canvasWidth = canvas.getWidth();
+        int canvasHeight = canvas.getHeight();
 
-                Transformation identity = TransformationFactory.getIdentity();
-                modelViewStack.push(identity);
+        if (canvasWidth == 0) {
+            canvasWidth = 1;
+        }
 
-                Transformation orthoProj = TransformationFactory.getOrthographic(0.0, 1.0, 0.0, 1.0, -1.0, 0.0);
-                projectionStack.push(orthoProj);
+        if (canvasHeight == 0) {
+            canvasHeight = 1;
+        }
 
+        Texture legendSprite = null;
 
-                /* First, compute the legend box's position and dimensions from the Axes' parameters and the text sprite's dimensions */
+        if (nbValidLinks > 0) {
+            legendSprite = getTexture(colorMap, legend);
+        }
 
-                String parentAxesID = legend.getParentAxes();
-                Axes parentAxes = (Axes) GraphicController.getController().getObjectFromId(parentAxesID);
+        double normSpriteWidth = 0;
+        double normSpriteHeight = 0;
 
-                Double [] axesBounds = parentAxes.getAxesBounds();
-                Double [] margins = parentAxes.getMargins();
+        if (nbValidLinks > 0) {
+            Dimension textureSize = legendSprite.getDataProvider().getTextureSize();
+            normSpriteWidth = textureSize.getWidth() / (double) canvasWidth;
+            normSpriteHeight = textureSize.getHeight() / (double) canvasHeight;
+        }
 
-                int xAxisLocation = parentAxes.getXAxisLocation();
-                int yAxisLocation = parentAxes.getYAxisLocation();
+        double lineWidth;
+
+        /* The legend box's width and height */
+        double [] legendDims = new double[2];
+
+        double [] axesPos = new double[2];
+        double [] axesDims = new double[2];
+
+        lineWidth = LINE_WIDTH * (axesBounds[2]) * (1.0 - margins[0] - margins[1]);
+
+        double xOffset = lineWidth / 8.0;
+        double yOffset = (Y_OFFSET * (axesBounds[3]) * (1.0 - margins[2] - margins[3]));
+
+        legendDims[0] = normSpriteWidth + lineWidth + 3.0 * xOffset;
+        legendDims[1] = normSpriteHeight + 2.0 * yOffset;
+
+        axesPos[0] = axesBounds[0];
+        axesPos[1] = 1.0 - (axesBounds[1] + axesBounds[3]);
+
+        axesDims[0] = axesBounds[2];
+        axesDims[1] = axesBounds[3];
+
+        /* The {x, y} coordinates of the axes box's lower-left and upper-right corners (as defined by bounds and margins) */
+        double [] llBoxCorner = new double[2];
+        double [] urBoxCorner = new double[2];
+
+        LegendLocation legendLocation = legend.getLegendLocationAsEnum();
+
+        llBoxCorner[0] = axesPos[0] + margins[0] * axesDims[0];
+        llBoxCorner[1] = axesPos[1] + margins[3] * axesDims[1];
+
+        urBoxCorner[0] = axesPos[0] + (1.0 - margins[1]) * axesDims[0];
+        urBoxCorner[1] = axesPos[1] + (1.0 - margins[2]) * axesDims[1];
+
+        if (legendLocation == LegendLocation.IN_UPPER_RIGHT) {
+            legendCorner[0] = (float) (urBoxCorner[0] - xOffset - legendDims[0]);
+            legendCorner[1] = (float) (urBoxCorner[1] - yOffset - legendDims[1]);
+        } else if (legendLocation == LegendLocation.IN_UPPER_LEFT) {
+            legendCorner[0] = (float) (llBoxCorner[0] + xOffset);
+            legendCorner[1] = (float) (urBoxCorner[1] - yOffset - legendDims[1]);
+        } else if (legendLocation == LegendLocation.IN_LOWER_RIGHT) {
+            legendCorner[0] = (float) (urBoxCorner[0] - xOffset - legendDims[0]);
+            legendCorner[1] = (float) (llBoxCorner[1] + yOffset);
+        } else if (legendLocation == LegendLocation.IN_LOWER_LEFT) {
+            legendCorner[0] = (float) (llBoxCorner[0] + xOffset);
+            legendCorner[1] = (float) (llBoxCorner[1] + yOffset);
+        } else if (legendLocation == LegendLocation.OUT_UPPER_RIGHT) {
+            legendCorner[0] = (float) (urBoxCorner[0] + xOffset);
+            legendCorner[1] = (float) (urBoxCorner[1] - legendDims[1]);
+        } else if (legendLocation == LegendLocation.OUT_UPPER_LEFT) {
+            legendCorner[0] = (float) (llBoxCorner[0] - xOffset - legendDims[0]);
+            legendCorner[1] = (float) (urBoxCorner[1] - legendDims[1]);
+        } else if (legendLocation == LegendLocation.OUT_LOWER_RIGHT) {
+            legendCorner[0] = (float) (urBoxCorner[0] + xOffset);
+            legendCorner[1] = (float) (llBoxCorner[1]);
+        } else if (legendLocation == LegendLocation.OUT_LOWER_LEFT) {
+            legendCorner[0] = (float) (llBoxCorner[0] - xOffset - legendDims[0]);
+            legendCorner[1] = (float) (llBoxCorner[1]);
+        } else if (legendLocation == LegendLocation.UPPER_CAPTION) {
+            legendCorner[0] = (float) (llBoxCorner[0]);
+            legendCorner[1] = (float) (urBoxCorner[1] + yOffset);
+
+            /* x-axis at the top */
+            if (xAxisLocation == 1) {
+                /* To do: use the actual label+tick bounding box height */
+                legendCorner[1] += TICK_LABEL_SIZE;
+            }
+        } else if (legendLocation == LegendLocation.LOWER_CAPTION) {
+            legendCorner[0] = (float) (llBoxCorner[0]);
+            legendCorner[1] = (float) (llBoxCorner[1] - yOffset - legendDims[1]);
+
+            /* x-axis at the bottom */
+            if (xAxisLocation == 0) {
+                /* To do: use the actual label+tick bounding box height */
+                legendCorner[1] -= TICK_LABEL_SIZE;
+            }
+        } else if (legendLocation == LegendLocation.BY_COORDINATES) {
+            Double [] legPos = legend.getPosition();
 
+            legendCorner[0] = (float) (axesPos[0] + legPos[0] * axesBounds[2]);
+            legendCorner[1] = (float) (axesPos[1] + (1.0 - legPos[1]) * axesBounds[3] - legendDims[1]);
+        }
 
-                int canvasWidth = canvas.getWidth();
-                int canvasHeight = canvas.getHeight();
-
-                if (canvasWidth == 0) {
-                        canvasWidth = 1;
-                }
-
-                if (canvasHeight == 0) {
-                        canvasHeight = 1;
-                }
-
-                Texture legendSprite = null;
-
-                if (nbValidLinks > 0) {
-                    legendSprite = getTexture(colorMap, legend);
-                }
-
-                double normSpriteWidth = 0;
-                double normSpriteHeight = 0;
-
-                if (nbValidLinks > 0) {
-                    Dimension textureSize = legendSprite.getDataProvider().getTextureSize();
-                    normSpriteWidth = (double) textureSize.getWidth() / (double) canvasWidth;
-                    normSpriteHeight = (double) textureSize.getHeight() / (double) canvasHeight;
-                }
-
-                double lineWidth;
-
-                /* The legend box's width and height */
-                double [] legendDims = new double[2];
-
-                double [] axesPos = new double[2];
-                double [] axesDims = new double[2];
-
-                lineWidth = LINE_WIDTH * (axesBounds[2])*(1.0-margins[0]-margins[1]);
-
-                double xOffset = lineWidth/8.0;
-                double yOffset = (Y_OFFSET * (axesBounds[3])*(1.0-margins[2]-margins[3]));
-
-                legendDims[0] = normSpriteWidth + lineWidth + 3.0*xOffset;
-                legendDims[1] = normSpriteHeight + 2.0*yOffset;
-
-                axesPos[0] = axesBounds[0];
-                axesPos[1] = 1.0 - (axesBounds[1]+axesBounds[3]);
-
-                axesDims[0] = axesBounds[2];
-                axesDims[1] = axesBounds[3];
-
-                /* The {x, y} coordinates of the axes box's lower-left and upper-right corners (as defined by bounds and margins) */
-                double [] llBoxCorner = new double[2];
-                double [] urBoxCorner = new double[2];
-
-                LegendLocation legendLocation = legend.getLegendLocationAsEnum();
-
-                llBoxCorner[0] = axesPos[0] + margins[0]*axesDims[0];
-                llBoxCorner[1] = axesPos[1] + margins[3]*axesDims[1];
-
-                urBoxCorner[0] = axesPos[0] + (1.0 - margins[1])*axesDims[0];
-                urBoxCorner[1] = axesPos[1] + (1.0 - margins[2])*axesDims[1];
-
-                if (legendLocation == LegendLocation.IN_UPPER_RIGHT) {
-                        legendCorner[0] = (float) (urBoxCorner[0] - xOffset - legendDims[0]);
-                        legendCorner[1] = (float) (urBoxCorner[1] - yOffset - legendDims[1]);
-                } else if (legendLocation == LegendLocation.IN_UPPER_LEFT) {
-                        legendCorner[0] = (float) (llBoxCorner[0] + xOffset);
-                        legendCorner[1] = (float) (urBoxCorner[1] - yOffset - legendDims[1]);
-                } else if (legendLocation == LegendLocation.IN_LOWER_RIGHT) {
-                        legendCorner[0] = (float) (urBoxCorner[0] - xOffset - legendDims[0]);
-                        legendCorner[1] = (float) (llBoxCorner[1] + yOffset);
-                } else if (legendLocation == LegendLocation.IN_LOWER_LEFT) {
-                        legendCorner[0] = (float) (llBoxCorner[0] + xOffset);
-                        legendCorner[1] = (float) (llBoxCorner[1] + yOffset);
-                } else if (legendLocation == LegendLocation.OUT_UPPER_RIGHT) {
-                        legendCorner[0] = (float) (urBoxCorner[0] + xOffset);
-                        legendCorner[1] = (float) (urBoxCorner[1] - legendDims[1]);
-                } else if (legendLocation == LegendLocation.OUT_UPPER_LEFT) {
-                        legendCorner[0] = (float) (llBoxCorner[0] - xOffset - legendDims[0]);
-                        legendCorner[1] = (float) (urBoxCorner[1] - legendDims[1]);
-                } else if (legendLocation == LegendLocation.OUT_LOWER_RIGHT) {
-                        legendCorner[0] = (float) (urBoxCorner[0] + xOffset);
-                        legendCorner[1] = (float) (llBoxCorner[1]);
-                } else if (legendLocation == LegendLocation.OUT_LOWER_LEFT) {
-                        legendCorner[0] = (float) (llBoxCorner[0] - xOffset - legendDims[0]);
-                        legendCorner[1] = (float) (llBoxCorner[1]);
-                } else if (legendLocation == LegendLocation.UPPER_CAPTION) {
-                        legendCorner[0] = (float) (llBoxCorner[0]);
-                        legendCorner[1] = (float) (urBoxCorner[1] + yOffset);
-
-                        /* x-axis at the top */
-                        if (xAxisLocation == 1) {
-                                /* To do: use the actual label+tick bounding box height */
-                                legendCorner[1] += TICK_LABEL_SIZE;
-                        }
-                } else if (legendLocation == LegendLocation.LOWER_CAPTION) {
-                        legendCorner[0] = (float) (llBoxCorner[0]);
-                        legendCorner[1] = (float) (llBoxCorner[1] - yOffset - legendDims[1]);
-
-                        /* x-axis at the bottom */
-                        if (xAxisLocation == 0) {
-                                /* To do: use the actual label+tick bounding box height */
-                                legendCorner[1] -= TICK_LABEL_SIZE;
-                        }
-                } else if (legendLocation == LegendLocation.BY_COORDINATES) {
-                        Double [] legPos = legend.getPosition();
-
-                        legendCorner[0] = (float) (axesPos[0] + legPos[0]*axesBounds[2]);
-                        legendCorner[1] = (float) (axesPos[1] + (1.0-legPos[1])*axesBounds[3] - legendDims[1]);
-                }
-
-                /* y-axis positioned to the left */
-                if ((legendLocation == LegendLocation.OUT_UPPER_LEFT || legendLocation == LegendLocation.OUT_LOWER_LEFT) && yAxisLocation == 4) {
-                        /* To do: use the actual label+tick bounding box width */
-                        legendCorner[0] -= TICK_LABEL_SIZE;
-                /* y-axis positioned to the right */
-                } else if ((legendLocation == LegendLocation.OUT_UPPER_RIGHT || legendLocation == LegendLocation.OUT_LOWER_RIGHT) && yAxisLocation == 5) {
-                        /* To do: use the actual label+tick bounding box width */
-                        legendCorner[0] += TICK_LABEL_SIZE;
-                }
-
-
-                /* Afterwards, draw the elements making up the Legend using the previously computed values */
-
-                /* Legend background vertex data: lower-left, lower-right, upper-left and upper-right corners */
-                float [] rectangleVertexData = new float[] {
-                    (float)legendCorner[0], (float)legendCorner[1], Z_FRONT, 1.0f,
-                    (float)(legendCorner[0]+legendDims[0]), (float)legendCorner[1], Z_FRONT, 1.0f,
-                    (float)legendCorner[0], (float)(legendCorner[1]+legendDims[1]), Z_FRONT, 1.0f,
-                    (float)(legendCorner[0]+legendDims[0]), (float)(legendCorner[1]+legendDims[1]), Z_FRONT, 1.0f
-                };
-
-                /* The indices of a rectangle's triangles and a rectangle outline's segment loop */
-                int[] rectangleIndexData = new int[] {0, 1, 3, 0, 3, 2};
-                int[] rectangleOutlineIndexData = new int[] {0, 1, 1, 3, 3, 2, 2, 0};
-
-                rectangleIndices.setData(rectangleIndexData);
-                rectangleOutlineIndices.setData(rectangleOutlineIndexData);
-
-                rectangleVertices.setData(rectangleVertexData, 4);
-
-                /* Legend rectangle background and outline */
-                DefaultGeometry legendRectangle = new DefaultGeometry();
-                legendRectangle.setVertices(rectangleVertices);
-                legendRectangle.setIndices(rectangleIndices);
-
-                Appearance appearance = new Appearance();
-
-                if (legend.getFillMode()) {
-                    legendRectangle.setFillDrawingMode(Geometry.FillDrawingMode.TRIANGLES);
-                    appearance.setFillColor(ColorFactory.createColor(colorMap, legend.getBackground()));
-                } else {
-                    legendRectangle.setFillDrawingMode(Geometry.FillDrawingMode.NONE);
-                }
-
-                /* Legend outline */
-                if (legend.getLineMode()) {
-                    legendRectangle.setLineDrawingMode(Geometry.LineDrawingMode.SEGMENTS);
-                    legendRectangle.setWireIndices(rectangleOutlineIndices);
-
-                    appearance.setLineColor(ColorFactory.createColor(colorMap, legend.getLineColor()));
-                    appearance.setLineWidth(legend.getLineThickness().floatValue());
-                    appearance.setLinePattern(legend.getLineStyleAsEnum().asPattern());
-                } else {
-                    legendRectangle.setLineDrawingMode(Geometry.LineDrawingMode.NONE);
-                }
-
-                drawingTools.draw(legendRectangle, appearance);
-
-                /* Lines: 3 vertices each, left, middle, and right */
-                float [] lineVertexData = new float[] {0.25f, 0.75f, Z_FRONT, 1.0f,
-                                                 0.5f, 0.75f, Z_FRONT, 1.0f,
-                                                 0.75f, 0.75f, Z_FRONT, 1.0f};
-
-                double normSpriteMargin = 0.0;
-
-                if (nbValidLinks > 0) {
-                    normSpriteMargin = (double) legendSpriteDrawer.getMargin() / (double) canvasHeight;
-                }
-
-                lineVertexData[0] = (float) (legendCorner[0] + xOffset);
-                lineVertexData[1] = (float) (legendCorner[1] + normSpriteMargin + yOffset);
-
-                lineVertexData[8] = lineVertexData[0] + (float) lineWidth;
-                lineVertexData[9] = lineVertexData[1];
-
-                lineVertexData[4] = 0.5f*(lineVertexData[0] + lineVertexData[8]);
-                lineVertexData[5] = lineVertexData[1];
-
-                float deltaHeight = 0.0f;
-
-                if (links.length > 0) {
-                    deltaHeight = (float) (normSpriteHeight - 2.0 * normSpriteMargin) / ((float)(links.length));
-                }
+        /* y-axis positioned to the left */
+        if ((legendLocation == LegendLocation.OUT_UPPER_LEFT || legendLocation == LegendLocation.OUT_LOWER_LEFT) && yAxisLocation == 4) {
+            /* To do: use the actual label+tick bounding box width */
+            legendCorner[0] -= TICK_LABEL_SIZE;
+            /* y-axis positioned to the right */
+        } else if ((legendLocation == LegendLocation.OUT_UPPER_RIGHT || legendLocation == LegendLocation.OUT_LOWER_RIGHT) && yAxisLocation == 5) {
+            /* To do: use the actual label+tick bounding box width */
+            legendCorner[0] += TICK_LABEL_SIZE;
+        }
 
-                lineVertexData[1] = lineVertexData[1] + 0.5f*deltaHeight;
-                lineVertexData[5] = lineVertexData[5] + 0.5f*deltaHeight;
-                lineVertexData[9] = lineVertexData[9] + 0.5f*deltaHeight;
 
-                /* Bar vertex data: lower-left, lower-right, upper-left and upper-right corners */
-                float [] barVertexData = new float[] {0.25f, 0.75f, Z_FRONT, 1.0f,
-                                                0.75f, 0.75f, Z_FRONT, 1.0f,
-                                                0.25f, 1.00f, Z_FRONT, 1.0f,
-                                                0.75f, 1.00f, Z_FRONT, 1.0f};
+        /* Afterwards, draw the elements making up the Legend using the previously computed values */
 
-                float barHeight = BAR_HEIGHT*deltaHeight;
+        /* Legend background vertex data: lower-left, lower-right, upper-left and upper-right corners */
+        float [] rectangleVertexData = new float[] {
+            (float)legendCorner[0], (float)legendCorner[1], Z_FRONT, 1.0f,
+            (float)(legendCorner[0] + legendDims[0]), (float)legendCorner[1], Z_FRONT, 1.0f,
+            (float)legendCorner[0], (float)(legendCorner[1] + legendDims[1]), Z_FRONT, 1.0f,
+            (float)(legendCorner[0] + legendDims[0]), (float)(legendCorner[1] + legendDims[1]), Z_FRONT, 1.0f
+        };
 
-                barVertexData[0] = (float) (legendCorner[0] + xOffset);
-                barVertexData[1] = (float) (legendCorner[1] + normSpriteMargin + yOffset) + 0.5f*(deltaHeight - barHeight);
+        /* The indices of a rectangle's triangles and a rectangle outline's segment loop */
+        int[] rectangleIndexData = new int[] {0, 1, 3, 0, 3, 2};
+        int[] rectangleOutlineIndexData = new int[] {0, 1, 1, 3, 3, 2, 2, 0};
 
-                barVertexData[4] = barVertexData[0] + (float) lineWidth;
-                barVertexData[5] = barVertexData[1];
+        rectangleIndices.setData(rectangleIndexData);
+        rectangleOutlineIndices.setData(rectangleOutlineIndexData);
 
-                barVertexData[8] = barVertexData[0];
-                barVertexData[9] = barVertexData[1] + barHeight;
+        rectangleVertices.setData(rectangleVertexData, 4);
 
-                barVertexData[12] = barVertexData[4];
-                barVertexData[13] = barVertexData[9];
+        /* Legend rectangle background and outline */
+        DefaultGeometry legendRectangle = new DefaultGeometry();
+        legendRectangle.setVertices(rectangleVertices);
+        legendRectangle.setIndices(rectangleIndices);
 
-                for (String link : links) {
-                        Polyline currentLine = (Polyline) GraphicController.getController().getObjectFromId(link);
+        Appearance appearance = new Appearance();
 
-                        drawLegendItem(drawingTools, colorMap, currentLine, barVertexData, lineVertexData);
+        if (legend.getFillMode()) {
+            legendRectangle.setFillDrawingMode(Geometry.FillDrawingMode.TRIANGLES);
+            appearance.setFillColor(ColorFactory.createColor(colorMap, legend.getBackground()));
+        } else {
+            legendRectangle.setFillDrawingMode(Geometry.FillDrawingMode.NONE);
+        }
 
-                        /* Update the vertex data's vertical position */
-                        lineVertexData[1] += deltaHeight;
-                        lineVertexData[5] += deltaHeight;
-                        lineVertexData[9] += deltaHeight;
+        /* Legend outline */
+        if (legend.getLineMode()) {
+            legendRectangle.setLineDrawingMode(Geometry.LineDrawingMode.SEGMENTS);
+            legendRectangle.setWireIndices(rectangleOutlineIndices);
 
-                        barVertexData[1] += deltaHeight;
-                        barVertexData[5] += deltaHeight;
-                        barVertexData[9] += deltaHeight;
-                        barVertexData[13] += deltaHeight;
-                }
+            appearance.setLineColor(ColorFactory.createColor(colorMap, legend.getLineColor()));
+            appearance.setLineWidth(legend.getLineThickness().floatValue());
+            appearance.setLinePattern(legend.getLineStyleAsEnum().asPattern());
+        } else {
+            legendRectangle.setLineDrawingMode(Geometry.LineDrawingMode.NONE);
+        }
+
+        drawingTools.draw(legendRectangle, appearance);
 
-                /* Legend text */
-                float [] spritePosition = new float[]{lineVertexData[8] + (float) xOffset, (float) (legendCorner[1] + yOffset), Z_FRONT};
+        /* Lines: 3 vertices each, left, middle, and right */
+        float [] lineVertexData = new float[] {0.25f, 0.75f, Z_FRONT, 1.0f,
+                                               0.5f, 0.75f, Z_FRONT, 1.0f,
+                                               0.75f, 0.75f, Z_FRONT, 1.0f
+                                              };
 
-                /* Draw the sprite only if there are valid links */
-                if (nbValidLinks > 0) {
-                    drawingTools.draw(legendSprite, AnchorPosition.LOWER_LEFT, new Vector3d(spritePosition));
-                }
+        double normSpriteMargin = 0.0;
 
-                /* Restore the transformation stacks */
-                modelViewStack.pop();
-                projectionStack.pop();
+        if (nbValidLinks > 0) {
+            normSpriteMargin = (double) legendSpriteDrawer.getMargin() / (double) canvasHeight;
+        }
 
-                /* Output the position if required */
-                Double [] legendPosition = new Double[2];
+        lineVertexData[0] = (float) (legendCorner[0] + xOffset);
+        lineVertexData[1] = (float) (legendCorner[1] + normSpriteMargin + yOffset);
 
-                if (axesDims[0] == 0.0) {
-                        axesDims[0] = 1.0;
-                }
+        lineVertexData[8] = lineVertexData[0] + (float) lineWidth;
+        lineVertexData[9] = lineVertexData[1];
 
-                if (axesDims[1] == 0.0) {
-                        axesDims[1] = 1.0;
-                }
+        lineVertexData[4] = 0.5f * (lineVertexData[0] + lineVertexData[8]);
+        lineVertexData[5] = lineVertexData[1];
 
-                legendPosition[0] = (legendCorner[0] - axesPos[0]) / axesDims[0];
-                legendPosition[1] = 1.0 - (legendCorner[1] + legendDims[1] - axesPos[1]) / axesDims[1];
+        float deltaHeight = 0.0f;
 
-                if (legendLocation != LegendLocation.BY_COORDINATES) {
-                        legend.setPosition(legendPosition);
-                }
+        if (links.length > 0) {
+            deltaHeight = (float) (normSpriteHeight - 2.0 * normSpriteMargin) / ((float)(links.length));
         }
 
-        /**
-         * Draw the legend item corresponding to the given polyline.
-         * It draws either a horizontal line or bar depending on the polyline's properties (style, fill and line modes).
-         * @param drawingTools the DrawingTools {@see DrawingTools} used to draw the Legend.
-         * @param colorMap the colorMap used.
-         * @param polyline the given polyline.
-         * @param barVertexData a bar's vertex data (4 consecutive (x,y,z,w) quadruplets: lower-left, lower-right, upper-left and upper-right corners.
-         * @param lineVertexData a line's vertex data (3 consecutive (x,y,z,w) quadruplets: left, middle and right vertices).
-         * @throws org.scilab.forge.scirenderer.SciRendererException if the draw fail.
-         */
-        private void drawLegendItem(DrawingTools drawingTools, ColorMap colorMap, Polyline polyline, float[] barVertexData, float[] lineVertexData) throws SciRendererException {
-            int polylineStyle = polyline.getPolylineStyle();
+        lineVertexData[1] = lineVertexData[1] + 0.5f * deltaHeight;
+        lineVertexData[5] = lineVertexData[5] + 0.5f * deltaHeight;
+        lineVertexData[9] = lineVertexData[9] + 0.5f * deltaHeight;
 
-            int lineColor = polyline.getLineColor();
-            double lineThickness = polyline.getLineThickness();
-            short linePattern = polyline.getLineStyleAsEnum().asPattern();
+        /* Bar vertex data: lower-left, lower-right, upper-left and upper-right corners */
+        float [] barVertexData = new float[] {0.25f, 0.75f, Z_FRONT, 1.0f,
+                                              0.75f, 0.75f, Z_FRONT, 1.0f,
+                                              0.25f, 1.00f, Z_FRONT, 1.0f,
+                                              0.75f, 1.00f, Z_FRONT, 1.0f
+                                             };
 
-            boolean isBar = (polylineStyle == 6) || (polylineStyle == 7);
-            boolean barDrawn = isBar || polyline.getFillMode();
+        float barHeight = BAR_HEIGHT * deltaHeight;
 
-            /* Draw a bar if the curve is a bar or if it is filled */
-            if (barDrawn) {
-                barVertices.setData(barVertexData, 4);
+        barVertexData[0] = (float) (legendCorner[0] + xOffset);
+        barVertexData[1] = (float) (legendCorner[1] + normSpriteMargin + yOffset) + 0.5f * (deltaHeight - barHeight);
 
-                DefaultGeometry bar = new DefaultGeometry();
-                bar.setFillDrawingMode(Geometry.FillDrawingMode.TRIANGLES);
+        barVertexData[4] = barVertexData[0] + (float) lineWidth;
+        barVertexData[5] = barVertexData[1];
 
-                Appearance barAppearance = new Appearance();
-                barAppearance.setFillColor(ColorFactory.createColor(colorMap, polyline.getBackground()));
-                bar.setVertices(barVertices);
-                bar.setIndices(rectangleIndices);
+        barVertexData[8] = barVertexData[0];
+        barVertexData[9] = barVertexData[1] + barHeight;
 
-                /* Bar outline */
-                if (isBar || polyline.getLineMode()) {
-                    bar.setLineDrawingMode(Geometry.LineDrawingMode.SEGMENTS);
-                    bar.setWireIndices(rectangleOutlineIndices);
+        barVertexData[12] = barVertexData[4];
+        barVertexData[13] = barVertexData[9];
 
-                    barAppearance.setLineColor(ColorFactory.createColor(colorMap, polyline.getLineColor()));
-                    barAppearance.setLineWidth((float) lineThickness);
-                    barAppearance.setLinePattern(linePattern);
-                } else {
-                    bar.setLineDrawingMode(Geometry.LineDrawingMode.NONE);
-                }
+        for (String link : links) {
+            Polyline currentLine = (Polyline) GraphicController.getController().getObjectFromId(link);
 
-                drawingTools.draw(bar, barAppearance);
-            }
+            drawLegendItem(drawingTools, colorMap, currentLine, barVertexData, lineVertexData);
 
-            /* Draw a line otherwise */
-            if (!barDrawn) {
-                lineVertices.setData(lineVertexData, 4);
-
-                /* A line must also be drawn for the vertical polyline style (3), whatever line mode's value */
-                if (polyline.getLineMode() || polylineStyle == 3) {
-                    DefaultGeometry line = new DefaultGeometry();
-                    line.setFillDrawingMode(Geometry.FillDrawingMode.NONE);
-                    line.setLineDrawingMode(Geometry.LineDrawingMode.SEGMENTS_STRIP);
-                    line.setVertices(lineVertices);
-                    Appearance lineAppearance = new Appearance();
-                    lineAppearance.setLineColor(ColorFactory.createColor(colorMap, lineColor));
-                    lineAppearance.setLineWidth((float) lineThickness);
-                    lineAppearance.setLinePattern(linePattern);
-
-                    drawingTools.draw(line, lineAppearance);
-                }
-            }
+            /* Update the vertex data's vertical position */
+            lineVertexData[1] += deltaHeight;
+            lineVertexData[5] += deltaHeight;
+            lineVertexData[9] += deltaHeight;
 
-            /* Draw arrows */
-            if (polylineStyle == 4) {
-                if (barDrawn) {
-                    /*
-                     * Overlap can occur between the arrow heads of the bar's two smallest segments and the adjacent items.
-                     * To do: adjust arrow size to correct this.
-                     */
-                    visitor.getArrowDrawer().drawArrows(polyline.getParentAxes(), barVertices, rectangleOutlineIndices,
-                        polyline.getArrowSizeFactor(), lineThickness, lineColor);
-                } else {
-                    visitor.getArrowDrawer().drawArrows(polyline.getParentAxes(), lineVertices, lineIndices,
-                        polyline.getArrowSizeFactor(), lineThickness, lineColor);
-                }
-            }
+            barVertexData[1] += deltaHeight;
+            barVertexData[5] += deltaHeight;
+            barVertexData[9] += deltaHeight;
+            barVertexData[13] += deltaHeight;
+        }
 
-            if (polyline.getMarkMode()) {
-                Texture markTexture = markManager.getMarkSprite(polyline, colorMap);
+        /* Legend text */
+        float [] spritePosition = new float[] {lineVertexData[8] + (float) xOffset, (float) (legendCorner[1] + yOffset), Z_FRONT};
 
-                if (barDrawn) {
-                    drawingTools.draw(markTexture, AnchorPosition.CENTER, barVertices);
-                } else {
-                    drawingTools.draw(markTexture, AnchorPosition.CENTER, lineVertices);
-                }
-            }
+        /* Draw the sprite only if there are valid links */
+        if (nbValidLinks > 0) {
+            drawingTools.draw(legendSprite, AnchorPosition.LOWER_LEFT, new Vector3d(spritePosition));
+        }
+
+        /* Restore the transformation stacks */
+        modelViewStack.pop();
+        projectionStack.pop();
+
+        /* Output the position if required */
+        Double [] legendPosition = new Double[2];
 
+        if (axesDims[0] == 0.0) {
+            axesDims[0] = 1.0;
         }
 
-        /**
-         * Updates the legend by disposing its sprite.
-         * @param id the legend id.
-         * @param property the property to update.
-         */
-        public void update(String id, String property) {
-                if (textureMap.containsKey(id)) {
-                        if (SPRITE_PROPERTIES.contains(property)) {
-                                dispose(id);
-                        }
-                }
+        if (axesDims[1] == 0.0) {
+            axesDims[1] = 1.0;
         }
 
-        /**
-         * Disposes the Legend sprite corresponding to the given id.
-         * @param id the legend id.
-         */
-        public void dispose(String id) {
-            Texture texture = textureMap.get(id);
-            if (texture != null) {
-                textureManager.dispose(texture);
-                    textureMap.remove(id);
-            }
+        legendPosition[0] = (legendCorner[0] - axesPos[0]) / axesDims[0];
+        legendPosition[1] = 1.0 - (legendCorner[1] + legendDims[1] - axesPos[1]) / axesDims[1];
+
+        if (legendLocation != LegendLocation.BY_COORDINATES) {
+            legend.setPosition(legendPosition);
         }
+    }
+
+    /**
+     * Draw the legend item corresponding to the given polyline.
+     * It draws either a horizontal line or bar depending on the polyline's properties (style, fill and line modes).
+     * @param drawingTools the DrawingTools {@see DrawingTools} used to draw the Legend.
+     * @param colorMap the colorMap used.
+     * @param polyline the given polyline.
+     * @param barVertexData a bar's vertex data (4 consecutive (x,y,z,w) quadruplets: lower-left, lower-right, upper-left and upper-right corners.
+     * @param lineVertexData a line's vertex data (3 consecutive (x,y,z,w) quadruplets: left, middle and right vertices).
+     * @throws org.scilab.forge.scirenderer.SciRendererException if the draw fail.
+     */
+    private void drawLegendItem(DrawingTools drawingTools, ColorMap colorMap, Polyline polyline, float[] barVertexData, float[] lineVertexData) throws SciRendererException {
+        int polylineStyle = polyline.getPolylineStyle();
+
+        int lineColor = polyline.getLineColor();
+        double lineThickness = polyline.getLineThickness();
+        short linePattern = polyline.getLineStyleAsEnum().asPattern();
+
+        boolean isBar = (polylineStyle == 6) || (polylineStyle == 7);
+        boolean barDrawn = isBar || polyline.getFillMode();
+
+        /* Draw a bar if the curve is a bar or if it is filled */
+        if (barDrawn) {
+            barVertices.setData(barVertexData, 4);
+
+            DefaultGeometry bar = new DefaultGeometry();
+            bar.setFillDrawingMode(Geometry.FillDrawingMode.TRIANGLES);
+
+            Appearance barAppearance = new Appearance();
+            barAppearance.setFillColor(ColorFactory.createColor(colorMap, polyline.getBackground()));
+            bar.setVertices(barVertices);
+            bar.setIndices(rectangleIndices);
+
+            /* Bar outline */
+            if (isBar || polyline.getLineMode()) {
+                bar.setLineDrawingMode(Geometry.LineDrawingMode.SEGMENTS);
+                bar.setWireIndices(rectangleOutlineIndices);
+
+                barAppearance.setLineColor(ColorFactory.createColor(colorMap, polyline.getLineColor()));
+                barAppearance.setLineWidth((float) lineThickness);
+                barAppearance.setLinePattern(linePattern);
+            } else {
+                bar.setLineDrawingMode(Geometry.LineDrawingMode.NONE);
+            }
 
-        /**
-         * Disposes all the Legend resources.
-         */
-        public void disposeAll() {
-            visitor.getCanvas().getBuffersManager().dispose(rectangleVertices);
-            visitor.getCanvas().getBuffersManager().dispose(lineVertices);
-            visitor.getCanvas().getBuffersManager().dispose(barVertices);
-            visitor.getCanvas().getBuffersManager().dispose(lineIndices);
-            visitor.getCanvas().getBuffersManager().dispose(rectangleIndices);
-            visitor.getCanvas().getBuffersManager().dispose(rectangleOutlineIndices);
-
-            textureManager.dispose(textureMap.values());
-                textureMap.clear();
+            drawingTools.draw(bar, barAppearance);
         }
 
-        /**
-         * Returns the legend text texture.
-         * @param colorMap the color map.
-         * @param legend the Legend.
-         * @return the text sprite.
-         */
-        private Texture getTexture(ColorMap colorMap, Legend legend) {
-            Texture texture = textureMap.get(legend.getIdentifier());
-            if (texture == null) {
-                this.legendSpriteDrawer = new LegendSpriteDrawer(colorMap, legend);
-                texture = textureManager.createTexture();
-                texture.setDrawer(legendSpriteDrawer);
-                textureMap.put(legend.getIdentifier(), texture);
+        /* Draw a line otherwise */
+        if (!barDrawn) {
+            lineVertices.setData(lineVertexData, 4);
+
+            /* A line must also be drawn for the vertical polyline style (3), whatever line mode's value */
+            if (polyline.getLineMode() || polylineStyle == 3) {
+                DefaultGeometry line = new DefaultGeometry();
+                line.setFillDrawingMode(Geometry.FillDrawingMode.NONE);
+                line.setLineDrawingMode(Geometry.LineDrawingMode.SEGMENTS_STRIP);
+                line.setVertices(lineVertices);
+                Appearance lineAppearance = new Appearance();
+                lineAppearance.setLineColor(ColorFactory.createColor(colorMap, lineColor));
+                lineAppearance.setLineWidth((float) lineThickness);
+                lineAppearance.setLinePattern(linePattern);
+
+                drawingTools.draw(line, lineAppearance);
             }
-            return texture;
         }
 
-        /**
-         * Determines and returns the number of valid links for the given Legend object.
-         * @param legend the given Legend.
-         * @return the number of valid links.
-         */
-        private int getNumberValidLinks(Legend legend) {
-                int nbValidLinks = 0;
-                String [] links = legend.getLinks();
+        /* Draw arrows */
+        if (polylineStyle == 4) {
+            if (barDrawn) {
+                /*
+                 * Overlap can occur between the arrow heads of the bar's two smallest segments and the adjacent items.
+                 * To do: adjust arrow size to correct this.
+                 */
+                visitor.getArrowDrawer().drawArrows(polyline.getParentAxes(), barVertices, rectangleOutlineIndices,
+                                                    polyline.getArrowSizeFactor(), lineThickness, lineColor);
+            } else {
+                visitor.getArrowDrawer().drawArrows(polyline.getParentAxes(), lineVertices, lineIndices,
+                                                    polyline.getArrowSizeFactor(), lineThickness, lineColor);
+            }
+        }
 
-                for (String link : links) {
-                        Polyline currentLine = (Polyline) GraphicController.getController().getObjectFromId(link);
+        if (polyline.getMarkMode()) {
+            Texture markTexture = markManager.getMarkSprite(polyline, colorMap);
 
-                        if (currentLine != null) {
-                                nbValidLinks++;
-                        }
-                }
+            if (barDrawn) {
+                drawingTools.draw(markTexture, AnchorPosition.CENTER, barVertices);
+            } else {
+                drawingTools.draw(markTexture, AnchorPosition.CENTER, lineVertices);
+            }
+        }
 
-                return nbValidLinks;
+    }
+
+    /**
+     * Updates the legend by disposing its sprite.
+     * @param id the legend id.
+     * @param property the property to update.
+     */
+    public void update(String id, String property) {
+        if (textureMap.containsKey(id)) {
+            if (SPRITE_PROPERTIES.contains(property)) {
+                dispose(id);
+            }
+        }
+    }
+
+    /**
+     * Disposes the Legend sprite corresponding to the given id.
+     * @param id the legend id.
+     */
+    public void dispose(String id) {
+        Texture texture = textureMap.get(id);
+        if (texture != null) {
+            textureManager.dispose(texture);
+            textureMap.remove(id);
+        }
+    }
+
+    /**
+     * Disposes all the Legend resources.
+     */
+    public void disposeAll() {
+        visitor.getCanvas().getBuffersManager().dispose(rectangleVertices);
+        visitor.getCanvas().getBuffersManager().dispose(lineVertices);
+        visitor.getCanvas().getBuffersManager().dispose(barVertices);
+        visitor.getCanvas().getBuffersManager().dispose(lineIndices);
+        visitor.getCanvas().getBuffersManager().dispose(rectangleIndices);
+        visitor.getCanvas().getBuffersManager().dispose(rectangleOutlineIndices);
+
+        textureManager.dispose(textureMap.values());
+        textureMap.clear();
+    }
+
+    /**
+     * Returns the legend text texture.
+     * @param colorMap the color map.
+     * @param legend the Legend.
+     * @return the text sprite.
+     */
+    private Texture getTexture(ColorMap colorMap, Legend legend) {
+        Texture texture = textureMap.get(legend.getIdentifier());
+        if (texture == null) {
+            this.legendSpriteDrawer = new LegendSpriteDrawer(colorMap, legend);
+            texture = textureManager.createTexture();
+            texture.setDrawer(legendSpriteDrawer);
+            textureMap.put(legend.getIdentifier(), texture);
+        }
+        return texture;
+    }
+
+    /**
+     * Determines and returns the number of valid links for the given Legend object.
+     * @param legend the given Legend.
+     * @return the number of valid links.
+     */
+    private int getNumberValidLinks(Legend legend) {
+        int nbValidLinks = 0;
+        String [] links = legend.getLinks();
+
+        for (String link : links) {
+            Polyline currentLine = (Polyline) GraphicController.getController().getObjectFromId(link);
+
+            if (currentLine != null) {
+                nbValidLinks++;
+            }
         }
 
-        /**
-         * Updates the links and text properties of the Legend depending
-         * on the number of valid links provided (the number of links
-         * to non-null objects).
-         * To do: use the graphic controller to perform the update;
-         * move the link update from LegendDrawer to somewhere more appropriate.
-         * @param legend the Legend to update.
-         * @param nbValidLinks the number of valid links.
+        return nbValidLinks;
+    }
+
+    /**
+     * Updates the links and text properties of the Legend depending
+     * on the number of valid links provided (the number of links
+     * to non-null objects).
+     * To do: use the graphic controller to perform the update;
+     * move the link update from LegendDrawer to somewhere more appropriate.
+     * @param legend the Legend to update.
+     * @param nbValidLinks the number of valid links.
+     */
+    private void updateLinks(Legend legend, int nbValidLinks) {
+        int i1 = 0;
+        ArrayList <String> newLinks = new ArrayList<String>(0);
+        String[] newStrings;
+        Integer[] newDims = new Integer[2];
+
+        /*
+         * In case there are no valid links, we create a single empty String
+         * in order to retain the Legend's font properties.
          */
-        private void updateLinks(Legend legend, int nbValidLinks) {
-                int i1 = 0;
-                ArrayList <String> newLinks = new ArrayList<String>(0);
-                String[] newStrings;
-                Integer[] newDims = new Integer[2];
-
-                /*
-                 * In case there are no valid links, we create a single empty String
-                 * in order to retain the Legend's font properties.
-                 */
-                if (nbValidLinks == 0) {
-                    newDims[0] = 1;
-                } else {
-                    newDims[0] = nbValidLinks;
-                }
+        if (nbValidLinks == 0) {
+            newDims[0] = 1;
+        } else {
+            newDims[0] = nbValidLinks;
+        }
 
-                newDims[1] = 1;
+        newDims[1] = 1;
 
-                newStrings = new String[newDims[0]];
+        newStrings = new String[newDims[0]];
 
-                if (nbValidLinks == 0) {
-                    newStrings[0] = new String("");
-                }
+        if (nbValidLinks == 0) {
+            newStrings[0] = new String("");
+        }
 
-                String[] links = legend.getLinks();
-                String[] strings = legend.getTextStrings();
+        String[] links = legend.getLinks();
+        String[] strings = legend.getTextStrings();
 
-                for (int i = 0; i < links.length; i++) {
-                        Polyline currentLine = (Polyline) GraphicController.getController().getObjectFromId(links[i]);
+        for (int i = 0; i < links.length; i++) {
+            Polyline currentLine = (Polyline) GraphicController.getController().getObjectFromId(links[i]);
 
-                        /* Text strings are stored in reverse order relative to links. */
-                        if (currentLine != null) {
-                                newLinks.add(links[i]);
+            /* Text strings are stored in reverse order relative to links. */
+            if (currentLine != null) {
+                newLinks.add(links[i]);
 
-                                newStrings[nbValidLinks-i1-1] = new String(strings[strings.length-i-1]);
-                                i1++;
-                        }
-                }
+                newStrings[nbValidLinks - i1 - 1] = new String(strings[strings.length - i - 1]);
+                i1++;
+            }
+        }
 
-                /* Update the legend's links and text */
-                legend.setLinks(newLinks);
+        /* Update the legend's links and text */
+        legend.setLinks(newLinks);
 
-                legend.setTextArrayDimensions(newDims);
-                legend.setTextStrings(newStrings);
-        }
+        legend.setTextArrayDimensions(newDims);
+        legend.setTextStrings(newStrings);
+    }
 }
index b142486..7aa9cad 100644 (file)
@@ -356,7 +356,7 @@ public class ScilabEditorPane extends JEditorPane implements Highlighter.Highlig
             int res = 0;
             int sres;
             ScilabDocument doc = (ScilabDocument) getDocument();
-            ((CompoundUndoManager) doc.getUndoManager()).enableOneShot(true);
+            doc.getUndoManager().enableOneShot(true);
             doc.mergeEditsBegin();
             caret.protectHighlights(true);
             for (int i = 0; i < pos.length; i++) {
@@ -371,7 +371,7 @@ public class ScilabEditorPane extends JEditorPane implements Highlighter.Highlig
                 }
             }
             doc.mergeEditsEnd();
-            ((CompoundUndoManager) doc.getUndoManager()).enableOneShot(false);
+            doc.getUndoManager().enableOneShot(false);
             caret.protectHighlights(false);
             caret.updateHighlights();
         }
index 7805c7d..5c81e8d 100644 (file)
@@ -47,7 +47,7 @@ public final class CapitalizeAction extends DefaultAction {
      * doAction
      */
     public void doAction() {
-        ScilabEditorPane sep = (ScilabEditorPane) getEditor().getTextPane();
+        ScilabEditorPane sep = getEditor().getTextPane();
         ScilabDocument doc = (ScilabDocument) sep.getDocument();
         String str;
         int start = sep.getSelectionStart();
@@ -63,11 +63,11 @@ public final class CapitalizeAction extends DefaultAction {
                     str = letter.toUpperCase();
                 }
                 doc.mergeEditsBegin();
-                ((CompoundUndoManager) doc.getUndoManager()).enableOneShot(true);
+                doc.getUndoManager().enableOneShot(true);
                 sep.select(start, start + 1);
                 sep.replaceSelection(str);
                 doc.mergeEditsEnd();
-                ((CompoundUndoManager) doc.getUndoManager()).enableOneShot(false);
+                doc.getUndoManager().enableOneShot(false);
             } catch (BadLocationException e) { }
         } else {
             str = sep.getSelectedText();
@@ -121,17 +121,17 @@ public final class CapitalizeAction extends DefaultAction {
     protected static MenuItem createMenu(final String label1, final String label2, final SciNotes editor, KeyStroke key, final CapitalizeAction hoka) {
         final MenuItem menuitem = createMenu(label1, null, hoka, key);
         ((JMenuItem) menuitem.getAsSimpleMenuItem()).addPropertyChangeListener(new PropertyChangeListener() {
-                public void propertyChange(PropertyChangeEvent e) {
-                    if (editor.getTextPane() != null) {
-                        String select = editor.getTextPane().getSelectedText();
-                        if (select == null) {
-                            menuitem.setText(label2);
-                        } else {
-                            menuitem.setText(label1);
-                        }
+            public void propertyChange(PropertyChangeEvent e) {
+                if (editor.getTextPane() != null) {
+                    String select = editor.getTextPane().getSelectedText();
+                    if (select == null) {
+                        menuitem.setText(label2);
+                    } else {
+                        menuitem.setText(label1);
                     }
                 }
-            });
+            }
+        });
 
         return menuitem;
     }
index b97ec51..81d8842 100644 (file)
@@ -45,7 +45,7 @@ public final class CommentAction extends DefaultAction {
      * doAction
      */
     public void doAction() {
-        ScilabEditorPane sep = (ScilabEditorPane) getEditor().getTextPane();
+        ScilabEditorPane sep = getEditor().getTextPane();
         int start = sep.getSelectionStart();
         int end = sep.getSelectionEnd();
         int pos = sep.getCaretPosition();
index c3bf03d..aa6e739 100644 (file)
@@ -58,7 +58,7 @@ public class CopyAsHTMLAction extends DefaultAction {
         if (!getEditor().getTextPane().copyColumnSelectionInClipBoard()) {
             String selection = getEditor().getTextPane().getSelectedText();
             if (selection != null) {
-                HTMLSelection sel = new HTMLSelection((ScilabEditorPane) getEditor().getTextPane(), selection, printLineNumber);
+                HTMLSelection sel = new HTMLSelection(getEditor().getTextPane(), selection, printLineNumber);
                 Toolkit.getDefaultToolkit().getSystemClipboard().setContents(sel, sel);
             }
         }
@@ -134,7 +134,7 @@ public class CopyAsHTMLAction extends DefaultAction {
          * {@inheritDoc}
          */
         public DataFlavor[] getTransferDataFlavors() {
-            return new DataFlavor[]{htmlFlavor, DataFlavor.stringFlavor};
+            return new DataFlavor[] {htmlFlavor, DataFlavor.stringFlavor};
         }
 
         /**
index 002bb36..665fbc7 100644 (file)
@@ -51,14 +51,14 @@ public final class CutAction extends DefaultAction {
         ScilabDocument doc = (ScilabDocument) getEditor().getTextPane().getDocument();
         doc.mergeEditsBegin();
         if (!getEditor().getTextPane().copyColumnSelectionInClipBoard() || !getEditor().getTextPane().removeColumnSelection()) {
-           String selection = getEditor().getTextPane().getSelectedText();
-           if (selection != null) {
-               CopyAsHTMLAction.HTMLSelection sel = new CopyAsHTMLAction.HTMLSelection((ScilabEditorPane) getEditor().getTextPane(), selection, false);
-               Toolkit.getDefaultToolkit().getSystemClipboard().setContents(sel, sel);
-               getEditor().getTextPane().replaceSelection("");
-           }
-       }
-       doc.mergeEditsEnd();
+            String selection = getEditor().getTextPane().getSelectedText();
+            if (selection != null) {
+                CopyAsHTMLAction.HTMLSelection sel = new CopyAsHTMLAction.HTMLSelection(getEditor().getTextPane(), selection, false);
+                Toolkit.getDefaultToolkit().getSystemClipboard().setContents(sel, sel);
+                getEditor().getTextPane().replaceSelection("");
+            }
+        }
+        doc.mergeEditsEnd();
     }
 
     /**
index 07bc73a..9354385 100644 (file)
@@ -45,7 +45,7 @@ public final class DoubleQuoteStringAction extends DefaultAction {
      * doAction
      */
     public void doAction() {
-        ScilabEditorPane sep = (ScilabEditorPane) getEditor().getTextPane();
+        ScilabEditorPane sep = getEditor().getTextPane();
         ScilabDocument doc = (ScilabDocument) sep.getDocument();
         doc.getUndoManager().enableOneShot(true);
         doc.mergeEditsBegin();
index 4689037..e08200c 100644 (file)
@@ -52,7 +52,7 @@ public final class EvaluateSelectionAction extends DefaultAction {
      */
     public void doAction() {
         /* Will do the job as if it was copy / paste in scilab Console */
-        ScilabEditorPane sep = (ScilabEditorPane) getEditor().getTextPane();
+        ScilabEditorPane sep = getEditor().getTextPane();
         String selection = sep.getCodeToExecute();
         if (selection.compareTo("") != 0) {
             StringTokenizer tokens = new StringTokenizer(selection, "\n");
@@ -82,17 +82,17 @@ public final class EvaluateSelectionAction extends DefaultAction {
             ((JMenuItem) menuitem.getAsSimpleMenuItem()).setEnabled(false);
         }
         ((JMenuItem) menuitem.getAsSimpleMenuItem()).addPropertyChangeListener(new PropertyChangeListener() {
-                public void propertyChange(PropertyChangeEvent e) {
-                    if (editor.getTextPane() != null) {
-                        String select = editor.getTextPane().getSelectedText();
-                        if (select == null) {
-                            menuitem.setText(label2);
-                        } else {
-                            menuitem.setText(label1);
-                        }
+            public void propertyChange(PropertyChangeEvent e) {
+                if (editor.getTextPane() != null) {
+                    String select = editor.getTextPane().getSelectedText();
+                    if (select == null) {
+                        menuitem.setText(label2);
+                    } else {
+                        menuitem.setText(label1);
                     }
                 }
-            });
+            }
+        });
 
         return menuitem;
     }
index e4d23fd..71a0f67 100644 (file)
@@ -99,32 +99,32 @@ public class ExportAction extends DefaultAction {
         fileChooser.setTitle(title);
 
         fileChooser.addPropertyChangeListener(JFileChooser.FILE_FILTER_CHANGED_PROPERTY, new PropertyChangeListener() {
-                public void propertyChange(PropertyChangeEvent e) {
-                    Object val = e.getNewValue();
-                    if (val != null && (val instanceof SciFileFilter)) {
-                        String filter = ((SciFileFilter) val).getDescription();
-                        String file = currentFile.getName();
-                        int dotpos = file.lastIndexOf(".");
-                        if (dotpos != -1) {
-                            file = file.substring(0, dotpos);
-                        }
-                        dotpos = filter.lastIndexOf(".");
-                        if (dotpos != -1) {
-                            filter = filter.substring(dotpos, filter.length() - 1);
-                        }
-                        fileChooser.setSelectedFile(new File(file + filter));
+            public void propertyChange(PropertyChangeEvent e) {
+                Object val = e.getNewValue();
+                if (val != null && (val instanceof SciFileFilter)) {
+                    String filter = ((SciFileFilter) val).getDescription();
+                    String file = currentFile.getName();
+                    int dotpos = file.lastIndexOf(".");
+                    if (dotpos != -1) {
+                        file = file.substring(0, dotpos);
                     }
+                    dotpos = filter.lastIndexOf(".");
+                    if (dotpos != -1) {
+                        filter = filter.substring(dotpos, filter.length() - 1);
+                    }
+                    fileChooser.setSelectedFile(new File(file + filter));
                 }
-            });
+            }
+        });
 
         fileChooser.addPropertyChangeListener(JFileChooser.SELECTED_FILE_CHANGED_PROPERTY , new PropertyChangeListener() {
-                public void propertyChange(PropertyChangeEvent e) {
-                    Object val = e.getNewValue();
-                    if (val != null && (val instanceof File)) {
-                        currentFile = (File) val;
-                    }
+            public void propertyChange(PropertyChangeEvent e) {
+                Object val = e.getNewValue();
+                if (val != null && (val instanceof File)) {
+                    currentFile = (File) val;
                 }
-            });
+            }
+        });
 
         String name = getEditor().getTextPane().getName();
         if (name == null) {
@@ -214,7 +214,7 @@ public class ExportAction extends DefaultAction {
 
         if (fileName != null && type != null) {
             getEditor().getTextPane().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
-            CodeExporter.convert((ScilabEditorPane) getEditor().getTextPane(), fileName, type, PageSetupAction.getPageFormat());
+            CodeExporter.convert(getEditor().getTextPane(), fileName, type, PageSetupAction.getPageFormat());
             getEditor().getTextPane().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
         }
     }
index 7d64159..4e87f90 100644 (file)
@@ -39,25 +39,25 @@ public class GenerateHelpFromFunctionAction extends DefaultAction {
      * The help template
      */
     public static final String TEMPLATE = "//\n"
-        + "//\n"
-        + "// Calling Sequence\n"
-        + "// [returnValues] = functionName(argsValues) // \n"
-        + "// Parameters\n"
-        + "// argsValuesOnColumn\n"
-        + "// returnValuesOnColumn\n"
-        + "// \n"
-        + "// Description\n"
-        + "// \n"
-        + "// \n"
-        + "// Examples\n"
-        + "// \n"
-        + "// \n"
-        + "// See Also\n"
-        + "// \n"
-        + "// \n"
-        + "// Authors\n"
-        + "// \n"
-        + "\n";
+                                          + "//\n"
+                                          + "// Calling Sequence\n"
+                                          + "// [returnValues] = functionName(argsValues) // \n"
+                                          + "// Parameters\n"
+                                          + "// argsValuesOnColumn\n"
+                                          + "// returnValuesOnColumn\n"
+                                          + "// \n"
+                                          + "// Description\n"
+                                          + "// \n"
+                                          + "// \n"
+                                          + "// Examples\n"
+                                          + "// \n"
+                                          + "// \n"
+                                          + "// See Also\n"
+                                          + "// \n"
+                                          + "// \n"
+                                          + "// Authors\n"
+                                          + "// \n"
+                                          + "\n";
 
     /**
      * Constructor
@@ -72,7 +72,7 @@ public class GenerateHelpFromFunctionAction extends DefaultAction {
      * doAction
      */
     public void doAction() {
-        ScilabEditorPane sep = (ScilabEditorPane) getEditor().getTextPane();
+        ScilabEditorPane sep = getEditor().getTextPane();
         int pos = sep.getCaretPosition();
         ScilabDocument doc = (ScilabDocument) sep.getDocument();
         Element root = doc.getDefaultRootElement();
@@ -123,15 +123,15 @@ public class GenerateHelpFromFunctionAction extends DefaultAction {
     public static MenuItem createMenu(String label, final SciNotes editor, KeyStroke key) {
         final MenuItem menuitem = createMenu(label, null, new GenerateHelpFromFunctionAction(label, editor), key);
         ((JMenuItem) menuitem.getAsSimpleMenuItem()).addPropertyChangeListener(new PropertyChangeListener() {
-                public void propertyChange(PropertyChangeEvent e) {
-                    if (editor.getTextPane() != null) {
-                        Element root = editor.getTextPane().getDocument().getDefaultRootElement();
-                        int pos = editor.getTextPane().getCaretPosition();
-                        ScilabDocument.ScilabLeafElement elem = (ScilabDocument.ScilabLeafElement) root.getElement(root.getElementIndex(pos));
-                        menuitem.setEnabled(elem.isFunction());
-                    }
+            public void propertyChange(PropertyChangeEvent e) {
+                if (editor.getTextPane() != null) {
+                    Element root = editor.getTextPane().getDocument().getDefaultRootElement();
+                    int pos = editor.getTextPane().getCaretPosition();
+                    ScilabDocument.ScilabLeafElement elem = (ScilabDocument.ScilabLeafElement) root.getElement(root.getElementIndex(pos));
+                    menuitem.setEnabled(elem.isFunction());
                 }
-            });
+            }
+        });
 
         return menuitem;
     }
index fc28543..b09eea6 100644 (file)
@@ -41,7 +41,7 @@ public class GotoNextAnchorAction extends DefaultAction {
      * doAction
      */
     public void doAction() {
-        ScilabEditorPane sep = (ScilabEditorPane) getEditor().getTextPane();
+        ScilabEditorPane sep = getEditor().getTextPane();
         ScilabDocument doc = (ScilabDocument) sep.getDocument();
         Element root = doc.getDefaultRootElement();
         int line = root.getElementIndex(sep.getCaretPosition());
index 3e04be9..a00c64a 100644 (file)
@@ -41,7 +41,7 @@ public class GotoPreviousAnchorAction extends DefaultAction {
      * doAction
      */
     public void doAction() {
-        ScilabEditorPane sep = (ScilabEditorPane) getEditor().getTextPane();
+        ScilabEditorPane sep = getEditor().getTextPane();
         ScilabDocument doc = (ScilabDocument) sep.getDocument();
         Element root = doc.getDefaultRootElement();
         int line = root.getElementIndex(sep.getCaretPosition());
index 3085450..b372639 100644 (file)
@@ -54,7 +54,7 @@ public class HelpOnKeywordAction extends DefaultAction {
         int end = getEditor().getTextPane().getSelectionEnd();
         try {
             if (start == end) {
-                String kw = ((ScilabEditorPane) getEditor().getTextPane()).getHelpableKeyword(!isPopup);
+                String kw = getEditor().getTextPane().getHelpableKeyword(!isPopup);
                 if (kw != null) {
                     selection = kw;
                 }
@@ -91,25 +91,25 @@ public class HelpOnKeywordAction extends DefaultAction {
     protected static MenuItem createMenu(final String label1, final String label2, final SciNotes editor, KeyStroke key, final HelpOnKeywordAction hoka) {
         final MenuItem menuitem = createMenu(label1, null, hoka, key);
         ((JMenuItem) menuitem.getAsSimpleMenuItem()).addPropertyChangeListener(new PropertyChangeListener() {
-                public void propertyChange(PropertyChangeEvent e) {
-                    if (editor.getTextPane() != null) {
-                        String select = editor.getTextPane().getSelectedText();
-                        if (select == null) {
-                            String kw = ((ScilabEditorPane) editor.getTextPane()).getHelpableKeyword(!hoka.isPopup);
-                            if (kw != null) {
-                                menuitem.setText(label1 + SciNotesMessages.QUOTE + kw + SciNotesMessages.QUOTE);
-                                menuitem.setEnabled(true);
-                            } else {
-                                menuitem.setText(label1 + SciNotesMessages.DOTS);
-                                menuitem.setEnabled(false);
-                            }
-                        } else {
-                            menuitem.setText(label2);
+            public void propertyChange(PropertyChangeEvent e) {
+                if (editor.getTextPane() != null) {
+                    String select = editor.getTextPane().getSelectedText();
+                    if (select == null) {
+                        String kw = editor.getTextPane().getHelpableKeyword(!hoka.isPopup);
+                        if (kw != null) {
+                            menuitem.setText(label1 + SciNotesMessages.QUOTE + kw + SciNotesMessages.QUOTE);
                             menuitem.setEnabled(true);
+                        } else {
+                            menuitem.setText(label1 + SciNotesMessages.DOTS);
+                            menuitem.setEnabled(false);
                         }
+                    } else {
+                        menuitem.setText(label2);
+                        menuitem.setEnabled(true);
                     }
                 }
-            });
+            }
+        });
 
         return menuitem;
     }
index 92ec9a1..04922bc 100644 (file)
@@ -42,7 +42,7 @@ public final class IndentAction extends DefaultAction {
      * doAction
      */
     public void doAction() {
-        ScilabEditorPane sep = (ScilabEditorPane) getEditor().getTextPane();
+        ScilabEditorPane sep = getEditor().getTextPane();
         int start = sep.getSelectionStart();
         int end = sep.getSelectionEnd();
         int pos = sep.getCaretPosition();
index f93b6de..adc73fb 100644 (file)
@@ -46,7 +46,7 @@ public class NextParagraphAction extends DefaultAction {
      * doAction
      */
     public void doAction() {
-        ScilabEditorPane sep = (ScilabEditorPane) getEditor().getTextPane();
+        ScilabEditorPane sep = getEditor().getTextPane();
         ScilabDocument doc = (ScilabDocument) sep.getDocument();
         Element root = doc.getDefaultRootElement();
         int line = root.getElementIndex(sep.getCaretPosition());