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.List;
012:
013: import net.refractions.udig.project.ILayer;
014: import net.refractions.udig.project.internal.commands.selection.BBoxSelectionCommand;
015: import net.refractions.udig.project.internal.commands.selection.FIDSelectCommand;
016: import net.refractions.udig.project.internal.commands.selection.NoSelectCommand;
017: import net.refractions.udig.project.internal.commands.selection.SelectCommand;
018:
019: import org.geotools.feature.Feature;
020: import org.geotools.filter.Filter;
021:
022: import com.vividsolutions.jts.geom.Envelope;
023:
024: /**
025: * A factory which can be used to create all the standard selection commands.
026: *
027: * API use
028: *
029: * @author jeichar
030: * @deprecated
031: * @since 0.3
032: */
033: public class SelectionCommandFactory {
034: /**
035: * Creates a new SelectionCommandFactory object
036: *
037: * @return a new SelectionCommandFactory object
038: */
039: public static SelectionCommandFactory getInstance() {
040: return instance;
041: }
042:
043: private static final SelectionCommandFactory instance = new SelectionCommandFactory();
044:
045: protected SelectionCommandFactory() {
046: // no op;
047: }
048:
049: /**
050: * Creates a new {@linkplain BBoxSelectionCommand}
051: *
052: * @param bbox A bounding used as the filter, all features intersecting the bbox will be
053: * considered selected
054: * @param modifiers Options include: BBoxSelectionCommand.ADD, BBoxSelectionCommand.NONE,
055: * BBoxSelectionCommand.SUBTRACT
056: * @return A new BBoxSelectionCommand. The command should be sent to the
057: * {@linkplain SelectionManager}to be executed.
058: * @see Envelope
059: * @see MapCommand
060: */
061: public MapCommand createBBoxSelectionCommand(Envelope bbox,
062: int modifiers) {
063: return new BBoxSelectionCommand(bbox, modifiers);
064: }
065:
066: /**
067: * Creates a new {@linkplain BBoxSelectionCommand}.
068: * Same as createBBoxSelectionCommand(bbox, BBoxSelectionCommand.NONE)
069: *
070: * @param bbox A bounding used as the filter, all features intersecting the bbox will be
071: * considered selected
072: * @return A new BBoxSelectionCommand. The command should be sent to the
073: * {@linkplain SelectionManager}to be executed.
074: * @see Envelope
075: * @see MapCommand
076: */
077: public MapCommand createBBoxSelectionCommand(Envelope boundingBox) {
078: return new BBoxSelectionCommand(boundingBox,
079: BBoxSelectionCommand.NONE);
080: }
081:
082: /**
083: * Creates a {@linkplain NoSelectCommand}
084: *
085: * @return a {@linkplain NoSelectCommand}object. The command should be sent to the
086: * {@linkplain SelectionManager}to be executed.
087: * @see MapCommand
088: */
089: public MapCommand createNoSelectCommand() {
090: return new NoSelectCommand();
091: }
092:
093: /**
094: * Create a MapCommand that sets the layer selection to be a fidfilter.
095: *
096: * @return a {@linkplain FIDSelectCommand}
097: * @see MapCommand
098: */
099: public MapCommand createFIDSelectCommand(ILayer layer, String fid) {
100: return new FIDSelectCommand(layer, fid);
101: }
102:
103: /**
104: * Create a MapCommand that sets the layer selection to be a fidfilter.
105: *
106: * @return a {@linkplain FIDSelectCommand}
107: * @see MapCommand
108: */
109: public MapCommand createFIDSelectCommand(ILayer layer,
110: Feature feature) {
111: return new FIDSelectCommand(layer, feature.getID());
112: }
113:
114: /**
115: * Create a MapCommand that sets the layer selection to be the filter.
116: *
117: * @return a {@linkplain SelectCommand}
118: * @see MapCommand
119: */
120: public MapCommand createSelectCommand(ILayer layer, Filter filter) {
121: return new SelectCommand(layer, filter);
122: }
123:
124: /**
125: * Create a CompositeCommand
126: *
127: * @param commands the commands to be executed as a single command
128: * @return a {@linkplain CompositeCommand}
129: * @see MapCommand
130: */
131: public MapCommand createCompositeCommand(
132: List<? extends MapCommand> commands) {
133: return new CompositeCommand(commands);
134: }
135:
136: /**
137: * Create a CompositeCommand
138: *
139: * @param commands the commands to be executed as a single command
140: * @return a {@linkplain CompositeCommand}
141: * @see MapCommand
142: */
143: public MapCommand createUndoableCompositeCommand(
144: List<? extends UndoableMapCommand> commands) {
145: return new UndoableComposite(commands);
146: }
147:
148: }
|