Package org.locationtech.udig.project.ui.commands

Examples of org.locationtech.udig.project.ui.commands.DrawCommandFactory


                shape = linearArc;
            }
        }

        if (drawShapeCommand == null) {
            DrawCommandFactory dcf = DrawCommandFactory.getInstance();
            drawShapeCommand = dcf.createDrawShapeCommand(shape);
            IToolContext context = handler.getContext();
            ViewportPane viewportPane = context.getViewportPane();
            viewportPane.addDrawCommand(drawShapeCommand);
        } else {
            drawShapeCommand.setShape(shape);
View Full Code Here


     */
    @SuppressWarnings("unchecked")
    private List<UndoableMapCommand> processIntoCommands( EditToolHandler handler, ILayer layer,
            Entry<String, GeometryCreationUtil.Bag> entry ) {
        IMapDisplay display = handler.getContext().getMapDisplay();
        DrawCommandFactory drawfactory = handler.getContext().getDrawFactory();
        SimpleFeatureType schema = layer.getSchema();
        Class<Geometry> binding = (Class<Geometry>) schema.getGeometryDescriptor().getType()
                .getBinding();

        List<UndoableMapCommand> commands = new ArrayList<UndoableMapCommand>();

        EditGeom editGeom = entry.getValue().geom;
        List<Geometry> geoms = entry.getValue().jts;
        Geometry geom = GeometryCreationUtil.ceateGeometryCollection(geoms, binding);

        if (geom == null) { // null is used to mark things for delete?
            IBlockingProvider<ILayer> layerProvider = new StaticBlockingProvider<ILayer>(layer);
            FIDFeatureProvider featureProvider = new FIDFeatureProvider(entry.getKey(),
                    layerProvider);
            DeleteFeatureCommand deleteFeatureCommand = new DeleteFeatureCommand(featureProvider,
                    layerProvider);
            commands.add(deleteFeatureCommand);
        } else {
            // geometry is going to be written out
            if (updateBlackboard) {
                // mostly used to tack on an extra addVertex command
                // so the display is drawn as a closed polygon.
                updateBlackboardGeometry(handler, editGeom, geom, commands);
            }
            GeometryOperationAnimation animation = new GeometryOperationAnimation(
                    EditGeomPathIterator.getPathIterator(editGeom).toShape(),
                    new IsBusyStateProvider(handler));

            UndoableMapCommand startAnimationCommand = drawfactory.createStartAnimationCommand(
                    display, Collections.singletonList((IAnimation) animation));
            commands.add(startAnimationCommand);

            if (isCurrentGeometry(handler, editGeom)) {
                if (isCreatingNewFeature(handler)) {
                    int attributeCount = schema.getAttributeCount();
                    SimpleFeature feature;
                    try {
                        feature = SimpleFeatureBuilder.template(schema, "newFeature"
                                + new Random().nextInt());
                        // feature = SimpleFeatureBuilder.build(schema, new
                        // Object[attributeCount],"newFeature");
                        feature.setDefaultGeometry(geom);
                    } catch (IllegalAttributeException e) {
                        throw new IllegalStateException(
                                "Could not create an empty " + schema.getTypeName() + ":" + e, e); //$NON-NLS-1$//$NON-NLS-2$
                    }
                   
                    CreateFeatureCommand.runFeatureCreationInterceptors(feature);
                   
                    // FeaturePanelProcessor panels = ProjectUIPlugin.getDefault()
                    // .getFeaturePanelProcessor();
                    // List<FeaturePanelEntry> popup = panels.search(schema);
                    // if (popup.isEmpty()) {
                    CreateAndSelectNewFeature newFeatureCommand = new CreateAndSelectNewFeature(
                            handler.getCurrentGeom(), feature, layer, deselectCreatedFeatures);
                    commands.add(newFeatureCommand);
                    // } else {
                    // CreateDialogAndSelectNewFeature newFeatureCommand = new
                    // CreateDialogAndSelectNewFeature(
                    // handler.getCurrentGeom(), feature, layer, deselectCreatedFeatures,
                    // popup);
                    // commands.add(newFeatureCommand);
                    // }
                } else {
                    // not creating it so don't need to set it.
                    UndoableMapCommand setGeometryCommand = new SetGeometryCommand(editGeom
                            .getFeatureIDRef().get(), new StaticBlockingProvider<ILayer>(layer),
                            SetGeometryCommand.DEFAULT, geom);
                    commands.add(setGeometryCommand);
                }
            } else {
                commands.add(new CreateNewOrSelectExitingFeatureCommand(editGeom.getFeatureIDRef()
                        .get(), layer, geom));

            }
            commands.add(new SetEditGeomChangedStateCommand(editGeom, false));
            commands.add(drawfactory.createStopAnimationCommand(display, Collections
                    .singletonList((IAnimation) animation)));
        }
        return commands;
    }
View Full Code Here

TOP

Related Classes of org.locationtech.udig.project.ui.commands.DrawCommandFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.