/*
 * jssf - Java Side Scroller Format library
 * Copyright (C) 2015 Delwink, LLC
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, version 3 only.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.delwink.jssf.geom;

public class Rectangle {
    private Point pos, size;
    
    public Rectangle(Point pos, Point size) {
        this.setRectangle(pos, size);
    }
    
    public Rectangle(Rectangle r) {
        this.setRectangle(r);
    }
    
    public final void setRectangle(Point pos, Point size) {
        this.pos = pos;
        this.size = size;
    }
    
    public final void setRectangle(Rectangle r) {
        this.pos = r.getPos();
        this.size = r.getSize();
    }
    
    public void shift(float x, float y) {
        this.pos.shift(x, y);
    }
    
    public void grow(float x, float y) {
        this.size.shift(x, y);
    }
    
    public Point getPos() {
        return new Point(this.pos);
    }
    
    public void setPos(Point pos) {
        this.pos = pos;
    }
    
    public Point getSize() {
        return new Point(this.size);
    }
    
    public void setSize(Point size) {
        this.size = size;
    }
}

@@ -720,61 +720,248 @@
 m;%0A%0A
-public class Rectangle %7B%0A    private Point pos, size;
+import java.awt.geom.Point2D;%0Aimport java.awt.geom.Rectangle2D;%0Aimport java.util.ArrayList;%0A%0Apublic class Rectangle extends Rectangle2D.Double %7B%0A    public Rectangle(double x, double y, double w, double h) %7B%0A        super(x, y, w, h);%0A    %7D
 %0A   
@@ -980,32 +980,34 @@
  Rectangle(Point
+2D
  pos, Point size
@@ -993,32 +993,34 @@
 int2D pos, Point
+2D
  size) %7B%0A       
@@ -1024,281 +1024,638 @@
     
-this.setRectangle(pos, size);%0A    %7D%0A    %0A    public Rectangle(Rectangle r) %7B%0A        this.setRectangle(r);%0A    %7D%0A    %0A    public final void setRectangle(Point pos, Point size) %7B%0A        this.pos = pos;%0A        this.size = size;%0A    %7D%0A    %0A    public final void setRectangle
+super(pos.getX(), pos.getY(), size.getX(), size.getY());%0A    %7D%0A    %0A    public ArrayList%3CPoint2D.Double%3E getIntersection(LineSegment ls) %7B%0A        ArrayList%3CPoint2D.Double%3E intersected = new ArrayList%3C%3E();%0A        LineSegment%5B%5D lines = this.getLines();%0A        %0A        for (LineSegment line : lines) %7B%0A            Point2D.Double p = line.getIntersection(ls);%0A            if (p != null && !intersected.contains(p))%0A                intersected.add(p);%0A        %7D%0A        %0A        if (intersected.isEmpty())%0A            return null;%0A        %0A        return intersected;%0A    %7D%0A    %0A    public ArrayList%3CPoint2D.Double%3E getIntersection
 (Rec
@@ -1662,16 +1662,17 @@
 tangle r
+2
 ) %7B%0A    
@@ -1679,68 +1679,137 @@
     
-this.pos = r.getPos();%0A        this.size
+ArrayList%3CPoint2D.Double%3E intersected = new ArrayList%3C%3E();%0A        LineSegment%5B%5D l1s = this.getLines(), l2s
  = r
+2
 .get
-Size
+Lines
 ();%0A    
 %7D%0A  
@@ -1800,26 +1800,24 @@
 ines();%0A    
-%7D%0A
     %0A    pub
@@ -1817,455 +1817,907 @@
     
-public void shift(float x, float y) %7B%0A        this.pos.shift(x, y
+    for (LineSegment l1 : l1s)%0A            for (LineSegment l2 : l2s) %7B%0A                Point2D.Double p = l1.getIntersection(l2
 );%0A    
-%7D%0A
+     
     
-%0A
    
- public void grow(float x, float y) %7B%0A        this.size.shift(x, y);%0A    %7D%0A    %0A    public Point getPos() %7B%0A        return new Point(this.pos);%0A
+if (p != null && !intersected.contains(p))%0A                    intersected.add(p);%0A            %7D%0A        %0A        return intersected;%0A    %7D%0A    %0A    public LineSegment%5B%5D getLines() %7B%0A        Point2D.Double endPoint = new Point2D.Double(this.getX() + this.getWidth(),%0A 
     
-%7D%0A
+   
     
-%0A
     
-public void setPos(Point pos) %7B%0A        this.pos = pos;
+this.getY() + this.getHeight());%0A        %0A        LineSegment lines%5B%5D = %7B
 %0A    
-%7D%0A
     
-%0A
     
-public 
+new LineSegment(this.getX(), this.getY(), end
 Point
- getSize() %7B%0A        return new Point(this.size);
+.getX(), this.getY()),%0A            new LineSegment(this.getX(), this.getY(), this.getX(), endPoint.getY()),
 %0A    
-%7D%0A
     
-%0A
     
-public void setSize(Point size) %7B%0A        this.size = size
+new LineSegment(this.getX(), endPoint.getY(), endPoint.getX(), endPoint.getY()),%0A            new LineSegment(endPoint.getX(), this.getY(), endPoint.getX(), endPoint.getY())%0A        %7D;%0A        %0A        return lines
 ;%0A  

Change to Java2D points