store = editLayer
+ .getResource(FeatureStore.class, null);
transform();
if (store.getTransaction() == Transaction.AUTO_COMMIT) {
throw new Exception("Error transaction has not been started"); //$NON-NLS-1$
}
final SimpleFeatureType type = store.getSchema();
- // Object[] attrs = new Object[type.getAttributeCount()];
- // for( int i = 0; i < attrs.length; i++ ) {
- // attrs[i] = toDefaultValue(type.getDescriptor(i));
- // }
- //
- // final SimpleFeature newFeature = SimpleFeatureBuilder.build(type, attrs, "newFeature"
- // + new Random().nextInt());
-
- String proposedFid = "newFeature"+"newFeature" + new Random().nextInt();
- final SimpleFeature newFeature = SimpleFeatureBuilder.template(type, proposedFid );
+ String proposedFid = "newFeature" + "newFeature" + new Random().nextInt(); //$NON-NLS-1$ //$NON-NLS-2$
+ final SimpleFeature newFeature = SimpleFeatureBuilder.template(type, proposedFid);
Class geomType = type.getGeometryDescriptor().getType().getBinding();
Geometry geom = GeometryBuilder.create().safeCreateGeometry(geomType, coordinates);
@@ -119,21 +107,22 @@ public void run( IProgressMonitor monitor ) throws Exception {
fid = newFeature.getID();
SimpleFeature feature = new AdaptableFeature(newFeature, editLayer);
-
+
runFeatureCreationInterceptors(feature);
map.getEditManagerInternal().addFeature(newFeature, (Layer) editLayer);
}
+
/**
* Retrieves a default value for the provided descriptor.
*
* The descriptor getDefaultValue() is used if available; if not a default value is created base
* on the descriptor binding. The default values mirror those used by Java; empty string,
* boolean false, 0 integer, 0.0 double, etc... >p>
- *
+ *
* @param type attribute descriptor
*/
- private Object toDefaultValue( AttributeDescriptor type ) {
+ private Object toDefaultValue(AttributeDescriptor type) {
if (type.getDefaultValue() != null) {
return type.getDefaultValue();
}
@@ -167,9 +156,10 @@ private Layer findEditLayer() {
if (map.getEditManagerInternal().getEditLayerInternal() != null) {
return map.getEditManagerInternal().getEditLayerInternal();
}
- for( Iterator iter = map.getLayersInternal().iterator(); iter.hasNext(); ) {
+ for (Iterator iter = map.getLayersInternal().iterator(); iter.hasNext();) {
layer = iter.next();
- if (layer.hasResource(FeatureStore.class) && layer.isSelectable() && layer.isVisible()) {
+ if (layer.hasResource(FeatureStore.class) && layer.getInteraction(Interaction.SELECT)
+ && layer.isVisible()) {
break;
}
}
@@ -178,61 +168,59 @@ private Layer findEditLayer() {
/**
* Transforms coordinates into the layer CRS if required
- *
+ *
* @throws Exception
*/
private void transform() throws Exception {
ILayer editLayer = getMap().getEditManager().getEditLayer();
- if (map.getViewportModel().getCRS().equals(editLayer.getCRS(null))) {
+ if (map.getViewportModel().getCRS().equals(editLayer.getCRS())) {
return;
}
- MathTransform mt = CRS.findMathTransform(map.getViewportModel().getCRS(), editLayer
- .getCRS(), true);
+ MathTransform mt = CRS.findMathTransform(map.getViewportModel().getCRS(),
+ editLayer.getCRS(), true);
if (mt == null || mt.isIdentity()) {
return;
}
double[] coords = new double[coordinates.length * 2];
- for( int i = 0; i < coordinates.length; i++ ) {
+ for (int i = 0; i < coordinates.length; i++) {
coords[i * 2] = coordinates[i].x;
coords[i * 2 + 1] = coordinates[i].y;
}
mt.transform(coords, 0, coords, 0, coordinates.length);
- for( int i = 0; i < coordinates.length; i++ ) {
+ for (int i = 0; i < coordinates.length; i++) {
coordinates[i].x = coords[i * 2];
coordinates[i].y = coords[i * 2 + 1];
}
}
+ @Override
public MapCommand copy() {
return new CreateFeatureCommand(coordinates);
}
- /**
- * @see org.locationtech.udig.project.command.MapCommand#getName()
- */
+ @Override
public String getName() {
return Messages.CreateFeatureCommand_createFeature;
}
- /**
- * @see org.locationtech.udig.project.command.UndoableCommand#rollback()
- */
- public void rollback( IProgressMonitor monitor ) throws Exception {
+ @Override
+ public void rollback(IProgressMonitor monitor) throws Exception {
ILayer editLayer = getMap().getEditManager().getEditLayer();
- FilterFactory filterFactory = CommonFactoryFinder.getFilterFactory(GeoTools
- .getDefaultHints());
- editLayer.getResource(FeatureStore.class, null).removeFeatures(
- filterFactory.id(FeatureUtils.stringToId(filterFactory, fid)));
+ FilterFactory filterFactory = CommonFactoryFinder
+ .getFilterFactory(GeoTools.getDefaultHints());
+ editLayer.getResource(FeatureStore.class, null)
+ .removeFeatures(filterFactory.id(FeatureUtils.stringToId(filterFactory, fid)));
}
- public static void runFeatureCreationInterceptors( Feature feature ) {
+
+ public static void runFeatureCreationInterceptors(Feature feature) {
List interceptors = ExtensionPointList
.getExtensionPointList(FeatureInterceptor.EXTENSION_ID);
- for( IConfigurationElement element : interceptors ) {
- String id = element.getAttribute("id");
+ for (IConfigurationElement element : interceptors) {
+ String id = element.getAttribute("id"); //$NON-NLS-1$
if (FeatureInterceptor.CREATED_ID.equals(element.getName())) {
try {
FeatureInterceptor interceptor = (FeatureInterceptor) element
- .createExecutableExtension("class");
+ .createExecutableExtension("class"); //$NON-NLS-1$
interceptor.run(feature);
} catch (Exception e) {
ProjectPlugin.log("FeatureInterceptor " + id + ":" + e, e);
diff --git a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/impl/LayerImpl.java b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/impl/LayerImpl.java
index 83d349c982..fcc8c5170e 100644
--- a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/impl/LayerImpl.java
+++ b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/impl/LayerImpl.java
@@ -242,7 +242,6 @@ private void raiseEvents(Notification msg) {
}
}
- @SuppressWarnings("unchecked")
private void registerWithContainers(Notification msg) {
// register itself with container objects
switch (msg.getEventType()) {
@@ -343,7 +342,7 @@ public void changed(FeatureEvent featureEvent) {
CopyOnWriteArraySet listeners = new CopyOnWriteArraySet<>();
/**
- * Ensures that a warning about georesources not found is only logged once
+ * Ensures that a warning about GeoResources not found is only logged once
*/
private volatile boolean warned = false;
@@ -358,7 +357,7 @@ public void changed(FeatureEvent featureEvent) {
private final Lock geoResourceCacheLock = new UDIGDisplaySafeLock();
/**
- * indicates whether or not the CRS is a known CRS (the georesources return null when asked for
+ * indicates whether or not the CRS is a known CRS (the GeoResources return null when asked for
* a CRS). If null then it has not been computed yet. if false and crsLoader !=null then it is
* being computed.
*/
@@ -366,7 +365,7 @@ public void changed(FeatureEvent featureEvent) {
/**
* Used in {@link #isUnknownCRS()} to lazily compute the CRS. If null and unknownCRS is null
- * then the crs has not been computed. if not null then the computatin is taking place.
+ * then the CRS has not been computed. if not null then the computation is taking place.
*/
private volatile ISafeRunnable crsLoader;
@@ -389,19 +388,11 @@ protected void finalize() throws Throwable {
CatalogPlugin.removeListener(this);
}
- /*
- * @see
- * org.locationtech.udig.project.Layer#addListener(org.locationtech.udig.project.LayerListener)
- */
@Override
public void addListener(final ILayerListener listener) {
listeners.add(listener);
}
- /*
- * @see org.locationtech.udig.project.Layer#removeListener(org.locationtech.udig.project.
- * LayerListener)
- */
@Override
public void removeListener(final ILayerListener listener) {
listeners.remove(listener);
@@ -505,7 +496,6 @@ public int getZorder() {
* @generated NOT
*/
@Override
- @SuppressWarnings("unchecked")
public void setZorder(int newZorder) {
if (getContextModel() == null || getMapInternal().getLayersInternal() == null) {
return;
@@ -646,8 +636,11 @@ public void setVisible(boolean newVisible) {
* New implementation of the method:
*
* getGeoResource() is a blocking method but it must not block UI thread. With this purpose the
- * new imlementation is done to avoid UI thread blocking because of synchronization.
+ * new implementation is done to avoid UI thread blocking because of synchronization.
+ *
+ *
+ *
+ *
*
* @uml.property name="geoResources"
* @generated NOT
@@ -1069,24 +1062,6 @@ public void setGlyph(ImageDescriptor icon) {
setIcon(icon);
}
- /**
- * @deprecated use getInteraction(Interaction.SELECT)
- */
- @Deprecated
- @Override
- public boolean isSelectable() {
- return getInteraction(Interaction.SELECT);
- }
-
- /**
- * @deprecated use setInteraction(Interaction.SELECT, value)
- */
- @Deprecated
- @Override
- public void setSelectable(boolean newSelectable) {
- setInteraction(Interaction.SELECT, newSelectable);
- }
-
/**
*
*
@@ -1412,9 +1387,6 @@ public Query getQuery(boolean selection) {
private volatile String statusMessage = Messages.LayerImpl_status;
- /**
- * @see org.locationtech.udig.project.internal.Layer#getSchema()
- */
@Override
public SimpleFeatureType getSchema() {
FeatureSource data;
@@ -1426,41 +1398,14 @@ public SimpleFeatureType getSchema() {
} catch (IOException e) {
ProjectPlugin.log(null, e);
}
- // XXX: rgould how do I process a getWMS().createDescribeLayerRequest()?
-
- // URL wfsURL = null;
- //
- // try {
- // DescribeLayerRequest request = null;
- // request = getWMS().createDescribeLayerRequest();
- // request.setLayers(getName());
- // DescribeLayerResponse response = (DescribeLayerResponse)
- // getWMS().issueRequest(request);
- // wfsURL = response.getLayerDescs()[0].getWfs();
- // } catch (SAXException e1) {
- // // TODO Catch e1
- // } catch (UnsupportedOperationException e) {
- // // TODO Catch e
- // } catch (IOException e) {
- // // TODO Catch e
- // }
-
- // WFS URL now possibly has a URL
-
return null;
}
- /**
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
@Override
public int compareTo(ILayer arg0) {
return doComparison(this, arg0);
}
- /**
- * @see org.locationtech.udig.project.internal.Layer#getInteraction(java.lang.String)
- */
@Override
public boolean getInteraction(Interaction interaction) {
// special cases handled as fields
@@ -1494,9 +1439,6 @@ protected boolean getDefaultApplicable(Interaction interaction) {
return false;
}
- /**
- * @see org.locationtech.udig.project.internal.Layer#setInteraction(java.lang.String, boolean)
- */
@Override
public void setInteraction(Interaction interaction, boolean applicable) {
if (Interaction.VISIBLE.equals(interaction)) {
@@ -1513,7 +1455,10 @@ public void setInteraction(Interaction interaction, boolean applicable) {
*/
@Override
public CoordinateReferenceSystem getCRS() {
- return getCRS(null);
+ if (cRS == null) {
+ return UNKNOWN_CRS;
+ }
+ return cRS;
}
/**
@@ -1538,7 +1483,6 @@ public void setCRS(CoordinateReferenceSystem newCRS) {
/**
*
- *
* @generated
*/
public void setCRSGen(CoordinateReferenceSystem newCRS) {
@@ -1763,9 +1707,6 @@ public void setShown(boolean newShown) {
oldShown, shown));
}
- /**
- * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
- */
@Override
@SuppressWarnings("unchecked")
public Object getAdapter(final Class adapter) {
@@ -1812,7 +1753,7 @@ public Object getAdapter(final Class adapter) {
}
}
- /*
+ /**
* Adapt to an IWorkbenchAdapter. Other aspects of Eclipse can read the properties we
* provide access to. (example: Property page dialogs can read the label and display that in
* their title.)
@@ -1831,14 +1772,6 @@ public String getLabel(Object object) {
return Platform.getAdapterManager().getAdapter(this, adapter);
}
- @Override
- public CoordinateReferenceSystem getCRS(IProgressMonitor monitor) {
-
- if (cRS != null)
- return cRS;
- return getCRSInternal(monitor);
- }
-
/**
*
*
@@ -2147,34 +2080,6 @@ public boolean eIsSet(int featureID) {
return super.eIsSet(featureID);
}
- /**
- * queries the georesources for a CRS
- *
- * @param monitor
- * @return
- */
- private CoordinateReferenceSystem getCRSInternal(IProgressMonitor monitor) {
- try {
- CoordinateReferenceSystem crs = getGeoResource().getInfo(monitor).getCRS();
- if (crs != null)
- return crs;
- } catch (Exception e) {
- ProjectPlugin.log(null, e);
- }
-
- List list = getGeoResources();
- for (IGeoResource resource : list) {
- try {
- if (resource.getInfo(monitor).getCRS() != null)
- return resource.getInfo(monitor).getCRS();
- } catch (Exception e) {
- ProjectPlugin.log(null, e);
- }
- }
-
- return UNKNOWN_CRS;
- }
-
@Override
public void refresh(Envelope bounds) {
if (!isVisible())
@@ -2308,7 +2213,7 @@ public IGeoResourceInfo call() throws Exception {
/**
* Creates A geometry filter for the given layer.
*
- * @param boundingBox in the same crs as the viewport model.
+ * @param boundingBox in the same CRS as the viewport model.
* @return a Geometry filter in the correct CRS or null if an exception occurs.
*/
@Override
@@ -2337,9 +2242,6 @@ public Filter createBBoxFilter(Envelope boundingBox, IProgressMonitor monitor) {
return bboxFilter;
}
- /**
- * @see org.locationtech.udig.project.internal.Layer#getMap()
- */
@Override
public org.locationtech.udig.project.internal.Map getMapInternal() {
ContextModel context = getContextModel();
@@ -2348,18 +2250,11 @@ public org.locationtech.udig.project.internal.Map getMapInternal() {
return context.getMap();
}
- /**
- * @see org.locationtech.udig.project.ILayer#getMap()
- */
@Override
public IMap getMap() {
return getMapInternal();
}
- /**
- * @see org.locationtech.udig.core.IBlockingAdaptable#getAdapter(java.lang.Class,
- * org.eclipse.core.runtime.IProgressMonitor)
- */
@Override
public T getAdapter(final Class adapter, IProgressMonitor monitor) throws IOException {
if (hasResource(adapter)) {
@@ -2369,14 +2264,11 @@ public T getAdapter(final Class adapter, IProgressMonitor monitor) throws
return list.get(0);
}
if (adapter.isAssignableFrom(CoordinateReferenceSystem.class)) {
- return adapter.cast(getCRS(monitor));
+ return adapter.cast(getCRS());
}
return null;
}
- /**
- * @see org.locationtech.udig.core.IBlockingAdaptable#canAdaptTo(java.lang.Class)
- */
@Override
public boolean canAdaptTo(Class adapter) {
return hasResource(adapter) || adapter.isAssignableFrom(CoordinateReferenceSystem.class);
diff --git a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/impl/MapImpl.java b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/impl/MapImpl.java
index 4353d78275..c3468f2ebf 100644
--- a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/impl/MapImpl.java
+++ b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/impl/MapImpl.java
@@ -1,4 +1,5 @@
-/* uDig - User Friendly Desktop Internet GIS client
+/**
+ * uDig - User Friendly Desktop Internet GIS client
* http://udig.refractions.net
* (C) 2004-2012, Refractions Research Inc.
*
@@ -59,6 +60,7 @@
import org.locationtech.udig.project.IMapCompositionListener;
import org.locationtech.udig.project.IMapListener;
import org.locationtech.udig.project.IProject;
+import org.locationtech.udig.project.Interaction;
import org.locationtech.udig.project.command.Command;
import org.locationtech.udig.project.command.CommandListener;
import org.locationtech.udig.project.command.CommandManager;
@@ -112,6 +114,7 @@
* Project element used by MapEditorInput.
*
* For more information please see *org.locationtech.udig.project.internal.ui.mapEditorInput*.
+ *
*
* @author Jesse
* @since 1.0.0
@@ -122,9 +125,9 @@ public class MapImpl extends EObjectImpl implements Map {
private static final String ERROR_EXECUTING_COMMAND = "Error executing command: ";
/**
- * The default value of the '{@link #getName() Name}' attribute.
- *
+ *
* @see #getName()
* @generated NOT
* @ordered
@@ -132,9 +135,9 @@ public class MapImpl extends EObjectImpl implements Map {
protected static final String NAME_EDEFAULT = "";
/**
- * The cached value of the '{@link #getName() Name}' attribute.
- *
+ * The cached value of the '{@link #getName() Name}' attribute.
+ *
+ *
* @see #getName()
* @generated NOT
* @ordered
@@ -144,6 +147,7 @@ public class MapImpl extends EObjectImpl implements Map {
/**
* The cached value of the '{@link #getProjectInternal() Project Internal}' reference.
*
+ *
* @see #getProjectInternal()
* @generated not
* @ordered
@@ -151,8 +155,9 @@ public class MapImpl extends EObjectImpl implements Map {
protected volatile Project projectInternal = null;
/**
- * The cached value of the '{@link #getContextModel() Context Model}' containment reference.
- *
+ * The cached value of the '{@link #getContextModel() Context Model}' containment
+ * reference.
+ *
* @see #getContextModel()
* @generated not
* @ordered
@@ -180,8 +185,9 @@ public class MapImpl extends EObjectImpl implements Map {
protected volatile String abstract_ = ABSTRACT_EDEFAULT;
/**
- * The default value of the '{@link #getNavCommandStack() Nav Command Stack}' attribute.
- *
+ * The default value of the '{@link #getNavCommandStack() Nav Command Stack}'
+ * attribute.
+ *
* @see #getNavCommandStack()
* @generated
* @ordered
@@ -189,8 +195,9 @@ public class MapImpl extends EObjectImpl implements Map {
protected static final NavCommandStack NAV_COMMAND_STACK_EDEFAULT = null;
/**
- * The default value of the '{@link #getCommandStack() Command Stack}' attribute.
- *
+ * The default value of the '{@link #getCommandStack() Command Stack}' attribute.
+ *
* @see #getCommandStack()
* @generated
* @ordered
@@ -198,8 +205,9 @@ public class MapImpl extends EObjectImpl implements Map {
protected static final CommandStack COMMAND_STACK_EDEFAULT = null;
/**
- * The cached value of the '{@link #getLayerFactory() Layer Factory}' containment reference.
- *
+ * The cached value of the '{@link #getLayerFactory() Layer Factory}' containment
+ * reference.
+ *
* @see #getLayerFactory()
* @generated not
* @ordered
@@ -207,8 +215,9 @@ public class MapImpl extends EObjectImpl implements Map {
protected volatile LayerFactory layerFactory = null;
/**
- * The cached value of the '{@link #getViewportModelInternal() Viewport Model Internal}' containment reference.
- *
+ * The cached value of the '{@link #getViewportModelInternal() Viewport Model
+ * Internal}' containment reference.
+ *
* @see #getViewportModelInternal()
* @generated not
* @ordered
@@ -216,8 +225,8 @@ public class MapImpl extends EObjectImpl implements Map {
protected volatile ViewportModel viewportModelInternal = null;
/**
- * The default value of the '{@link #getColorPalette() Color Palette}' attribute.
- *
+ * The default value of the '{@link #getColorPalette() Color Palette}' attribute.
*
* @see #getColorPalette()
* @generated NOT
@@ -236,8 +245,9 @@ public class MapImpl extends EObjectImpl implements Map {
protected volatile BrewerPalette colorPalette = null;
/**
- * The cached value of the '{@link #getEditManagerInternal() Edit Manager Internal}' containment reference.
- *
+ * The cached value of the '{@link #getEditManagerInternal() Edit Manager Internal}'
+ * containment reference.
+ *
* @see #getEditManagerInternal()
* @generated not
* @ordered
@@ -245,8 +255,9 @@ public class MapImpl extends EObjectImpl implements Map {
protected volatile EditManager editManagerInternal = null;
/**
- * The cached value of the '{@link #getRenderManagerInternal() Render Manager Internal}' reference.
- *
+ * The cached value of the '{@link #getRenderManagerInternal() Render Manager
+ * Internal}' reference.
+ *
* @see #getRenderManagerInternal()
* @generated not
* @ordered
@@ -254,8 +265,8 @@ public class MapImpl extends EObjectImpl implements Map {
protected volatile RenderManager renderManagerInternal = null;
/**
- * The default value of the '{@link #getColourScheme() Colour Scheme}' attribute.
- *
+ * The default value of the '{@link #getColourScheme() Colour Scheme}' attribute.
*
* @see #getColourScheme()
* @generated NOT
@@ -276,8 +287,9 @@ public class MapImpl extends EObjectImpl implements Map {
protected volatile ColourScheme colourScheme = null;
/**
- * The cached value of the '{@link #getBlackBoardInternal() Black Board Internal}' containment reference.
- *
+ * The cached value of the '{@link #getBlackBoardInternal() Black Board Internal}'
+ * containment reference.
+ *
* @see #getBlackBoardInternal()
* @generated not
* @ordered
@@ -286,8 +298,8 @@ public class MapImpl extends EObjectImpl implements Map {
/**
* The cached value of the '{@link #getLegend() Legend}' containment reference list.
- *
- *
+ *
+ *
* @see #getLegend()
* @generated
* @ordered
@@ -319,6 +331,7 @@ private void addMapListenerAdapter() {
/**
*
+ *
* @generated
*/
@Override
@@ -350,6 +363,7 @@ public Project getProjectInternal() {
/**
*
+ *
* @generated
*/
public Project getProjectInternalGen() {
@@ -368,6 +382,7 @@ public Project getProjectInternalGen() {
/**
*
+ *
* @generated
*/
public Project basicGetProjectInternal() {
@@ -376,6 +391,7 @@ public Project basicGetProjectInternal() {
/**
*
+ *
* @generated
*/
public NotificationChain basicSetProjectInternal(Project newProjectInternal,
@@ -395,6 +411,7 @@ public NotificationChain basicSetProjectInternal(Project newProjectInternal,
/**
*
+ *
* @generated NOT
*/
@Override
@@ -440,6 +457,7 @@ public ContextModel getContextModel() {
/**
*
+ *
* @generated
*/
@SuppressWarnings("deprecation")
@@ -511,6 +529,7 @@ public ViewportModel getViewportModelInternal() {
/**
*
+ *
* @generated
*/
public NotificationChain basicSetViewportModelInternal(ViewportModel newViewportModelInternal,
@@ -545,6 +564,7 @@ public void setViewportModelInternal(ViewportModel newViewportModelInternal) {
/**
*
+ *
* @generated
*/
public void setViewportModelInternalGen(ViewportModel newViewportModelInternal) {
@@ -567,6 +587,7 @@ public void setViewportModelInternalGen(ViewportModel newViewportModelInternal)
/**
*
+ *
* @generated NOT
*/
@Override
@@ -575,7 +596,7 @@ public BrewerPalette getColorPalette() {
String defaultPalette = ProjectPlugin.getPlugin().getPreferenceStore()
.getString(PreferenceConstants.P_DEFAULT_PALETTE);
if (defaultPalette == null || !PlatformGIS.getColorBrewer().hasPalette(defaultPalette))
- defaultPalette = "Dark2"; //failsafe default //$NON-NLS-1$
+ defaultPalette = "Dark2"; // failsafe default //$NON-NLS-1$
colorPalette = PlatformGIS.getColorBrewer().getPalette(defaultPalette);
}
return colorPalette;
@@ -583,6 +604,7 @@ public BrewerPalette getColorPalette() {
/**
*
+ *
* @generated
*/
@Override
@@ -596,6 +618,7 @@ public void setColorPalette(BrewerPalette newColorPalette) {
/**
*
+ *
* @generated
*/
@Override
@@ -605,6 +628,7 @@ public String getAbstract() {
/**
*
+ *
* @generated
*/
@Override
@@ -618,6 +642,7 @@ public void setAbstract(String newAbstract) {
/**
*
+ *
* @generated
*/
@Override
@@ -627,6 +652,7 @@ public String getName() {
/**
*
+ *
* @generated
*/
@Override
@@ -686,7 +712,8 @@ private ReferencedEnvelope getDefaultBounds() {
}
/**
- * Takes an Extent, usually from a {@link CoordinateReferenceSystem}, and converts it to a ReferencedEnvelope
+ * Takes an Extent, usually from a {@link CoordinateReferenceSystem}, and converts it to a
+ * ReferencedEnvelope
*
* @param extent the extent to convert.
* @param crs the desired CRS of the ReferencedEnvelope.
@@ -806,6 +833,7 @@ public LayerFactory getLayerFactory() {
/**
*
+ *
* @generated
*/
public NotificationChain basicSetLayerFactory(LayerFactory newLayerFactory,
@@ -825,6 +853,7 @@ public NotificationChain basicSetLayerFactory(LayerFactory newLayerFactory,
/**
*
+ *
* @generated
*/
@Override
@@ -1020,8 +1049,8 @@ public void forwardHistory() {
}
/**
- *
- *
+ *
+ *
* @generated
*/
@Override
@@ -1065,8 +1094,8 @@ public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID,
}
/**
- *
- *
+ *
+ *
* @generated
*/
@Override
@@ -1094,8 +1123,8 @@ public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID,
}
/**
- *
- *
+ *
+ *
* @generated
*/
@Override
@@ -1138,8 +1167,8 @@ public Object eGet(int featureID, boolean resolve, boolean coreType) {
}
/**
- *
- *
+ *
+ *
* @generated
*/
@SuppressWarnings("unchecked")
@@ -1188,8 +1217,8 @@ public void eSet(int featureID, Object newValue) {
}
/**
- *
- *
+ *
+ *
* @generated
*/
@Override
@@ -1236,8 +1265,8 @@ public void eUnset(int featureID) {
}
/**
- *
- *
+ *
+ *
* @generated
*/
@Override
@@ -1296,6 +1325,7 @@ public EditManager getEditManagerInternal() {
/**
*
+ *
* @generated
*/
public NotificationChain basicSetEditManagerInternal(EditManager newEditManagerInternal,
@@ -1316,6 +1346,7 @@ public NotificationChain basicSetEditManagerInternal(EditManager newEditManagerI
/**
*
+ *
* @generated
*/
@Override
@@ -1339,6 +1370,7 @@ public void setEditManagerInternal(EditManager newEditManagerInternal) {
/**
*
+ *
* @generated
*/
@Override
@@ -1358,6 +1390,7 @@ public RenderManager getRenderManagerInternal() {
/**
*
+ *
* @generated
*/
public RenderManager basicGetRenderManagerInternal() {
@@ -1366,6 +1399,7 @@ public RenderManager basicGetRenderManagerInternal() {
/**
*
+ *
* @generated
*/
public NotificationChain basicSetRenderManagerInternal(RenderManager newRenderManagerInternal,
@@ -1386,6 +1420,7 @@ public NotificationChain basicSetRenderManagerInternal(RenderManager newRenderMa
/**
*
+ *
* @generated
*/
public void setRenderManagerInternalGen(RenderManager newRenderManagerInternal) {
@@ -1451,6 +1486,7 @@ public void setRenderManagerInternal(RenderManager newRenderManager) {
/**
*
+ *
* @generated NOT
*/
@Override
@@ -1463,6 +1499,7 @@ public ColourScheme getColourScheme() {
/**
*
+ *
* @generated
*/
@Override
@@ -1486,6 +1523,7 @@ public IBlackboard getBlackboard() {
/**
*
+ *
* @generated
*/
@Override
@@ -1495,6 +1533,7 @@ public Blackboard getBlackBoardInternal() {
/**
*
+ *
* @generated
*/
public NotificationChain basicSetBlackBoardInternal(Blackboard newBlackBoardInternal,
@@ -1515,6 +1554,7 @@ public NotificationChain basicSetBlackBoardInternal(Blackboard newBlackBoardInte
/**
*
+ *
* @generated
*/
@Override
@@ -1539,8 +1579,8 @@ public void setBlackBoardInternal(Blackboard newBlackBoardInternal) {
}
/**
- *
- *
+ *
+ *
* @generated
*/
@Override
@@ -1554,6 +1594,7 @@ public List getLegend() {
/**
*
+ *
* @generated
*/
@Override
@@ -1587,9 +1628,9 @@ public Object getAdapter(Class adapter) {
}
/*
- * Adapt to an IWorkbenchAdapter. Other aspects of Eclipse can read the
- * properties we provide access to. (example: Property page dialogs
- * can read the label and display that in their title.)
+ * Adapt to an IWorkbenchAdapter. Other aspects of Eclipse can read the properties we
+ * provide access to. (example: Property page dialogs can read the label and display that in
+ * their title.)
*/
if (adapter.isAssignableFrom(IWorkbenchAdapter.class)) {
return new WorkbenchAdapter() {
@@ -1820,7 +1861,7 @@ private SpatialOperator localize(SimpleFeatureType schema, SpatialOperator filte
* Constructs a filter for the provided layer, based on the GeometryFilter.
*/
private Filter target(Layer layer, Filter filter) {
- if (!layer.isSelectable()) {
+ if (!layer.getInteraction(Interaction.SELECT)) {
return Filter.INCLUDE;
}
try {
diff --git a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/render/impl/ViewportModelImpl.java b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/render/impl/ViewportModelImpl.java
index 44cb699828..a09c4443fb 100644
--- a/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/render/impl/ViewportModelImpl.java
+++ b/plugins/org.locationtech.udig.project/src/org/locationtech/udig/project/internal/render/impl/ViewportModelImpl.java
@@ -65,9 +65,9 @@
*/
public class ViewportModelImpl extends EObjectImpl implements ViewportModel {
/**
- * The default value of the '{@link #getCRS() CRS}' attribute.
- *
+ * The default value of the '{@link #getCRS() CRS}' attribute.
*
+ *
* @see #getCRS()
* @generated
* @ordered
@@ -93,9 +93,9 @@ public class ViewportModelImpl extends EObjectImpl implements ViewportModel {
protected boolean cRSESet = false;
/**
- * The default value of the '{@link #getBounds() Bounds}' attribute.
- *
- *
+ * The default value of the '{@link #getBounds() Bounds}' attribute.
+ *
* @see #getBounds()
* @generated
* @ordered
@@ -104,8 +104,8 @@ public class ViewportModelImpl extends EObjectImpl implements ViewportModel {
.createFromString(RenderPackage.eINSTANCE.getReferencedEnvelope(), ""); //$NON-NLS-1$
/**
- * The cached value of the '{@link #getBounds() Bounds}' attribute.
+ * The cached value of the '{@link #getBounds() Bounds}' attribute.
*
* @see #getBounds()
* @generated NOT
@@ -134,8 +134,8 @@ public class ViewportModelImpl extends EObjectImpl implements ViewportModel {
protected static final double HEIGHT_EDEFAULT = 0.0;
/**
- * The default value of the '{@link #getWidth() Width}' attribute.
+ * The default value of the '{@link #getWidth() Width}' attribute.
*
* @see #getWidth()
* @generated
@@ -164,8 +164,9 @@ public class ViewportModelImpl extends EObjectImpl implements ViewportModel {
protected static final Coordinate PIXEL_SIZE_EDEFAULT = null;
/**
- * The cached value of the '{@link #getRenderManagerInternal() Render Manager Internal}' reference.
- *
+ * The cached value of the '{@link #getRenderManagerInternal() Render Manager
+ * Internal}' reference.
+ *
* @see #getRenderManagerInternal()
* @generated
* @ordered
@@ -173,9 +174,9 @@ public class ViewportModelImpl extends EObjectImpl implements ViewportModel {
protected RenderManager renderManagerInternal;
/**
- * The cached value of the '{@link #getPreferredScaleDenominators() Preferred Scale Denominators}' attribute.
- *
- *
+ * The cached value of the '{@link #getPreferredScaleDenominators() Preferred Scale
+ * Denominators}' attribute.
+ *
* @see #getPreferredScaleDenominators()
* @generated
* @ordered
@@ -194,6 +195,7 @@ protected ViewportModelImpl() {
/**
*
+ *
* @generated
*/
@Override
@@ -203,6 +205,7 @@ protected EClass eStaticClass() {
/**
*
+ *
* @generated
*/
@Override
@@ -212,7 +215,6 @@ public CoordinateReferenceSystem getCRS() {
@Override
public void setCRS(CoordinateReferenceSystem newCRS) {
- double scale = getScaleDenominator();
if (newCRS == null)
throw new IllegalArgumentException("A CRS cannot be null"); //$NON-NLS-1$
if (newCRS.equals(cRS))
@@ -236,6 +238,7 @@ public void setCRS(CoordinateReferenceSystem newCRS) {
DirectPosition newCenter = transform.transform(position,
new DirectPosition2D());
setCenter(new Coordinate(newCenter.getOrdinate(0), newCenter.getOrdinate(1)));
+ double scale = getScaleDenominator();
setScale(scale);
}
} catch (FactoryException e) {
@@ -286,6 +289,7 @@ public void unsetCRS() {
/**
*
+ *
* @generated
*/
@Override
@@ -343,7 +347,8 @@ && validState()) {
mapDisplay.getDPI(), referenced);
if (forceContainBBoxZoom && !finalBounds.contains(newBounds)) {
Iterator tail = getPreferredScaleDenominators().tailSet(scale).iterator();
- // the tail will include scale because scale is one of the elements in the set. So drop that
+ // the tail will include scale because scale is one of the elements in the set. So
+ // drop that
tail.next();
Double nextLargest = tail.next();
if (nextLargest != null) {
@@ -471,6 +476,7 @@ && getRenderManagerInternal().getMapDisplay().getWidth() > 0
/**
*
+ *
* @generated
*/
@Override
@@ -481,8 +487,8 @@ public Map getMapInternal() {
}
/**
- *
- *
+ *
+ *
* @generated
*/
public NotificationChain basicSetMapInternal(Map newMapInternal, NotificationChain msgs) {
@@ -493,6 +499,7 @@ public NotificationChain basicSetMapInternal(Map newMapInternal, NotificationCha
/**
*
+ *
* @generated
*/
public void setMapInternalGen(Map newMapInternal) {
@@ -553,6 +560,7 @@ public void setMapInternal(Map newMap) {
/**
*
+ *
* @generated
*/
@Override
@@ -562,6 +570,7 @@ public RenderManager getRenderManagerInternal() {
/**
*
+ *
* @generated
*/
public NotificationChain basicSetRenderManagerInternal(RenderManager newRenderManagerInternal,
@@ -582,6 +591,7 @@ public NotificationChain basicSetRenderManagerInternal(RenderManager newRenderMa
/**
*
+ *
* @generated
*/
@Override
@@ -645,7 +655,7 @@ public void setBounds(double minx, double maxx, double miny, double maxy) {
@Override
public AffineTransform worldToScreenTransform() {
if (!validState())
- return new AffineTransform(); //Identity (screen-space is arbitrary here.)
+ return new AffineTransform(); // Identity (screen-space is arbitrary here.)
// set up the affine transform and calculate scale values
return worldToScreenTransform(getBounds(),
getRenderManagerInternal().getMapDisplay().getDisplaySize());
@@ -801,6 +811,7 @@ public void zoomToExtent() {
/**
*
+ *
* @generated
*/
@Override
@@ -867,7 +878,7 @@ private void fireNotification(Envelope oldBounds) {
eNotify(new ENotificationImpl(this, Notification.SET,
RenderPackage.VIEWPORT_MODEL__BOUNDS, oldBounds, bounds));
- //notifyListeners(new ViewportModelEvent(this, EventType.CRS, bounds, oldBounds));
+ // notifyListeners(new ViewportModelEvent(this, EventType.CRS, bounds, oldBounds));
notifyListeners(new ViewportModelEvent(this, EventType.BOUNDS, bounds, oldBounds));
}
}
@@ -923,8 +934,8 @@ public void zoomToBox(Envelope newbbox) {
}
/**
- *
- *
+ *
+ *
* @generated
*/
@Override
@@ -946,8 +957,8 @@ public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID,
}
/**
- *
- *
+ *
+ *
* @generated
*/
@Override
@@ -963,8 +974,8 @@ public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID,
}
/**
- *
- *
+ *
+ *
* @generated
*/
@Override
@@ -978,8 +989,8 @@ public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs
}
/**
- *
- *
+ *
+ *
* @generated
*/
@Override
@@ -1010,8 +1021,8 @@ public Object eGet(int featureID, boolean resolve, boolean coreType) {
}
/**
- *
- *
+ *
+ *
* @generated
*/
@SuppressWarnings("unchecked")
@@ -1047,8 +1058,8 @@ public void eSet(int featureID, Object newValue) {
}
/**
- *
- *
+ *
+ *
* @generated
*/
@Override
@@ -1083,8 +1094,8 @@ public void eUnset(int featureID) {
}
/**
- *
- *
+ *
+ *
* @generated
*/
@Override
@@ -1238,8 +1249,8 @@ public void setPreferredScaleDenominators(SortedSet newPreferredScaleDen
}
/**
- * This method will calculate the current width based on ScaleUtils and
- * the current RenderManager.
+ * This method will calculate the current width based on ScaleUtils and the current
+ * RenderManager.
*/
@Override
public void setScale(double scaleDenominator) {
diff --git a/plugins/org.locationtech.udig.tool.edit.tests/src/org/locationtech/udig/tools/edit/behaviour/SelectGeometryBehaviourTest.java b/plugins/org.locationtech.udig.tool.edit.tests/src/org/locationtech/udig/tools/edit/behaviour/SelectGeometryBehaviourTest.java
index 2e23e74b66..e21722df7f 100644
--- a/plugins/org.locationtech.udig.tool.edit.tests/src/org/locationtech/udig/tools/edit/behaviour/SelectGeometryBehaviourTest.java
+++ b/plugins/org.locationtech.udig.tool.edit.tests/src/org/locationtech/udig/tools/edit/behaviour/SelectGeometryBehaviourTest.java
@@ -1,7 +1,7 @@
-/*
- * uDig - User Friendly Desktop Internet GIS client
- * http://udig.refractions.net
- * (C) 2012, Refractions Research Inc.
+/**
+ * uDig - User Friendly Desktop Internet GIS client
+ * http://udig.refractions.net
+ * (C) 2012, Refractions Research Inc.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -10,7 +10,6 @@
*/
package org.locationtech.udig.tools.edit.behaviour;
-
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
@@ -62,235 +61,289 @@
import org.opengis.filter.spatial.BBOX;
public class SelectGeometryBehaviourTest extends AbstractProjectUITestCase {
- final int none=MapMouseEvent.NONE;
+ final int none = MapMouseEvent.NONE;
+
final int ctrl = MapMouseEvent.MOD1_DOWN_MASK;
+
final int shift = MapMouseEvent.SHIFT_DOWN_MASK;
+
final int alt = MapMouseEvent.ALT_DOWN_MASK;
+
final int button1 = MapMouseEvent.BUTTON1;
+
final int button2 = MapMouseEvent.BUTTON2;
+
private org.locationtech.udig.project.internal.Map map;
- private FeatureCollection features;
- java.awt.Point SCREEN=new java.awt.Point(500,500);
+ private FeatureCollection features;
+
+ java.awt.Point SCREEN = new java.awt.Point(500, 500);
+
private TestHandler handler;
-
+
@Before
public void setUp() throws Exception {
- map=MapTests.createDefaultMap("Test",3,true,new Dimension(500,500)); //$NON-NLS-1$
- FeatureStore resource = map.getLayersInternal().get(0).getResource(FeatureStore.class, null);
- features=resource.getFeatures();
- GeometryFactory fac=new GeometryFactory();
- int i=0;
- for( FeatureIterator iter=features.features(); iter.hasNext(); ){
+ map = MapTests.createDefaultMap("Test", 3, true, new Dimension(500, 500)); //$NON-NLS-1$
+ FeatureStore resource = map.getLayersInternal().get(0)
+ .getResource(FeatureStore.class, null);
+ features = resource.getFeatures();
+ GeometryFactory fac = new GeometryFactory();
+ int i = 0;
+ for (FeatureIterator iter = features.features(); iter.hasNext();) {
i++;
- SimpleFeature feature=iter.next();
- Coordinate c=map.getViewportModel().pixelToWorld(i*10,0);
- FilterFactory filterFactory = CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
- Set ids = new HashSet();
- ids.add(filterFactory.featureId(feature.getID()));
- GeometryDescriptor defaultGeometry = feature.getFeatureType().getGeometryDescriptor();
- resource.modifyFeatures(defaultGeometry.getName(), fac.createPoint(c),
+ SimpleFeature feature = iter.next();
+ Coordinate c = map.getViewportModel().pixelToWorld(i * 10, 0);
+ FilterFactory filterFactory = CommonFactoryFinder
+ .getFilterFactory(GeoTools.getDefaultHints());
+ Set ids = new HashSet<>();
+ ids.add(filterFactory.featureId(feature.getID()));
+ GeometryDescriptor defaultGeometry = feature.getFeatureType().getGeometryDescriptor();
+ resource.modifyFeatures(defaultGeometry.getName(), fac.createPoint(c),
filterFactory.id(ids));
}
- ((EditManager)map.getEditManager()).commitTransaction();
+ ((EditManager) map.getEditManager()).commitTransaction();
- handler=new TestHandler();
- ((ToolContext)handler.getContext()).setMapInternal(map);
- ((ToolContext)handler.getContext()).setRenderManagerInternal(map.getRenderManagerInternal());
+ handler = new TestHandler();
+ ((ToolContext) handler.getContext()).setMapInternal(map);
+ ((ToolContext) handler.getContext())
+ .setRenderManagerInternal(map.getRenderManagerInternal());
}
-
- /*
- * Test method for 'org.locationtech.udig.tools.edit.mode.MoveVertexMode.isValid(EditToolHandler, MapMouseEvent, EventType)'
+
+ /**
+ * Test method for
+ * 'org.locationtech.udig.tools.edit.mode.MoveVertexMode.isValid(EditToolHandler, MapMouseEvent,
+ * EventType)'
*/
@Test
public void testIsValid() throws Exception {
- SelectFeatureBehaviour mode=new SelectFeatureBehaviour(new Class[]{Polygon.class, MultiPolygon.class}, BBOX.class);
+ SelectFeatureBehaviour mode = new SelectFeatureBehaviour(
+ new Class[] { Polygon.class, MultiPolygon.class }, BBOX.class);
- assertFalse(mode.isValid(handler, new MapMouseEvent(null, 0, 0, none, none, 0), EventType.DOUBLE_CLICK));
+ assertFalse(mode.isValid(handler, new MapMouseEvent(null, 0, 0, none, none, 0),
+ EventType.DOUBLE_CLICK));
- assertTrue(mode.isValid(handler, new MapMouseEvent(null, 10, 0, none, none, button1), EventType.RELEASED));
+ assertTrue(mode.isValid(handler, new MapMouseEvent(null, 10, 0, none, none, button1),
+ EventType.RELEASED));
// not valid for drag events
- assertFalse(mode.isValid(handler, new MapMouseEvent(null, 10, 0, none, none, button1), EventType.DRAGGED));
+ assertFalse(mode.isValid(handler, new MapMouseEvent(null, 10, 0, none, none, button1),
+ EventType.DRAGGED));
// not valid for exit events
- assertFalse(mode.isValid(handler, new MapMouseEvent(null, 10, 0, none, none, button1), EventType.EXITED));
+ assertFalse(mode.isValid(handler, new MapMouseEvent(null, 10, 0, none, none, button1),
+ EventType.EXITED));
// not valid for moved events
- assertFalse(mode.isValid(handler, new MapMouseEvent(null, 10, 0, none, none, button1), EventType.MOVED));
+ assertFalse(mode.isValid(handler, new MapMouseEvent(null, 10, 0, none, none, button1),
+ EventType.MOVED));
// not valid for pressed events
- assertFalse(mode.isValid(handler, new MapMouseEvent(null, 10, 0, none, none, button1), EventType.PRESSED));
+ assertFalse(mode.isValid(handler, new MapMouseEvent(null, 10, 0, none, none, button1),
+ EventType.PRESSED));
- // ctl down is legal
- assertTrue(mode.isValid(handler, new MapMouseEvent(null, 10,0, ctrl,none, button1), EventType.RELEASED));
+ // ctrl down is legal
+ assertTrue(mode.isValid(handler, new MapMouseEvent(null, 10, 0, ctrl, none, button1),
+ EventType.RELEASED));
// shift down is legal
- assertTrue(mode.isValid(handler, new MapMouseEvent(null, 10,0, shift, none, button1), EventType.RELEASED));
+ assertTrue(mode.isValid(handler, new MapMouseEvent(null, 10, 0, shift, none, button1),
+ EventType.RELEASED));
- // ctl down is not legal
- assertFalse(mode.isValid(handler, new MapMouseEvent(null, 10,0, alt, none, button1), EventType.RELEASED));
+ // ctrl down is not legal
+ assertFalse(mode.isValid(handler, new MapMouseEvent(null, 10, 0, alt, none, button1),
+ EventType.RELEASED));
// only 1 modifier is legal
- assertFalse(mode.isValid(handler, new MapMouseEvent(null,
- 0, 0, shift|ctrl, none, button1), EventType.RELEASED));
-
+ assertFalse(mode.isValid(handler,
+ new MapMouseEvent(null, 0, 0, shift | ctrl, none, button1), EventType.RELEASED));
+
// button2 is not legal
- assertFalse(mode.isValid(handler, new MapMouseEvent(null, 10, 0, none, none, button2), EventType.RELEASED));
-
+ assertFalse(mode.isValid(handler, new MapMouseEvent(null, 10, 0, none, none, button2),
+ EventType.RELEASED));
+
List geoms = handler.getEditBlackboard().getGeoms();
- handler.getEditBlackboard().addPoint(10,0, geoms.get(0).getShell());
+ handler.getEditBlackboard().addPoint(10, 0, geoms.get(0).getShell());
handler.setCurrentShape(handler.getEditBlackboard().getGeoms().get(0).getShell());
}
- /*
- * Test method for 'org.locationtech.udig.tools.edit.mode.MoveVertexMode.run(EditToolHandler, MapMouseEvent, EventType)'
+ /**
+ * Test method for 'org.locationtech.udig.tools.edit.mode.MoveVertexMode.run(EditToolHandler,
+ * MapMouseEvent, EventType)'
*/
@Ignore
@Test
public void testRun() throws Exception {
- SelectFeatureBehaviour mode=new SelectFeatureBehaviour(new Class[]{Point.class}, BBOX.class);
-
- Listener l=new Listener();
+ SelectFeatureBehaviour mode = new SelectFeatureBehaviour(new Class[] { Point.class },
+ BBOX.class);
+
+ Listener l = new Listener();
handler.getBehaviours().add(mode);
handler.getContext().getMap().getBlackboard().addListener(l);
- handler.setEditBlackboard(new EditBlackboard(SCREEN.x,
- SCREEN.y, map.getViewportModel().worldToScreenTransform(), map.getLayersInternal().get(0).layerToMapTransform()));
+ handler.setEditBlackboard(new EditBlackboard(SCREEN.x, SCREEN.y,
+ map.getViewportModel().worldToScreenTransform(),
+ map.getLayersInternal().get(0).layerToMapTransform()));
handler.setContext(ApplicationGISInternal.createContext(map));
handler.getEditBlackboard().getListeners().add(l);
-
- handler.handleEvent(new MapMouseEvent(null, 10, 0, none, none, button1), EventType.RELEASED);
- assertEquals( org.locationtech.udig.tools.edit.support.Point.valueOf(10,0), handler.getCurrentGeom().getShell().getPoint(0));
- assertTrue( l.set );
+
+ handler.handleEvent(new MapMouseEvent(null, 10, 0, none, none, button1),
+ EventType.RELEASED);
+ assertEquals(org.locationtech.udig.tools.edit.support.Point.valueOf(10, 0),
+ handler.getCurrentGeom().getShell().getPoint(0));
+ assertTrue(l.set);
assertNull(l.old);
- assertEquals( handler.getCurrentGeom(), l.current);
-
- EditGeom geom=l.added.get(l.added.size()-1);
- handler.handleEvent(new MapMouseEvent(null, 20, 0, none, none, button1), EventType.RELEASED);
- assertEquals( org.locationtech.udig.tools.edit.support.Point.valueOf(20,0), handler.getCurrentGeom().getShell().getPoint(0));
- assertTrue( l.set );
- assertEquals(geom,l.old);
- assertEquals( handler.getCurrentGeom(), l.current);
- assertEquals( 1, handler.getEditBlackboard().getGeoms().size());
-
+ assertEquals(handler.getCurrentGeom(), l.current);
+
+ EditGeom geom = l.added.get(l.added.size() - 1);
+ handler.handleEvent(new MapMouseEvent(null, 20, 0, none, none, button1),
+ EventType.RELEASED);
+ assertEquals(org.locationtech.udig.tools.edit.support.Point.valueOf(20, 0),
+ handler.getCurrentGeom().getShell().getPoint(0));
+ assertTrue(l.set);
+ assertEquals(geom, l.old);
+ assertEquals(handler.getCurrentGeom(), l.current);
+ assertEquals(1, handler.getEditBlackboard().getGeoms().size());
+
// add using shift
- handler.handleEvent(new MapMouseEvent(null, 10, 0, shift, none, button1), EventType.RELEASED);
- geom=l.added.get(l.added.size()-1);
- assertEquals(1, handler.getEditBlackboard().getGeoms(20,0).size());
- assertFalse( l.set );
- assertEquals(geom,l.current);
- assertEquals( geom, handler.getCurrentGeom());
- assertEquals( 2, handler.getEditBlackboard().getGeoms().size());
-
+ handler.handleEvent(new MapMouseEvent(null, 10, 0, shift, none, button1),
+ EventType.RELEASED);
+ geom = l.added.get(l.added.size() - 1);
+ assertEquals(1, handler.getEditBlackboard().getGeoms(20, 0).size());
+ assertFalse(l.set);
+ assertEquals(geom, l.current);
+ assertEquals(geom, handler.getCurrentGeom());
+ assertEquals(2, handler.getEditBlackboard().getGeoms().size());
+
// add using ctrl
- handler.handleEvent(new MapMouseEvent(null, 30, 0, ctrl, none, button1), EventType.RELEASED);
- geom=l.added.get(l.added.size()-1);
- assertEquals(1, handler.getEditBlackboard().getGeoms(30,0).size());
- assertFalse( l.set );
- assertEquals( geom, handler.getCurrentGeom());
- assertEquals( 3, handler.getEditBlackboard().getGeoms().size());
-
+ handler.handleEvent(new MapMouseEvent(null, 30, 0, ctrl, none, button1),
+ EventType.RELEASED);
+ geom = l.added.get(l.added.size() - 1);
+ assertEquals(1, handler.getEditBlackboard().getGeoms(30, 0).size());
+ assertFalse(l.set);
+ assertEquals(geom, handler.getCurrentGeom());
+ assertEquals(3, handler.getEditBlackboard().getGeoms().size());
+
// remove using ctrl
- handler.handleEvent(new MapMouseEvent(null, 30, 0, ctrl, none, button1), EventType.RELEASED);
- assertEquals(0, handler.getEditBlackboard().getGeoms(30,0).size());
- assertEquals( 2, handler.getEditBlackboard().getGeoms().size());
-
+ handler.handleEvent(new MapMouseEvent(null, 30, 0, ctrl, none, button1),
+ EventType.RELEASED);
+ assertEquals(0, handler.getEditBlackboard().getGeoms(30, 0).size());
+ assertEquals(2, handler.getEditBlackboard().getGeoms().size());
+
// click on nothing and all should be deselected
- handler.handleEvent( new MapMouseEvent(null, 0, 0, none, none, button1), EventType.RELEASED);
- assertEquals(0, handler.getEditBlackboard().getGeoms(20,0).size());
- assertEquals( 1, handler.getEditBlackboard().getGeoms().size());
+ handler.handleEvent(new MapMouseEvent(null, 0, 0, none, none, button1), EventType.RELEASED);
+ assertEquals(0, handler.getEditBlackboard().getGeoms(20, 0).size());
+ assertEquals(1, handler.getEditBlackboard().getGeoms().size());
assertTrue(l.set);
- assertNull( handler.getCurrentGeom() );
-
+ assertNull(handler.getCurrentGeom());
+
}
-
+
@Test
public void testSelectMultiGeom() throws Exception {
- SelectFeatureBehaviour mode=new SelectFeatureBehaviour(new Class[]{MultiLineString.class}, BBOX.class);
+ SelectFeatureBehaviour mode = new SelectFeatureBehaviour(
+ new Class[] { MultiLineString.class }, BBOX.class);
handler.getBehaviours().add(mode);
- handler.setEditBlackboard(new EditBlackboard(500,500, map.getViewportModel().worldToScreenTransform(),
- map.getLayersInternal().get(0).layerToMapTransform()));
-
- FeatureStore resource = map.getLayersInternal().get(0).getResource(FeatureStore.class, null);
- GeometryFactory factory=new GeometryFactory();
- LineString line1=factory.createLineString(new Coordinate[]{
- map.getViewportModel().pixelToWorld(10,10), map.getViewportModel().pixelToWorld(10,20)
- });
- LineString line2=factory.createLineString(new Coordinate[]{
- map.getViewportModel().pixelToWorld(20,10), map.getViewportModel().pixelToWorld(20,20)
- });
-
- MultiLineString multiline = factory.createMultiLineString(new LineString[]{line1, line2});
-
- SimpleFeature feature = SimpleFeatureBuilder.build(resource.getSchema(),
- new Object[]{multiline, "multiline"}, "testGeom"); //$NON-NLS-1$
- Set ids = new HashSet();
- FilterFactory filterFactory = CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
+ handler.setEditBlackboard(
+ new EditBlackboard(500, 500, map.getViewportModel().worldToScreenTransform(),
+ map.getLayersInternal().get(0).layerToMapTransform()));
+
+ FeatureStore resource = map.getLayersInternal().get(0)
+ .getResource(FeatureStore.class, null);
+ GeometryFactory factory = new GeometryFactory();
+ LineString line1 = factory
+ .createLineString(new Coordinate[] { map.getViewportModel().pixelToWorld(10, 10),
+ map.getViewportModel().pixelToWorld(10, 20) });
+ LineString line2 = factory
+ .createLineString(new Coordinate[] { map.getViewportModel().pixelToWorld(20, 10),
+ map.getViewportModel().pixelToWorld(20, 20) });
+
+ MultiLineString multiline = factory
+ .createMultiLineString(new LineString[] { line1, line2 });
+
+ SimpleFeature feature = SimpleFeatureBuilder.build(resource.getSchema(),
+ new Object[] { multiline, "multiline" }, "testGeom"); //$NON-NLS-1$ //$NON-NLS-2$
+ Set ids = new HashSet<>();
+ FilterFactory filterFactory = CommonFactoryFinder
+ .getFilterFactory(GeoTools.getDefaultHints());
ids.add(filterFactory.featureId(features.features().next().getID()));
- resource.modifyFeatures(feature.getFeatureType().getGeometryDescriptor().getName(), multiline,
- filterFactory.id(ids));
-
-
- handler.handleEvent(new MapMouseEvent(null, 20, 15, none, none, button1), EventType.RELEASED);
-
- assertTrue(handler.getCurrentShape().hasVertex(org.locationtech.udig.tools.edit.support.Point.valueOf(20,10)));
- assertTrue(handler.getCurrentShape().hasVertex(org.locationtech.udig.tools.edit.support.Point.valueOf(20,20)));
- assertFalse(handler.getCurrentShape().hasVertex(org.locationtech.udig.tools.edit.support.Point.valueOf(10,10)));
- assertFalse(handler.getCurrentShape().hasVertex(org.locationtech.udig.tools.edit.support.Point.valueOf(10,20)));
-
- handler.handleEvent(new MapMouseEvent(null, 10, 15, none, none, button1), EventType.RELEASED);
-
- assertTrue(handler.getCurrentShape().hasVertex(org.locationtech.udig.tools.edit.support.Point.valueOf(10,10)));
- assertTrue(handler.getCurrentShape().hasVertex(org.locationtech.udig.tools.edit.support.Point.valueOf(10,20)));
- assertFalse(handler.getCurrentShape().hasVertex(org.locationtech.udig.tools.edit.support.Point.valueOf(20,10)));
- assertFalse(handler.getCurrentShape().hasVertex(org.locationtech.udig.tools.edit.support.Point.valueOf(20,20)));
-
+ resource.modifyFeatures(feature.getFeatureType().getGeometryDescriptor().getName(),
+ multiline, filterFactory.id(ids));
+
+ handler.handleEvent(new MapMouseEvent(null, 20, 15, none, none, button1),
+ EventType.RELEASED);
+
+ assertTrue(handler.getCurrentShape()
+ .hasVertex(org.locationtech.udig.tools.edit.support.Point.valueOf(20, 10)));
+ assertTrue(handler.getCurrentShape()
+ .hasVertex(org.locationtech.udig.tools.edit.support.Point.valueOf(20, 20)));
+ assertFalse(handler.getCurrentShape()
+ .hasVertex(org.locationtech.udig.tools.edit.support.Point.valueOf(10, 10)));
+ assertFalse(handler.getCurrentShape()
+ .hasVertex(org.locationtech.udig.tools.edit.support.Point.valueOf(10, 20)));
+
+ handler.handleEvent(new MapMouseEvent(null, 10, 15, none, none, button1),
+ EventType.RELEASED);
+
+ assertTrue(handler.getCurrentShape()
+ .hasVertex(org.locationtech.udig.tools.edit.support.Point.valueOf(10, 10)));
+ assertTrue(handler.getCurrentShape()
+ .hasVertex(org.locationtech.udig.tools.edit.support.Point.valueOf(10, 20)));
+ assertFalse(handler.getCurrentShape()
+ .hasVertex(org.locationtech.udig.tools.edit.support.Point.valueOf(20, 10)));
+ assertFalse(handler.getCurrentShape()
+ .hasVertex(org.locationtech.udig.tools.edit.support.Point.valueOf(20, 20)));
+
}
- class Listener extends EditBlackboardAdapter implements IBlackboardListener{
+ class Listener extends EditBlackboardAdapter implements IBlackboardListener {
List added;
- boolean set=false;
+
+ boolean set = false;
+
EditGeom old;
+
EditGeom current;
-
+
@SuppressWarnings("unchecked")
@Override
- public void changed( EditBlackboardEvent e ) {
-
- switch( e.getType() ) {
+ public void changed(EditBlackboardEvent e) {
+
+ switch (e.getType()) {
case SET_GEOMS:
- set=true;
- added=(List) e.getNewValue();
+ set = true;
+ added = (List) e.getNewValue();
break;
case ADD_GEOMS:
- set=false;
- added=(List) e.getNewValue();
+ set = false;
+ added = (List) e.getNewValue();
break;
case REMOVE_GEOMS:
- set=true;
- added=(List) e.getNewValue();
+ set = true;
+ added = (List) e.getNewValue();
break;
default:
-
+
break;
}
}
-
+
@Override
- public void batchChange( List e ) {
- for( EditBlackboardEvent event : e ) {
+ public void batchChange(List e) {
+ for (EditBlackboardEvent event : e) {
changed(event);
}
}
-
- public void blackBoardChanged( BlackboardEvent event ) {
- if( event.getKey()==EditToolHandler.CURRENT_SHAPE){
- if( event.getNewValue()==null )
- this.current=null;
+
+ @Override
+ public void blackBoardChanged(BlackboardEvent event) {
+ if (event.getKey() == EditToolHandler.CURRENT_SHAPE) {
+ if (event.getNewValue() == null)
+ this.current = null;
else
- this.current=((PrimitiveShape) event.getNewValue()).getEditGeom();
- if( event.getOldValue()!=null )
- this.old=((PrimitiveShape) event.getOldValue()).getEditGeom();
+ this.current = ((PrimitiveShape) event.getNewValue()).getEditGeom();
+ if (event.getOldValue() != null)
+ this.old = ((PrimitiveShape) event.getOldValue()).getEditGeom();
}
}
- public void blackBoardCleared( IBlackboard source ) {
+ @Override
+ public void blackBoardCleared(IBlackboard source) {
+
}
}
diff --git a/plugins/org.locationtech.udig.tool.edit.tests/src/org/locationtech/udig/tools/edit/impl/SelectionToolTest.java b/plugins/org.locationtech.udig.tool.edit.tests/src/org/locationtech/udig/tools/edit/impl/SelectionToolTest.java
index d23f121a43..263f4c47d0 100644
--- a/plugins/org.locationtech.udig.tool.edit.tests/src/org/locationtech/udig/tools/edit/impl/SelectionToolTest.java
+++ b/plugins/org.locationtech.udig.tool.edit.tests/src/org/locationtech/udig/tools/edit/impl/SelectionToolTest.java
@@ -1,4 +1,5 @@
-/* uDig - User Friendly Desktop Internet GIS client
+/**
+ * uDig - User Friendly Desktop Internet GIS client
* http://udig.refractions.net
* (C) 2004, Refractions Research Inc.
*
@@ -25,7 +26,6 @@
import org.locationtech.jts.geom.LinearRing;
import org.locationtech.udig.TestViewportPane;
import org.locationtech.udig.core.internal.FeatureUtils;
-import org.locationtech.udig.project.ILayer;
import org.locationtech.udig.project.internal.EditManager;
import org.locationtech.udig.project.internal.render.RenderManager;
import org.locationtech.udig.project.ui.render.displayAdapter.MapMouseEvent;
@@ -38,74 +38,82 @@
import org.opengis.filter.FilterFactory;
/**
- * Test the SelectionToolTest
+ * Test the SelectionToolTest
+ *
* @author jones
* @since 1.1.0
*/
-public class SelectionToolTest extends AbstractToolTest{
+public class SelectionToolTest extends AbstractToolTest {
@Before
public void setUp() throws Exception {
- handler=new TestHandler(3);
-
- FeatureStore source = ((ILayer) handler.getContext().getMapLayers().get(0)).getResource(FeatureStore.class, null);
- FilterFactory filterFac=CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
- GeometryFactory geomFac=new GeometryFactory();
- int i=0;
- for( FeatureIterator iter = source.getFeatures().features(); iter.hasNext(); ){
+ handler = new TestHandler(3);
+
+ FeatureStore source = handler.getContext().getMapLayers()
+ .get(0).getResource(FeatureStore.class, null);
+ FilterFactory filterFac = CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
+ GeometryFactory geomFac = new GeometryFactory();
+ int i = 0;
+ for (FeatureIterator iter = source.getFeatures().features(); iter
+ .hasNext();) {
SimpleFeature feature = iter.next();
- source.modifyFeatures(feature.getFeatureType().getDescriptor("name").getName(), "feature"+i, filterFac.id(FeatureUtils.stringToId(filterFac, feature.getID()))); //$NON-NLS-1$//$NON-NLS-2$
+ source.modifyFeatures(feature.getFeatureType().getDescriptor("name").getName(), //$NON-NLS-1$
+ "feature" + i, //$NON-NLS-1$
+ filterFac.id(FeatureUtils.stringToId(filterFac, feature.getID())));
Geometry geom;
- if( i==0 ){
- geom=geomFac.createPoint(new Coordinate(0,10));
- }else if( i==1 ){
- geom=geomFac.createLineString(new Coordinate[]{
- new Coordinate( 10,10), new Coordinate(10,20)
- });
- }else{
- geom=geomFac.createLinearRing(
- new Coordinate[]{
- new Coordinate( 20,10), new Coordinate(40,10),
- new Coordinate( 40,40), new Coordinate(20,40),
- new Coordinate( 20,10)
- }
- );
- geom=geomFac.createPolygon((LinearRing) geom, new LinearRing[0]);
+ if (i == 0) {
+ geom = geomFac.createPoint(new Coordinate(0, 10));
+ } else if (i == 1) {
+ geom = geomFac.createLineString(
+ new Coordinate[] { new Coordinate(10, 10), new Coordinate(10, 20) });
+ } else {
+ geom = geomFac.createLinearRing(new Coordinate[] { new Coordinate(20, 10),
+ new Coordinate(40, 10), new Coordinate(40, 40), new Coordinate(20, 40),
+ new Coordinate(20, 10) });
+ geom = geomFac.createPolygon((LinearRing) geom, new LinearRing[0]);
}
- source.modifyFeatures(feature.getFeatureType().getGeometryDescriptor().getName(), geom, filterFac.id(FeatureUtils.stringToId(filterFac, feature.getID())));
+ source.modifyFeatures(feature.getFeatureType().getGeometryDescriptor().getName(), geom,
+ filterFac.id(FeatureUtils.stringToId(filterFac, feature.getID())));
i++;
}
((EditManager) handler.getContext().getEditManager()).commitTransaction();
- ((RenderManager)handler.getContext().getRenderManager()).setMapDisplay(new TestViewportPane(new Dimension(500,500)));
-
+ ((RenderManager) handler.getContext().getRenderManager())
+ .setMapDisplay(new TestViewportPane(new Dimension(500, 500)));
+
tool.setHandler(handler);
-
+
tool.testinitEventBehaviours(new EditToolConfigurationHelper(handler.getBehaviours()));
-
+
}
-
+
@Override
protected AbstractEditTool createTool() {
return new SelectionTool();
}
-
+
@Test
- public void testSelect1FeatureThenAnother() throws Exception{
-
- Point p=handler.getEditBlackboard().toPoint(new Coordinate(0,10));
- tool.mouseReleased(new MapMouseEvent(handler.getContext().getMapDisplay(), p.getX(), p.getY(), 0,0,MapMouseEvent.BUTTON1));
-
- assertEquals("feature0", handler.getContext().getEditManager().getEditFeature().getAttribute("name")); //$NON-NLS-1$//$NON-NLS-2$
-
- p=handler.getEditBlackboard().toPoint(new Coordinate(10,15));
- tool.mouseReleased(new MapMouseEvent(handler.getContext().getMapDisplay(), p.getX(), p.getY(), 0,0,MapMouseEvent.BUTTON1));
-
- assertEquals("feature1", handler.getContext().getEditManager().getEditFeature().getAttribute("name")); //$NON-NLS-1$ //$NON-NLS-2$
-
- p=handler.getEditBlackboard().toPoint(new Coordinate(30,30));
- tool.mouseReleased(new MapMouseEvent(handler.getContext().getMapDisplay(), p.getX(), p.getY(), 0,0,MapMouseEvent.BUTTON1));
-
- assertEquals("feature2", handler.getContext().getEditManager().getEditFeature().getAttribute("name")); //$NON-NLS-1$ //$NON-NLS-2$
+ public void testSelect1FeatureThenAnother() throws Exception {
+
+ Point p = handler.getEditBlackboard().toPoint(new Coordinate(0, 10));
+ tool.mouseReleased(
+ new MapMouseEvent(handler.getContext().getMapDisplay(), p.getX(), p.getY(), 0, 0, MapMouseEvent.BUTTON1));
+
+ assertEquals("feature0", //$NON-NLS-1$
+ handler.getContext().getEditManager().getEditFeature().getAttribute("name")); //$NON-NLS-1$
+
+ p = handler.getEditBlackboard().toPoint(new Coordinate(10, 15));
+ tool.mouseReleased(new MapMouseEvent(handler.getContext().getMapDisplay(), p.getX(),
+ p.getY(), 0, 0, MapMouseEvent.BUTTON1));
+
+ assertEquals("feature1", //$NON-NLS-1$
+ handler.getContext().getEditManager().getEditFeature().getAttribute("name")); //$NON-NLS-1$
+
+ p = handler.getEditBlackboard().toPoint(new Coordinate(30, 30));
+ tool.mouseReleased(new MapMouseEvent(handler.getContext().getMapDisplay(), p.getX(),
+ p.getY(), 0, 0, MapMouseEvent.BUTTON1));
+
+ assertEquals("feature2", //$NON-NLS-1$
+ handler.getContext().getEditManager().getEditFeature().getAttribute("name")); //$NON-NLS-1$
}
-
+
}