Search in sources :

Example 1 with FieldConfigString

use of com.sldeditor.ui.detail.config.FieldConfigString in project sldeditor by robward-scisys.

the class StrokeDetailsTest method testStrokeDetailsPolygon.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.StrokeDetails#StrokeDetails(com.sldeditor.filter.v2.function.FunctionNameInterface)}.
 */
@Test
public void testStrokeDetailsPolygon() {
    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);
    PolygonSymbolizer symbolizer = DefaultSymbols.createDefaultPolygonSymbolizer();
    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);
    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 : FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) 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 2 with FieldConfigString

use of com.sldeditor.ui.detail.config.FieldConfigString 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 3 with FieldConfigString

use of com.sldeditor.ui.detail.config.FieldConfigString 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 4 with FieldConfigString

use of com.sldeditor.ui.detail.config.FieldConfigString 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 5 with FieldConfigString

use of com.sldeditor.ui.detail.config.FieldConfigString in project sldeditor by robward-scisys.

the class FieldConfigBaseTest method testDuplicate.

/**
 * Test method for {@link com.sldeditor.ui.detail.config.FieldConfigBase#duplicate()}.
 */
@Test
public void testDuplicate() {
    FieldIdEnum expectedFieldId = FieldIdEnum.NAME;
    String expectedLabel = "test label";
    TestFieldConfigBase field = new TestFieldConfigBase(new FieldConfigCommonData(String.class, expectedFieldId, expectedLabel, false));
    TestUpdateSymbolInterface listener = new TestUpdateSymbolInterface();
    field.addDataChangedListener(listener);
    FieldConfigString copy = (FieldConfigString) field.duplicate();
    assertNotNull(copy);
}
Also used : FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) Test(org.junit.Test)

Aggregations

FieldConfigString (com.sldeditor.ui.detail.config.FieldConfigString)37 Test (org.junit.Test)32 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)21 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)20 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)13 NamedLayer (org.geotools.styling.NamedLayer)12 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)11 Style (org.geotools.styling.Style)11 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)10 Rule (org.geotools.styling.Rule)10 StrokeDetails (com.sldeditor.ui.detail.StrokeDetails)8 FieldConfigDouble (com.sldeditor.ui.detail.config.FieldConfigDouble)5 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)4 FieldConfigSlider (com.sldeditor.ui.detail.config.FieldConfigSlider)3 Geometry (com.vividsolutions.jts.geom.Geometry)3 GroupIdEnum (com.sldeditor.common.xml.ui.GroupIdEnum)2 PointFillDetails (com.sldeditor.ui.detail.PointFillDetails)2 RasterSymbolizerDetails (com.sldeditor.ui.detail.RasterSymbolizerDetails)2 FieldConfigColour (com.sldeditor.ui.detail.config.FieldConfigColour)2 FieldConfigPopulation (com.sldeditor.ui.detail.config.FieldConfigPopulation)2