Search in sources :

Example 26 with FieldConfigString

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

the class FieldConfigStringTest method testSetEnabled.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigString#internal_setEnabled(boolean)}. Test
 * method for {@link com.sldeditor.ui.detail.config.FieldConfigString#isEnabled()}. Test method
 * for {@link com.sldeditor.ui.detail.config.FieldConfigString#createUI(javax.swing.Box)}.
 */
@Test
public void testSetEnabled() {
    // Value only, no attribute/expression dropdown
    boolean valueOnly = true;
    FieldConfigString field = new FieldConfigString(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly), "button text");
    // Text field will not have been created
    boolean expectedValue = true;
    field.internal_setEnabled(expectedValue);
    assertFalse(field.isEnabled());
    // Create text field
    field.createUI();
    assertEquals(expectedValue, field.isEnabled());
    expectedValue = false;
    field.internal_setEnabled(expectedValue);
    assertEquals(expectedValue, field.isEnabled());
    // Has attribute/expression dropdown
    valueOnly = false;
    FieldConfigString field2 = new FieldConfigString(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly), "button text");
    // Text field will not have been created
    expectedValue = true;
    field2.internal_setEnabled(expectedValue);
    assertFalse(field2.isEnabled());
    // Create text field
    field2.createUI();
    assertEquals(expectedValue, field2.isEnabled());
    expectedValue = false;
    field2.internal_setEnabled(expectedValue);
    // Actual value is coming from the attribute panel, not the text field
    assertEquals(!expectedValue, field2.isEnabled());
}
Also used : FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) Test(org.junit.Test)

Example 27 with FieldConfigString

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

the class FieldConfigStringTest method testSetVisible.

/**
 * Test method for {@link com.sldeditor.ui.detail.config.FieldConfigString#setVisible(boolean)}.
 */
@Test
public void testSetVisible() {
    boolean valueOnly = true;
    FieldConfigString field = new FieldConfigString(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly), "button text");
    boolean expectedValue = true;
    field.setVisible(expectedValue);
    expectedValue = false;
    field.setVisible(expectedValue);
}
Also used : FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) Test(org.junit.Test)

Example 28 with FieldConfigString

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

the class UserLayerDetailsTest method testUserLayerDetails.

/**
 * Test method for {@link com.sldeditor.ui.detail.UserLayerDetails#UserLayerDetails(com.sldeditor.filter.v2.function.FunctionNameInterface)}.
 * Test method for {@link com.sldeditor.ui.detail.UserLayerDetails#populate(com.sldeditor.common.data.SelectedSymbol)}.
 * Test method for {@link com.sldeditor.ui.detail.UserLayerDetails#dataChanged(com.sldeditor.ui.detail.config.FieldId)}.
 * Test method for {@link com.sldeditor.ui.detail.UserLayerDetails#getFieldDataManager()}.
 * Test method for {@link com.sldeditor.ui.detail.UserLayerDetails#isDataPresent()}.
 * Test method for {@link com.sldeditor.ui.detail.UserLayerDetails#preLoadSymbol()}.
 */
@Test
public void testUserLayerDetails() {
    UserLayerDetails panel = new UserLayerDetails();
    panel.populate(null);
    // Set up test data
    StyledLayerDescriptor sld = DefaultSymbols.createNewSLD();
    SelectedSymbol.getInstance().createNewSLD(sld);
    UserLayer userLayer = DefaultSymbols.createNewUserLayer();
    String expectedUserValue = "user layer test value";
    userLayer.setName(expectedUserValue);
    userLayer.addUserStyle(DefaultSymbols.createNewStyle());
    sld.layers().add(userLayer);
    SelectedSymbol.getInstance().addNewStyledLayer(userLayer);
    SelectedSymbol.getInstance().setStyledLayer(userLayer);
    panel.populate(SelectedSymbol.getInstance());
    panel.dataChanged(null);
    GraphicPanelFieldManager fieldDataManager = panel.getFieldDataManager();
    assertNotNull(fieldDataManager);
    panel.dataChanged(FieldIdEnum.INLINE_FEATURE);
    FieldConfigString nameField = (FieldConfigString) fieldDataManager.get(FieldIdEnum.NAME);
    assertTrue(expectedUserValue.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) UserLayerDetails(com.sldeditor.ui.detail.UserLayerDetails) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) UserLayer(org.geotools.styling.UserLayer) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) Test(org.junit.Test)

Example 29 with FieldConfigString

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

the class RuleDetails method getMinimumValue.

/**
 * Gets the minimum value.
 *
 * @param field the field
 * @return the minimum value
 */
private static double getMinimumValue(FieldConfigBase field) {
    double value = 0.0;
    if (field.isEnabled()) {
        FieldConfigString textFieldConfig = (FieldConfigString) field;
        value = ScaleUtil.extractValue(textFieldConfig.getStringValue());
    }
    return value;
}
Also used : FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString)

Example 30 with FieldConfigString

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

the class FeatureTypeStyleDetailsTest method testFeatureTypeStyleDetails.

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