Search in sources :

Example 16 with FeatureTypeStyle

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

the class StrokeDetailsTest method testStrokeDetailsCircle.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.StrokeDetails#StrokeDetails(com.sldeditor.filter.v2.function.FunctionNameInterface)}.
 */
@Test
public void testStrokeDetailsCircle() {
    StrokeDetails panel = new StrokeDetails();
    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 expectedNameValue = "rule test value";
    rule.setName(expectedNameValue);
    PointSymbolizer symbolizer = DefaultSymbols.createDefaultPointSymbolizer();
    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);
    FieldConfigSymbolType symbolTypeField = (FieldConfigSymbolType) fieldDataManager.get(FieldIdEnum.STROKE_STYLE);
    symbolTypeField.populateField("circle");
    double expectedAngle = 14.5;
    FieldConfigDouble angleField = (FieldConfigDouble) fieldDataManager.get(FieldIdEnum.STROKE_SYMBOL_ANGLE);
    angleField.populateField(expectedAngle);
    FieldConfigSlider opacityField = (FieldConfigSlider) fieldDataManager.get(FieldIdEnum.OVERALL_OPACITY);
    double opacity = 0.15;
    opacityField.populateField(opacity);
    FieldConfigString dashField = (FieldConfigString) fieldDataManager.get(FieldIdEnum.STROKE_DASH_ARRAY);
    String dashArray = "1 2";
    dashField.populateField(dashArray);
    panel.dataChanged(null);
    double actualValue = angleField.getDoubleValue();
    assertTrue(Math.abs(actualValue - expectedAngle) < 0.01);
    assertFalse(panel.isDataPresent());
    actualValue = opacityField.getDoubleValue();
    assertTrue(Math.abs(actualValue - opacity) < 0.01);
    // Reset to default value
    panel.preLoadSymbol();
    actualValue = angleField.getDoubleValue();
    assertTrue(Math.abs(actualValue - 0.0) < 0.01);
    actualValue = opacityField.getDoubleValue();
    assertTrue(Math.abs(actualValue - 1.0) < 0.01);
}
Also used : PointSymbolizer(org.geotools.styling.PointSymbolizer) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) StrokeDetails(com.sldeditor.ui.detail.StrokeDetails) FieldConfigDouble(com.sldeditor.ui.detail.config.FieldConfigDouble) FieldConfigSlider(com.sldeditor.ui.detail.config.FieldConfigSlider) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) Rule(org.geotools.styling.Rule) NamedLayer(org.geotools.styling.NamedLayer) FieldConfigSymbolType(com.sldeditor.ui.detail.config.FieldConfigSymbolType) Test(org.junit.Test)

Example 17 with FeatureTypeStyle

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

the class StyleDetailsTest method testStyleDetails.

/**
 * Test method for {@link com.sldeditor.ui.detail.StyleDetails#StyleDetails(com.sldeditor.filter.v2.function.FunctionNameInterface)}.
 * Test method for {@link com.sldeditor.ui.detail.StyleDetails#populate(com.sldeditor.common.data.SelectedSymbol)}.
 * Test method for {@link com.sldeditor.ui.detail.StyleDetails#dataChanged(com.sldeditor.ui.detail.config.FieldId)}.
 * Test method for {@link com.sldeditor.ui.detail.StyleDetails#getFieldDataManager()}.
 * Test method for {@link com.sldeditor.ui.detail.StyleDetails#isDataPresent()}.
 * Test method for {@link com.sldeditor.ui.detail.StyleDetails#preLoadSymbol()}.
 */
@Test
public void testStyleDetails() {
    StyleDetails panel = new StyleDetails();
    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 expectedNameValue = "style test value";
    style.setName(expectedNameValue);
    namedLayer.addStyle(style);
    FeatureTypeStyle fts = DefaultSymbols.createNewFeatureTypeStyle();
    style.featureTypeStyles().add(fts);
    sld.layers().add(namedLayer);
    SelectedSymbol.getInstance().addNewStyledLayer(namedLayer);
    SelectedSymbol.getInstance().setStyledLayer(namedLayer);
    SelectedSymbol.getInstance().setStyle(style);
    panel.populate(SelectedSymbol.getInstance());
    panel.dataChanged(null);
    GraphicPanelFieldManager fieldDataManager = panel.getFieldDataManager();
    assertNotNull(fieldDataManager);
    FieldConfigString nameField = (FieldConfigString) fieldDataManager.get(FieldIdEnum.NAME);
    assertTrue(expectedNameValue.compareTo(nameField.getStringValue()) == 0);
    assertTrue(panel.isDataPresent());
    // Reset to default value
    panel.preLoadSymbol();
    assertTrue("".compareTo(nameField.getStringValue()) == 0);
}
Also used : StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) StyleDetails(com.sldeditor.ui.detail.StyleDetails) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) NamedLayer(org.geotools.styling.NamedLayer) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) Test(org.junit.Test)

Example 18 with FeatureTypeStyle

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

the class TextSymbolizerDetailsTest method testTextSymbolizerDetails.

/**
 * Test method for {@link com.sldeditor.ui.detail.TextSymbolizerDetails#TextSymbolizerDetails(com.sldeditor.filter.v2.function.FunctionNameInterface)}.
 * Test method for {@link com.sldeditor.ui.detail.TextSymbolizerDetails#populate(com.sldeditor.common.data.SelectedSymbol)}.
 * Test method for {@link com.sldeditor.ui.detail.TextSymbolizerDetails#dataChanged(com.sldeditor.ui.detail.config.FieldId)}.
 * Test method for {@link com.sldeditor.ui.detail.TextSymbolizerDetails#getFieldDataManager()}.
 * Test method for {@link com.sldeditor.ui.detail.TextSymbolizerDetails#isDataPresent()}.
 * Test method for {@link com.sldeditor.ui.detail.TextSymbolizerDetails#preLoadSymbol()}.
 */
@Test
public void testTextSymbolizerDetails() {
    TextSymbolizerDetails panel = new TextSymbolizerDetails();
    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);
    TextSymbolizer symbolizer = DefaultSymbols.createDefaultTextSymbolizer();
    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();
}
Also used : StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) TextSymbolizer(org.geotools.styling.TextSymbolizer) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) Rule(org.geotools.styling.Rule) NamedLayer(org.geotools.styling.NamedLayer) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) TextSymbolizerDetails(com.sldeditor.ui.detail.TextSymbolizerDetails) Test(org.junit.Test)

Example 19 with FeatureTypeStyle

use of org.geotools.styling.FeatureTypeStyle 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);
}
Also used : VendorOptionPresent(com.sldeditor.common.vendoroption.minversion.VendorOptionPresent) StyleFactoryImpl(org.geotools.styling.StyleFactoryImpl) VendorOptionVersion(com.sldeditor.common.vendoroption.VendorOptionVersion) FeatureTypeStyleDetails(com.sldeditor.ui.detail.FeatureTypeStyleDetails) ArrayList(java.util.ArrayList) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) VOGeoServerFTSCompositeBase(com.sldeditor.ui.detail.vendor.geoserver.featuretypestyle.VOGeoServerFTSCompositeBase) Test(org.junit.Test)

Example 20 with FeatureTypeStyle

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

the class PointFillDetailsTest method testFillDetailsPoint.

/**
 * Test method for {@link com.sldeditor.ui.detail.PointFillDetailsTest#FillDetails(java.lang.Class, com.sldeditor.filter.v2.function.FunctionNameInterface)}.
 */
@Test
public void testFillDetailsPoint() {
    PointFillDetails panel = new PointFillDetails();
    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 expectedNameValue = "rule test value";
    rule.setName(expectedNameValue);
    PointSymbolizer symbolizer = DefaultSymbols.createDefaultPointSymbolizer();
    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);
    double expectedAngle = 14.5;
    FieldConfigDouble angleField = (FieldConfigDouble) fieldDataManager.get(FieldIdEnum.ANGLE);
    angleField.populateField(expectedAngle);
    FieldConfigSlider opacityField = (FieldConfigSlider) fieldDataManager.get(FieldIdEnum.OVERALL_OPACITY);
    double opacity = 0.15;
    opacityField.populateField(opacity);
    panel.dataChanged(FieldIdEnum.UNKNOWN);
    double actualValue = angleField.getDoubleValue();
    assertTrue(Math.abs(actualValue - expectedAngle) < 0.01);
    assertTrue(panel.isDataPresent());
    actualValue = opacityField.getDoubleValue();
    assertTrue(Math.abs(actualValue - opacity) < 0.01);
    // Reset to default value
    panel.preLoadSymbol();
    actualValue = angleField.getDoubleValue();
    assertTrue(Math.abs(actualValue - 0.0) < 0.01);
    actualValue = opacityField.getDoubleValue();
    assertTrue(Math.abs(actualValue - 1.0) < 0.01);
}
Also used : PointSymbolizer(org.geotools.styling.PointSymbolizer) StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) FieldConfigDouble(com.sldeditor.ui.detail.config.FieldConfigDouble) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FieldConfigSlider(com.sldeditor.ui.detail.config.FieldConfigSlider) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) Rule(org.geotools.styling.Rule) PointFillDetails(com.sldeditor.ui.detail.PointFillDetails) NamedLayer(org.geotools.styling.NamedLayer) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) Test(org.junit.Test)

Aggregations

FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)110 Style (org.geotools.styling.Style)81 Rule (org.geotools.styling.Rule)65 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)43 Test (org.junit.Test)42 NamedLayer (org.geotools.styling.NamedLayer)38 PointSymbolizer (org.geotools.styling.PointSymbolizer)24 PolygonSymbolizer (org.geotools.styling.PolygonSymbolizer)22 StyledLayer (org.geotools.styling.StyledLayer)21 LineSymbolizer (org.geotools.styling.LineSymbolizer)20 NamedLayerImpl (org.geotools.styling.NamedLayerImpl)17 Symbolizer (org.geotools.styling.Symbolizer)16 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)15 RasterSymbolizer (org.geotools.styling.RasterSymbolizer)14 FieldConfigString (com.sldeditor.ui.detail.config.FieldConfigString)12 StyleFactoryImpl (org.geotools.styling.StyleFactoryImpl)12 TextSymbolizer (org.geotools.styling.TextSymbolizer)12 UserLayerImpl (org.geotools.styling.UserLayerImpl)12 ArrayList (java.util.ArrayList)11 LineStyle (org.polymap.core.style.model.feature.LineStyle)11