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);
}
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);
}
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);
}
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);
}
}
}
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);
}
}
}
}
}
Aggregations