final DrawFeature drawRegularPolygon = new DrawFeature(vectorLayer, new RegularPolygonHandler()); map.addControl(drawRegularPolygon); drawRegularPolygon.activate(); RegularPolygonHandlerOptions options = new RegularPolygonHandlerOptions(); options.setSides(4); ((RegularPolygonHandler) drawRegularPolygon.getHandler()).setOptions(options);
/** * Remove the most recently added point in the current sketch geometry. * * @return true if an edit was undone. */ public boolean undo() { return DrawFeatureImpl.undo(getJSObject()); }
//Create a style. We want a blue dashed line. final Style drawStyle = new Style(); //create a Style to use drawStyle.setFillColor("white"); drawStyle.setGraphicName("x"); drawStyle.setPointRadius(4); drawStyle.setStrokeWidth(3); drawStyle.setStrokeColor("#66FFFF"); drawStyle.setStrokeDashstyle("dash"); //create a StyleMap using the Style StyleMap drawStyleMap = new StyleMap(drawStyle); //Create PathHanlderOptions using this StyleMap PathHandlerOptions phOpt = new PathHandlerOptions(); phOpt.setStyleMap(drawStyleMap); //Create DrawFeatureOptions and set the PathHandlerOptions (that have the StyleMap, that have the Style we wish) DrawFeatureOptions drawFeatureOptions = new DrawFeatureOptions(); drawFeatureOptions.setHandlerOptions(phOpt); PathHandler pathHanlder = new PathHandler(); // Create the DrawFeature control to draw on the map, and pass the DrawFeatureOptions to control the style of the sketch final DrawFeature drawLine = new DrawFeature(vectorLayer, pathHanlder, drawFeatureOptions); map.addControl(drawLine); drawLine.activate();
/** * Cancel the current sketch. This removes the current sketch and keeps the * drawing control active. */ public void cancel() { DrawFeatureImpl.cancel(getJSObject()); }
/** * Reinsert the most recently removed point resulting from an undo call. The * undo stack is deleted whenever a point is added by other means. * * @return true if an edit was redone. */ public boolean redo() { return DrawFeatureImpl.redo(getJSObject()); }
/** * Finishes the sketch without including the currently drawn point. This * method can be called to terminate drawing programmatically instead of * waiting for the user to end the sketch. */ public void finishSketch() { DrawFeatureImpl.finishSketch(getJSObject()); }
/** * This method returns the Handler associated to the control. The CLASS_NAME * of the handler depends on the kind of control. * * @return Handler */ public <H extends Handler> H getHandler() { return chainHandlerManager.buildHandler(DrawFeatureImpl.getHandler( getJSObject())); }