[elvystrac] r1659 -

  • From: elvys@xxxxxxxxxxxxxxxxxxxxxx
  • To: elvystrac@xxxxxxxxxxxxx
  • Date: Wed, 27 Jan 2010 22:07:58 +0100

Author: EvaV
Date: 2010-01-27 22:07:57 +0100 (Wed, 27 Jan 2010)
New Revision: 1659

Modified:
   trunk/layouteditor/LayoutDesigner/src/applet/AbsoluteCoordinates.java
   trunk/layouteditor/LayoutDesigner/src/applet/Layout.java
   trunk/layouteditor/LayoutDesigner/src/applet/MovingObject.java
   trunk/layouteditor/LayoutDesigner/src/applet/Position.java
   trunk/layouteditor/LayoutDesigner/src/applet/Positions.java
   trunk/layouteditor/LayoutDesigner/src/applet/PropertiesTable.java
Log:


Modified: trunk/layouteditor/LayoutDesigner/src/applet/AbsoluteCoordinates.java
===================================================================
--- trunk/layouteditor/LayoutDesigner/src/applet/AbsoluteCoordinates.java       
2010-01-25 23:19:29 UTC (rev 1658)
+++ trunk/layouteditor/LayoutDesigner/src/applet/AbsoluteCoordinates.java       
2010-01-27 21:07:57 UTC (rev 1659)
@@ -79,6 +79,15 @@
        public AbsoluteCoordinates clone() {
                return new AbsoluteCoordinates(topX, topY, width, height);
        }
+       
+       /**
+        * Decides whatever this AbsoluteCoordinates has same properties and 
coordinates as the second one
+        * @param second the second AbsoluteCoordinates
+        * @return whatever this AbsoluteCoordinates has same properties and 
coordinates as the second one
+        */
+       public boolean equals(AbsoluteCoordinates second) {
+               return ((this.height == second.height) && (this.topX == 
second.topX) && (this.topY == second.topY) && (this.width == second.width));
+       }
 
        // getters & setters
        /**

Modified: trunk/layouteditor/LayoutDesigner/src/applet/Layout.java
===================================================================
--- trunk/layouteditor/LayoutDesigner/src/applet/Layout.java    2010-01-25 
23:19:29 UTC (rev 1658)
+++ trunk/layouteditor/LayoutDesigner/src/applet/Layout.java    2010-01-27 
21:07:57 UTC (rev 1659)
@@ -157,9 +157,18 @@
                        int deltaTopX, int deltaTopY, int deltaWidth, int 
deltaHeight,
                        Layout.AddType addType) {
 
+               Positions oldPositions = getLayoutPositions().clone();
                Positions layoutPositions = getLayoutPositions().clone();
                Positions positions = getSelectedPositions();
 
+               boolean isOutOf = false;
+               int deltaMonitorTopX = 0;
+               int deltaMonitorTopY = 0;
+               int deltaMonitorWidth = 0;
+               int deltaMonitorHeight = 0;
+
+               isSnappedToGrid = designArea.isSnapToGridEnabled();
+               
                for (int i = 0; i < positions.getPositions().size(); ++i) {
                        Position oldPosition = positions.getPositions().get(i);
                        Position newPosition = oldPosition.clone();
@@ -174,6 +183,16 @@
                        int monitorX = grid.getMonitorGridXsize();
                        int monitorY = grid.getMonitorGridYsize();
 
+                       /*if (isSnappedToGrid) {
+
+                               System.out.println("snapped to grid");
+                               System.out.println(oldTopX + " : " + oldTopY);
+                               grid = new Grid(oldTopX, oldTopY);
+                               grid.snapToGridKioskCoordinates(designArea);
+                               oldTopX = grid.getX();
+                               oldTopY = grid.getY();
+                               System.out.println(oldTopX + " : " + oldTopY);
+                       }*/
                        kiosek.setTopX(oldTopX + deltaTopX);
                        kiosek.setTopY(oldTopY + deltaTopY);
                        kiosek.setWidth(oldWidth + deltaWidth);
@@ -182,12 +201,23 @@
                        int WIDTH = getScreenResolution().getElvysWidth();
                        int HEIGHT = getScreenResolution().getElvysHeight();
 
-                       kiosek = 
oldPosition.changeCoordinatesToNotBeOutOfDesignArea(kiosek
-                                       .getTopX(), kiosek.getTopY(), 
kiosek.getWidth(), kiosek
-                                       .getHeight(), WIDTH, HEIGHT, addType, 
true, designArea);
+                       //System.out.println(kiosek.getTopX() + " : " + 
kiosek.getTopY() + " : " + kiosek.getWidth() + " : " + kiosek.getHeight());
+                       //System.out.println(kiosek.getTopX() + 
kiosek.getWidth() + " : " + kiosek.getHeight() + kiosek.getTopY());
+                       AbsoluteCoordinates kiosek1 = oldPosition
+                                       
.changeCoordinatesToNotBeOutOfDesignArea(kiosek.getTopX(),
+                                                       kiosek.getTopY(), 
kiosek.getWidth(), kiosek
+                                                                       
.getHeight(), WIDTH, HEIGHT, addType, true,
+                                                       designArea);
+                       //System.out.println(addType + " : " + WIDTH + " : " + 
HEIGHT);
+                       //System.out.println(kiosek.getTopX() + " : " + 
kiosek.getTopY() + " : " + kiosek.getWidth() + " : " + kiosek.getHeight());
 
-                       newPosition.setElvys(kiosek);
+                       isOutOf = !(kiosek.equals(kiosek1));
+                       if (isOutOf) {
+                               return;
+                       }
 
+                       newPosition.setElvys(kiosek1);
+
                        if (isSnappedToGrid) {
                                AbsoluteCoordinates monitor = 
newPosition.getMonitor();
                                int newMonitorTopX = monitor.getTopX();
@@ -229,60 +259,80 @@
 
                        } else {
                                AbsoluteCoordinates monitor = 
newPosition.getMonitor().clone();
+                               int oldMonitorTopX = monitor.getTopX();
+                               int oldMonitorTopY = monitor.getTopY();
+                               int oldMonitorWidth = monitor.getWidth();
+                               int oldMonitorHeight = monitor.getHeight();
 
-                               if (deltaTopX > 0) {
-                                       newPosition.setMonitorTopXFromElvys();
+                               if (i != 0) {
+                                       monitor.setHeight(oldMonitorHeight + 
deltaMonitorHeight);
+                                       monitor.setTopX(oldMonitorTopX + 
deltaMonitorTopX);
+                                       monitor.setTopY(oldMonitorTopY + 
deltaMonitorTopY);
+                                       monitor.setWidth(oldMonitorWidth + 
deltaMonitorWidth);
+                                       newPosition.setMonitor(monitor);
+                                       
                                }
 
-                               if (deltaTopX < 0) {
-                                       
newPosition.setMonitorTopXFromElvysFloor();
-                               }
+                               else {
+                                       if (deltaTopX > 0) {
+                                               
newPosition.setMonitorTopXFromElvys();
+                                       }
 
-                               if (deltaTopY > 0) {
-                                       newPosition.setMonitorTopYFromElvys();
-                               }
+                                       if (deltaTopX < 0) {
+                                               
newPosition.setMonitorTopXFromElvysFloor();
+                                       }
 
-                               if (deltaTopY < 0) {
-                                       
newPosition.setMonitorTopYFromElvysFloor();
-                               }
+                                       if (deltaTopY > 0) {
+                                               
newPosition.setMonitorTopYFromElvys();
+                                       }
 
-                               if (deltaWidth > 0) {
-                                       if (deltaTopX < 0) {
-                                               int delta = monitor.getTopX()
-                                                               - 
newPosition.getMonitor().getTopX();
-                                               int width = monitor.getWidth();
-                                               
newPosition.getMonitor().setWidth(width + delta);
-                                       } else {
+                                       if (deltaTopY < 0) {
+                                               
newPosition.setMonitorTopYFromElvysFloor();
+                                       }
+
+                                       if (deltaWidth > 0) {
+                                               if (deltaTopX < 0) {
+                                                       int delta = 
monitor.getTopX()
+                                                                       - 
newPosition.getMonitor().getTopX();
+                                                       int width = 
monitor.getWidth();
+                                                       
newPosition.getMonitor().setWidth(width + delta);
+                                               } else {
+                                                       
newPosition.setMonitorWidthFromElvys();
+                                               }
+                                       }
+
+                                       if (deltaWidth < 0) {
                                                
newPosition.setMonitorWidthFromElvys();
                                        }
-                               }
 
-                               if (deltaWidth < 0) {
-                                       newPosition.setMonitorWidthFromElvys();
-                               }
+                                       if (deltaHeight > 0) {
+                                               if (deltaTopY < 0) {
+                                                       int delta = 
monitor.getTopY()
+                                                                       - 
newPosition.getMonitor().getTopY();
+                                                       int height = 
monitor.getHeight();
+                                                       
newPosition.getMonitor().setHeight(height + delta);
+                                               } else {
+                                                       
newPosition.setMonitorHeightFromElvys();
+                                               }
+                                       }
 
-                               if (deltaHeight > 0) {
-                                       if (deltaTopY < 0) {
-                                               int delta = monitor.getTopY()
-                                                               - 
newPosition.getMonitor().getTopY();
-                                               int height = 
monitor.getHeight();
-                                               
newPosition.getMonitor().setHeight(height + delta);
-                                       } else {
-                                               
newPosition.setMonitorHeightFromElvys();
+                                       if (deltaHeight < 0) {
+                                               
newPosition.setMonitorHeightFromElvysFloor();
                                        }
+                                       
+                                       deltaMonitorTopX = 
newPosition.getMonitor().getTopX() - oldMonitorTopX;
+                                       deltaMonitorTopY = 
newPosition.getMonitor().getTopY() - oldMonitorTopY; 
+                                       deltaMonitorWidth = 
newPosition.getMonitor().getWidth() - oldMonitorWidth;
+                                       deltaMonitorHeight = 
newPosition.getMonitor().getHeight() - oldMonitorHeight;
                                }
 
-                               if (deltaHeight < 0) {
-                                       
newPosition.setMonitorHeightFromElvysFloor();
-                               }
-
                        }
 
                        addPosition(layoutPositions, newPosition, oldPosition, 
designArea,
                                        addType, false);
 
                }
-               setLayoutPositions(layoutPositions);
+               setLayoutPositions(layoutPositions, oldPositions);
        }
 
        /**
@@ -306,6 +356,7 @@
                        int deltaTopX, int deltaTopY, int deltaWidth, int 
deltaHeight,
                        Layout.AddType addType) {
 
+               Positions oldPositions = getLayoutPositions().clone();
                Positions layoutPositions = getLayoutPositions().clone();
                Positions positions = getSelectedPositions();
 
@@ -355,7 +406,7 @@
                        }
 
                }
-               setLayoutPositions(layoutPositions);
+               setLayoutPositions(layoutPositions, oldPositions);
        }
 
        /**
@@ -431,8 +482,8 @@
                                return;
                        }
                }
-               
-               if(isFinalPosition) {
+
+               if (isFinalPosition) {
                        boolean isDesignedCorrectly = 
position.toNoOverlap(addType,
                                        noOverlapPosition);
                        if (!isDesignedCorrectly) {
@@ -917,22 +968,26 @@
 
        /**
         * Decides whatever this layout contains position with the given id
-        * @param id id of position
+        * 
+        * @param id
+        *            id of position
         * @param positions
         * @return whatever position with this id is in this layout
         */
        private boolean contains(int id, Positions positions) {
                for (int i = 0; i < positions.size(); ++i) {
-                       if(positions.get(i).getId() == id) {
+                       if (positions.get(i).getId() == id) {
                                return true;
                        }
                }
                return false;
        }
-       
+
        /**
-        * Selects given positions 
-        * @param positionsToSelect positions to select
+        * Selects given positions
+        * 
+        * @param positionsToSelect
+        *            positions to select
         */
        public void selectPositions(Positions positionsToSelect) {
                for (int i = 0; i < positions.size(); ++i) {
@@ -1065,6 +1120,23 @@
        }
 
        /**
+        * Sets layoutPositions and checks if there is overlap among them
+        * 
+        * @param layoutPositions
+        *            the layoutPositions to set
+        * @param oldPositions
+        *            the old layout positions to set
+        */
+       public void setLayoutPositions(Positions layoutPositions,
+                       Positions oldPositions) {
+               if (layoutPositions.isOverlap()) {
+                       this.positions = oldPositions;
+               } else {
+                       this.positions = layoutPositions;
+               }
+       }
+
+       /**
         * @return the layoutPositions
         */
        public Positions getLayoutPositions() {

Modified: trunk/layouteditor/LayoutDesigner/src/applet/MovingObject.java
===================================================================
--- trunk/layouteditor/LayoutDesigner/src/applet/MovingObject.java      
2010-01-25 23:19:29 UTC (rev 1658)
+++ trunk/layouteditor/LayoutDesigner/src/applet/MovingObject.java      
2010-01-27 21:07:57 UTC (rev 1659)
@@ -48,7 +48,7 @@
        private int monitorX2;
        private int monitorY1;
        private int monitorY2;
-
+       
        private ActionType action;              /** actual action */
        private DesignArea designArea;  /** design area where this position is 
designed */
        private PopupMenu popupMenu;    /** popup menu */
@@ -343,20 +343,42 @@
                        return;
                }
 
+               Layout.AddType addType;
+               if (action == ActionType.MOVE) {
+                       addType = Layout.AddType.MOVE;
+               } else {
+                       addType = Layout.AddType.RESIZE;
+               }
+
+               int WIDTH = designArea.getMyLayout().getScreenResolution()
+                               .getMonitorWidth();
+               int HEIGHT = designArea.getMyLayout().getScreenResolution()
+                               .getMonitorHeight();
+
+               
+               
                Positions positions = 
designArea.getMyLayout().getLayoutPositions();
                Positions newPositions = positions.clone();
 
                int monitorDeltaX = monitorX2 - monitorDx;
                int monitorDeltaY = monitorY2 - monitorDy;
+               
+               System.out.println(monitorDeltaX + " : " + monitorDeltaY);
 
                monitorDeltaX = positions.changeDeltaXtoNotBeOutOfMonitor(
                                monitorDeltaX, designArea);
                monitorDeltaY = positions.changeDeltaYtoNotBeOutOfMonitor(
                                monitorDeltaY, designArea);
-
+               
+               
+               System.out.println(monitorDeltaX + " : " + monitorDeltaY);
+               
+               
                for (int i = 0; i < positions.size(); ++i) {
 
+                       
                        Position position = positions.get(i);
+                       AbsoluteCoordinates monitor = 
position.getMonitor().clone();
                        Position newPosition = position.clone();
 
                        int oldTopX = position.getMonitor().getTopX();
@@ -379,26 +401,33 @@
                                        newWidth = grid.getX();
                                        newHeight = grid.getY();
                                }
+       
+                               
+                               monitor = new AbsoluteCoordinates(newTopX, 
newTopY, newWidth, newHeight);
+                               AbsoluteCoordinates monitor1 = newPosition
+                               
.changeCoordinatesToNotBeOutOfDesignArea(newTopX,
+                                               newTopY, newWidth, newHeight, 
WIDTH,
+                                               HEIGHT, addType, false, 
designArea);
+                               
+                               newPosition.setMonitor(monitor1);
+                               newPosition.setElvysFromMonitor(monitor1, 
designArea.isSnapToGridEnabled(), action);
 
-                               newPosition.setMonitor(new 
AbsoluteCoordinates(newTopX,
-                                               newTopY, newWidth, newHeight));
-                               newPosition.setElvysFromMonitor(new 
AbsoluteCoordinates(newTopX,
-                                               newTopY, newWidth, newHeight), 
designArea.isSnapToGridEnabled(), action);
-
                                MovingObject object = 
designArea.getObjects().get(i);
 
-                               object.monitorTopX = newTopX;
-                               object.monitorTopY = newTopY;
-                               object.monitorWidth = newWidth;
-                               object.monitorHeight = newHeight;
+                               object.monitorTopX = monitor1.getTopX();
+                               object.monitorTopY = monitor1.getTopY();
+                               object.monitorWidth = monitor1.getWidth();
+                               object.monitorHeight = monitor1.getHeight();
 
-                               object.setLocation(newTopX, newTopY);
-                               object.setSize(newWidth, newHeight);
+                               object.setLocation(monitor1.getTopX(), 
monitor1.getTopY());
+                               object.setSize(monitor1.getWidth(), 
monitor1.getHeight());
                                object.setPosition(newPosition);
 
+                               
                        }
 
                        newPositions.addPosition(newPosition);
+                       
                }
 
                designArea.getMyLayout().setLayoutPositions(newPositions);
@@ -670,7 +699,6 @@
                                                .getPositions();
 
                                designArea.setObjects(new MovingObjects());
-
                                for (int i = 0; i < positions.size(); ++i) {
                                        Position actualPosition = 
positions.get(i);
 

Modified: trunk/layouteditor/LayoutDesigner/src/applet/Position.java
===================================================================
--- trunk/layouteditor/LayoutDesigner/src/applet/Position.java  2010-01-25 
23:19:29 UTC (rev 1658)
+++ trunk/layouteditor/LayoutDesigner/src/applet/Position.java  2010-01-27 
21:07:57 UTC (rev 1659)
@@ -1105,6 +1105,7 @@
                        int topX, int topY, int width, int height, int WIDTH, 
int HEIGHT,
                        Layout.AddType addType, boolean isElvys, DesignArea 
designArea) {
 
+               isSnappedToGrid = designArea.isSnapToGridEnabled();
                if (isSnappedToGrid) {
 
                        Grid grid = new Grid(WIDTH, HEIGHT);

Modified: trunk/layouteditor/LayoutDesigner/src/applet/Positions.java
===================================================================
--- trunk/layouteditor/LayoutDesigner/src/applet/Positions.java 2010-01-25 
23:19:29 UTC (rev 1658)
+++ trunk/layouteditor/LayoutDesigner/src/applet/Positions.java 2010-01-27 
21:07:57 UTC (rev 1659)
@@ -82,6 +82,22 @@
 
 
        /**
+        * Gets only selected positions
+        * @return selected positions
+        */
+       private Positions getSelectedPositions() {
+               Positions newPositions = new Positions();
+               Vector<Position> newVectorPositions = new Vector<Position>();
+               for(int i = 0; i < size(); ++i) {
+                       if(positions.get(i).isSelected()) {
+                               
newVectorPositions.add(positions.get(i).clone());
+                       }
+               }
+               newPositions.setPositions(newVectorPositions);
+               newPositions.setLayout(this.getLayout());
+               return newPositions;
+       }
+       /**
         * Returns clone of this instance
         */
        public Positions clone() {
@@ -416,17 +432,18 @@
         */
        public int changeDeltaXtoNotBeOutOfMonitor(int dx, DesignArea 
designArea) {
 
-               int oldTopX = this.getMonitorTopX();
-               int topX = this.getMonitorTopX() + dx;
+               int oldTopX = this.getSelectedPositions().getMonitorTopX();
+               int topX = this.getSelectedPositions().getMonitorTopX() + dx;
 
-               int WIDTH = designArea.getMyLayout()
-                               .getScreenResolution().getMonitorWidth();
 
+               int WIDTH = 
designArea.getMyLayout().getScreenResolution().getMonitorWidth();
+
+               int oldWidth = this.getSelectedPositions().getMonitorWidth();
                if (topX < 0) {
                        int newTopX = 0;
                        return newTopX - oldTopX;
-               } else if (topX + this.getMonitorWidth() > WIDTH) {
-                       int newTopX = WIDTH - this.getMonitorWidth();
+               } else if (topX + oldWidth > WIDTH) {
+                       int newTopX = WIDTH - oldWidth;
                        return newTopX - oldTopX;
                } else {
                        return dx;
@@ -441,17 +458,17 @@
         */
        public int changeDeltaYtoNotBeOutOfMonitor(int dy, DesignArea 
designArea) {
 
-               int oldTopY = this.getMonitorTopY();
-               int topY = this.getMonitorTopY() + dy;
+               int oldTopY = this.getSelectedPositions().getMonitorTopY();
+               int oldHeight = this.getSelectedPositions().getMonitorHeight();
+               int topY = this.getSelectedPositions().getMonitorTopY() + dy;
 
-               int HEIGHT = designArea.getMyLayout()
-                               .getScreenResolution().getMonitorHeight();
+               int HEIGHT = 
designArea.getMyLayout().getScreenResolution().getMonitorHeight();
 
                if (topY < 0) {
                        int newTopY = 0;
                        return newTopY - oldTopY;
-               } else if (topY + this.getMonitorHeight() > HEIGHT) {
-                       int newTopY = HEIGHT - this.getMonitorHeight();
+               } else if (topY + oldHeight > HEIGHT) {
+                       int newTopY = HEIGHT - oldHeight;
                        return newTopY - oldTopY;
                } else {
                        return dy;

Modified: trunk/layouteditor/LayoutDesigner/src/applet/PropertiesTable.java
===================================================================
--- trunk/layouteditor/LayoutDesigner/src/applet/PropertiesTable.java   
2010-01-25 23:19:29 UTC (rev 1658)
+++ trunk/layouteditor/LayoutDesigner/src/applet/PropertiesTable.java   
2010-01-27 21:07:57 UTC (rev 1659)
@@ -221,6 +221,10 @@
                                heightField.setEditable(false);
 
                        } else {
+                               topXField.setEditable(true);
+                               topYField.setEditable(true);
+                               widthField.setEditable(true);
+                               heightField.setEditable(true);
                                widthField.setValue(new 
Integer(selectedPositions
                                                .getElvysWidth()));
                                newWidth = selectedPositions.getElvysWidth();
@@ -483,18 +487,18 @@
                        textField.setValue(textField.getValue());
                } else
                        try {
-                               oldTopX = 
Integer.valueOf(topXField.getValue().toString());
-                               oldTopY = 
Integer.valueOf(topYField.getValue().toString());
                                if(widthField.isEditable()) {
+                                       oldTopX = 
Integer.valueOf(topXField.getValue().toString());
+                                       oldTopY = 
Integer.valueOf(topYField.getValue().toString());     
                                        oldWidth = 
Integer.valueOf(widthField.getValue().toString());
                                        oldHeight = 
Integer.valueOf(heightField.getValue().toString());
                                }
 
                                textField.commitEdit();
 
-                               newTopX = 
Integer.valueOf(topXField.getValue().toString());
-                               newTopY = 
Integer.valueOf(topYField.getValue().toString());
                                if(widthField.isEditable()) {
+                                       newTopX = 
Integer.valueOf(topXField.getValue().toString());
+                                       newTopY = 
Integer.valueOf(topYField.getValue().toString());     
                                        newWidth = 
Integer.valueOf(widthField.getValue().toString());
                                        newHeight = 
Integer.valueOf(heightField.getValue().toString());
                                }


Other related posts:

  • » [elvystrac] r1659 - - elvys