Skip to content

Commit 8e7a095

Browse files
committed
[GEF] Remove getter for absolute coordinates from Tool
All GEF classes are supposed to work with relative coordinates, which can be translated to absolute coordinates, if necessary. However, WindowBuilder initially only used absolute coordinates for everything. With this removal, both projects now use the same coordinate system, which allows us to use the GEF classes directly. This change not only removes the `getAbsoluteStartLocation()` and `getAbsoluteLocation()` methods from the `Tool` class, it also removes the getter for the X and Y offset in the `IEditPartViewer` interface.
1 parent f8ff37b commit 8e7a095

5 files changed

Lines changed: 2 additions & 71 deletions

File tree

org.eclipse.wb.core/src-gef/org/eclipse/wb/gef/core/IEditPartViewer.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,6 @@ public interface IEditPartViewer extends ISelectionProvider, org.eclipse.gef.Edi
8787
//
8888
////////////////////////////////////////////////////////////////////////////
8989

90-
/**
91-
* @return viewer horizontal scroll offset.
92-
*/
93-
int getHOffset();
94-
95-
/**
96-
* @return viewer vertical scroll offset.
97-
*/
98-
int getVOffset();
99-
10090
/**
10191
* Returns the {@link EditDomain EditDomain} to which this viewer belongs.
10292
*/

org.eclipse.wb.core/src-gef/org/eclipse/wb/gef/core/tools/Tool.java

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,8 @@ private void setEvent(MouseEvent event) {
242242

243243
protected boolean movedPastThreshold() {
244244
if (!getFlag(FLAG_PAST_THRESHOLD)) {
245-
Point start = getAbsoluteStartLocation();
246-
Point end = getAbsoluteLocation();
245+
Point start = getStartLocation();
246+
Point end = getLocation();
247247
setFlag(FLAG_PAST_THRESHOLD, Math.abs(start.x - end.x) > DRAG_THRESHOLD || Math.abs(start.y - end.y) > DRAG_THRESHOLD);
248248
}
249249
return getFlag(FLAG_PAST_THRESHOLD);
@@ -348,23 +348,6 @@ public void viewerExited(MouseEvent event, EditPartViewer viewer) {
348348
// Drop Access
349349
//
350350
////////////////////////////////////////////////////////////////////////////
351-
/**
352-
* Returns the current x, y <b>*absolute*</b> position of the mouse cursor.
353-
*/
354-
public final Point getAbsoluteLocation() {
355-
return new Point(getLocation().x + getCurrentViewer().getHOffset(),
356-
getLocation().y + getCurrentViewer().getVOffset());
357-
}
358-
359-
/**
360-
* Returns the starting mouse <b>*absolute*</b> location for the current tool operation. This is
361-
* typically the mouse location where the user first pressed a mouse button. This is important for
362-
* tools that interpret mouse drags.
363-
*/
364-
protected Point getAbsoluteStartLocation() {
365-
return new Point(getStartLocation().x + getCurrentViewer().getHOffset(),
366-
getStartLocation().y + getCurrentViewer().getVOffset());
367-
}
368351

369352
/**
370353
* Resets all state fields to default values.

org.eclipse.wb.core/src-gef/org/eclipse/wb/internal/gef/graphical/GraphicalViewer.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -83,22 +83,6 @@ public FigureCanvas getControl() {
8383
return m_canvas;
8484
}
8585

86-
/**
87-
* @return viewer horizontal scroll offset.
88-
*/
89-
@Override
90-
public int getHOffset() {
91-
return m_canvas.getViewport().getHorizontalRangeModel().getValue();
92-
}
93-
94-
/**
95-
* @return viewer vertical scroll offset.
96-
*/
97-
@Override
98-
public int getVOffset() {
99-
return m_canvas.getViewport().getVerticalRangeModel().getValue();
100-
}
101-
10286
/**
10387
* Returns root {@link EditPart}.
10488
*/

org.eclipse.wb.core/src-gef/org/eclipse/wb/internal/gef/tree/TreeViewer.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -73,22 +73,6 @@ public Tree getControl() {
7373
return m_tree;
7474
}
7575

76-
/**
77-
* @return viewer horizontal scroll offset.
78-
*/
79-
@Override
80-
public int getHOffset() {
81-
return 0;
82-
}
83-
84-
/**
85-
* @return viewer vertical scroll offset.
86-
*/
87-
@Override
88-
public int getVOffset() {
89-
return 0;
90-
}
91-
9276
/**
9377
* Returns root {@link EditPart}.
9478
*/

org.eclipse.wb.tests/src/org/eclipse/wb/tests/gef/EmptyEditPartViewer.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,16 +123,6 @@ public void removeSelectionChangedListener(ISelectionChangedListener listener) {
123123
public void setSelection(ISelection selection) {
124124
}
125125

126-
@Override
127-
public int getHOffset() {
128-
return 0;
129-
}
130-
131-
@Override
132-
public int getVOffset() {
133-
return 0;
134-
}
135-
136126
@Override
137127
public RootEditPart getRootEditPart() {
138128
return null;

0 commit comments

Comments
 (0)