use of org.geotools.styling.StyleFactoryImpl in project sldeditor by robward-scisys.
the class ExtentModelTest method testGetExtentList.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.featuretypeconstraint.ExtentModel#getExtentList()}.
* Test method for
* {@link com.sldeditor.ui.detail.config.featuretypeconstraint.ExtentModel#removeEntries(int, int)}.
* Test method for
* {@link com.sldeditor.ui.detail.config.featuretypeconstraint.ExtentModel#populate(org.geotools.styling.Extent[])}.
*/
@Test
public void testGetExtentList() {
TestModelUpdate testUpdate = new TestModelUpdate();
StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
ExtentModel model = new ExtentModel(testUpdate);
Extent[] extentArray = null;
model.populate(extentArray);
extentArray = new Extent[5];
extentArray[0] = styleFactory.createExtent("extent 1", "1 1 1 1");
extentArray[1] = styleFactory.createExtent("extent 2", "2 2 2 2");
extentArray[2] = styleFactory.createExtent("extent 3", "3 3 3 3");
extentArray[3] = styleFactory.createExtent("extent 4", "4 4 4 4");
extentArray[4] = styleFactory.createExtent("extent 5", "5 5 5 5");
model.populate(extentArray);
List<Extent> actualList = model.getExtentList();
assertEquals(5, actualList.size());
assertTrue(actualList.get(2).getName().compareTo("extent 3") == 0);
assertFalse(testUpdate.hasExtentUpdatedBeenCalled());
model.removeEntries(-1, 2);
assertFalse(testUpdate.hasExtentUpdatedBeenCalled());
model.removeEntries(2, 22);
assertFalse(testUpdate.hasExtentUpdatedBeenCalled());
model.removeEntries(22, 2);
assertFalse(testUpdate.hasExtentUpdatedBeenCalled());
model.removeEntries(2, 2);
assertTrue(testUpdate.hasExtentUpdatedBeenCalled());
actualList = model.getExtentList();
assertEquals(4, actualList.size());
assertTrue(actualList.get(2).getName().compareTo("extent 4") == 0);
}
use of org.geotools.styling.StyleFactoryImpl 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.StyleFactoryImpl in project sldeditor by robward-scisys.
the class VOGeoServerFTSCompositeBaseTest method testVOGeoServerFTSCompositeBase.
/**
* Test method for
* {@link com.sldeditor.ui.detail.vendor.geoserver.featuretypestyle.VOGeoServerFTSCompositeBase#VOGeoServerFTSCompositeBase(java.lang.Class)}.
*/
@Test
public void testVOGeoServerFTSCompositeBase() {
Class<FeatureTypeStyleDetails> panelId = FeatureTypeStyleDetails.class;
VOGeoServerFTSCompositeBase obj = new VOGeoServerFTSCompositeBase(panelId);
assertEquals(panelId, obj.getPanelId());
assertNotNull(obj.getFieldDataManager());
assertNotNull(obj.getPanel());
assertTrue(obj.isDataPresent());
assertNotNull(obj.getVendorOptionInfo());
// Check getVendorOptionVersion
VendorOptionVersion vendorOption = obj.getVendorOption();
assertEquals(GeoServerVendorOption.class, vendorOption.getClassType());
String actualVersionString = vendorOption.getEarliest().getVersionString();
String expectedVersionString = "2.7.0";
assertEquals(expectedVersionString, actualVersionString);
obj.setParentPanel(null);
assertNull(obj.getParentPanel());
obj.preLoadSymbol();
List<VendorOptionPresent> vendorOptionsPresentList = new ArrayList<VendorOptionPresent>();
String testString = "test";
obj.getMinimumVersion(null, testString, vendorOptionsPresentList);
assertTrue(vendorOptionsPresentList.isEmpty());
StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
FeatureTypeStyle fts = styleFactory.createFeatureTypeStyle();
obj.getMinimumVersion(null, fts, vendorOptionsPresentList);
assertEquals(0, vendorOptionsPresentList.size());
// Valid string
String expectedValue = "true";
fts.getOptions().put(FeatureTypeStyle.COMPOSITE_BASE, expectedValue);
obj.getMinimumVersion(null, fts, vendorOptionsPresentList);
assertEquals(1, vendorOptionsPresentList.size());
obj.populate(fts);
obj.updateSymbol(fts);
String actualValue = fts.getOptions().get(FeatureTypeStyle.COMPOSITE_BASE);
assertEquals(actualValue, expectedValue);
// No opacity
expectedValue = "false";
fts.getOptions().put(FeatureTypeStyle.COMPOSITE_BASE, expectedValue);
obj.populate(fts);
obj.updateSymbol(fts);
actualValue = fts.getOptions().get(FeatureTypeStyle.COMPOSITE_BASE);
assertEquals(actualValue, expectedValue);
// Invalid string
expectedValue = "invalid";
fts.getOptions().put(FeatureTypeStyle.COMPOSITE_BASE, expectedValue);
obj.populate(fts);
obj.updateSymbol(fts);
actualValue = fts.getOptions().get(FeatureTypeStyle.COMPOSITE_BASE);
assertEquals("false", actualValue);
// Increase code coverage
obj.populate((PolygonSymbolizer) null);
obj.updateSymbol((PolygonSymbolizer) null);
obj.populate((RasterSymbolizer) null);
obj.updateSymbol((RasterSymbolizer) null);
obj.populate((TextSymbolizer) null);
obj.updateSymbol((TextSymbolizer) null);
obj.populate((SelectedSymbol) null);
obj.dataChanged(FieldIdEnum.VO_FTS_COMPOSITE_BASE_BOOL);
}
use of org.geotools.styling.StyleFactoryImpl in project sldeditor by robward-scisys.
the class RasterSymbolizerDetailsTest method testRasterSymbolizerDetailsColourChannel.
/**
* Test method for {@link com.sldeditor.ui.detail.RasterSymbolizerDetails#RasterSymbolizerDetails(com.sldeditor.filter.v2.function.FunctionNameInterface)}.
* Test method for {@link com.sldeditor.ui.detail.RasterSymbolizerDetails#isDataPresent()}.
* Test method for {@link com.sldeditor.ui.detail.RasterSymbolizerDetails#populate(com.sldeditor.common.data.SelectedSymbol)}.
* Test method for {@link com.sldeditor.ui.detail.RasterSymbolizerDetails#dataChanged(com.sldeditor.ui.detail.config.FieldId)}.
* Test method for {@link com.sldeditor.ui.detail.RasterSymbolizerDetails#getFieldDataManager()}.
* Test method for {@link com.sldeditor.ui.detail.RasterSymbolizerDetails#preLoadSymbol()}.
*/
@Test
public void testRasterSymbolizerDetailsColourChannel() {
RasterSymbolizerDetails panel = new RasterSymbolizerDetails();
panel.populate(null);
// Set up test data
StyledLayerDescriptor sld = DefaultSymbols.createNewSLD();
SelectedSymbol.getInstance().createNewSLD(sld);
NamedLayer namedLayer = DefaultSymbols.createNewNamedLayer();
String expectedNameLayerValue = "named layer test value";
namedLayer.setName(expectedNameLayerValue);
Style style = DefaultSymbols.createNewStyle();
String expectedNameStyleValue = "style test value";
style.setName(expectedNameStyleValue);
namedLayer.addStyle(style);
FeatureTypeStyle fts = DefaultSymbols.createNewFeatureTypeStyle();
String expectedNameFTSValue = "feature type style test value";
fts.setName(expectedNameFTSValue);
style.featureTypeStyles().add(fts);
Rule rule = DefaultSymbols.createNewRule();
String expectedRuleValue = "rule test value";
rule.setName(expectedRuleValue);
StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
FilterFactory ff = CommonFactoryFinder.getFilterFactory();
ContrastEnhancement contrastEnhancement = (ContrastEnhancement) styleFactory.contrastEnhancement(ff.literal(.5), "ramp");
SelectedChannelType redChannel = styleFactory.createSelectedChannelType("red", contrastEnhancement);
SelectedChannelType greenChannel = styleFactory.createSelectedChannelType("green", contrastEnhancement);
SelectedChannelType blueChannel = styleFactory.createSelectedChannelType("blue", contrastEnhancement);
SelectedChannelType[] channels = new SelectedChannelType[3];
channels[0] = redChannel;
channels[1] = greenChannel;
channels[2] = blueChannel;
RasterSymbolizer symbolizer = DefaultSymbols.createDefaultRasterSymbolizer();
symbolizer.setChannelSelection(styleFactory.createChannelSelection(channels));
String expectedNameValue = "symbolizer test value";
symbolizer.setName(expectedNameValue);
rule.symbolizers().add(symbolizer);
fts.rules().add(rule);
sld.layers().add(namedLayer);
SelectedSymbol.getInstance().addNewStyledLayer(namedLayer);
SelectedSymbol.getInstance().setStyledLayer(namedLayer);
SelectedSymbol.getInstance().setStyle(style);
SelectedSymbol.getInstance().setFeatureTypeStyle(fts);
SelectedSymbol.getInstance().setRule(rule);
SelectedSymbol.getInstance().setSymbolizer(symbolizer);
panel.populate(SelectedSymbol.getInstance());
GraphicPanelFieldManager fieldDataManager = panel.getFieldDataManager();
assertNotNull(fieldDataManager);
panel.dataChanged(null);
FieldConfigString nameField = (FieldConfigString) fieldDataManager.get(FieldIdEnum.NAME);
assertNull(nameField);
assertTrue(panel.isDataPresent());
// Reset to default value
panel.preLoadSymbol();
}
use of org.geotools.styling.StyleFactoryImpl in project sldeditor by robward-scisys.
the class VOGeoServerContrastEnhancementNormalizeGreenTest method testVOGeoServerContrastEnhancementNormalizeGreen.
/**
* Test method for
* {@link com.sldeditor.ui.detail.vendor.geoserver.raster.VOGeoServerContrastEnhancementNormalizeGreen#VOGeoServerContrastEnhancementNormalizeGreen(java.lang.Class, com.sldeditor.ui.detail.RasterSymbolizerDetails)}.
* Test method for
* {@link com.sldeditor.ui.detail.vendor.geoserver.raster.VOGeoServerContrastEnhancementNormalizeGreen#getContrastEnhancement(com.sldeditor.common.xml.ui.GroupIdEnum, org.geotools.styling.ChannelSelection)}.
*/
@Test
public void testVOGeoServerContrastEnhancementNormalizeGreen() {
RasterSymbolizerDetails panel = new RasterSymbolizerDetails();
VOGeoServerContrastEnhancementNormalizeGreen testObj = new VOGeoServerContrastEnhancementNormalizeGreen(panel.getClass(), panel);
RasterSymbolizer rasterSymbolizer = null;
testObj.setParentPanel(panel);
testObj.populate(rasterSymbolizer);
testObj.updateSymbol(rasterSymbolizer);
StyleFactoryImpl styleFactory = (StyleFactoryImpl) CommonFactoryFinder.getStyleFactory();
rasterSymbolizer = styleFactory.createRasterSymbolizer();
GroupConfigInterface constrastMethodGroup = panel.getGroup(GroupIdEnum.RASTER_RGB_CHANNEL_GREEN_CONTRAST_METHOD);
assertNotNull(constrastMethodGroup);
MultiOptionGroup constrastMethodGroup2 = (MultiOptionGroup) constrastMethodGroup;
Box box = Box.createVerticalBox();
constrastMethodGroup2.createUI(panel.getFieldDataManager(), box, panel, panel.getPanelId());
constrastMethodGroup2.setOption(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD_LOGARITHMIC);
ChannelSelection channelSelection = createChannelSelection(styleFactory, ContrastMethod.LOGARITHMIC);
rasterSymbolizer.setChannelSelection(channelSelection);
testObj.populate(rasterSymbolizer);
SelectedSymbol.getInstance().setSymbolizer(rasterSymbolizer);
Controller.getInstance().setPopulating(true);
panel.populate(SelectedSymbol.getInstance());
Controller.getInstance().setPopulating(false);
testObj.updateSymbol(rasterSymbolizer);
channelSelection = createChannelSelection(styleFactory, ContrastMethod.EXPONENTIAL);
rasterSymbolizer.setChannelSelection(channelSelection);
constrastMethodGroup2.setOption(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD_EXPONENTIAL);
testObj.populate(rasterSymbolizer);
testObj.updateSymbol(rasterSymbolizer);
channelSelection = createChannelSelection(styleFactory, ContrastMethod.HISTOGRAM);
rasterSymbolizer.setChannelSelection(channelSelection);
constrastMethodGroup2.setOption(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD_HISTOGRAM);
testObj.populate(rasterSymbolizer);
testObj.updateSymbol(rasterSymbolizer);
channelSelection = createChannelSelection(styleFactory, ContrastMethod.NORMALIZE);
constrastMethodGroup2.setOption(GroupIdEnum.RASTER_OVERALL_CONTRAST_METHOD_NORMALIZE);
rasterSymbolizer.setChannelSelection(channelSelection);
testObj.populate(rasterSymbolizer);
testObj.updateSymbol(rasterSymbolizer);
// Error
channelSelection = createChannelSelectionError(styleFactory, ContrastMethod.NORMALIZE);
rasterSymbolizer.setChannelSelection(channelSelection);
testObj.populate(rasterSymbolizer);
testObj.updateSymbol(rasterSymbolizer);
// Increase code coverage
testObj.populate((SelectedSymbol) null);
testObj.populate((TextSymbolizer) null);
testObj.populate((PolygonSymbolizer) null);
testObj.updateSymbol((TextSymbolizer) null);
testObj.updateSymbol((PolygonSymbolizer) null);
testObj.preLoadSymbol();
assertTrue(testObj.isDataPresent());
testObj.dataChanged(FieldIdEnum.DESCRIPTION);
}
Aggregations