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