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.Collection;
012: import java.util.List;
013:
014: import net.refractions.udig.catalog.IGeoResource;
015: import net.refractions.udig.project.ILayer;
016: import net.refractions.udig.project.IMap;
017: import net.refractions.udig.project.command.UndoableMapCommand;
018: import net.refractions.udig.project.internal.Layer;
019: import net.refractions.udig.project.internal.Map;
020: import net.refractions.udig.project.internal.Project;
021: import net.refractions.udig.project.internal.commands.AddLayerCommand;
022: import net.refractions.udig.project.internal.commands.AddLayersCommand;
023: import net.refractions.udig.project.internal.commands.ChangeCRSCommand;
024: import net.refractions.udig.project.internal.commands.CreateMapCommand;
025: import net.refractions.udig.project.internal.commands.DeleteLayerCommand;
026: import net.refractions.udig.project.internal.commands.SetApplicabilityCommand;
027:
028: import org.opengis.referencing.crs.CoordinateReferenceSystem;
029:
030: /**
031: * Creates Edit commands which must be used to modify editable feature data. API internal classes
032: * are in the returned API
033: *
034: * @author jeichar
035: * @since 0.3
036: */
037: @SuppressWarnings("deprecation")
038: public class BasicCommandFactory extends
039: net.refractions.udig.project.command.BasicCommandFactory {
040: /**
041: * Creates a new EditCommandFactory object
042: *
043: * @return a new EditCommandFactory object
044: */
045: public static BasicCommandFactory getInstance() {
046: return instance;
047: }
048:
049: private static final BasicCommandFactory instance = new BasicCommandFactory();
050:
051: protected BasicCommandFactory() {
052: // no op
053: }
054:
055: /**
056: * Create a delete layer command
057: *
058: * @param map the map containing the layer
059: * @param layer the layer to delete
060: * @return a new {@linkplain DeleteLayerCommand}object that deletes the layer.
061: * @see DeleteLayerCommand
062: */
063: public UndoableMapCommand createDeleteLayer(ILayer layer) {
064: return new DeleteLayerCommand((Layer) layer);
065: }
066:
067: /**
068: * Create an Add Layer command
069: *
070: * @param layer the layer to add to the map.
071: * @return a new {@linkplain AddLayerCommand}object that deletes the feature.
072: * @see AddLayerCommand
073: */
074: public UndoableMapCommand createAddLayer(ILayer layer) {
075: return new AddLayerCommand((Layer) layer);
076: }
077:
078: /**
079: * Create an Add Layer command
080: *
081: * @param layer the layer to add to the map.
082: * @param index the zorder where the layer will be added.
083: * @return a new {@linkplain AddLayerCommand}object that deletes the feature.
084: * @see AddLayerCommand
085: */
086: public UndoableMapCommand createAddLayer(ILayer layer, int index) {
087: return new AddLayerCommand((Layer) layer, index);
088: }
089:
090: /**
091: * Create an AddLayers command that adds all the layers in the collection
092: *
093: * @param evaluationObject the layer to add to the map.
094: * @param index the zorder where the layer will be added.
095: * @return a new {@linkplain AddLayersCommand}object that deletes the feature.
096: * @see AddLayersCommand
097: */
098: public UndoableMapCommand createAddManyLayers(Collection layers,
099: int index) {
100: return new AddLayersCommand(layers, index);
101: }
102:
103: /**
104: * Create an AddLayers command that adds all the layers in the collection
105: *
106: * @param evaluationObject the layer to add to the map.
107: * @return a new {@linkplain AddLayersCommand}object that deletes the feature.
108: * @see AddLayersCommand
109: */
110: public UndoableMapCommand createAddManyLayers(Collection layers) {
111: return new AddLayersCommand(layers);
112: }
113:
114: /**
115: * Create a Change CRS command
116: *
117: * @param map the map for which the CRS is going to change.
118: * @return a new {@linkplain ChangeCRSCommand}object that changes the CRS.
119: * @see ChangeCRSCommand
120: */
121: public UndoableMapCommand createChangeCRS(IMap map,
122: CoordinateReferenceSystem crs) {
123: return new ChangeCRSCommand((Map) map, crs);
124: }
125:
126: /**
127: * Create a CreateMapCommand
128: *
129: * @param name the name of the map
130: * @param layerResources the IGeoResources that will make up the layers of the map.
131: * @param owner The project that will contain the map.
132: * @return
133: */
134: public UndoableMapCommand createCreateMapCommand(String name,
135: List<IGeoResource> layerResources, Project owner) {
136: return new CreateMapCommand(name, layerResources, owner);
137: }
138:
139: /**
140: * Create a CreateMapCommand
141: *
142: * @param layerResources the IGeoResources that will make up the layers of the map.
143: * @param owner The project that will contain the map.
144: * @return
145: */
146: public UndoableMapCommand createCreateMapCommand(
147: List<IGeoResource> layerResources, Project owner) {
148: return new CreateMapCommand(null, layerResources, owner);
149: }
150:
151: /**
152: * Create a CreateMapCommand
153: *
154: * @param name the name of the map
155: * @param layerResources the IGeoResources that will make up the layers of the map.
156: * @return
157: */
158: public UndoableMapCommand createCreateMapCommand(String name,
159: List<IGeoResource> layerResources) {
160: return new CreateMapCommand(name, layerResources, null);
161: }
162:
163: /**
164: * Create a CreateMapCommand
165: *
166: * @param layerResources the objects, (Layers or IGeoResources) that will make up the map.
167: * @return
168: */
169: public UndoableMapCommand createCreateMapCommand(
170: List<IGeoResource> layerResources) {
171: return new CreateMapCommand(null, layerResources, null);
172: }
173:
174: public UndoableMapCommand createSetApplicabilityCommand(
175: ILayer layer, String applicabilityId, boolean newValue) {
176: return new SetApplicabilityCommand(layer, applicabilityId,
177: newValue);
178: }
179:
180: }
|