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.factory;
010:
011: import java.util.Arrays;
012:
013: import net.refractions.udig.project.command.NavCommand;
014: import net.refractions.udig.project.internal.command.navigation.NavComposite;
015: import net.refractions.udig.project.internal.command.navigation.PanCommand;
016: import net.refractions.udig.project.internal.command.navigation.SetViewportBBoxCommand;
017: import net.refractions.udig.project.internal.command.navigation.SetViewportCenterCommand;
018: import net.refractions.udig.project.internal.command.navigation.SetViewportHeight;
019: import net.refractions.udig.project.internal.command.navigation.SetViewportWidth;
020: import net.refractions.udig.project.internal.command.navigation.ZoomCommand;
021: import net.refractions.udig.project.internal.command.navigation.ZoomExtentCommand;
022:
023: import org.opengis.referencing.crs.CoordinateReferenceSystem;
024:
025: import com.vividsolutions.jts.geom.Coordinate;
026: import com.vividsolutions.jts.geom.Envelope;
027:
028: /**
029: * API comment me TODO provide type description
030: *
031: * @author jeichar
032: * @since TODO provide version
033: */
034: @SuppressWarnings("deprecation")
035: public class NavigationCommandFactory extends
036: net.refractions.udig.project.command.NavigationCommandFactory {
037: /**
038: * Creates a new NavigationCommandFactory object
039: *
040: * @return a new NavigationCommandFactory object
041: */
042: public static NavigationCommandFactory getInstance() {
043: return instance;
044: }
045:
046: private static final NavigationCommandFactory instance = new NavigationCommandFactory();
047:
048: protected NavigationCommandFactory() {
049: // no op
050: }
051:
052: /**
053: * Creates a new {@linkplain NavComposite}
054: *
055: * @param commands an array of commands to execute as a simgle command. The array will be
056: * executed from position 0 to position length-1 in order.
057: * @return a new NavComposite object
058: * @see NavCommand
059: */
060: public NavCommand createCompositeCommand(NavCommand[] commands) {
061: return new NavComposite(Arrays.asList(commands));
062: }
063:
064: /**
065: * Creates a new {@linkplain SetViewportBBoxCommand}
066: *
067: * @param newbbox the new bounding box to set in the viewport
068: * @return a new SetViewportBBoxCommand object
069: * @see NavCommand
070: * @see Envelope
071: */
072: public NavCommand createSetViewportBBoxCommand(Envelope newbbox) {
073: return new SetViewportBBoxCommand(newbbox);
074: }
075:
076: /**
077: * Creates a new {@linkplain ZoomCommand}
078: *
079: * @param zoomfactor the amount to zoom
080: * @return a new ZoomCommand object
081: * @see NavCommand
082: */
083: public NavCommand createZoomCommand(double zoomfactor) {
084: return new ZoomCommand(zoomfactor);
085: }
086:
087: /**
088: * Creates a new {@linkplain ZoomExtentCommand}
089: *
090: * @return a new ZoomExtentCommand object
091: * @see NavCommand
092: */
093: public NavCommand createZoomExtentCommand() {
094: return new ZoomExtentCommand();
095: }
096:
097: /**
098: * Creates a new {@linkplain SetViewportCenterCommand}
099: *
100: * @param center Sets the center of the viewport. The Coordinate must be in world coordinates.
101: * @return a new SetViewportCenterCommand object
102: * @see NavCommand
103: * @see Coordinate
104: */
105: public NavCommand createSetViewportCenterCommand(Coordinate center) {
106: return new SetViewportCenterCommand(center);
107: }
108:
109: /**
110: * Creates a new {@linkplain SetViewportHeight}
111: *
112: * @param height The new viewport height
113: * @return a new SetViewportHeight object
114: * @see NavCommand
115: */
116: public NavCommand createSetViewportHeight(double height) {
117: return new SetViewportHeight(height);
118: }
119:
120: /**
121: * Creates a new {@linkplain SetViewportWidth}
122: *
123: * @param width the new viewport width
124: * @return a new SetViewportWidth object
125: * @see NavCommand
126: */
127: public NavCommand createSetViewportWidth(double width) {
128: return new SetViewportWidth(width);
129: }
130:
131: /**
132: * Creates a new {@linkplain PanCommand}Pans the viewport in terms of pixels on the screen.
133: * Each pixel represents a distance in world coordinates, the x and y distances differ, so a pan
134: * of 8 pixels in the x direction will be translated to a pan of 8*xdistance in the world.
135: *
136: * @param xpixels The amount, in pixels, to pan in the x direction
137: * @param ypixels The amount, in pixels, to pan in the y direction
138: * @return a new PanCommand object
139: * @see NavCommand
140: */
141: public NavCommand createPanCommandUsingScreenCoords(int xpixels,
142: int ypixels) {
143: return new PanCommand(xpixels, ypixels);
144: }
145:
146: /**
147: * Creates a new {@linkplain PanCommand}
148: *
149: * @param x The amount, in world coordinates, to pan in the x direction
150: * @param y The amount, in world coordinates, to pan in the y direction
151: * @return a new PanCommand object
152: * @see NavCommand
153: */
154: public NavCommand createPanCommandUsingWorldCoords(double x,
155: double y) {
156: return new PanCommand(x, y);
157: }
158:
159: public NavCommand createSetViewportBBoxCommand(Envelope bounds,
160: CoordinateReferenceSystem crs) {
161: return new SetViewportBBoxCommand(bounds, crs);
162: }
163:
164: }
|