Search in sources :

Example 16 with FeatureTypeConstraint

use of org.geotools.styling.FeatureTypeConstraint in project sldeditor by robward-scisys.

the class FieldConfigFeatureTypeConstraintTest method testUndoAction.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.featuretypeconstraint.FieldConfigFeatureTypeConstraint#undoAction(com.sldeditor.common.undo.UndoInterface)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.featuretypeconstraint.FieldConfigFeatureTypeConstraint#redoAction(com.sldeditor.common.undo.UndoInterface)}.
 */
@Test
public void testUndoAction() {
    FieldConfigFeatureTypeConstraint field = new FieldConfigFeatureTypeConstraint(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", true));
    field.undoAction(null);
    field.redoAction(null);
    field.createUI();
    StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
    FeatureTypeConstraint expectedValue1 = styleFactory.createFeatureTypeConstraint("Feature", Filter.INCLUDE, new Extent[0]);
    List<FeatureTypeConstraint> testValue = new ArrayList<FeatureTypeConstraint>();
    testValue.add(expectedValue1);
    field.populateField(testValue);
    assertEquals(expectedValue1, field.getFeatureTypeConstraint().get(0));
    FeatureTypeConstraint expectedValue2 = styleFactory.createFeatureTypeConstraint("Feature2", Filter.INCLUDE, new Extent[0]);
    List<FeatureTypeConstraint> testValue2 = new ArrayList<FeatureTypeConstraint>();
    testValue2.add(expectedValue1);
    testValue2.add(expectedValue2);
    field.populateField(testValue2);
    UndoManager.getInstance().undo();
    assertEquals(1, field.getFeatureTypeConstraint().size());
    assertEquals(expectedValue1, field.getFeatureTypeConstraint().get(0));
    UndoManager.getInstance().redo();
    assertEquals(2, field.getFeatureTypeConstraint().size());
    assertEquals(expectedValue2, field.getFeatureTypeConstraint().get(1));
    // Increase the code coverage
    field.undoAction(null);
    field.undoAction(new UndoEvent(null, FieldIdEnum.NAME, "", "new"));
    field.redoAction(null);
    field.redoAction(new UndoEvent(null, FieldIdEnum.NAME, "", "new"));
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) UndoEvent(com.sldeditor.common.undo.UndoEvent) FeatureTypeConstraint(org.geotools.styling.FeatureTypeConstraint) FieldConfigFeatureTypeConstraint(com.sldeditor.ui.detail.config.featuretypeconstraint.FieldConfigFeatureTypeConstraint) StyleFactoryImpl(org.geotools.styling.StyleFactoryImpl) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) ArrayList(java.util.ArrayList) FieldConfigFeatureTypeConstraint(com.sldeditor.ui.detail.config.featuretypeconstraint.FieldConfigFeatureTypeConstraint) Test(org.junit.Test)

Example 17 with FeatureTypeConstraint

use of org.geotools.styling.FeatureTypeConstraint in project sldeditor by robward-scisys.

the class ExtentModelTest method testUpdateExtent.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.featuretypeconstraint.ExtentModel#updateExtent(org.geotools.styling.FeatureTypeConstraint)}.
 */
@Test
public void testUpdateExtent() {
    ExtentModel model = new ExtentModel(null);
    Extent[] extentArray = null;
    model.populate(extentArray);
    extentArray = new Extent[2];
    StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
    extentArray[0] = styleFactory.createExtent("extent 1", "1 1 1 1");
    extentArray[1] = styleFactory.createExtent("extent 2", "2 2 2 2");
    model.populate(extentArray);
    FeatureTypeConstraint ftc = styleFactory.createFeatureTypeConstraint("feature type name", Filter.INCLUDE, null);
    model.updateExtent(null);
    model.updateExtent(ftc);
    assertNotNull(ftc.getExtents());
    assertEquals(2, ftc.getExtents().length);
}
Also used : FeatureTypeConstraint(org.geotools.styling.FeatureTypeConstraint) ExtentModel(com.sldeditor.ui.detail.config.featuretypeconstraint.ExtentModel) Extent(org.geotools.styling.Extent) StyleFactoryImpl(org.geotools.styling.StyleFactoryImpl) Test(org.junit.Test)

Example 18 with FeatureTypeConstraint

use of org.geotools.styling.FeatureTypeConstraint in project sldeditor by robward-scisys.

the class NamedLayerDetails method updateSymbol.

/**
 * Update symbol.
 */
private void updateSymbol() {
    if (!Controller.getInstance().isPopulating()) {
        String name = fieldConfigVisitor.getText(FieldIdEnum.NAME);
        NamedLayer namedLayer = getStyleFactory().createNamedLayer();
        namedLayer.setName(name);
        // Feature type constraints
        List<FeatureTypeConstraint> ftcList = fieldConfigVisitor.getFeatureTypeConstraint(FieldIdEnum.LAYER_FEATURE_CONSTRAINTS);
        if ((ftcList != null) && !ftcList.isEmpty()) {
            FeatureTypeConstraint[] ftcArray = new FeatureTypeConstraint[ftcList.size()];
            namedLayer.setLayerFeatureConstraints(ftcList.toArray(ftcArray));
        }
        StyledLayer existingStyledLayer = SelectedSymbol.getInstance().getStyledLayer();
        if (existingStyledLayer instanceof NamedLayerImpl) {
            NamedLayerImpl existingNamedLayer = (NamedLayerImpl) existingStyledLayer;
            for (Style style : existingNamedLayer.styles()) {
                namedLayer.addStyle(style);
            }
        }
        SelectedSymbol.getInstance().replaceStyledLayer(namedLayer);
        this.fireUpdateSymbol();
    }
}
Also used : FeatureTypeConstraint(org.geotools.styling.FeatureTypeConstraint) StyledLayer(org.geotools.styling.StyledLayer) NamedLayerImpl(org.geotools.styling.NamedLayerImpl) Style(org.geotools.styling.Style) NamedLayer(org.geotools.styling.NamedLayer)

Aggregations

FeatureTypeConstraint (org.geotools.styling.FeatureTypeConstraint)18 Test (org.junit.Test)6 StyleFactoryImpl (org.geotools.styling.StyleFactoryImpl)4 StyledLayer (org.geotools.styling.StyledLayer)4 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)3 Extent (org.geotools.styling.Extent)3 Style (org.geotools.styling.Style)3 UndoEvent (com.sldeditor.common.undo.UndoEvent)2 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)2 GroupConfigInterface (com.sldeditor.ui.detail.config.base.GroupConfigInterface)2 MultiOptionGroup (com.sldeditor.ui.detail.config.base.MultiOptionGroup)2 FieldConfigFeatureTypeConstraint (com.sldeditor.ui.detail.config.featuretypeconstraint.FieldConfigFeatureTypeConstraint)2 Geometry (com.vividsolutions.jts.geom.Geometry)2 NamedLayerImpl (org.geotools.styling.NamedLayerImpl)2 RemoteOWS (org.geotools.styling.RemoteOWS)2 UserLayer (org.geotools.styling.UserLayer)2 UserLayerImpl (org.geotools.styling.UserLayerImpl)2 DataSourceInterface (com.sldeditor.datasource.DataSourceInterface)1 FilterPanelInterface (com.sldeditor.filter.FilterPanelInterface)1 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)1