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

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


  public boolean addFeature(Feature feature) {
    if (!features.containsKey(feature.getId())) {
      features.put(feature.getId(), feature);
      return true;
    } else {
      Feature localFeature = features.get(feature.getId());
      if (feature.isAttributesLoaded()) {
        localFeature.setAttributes(feature.getAttributes());
      }
      if (feature.isGeometryLoaded()) {
        localFeature.setGeometry(feature.getGeometry());
      }
      localFeature.setDeletable(feature.isDeletable());
      localFeature.setUpdatable(feature.isUpdatable());
      localFeature.setStyleId(feature.getStyleId());
      return false;
    }
  }
View Full Code Here


  /**
   * This method is used only when selection is enabled (see setSelectionEnabled). When a feature deselection event is
   * sent out from the MapModel, check if we have that row selected and deselect it.
   */
  public void onFeatureDeselected(FeatureDeselectedEvent event) {
    Feature feature = event.getFeature();

    // Only deselect if it is actually selected:
    boolean selected = false;
    ListGridRecord[] selections = getSelection();
    for (ListGridRecord selection : selections) {
      if (selection.getAttribute(FEATURE_ID_FIELD_NAME).equals(feature.getId())) {
        selected = true;
        break;
      }
    }

    // If selected, find the correct row and deselect:
    if (selected) {
      ListGridRecord[] records = this.getRecords();
      for (int i = 0; i < records.length; i++) {
        if (records[i].getAttribute(FEATURE_ID_FIELD_NAME).equals(feature.getId())) {
          deselectRecord(records[i]);
          break;
        }
      }
    }
View Full Code Here

  /**
   * This method is used only when selection is enabled (see setSelectionEnabled). When a feature selection event is
   * sent out from the MapModel, check if we have that row deselected and select it.
   */
  public void onFeatureSelected(FeatureSelectedEvent event) {
    Feature feature = event.getFeature();

    // Only select if it is actually deselected:
    boolean selected = false;
    ListGridRecord[] selections = getSelection();
    for (ListGridRecord selection : selections) {
      if (selection.getAttribute(FEATURE_ID_FIELD_NAME).equals(feature.getId())) {
        selected = true;
        break;
      }
    }

    // If deselected, find the correct row and select:
    if (!selected) {
      ListGridRecord[] records = this.getRecords();
      for (int i = 0; i < records.length; i++) {
        if (records[i].getAttribute(FEATURE_ID_FIELD_NAME).equals(feature.getId())) {
          selectRecord(i);
          break;
        }
      }
    }
View Full Code Here

  public int size() {
    return features.size();
  }

  public Feature newFeature() {
    return new Feature(getLayer());
  }
View Full Code Here

  @Test
  public void testSelectDeselectFeature() {
    org.geomajas.layer.feature.Feature dto1 = new org.geomajas.layer.feature.Feature();
    dto1.setId("feat1");
    Feature feature1 = new Feature(dto1, layer1);

    org.geomajas.layer.feature.Feature dto2 = new org.geomajas.layer.feature.Feature();
    dto2.setId("feat2");
    Feature feature2 = new Feature(dto2, layer1);

    Assert.assertFalse(feature1.isSelected());
    Assert.assertFalse(feature2.isSelected());
    Assert.assertEquals(0, selectedCount);
    Assert.assertEquals(0, deselectedCount);
    Assert.assertNull(lastFeatureId);

    layer1.selectFeature(feature1);
    Assert.assertTrue(feature1.isSelected());
    Assert.assertFalse(feature2.isSelected());
    Assert.assertEquals(1, selectedCount);
    Assert.assertEquals(0, deselectedCount);
    Assert.assertEquals("feat1", lastFeatureId);
    lastFeatureId = null;

    layer1.selectFeature(feature2);
    Assert.assertTrue(feature1.isSelected());
    Assert.assertTrue(feature2.isSelected());
    Assert.assertEquals(2, selectedCount);
    Assert.assertEquals(0, deselectedCount);
    Assert.assertEquals("feat2", lastFeatureId);

    layer1.deselectFeature(feature1);
    Assert.assertFalse(feature1.isSelected());
    Assert.assertTrue(feature2.isSelected());
    Assert.assertEquals(2, selectedCount);
    Assert.assertEquals(1, deselectedCount);
    Assert.assertEquals("feat1", lastFeatureId);
  }
View Full Code Here

  @Test
  public void testDeselectLayer() {
    org.geomajas.layer.feature.Feature dto1 = new org.geomajas.layer.feature.Feature();
    dto1.setId("feat1");
    Feature feature1 = new Feature(dto1, layer1);

    org.geomajas.layer.feature.Feature dto2 = new org.geomajas.layer.feature.Feature();
    dto2.setId("feat2");
    Feature feature2 = new Feature(dto2, layer1);

    Assert.assertFalse(feature1.isSelected());
    Assert.assertFalse(feature2.isSelected());
    Assert.assertEquals(0, selectedCount);
    Assert.assertEquals(0, deselectedCount);

    mapModel.selectLayer(layer1);
    Assert.assertFalse(feature1.isSelected());
    Assert.assertFalse(feature2.isSelected());
    Assert.assertEquals(0, selectedCount);
    Assert.assertEquals(0, deselectedCount);

    layer1.selectFeature(feature1);
    layer1.selectFeature(feature2);
    Assert.assertTrue(feature1.isSelected());
    Assert.assertTrue(feature2.isSelected());
    Assert.assertEquals(2, selectedCount);
    Assert.assertEquals(0, deselectedCount);

    mapModel.selectLayer(layer1);
    Assert.assertTrue(feature1.isSelected());
    Assert.assertTrue(feature2.isSelected());
    Assert.assertEquals(2, selectedCount);
    Assert.assertEquals(0, deselectedCount);

    mapModel.selectLayer(layer2);
    Assert.assertTrue(feature1.isSelected());
    Assert.assertTrue(feature2.isSelected());
    Assert.assertEquals(2, selectedCount);
    Assert.assertEquals(0, deselectedCount);
  }
View Full Code Here

    op = new RemoveRingOp(index);
  }

  @Test
  public void testPolygon() {
    Feature feature = new Feature();
    feature.setGeometry((Polygon) polygon.clone());
    op.execute(feature);
    Polygon p = (Polygon) feature.getGeometry();
    LinearRing r = p.getInteriorRingN(index.getInteriorRingIndex());
    Assert.assertEquals(60.0, r.getCoordinateN(0).getX(), DELTA);
    op.undo(feature);
    Assert.assertEquals(polygon.toWkt(), feature.getGeometry().toWkt());
  }
View Full Code Here

    Assert.assertEquals(polygon.toWkt(), feature.getGeometry().toWkt());
  }

  @Test
  public void testMultiPolygon() {
    Feature feature = new Feature();
    feature.setGeometry((MultiPolygon) multiPolygon.clone());
    op.execute(feature);
    MultiPolygon m = (MultiPolygon) feature.getGeometry();
    Polygon p = (Polygon) m.getGeometryN(index.getGeometryIndex());
    LinearRing r = p.getInteriorRingN(index.getInteriorRingIndex());
    Assert.assertEquals(60.0, r.getCoordinateN(0).getX(), DELTA);
    op.undo(feature);
    Assert.assertEquals(multiPolygon.toWkt(), feature.getGeometry().toWkt());
  }
View Full Code Here

    op = new RemoveCoordinateOp(index);
  }

  @Test
  public void testLineString() {
    Feature feature = new Feature();
    feature.setGeometry((LineString) lineString.clone());
    op.execute(feature);
    LineString l = (LineString) feature.getGeometry();
    Assert.assertEquals(30.0, l.getCoordinateN(index.getCoordinateIndex()).getX(), DELTA);
    op.undo(feature);
    Assert.assertEquals(lineString.toWkt(), feature.getGeometry().toWkt());
  }
View Full Code Here

    Assert.assertEquals(lineString.toWkt(), feature.getGeometry().toWkt());
  }

  @Test
  public void testMultiLineString() {
    Feature feature = new Feature();
    feature.setGeometry((MultiLineString) multiLineString.clone());
    op.execute(feature);
    MultiLineString m = (MultiLineString) feature.getGeometry();
    LineString l = (LineString) m.getGeometryN(index.getGeometryIndex());
    Assert.assertEquals(30.0, l.getCoordinateN(index.getCoordinateIndex()).getX(), DELTA);
    op.undo(feature);
    Assert.assertEquals(multiLineString.toWkt(), feature.getGeometry().toWkt());
  }
View Full Code Here

TOP

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

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.