001: /*
002: * uDig - User Friendly Desktop Internet GIS client http://udig.refractions.net (C) 2004,
003: * Refractions Research Inc. This library is free software; you can redistribute it and/or modify it
004: * under the terms of the GNU Lesser General Public License as published by the Free Software
005: * Foundation; version 2.1 of the License. This library is distributed in the hope that it will be
006: * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
007: * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
008: */
009: package net.refractions.udig.project.command;
010:
011: import java.util.Arrays;
012:
013: import net.refractions.udig.project.internal.command.navigation.NavComposite;
014: import net.refractions.udig.project.internal.command.navigation.PanCommand;
015: import net.refractions.udig.project.internal.command.navigation.SetViewportBBoxCommand;
016: import net.refractions.udig.project.internal.command.navigation.SetViewportCenterCommand;
017: import net.refractions.udig.project.internal.command.navigation.SetViewportHeight;
018: import net.refractions.udig.project.internal.command.navigation.SetViewportWidth;
019: import net.refractions.udig.project.internal.command.navigation.ZoomCommand;
020: import net.refractions.udig.project.internal.command.navigation.ZoomExtentCommand;
021:
022: import org.opengis.referencing.crs.CoordinateReferenceSystem;
023:
024: import com.vividsolutions.jts.geom.Coordinate;
025: import com.vividsolutions.jts.geom.Envelope;
026:
027: /**
028: * API comment me TODO provide type description
029: *
030: * @author jeichar
031: * @deprecated
032: * @since TODO provide version
033: */
034: public class NavigationCommandFactory {
035: /**
036: * Creates a new NavigationCommandFactory object
037: *
038: * @return a new NavigationCommandFactory object
039: */
040: public static NavigationCommandFactory getInstance() {
041: return instance;
042: }
043:
044: private static final NavigationCommandFactory instance = new NavigationCommandFactory();
045:
046: protected NavigationCommandFactory() {
047: // no op
048: }
049:
050: /**
051: * Creates a new {@linkplain NavComposite}
052: *
053: * @param commands an array of commands to execute as a simgle command. The array will be
054: * executed from position 0 to position length-1 in order.
055: * @return a new NavComposite object
056: * @see NavCommand
057: */
058: public NavCommand createCompositeCommand(NavCommand[] commands) {
059: return new NavComposite(Arrays.asList(commands));
060: }
061:
062: /**
063: * Creates a new {@linkplain SetViewportBBoxCommand}
064: *
065: * @param newbbox the new bounding box to set in the viewport
066: * @return a new SetViewportBBoxCommand object
067: * @see NavCommand
068: * @see Envelope
069: */
070: public NavCommand createSetViewportBBoxCommand(Envelope newbbox) {
071: return new SetViewportBBoxCommand(newbbox);
072: }
073:
074: /**
075: * Creates a new {@linkplain ZoomCommand}
076: *
077: * @param zoomfactor the amount to zoom
078: * @return a new ZoomCommand object
079: * @see NavCommand
080: */
081: public NavCommand createZoomCommand(double zoomfactor) {
082: return new ZoomCommand(zoomfactor);
083: }
084:
085: /**
086: * Creates a new {@linkplain ZoomExtentCommand}
087: *
088: * @return a new ZoomExtentCommand object
089: * @see NavCommand
090: */
091: public NavCommand createZoomExtentCommand() {
092: return new ZoomExtentCommand();
093: }
094:
095: /**
096: * Creates a new {@linkplain SetViewportCenterCommand}
097: *
098: * @param center Sets the center of the viewport. The Coordinate must be in world coordinates.
099: * @return a new SetViewportCenterCommand object
100: * @see NavCommand
101: * @see Coordinate
102: */
103: public NavCommand createSetViewportCenterCommand(Coordinate center) {
104: return new SetViewportCenterCommand(center);
105: }
106:
107: /**
108: * Creates a new {@linkplain SetViewportHeight}
109: *
110: * @param height The new viewport height
111: * @return a new SetViewportHeight object
112: * @see NavCommand
113: */
114: public NavCommand createSetViewportHeight(double height) {
115: return new SetViewportHeight(height);
116: }
117:
118: /**
119: * Creates a new {@linkplain SetViewportWidth}
120: *
121: * @param width the new viewport width
122: * @return a new SetViewportWidth object
123: * @see NavCommand
124: */
125: public NavCommand createSetViewportWidth(double width) {
126: return new SetViewportWidth(width);
127: }
128:
129: /**
130: * Creates a new {@linkplain PanCommand}Pans the viewport in terms of pixels on the screen.
131: * Each pixel represents a distance in world coordinates, the x and y distances differ, so a pan
132: * of 8 pixels in the x direction will be translated to a pan of 8*xdistance in the world.
133: *
134: * @param xpixels The amount, in pixels, to pan in the x direction
135: * @param ypixels The amount, in pixels, to pan in the y direction
136: * @return a new PanCommand object
137: * @see NavCommand
138: */
139: public NavCommand createPanCommandUsingScreenCoords(int xpixels,
140: int ypixels) {
141: return new PanCommand(xpixels, ypixels);
142: }
143:
144: /**
145: * Creates a new {@linkplain PanCommand}
146: *
147: * @param x The amount, in world coordinates, to pan in the x direction
148: * @param y The amount, in world coordinates, to pan in the y direction
149: * @return a new PanCommand object
150: * @see NavCommand
151: */
152: public NavCommand createPanCommandUsingWorldCoords(double x,
153: double y) {
154: return new PanCommand(x, y);
155: }
156:
157: public NavCommand createSetViewportBBoxCommand(Envelope bounds,
158: CoordinateReferenceSystem crs) {
159: return new SetViewportBBoxCommand(bounds, crs);
160: }
161:
162: }
|