Search in sources :

Example 1 with PolygonGraphics

use of org.cesiumjs.cs.datasources.graphics.PolygonGraphics in project gwt-cs by iSergio.

the class Picking method drillDownPicking.

private void drillDownPicking() {
    _pickedEntities = new EntityCollection();
    _pickColor = Color.YELLOW().withAlpha(0.5f);
    PolygonGraphicsOptions polygonGraphicsOptions = new PolygonGraphicsOptions();
    polygonGraphicsOptions.hierarchy = new ConstantProperty<>(new PolygonHierarchy(Cartesian3.fromDegreesArray(new double[] { -70.0, 30.0, -60.0, 30.0, -60.0, 40.0, -70.0, 40.0 })));
    polygonGraphicsOptions.height = new ConstantProperty<>(0);
    EntityOptions entityOptions = new EntityOptions();
    entityOptions.polygon = new PolygonGraphics(polygonGraphicsOptions);
    Entity red = viewerPanel.getViewer().entities().add(new Entity(entityOptions));
    makeProperty(red, Color.RED().withAlpha(0.5f));
    polygonGraphicsOptions = new PolygonGraphicsOptions();
    polygonGraphicsOptions.hierarchy = new ConstantProperty<>(new PolygonHierarchy(Cartesian3.fromDegreesArray(new double[] { -75.0, 34.0, -63.0, 34.0, -63.0, 40.0, -75.0, 40.0 })));
    polygonGraphicsOptions.height = new ConstantProperty<>(0);
    entityOptions = new EntityOptions();
    entityOptions.polygon = new PolygonGraphics(polygonGraphicsOptions);
    Entity blue = viewerPanel.getViewer().entities().add(new Entity(entityOptions));
    makeProperty(blue, Color.BLUE().withAlpha(0.5f));
    polygonGraphicsOptions = new PolygonGraphicsOptions();
    polygonGraphicsOptions.hierarchy = new ConstantProperty<>(new PolygonHierarchy(Cartesian3.fromDegreesArray(new double[] { -67.0, 36.0, -55.0, 36.0, -55.0, 30.0, -67.0, 30.0 })));
    polygonGraphicsOptions.height = new ConstantProperty<>(0);
    entityOptions = new EntityOptions();
    entityOptions.polygon = new PolygonGraphics(polygonGraphicsOptions);
    Entity green = viewerPanel.getViewer().entities().add(new Entity(entityOptions));
    makeProperty(green, Color.GREEN().withAlpha(0.5f));
    // Move the primitive that the mouse is over to the top.
    _handler = new ScreenSpaceEventHandler(viewerPanel.getViewer().scene().canvas());
    _handler.setInputAction(new ScreenSpaceEventHandler.Listener<MouseMoveEvent>() {

        @Override
        public void function(MouseMoveEvent event) {
            PickedObject[] pickedObjects = viewerPanel.getViewer().scene().drillPick(event.endPosition);
            if (pickedObjects != null) {
                _pickedEntities.removeAll();
                for (PickedObject pickedObject : pickedObjects) {
                    Entity entity = (Entity) pickedObject.id;
                    _pickedEntities.add(entity);
                }
            }
        }
    }, ScreenSpaceEventType.MOUSE_MOVE());
}
Also used : Entity(org.cesiumjs.cs.datasources.Entity) MouseMoveEvent(org.cesiumjs.cs.core.events.MouseMoveEvent) EntityCollection(org.cesiumjs.cs.collections.EntityCollection) PolygonGraphicsOptions(org.cesiumjs.cs.datasources.graphics.options.PolygonGraphicsOptions) PolygonGraphics(org.cesiumjs.cs.datasources.graphics.PolygonGraphics) EntityOptions(org.cesiumjs.cs.datasources.options.EntityOptions)

Aggregations

EntityCollection (org.cesiumjs.cs.collections.EntityCollection)1 MouseMoveEvent (org.cesiumjs.cs.core.events.MouseMoveEvent)1 Entity (org.cesiumjs.cs.datasources.Entity)1 PolygonGraphics (org.cesiumjs.cs.datasources.graphics.PolygonGraphics)1 PolygonGraphicsOptions (org.cesiumjs.cs.datasources.graphics.options.PolygonGraphicsOptions)1 EntityOptions (org.cesiumjs.cs.datasources.options.EntityOptions)1