Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 129864
Collapse All | Expand All

(-)src/org/eclipse/draw2d/geometry/PrecisionRectangle.java (+29 lines)
Lines 77-82 Link Here
77
}
77
}
78
78
79
/**
79
/**
80
 * @see org.eclipse.draw2d.geometry.Rectangle#crop(org.eclipse.draw2d.geometry.Insets)
81
 */
82
public Rectangle crop(Insets insets) {
83
    if (insets == null) 
84
        return this;
85
    setX(preciseX + insets.left);
86
    setY(preciseY += insets.top);
87
    setWidth(preciseWidth - (insets.getWidth()));
88
    setHeight(preciseHeight -= (insets.getHeight()));
89
    
90
    return this;
91
}
92
93
/**
94
 * @see org.eclipse.draw2d.geometry.Rectangle#equals(java.lang.Object)
95
 */
96
public boolean equals(Object o) {
97
    if (o instanceof PrecisionRectangle) {
98
        PrecisionRectangle pr = (PrecisionRectangle)o;
99
        return pr.preciseX == preciseX &&
100
               pr.preciseY == preciseY &&
101
               pr.preciseX == preciseY &&
102
               pr.preciseY == preciseY;
103
    }
104
    
105
    return super.equals(o);
106
}
107
108
/**
80
 * @see org.eclipse.draw2d.geometry.Rectangle#performScale(double)
109
 * @see org.eclipse.draw2d.geometry.Rectangle#performScale(double)
81
 */
110
 */
82
public void performScale(double factor) {
111
public void performScale(double factor) {
(-)src/org/eclipse/draw2d/test/PrecisionRectangleTest.java (+39 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.draw2d.test;
13
14
import junit.framework.TestCase;
15
16
import org.eclipse.draw2d.geometry.Insets;
17
import org.eclipse.draw2d.geometry.PrecisionRectangle;
18
import org.eclipse.draw2d.geometry.Rectangle;
19
20
/**
21
 * @author sshaw
22
 *
23
 */
24
public class PrecisionRectangleTest extends TestCase {
25
26
    public void testCrop() {
27
        Insets insets = new Insets (2, 2, 2, 2);
28
        
29
        PrecisionRectangle prect = new PrecisionRectangle(new Rectangle(100, 100, 250, 250));
30
        PrecisionRectangle copy = prect.getPreciseCopy ();
31
        prect.performTranslate(30, 30);
32
        prect.performScale(2f);
33
        prect.crop (insets);
34
        prect.performScale(1/2f);
35
        prect.performTranslate(-30, -30);
36
        
37
        assertTrue(!prect.equals (copy));
38
    }
39
}

Return to bug 129864