@Override public void dispose() { digitizerModule.setDigitizingAction(null); if (drawingPane != null && drawingPane.getDrawObjectsAsGeoPoints() != null) { drawingPane.getDrawObjectsAsGeoPoints().clear(); } digitizerModule.resetDigitizerPane(); digitizerModule.resetFunctionSelect(); digitizerModule.getMapModule().update(); super.dispose(); }
public void createArc() { List<Point> points = drawingPane.getDrawObjectsAsGeoPoints(); ApplicationContainer<?> appCont = digitizerModule.getApplicationContainer(); if (points.size() >= 3) { try { Curve curve = GeometryUtils.calcCircleCoordinates( points.get(0).getPosition(), getRadius(), getNoOfVertices(), points.get(1).getPosition(), points.get(2).getPosition(), points.get(1).getCoordinateSystem()); MapModel mapModel = appCont.getMapModel(null); Layer layer = mapModel.getLayersSelectedForAction(MapModel.SELECTION_EDITING).get(0); FeatureAdapter featureAdapter = (FeatureAdapter) layer.getDataAccess().get(0); FeatureType ft = featureAdapter.getSchema(); Feature feat = featureAdapter.getDefaultFeature(ft.getName()); feat = feat.cloneDeep(); QualifiedName geomProperty = ft.getGeometryProperties()[0].getName(); feat.getProperties(geomProperty)[0].setValue(curve); Command cmd = new InsertFeatureCommand(featureAdapter, feat); appCont.getCommandProcessor().executeSychronously(cmd, true); } catch (Exception ex) { LOG.logError(ex); DialogFactory.openErrorDialog( appCont.getViewPlatform(), DrawArcDialog.this, Messages.getMessage(getLocale(), "$MD11628"), Messages.getMessage(getLocale(), "$MD11629"), ex); } } }
/** updates geometry with current ({@link #spArc}) arc */ private void applyArc() { List<Point> points = drawingPane.getDrawObjectsAsGeoPoints(); if (points.size() > 2) { double d = GeometryUtils.distance(points.get(1).getPosition(), points.get(0).getPosition()); Point p = GeometryUtils.vectorByAngle( points.get(1), points.get(0), d, Math.toRadians(getArc()), false); points.set(2, p); digitizerModule.getMapModule().update(); } }
/** updates geometry with current ({@link #spArcRadius}) radius */ private void applyRadius() { List<Point> points = drawingPane.getDrawObjectsAsGeoPoints(); if (points.size() > 2) { // calculate new end point for first vector double[] lineParam = LineUtils.getLineFromPoints( points.get(0).getX(), points.get(0).getY(), points.get(1).getX(), points.get(1).getY()); Pair<Position, Position> pair1 = LineUtils.getSymmetricPoints( points.get(0).getX(), points.get(0).getY(), lineParam[0], getRadius()); // calculate new end point for second vector lineParam = LineUtils.getLineFromPoints( points.get(0).getX(), points.get(0).getY(), points.get(2).getX(), points.get(2).getY()); Pair<Position, Position> pair2 = LineUtils.getSymmetricPoints( points.get(0).getX(), points.get(0).getY(), lineParam[0], getRadius()); // must check to ensure correct direction if (points.get(1).getX() >= points.get(0).getX()) { points.set( 1, GeometryFactory.createPoint(pair1.first, points.get(0).getCoordinateSystem())); } else { points.set( 1, GeometryFactory.createPoint(pair1.second, points.get(0).getCoordinateSystem())); } if (points.get(2).getX() >= points.get(0).getX()) { points.set( 2, GeometryFactory.createPoint(pair2.first, points.get(0).getCoordinateSystem())); } else { points.set( 2, GeometryFactory.createPoint(pair2.second, points.get(0).getCoordinateSystem())); } digitizerModule.getMapModule().update(); } }