Search in sources :

Example 1 with FeatureTypeConstraint

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

the class FieldConfigFeatureTypeConstraintTest method testGenerateExpression.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.featuretypeconstraint.FieldConfigFeatureTypeConstraint#generateExpression()}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.featuretypeconstraint.FieldConfigFeatureTypeConstraint#populateExpression(java.lang.Object)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.featuretypeconstraint.FieldConfigFeatureTypeConstraint#setTestValue(com.sldeditor.ui.detail.config.FieldId, java.util.List)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.featuretypeconstraint.FieldConfigFeatureTypeConstraint#populateField(java.util.List)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.featuretypeconstraint.FieldConfigFeatureTypeConstraint#getFeatureTypeConstraint()}.
 */
@Test
public void testGenerateExpression() {
    FieldConfigFeatureTypeConstraint field = new FieldConfigFeatureTypeConstraint(new FieldConfigCommonData(Geometry.class, FieldIdEnum.NAME, "label", true));
    List<FeatureTypeConstraint> testValue = null;
    field.populate(null);
    field.setTestValue(FieldIdEnum.UNKNOWN, testValue);
    field.populateField(testValue);
    field.createUI();
    assertNull(field.getStringValue());
    StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
    FeatureTypeConstraint expectedValue1 = styleFactory.createFeatureTypeConstraint("Feature", Filter.INCLUDE, new Extent[0]);
    testValue = new ArrayList<FeatureTypeConstraint>();
    testValue.add(expectedValue1);
    field.populateField(testValue);
    assertEquals(expectedValue1, field.getFeatureTypeConstraint().get(0));
    field.setTestValue(FieldIdEnum.UNKNOWN, testValue);
    assertEquals(expectedValue1, field.getFeatureTypeConstraint().get(0));
    field.populateExpression((String) null);
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) 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) FieldConfigFeatureTypeConstraint(com.sldeditor.ui.detail.config.featuretypeconstraint.FieldConfigFeatureTypeConstraint) Test(org.junit.Test)

Example 2 with FeatureTypeConstraint

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

the class FeatureTypeConstraintModelTest method testPopulate.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.featuretypeconstraint.FeatureTypeConstraintModel#populate(java.util.List)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.featuretypeconstraint.FeatureTypeConstraintModel#removeEntries(int, int)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.featuretypeconstraint.FeatureTypeConstraintModel#getFeatureTypeConstraint(int)}.
 */
@Test
public void testPopulate() {
    TestModelUpdate testUpdate = new TestModelUpdate();
    StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
    FeatureTypeConstraintModel model = new FeatureTypeConstraintModel(testUpdate);
    List<FeatureTypeConstraint> ftcList = null;
    model.populate(ftcList);
    ftcList = new ArrayList<FeatureTypeConstraint>();
    ftcList.add(styleFactory.createFeatureTypeConstraint("ftc1", Filter.INCLUDE, new Extent[0]));
    ftcList.add(styleFactory.createFeatureTypeConstraint("ftc2", Filter.INCLUDE, new Extent[0]));
    ftcList.add(styleFactory.createFeatureTypeConstraint("ftc3", Filter.INCLUDE, new Extent[0]));
    ftcList.add(styleFactory.createFeatureTypeConstraint("ftc4", Filter.INCLUDE, new Extent[0]));
    ftcList.add(styleFactory.createFeatureTypeConstraint("ftc5", Filter.INCLUDE, new Extent[0]));
    model.populate(ftcList);
    List<FeatureTypeConstraint> actualList = model.getFeatureTypeConstraint();
    assertEquals(5, actualList.size());
    assertTrue(actualList.get(2).getFeatureTypeName().compareTo("ftc3") == 0);
    assertFalse(testUpdate.hasFTCUpdatedBeenCalled());
    model.removeEntries(-1, 2);
    assertFalse(testUpdate.hasFTCUpdatedBeenCalled());
    model.removeEntries(2, 22);
    assertFalse(testUpdate.hasFTCUpdatedBeenCalled());
    model.removeEntries(22, 2);
    assertFalse(testUpdate.hasFTCUpdatedBeenCalled());
    model.removeEntries(2, 2);
    assertTrue(testUpdate.hasFTCUpdatedBeenCalled());
    actualList = model.getFeatureTypeConstraint();
    assertEquals(4, actualList.size());
    assertTrue(actualList.get(2).getFeatureTypeName().compareTo("ftc4") == 0);
    assertNull(model.getFeatureTypeConstraint(-1));
    assertNull(model.getFeatureTypeConstraint(6));
    FeatureTypeConstraint actualFTC = model.getFeatureTypeConstraint(1);
    assertTrue(actualFTC.getFeatureTypeName().compareTo("ftc2") == 0);
}
Also used : FeatureTypeConstraint(org.geotools.styling.FeatureTypeConstraint) StyleFactoryImpl(org.geotools.styling.StyleFactoryImpl) Extent(org.geotools.styling.Extent) FeatureTypeConstraintModel(com.sldeditor.ui.detail.config.featuretypeconstraint.FeatureTypeConstraintModel) Test(org.junit.Test)

Example 3 with FeatureTypeConstraint

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

the class InlineDatastoreVisitor method visit.

/**
 * (non-Javadoc)
 * @see org.geotools.styling.visitor.DuplicatingStyleVisitor#visit(org.geotools.styling.UserLayer)
 */
public void visit(UserLayer layer) {
    Style[] style = layer.getUserStyles();
    int length = style.length;
    Style[] styleCopy = new Style[length];
    for (int i = 0; i < length; i++) {
        if (style[i] != null) {
            style[i].accept(this);
            styleCopy[i] = (Style) pages.pop();
        }
    }
    FeatureTypeConstraint[] lfc = layer.getLayerFeatureConstraints();
    FeatureTypeConstraint[] lfcCopy = new FeatureTypeConstraint[lfc.length];
    length = lfc.length;
    for (int i = 0; i < length; i++) {
        if (lfc[i] != null) {
            lfc[i].accept(this);
            lfcCopy[i] = (FeatureTypeConstraint) pages.pop();
        }
    }
    UserLayer copy = sf.createUserLayer();
    copy.setName(layer.getName());
    copy.setUserStyles(styleCopy);
    copy.setLayerFeatureConstraints(lfcCopy);
    // Reuse the existing inline feature data store
    copy.setInlineFeatureDatastore(layer.getInlineFeatureDatastore());
    copy.setInlineFeatureType(layer.getInlineFeatureType());
    if (STRICT && !copy.equals(layer)) {
        throw new IllegalStateException("Was unable to duplicate provided UserLayer:" + layer);
    }
    pages.push(copy);
}
Also used : FeatureTypeConstraint(org.geotools.styling.FeatureTypeConstraint) Style(org.geotools.styling.Style) UserLayer(org.geotools.styling.UserLayer) FeatureTypeConstraint(org.geotools.styling.FeatureTypeConstraint)

Example 4 with FeatureTypeConstraint

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

the class NamedLayerDetails method populate.

/*
     * (non-Javadoc)
     * 
     * @see com.sldeditor.ui.iface.PopulateDetailsInterface#populate(com.sldeditor.ui.detail.SelectedSymbol)
     */
@Override
public void populate(SelectedSymbol selectedSymbol) {
    if (selectedSymbol != null) {
        StyledLayer styledLayer = selectedSymbol.getStyledLayer();
        if (styledLayer instanceof NamedLayerImpl) {
            NamedLayerImpl namedLayer = (NamedLayerImpl) styledLayer;
            fieldConfigVisitor.populateTextField(FieldIdEnum.NAME, namedLayer.getName());
            // Feature layer constraint
            List<FeatureTypeConstraint> ftcList = namedLayer.layerFeatureConstraints();
            fieldConfigVisitor.populateFieldTypeConstraint(FieldIdEnum.LAYER_FEATURE_CONSTRAINTS, ftcList);
        }
    }
}
Also used : FeatureTypeConstraint(org.geotools.styling.FeatureTypeConstraint) StyledLayer(org.geotools.styling.StyledLayer) NamedLayerImpl(org.geotools.styling.NamedLayerImpl)

Example 5 with FeatureTypeConstraint

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

the class UserLayerDetails method populate.

/*
     * (non-Javadoc)
     * 
     * @see com.sldeditor.ui.iface.PopulateDetailsInterface#populate(com.sldeditor.ui.detail.SelectedSymbol)
     */
@Override
public void populate(SelectedSymbol selectedSymbol) {
    if (selectedSymbol != null) {
        StyledLayer styledLayer = selectedSymbol.getStyledLayer();
        if (styledLayer instanceof UserLayerImpl) {
            UserLayerImpl userLayer = (UserLayerImpl) styledLayer;
            fieldConfigVisitor.populateTextField(FieldIdEnum.NAME, userLayer.getName());
            // Feature layer constraint
            List<FeatureTypeConstraint> ftcList = userLayer.layerFeatureConstraints();
            fieldConfigVisitor.populateFieldTypeConstraint(FieldIdEnum.LAYER_FEATURE_CONSTRAINTS, ftcList);
            // Source
            GroupConfigInterface group = getGroup(GroupIdEnum.USER_LAYER_SOURCE);
            if (group != null) {
                MultiOptionGroup userLayerSourceGroup = (MultiOptionGroup) group;
                if (userLayer.getInlineFeatureDatastore() == null) {
                    userLayerSourceGroup.setOption(GroupIdEnum.REMOTE_OWS_OPTION);
                    // Remote OWS
                    String service = "";
                    String onlineResource = "";
                    RemoteOWS remoteOWS = userLayer.getRemoteOWS();
                    if (remoteOWS != null) {
                        service = remoteOWS.getService();
                        onlineResource = remoteOWS.getOnlineResource();
                    }
                    fieldConfigVisitor.populateTextField(FieldIdEnum.REMOTE_OWS_SERVICE, service);
                    fieldConfigVisitor.populateTextField(FieldIdEnum.REMOTE_OWS_ONLINERESOURCE, onlineResource);
                } else {
                    userLayerSourceGroup.setOption(GroupIdEnum.INLINE_FEATURE_OPTION);
                    // Inline features
                    fieldConfigVisitor.populateUserLayer(FieldIdEnum.INLINE_FEATURE, userLayer);
                }
            }
        }
    }
}
Also used : RemoteOWS(org.geotools.styling.RemoteOWS) UserLayerImpl(org.geotools.styling.UserLayerImpl) FeatureTypeConstraint(org.geotools.styling.FeatureTypeConstraint) StyledLayer(org.geotools.styling.StyledLayer) GroupConfigInterface(com.sldeditor.ui.detail.config.base.GroupConfigInterface) MultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup)

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