Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 86005 Details for
Bug 212460
Request for extra methods on PrecisionRectangle and a fix on PrecisionPoint
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Corrected patch
GEF_PrecisionUtils_Jan02_Corrections (text/plain), 16.58 KB, created by
Alex Boyko
on 2008-01-02 13:04:06 EST
(
hide
)
Description:
Corrected patch
Filename:
MIME Type:
Creator:
Alex Boyko
Created:
2008-01-02 13:04:06 EST
Size:
16.58 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.draw2d >Index: src/org/eclipse/draw2d/geometry/PrecisionPoint.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.gef/plugins/org.eclipse.draw2d/src/org/eclipse/draw2d/geometry/PrecisionPoint.java,v >retrieving revision 1.10 >diff -u -r1.10 PrecisionPoint.java >--- src/org/eclipse/draw2d/geometry/PrecisionPoint.java 30 Mar 2005 21:27:45 -0000 1.10 >+++ src/org/eclipse/draw2d/geometry/PrecisionPoint.java 2 Jan 2008 18:02:32 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2005 IBM Corporation and others. >+ * Copyright (c) 2000, 2007 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -33,15 +33,9 @@ > * @param copy Point from which the initial values are taken > */ > public PrecisionPoint(Point copy) { >- if (copy instanceof PrecisionPoint) { >- PrecisionPoint precPt = (PrecisionPoint)copy; >- preciseX = precPt.preciseX; >- preciseY = precPt.preciseY; >- updateInts(); >- } else { >- preciseX = x = copy.x; >- preciseY = y = copy.y; >- } >+ preciseX = copy.preciseX(); >+ preciseY = copy.preciseY(); >+ updateInts(); > } > > /** >@@ -61,9 +55,9 @@ > * @param y Y value > */ > public PrecisionPoint(double x, double y) { >- super(x, y); > preciseX = x; > preciseY = y; >+ updateInts(); > } > > /** >@@ -80,8 +74,7 @@ > public void performScale(double factor) { > preciseX = preciseX * factor; > preciseY = preciseY * factor; >- x = (int)Math.floor(preciseX + 0.000000001); >- y = (int)Math.floor(preciseY + 0.000000001); >+ updateInts(); > } > > /** >@@ -90,23 +83,16 @@ > public void performTranslate(int dx, int dy) { > preciseX += dx; > preciseY += dy; >- x = (int)Math.floor(preciseX + 0.000000001); >- y = (int)Math.floor(preciseY + 0.000000001); >+ updateInts(); > } > > /** > * @see org.eclipse.draw2d.geometry.Point#setLocation(Point) > */ > public Point setLocation(Point pt) { >- if (pt instanceof PrecisionPoint) { >- preciseX = ((PrecisionPoint)pt).preciseX; >- preciseY = ((PrecisionPoint)pt).preciseY; >- } else { >- preciseX = pt.x; >- preciseY = pt.y; >- } >- x = (int)Math.floor(preciseX + 0.000000001); >- y = (int)Math.floor(preciseY + 0.000000001); >+ preciseX = pt.preciseX(); >+ preciseY = pt.preciseY(); >+ updateInts(); > return this; > } > >@@ -118,4 +104,18 @@ > y = (int)Math.floor(preciseY + 0.000000001); > } > >+/** >+ * @see org.eclipse.draw2d.geometry.Point#preciseX() >+ */ >+public double preciseX() { >+ return preciseX; >+} >+ >+/** >+ * @see org.eclipse.draw2d.geometry.Point#preciseY() >+ */ >+public double preciseY() { >+ return preciseY; >+} >+ > } >Index: src/org/eclipse/draw2d/geometry/Rectangle.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.gef/plugins/org.eclipse.draw2d/src/org/eclipse/draw2d/geometry/Rectangle.java,v >retrieving revision 1.18 >diff -u -r1.18 Rectangle.java >--- src/org/eclipse/draw2d/geometry/Rectangle.java 15 May 2006 17:44:38 -0000 1.18 >+++ src/org/eclipse/draw2d/geometry/Rectangle.java 2 Jan 2008 18:02:32 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2005 IBM Corporation and others. >+ * Copyright (c) 2000, 2007 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -882,7 +882,7 @@ > * @param p Point to be unioned with this Rectangle > * @since 2.0 > */ >-public final void union(Point p) { >+public void union(Point p) { > union(p.x, p.y); > } > >@@ -894,7 +894,7 @@ > * @param rect Rectangle to be unioned with this Rectangle > * @since 2.0 > */ >-public final Rectangle union(Rectangle rect) { >+public Rectangle union(Rectangle rect) { > if (rect == null) > return this; > return union(rect.x, rect.y, rect.width, rect.height); >@@ -921,4 +921,44 @@ > return this; > } > >+/** >+ * Returns <code>double</code> x coordinate >+ * >+ * @return <code>double</code> x coordinate >+ * @since 3.4 >+ */ >+public double preciseX() { >+ return x; >+} >+ >+/** >+ * Returns <code>double</code> y coordinate >+ * >+ * @return <code>double</code> y coordinate >+ * @since 3.4 >+ */ >+public double preciseY() { >+ return y; >+} >+ >+/** >+ * Returns <code>double</code> width >+ * >+ * @return <code>double</code> width >+ * @since 3.4 >+ */ >+public double preciseWidth() { >+ return width; >+} >+ >+/** >+ * Returns <code>double</code> height >+ * >+ * @return <code>double</code> height >+ * @since 3.4 >+ */ >+public double preciseHeight() { >+ return height; >+} >+ > } >Index: src/org/eclipse/draw2d/geometry/PrecisionDimension.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.gef/plugins/org.eclipse.draw2d/src/org/eclipse/draw2d/geometry/PrecisionDimension.java,v >retrieving revision 1.7 >diff -u -r1.7 PrecisionDimension.java >--- src/org/eclipse/draw2d/geometry/PrecisionDimension.java 11 May 2005 19:25:02 -0000 1.7 >+++ src/org/eclipse/draw2d/geometry/PrecisionDimension.java 2 Jan 2008 18:02:32 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2003, 2005 IBM Corporation and others. >+ * Copyright (c) 2003, 2007 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -20,6 +20,7 @@ > * The width in double precision. > */ > public double preciseWidth; >+ > /** > * The height in double precision. > */ >@@ -47,9 +48,9 @@ > * @param d the reference dimension > */ > public PrecisionDimension(Dimension d) { >- super(d); >- preciseHeight = d.height; >- preciseWidth = d.width; >+ preciseHeight = d.preciseHeight(); >+ preciseWidth = d.preciseWidth(); >+ updateInts(); > } > > /** >@@ -69,4 +70,18 @@ > height = (int)Math.floor(preciseHeight + 0.000000001); > } > >+/** >+ * @see org.eclipse.draw2d.geometry.Dimension#preciseWidth() >+ */ >+public double preciseWidth() { >+ return preciseWidth; >+} >+ >+/** >+ * @see org.eclipse.draw2d.geometry.Dimension#preciseHeight() >+ */ >+public double preciseHeight() { >+ return preciseHeight; >+} >+ > } >Index: src/org/eclipse/draw2d/geometry/Dimension.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.gef/plugins/org.eclipse.draw2d/src/org/eclipse/draw2d/geometry/Dimension.java,v >retrieving revision 1.14 >diff -u -r1.14 Dimension.java >--- src/org/eclipse/draw2d/geometry/Dimension.java 30 Mar 2005 21:27:45 -0000 1.14 >+++ src/org/eclipse/draw2d/geometry/Dimension.java 2 Jan 2008 18:02:32 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2005 IBM Corporation and others. >+ * Copyright (c) 2000, 2007 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -435,4 +435,24 @@ > return this; > } > >+/** >+ * Returns <code>double</code> width >+ * >+ * @return <code>double</code> width >+ * @since 3.4 >+ */ >+public double preciseWidth() { >+ return width; >+} >+ >+/** >+ * Returns <code>double</code> height >+ * >+ * @return <code>double</code> height >+ * @since 3.4 >+ */ >+public double preciseHeight() { >+ return height; >+} >+ > } >Index: src/org/eclipse/draw2d/geometry/Point.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.gef/plugins/org.eclipse.draw2d/src/org/eclipse/draw2d/geometry/Point.java,v >retrieving revision 1.9 >diff -u -r1.9 Point.java >--- src/org/eclipse/draw2d/geometry/Point.java 29 Mar 2005 23:58:02 -0000 1.9 >+++ src/org/eclipse/draw2d/geometry/Point.java 2 Jan 2008 18:02:32 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2005 IBM Corporation and others. >+ * Copyright (c) 2000, 2007 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -395,4 +395,24 @@ > return this; > } > >+/** >+ * Returns <code>double</code> x coordinate >+ * >+ * @return <code>double</code> x coordinate >+ * @since 3.4 >+ */ >+public double preciseX() { >+ return x; >+} >+ >+/** >+ * Returns <code>double</code> y coordinate >+ * >+ * @return <code>double</code> y coordinate >+ * @since 3.4 >+ */ >+public double preciseY() { >+ return y; >+} >+ > } >Index: src/org/eclipse/draw2d/geometry/PrecisionRectangle.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.gef/plugins/org.eclipse.draw2d/src/org/eclipse/draw2d/geometry/PrecisionRectangle.java,v >retrieving revision 1.17 >diff -u -r1.17 PrecisionRectangle.java >--- src/org/eclipse/draw2d/geometry/PrecisionRectangle.java 3 Mar 2006 05:06:29 -0000 1.17 >+++ src/org/eclipse/draw2d/geometry/PrecisionRectangle.java 2 Jan 2008 18:02:32 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2003, 2005 IBM Corporation and others. >+ * Copyright (c) 2003, 2007 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -10,6 +10,7 @@ > *******************************************************************************/ > package org.eclipse.draw2d.geometry; > >+ > /** > * A Rectangle implementation using floating point values which are truncated into the inherited > * integer fields. The use of floating point prevents rounding errors from accumulating. >@@ -40,18 +41,10 @@ > * @param rect the base rectangle > */ > public PrecisionRectangle(Rectangle rect) { >- if (rect instanceof PrecisionRectangle) { >- PrecisionRectangle rectangle = (PrecisionRectangle)rect; >- preciseX = rectangle.preciseX; >- preciseY = rectangle.preciseY; >- preciseWidth = rectangle.preciseWidth; >- preciseHeight = rectangle.preciseHeight; >- } else { >- preciseX = rect.x; >- preciseY = rect.y; >- preciseWidth = rect.width; >- preciseHeight = rect.height; >- } >+ preciseX = rect.preciseX(); >+ preciseY = rect.preciseY(); >+ preciseWidth = rect.preciseWidth(); >+ preciseHeight = rect.preciseHeight(); > updateInts(); > } > >@@ -148,14 +141,8 @@ > * @see org.eclipse.draw2d.geometry.Rectangle#resize(org.eclipse.draw2d.geometry.Dimension) > */ > public Rectangle resize(Dimension sizeDelta) { >- if (sizeDelta instanceof PrecisionDimension) { >- PrecisionDimension pd = (PrecisionDimension)sizeDelta; >- preciseWidth += pd.preciseWidth; >- preciseHeight += pd.preciseHeight; >- } else { >- preciseWidth += sizeDelta.width; >- preciseHeight += sizeDelta.height; >- } >+ preciseWidth += sizeDelta.preciseWidth(); >+ preciseHeight += sizeDelta.preciseHeight(); > updateInts(); > return this; > } >@@ -200,14 +187,8 @@ > * @see org.eclipse.draw2d.geometry.Rectangle#translate(org.eclipse.draw2d.geometry.Point) > */ > public Rectangle translate(Point p) { >- if (p instanceof PrecisionPoint) { >- PrecisionPoint pp = (PrecisionPoint)p; >- preciseX += pp.preciseX; >- preciseY += pp.preciseY; >- } else { >- preciseX += p.x; >- preciseY += p.y; >- } >+ preciseX += p.preciseX(); >+ preciseY += p.preciseY(); > updateInts(); > return this; > } >@@ -218,6 +199,8 @@ > * @since 3.0 > * @param other the rectangle being unioned > * @return <code>this</code> for convenience >+ * @deprecated >+ * Use {@link #union(Rectangle)} instead > */ > public PrecisionRectangle union(PrecisionRectangle other) { > double newright = Math.max(preciseRight(), other.preciseRight()); >@@ -232,6 +215,21 @@ > } > > /** >+ * @see org.eclipse.draw2d.geometry.Rectangle#union(org.eclipse.draw2d.geometry.Rectangle) >+ */ >+public Rectangle union(Rectangle other) { >+ double newright = Math.max(preciseRight(), other.preciseX() + other.preciseWidth()); >+ double newbottom = Math.max(preciseBottom(), other.preciseY() + other.preciseHeight()); >+ preciseX = Math.min(preciseX, other.preciseX()); >+ preciseY = Math.min(preciseY, other.preciseY()); >+ preciseWidth = newright - preciseX; >+ preciseHeight = newbottom - preciseY; >+ updateInts(); >+ >+ return this; >+} >+ >+/** > * Updates the integer values based on the current precise values. The integer values ar > * the floor of the double values. This is called automatically when calling api which is > * overridden in this class. >@@ -244,4 +242,139 @@ > height = (int)Math.floor(preciseHeight + preciseY + 0.000000001) - y; > } > >+/** >+ * @see org.eclipse.draw2d.geometry.Rectangle#union(org.eclipse.draw2d.geometry.Point) >+ */ >+public void union(Point p) { >+ if (p.preciseX() < preciseX) { >+ preciseWidth += (preciseX - p.preciseX()); >+ preciseX = p.preciseX(); >+ } else { >+ double right = preciseX + preciseWidth; >+ if (p.preciseX() > right) { >+ preciseWidth = p.preciseX() - preciseX; >+ } >+ } >+ if (p.preciseY() < preciseY) { >+ preciseHeight += (preciseY - p.preciseY()); >+ preciseY = p.preciseY(); >+ } else { >+ double bottom = preciseY + preciseHeight; >+ if (p.preciseY() > bottom) { >+ preciseHeight = p.preciseY() - preciseY; >+ } >+ } >+ updateInts(); >+} >+ >+/** >+ * @see org.eclipse.draw2d.geometry.Rectangle#transpose() >+ */ >+public Rectangle transpose() { >+ double temp = preciseX; >+ preciseX = preciseY; >+ preciseY = temp; >+ temp = preciseWidth; >+ preciseWidth = preciseHeight; >+ preciseHeight = temp; >+ super.transpose(); >+ return this; >+} >+ >+/** >+ * @see org.eclipse.draw2d.geometry.Rectangle#setLocation(org.eclipse.draw2d.geometry.Point) >+ */ >+public Rectangle setLocation(Point loc) { >+ preciseX = loc.preciseX(); >+ preciseY = loc.preciseY(); >+ updateInts(); >+ return this; >+} >+ >+/** >+ * Returns the precise geometric centre of the rectangle >+ * >+ * @return <code>PrecisionPoint</code> geometric center of the rectangle >+ * @since 3.4 >+ */ >+public Point getCenter() { >+ return new PrecisionPoint(preciseX + preciseWidth / 2.0, preciseY + preciseHeight / 2.0); >+} >+ >+/** >+ * Shrinks the sides of this Rectangle by the horizontal and vertical values >+ * provided as input, and returns this Rectangle for convenience. The center of >+ * this Rectangle is kept constant. >+ * >+ * @param h Horizontal reduction amount >+ * @param v Vertical reduction amount >+ * @return <code>this</code> for convenience >+ * @since 3.4 >+ */ >+public Rectangle shrink(double h, double v) { >+ preciseX += h; >+ preciseWidth -= (h + h); >+ preciseY += v; >+ preciseHeight -= (v + v); >+ updateInts(); >+ return this; >+} >+ >+/** >+ * Expands the horizontal and vertical sides of this Rectangle with the values >+ * provided as input, and returns this for convenience. The location of its >+ * center is kept constant. >+ * >+ * @param h Horizontal increment >+ * @param v Vertical increment >+ * @return <code>this</code> for convenience >+ * @since 3.4 >+ */ >+public Rectangle expand(double h, double v) { >+ return shrink(-h, -v); >+} >+ >+/** >+ * @see org.eclipse.draw2d.geometry.Rectangle#shrink(int, int) >+ */ >+public Rectangle shrink(int h, int v) { >+ return shrink((double)h, (double)v); >+} >+ >+/** >+ * @see org.eclipse.draw2d.geometry.Rectangle#contains(org.eclipse.draw2d.geometry.Point) >+ */ >+public boolean contains(Point p) { >+ return preciseX <= p.preciseX() && p.preciseX() <= preciseX + preciseWidth >+ && preciseY <= p.preciseY() && p.preciseY() <= preciseY + preciseHeight; >+} >+ >+/** >+ * @see org.eclipse.draw2d.geometry.Rectangle#preciseX() >+ */ >+public double preciseX() { >+ return preciseX; >+} >+ >+/** >+ * @see org.eclipse.draw2d.geometry.Rectangle#preciseY() >+ */ >+public double preciseY() { >+ return preciseY; >+} >+ >+/** >+ * @see org.eclipse.draw2d.geometry.Rectangle#preciseWidth() >+ */ >+public double preciseWidth() { >+ return preciseWidth; >+} >+ >+/** >+ * @see org.eclipse.draw2d.geometry.Rectangle#preciseHeight() >+ */ >+public double preciseHeight() { >+ return preciseHeight; >+} >+ > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
ahunter.eclipse
:
iplog+
Actions:
View
|
Diff
Attachments on
bug 212460
:
84900
|
85011
|
85133
|
85304
|
85466
| 86005