Search in sources :

Example 1 with GraphicPanelFieldManager

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

the class FieldConfigWindBarbsTest method testGetValue.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.vendor.geoserver.marker.windbarb.FieldConfigWindBarbs#getValue(com.sldeditor.ui.detail.GraphicPanelFieldManager, org.opengis.filter.expression.Expression, boolean, boolean)}.
 */
@Test
public void testGetValue() {
    // Test it with null values
    boolean valueOnly = true;
    FieldConfigWindBarbs field = new FieldConfigWindBarbs(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly), null, null, null);
    field.createUI();
    assertNull(field.getStringValue());
    GraphicPanelFieldManager fieldConfigManager = null;
    Expression symbolType = null;
    List<GraphicalSymbol> actualValue = field.getValue(fieldConfigManager, symbolType, false, false);
    assertTrue(actualValue.isEmpty());
    Class<?> panelId = PointFillDetails.class;
    fieldConfigManager = new GraphicPanelFieldManager(panelId);
    String actualMarkerSymbol = "solid";
    StyleBuilder styleBuilder = new StyleBuilder();
    symbolType = styleBuilder.literalExpression(actualMarkerSymbol);
    FieldIdEnum colourFieldId = FieldIdEnum.FILL_COLOUR;
    FieldConfigColour colourField = new FieldConfigColour(new FieldConfigCommonData(panelId, colourFieldId, "", false));
    colourField.createUI();
    String expectedColourValue = "#012345";
    colourField.setTestValue(null, expectedColourValue);
    double expectedOpacityValue = 0.72;
    FieldConfigSlider opacityField = new FieldConfigSlider(new FieldConfigCommonData(panelId, colourFieldId, "", false));
    opacityField.createUI();
    opacityField.populateField(expectedOpacityValue);
    FieldConfigBase symbolSelectionField = new FieldConfigSymbolType(new FieldConfigCommonData(panelId, colourFieldId, "", false));
    symbolSelectionField.createUI();
    fieldConfigManager.add(colourFieldId, colourField);
    FieldIdEnum opacityFieldId = FieldIdEnum.OVERALL_OPACITY;
    fieldConfigManager.add(opacityFieldId, opacityField);
    FieldIdEnum symbolSelectionFieldId = FieldIdEnum.SYMBOL_TYPE;
    fieldConfigManager.add(symbolSelectionFieldId, symbolSelectionField);
    // Try without setting any fields
    actualValue = field.getValue(fieldConfigManager, symbolType, false, false);
    assertNotNull(actualValue);
    assertEquals(1, actualValue.size());
    Mark actualSymbol = (Mark) actualValue.get(0);
    assertTrue(actualSymbol.getWellKnownName().toString().compareTo("windbarbs://default(0)[m/s]") == 0);
}
Also used : FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) GraphicalSymbol(org.opengis.style.GraphicalSymbol) StyleBuilder(org.geotools.styling.StyleBuilder) FieldConfigSlider(com.sldeditor.ui.detail.config.FieldConfigSlider) Mark(org.geotools.styling.Mark) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) Expression(org.opengis.filter.expression.Expression) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigWindBarbs(com.sldeditor.ui.detail.vendor.geoserver.marker.windbarb.FieldConfigWindBarbs) FieldConfigColour(com.sldeditor.ui.detail.config.FieldConfigColour) PointFillDetails(com.sldeditor.ui.detail.PointFillDetails) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) FieldConfigSymbolType(com.sldeditor.ui.detail.config.FieldConfigSymbolType) Test(org.junit.Test)

Example 2 with GraphicPanelFieldManager

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

the class ExtractGeometryFieldTest method testGetGeometryField.

/**
 * Test method for {@link com.sldeditor.ui.detail.ExtractGeometryField#getGeometryField(com.sldeditor.ui.detail.config.FieldConfigPopulation)}.
 */
@Test
public void testGetGeometryField() {
    assertNull(ExtractGeometryField.getGeometryField(null));
    FieldIdEnum fieldId = FieldIdEnum.GEOMETRY;
    GraphicPanelFieldManager fieldConfigManager = new GraphicPanelFieldManager(Geometry.class);
    FieldConfigGeometry geometryField = new FieldConfigGeometry(new FieldConfigCommonData(Geometry.class, fieldId, "label", true), "button");
    geometryField.createUI();
    fieldConfigManager.add(fieldId, geometryField);
    FieldConfigPopulation obj = new FieldConfigPopulation(fieldConfigManager);
    // Try valid geometry field name
    geometryField.populateField("ValidTestField");
    Expression actualExpression = ExtractGeometryField.getGeometryField(obj);
    assertNotNull(actualExpression);
    // Try invalid geometry field name
    geometryField.populateField("");
    actualExpression = ExtractGeometryField.getGeometryField(obj);
    assertNull(actualExpression);
    // Try invalid geometry field name
    geometryField.populateField("    ");
    actualExpression = ExtractGeometryField.getGeometryField(obj);
    assertNull(actualExpression);
    // Try when there is no geometry field
    obj = new FieldConfigPopulation(fieldConfigManager);
    actualExpression = ExtractGeometryField.getGeometryField(obj);
    assertNull(actualExpression);
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) FieldConfigGeometry(com.sldeditor.ui.detail.config.FieldConfigGeometry) FieldConfigPopulation(com.sldeditor.ui.detail.config.FieldConfigPopulation) FieldConfigGeometry(com.sldeditor.ui.detail.config.FieldConfigGeometry) Expression(org.opengis.filter.expression.Expression) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) Test(org.junit.Test)

Example 3 with GraphicPanelFieldManager

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

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

use of com.sldeditor.ui.detail.GraphicPanelFieldManager 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)

Aggregations

GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)53 Test (org.junit.Test)51 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)34 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)33 FieldConfigString (com.sldeditor.ui.detail.config.FieldConfigString)23 PointFillDetails (com.sldeditor.ui.detail.PointFillDetails)18 FieldConfigSlider (com.sldeditor.ui.detail.config.FieldConfigSlider)17 FieldConfigColour (com.sldeditor.ui.detail.config.FieldConfigColour)16 StyleBuilder (org.geotools.styling.StyleBuilder)16 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)16 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)15 NamedLayer (org.geotools.styling.NamedLayer)15 FieldConfigSymbolType (com.sldeditor.ui.detail.config.FieldConfigSymbolType)14 Style (org.geotools.styling.Style)14 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)13 Rule (org.geotools.styling.Rule)13 ColourFieldConfig (com.sldeditor.ui.detail.ColourFieldConfig)12 FieldConfigPopulation (com.sldeditor.ui.detail.config.FieldConfigPopulation)12 Geometry (com.vividsolutions.jts.geom.Geometry)12 StrokeDetails (com.sldeditor.ui.detail.StrokeDetails)9