Revision: 5296
http://sourceforge.net/p/jump-pilot/code/5296
Author: edso
Date: 2016-12-29 17:33:41 +0000 (Thu, 29 Dec 2016)
Log Message:
-----------
reformat
removed unneeded undo call
Modified Paths:
--------------
core/trunk/src/com/vividsolutions/jump/workbench/ui/zoom/ZoomToCoordinatePlugIn.java
Modified:
core/trunk/src/com/vividsolutions/jump/workbench/ui/zoom/ZoomToCoordinatePlugIn.java
===================================================================
---
core/trunk/src/com/vividsolutions/jump/workbench/ui/zoom/ZoomToCoordinatePlugIn.java
2016-12-29 17:32:49 UTC (rev 5295)
+++
core/trunk/src/com/vividsolutions/jump/workbench/ui/zoom/ZoomToCoordinatePlugIn.java
2016-12-29 17:33:41 UTC (rev 5296)
@@ -24,96 +24,96 @@
import com.vividsolutions.jump.workbench.ui.cursortool.Animations;
public class ZoomToCoordinatePlugIn extends AbstractPlugIn {
- private Coordinate lastCoordinate = new Coordinate(0, 0);
- public boolean execute(PlugInContext context) throws Exception {
- reportNothingToUndoYet(context);
- Coordinate coordinate = prompt(context);
- if (coordinate == null) {
- return false;
- }
- lastCoordinate = coordinate;
- context.getLayerViewPanel().getViewport()
- .zoom(toEnvelope(coordinate,
context.getLayerManager()));
-
Animations.drawExpandingRing(context.getLayerViewPanel().getViewport()
- .toViewPoint(lastCoordinate), false, Color.BLUE,
- context.getLayerViewPanel(), new float[] { 20, 20 });
+ private Coordinate lastCoordinate = new Coordinate(0, 0);
- return true;
- }
+ public boolean execute(PlugInContext context) throws Exception {
+ Coordinate coordinate = prompt(context);
+ if (coordinate == null) {
+ return false;
+ }
+ lastCoordinate = coordinate;
+ context.getLayerViewPanel().getViewport()
+ .zoom(toEnvelope(coordinate, context.getLayerManager()));
+ Animations.drawExpandingRing(context.getLayerViewPanel().getViewport()
+ .toViewPoint(lastCoordinate), false, Color.BLUE,
+ context.getLayerViewPanel(), new float[] { 20, 20 });
- private Coordinate prompt(PlugInContext context) {
- while (true) {
- try {
- return
toCoordinate(JOptionPane.showInputDialog(context
- .getWorkbenchFrame(),
-
I18N.get("ui.zoom.ZoomToCoordinatePlugIn.enter-coordinate-to-zoom-to"), lastCoordinate.x
+ ", "
- +
lastCoordinate.y));
- } catch (Exception e) {
-
JOptionPane.showMessageDialog(context.getWorkbenchFrame(), e
- .getMessage(),
-
context.getWorkbenchFrame().getTitle(),
- JOptionPane.ERROR_MESSAGE);
- }
- }
+ return true;
+ }
- }
+ private Coordinate prompt(PlugInContext context) {
+ while (true) {
+ try {
+ return toCoordinate(JOptionPane.showInputDialog(context
+ .getWorkbenchFrame(), I18N
+ .get("ui.zoom.ZoomToCoordinatePlugIn.enter-coordinate-to-zoom-to"),
+ lastCoordinate.x + ", " + lastCoordinate.y));
+ } catch (Exception e) {
+ JOptionPane.showMessageDialog(context.getWorkbenchFrame(),
+ e.getMessage(), context.getWorkbenchFrame().getTitle(),
+ JOptionPane.ERROR_MESSAGE);
+ }
+ }
- private Envelope toEnvelope(Coordinate coordinate, LayerManager layerManager) {
- int segments = 0;
- int segmentSum = 0;
- outer : for (Iterator i = layerManager.iterator(); i.hasNext();
) {
- Layer layer = (Layer) i.next();
- for (Iterator j =
layer.getFeatureCollectionWrapper().iterator(); j
- .hasNext(); ) {
- Feature feature = (Feature) j.next();
- Collection coordinateArrays =
CoordinateArrays.toCoordinateArrays(feature.getGeometry(), false);
- for (Iterator k = coordinateArrays.iterator(); k.hasNext(); ) {
- Coordinate[] coordinates = (Coordinate[]) k.next();
- for (int a = 1; a < coordinates.length; a++) {
- segments++;
- segmentSum += coordinates[a].distance(coordinates[a-1]);
- if (segments > 100) { break outer; }
- }
- }
- }
- }
- Envelope envelope = new Envelope(coordinate);
- //Choose a reasonable magnification [Jon Aquino 10/22/2003]
- if (segmentSum > 0) {
- envelope = EnvelopeUtil.expand(envelope,
- segmentSum / (double) segments);
- } else {
- envelope = EnvelopeUtil.expand(envelope, 50);
- }
- return envelope;
- }
+ }
- private Coordinate toCoordinate(String s) throws Exception {
- if (s == null) {
- return null;
- }
- if (s.trim().length() == 0) {
- return null;
- }
- s = StringUtil.replaceAll(s, ",", " ");
- StringTokenizer tokenizer = new StringTokenizer(s);
- String x = tokenizer.nextToken();
- if (!StringUtil.isNumber(x)) {
- throw new Exception("Not a number: " + x);
- }
- String y = tokenizer.nextToken();
- if (!StringUtil.isNumber(y)) {
- throw new Exception("Not a number: " + y);
- }
- return new Coordinate(Double.parseDouble(x),
Double.parseDouble(y));
- }
+ private Envelope toEnvelope(Coordinate coordinate, LayerManager
layerManager) {
+ int segments = 0;
+ int segmentSum = 0;
+ outer: for (Iterator i = layerManager.iterator(); i.hasNext();) {
+ Layer layer = (Layer) i.next();
+ for (Iterator j = layer.getFeatureCollectionWrapper().iterator(); j
+ .hasNext();) {
+ Feature feature = (Feature) j.next();
+ Collection coordinateArrays = CoordinateArrays.toCoordinateArrays(
+ feature.getGeometry(), false);
+ for (Iterator k = coordinateArrays.iterator(); k.hasNext();) {
+ Coordinate[] coordinates = (Coordinate[]) k.next();
+ for (int a = 1; a < coordinates.length; a++) {
+ segments++;
+ segmentSum += coordinates[a].distance(coordinates[a - 1]);
+ if (segments > 100) {
+ break outer;
+ }
+ }
+ }
+ }
+ }
+ Envelope envelope = new Envelope(coordinate);
+ // Choose a reasonable magnification [Jon Aquino 10/22/2003]
+ if (segmentSum > 0) {
+ envelope = EnvelopeUtil.expand(envelope, segmentSum / (double) segments);
+ } else {
+ envelope = EnvelopeUtil.expand(envelope, 50);
+ }
+ return envelope;
+ }
- public MultiEnableCheck createEnableCheck(
- final WorkbenchContext workbenchContext) {
- EnableCheckFactory checkFactory = new EnableCheckFactory(
- workbenchContext);
+ private Coordinate toCoordinate(String s) throws Exception {
+ if (s == null) {
+ return null;
+ }
+ if (s.trim().length() == 0) {
+ return null;
+ }
+ s = StringUtil.replaceAll(s, ",", " ");
+ StringTokenizer tokenizer = new StringTokenizer(s);
+ String x = tokenizer.nextToken();
+ if (!StringUtil.isNumber(x)) {
+ throw new Exception("Not a number: " + x);
+ }
+ String y = tokenizer.nextToken();
+ if (!StringUtil.isNumber(y)) {
+ throw new Exception("Not a number: " + y);
+ }
+ return new Coordinate(Double.parseDouble(x), Double.parseDouble(y));
+ }
- return new MultiEnableCheck().add(checkFactory
-
.createWindowWithLayerViewPanelMustBeActiveCheck());
- }
+ public MultiEnableCheck createEnableCheck(
+ final WorkbenchContext workbenchContext) {
+ EnableCheckFactory checkFactory = new EnableCheckFactory(workbenchContext);
+
+ return new MultiEnableCheck().add(checkFactory
+ .createWindowWithLayerViewPanelMustBeActiveCheck());
+ }
}
\ No newline at end of file
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel