Skip to content

Commit

Permalink
fix issue56: "CADTools - Drawing Blocks throws NPEs"
Browse files Browse the repository at this point in the history
openjump-gis/openjump#56
using new null safe execute() call in OJ2 now
  • Loading branch information
edeso committed Aug 28, 2022
1 parent f60b5ab commit a0b7fb5
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ protected void gestureFinished() throws Exception {
UndoableCommand cmd = featureDrawingUtil.createAddCommand(geom2,
isRollingBackInvalidEdits(), getPanel(), this);

if (cmd!=null)
execute(cmd);
execute(cmd, true);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

import com.vividsolutions.jump.workbench.JUMPWorkbench;
import com.vividsolutions.jump.workbench.Logger;
import com.vividsolutions.jump.workbench.model.UndoableCommand;

import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.geom.LineSegment;
Expand Down Expand Up @@ -115,11 +117,14 @@ public void gestureFinished() throws Exception {
Integer dimension = (Integer) BlockPanel.dimensionSpinner.getValue();
GeometryUtils.scaleGeometry(geom2, dimension);
GeometryUtils.centerGeometry(geom2, displacement);
geom2.geometryChanged();
// Get the selected layer if layer doesn't exist, add new layer
//getPanel().setViewportInitialized(true);

getPanel().setViewportInitialized(true);
execute(featureDrawingUtil.createAddCommand(geom2, isRollingBackInvalidEdits(), getPanel(), this));
UndoableCommand cmd = featureDrawingUtil.createAddCommand(geom2,
isRollingBackInvalidEdits(), getPanel(), this);

execute(cmd,true);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ protected void gestureFinished() throws Exception {

if (CADToolsOptionsPanel.isGetCentroid()) {
execute(featureDrawingUtil.createAddCommand(p,
isRollingBackInvalidEdits(), getPanel(), this));
isRollingBackInvalidEdits(), getPanel(), this),true);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,15 @@ protected void gestureFinished() throws Exception {
if (CADToolsOptionsPanel.isGetAsPolygon()) {
execute(featureDrawingUtil.createAddCommand(
getPolygonCircleDiameter(), isRollingBackInvalidEdits(),
getPanel(), this));
getPanel(), this),true);
} else {
execute(featureDrawingUtil.createAddCommand(getCircleDiameter(),
isRollingBackInvalidEdits(), getPanel(), this));
isRollingBackInvalidEdits(), getPanel(), this),true);
}

if (CADToolsOptionsPanel.isGetCentroid()) {
execute(featureDrawingUtil.createAddCommand(getCenter(),
isRollingBackInvalidEdits(), getPanel(), this));
isRollingBackInvalidEdits(), getPanel(), this),true);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ protected void gestureFinished() throws Exception {
if (CADToolsOptionsPanel.isGetAsPolygon()) {
execute(featureDrawingUtil.createAddCommand(
getPolygonCircleRadius(), isRollingBackInvalidEdits(),
getPanel(), this));
getPanel(), this),true);
} else {
execute(featureDrawingUtil.createAddCommand(getCircleRadius(),
isRollingBackInvalidEdits(), getPanel(), this));
isRollingBackInvalidEdits(), getPanel(), this),true);
}

if (CADToolsOptionsPanel.isGetCentroid()) {
execute(featureDrawingUtil.createAddCommand(getCenter(),
isRollingBackInvalidEdits(), getPanel(), this));
isRollingBackInvalidEdits(), getPanel(), this),true);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ protected void gestureFinished() throws Exception {
if (CADToolsOptionsPanel.isGetAsPolygon()) {
execute(featureDrawingUtil.createAddCommand(
getPolygonCircleTangent(), isRollingBackInvalidEdits(),
getPanel(), this));
getPanel(), this),true);
} else {
execute(featureDrawingUtil.createAddCommand(getCircleTangent(),
isRollingBackInvalidEdits(), getPanel(), this));
isRollingBackInvalidEdits(), getPanel(), this),true);
}

if (CADToolsOptionsPanel.isGetCentroid()) {
execute(featureDrawingUtil.createAddCommand(getCenter(),
isRollingBackInvalidEdits(), getPanel(), this));
isRollingBackInvalidEdits(), getPanel(), this),true);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ protected void gestureFinished() throws Exception {

if (CADToolsOptionsPanel.isGetAsPolygon()) {
execute(featureDrawingUtil.createAddCommand(getPolygonCircle(),
isRollingBackInvalidEdits(), getPanel(), this));
isRollingBackInvalidEdits(), getPanel(), this),true);
} else {
execute(featureDrawingUtil.createAddCommand(getCircle(),
isRollingBackInvalidEdits(), getPanel(), this));
isRollingBackInvalidEdits(), getPanel(), this),true);
}
if (CADToolsOptionsPanel.isGetCentroid()) {
execute(featureDrawingUtil.createAddCommand(getCenter(),
isRollingBackInvalidEdits(), getPanel(), this));
isRollingBackInvalidEdits(), getPanel(), this),true);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ protected void gestureFinished() throws Exception {
geom = factory.createPolygon(getParallelogram(), null);

execute(featureDrawingUtil.createAddCommand(geom.getCentroid(),
isRollingBackInvalidEdits(), getPanel(), this));
isRollingBackInvalidEdits(), getPanel(), this),true);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,14 @@ protected void gestureFinished() throws Exception {

if (CADToolsOptionsPanel.isGetAsPolygon()) {
execute(featureDrawingUtil.createAddCommand(getEllipsePolygon(), isRollingBackInvalidEdits(), getPanel(),
this));
this),true);
} else {
execute(featureDrawingUtil.createAddCommand(getEllipseLineString(), isRollingBackInvalidEdits(), getPanel(),
this));
this),true);
}

if (CADToolsOptionsPanel.isGetCentroid()) {
execute(featureDrawingUtil.createAddCommand(getCenter(), isRollingBackInvalidEdits(), getPanel(), this));
execute(featureDrawingUtil.createAddCommand(getCenter(), isRollingBackInvalidEdits(), getPanel(), this),true);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ protected void gestureFinished() throws Exception {

if (CADToolsOptionsPanel.isGetCentroid()) {
execute(featureDrawingUtil.createAddCommand(p,
isRollingBackInvalidEdits(), getPanel(), this));
isRollingBackInvalidEdits(), getPanel(), this),true);
}

}
Expand Down

0 comments on commit a0b7fb5

Please sign in to comment.