Merge "Omaha #3472 Clicking & dragging the Az/Ran Overlay tool off the map causes the map to jump" into omaha_14.4.1
Former-commit-id:de91441935
[formerlyfed30c111e
] [formerly310f314b81
[formerly 76ca557a25e6b09b3412cfe7a2d154b3a522cf74]] Former-commit-id:310f314b81
Former-commit-id:b6163075ef
This commit is contained in:
commit
94081ece24
1 changed files with 82 additions and 23 deletions
|
@ -59,8 +59,8 @@ import com.raytheon.uf.viz.core.rsc.capabilities.OutlineCapability;
|
||||||
import com.raytheon.uf.viz.core.rsc.tools.AbstractMovableToolLayer;
|
import com.raytheon.uf.viz.core.rsc.tools.AbstractMovableToolLayer;
|
||||||
import com.raytheon.uf.viz.core.rsc.tools.GenericToolsResourceData;
|
import com.raytheon.uf.viz.core.rsc.tools.GenericToolsResourceData;
|
||||||
import com.raytheon.uf.viz.points.PointsDataManager;
|
import com.raytheon.uf.viz.points.PointsDataManager;
|
||||||
|
import com.raytheon.viz.awipstools.common.ToolsUiUtil;
|
||||||
import com.raytheon.viz.awipstools.common.stormtrack.StormTrackDisplay;
|
import com.raytheon.viz.awipstools.common.stormtrack.StormTrackDisplay;
|
||||||
import com.raytheon.viz.awipstools.common.stormtrack.StormTrackUIManager;
|
|
||||||
import com.raytheon.viz.ui.cmenu.IContextMenuContributor;
|
import com.raytheon.viz.ui.cmenu.IContextMenuContributor;
|
||||||
import com.raytheon.viz.ui.input.EditableManager;
|
import com.raytheon.viz.ui.input.EditableManager;
|
||||||
import com.raytheon.viz.ui.input.InputAdapter;
|
import com.raytheon.viz.ui.input.InputAdapter;
|
||||||
|
@ -90,6 +90,10 @@ import com.vividsolutions.jts.geom.Coordinate;
|
||||||
* 07-28-14 #3430 mapeters Updated the 'handleMouseUp' function to prevent
|
* 07-28-14 #3430 mapeters Updated the 'handleMouseUp' function to prevent
|
||||||
* errors created when MB3 clicking off the map
|
* errors created when MB3 clicking off the map
|
||||||
* in editable mode.
|
* in editable mode.
|
||||||
|
* 08-11-14 #3472 mapeters Added Mode enum and isInsideCenter() function and
|
||||||
|
* updated functions in 'mouseHandler' to prevent
|
||||||
|
* errors when MB1 dragging tool off screen and to
|
||||||
|
* only change cursor to hand in editable mode.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -127,60 +131,97 @@ public class AzimuthToolLayer extends
|
||||||
private DrawableString[] labels = new DrawableString[RANGES.length
|
private DrawableString[] labels = new DrawableString[RANGES.length
|
||||||
+ ANGLES.length];
|
+ ANGLES.length];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Associated navigation modes:
|
||||||
|
* <UL>
|
||||||
|
* <LI>MOVE - Move the Az/Ran tool
|
||||||
|
* <LI>PAN - Allow other tools, such as pan, to have control
|
||||||
|
*/
|
||||||
|
private static enum Mode {
|
||||||
|
MOVE, PAN
|
||||||
|
};
|
||||||
|
|
||||||
private IInputHandler mouseHandler = new InputAdapter() {
|
private IInputHandler mouseHandler = new InputAdapter() {
|
||||||
|
|
||||||
private Shell lastShell = null;
|
private Shell lastShell = null;
|
||||||
|
|
||||||
|
/** The mode of the mouse. By default, pan */
|
||||||
|
private Mode mode = Mode.PAN;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handleMouseUp(int x, int y, int mouseButton) {
|
public boolean handleMouseUp(int x, int y, int mouseButton) {
|
||||||
if (nextCoordinate != null || (mouseButton == 3 && isEditable())) {
|
if (mouseButton == 3 && isEditable()) {
|
||||||
currCoordinate = getResourceContainer().translateClick(x, y);
|
IDisplayPaneContainer container = getResourceContainer();
|
||||||
|
if (container == null) {
|
||||||
if (currCoordinate == null) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Coordinate c2 = container.translateClick(x, y);
|
||||||
|
|
||||||
|
if (c2 == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
currCoordinate = c2;
|
||||||
centerPixel = descriptor.worldToPixel(new double[] {
|
centerPixel = descriptor.worldToPixel(new double[] {
|
||||||
currCoordinate.x, currCoordinate.y });
|
currCoordinate.x, currCoordinate.y });
|
||||||
nextCoordinate = null;
|
nextCoordinate = null;
|
||||||
|
|
||||||
if (lastShell != null) {
|
|
||||||
lastShell.setCursor(lastShell.getDisplay().getSystemCursor(
|
|
||||||
SWT.CURSOR_ARROW));
|
|
||||||
lastShell = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
recreate = true;
|
recreate = true;
|
||||||
issueRefresh();
|
issueRefresh();
|
||||||
return true;
|
return true;
|
||||||
}
|
} else if (this.mode == Mode.PAN) {
|
||||||
return false;
|
return false;
|
||||||
|
} else if (this.mode == Mode.MOVE) {
|
||||||
|
recreate = true;
|
||||||
|
issueRefresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Default back to pan operation
|
||||||
|
mode = Mode.PAN;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handleMouseDown(int x, int y, int mouseButton) {
|
public boolean handleMouseDown(int x, int y, int mouseButton) {
|
||||||
if (isEditable() && mouseButton == 1 && lastShell != null) {
|
|
||||||
nextCoordinate = new Coordinate(x, y);
|
if (isEditable() && mouseButton == 1 && isInsideCenter(x, y)) {
|
||||||
|
this.mode = Mode.MOVE;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
issueRefresh();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handleMouseDownMove(int x, int y, int mouseButton) {
|
public boolean handleMouseDownMove(int x, int y, int mouseButton) {
|
||||||
if (nextCoordinate != null) {
|
if (mouseButton != 1 || this.mode == Mode.PAN) {
|
||||||
nextCoordinate = getResourceContainer().translateClick(x, y);
|
return false;
|
||||||
issueRefresh();
|
}
|
||||||
|
|
||||||
|
if (this.mode == Mode.MOVE) {
|
||||||
|
IDisplayPaneContainer container = getResourceContainer();
|
||||||
|
if (container == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Coordinate c2 = container.translateClick(x, y);
|
||||||
|
|
||||||
|
if (c2 == null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
|
currCoordinate = c2;
|
||||||
|
centerPixel = descriptor.worldToPixel(new double[] {
|
||||||
|
currCoordinate.x, currCoordinate.y });
|
||||||
|
|
||||||
|
issueRefresh();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handleMouseMove(int x, int y) {
|
public boolean handleMouseMove(int x, int y) {
|
||||||
if (StormTrackUIManager.getCoordinateIndex(getResourceContainer(),
|
if (isInsideCenter(x, y) && isEditable()) {
|
||||||
new Coordinate[] { currCoordinate }, new Coordinate(x, y),
|
|
||||||
7.0) >= 0) {
|
|
||||||
IWorkbenchWindow window = PlatformUI.getWorkbench()
|
IWorkbenchWindow window = PlatformUI.getWorkbench()
|
||||||
.getActiveWorkbenchWindow();
|
.getActiveWorkbenchWindow();
|
||||||
lastShell = window.getShell();
|
lastShell = window.getShell();
|
||||||
|
@ -193,7 +234,6 @@ public class AzimuthToolLayer extends
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public AzimuthToolLayer(GenericToolsResourceData<AzimuthToolLayer> data,
|
public AzimuthToolLayer(GenericToolsResourceData<AzimuthToolLayer> data,
|
||||||
|
@ -215,6 +255,25 @@ public class AzimuthToolLayer extends
|
||||||
return AZIMUTH_LOCATION;
|
return AZIMUTH_LOCATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return if the given mouse position is within the tool's center.
|
||||||
|
*
|
||||||
|
* @param refX
|
||||||
|
* x location in screen pixels
|
||||||
|
* @param refY
|
||||||
|
* y location in screen pixels
|
||||||
|
* @return boolean true if within center, false otherwise
|
||||||
|
*/
|
||||||
|
public boolean isInsideCenter(int x, int y) {
|
||||||
|
IDisplayPaneContainer container = getResourceContainer();
|
||||||
|
if (container == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
int idx = ToolsUiUtil.closeToCoordinate(container,
|
||||||
|
new Coordinate[] { currCoordinate }, x, y, 7.0);
|
||||||
|
return idx >= 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue