Changeset 1142 for trunk


Ignore:
Timestamp:
09/18/18 11:57:32 (6 years ago)
Author:
bln4
Message:

Used Eclipse refactoring to encapsulate Point.X and Point.Y

Location:
trunk/src/org
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/apollo/ApolloGestureActions.java

    r1098 r1142  
    170170                                for (Item i : current.getItems()) {
    171171                                        Point pos = i.getPosition();
    172                                         pos.x %= windowSize.width;
    173                                         pos.y %= windowSize.height;
     172                                        pos.setX(pos.getX() % windowSize.width);
     173                                        pos.setY(pos.getY() % windowSize.height);
    174174                                        i.setPosition(pos);
    175175                                }
  • trunk/src/org/apollo/audio/structure/AudioStructureModel.java

    r1102 r1142  
    347347                                                if (localFileName != null) {
    348348                                                        tracks.put(localFileName, new TrackModelData(
    349                                                                         initiationTime, -1, name, result.position.y)); // pass -1 for running time to signify that must be read from audio file
     349                                                                        initiationTime, -1, name, result.position.getY())); // pass -1 for running time to signify that must be read from audio file
    350350                                                }
    351351                                               
     
    389389                                                        if (virtualFilename != null) {
    390390                                                                linkedTracks.put(virtualFilename, new LinkedTrackModelData(
    391                                                                                 initiationTime, result.explink, name, result.position.y)); // pass -1 for running time to signify that must be read from audio file
     391                                                                                initiationTime, result.explink, name, result.position.getY())); // pass -1 for running time to signify that must be read from audio file
    392392                                                        }
    393393                                               
  • trunk/src/org/apollo/gui/FrameLayoutDaemon.java

    r1102 r1142  
    562562                                                        int offsetX = width / 2;
    563563                                                        int offsetY = freespaceTrackToFormat.getHeight() / 2;
    564                                                         freespaceTrackToFormat.setPosition(containerPoint.x - offsetX, containerPoint.y - offsetY);
     564                                                        freespaceTrackToFormat.setPosition(containerPoint.getX() - offsetX, containerPoint.getY() - offsetY);
    565565                                                        StandardGestureActions.resetOffset();
    566566                                                }
  • trunk/src/org/apollo/io/SampledAudioFileImporter.java

    r1102 r1142  
    2525                                f,
    2626                                DisplayController.getCurrentFrame(),
    27                                 location.x,
    28                                 location.y);
     27                                location.getX(),
     28                                location.getY());
    2929               
    3030                // Add the sampled track widget to the current frame
  • trunk/src/org/apollo/items/EmulatedTextItem.java

    r1125 r1142  
    9797                Point p = EcosystemManager.getInputManager().getCursorPosition();
    9898               
    99                 return isOnEmulatedText(p.x, p.y);
     99                return isOnEmulatedText(p.getX(), p.getY());
    100100        }
    101101       
     
    134134
    135135                // If so and the event really comes from its parent ...
    136                 if (isOnEmulatedText(p.x, p.y)) {
     136                if (isOnEmulatedText(p.getX(), p.getY())) {
    137137                       
    138138                        int yOffset = -6;
     
    154154                        {
    155155                                // Insert the text according to the current mouse position
    156                                 Point newMouse = emulatedSource.insertChar(e.getKeyChar(), p.x, p.y);
     156                                Point newMouse = emulatedSource.insertChar(e.getKeyChar(), p.getX(), p.getY());
    157157                               
    158158                                List<String> lines = emulatedSource.getTextList();
     
    166166                                // Move "cursored mouse"
    167167                                if (newMouse != null) {
    168                                         EcosystemManager.getInputManager().setCursorPosition(new Point((int) newMouse.x, (int) newMouse.y + yOffset));
     168                                        EcosystemManager.getInputManager().setCursorPosition(new Point((int) newMouse.getX(), (int) newMouse.getY() + yOffset));
    169169                                }
    170170                        }
     
    193193
    194194                // If so and the event really comes from its parent ...
    195                 if (isOnEmulatedText(p.x, p.y)) {
     195                if (isOnEmulatedText(p.getX(), p.getY())) {
    196196                       
    197197                        int yOffset = -6;
     
    207207                               
    208208                                if (newMouse != null) {
    209                                         EcosystemManager.getInputManager().setCursorPosition(new Point((int) newMouse.x, (int) newMouse.y + yOffset));
     209                                        EcosystemManager.getInputManager().setCursorPosition(new Point((int) newMouse.getX(), (int) newMouse.getY() + yOffset));
    210210                                }
    211211
     
    241241
    242242                // If so and the event really comes from its parent ...
    243                 if (isOnEmulatedText(p.x, p.y)) {
     243                if (isOnEmulatedText(p.getX(), p.getY())) {
    244244                       
    245245                        String toMoveIntoFreespace = null;
     
    267267                                if (target != null) {
    268268                                        Text selectionCopy = new Text(target.getNextItemID(), toMoveIntoFreespace);
    269                                         selectionCopy.setPosition(p.x, p.y);
     269                                        selectionCopy.setPosition(p.getX(), p.getY());
    270270                                        selectionCopy.setSize(emulatedSource.getSize());
    271271                                        StandardGestureActions.pickup(selectionCopy);
     
    290290
    291291                // If so and the event really comes from its parent ...
    292                 if (isOnEmulatedText(p.x, p.y)) {
     292                if (isOnEmulatedText(p.getX(), p.getY())) {
    293293                       
    294294                        emulatedSource.clearSelection();
    295                         emulatedSource.setSelectionStart(p.x, p.y, e.getButton());
     295                        emulatedSource.setSelectionStart(p.getX(), p.getY(), e.getButton());
    296296
    297297                        repaint();
     
    313313
    314314                // If so and the event really comes from its parent ...
    315                 if (isOnEmulatedText(p.x, p.y)) {
     315                if (isOnEmulatedText(p.getX(), p.getY())) {
    316316
    317317                        EcosystemManager.getGraphicsManager().setCursor(new Cursor(Cursor.CursorType.TEXT));
    318318                       
    319                         emulatedSource.setSelectionEnd(p.x, p.y);
     319                        emulatedSource.setSelectionEnd(p.getX(), p.getY());
    320320                        repaint();
    321321                       
  • trunk/src/org/apollo/widgets/LinkedTrack.java

    r1102 r1142  
    18141814                                if (y < 0) {
    18151815                                        y = LinkedTrack.this.getY() + LinkedTrack.this.getHeight() + 2;
    1816                                         animationSource.getTopLeft().y = y - 2;
     1816                                        animationSource.getTopLeft().setY(y - 2);
    18171817                                }
    18181818
  • trunk/src/org/apollo/widgets/SampledTrack.java

    r1102 r1142  
    12741274                                        ((Graphics2D)g).setStroke(EditableSampledTrackGraphView.GRAPH_BAR_STROKE);
    12751275                                        g.drawLine(
    1276                                                         containerPoint.x + me.getX(),
    1277                                                         containerPoint.y,
    1278                                                         containerPoint.x + me.getX(),
    1279                                                         containerPoint.y + me.getComponent().getHeight());
     1276                                                        containerPoint.getX() + me.getX(),
     1277                                                        containerPoint.getY(),
     1278                                                        containerPoint.getX() + me.getX(),
     1279                                                        containerPoint.getY() + me.getComponent().getHeight());
    12801280                                       
    12811281                                        DisplayController.invalidateArea(new AxisAlignedBoxBounds(
    1282                                                         containerPoint.x + me.getX(),
    1283                                                         containerPoint.y,
     1282                                                        containerPoint.getX() + me.getX(),
     1283                                                        containerPoint.getY(),
    12841284                                                        1,
    1285                                                         containerPoint.y + me.getComponent().getHeight() + 1));
     1285                                                        containerPoint.getY() + me.getComponent().getHeight() + 1));
    12861286                       
    12871287                                        // Restore clip
  • trunk/src/org/expeditee/actions/Debug.java

    r1134 r1142  
    1919package org.expeditee.actions;
    2020
    21 import java.awt.AWTException;
     21import java.awt.Graphics;
    2222import java.awt.Robot;
    2323import java.util.List;
    2424import java.util.concurrent.TimeUnit;
     25
     26import javax.swing.JFrame;
     27import javax.swing.JPanel;
    2528
    2629import org.expeditee.gio.swing.SwingGraphicsManager;
     
    6871        }
    6972       
     73        @SuppressWarnings("serial")
     74        public static void GraphicsTranslateTest() {
     75                final JFrame f = new JFrame();
     76                f.setContentPane(new JPanel() {
     77                        public void paintComponent(Graphics g) {
     78                                final int pos = 10;
     79                                final int size = 100;
     80                                int translate = 10;
     81                                for(int i = 0; i < 5; i++) {
     82                                        g.translate(translate, translate);
     83                                        g.drawRect(pos, pos, size, size);
     84                                        g.translate(-translate, -translate);
     85                                }
     86                        }
     87                });
     88                f.setSize(400, 400);
     89                f.setVisible(true);
     90        }
     91       
    7092        public static void RobotTest() {
    7193                try {
  • trunk/src/org/expeditee/actions/Misc.java

    r1111 r1142  
    997997                                if (text.isFloating()) {
    998998                                        Point cursorPos = EcosystemManager.getInputManager().getCursorPosition();
    999                                         text.setPosition(cursorPos.x, cursorPos.y);
     999                                        text.setPosition(cursorPos.getX(), cursorPos.getY());
    10001000                                        StandardGestureActions.resetOffset();
    10011001                                } else {
     
    10841084
    10851085                Point cursorPos = DisplayController.getMousePosition();
    1086                 float curX = cursorPos.x;
    1087                 float curY = cursorPos.y;
     1086                float curX = cursorPos.getX();
     1087                float curY = cursorPos.getY();
    10881088
    10891089                Collection<Item> newItems = new LinkedList<Item>();
  • trunk/src/org/expeditee/actions/Simple.java

    r1102 r1142  
    11291129                                        for (Text text : targetFrame.getTextItems()) {
    11301130                                                Point startPoint = text.getPosition();
    1131                                                 if (Math.abs(startPoint.y - endPoint.y) < 10
    1132                                                                 && Math.abs(startPoint.x - endPoint.x) < 20) {
     1131                                                if (Math.abs(startPoint.getY() - endPoint.getY()) < 10
     1132                                                                && Math.abs(startPoint.getX() - endPoint.getX()) < 20) {
    11331133                                                        found = true;
    11341134                                                        valueItem = text;
     
    13801380                                                for (Text text : targetFrame.getTextItems()) {
    13811381                                                        Point startPoint = text.getPosition();
    1382                                                         if (Math.abs(startPoint.y - endPoint.y) < 10
    1383                                                                         && Math.abs(startPoint.x - endPoint.x) < 20) {
     1382                                                        if (Math.abs(startPoint.getY() - endPoint.getY()) < 10
     1383                                                                        && Math.abs(startPoint.getX() - endPoint.getX()) < 20) {
    13841384                                                                found = true;
    13851385                                                                valueItem = text;
     
    15911591                                                Point pos = ((Item) context.getPointers().getVariable(
    15921592                                                                tokens[1]).getValue()).getPosition();
    1593                                                 Integer x = pos.x;
    1594                                                 Integer y = pos.y;
     1593                                                Integer x = pos.getX();
     1594                                                Integer y = pos.getY();
    15951595                                                context.getPrimitives()
    15961596                                                                .setValue(tokens[2], new SInteger(x));
  • trunk/src/org/expeditee/agents/Sort.java

    r1102 r1142  
    6464                for (int i = 0; i < positions.size(); i++)
    6565                        textItems.get(i)
    66                                         .setPosition(positions.get(i).x, positions.get(i).y);
     66                                        .setPosition(positions.get(i).getX(), positions.get(i).getY());
    6767
    6868                // items will need to be resorted after this
  • trunk/src/org/expeditee/agents/SwitchyardTree.java

    r1102 r1142  
    5050                                                                Text itemCopy = childItem.copy();
    5151                                                                // add to the right of parent item
    52                                                                 lastItemEnd.set(lastItemEnd.x + 20, lastItemEnd.y);
    53                                                                 itemCopy.setPosition(lastItemEnd.x, lastItemEnd.y);
     52                                                                lastItemEnd.set(lastItemEnd.getX() + 20, lastItemEnd.getY());
     53                                                                itemCopy.setPosition(lastItemEnd.getX(), lastItemEnd.getY());
    5454                                                                lastItemEnd = itemCopy
    5555                                                                                .getParagraphEndPosition();
  • trunk/src/org/expeditee/agents/mail/MailSession.java

    r1102 r1142  
    479479                                        if (newItem != null) {
    480480                                                mailItems.add(newItem);
    481                                                 point.y += newItem.getBoundsHeight();
     481                                                point.setY(point.getY() + newItem.getBoundsHeight());
    482482                                                messagesRead++;
    483483                                        } else {
  • trunk/src/org/expeditee/core/Line.java

    r1097 r1142  
    5555        public int deltaX()
    5656        {
    57                 return _p2.x - _p1.x;
     57                return _p2.getX() - _p1.getX();
    5858        }
    5959       
     
    6161        public int deltaY()
    6262        {
    63                 return _p2.y - _p1.y;
     63                return _p2.getY() - _p1.getY();
    6464        }
    6565       
     
    8989                } else {
    9090                        double u = ((double) numerator) / denominator;
    91                         return u >= 0 && u <= 1 && this.contains(new Point((int) (q.x + u * s.x), (int) (q.y + u * s.y)), error);
     91                        return u >= 0 && u <= 1 && this.contains(new Point((int) (q.getX() + u * s.getX()), (int) (q.getY() + u * s.getY())), error);
    9292                }
    9393        }
     
    9898        private int crossLength(Point a, Point b)
    9999        {
    100                 return a.x * b.y - a.y * b.x;
     100                return a.getX() * b.getY() - a.getY() * b.getX();
    101101        }
    102102       
     
    174174                } else {
    175175                        double scaleFactor = projectionLength / lineLength;
    176                         return _p1.clone().add((_p2.x - _p1.x) * scaleFactor, (_p2.y - _p1.y) * scaleFactor);
     176                        return _p1.clone().add((_p2.getX() - _p1.getX()) * scaleFactor, (_p2.getY() - _p1.getY()) * scaleFactor);
    177177                }
    178178        }
  • trunk/src/org/expeditee/core/Point.java

    r1097 r1142  
    22
    33/**
    4  * Represents a (x,y)-coordinate in 2-dimensional space.
    5  * Coordinates are integral.
     4 * Represents a (x,y)-coordinate in 2-dimensional space. Coordinates are
     5 * integral.
    66 *
    77 * @author cts16
    88 */
    99public class Point {
    10        
     10
    1111        /** The origin of the coordinate system. */
    1212        public static final Point ORIGIN = new Point(0, 0);
    13        
     13
    1414        /** The x-coordinate of this point. */
    15         public int x;
     15        private int x;
    1616        /** The y-coordinate of this point. */
    17         public int y;
    18        
     17        private int y;
     18
    1919        /** Default constructor creates a point at the origin. */
    20         public Point()
    21         {
     20        public Point() {
    2221                this(0, 0);
    2322        }
    24        
     23
    2524        /** Standard constructor. */
    26         public Point(int x, int y)
    27         {
     25        public Point(int x, int y) {
    2826                set(x, y);
    2927        }
    30        
     28
    3129        /** Convenience constructor automatically casts floats to ints. */
    32         public Point(float x, float y)
    33         {
     30        public Point(float x, float y) {
    3431                this((int) x, (int) y);
    3532        }
    36        
     33
    3734        /** Copy constructor. */
    38         public Point(Point other)
    39         {
     35        public Point(Point other) {
    4036                this();
    4137                set(other);
    4238        }
    43        
     39
    4440        /** Sets the position of the point. */
    45         public Point set(int x, int y)
    46         {
    47                 this.x = x;
    48                 this.y = y;
    49                 return this;
    50         }
    51        
    52         /** Sets the position of this point to be the same as the given point.
    53             If p is null, no change is made. */
    54         public Point set(Point p)
    55         {
    56                 if (p != null) set(p.x, p.y);
    57                 return this;
    58         }
    59        
     41        public Point set(int x, int y) {
     42                this.setX(x);
     43                this.setY(y);
     44                return this;
     45        }
     46
     47        /**
     48         * Sets the position of this point to be the same as the given point. If p is
     49         * null, no change is made.
     50         */
     51        public Point set(Point p) {
     52                if (p != null)
     53                        set(p.getX(), p.getY());
     54                return this;
     55        }
     56
    6057        /** Moves the point by the given amount in each dimension. */
    61         public Point add(int x, int y)
    62         {
    63                 this.x += x;
    64                 this.y += y;
    65                 return this;
    66         }
    67        
    68         /** Moves the point by the given amount in each dimension.
    69             Doubles are automatically cast to ints. */
    70         public Point add(double x, double y)
    71         {
     58        public Point add(int x, int y) {
     59                this.setX(this.getX() + x);
     60                this.setY(this.getY() + y);
     61                return this;
     62        }
     63
     64        /**
     65         * Moves the point by the given amount in each dimension. Doubles are
     66         * automatically cast to ints.
     67         */
     68        public Point add(double x, double y) {
    7269                return add((int) x, (int) y);
    7370        }
    74        
    75         /** Adds the coordinates of the given point to this point's coordinates
    76             (treating points as vectors). */
    77         public Point add(Point p)
    78         {
    79                  if (p != null) add(p.x, p.y);
    80                  return this;
    81         }
    82        
     71
     72        /**
     73         * Adds the coordinates of the given point to this point's coordinates (treating
     74         * points as vectors).
     75         */
     76        public Point add(Point p) {
     77                if (p != null)
     78                        add(p.getX(), p.getY());
     79                return this;
     80        }
     81
    8382        /**
    8483         * Rotates this point around another point.
    8584         *
    8685         * @param angle
    87          *              The angle to rotate through (clockwise, in radians).
     86         *            The angle to rotate through (clockwise, in radians).
    8887         *
    8988         * @param x
    90          *              The x-coordinate of the centre of rotation.
     89         *            The x-coordinate of the centre of rotation.
    9190         *
    9291         * @param y
    93          *              The y-coordinate of the centre of rotation.
    94          */
    95         public Point rotate(double angle, int x, int y)
    96         {
     92         *            The y-coordinate of the centre of rotation.
     93         */
     94        public Point rotate(double angle, int x, int y) {
    9795                // Find the distance from this point to the centre of rotation
    9896                // (should stay the same during rotation)
    99                 double length = Point.distanceBetween(x, y, this.x, this.y);
    100                
     97                double length = Point.distanceBetween(x, y, this.getX(), this.getY());
     98
    10199                // Find the starting elevation angle of this point relative to
    102100                // the centre of rotation.
    103                 double startingAngle = Math.atan2(this.y - y, this.x - x);
    104                
    105                 // Increase/decrease the elevation angle by the given amount 
     101                double startingAngle = Math.atan2(this.getY() - y, this.getX() - x);
     102
     103                // Increase/decrease the elevation angle by the given amount
    106104                double finalAngle = startingAngle + angle;
    107                
     105
    108106                // Calculate the point at the same distance from the centre of rotation
    109107                // elevated at the new angle.
    110                 this.x = (int) (x + length * Math.cos(finalAngle));
    111                 this.y = (int) (y + length * Math.sin(finalAngle));
    112                
    113                 return this;
    114         }
    115        
     108                this.setX((int) (x + length * Math.cos(finalAngle)));
     109                this.setY((int) (y + length * Math.sin(finalAngle)));
     110
     111                return this;
     112        }
     113
    116114        /**
    117115         * Rotates this point around another point.
    118116         *
    119117         * @param angle
    120          *              The angle to rotate through (clockwise, in radians).
     118         *            The angle to rotate through (clockwise, in radians).
    121119         *
    122120         * @param cor
    123          *              The centre of rotation.
    124          */
    125         public Point rotate(double angle, Point cor)
    126         {
    127                 if (cor != null) rotate(angle, cor.x, cor.y);
    128                 return this;
    129         }
    130        
     121         *            The centre of rotation.
     122         */
     123        public Point rotate(double angle, Point cor) {
     124                if (cor != null)
     125                        rotate(angle, cor.getX(), cor.getY());
     126                return this;
     127        }
     128
    131129        /** Gets the distance from this point to another point. */
    132         public double getDistanceTo(Point other)
    133         {
     130        public double getDistanceTo(Point other) {
    134131                return distanceBetween(this, other);
    135132        }
    136        
     133
    137134        /** Gets the distance between two points. */
    138         public static double distanceBetween(Point p1, Point p2)
    139         {
    140                 if (p1 == null || p2 == null) return 0.0;
    141                
    142                 return distanceBetween(p1.x, p1.y, p2.x, p2.y);
     135        public static double distanceBetween(Point p1, Point p2) {
     136                if (p1 == null || p2 == null)
     137                        return 0.0;
     138
     139                return distanceBetween(p1.getX(), p1.getY(), p2.getX(), p2.getY());
    143140        }
    144141
    145142        /** Gets the distance between two points specified by their coordinates. */
    146         public static double distanceBetween(int x1, int y1, int x2, int y2)
    147         {
     143        public static double distanceBetween(int x1, int y1, int x2, int y2) {
    148144                double x = x1 - x2;
    149145                double y = y1 - y2;
    150146                return Math.sqrt(x * x + y * y);
    151147        }
    152        
     148
    153149        @Override
    154         public boolean equals(Object other)
    155         {
     150        public boolean equals(Object other) {
    156151                if (other instanceof Point) {
    157152                        Point p = (Point) other;
    158                         return this.x == p.x && this.y == p.y;
     153                        return this.getX() == p.getX() && this.getY() == p.getY();
    159154                }
    160155                return false;
     
    162157
    163158        /** Gets the x-coordinate of this point. */
    164         public int getX()
    165         {
     159        public int getX() {
    166160                return x;
    167161        }
    168        
     162
    169163        /** Gets the y-coordinate of this point. */
    170         public int getY()
    171         {
     164        public int getY() {
    172165                return y;
    173166        }
    174        
     167
    175168        @Override
    176         public Point clone()
    177         {
     169        public Point clone() {
    178170                return new Point(this);
    179171        }
    180        
    181         /** Gets a point representing the difference between the two given points
    182             (returned point should be treated as a vector). */
    183         public static Point difference(Point p1, Point p2)
    184         {
    185                 if (p1 == null || p2 == null) return null;
    186                 return new Point(p1.x - p2.x, p1.y - p2.y);
    187         }
    188        
     172
     173        /**
     174         * Gets a point representing the difference between the two given points
     175         * (returned point should be treated as a vector).
     176         */
     177        public static Point difference(Point p1, Point p2) {
     178                if (p1 == null || p2 == null)
     179                        return null;
     180                return new Point(p1.getX() - p2.getX(), p1.getY() - p2.getY());
     181        }
     182
    189183        /** Calculates the dot-product between two lines that share a common point. */
    190         public static double dotProduct(Point commonPoint, Point lineEnd1, Point lineEnd2)
    191         {
    192                 if (commonPoint == null || lineEnd1 == null || lineEnd2 == null) return 0.0;
    193                
    194                 Point p1 = new Point(lineEnd1.x - commonPoint.x, lineEnd1.y - commonPoint.y);
    195                 Point p2 = new Point(lineEnd2.x - commonPoint.x, lineEnd2.y - commonPoint.y);
    196                 return p1.x * p2.x + p1.y * p2.y;
    197         }
    198        
     184        public static double dotProduct(Point commonPoint, Point lineEnd1, Point lineEnd2) {
     185                if (commonPoint == null || lineEnd1 == null || lineEnd2 == null)
     186                        return 0.0;
     187
     188                Point p1 = new Point(lineEnd1.getX() - commonPoint.getX(), lineEnd1.getY() - commonPoint.getY());
     189                Point p2 = new Point(lineEnd2.getX() - commonPoint.getX(), lineEnd2.getY() - commonPoint.getY());
     190                return p1.getX() * p2.getX() + p1.getY() * p2.getY();
     191        }
     192
    199193        @Override
    200         public String toString()
    201         {
    202                 return "(" + x + ", " + y + ")";
     194        public String toString() {
     195                return "(" + getX() + ", " + getY() + ")";
     196        }
     197
     198        public void setY(int y) {
     199                this.y = y;
     200        }
     201
     202        public void setX(int x) {
     203                this.x = x;
    203204        }
    204205}
  • trunk/src/org/expeditee/core/bounds/AxisAlignedBoxBounds.java

    r1097 r1142  
    107107        public int getCentreX()
    108108        {
    109                 return _topLeft.x + _size.width / 2;
     109                return _topLeft.getX() + _size.width / 2;
    110110        }
    111111
     
    113113        public int getCentreY()
    114114        {
    115                 return _topLeft.y + _size.height / 2;
     115                return _topLeft.getY() + _size.height / 2;
    116116        }
    117117
     
    167167        public boolean contains(int x, int y)
    168168        {
    169                 return (x >= _topLeft.x &&
    170                                 x < (_topLeft.x + _size.width) &&
    171                                 y >= _topLeft.y &&
    172                                 y < (_topLeft.y + _size.height));
     169                return (x >= _topLeft.getX() &&
     170                                x < (_topLeft.getX() + _size.width) &&
     171                                y >= _topLeft.getY() &&
     172                                y < (_topLeft.getY() + _size.height));
    173173        }
    174174
     
    176176        public int getMaxX()
    177177        {
    178                 return _topLeft.x + _size.width - 1;
     178                return _topLeft.getX() + _size.width - 1;
    179179        }
    180180
     
    182182        public int getMinX()
    183183        {
    184                 return _topLeft.x;
     184                return _topLeft.getX();
    185185        }
    186186
     
    188188        public int getMaxY()
    189189        {
    190                 return _topLeft.y + _size.height - 1;
     190                return _topLeft.getY() + _size.height - 1;
    191191        }
    192192
     
    194194        public int getMinY()
    195195        {
    196                 return _topLeft.y;
     196                return _topLeft.getY();
    197197        }
    198198       
  • trunk/src/org/expeditee/core/bounds/Bounds.java

    r1097 r1142  
    2626        public boolean contains(Point p)
    2727        {
    28                 return contains(p.x, p.y);
     28                return contains(p.getX(), p.getY());
    2929        }
    3030       
  • trunk/src/org/expeditee/core/bounds/EllipticalBounds.java

    r1097 r1142  
    7676               
    7777                // Get the position of the given coordinates with respect to the ellipse centre
    78                 Point pRel = new Point(x - _centre.x, y - _centre.y);
     78                Point pRel = new Point(x - _centre.getX(), y - _centre.getY());
    7979               
    8080                // x^2 / r_x^2 + y^2 / r_y^2 must be <= 1
    8181                // (using diameters instead of radii hence the 4.0f value)
    82                 float xNorm = (((float) pRel.x) * pRel.x) / (((float) _diameters.width) * _diameters.width);
    83                 float yNorm = (((float) pRel.y) * pRel.y) / (((float) _diameters.height) * _diameters.height);
     82                float xNorm = (((float) pRel.getX()) * pRel.getX()) / (((float) _diameters.width) * _diameters.width);
     83                float yNorm = (((float) pRel.getY()) * pRel.getY()) / (((float) _diameters.height) * _diameters.height);
    8484                return (xNorm + yNorm <= 4.0f);
    8585        }
     
    8888        public int getMaxX()
    8989        {
    90                 return _centre.x + (_diameters.width / 2 + _diameters.width % 2);
     90                return _centre.getX() + (_diameters.width / 2 + _diameters.width % 2);
    9191        }
    9292
     
    9494        public int getMinX()
    9595        {
    96                 return _centre.x -(_diameters.width / 2 + _diameters.width % 2);
     96                return _centre.getX() -(_diameters.width / 2 + _diameters.width % 2);
    9797        }
    9898
     
    100100        public int getMaxY()
    101101        {
    102                 return _centre.y + (_diameters.height / 2 + _diameters.height % 2);
     102                return _centre.getY() + (_diameters.height / 2 + _diameters.height % 2);
    103103        }
    104104
     
    106106        public int getMinY()
    107107        {
    108                 return _centre.y - (_diameters.height / 2 + _diameters.height % 2);
     108                return _centre.getY() - (_diameters.height / 2 + _diameters.height % 2);
    109109        }
    110110
     
    256256               
    257257                Point pRel = Point.difference(p, _centre);
    258                 return Math.atan2(pRel.y, pRel.x);
     258                return Math.atan2(pRel.getY(), pRel.getX());
    259259        }
    260260       
     
    269269                double r_y = _diameters.height / 2.0;
    270270                Point lineStartRel = Point.difference(line.getFirstEnd(), _centre);
    271                 double x_0 = lineStartRel.x;
    272                 double y_0 = lineStartRel.y;
     271                double x_0 = lineStartRel.getX();
     272                double y_0 = lineStartRel.getY();
    273273                double x_d = line.deltaX();
    274274                double y_d = line.deltaY();
  • trunk/src/org/expeditee/core/bounds/PolygonBounds.java

    r1097 r1142  
    6161        public void addPoint(Point p)
    6262        {
    63                 addPoint(p.x, p.y);
     63                addPoint(p.getX(), p.getY());
    6464        }
    6565       
     
    142142        public void rotate(double angle, Point cor)
    143143        {
    144                 rotate(angle, cor.x, cor.y);
     144                rotate(angle, cor.getX(), cor.getY());
    145145        }
    146146       
     
    159159        int hits = 0;
    160160
    161         int lastx = _points.get(npoints - 1).x;
    162         int lasty = _points.get(npoints - 1).y;
     161        int lastx = _points.get(npoints - 1).getX();
     162        int lasty = _points.get(npoints - 1).getY();
    163163        int curx, cury;
    164164
    165165        // Walk the edges of the polygon
    166166        for (int i = 0; i < npoints; lastx = curx, lasty = cury, i++) {
    167             curx = _points.get(i).x;
    168             cury = _points.get(i).y;
     167            curx = _points.get(i).getX();
     168            cury = _points.get(i).getY();
    169169
    170170            if (cury == lasty) {
     
    379379                        Point p1 = _points.get(i);
    380380                        Point p2 = _points.get((i + 1) % _points.size());
    381                         area += p1.x * p2.y - p2.x * p1.y;
     381                        area += p1.getX() * p2.getY() - p2.getX() * p1.getY();
    382382                }
    383383               
     
    500500                if (ellipse == null || nSegments < 3) return null;
    501501               
    502                 int centreX = ellipse.getCentre().x;
    503                 int centreY = ellipse.getCentre().y;
     502                int centreX = ellipse.getCentre().getX();
     503                int centreY = ellipse.getCentre().getY();
    504504                double xRadius = ellipse.getDiameters().width / 2.0;
    505505                double yRadius = ellipse.getDiameters().height / 2.0;
     
    532532               
    533533                for (Point p : _points) {
    534                         if (_maxX == null || p.x > _maxX.intValue()) _maxX = new Integer(p.x);
    535                         if (_minX == null || p.x < _minX.intValue()) _minX = new Integer(p.x);
    536                         if (_maxY == null || p.y > _maxY.intValue()) _maxY = new Integer(p.y);
    537                         if (_minY == null || p.y < _minY.intValue()) _minY = new Integer(p.y);
     534                        if (_maxX == null || p.getX() > _maxX.intValue()) _maxX = new Integer(p.getX());
     535                        if (_minX == null || p.getX() < _minX.intValue()) _minX = new Integer(p.getX());
     536                        if (_maxY == null || p.getY() > _maxY.intValue()) _maxY = new Integer(p.getY());
     537                        if (_minY == null || p.getY() < _minY.intValue()) _minY = new Integer(p.getY());
    538538                }
    539539        }
  • trunk/src/org/expeditee/gio/DragAndDropManager.java

    r1097 r1142  
    109109
    110110                        if (lastItem == null) {
    111                                 currentPoint.y += 30;
     111                                currentPoint.setY(currentPoint.getY() + 30);
    112112                        } else {
    113                                 currentPoint.y += lastItem.getBoundsHeight();
     113                                currentPoint.setY(currentPoint.getY() + lastItem.getBoundsHeight());
    114114                        }
    115115                        // of the item that was created
  • trunk/src/org/expeditee/gio/GraphicsManager.java

    r1097 r1142  
    240240                if (p1 == null || p2 == null) return;
    241241               
    242                 drawLine(p1.x, p1.y, p2.x, p2.y, colour, stroke);
     242                drawLine(p1.getX(), p1.getY(), p2.getX(), p2.getY(), colour, stroke);
    243243        }
    244244       
  • trunk/src/org/expeditee/gio/GraphicsSurfaceStack.java

    r1097 r1142  
    1010/**
    1111 * Helper-class for the graphics manager to maintain a stack of drawing
    12  * surfaces. Should be sub-typed by the platform-specific graphics manager
    13  * to use the appropriate surface class.
     12 * surfaces. Should be sub-typed by the platform-specific graphics manager to
     13 * use the appropriate surface class.
    1414 */
    1515public abstract class GraphicsSurfaceStack<T> {
     
    3131        /** The clip-stack for each drawing surface. */
    3232        private Stack<EnforcedClipStack> _clipStackStack;
    33        
     33
    3434        /** Constructor specifying no root surface. */
    35         public GraphicsSurfaceStack()
    36         {
     35        public GraphicsSurfaceStack() {
    3736                this(null);
    3837        }
    39        
     38
    4039        /** Constructor specifying the root surface. */
    41         public GraphicsSurfaceStack(T rootSurface)
    42         {
     40        public GraphicsSurfaceStack(T rootSurface) {
    4341                setRootSurface(rootSurface);
    4442                _currentImage = null;
     
    4846                _clipStackStack = new Stack<EnforcedClipStack>();
    4947        }
    50        
    51         /** Should be overridden by sub-types to allow a drawing surface to be extracted from an image. */
     48
     49        /**
     50         * Should be overridden by sub-types to allow a drawing surface to be extracted
     51         * from an image.
     52         */
    5253        public abstract T getSurfaceFromImage(Image image);
    53        
    54         /** Should be overridden by sub-types to set the actual clip on a given surface. */
     54
     55        /**
     56         * Should be overridden by sub-types to set the actual clip on a given surface.
     57         */
    5558        public abstract void setSurfaceClip(T surface, Clip clip);
    56        
    57         /** Pushes a new image onto the stack, and sets it as the current drawing surface. */
    58         public void push(Image image)
    59         {
    60                 if (image == null) return;
    61                
     59
     60        /**
     61         * Pushes a new image onto the stack, and sets it as the current drawing
     62         * surface.
     63         */
     64        public void push(Image image) {
     65                if (image == null)
     66                        return;
     67
    6268                _currentSurface = getSurfaceFromImage(image);
    6369                _currentImage = image;
     
    6773                _clipStackStack.push(_currentClipStack);
    6874        }
    69        
    70         /** Removes an image from the stack. The removed image is returned, or null if the root surface was current. */
    71         public Image pop()
    72         {
    73                 if (_surfaceStack.isEmpty()) return null;
    74                
     75
     76        /**
     77         * Removes an image from the stack. The removed image is returned, or null if
     78         * the root surface was current.
     79         */
     80        public Image pop() {
     81                if (_surfaceStack.isEmpty())
     82                        return null;
     83
    7584                Image oldTop = _imageStack.pop();
    7685                _surfaceStack.pop();
    7786                _clipStackStack.pop();
    78                
     87
    7988                if (!_surfaceStack.isEmpty()) {
    8089                        _currentSurface = _surfaceStack.peek();
     
    8695                        _currentClipStack = _rootClipStack;
    8796                }
    88                
     97
    8998                return oldTop;
    9099        }
    91        
     100
    92101        /** Gets a reference to the current drawing surface. */
    93         public T getCurrentSurface()
    94         {
     102        public T getCurrentSurface() {
    95103                return _currentSurface;
    96104        }
    97        
     105
    98106        /** Gets a reference to the top image on the stack. */
    99         public Image getCurrentImage()
    100         {
     107        public Image getCurrentImage() {
    101108                return _currentImage;
    102109        }
    103        
    104         /** Pushes a new clip onto the stack, ensuring that it is a sub-area of the top of the stack. */
    105         public EnforcedClipKey pushClip(Clip clip)
    106         {
     110
     111        /**
     112         * Pushes a new clip onto the stack, ensuring that it is a sub-area of the top
     113         * of the stack.
     114         */
     115        public EnforcedClipKey pushClip(Clip clip) {
    107116                EnforcedClipKey key = _currentClipStack.push(clip);
    108                 if (key != null) ensureClip();
     117                if (key != null)
     118                        ensureClip();
    109119                return key;
    110120        }
    111        
    112         /** Pops the top of the current clip-stack if there given key corresponds to it. */
    113         public Clip popClip(EnforcedClipKey key)
    114         {
     121
     122        /**
     123         * Pops the top of the current clip-stack if there given key corresponds to it.
     124         */
     125        public Clip popClip(EnforcedClipKey key) {
    115126                Clip clip = _currentClipStack.pop(key);
    116                 if (clip != null) ensureClip();
     127                if (clip != null)
     128                        ensureClip();
    117129                return clip;
    118130        }
    119        
     131
    120132        /** Returns a copy of the top of the current clip-stack. */
    121         public Clip peekClip()
    122         {
     133        public Clip peekClip() {
    123134                return _currentClipStack.peek();
    124135        }
    125        
     136
    126137        /** Ensures the current clip is applied to the underlying surface. */
    127         public void ensureClip()
    128         {
     138        public void ensureClip() {
    129139                setSurfaceClip(_currentSurface, _currentClipStack.peek());
    130140        }
    131        
     141
    132142        /** Updates the root surface. Does not affect any stacked image surfaces. */
    133         public void setRootSurface(T rootSurface)
    134         {
    135                 if (_currentSurface == _rootSurface) _currentSurface = rootSurface;
     143        public void setRootSurface(T rootSurface) {
     144                if (_currentSurface == _rootSurface)
     145                        _currentSurface = rootSurface;
    136146                _rootSurface = rootSurface;
    137                
     147
    138148        }
    139149}
  • trunk/src/org/expeditee/gio/TextLayoutManager.java

    r1097 r1142  
    1717        public List<TextLayout> layoutStringRelative(String string, Font font, int widthLimit, int lineSpacing, boolean dontBreakWords, boolean fullJustify)
    1818        {
    19                 return layoutString(string, font, Point.ORIGIN, null, widthLimit, lineSpacing, dontBreakWords, fullJustify);
     19                return layoutString(string, font, Point.ORIGIN.clone(), null, widthLimit, lineSpacing, dontBreakWords, fullJustify);
    2020        }
    2121       
     
    7171                for(Line l : lines) {
    7272                        // check for lines that cross over our y
    73                         if((l.getFirstEnd().y >= p.y && l.getSecondEnd().y <= p.y) || (l.getFirstEnd().y <= p.y && l.getSecondEnd().y >= p.y)) {
    74                                 float dX = l.getFirstEnd().x - l.getSecondEnd().x;
    75                                 float dY = l.getFirstEnd().y - l.getSecondEnd().y;
     73                        if((l.getFirstEnd().getY() >= p.getY() && l.getSecondEnd().getY() <= p.getY()) || (l.getFirstEnd().getY() <= p.getY() && l.getSecondEnd().getY() >= p.getY())) {
     74                                float dX = l.getFirstEnd().getX() - l.getSecondEnd().getX();
     75                                float dY = l.getFirstEnd().getY() - l.getSecondEnd().getY();
    7676                                float newWidth;
    7777                                if(dX == 0) {
    78                                         newWidth = l.getFirstEnd().x;
     78                                        newWidth = l.getFirstEnd().getX();
    7979                                } else if(dY == 0) {
    80                                         newWidth = Math.min(l.getFirstEnd().x, l.getSecondEnd().x);
     80                                        newWidth = Math.min(l.getFirstEnd().getX(), l.getSecondEnd().getX());
    8181                                } else {
    82                                         newWidth = l.getFirstEnd().x + (p.y - l.getFirstEnd().y) * dX / dY;
     82                                        newWidth = l.getFirstEnd().getX() + (p.getY() - l.getFirstEnd().getY()) * dX / dY;
    8383                                }
    84                                 if(newWidth < p.x) {
     84                                if(newWidth < p.getX()) {
    8585                                        continue;
    8686                                }
     
    9090                        }
    9191                }
    92                 return width - p.x;
     92                return width - p.getX();
    9393        }
    9494       
Note: See TracChangeset for help on using the changeset viewer.