use of org.cesiumjs.cs.scene.interaction.options.DrawInteractionOptions in project gwt-cs by iSergio.
the class Drawing method buildPanel.
@Override
public void buildPanel() {
csVPanel = new ViewerPanel();
csVPanel.getViewer().scene().globe.depthTestAgainstTerrain = true;
Image image = new Image(GWT.getModuleBaseURL() + "images/point.png");
image.setPixelSize(22, 22);
drawPointTBtn = new ToggleButton(image);
drawPointTBtn.setPixelSize(22, 22);
drawPointTBtn.getElement().getStyle().setBackgroundImage("none");
drawPointTBtn.getElement().getStyle().setBorderColor("rgba(63,66,70,1)");
drawPointTBtn.getElement().getStyle().setBackgroundColor("rgba(63,66,70,0.7)");
drawPointTBtn.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
drawExtentTBtn.setValue(false, false);
drawPolygonTBtn.setValue(false, false);
drawCircleTBtn.setValue(false, false);
if (drawInteraction != null) {
drawInteraction.destroy();
drawInteraction = null;
}
if (event.getValue()) {
DrawInteractionOptions options = new DrawInteractionOptions();
options.type = PrimitiveType.POINT;
options.markerType = MarkerType.BILLBOARD_GRAPHIC;
drawInteraction = new DrawInteraction(csVPanel.getViewer().scene(), options);
drawInteraction.addDrawListener(new DrawInteractionListener(), DrawInteraction.EventType.DRAW_END);
}
}
});
image = new Image(GWT.getModuleBaseURL() + "images/line.png");
image.setPixelSize(22, 22);
drawLineTBtn = new ToggleButton(image);
drawLineTBtn.setPixelSize(22, 22);
drawLineTBtn.getElement().getStyle().setBackgroundImage("none");
drawLineTBtn.getElement().getStyle().setBorderColor("rgba(63,66,70,1)");
drawLineTBtn.getElement().getStyle().setBackgroundColor("rgba(63,66,70,0.7)");
drawLineTBtn.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
drawExtentTBtn.setValue(false, false);
drawPolygonTBtn.setValue(false, false);
drawCircleTBtn.setValue(false, false);
if (drawInteraction != null) {
drawInteraction.destroy();
drawInteraction = null;
}
if (event.getValue()) {
DrawInteractionOptions options = new DrawInteractionOptions();
options.type = PrimitiveType.CORRIDOR;
options.markerType = MarkerType.BILLBOARD_GRAPHIC;
drawInteraction = new DrawInteraction(csVPanel.getViewer().scene(), options);
drawInteraction.addDrawListener(new DrawInteractionListener(), DrawInteraction.EventType.DRAW_END);
}
}
});
image = new Image(GWT.getModuleBaseURL() + "images/rect.png");
image.setPixelSize(22, 22);
drawExtentTBtn = new ToggleButton(image);
drawExtentTBtn.setPixelSize(22, 22);
drawExtentTBtn.getElement().getStyle().setBackgroundImage("none");
drawExtentTBtn.getElement().getStyle().setBorderColor("rgba(63,66,70,1)");
drawExtentTBtn.getElement().getStyle().setBackgroundColor("rgba(63,66,70,0.7)");
drawExtentTBtn.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
drawLineTBtn.setValue(false, false);
drawPolygonTBtn.setValue(false, false);
drawCircleTBtn.setValue(false, false);
if (drawInteraction != null) {
drawInteraction.destroy();
drawInteraction = null;
}
if (event.getValue()) {
DrawInteractionOptions options = new DrawInteractionOptions();
options.markerType = MarkerType.BILLBOARD_GRAPHIC;
options.outlineColor = Color.RED();
options.outlineWidth = 1;
drawInteraction = new DrawInteraction(csVPanel.getViewer().scene(), options);
drawInteraction.addDrawListener(new DrawInteractionListener(), DrawInteraction.EventType.DRAW_END);
// As Entity
// drawInteraction.addDrawListener(new DrawInteraction.Listener() {
// @Override
// public void onDraw(DrawInteraction.Event event) {
// if (!(event.getPrimitive() instanceof RectanglePrimitive)) {
// return;
// }
// RectanglePrimitive primitive = ((RectanglePrimitive) event.getPrimitive());
// Rectangle rectangle = primitive.getRectangle();
//
// RectangleGraphicsOptions rectangleGraphicsOptions = new RectangleGraphicsOptions();
// rectangleGraphicsOptions.coordinates = new ConstantProperty<>(rectangle);
// rectangleGraphicsOptions.material = new ColorMaterialProperty(Color.RED().withAlpha(0.5f));
//
// EntityOptions entityOptions = new EntityOptions();
// entityOptions.rectangle = new RectangleGraphics(rectangleGraphicsOptions);
//
// csVPanel.getViewer().entities().add(entityOptions);
// }
// }, DrawInteraction.EventType.DRAW_END);
}
}
});
image = new Image(GWT.getModuleBaseURL() + "images/polygon.png");
image.setPixelSize(22, 22);
drawPolygonTBtn = new ToggleButton(image);
drawPolygonTBtn.setPixelSize(22, 22);
drawPolygonTBtn.getElement().getStyle().setBackgroundImage("none");
drawPolygonTBtn.getElement().getStyle().setBorderColor("rgba(63,66,70,1)");
drawPolygonTBtn.getElement().getStyle().setBackgroundColor("rgba(63,66,70,0.7)");
drawPolygonTBtn.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
drawLineTBtn.setValue(false, false);
drawExtentTBtn.setValue(false, false);
drawCircleTBtn.setValue(false, false);
if (drawInteraction != null) {
drawInteraction.destroy();
drawInteraction = null;
}
if (event.getValue()) {
DrawInteractionOptions options = new DrawInteractionOptions();
options.type = PrimitiveType.POLYGON;
options.markerType = MarkerType.BILLBOARD_GRAPHIC;
options.color = Color.BLUE().withAlpha(0.5f);
drawInteraction = new DrawInteraction(csVPanel.getViewer().scene(), options);
// As GroundPrimitive
drawInteraction.addDrawListener(new DrawInteractionListener(), DrawInteraction.EventType.DRAW_END);
}
}
});
image = new Image(GWT.getModuleBaseURL() + "images/circle.png");
image.setPixelSize(22, 22);
drawCircleTBtn = new ToggleButton(image);
drawCircleTBtn.setPixelSize(22, 22);
drawCircleTBtn.getElement().getStyle().setBackgroundImage("none");
drawCircleTBtn.getElement().getStyle().setBorderColor("rgba(63,66,70,1)");
drawCircleTBtn.getElement().getStyle().setBackgroundColor("rgba(63,66,70,0.7)");
drawCircleTBtn.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
drawLineTBtn.setValue(false, false);
drawExtentTBtn.setValue(false, false);
drawPolygonTBtn.setValue(false, false);
if (drawInteraction != null) {
drawInteraction.destroy();
drawInteraction = null;
}
if (event.getValue()) {
DrawInteractionOptions options = new DrawInteractionOptions();
options.type = PrimitiveType.CIRCLE;
options.markerType = MarkerType.BILLBOARD_GRAPHIC;
drawInteraction = new DrawInteraction(csVPanel.getViewer().scene(), options);
// As GroundPrimitive
drawInteraction.addDrawListener(new DrawInteractionListener(), DrawInteraction.EventType.DRAW_END);
}
}
});
final FlexTable flexTable = new FlexTable();
flexTable.setWidget(1, 0, drawPointTBtn);
flexTable.setWidget(2, 0, drawLineTBtn);
flexTable.setWidget(3, 0, drawExtentTBtn);
flexTable.setWidget(4, 0, drawPolygonTBtn);
flexTable.setWidget(5, 0, drawCircleTBtn);
final AbsolutePanel aPanel = new AbsolutePanel();
aPanel.add(csVPanel);
aPanel.add(flexTable, RootPanel.get().getOffsetWidth() - 74, 42);
contentPanel.add(new HTML("<p>Use Viewer to start building new applications or easily embed Cesium into existing applications.</p>"));
contentPanel.add(aPanel);
Window.addResizeHandler(new ResizeHandler() {
@Override
public void onResize(ResizeEvent resizeEvent) {
aPanel.setWidgetPosition(flexTable, RootPanel.get().getOffsetWidth() - 74, 42);
}
});
initWidget(contentPanel);
}
Aggregations