I. Dix преди 7 години
родител
ревизия
388ed38881
променени са 3 файла, в които са добавени 94 реда и са изтрити 108 реда
  1. 55 57
      src/ui/view/AbstractCanvas.java
  2. 6 6
      src/ui/view/MyCanvas.java
  3. 33 45
      src/ui/view/UpperNodeCanvas.java

+ 55 - 57
src/ui/view/AbstractCanvas.java

@@ -20,60 +20,58 @@ import java.util.TimerTask;
  * @author: I. Dix
  */
 public abstract class AbstractCanvas extends JPanel {
-    protected final JMenuItem itemDelete = new JMenuItem(Languages.getLanguage()[98]);
-    protected final JMenuItem itemCut = new JMenuItem(Languages.getLanguage()[95]);
-    protected final JMenuItem itemCopy = new JMenuItem(Languages.getLanguage()[96]);
-    protected final JMenuItem itemPaste = new JMenuItem(Languages.getLanguage()[97]);
-    protected final JMenuItem itemGroup = new JMenuItem(Languages.getLanguage()[99]);
-    protected final JMenuItem itemUngroup = new JMenuItem(Languages.getLanguage()[100]);
-    protected final JMenuItem itemTrack = new JMenuItem(Languages.getLanguage()[101]);
-    protected final JMenuItem itemUntrack = new JMenuItem(Languages.getLanguage()[102]);
-    protected final int ANIMTIME = 500; // animation Time
-    protected final int animFPS = 60;
-    protected final int animDelay = 1000 / animFPS; // animation Delay
-    // Selection
-    public AbstractCpsObject tempCps = null;
+    final JMenuItem itemDelete = new JMenuItem(Languages.getLanguage()[98]);
+    final JMenuItem itemCut = new JMenuItem(Languages.getLanguage()[95]);
+    final JMenuItem itemCopy = new JMenuItem(Languages.getLanguage()[96]);
+    final JMenuItem itemPaste = new JMenuItem(Languages.getLanguage()[97]);
+    final JMenuItem itemGroup = new JMenuItem(Languages.getLanguage()[99]);
+    final JMenuItem itemUngroup = new JMenuItem(Languages.getLanguage()[100]);
+    final JMenuItem itemTrack = new JMenuItem(Languages.getLanguage()[101]);
+    final JMenuItem itemUntrack = new JMenuItem(Languages.getLanguage()[102]);
+    final int ANIMTIME = 500; // animation Time
+    private final int animFPS = 60;
+    final int animDelay = 1000 / animFPS; // animation Delay
     protected Model model;
     protected Control controller;
-    protected UpdateController updCon;
-    // PopUpMenu
-    protected JPopupMenu popmenu = new JPopupMenu();
-    // Tooltip
-    protected boolean toolTip; // Tooltip on or off
-    protected Position toolTipPos = new Position(); // Tooltip Position
-    protected String toolTipText = "";
-    protected ArrayList<HolonElement> dataSelected = new ArrayList<>();
-    protected ArrayList<AbstractCpsObject> tempSelected = new ArrayList<>();
-    protected boolean[] showedInformation = new boolean[5];
-    // Mouse
-    protected boolean click = false;
-    protected boolean dragging = false; // for dragging
-    protected boolean dragged = false; // if an object/objects was/were dragged
-    protected boolean drawEdge = false; // for drawing edges
-    protected boolean doMark = false; // for double click
-    protected CpsEdge edgeHighlight = null;
     protected int x = 0;
     protected int y = 0;
-    protected Point mousePosition = new Point(); // Mouse Position when
-    protected ArrayList<Position> savePos;
+    // Selection
+    AbstractCpsObject tempCps = null;
+    UpdateController updCon;
+    // PopUpMenu
+    JPopupMenu popmenu = new JPopupMenu();
+    // Tooltip
+    boolean toolTip; // Tooltip on or off
+    Position toolTipPos = new Position(); // Tooltip Position
+    String toolTipText = "";
+    ArrayList<HolonElement> dataSelected = new ArrayList<>();
+    ArrayList<AbstractCpsObject> tempSelected = new ArrayList<>();
+    boolean[] showedInformation = new boolean[5];
+    boolean dragging = false; // for dragging
+    boolean dragged = false; // if an object/objects was/were dragged
+    boolean drawEdge = false; // for drawing edges
+    boolean doMark = false; // for double click
+    CpsEdge edgeHighlight = null;
+    Point mousePosition = new Point(); // Mouse Position when
+    ArrayList<Position> savePos;
     // edge Object Start Point
-    protected int cx, cy;
-    protected int sx, sy; // Mark Coords
-    protected Position unPos;
+    int cx, cy;
+    int sx, sy; // Mark Coords
+    Position unPos;
     // Animation
-    protected Timer animT; // animation Timer
-    protected int animDuration = ANIMTIME; // animation Duration
-    protected int animSteps = animDuration / animDelay; // animation Steps;
-    protected ArrayList<AbstractCpsObject> animCps = null;
-
+    Timer animT; // animation Timer
+    int animDuration = ANIMTIME; // animation Duration
+    int animSteps = animDuration / animDelay; // animation Steps;
+    ArrayList<AbstractCpsObject> animCps = null;
     // Graphics
-    protected Image img = null; // Contains the image to draw on the Canvas
-    protected Graphics2D g2; // For Painting
-    protected float scalediv20;
-
+    Image img = null; // Contains the image to draw on the Canvas
+    Graphics2D g2; // For Painting
+    float scalediv20;
+    // Mouse
+    private boolean click = false;
 
     // ------------------------------------------ METHODS ------------------------------------------
-    protected String paintEdge(CpsEdge con, String maxCap) {
+    String paintEdge(CpsEdge con, String maxCap) {
         if (con.getA().getId() != model.getSelectedObjectID() && con.getB().getId() != model.getSelectedObjectID()
                 && con != edgeHighlight) {
             if (con.getConnected() == CpsEdge.CON_UPPER_NODE) {
@@ -104,7 +102,7 @@ public abstract class AbstractCanvas extends JPanel {
     }
 
 
-    protected void setEdgeState(CpsEdge con) {
+    void setEdgeState(CpsEdge con) {
         if (con.isWorking()) {
             g2.setColor(Color.GREEN);
             if (con.getCapacity() != CpsEdge.CAPACITY_INFINITE) {
@@ -117,7 +115,7 @@ public abstract class AbstractCanvas extends JPanel {
     }
 
 
-    protected String setCapacityString(CpsEdge con, String maxCap) {
+    String setCapacityString(CpsEdge con, String maxCap) {
         if (con.getCapacity() == -1) {
             maxCap = Character.toString('\u221e');
         } else if (con.getCapacity() == -2) {
@@ -129,7 +127,7 @@ public abstract class AbstractCanvas extends JPanel {
     }
 
 
-    protected String drawEdgeLine(CpsEdge con, String maxCap) {
+    String drawEdgeLine(CpsEdge con, String maxCap) {
         if (con.getA().getId() == model.getSelectedObjectID()
                 || model.getSelectedCpsObjects().contains(con.getA()) || tempSelected.contains(con.getA())
                 || con.getB().getId() == model.getSelectedObjectID()
@@ -158,7 +156,7 @@ public abstract class AbstractCanvas extends JPanel {
     }
 
 
-    protected void setEdgePictureAndHighlighting(AbstractCpsObject cps) {
+    void setEdgePictureAndHighlighting(AbstractCpsObject cps) {
         // node image
         if (cps instanceof CpsNode && (cps == tempCps || model.getSelectedCpsObject() == cps
                 || model.getSelectedCpsObjects().contains(cps) || tempSelected.contains(cps))) {
@@ -211,7 +209,7 @@ public abstract class AbstractCanvas extends JPanel {
     }
 
 
-    protected void drawMarker() {
+    void drawMarker() {
         if (sx > x && sy > y) {
             g2.drawRect(x, y, sx - x, sy - y);
         } else if (sx < x && sy < y) {
@@ -224,7 +222,7 @@ public abstract class AbstractCanvas extends JPanel {
     }
 
 
-    protected void showTooltip(Graphics g) {
+    void showTooltip(Graphics g) {
         if (toolTip) {
             g2.setColor(new Color(255, 225, 150));
             g2.setStroke(new BasicStroke(1));
@@ -251,7 +249,7 @@ public abstract class AbstractCanvas extends JPanel {
     }
 
 
-    protected void setConsoleTextAfterSelect(AbstractCpsObject cps) {
+    void setConsoleTextAfterSelect(AbstractCpsObject cps) {
         if (model.getShowConsoleLog()) {
             controller.addTextToConsole("Selected: ", Color.BLACK, 12, false, false, false);
             controller.addTextToConsole("" + cps.getName(), Color.BLUE, 12, true, false, false);
@@ -261,7 +259,7 @@ public abstract class AbstractCanvas extends JPanel {
     }
 
 
-    protected void setRightclickMenu(MouseEvent e) {
+    void setRightClickMenu(MouseEvent e) {
         if (e.getButton() == MouseEvent.BUTTON3) {
             if (tempCps != null) {
                 itemDelete.setEnabled(true);
@@ -294,7 +292,7 @@ public abstract class AbstractCanvas extends JPanel {
     }
 
 
-    protected void markObjects() {
+    void markObjects() {
         if (doMark) {
             doMark = false;
             for (AbstractCpsObject cps : tempSelected) {
@@ -307,7 +305,7 @@ public abstract class AbstractCanvas extends JPanel {
         }
     }
 
-    protected int[] determineMousePositionOnEdge(CpsEdge p) {
+    int[] determineMousePositionOnEdge(CpsEdge p) {
         int lx, ly, hx, hy;
 
         if (p.getA().getPosition().x > p.getB().getPosition().x) {
@@ -334,7 +332,7 @@ public abstract class AbstractCanvas extends JPanel {
      *
      * @return true if doublecklick, false if not
      */
-    protected boolean doubleClick() {
+    boolean doubleClick() {
         if (click) {
             click = false;
             return true;
@@ -351,7 +349,7 @@ public abstract class AbstractCanvas extends JPanel {
         return false;
     }
 
-    protected boolean setToolTipInfoAndPosition(boolean on, AbstractCpsObject cps) {
+    boolean setToolTipInfoAndPosition(boolean on, AbstractCpsObject cps) {
         if (x - controller.getScale() <= cx && y - controller.getScale() <= cy && x >= cx && y >= cy) {
             on = true;
             toolTipPos.x = cps.getPosition().x - controller.getScaleDiv2();

+ 6 - 6
src/ui/view/MyCanvas.java

@@ -530,7 +530,7 @@ public class MyCanvas extends AbstractCanvas implements MouseListener, MouseMoti
         dragged = false;
 
         // Rightclick List
-        setRightclickMenu(e);
+        setRightClickMenu(e);
 
         markObjects();
 
@@ -774,7 +774,7 @@ public class MyCanvas extends AbstractCanvas implements MouseListener, MouseMoti
         return null;
     }
 
-    protected void updateLanguages() {
+    void updateLanguages() {
         itemCut.setText(Languages.getLanguage()[95]);
         itemCopy.setText(Languages.getLanguage()[96]);
         itemPaste.setText(Languages.getLanguage()[97]);
@@ -792,7 +792,7 @@ public class MyCanvas extends AbstractCanvas implements MouseListener, MouseMoti
      * @param object     boolean for objects
      * @param nodeOfnode
      */
-    public void setShowedInformation(boolean connection, boolean object, boolean border, boolean nodeOfnode) {
+    void setShowedInformation(boolean connection, boolean object, boolean border, boolean nodeOfnode) {
         showedInformation[0] = connection;
         showedInformation[1] = object;
         showedInformation[3] = border;
@@ -804,7 +804,7 @@ public class MyCanvas extends AbstractCanvas implements MouseListener, MouseMoti
      *
      * @return Array of boolean [0] = connection, [1] = objects
      */
-    protected boolean[] getShowedInformation() {
+    boolean[] getShowedInformation() {
         return showedInformation;
     }
 
@@ -813,7 +813,7 @@ public class MyCanvas extends AbstractCanvas implements MouseListener, MouseMoti
      *
      * @param bool
      */
-    protected void setToolTip(boolean bool) {
+    void setToolTip(boolean bool) {
         this.toolTip = bool;
     }
 
@@ -823,7 +823,7 @@ public class MyCanvas extends AbstractCanvas implements MouseListener, MouseMoti
      * @param x
      * @param y
      */
-    protected void setXY(int x, int y) {
+    void setXY(int x, int y) {
         this.x = x;
         this.y = y;
     }

+ 33 - 45
src/ui/view/UpperNodeCanvas.java

@@ -29,7 +29,7 @@ public class UpperNodeCanvas extends AbstractCanvas implements MouseListener, Mo
     public CpsUpperNode upperNode;
     // Path
     protected String path;
-    protected int code;
+    int code;
     private JLabel breadCrumb;
 
 
@@ -40,7 +40,7 @@ public class UpperNodeCanvas extends AbstractCanvas implements MouseListener, Mo
      * @param control   the Controller
      * @param unitGraph
      */
-    public UpperNodeCanvas(Model mod, Control control, UnitGraph unitGraph, CpsUpperNode UpperNode, String parentPath) {
+    UpperNodeCanvas(Model mod, Control control, UnitGraph unitGraph, CpsUpperNode UpperNode, String parentPath) {
         toolTip = false;
 
         this.controller = control;
@@ -722,7 +722,7 @@ public class UpperNodeCanvas extends AbstractCanvas implements MouseListener, Mo
         dragged = false;
 
         // Rightclick List
-        setRightclickMenu(e);
+        setRightClickMenu(e);
 
         markObjects();
 
@@ -1149,35 +1149,23 @@ public class UpperNodeCanvas extends AbstractCanvas implements MouseListener, Mo
         return null;
     }
 
-    /**
-     * sets the Edge Capacity.
-     *
-     * @param cap capacity
-     */
-    public void setEdgeCapacity(float cap) {
-        controller.setMaxCapacity(cap);
-    }
-
-    /**
-     * Set if Information should be shown.
-     *
-     * @param connection boolean for conecction
-     * @param object     boolean for objects
-     */
-    public void setShowedInformation(boolean connection, boolean object, boolean nodeOfnode) {
-        showedInformation[0] = connection;
-        showedInformation[1] = object;
-        showedInformation[4] = nodeOfnode;
-    }
-
-    /**
-     * Returns if Information should be shown.
-     *
-     * @return Array of boolean [0] = connection, [1] = objects
-     */
-    public boolean[] getShowedInformation() {
-        return showedInformation;
-    }
+//    /**
+//     * sets the Edge Capacity.
+//     *
+//     * @param cap capacity
+//     */
+//    public void setEdgeCapacity(float cap) {
+//        controller.setMaxCapacity(cap);
+//    }
+
+//    /**
+//     * Returns if Information should be shown.
+//     *
+//     * @return Array of boolean [0] = connection, [1] = objects
+//     */
+//    public boolean[] getShowedInformation() {
+//        return showedInformation;
+//    }
 
     /**
      * copies a set of given informations
@@ -1188,24 +1176,24 @@ public class UpperNodeCanvas extends AbstractCanvas implements MouseListener, Mo
         showedInformation = informations;
     }
 
-    /**
-     * Set the Background Image;
-     *
-     * @param imagePath Image Path
-     * @param mode      Image Mode
-     * @param width     Image custom width
-     * @param height    Image custom height
-     */
-    public void setBackgroundImage(String imagePath, int mode, int width, int height) {
-        upperNode.setBackgroundImage(imagePath, mode, width, height);
-    }
+//    /**
+//     * Set the Background Image;
+//     *
+//     * @param imagePath Image Path
+//     * @param mode      Image Mode
+//     * @param width     Image custom width
+//     * @param height    Image custom height
+//     */
+//    public void setBackgroundImage(String imagePath, int mode, int width, int height) {
+//        upperNode.setBackgroundImage(imagePath, mode, width, height);
+//    }
 
     /**
      * set tooltIp
      *
      * @param bool
      */
-    protected void setToolTip(boolean bool) {
+    void setToolTip(boolean bool) {
         this.toolTip = bool;
     }
 
@@ -1215,7 +1203,7 @@ public class UpperNodeCanvas extends AbstractCanvas implements MouseListener, Mo
      * @param x
      * @param y
      */
-    public void setXY(int x, int y) {
+    void setXY(int x, int y) {
         this.x = x;
         this.y = y;
     }