Package org.geomajas.gwt.client.map.feature

Examples of org.geomajas.gwt.client.map.feature.FeatureTransaction


    }
  }

  public void onMouseUp(MouseUpEvent event) {
    if (event.getNativeButton() != Event.BUTTON_RIGHT) {
      FeatureTransaction featureTransaction = getFeatureTransaction();
      if (featureTransaction != null && parent.getEditMode() == EditMode.INSERT_MODE) {
        // The creation of a new point:
        FeatureOperation op = new AddCoordinateOp(getGeometryIndex(), getWorldPosition(event));
        featureTransaction.execute(op);
        mapWidget.render(featureTransaction, RenderGroup.VECTOR, RenderStatus.DELETE);
        mapWidget.render(featureTransaction, RenderGroup.VECTOR, RenderStatus.ALL);
        updateGeometricInfo();
      } else if (featureTransaction != null && parent.getEditMode() == EditMode.DRAG_MODE
          && dragTargetId != null) {
        // Done dragging a point:
        TransactionGeomIndex index = TransactionGeomIndexUtil.getIndex(dragTargetId);
        // TODO: check validity
        FeatureOperation op = new SetCoordinateOp(index, getWorldPosition(event));
        featureTransaction.execute(op);
        if (dragTransaction != null) {
          mapWidget.render(dragTransaction, RenderGroup.VECTOR, RenderStatus.DELETE);
          dragTransaction = null;
        }
        mapWidget.render(featureTransaction, RenderGroup.VECTOR, RenderStatus.ALL);
View Full Code Here


  // MapController implementation:
  // -------------------------------------------------------------------------


  public void onMouseDown(MouseDownEvent event) {
    FeatureTransaction featureTransaction = getFeatureTransaction();
    if (featureTransaction != null && parent.getEditMode() == EditMode.DRAG_MODE
        && event.getNativeButton() != Event.BUTTON_RIGHT) {
      String targetId = getTargetId(event);
      if (TransactionGeomIndexUtil.isDraggable(targetId)) {
        dragTargetId = targetId;
        if (dragTransaction == null) {
          dragTransaction = (FeatureTransaction) featureTransaction.clone();
        }
        mapWidget.render(featureTransaction, RenderGroup.VECTOR, RenderStatus.DELETE);
        mapWidget.render(dragTransaction, RenderGroup.VECTOR, RenderStatus.ALL);
      }
    }
View Full Code Here

   * Implementation of the <code>MenuItemIfFunction</code> interface. This will determine if the menu action should be
   * enabled or not. In essence, this action will be enabled when the context menu event occurred on the area of a
   * polygon's exterior ring.
   */
  public boolean execute(Canvas target, Menu menu, MenuItem item) {
    FeatureTransaction featureTransaction = mapWidget.getMapModel().getFeatureEditor().getFeatureTransaction();
    if (featureTransaction != null) {
      MenuContext graphics = mapWidget.getMenuContext();
      String targetId = graphics.getRightButtonName();
      if (targetId != null && TransactionGeomIndexUtil.isExteriorRing(targetId, true)) {
        index = TransactionGeomIndexUtil.getIndex(targetId);
View Full Code Here

    setZoomOnScrollEnabled(true);

    mapModel.getFeatureEditor().addEditingHandler(new EditingHandler() {

      public void onEditingChange(EditingEvent event) {
        FeatureTransaction ft = mapModel.getFeatureEditor().getFeatureTransaction();
        if (ft != null) {
          if (event.getEditingEventType().equals(EditingEventType.START_EDITING)) {
            render(ft, RenderGroup.VECTOR, RenderStatus.ALL);
          } else if (event.getEditingEventType().equals(EditingEventType.STOP_EDITING)) {
            render(ft, RenderGroup.VECTOR, RenderStatus.DELETE);
View Full Code Here

  /**
   * Activate editing, and set the correct child editing controller on the parent editing controller.
   */
  public void onClick(MenuItemClickEvent event) {
    if (feature != null && feature.isSelected()) {
      FeatureTransaction ft = mapWidget.getMapModel().getFeatureEditor().startEditing(
          new Feature[] { feature.clone() }, new Feature[] { feature.clone() });
      mapWidget.render(ft, RenderGroup.VECTOR, RenderStatus.ALL);
      VectorLayer vLayer = feature.getLayer();
      if (vLayer.getLayerInfo().getLayerType() == LayerType.POINT) {
        controller.setController(new PointEditController(mapWidget, controller));
View Full Code Here

    }
  }

  public void onMouseUp(MouseUpEvent event) {
    if (event.getNativeButton() != Event.BUTTON_RIGHT) {
      FeatureTransaction featureTransaction = getFeatureTransaction();
      if (featureTransaction != null && parent.getEditMode() == EditMode.INSERT_MODE) {
        // The creation of a new point:
        FeatureOperation op = new AddCoordinateOp(getGeometryIndex(), getWorldPosition(event));
        featureTransaction.execute(op);
        parent.setEditMode(EditMode.DRAG_MODE);

        mapWidget.render(featureTransaction, RenderGroup.VECTOR, RenderStatus.DELETE);
        mapWidget.render(featureTransaction, RenderGroup.VECTOR, RenderStatus.ALL);
        updateGeometricInfo();
      } else if (featureTransaction != null && parent.getEditMode() == EditMode.DRAG_MODE
          && dragTargetId != null) {
        // Done dragging a point:
        TransactionGeomIndex index = TransactionGeomIndexUtil.getIndex(dragTargetId);
        // TODO: snap ???
        FeatureOperation op = new SetCoordinateOp(index, getWorldPosition(event));
        featureTransaction.execute(op);
        if (dragTransaction != null) {
          mapWidget.render(dragTransaction, RenderGroup.VECTOR, RenderStatus.DELETE);
          dragTransaction = null;
        }
        mapWidget.render(featureTransaction, RenderGroup.VECTOR, RenderStatus.ALL);
View Full Code Here

 
  /**
   * Show an overview of geometric attributes of the geometry that's being edited.
   */
  public void showGeometricInfo() {
    FeatureTransaction ft = getFeatureTransaction();
    if (infoLabel == null && ft != null && ft.getNewFeatures() != null && ft.getNewFeatures().length > 0) {
      infoLabel = new GeometricInfoLabel();
      infoLabel.addClickHandler(new DestroyLabelInfoOnClick());
      infoLabel.setGeometry(ft.getNewFeatures()[0].getGeometry());
      infoLabel.animateMove(mapWidget.getWidth() - 155, 10);
    }
  }
View Full Code Here

  /**
   * Update the overview of geometric attributes of the geometry that's being edited.
   */
  public void updateGeometricInfo() {
    FeatureTransaction ft = getFeatureTransaction();
    if (infoLabel != null && ft != null && ft.getNewFeatures() != null && ft.getNewFeatures().length > 0) {
      infoLabel.setGeometry(ft.getNewFeatures()[0].getGeometry());
    }
  }
View Full Code Here

   *
   * @param event
   *            The {@link MenuItemClickEvent} from clicking the action.
   */
  public void onClick(MenuItemClickEvent event) {
    FeatureTransaction featureTransaction = mapWidget.getMapModel().getFeatureEditor().getFeatureTransaction();
    mapWidget.render(featureTransaction, RenderGroup.VECTOR, RenderStatus.DELETE);
    featureTransaction.undoLastOperation();
    mapWidget.render(featureTransaction, RenderGroup.VECTOR, RenderStatus.ALL);
    controller.cleanup();
  }
View Full Code Here

  /**
   * This function tries to find out whether or not this menu item should be enabled. Only if there are more then 1
   * operations in the feature transaction operation queue, will this menu item be enabled.
   */
  public boolean execute(Canvas target, Menu menu, MenuItem item) {
    FeatureTransaction featureTransaction = mapWidget.getMapModel().getFeatureEditor().getFeatureTransaction();
    if (featureTransaction != null) {
      boolean operationCount = featureTransaction.getOperationQueue().size() > 0;
      if (operationCount) {
        // The first addCoordinateOp may not be undone!
        FeatureOperation firstOperation = featureTransaction.getOperationQueue().get(0);
        if (firstOperation instanceof AddCoordinateOp) {
          if (featureTransaction.getNewFeatures()[0].getGeometry().getNumPoints() == 1) {
            return false;
          }
        }

        return true;
View Full Code Here

TOP

Related Classes of org.geomajas.gwt.client.map.feature.FeatureTransaction

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.