Omaha #4375: Prevent Damage Path tool from creating vertices too close to a current vertex, fix ConcurrentModificationException on init.
Change-Id: Icbe56d770f5675fd55d6db8a35b17664b77ae6a8 Former-commit-id: 9fab39412385d87c923de7406b03347139352cde
This commit is contained in:
parent
f56c255ebd
commit
ab91a73c50
2 changed files with 12 additions and 16 deletions
|
@ -76,6 +76,8 @@ import com.vividsolutions.jts.geom.Polygon;
|
||||||
* Jun 03, 2015 4375 dgilling Support changes to PolygonLayer for
|
* Jun 03, 2015 4375 dgilling Support changes to PolygonLayer for
|
||||||
* multiple polygon support.
|
* multiple polygon support.
|
||||||
* Jun 08, 2015 4355 dgilling Fix NullPointerException in loadJob.
|
* Jun 08, 2015 4355 dgilling Fix NullPointerException in loadJob.
|
||||||
|
* Jun 12, 2015 4375 dgilling Fix ConcurrentModificationException in
|
||||||
|
* initInternal.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -119,10 +121,6 @@ public class DamagePathLayer<T extends DamagePathResourceData> extends
|
||||||
.valueOf(System.getProperty("damage.path.localization.level",
|
.valueOf(System.getProperty("damage.path.localization.level",
|
||||||
LocalizationLevel.USER.name()));
|
LocalizationLevel.USER.name()));
|
||||||
|
|
||||||
/*
|
|
||||||
* TODO: If we support multiple polygons in the future then the jobs will
|
|
||||||
* need to be smart enough to load/save different files.
|
|
||||||
*/
|
|
||||||
private final Job loadJob = new Job("Loading Damage Path") {
|
private final Job loadJob = new Job("Loading Damage Path") {
|
||||||
@Override
|
@Override
|
||||||
protected IStatus run(IProgressMonitor monitor) {
|
protected IStatus run(IProgressMonitor monitor) {
|
||||||
|
@ -136,7 +134,10 @@ public class DamagePathLayer<T extends DamagePathResourceData> extends
|
||||||
.error("The damage path file was invalid. The polygon has been reset.");
|
.error("The damage path file was invalid. The polygon has been reset.");
|
||||||
setDefaultPolygon();
|
setDefaultPolygon();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
setDefaultPolygon();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Status.OK_STATUS;
|
return Status.OK_STATUS;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -158,21 +159,13 @@ public class DamagePathLayer<T extends DamagePathResourceData> extends
|
||||||
dir.addFileUpdatedObserver(this);
|
dir.addFileUpdatedObserver(this);
|
||||||
|
|
||||||
loadJob.setSystem(true);
|
loadJob.setSystem(true);
|
||||||
loadJob.schedule();
|
|
||||||
saveJob.setSystem(true);
|
saveJob.setSystem(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initInternal(IGraphicsTarget target) throws VizException {
|
protected void initInternal(IGraphicsTarget target) throws VizException {
|
||||||
super.initInternal(target);
|
super.initInternal(target);
|
||||||
LocalizationFile prevFile = getValidDamagePathFile();
|
loadJob.schedule();
|
||||||
if (polygons.isEmpty() && prevFile != null) {
|
|
||||||
/*
|
|
||||||
* only get here if there is no previous file, otherwise loadJob
|
|
||||||
* will load the polygon
|
|
||||||
*/
|
|
||||||
setDefaultPolygon();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setDefaultPolygon() {
|
private void setDefaultPolygon() {
|
||||||
|
|
|
@ -57,6 +57,8 @@ import com.vividsolutions.jts.geom.Polygon;
|
||||||
* Jan 19, 2015 3974 njensen Initial creation
|
* Jan 19, 2015 3974 njensen Initial creation
|
||||||
* Mar 31, 2015 3977 nabowle Require non-empty coordinates in resetPolygon
|
* Mar 31, 2015 3977 nabowle Require non-empty coordinates in resetPolygon
|
||||||
* May 15, 2015 4375 dgilling Support multiple polygons.
|
* May 15, 2015 4375 dgilling Support multiple polygons.
|
||||||
|
* Jun 12, 2015 4375 dgilling Only show AddVertexAction when on polygon's
|
||||||
|
* edge and not near a current vertex.
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -224,12 +226,13 @@ public class PolygonLayer<T extends AbstractResourceData> extends
|
||||||
public void addContextMenuItems(IMenuManager menuManager, int x, int y) {
|
public void addContextMenuItems(IMenuManager menuManager, int x, int y) {
|
||||||
int edgePolygonIdx = uiInput.pointOnEdge(x, y);
|
int edgePolygonIdx = uiInput.pointOnEdge(x, y);
|
||||||
boolean onEdge = (edgePolygonIdx >= 0);
|
boolean onEdge = (edgePolygonIdx >= 0);
|
||||||
if (onEdge) {
|
|
||||||
menuManager.add(new AddVertexAction(edgePolygonIdx, x, y, uiInput));
|
|
||||||
}
|
|
||||||
|
|
||||||
int[] indices = uiInput.pointOnVertex(x, y);
|
int[] indices = uiInput.pointOnVertex(x, y);
|
||||||
boolean onVertex = (indices != null);
|
boolean onVertex = (indices != null);
|
||||||
|
|
||||||
|
if (onEdge && !onVertex) {
|
||||||
|
menuManager.add(new AddVertexAction(edgePolygonIdx, x, y, uiInput));
|
||||||
|
}
|
||||||
if (onVertex) {
|
if (onVertex) {
|
||||||
int polygonIndex = indices[0];
|
int polygonIndex = indices[0];
|
||||||
int vertexIndex = indices[1];
|
int vertexIndex = indices[1];
|
||||||
|
|
Loading…
Add table
Reference in a new issue