Search in sources :

Example 31 with ValueComboBoxData

use of com.sldeditor.ui.widgets.ValueComboBoxData in project sldeditor by robward-scisys.

the class FieldConfigEnum method getFieldEnableState.

/**
 * Gets the field enable state.
 *
 * @return the field enable state
 */
public Map<FieldIdEnum, Boolean> getFieldEnableState() {
    ValueComboBoxData value = getEnumValue();
    if (value == null) {
        return null;
    }
    Class<?> panelId = value.getPanelId();
    return fieldMap.get(panelId);
}
Also used : ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData)

Example 32 with ValueComboBoxData

use of com.sldeditor.ui.widgets.ValueComboBoxData in project sldeditor by robward-scisys.

the class WindBarbDetails method updateSymbol.

/**
 * Update symbol.
 */
private void updateSymbol() {
    if (!Controller.getInstance().isPopulating()) {
        ValueComboBoxData windSpeedUnits = fieldConfigVisitor.getComboBox(FieldIdEnum.WINDBARB_WINDSPEED_UNITS);
        Expression windSpeedExpression = fieldConfigVisitor.getExpression(FieldIdEnum.WINDBARB_WINDSPEED);
        boolean inNorthernHemisphere = fieldConfigVisitor.getBoolean(FieldIdEnum.WINDBARB_NORTHERN_HEMISPHERE);
        Object windSpeed = null;
        if (windSpeedExpression == null) {
            windSpeed = Integer.valueOf(0);
        } else if (windSpeedExpression instanceof LiteralExpressionImpl) {
            LiteralExpressionImpl literalExpression = (LiteralExpressionImpl) windSpeedExpression;
            windSpeed = literalExpression.getValue();
        } else if (windSpeedExpression instanceof ConstantExpression) {
            ConstantExpression constantExpression = (ConstantExpression) windSpeedExpression;
            windSpeed = constantExpression.getValue();
        } else if (windSpeedExpression instanceof AttributeExpressionImpl) {
            AttributeExpressionImpl attributeExpression = (AttributeExpressionImpl) windSpeedExpression;
            windSpeed = String.format("<ogc:PropertyName>%s</ogc:PropertyName>", attributeExpression.getPropertyName());
            ;
        } else {
            ConsoleManager.getInstance().error(this, Localisation.getField(WindBarbDetails.class, "WindBarb.windspeedError1") + windSpeedExpression.getClass().getName());
        }
        String url = String.format("windbarbs://default(%s)[%s]", windSpeed, windSpeedUnits.getKey());
        if (!inNorthernHemisphere) {
            url = url + HEMISPHERE_S;
        }
        windBarbsExpression = getFilterFactory().literal(url);
        if (parentObj != null) {
            parentObj.windBarbValueUpdated();
        }
    }
}
Also used : ConstantExpression(org.geotools.filter.ConstantExpression) Expression(org.opengis.filter.expression.Expression) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl) ConstantExpression(org.geotools.filter.ConstantExpression) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData)

Example 33 with ValueComboBoxData

use of com.sldeditor.ui.widgets.ValueComboBoxData in project sldeditor by robward-scisys.

the class VOGeoServerLabellingUnderline method internal_updateSymbolEnumField.

/**
 * Internal_update symbol enum field.
 *
 * @param options the options
 * @param field the field
 * @param key the key
 */
private void internal_updateSymbolEnumField(Map<String, String> options, FieldIdEnum field, String key) {
    ValueComboBoxData value = fieldConfigVisitor.getComboBox(field);
    Object object = getDefaultFieldValue(field);
    String defaultValue = null;
    if (object instanceof TextSymbolizer.PolygonAlignOptions) {
        TextSymbolizer.PolygonAlignOptions option = (PolygonAlignOptions) object;
        defaultValue = option.toString();
    } else {
        defaultValue = (String) object;
    }
    if (defaultValue == null) {
        ConsoleManager.getInstance().error(this, "Failed to find default for field : " + field);
    } else if (value.getKey().compareToIgnoreCase(defaultValue) != 0) {
        options.put(key, value.getKey());
    }
}
Also used : PolygonAlignOptions(org.geotools.styling.TextSymbolizer.PolygonAlignOptions) TextSymbolizer(org.geotools.styling.TextSymbolizer) PolygonAlignOptions(org.geotools.styling.TextSymbolizer.PolygonAlignOptions) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData)

Example 34 with ValueComboBoxData

use of com.sldeditor.ui.widgets.ValueComboBoxData in project sldeditor by robward-scisys.

the class VOGeoServerRandomFill method internal_updateSymbolEnumField.

/**
 * Internal_update symbol enum field.
 *
 * @param options the options
 * @param field the field
 * @param key the key
 */
private void internal_updateSymbolEnumField(Map<String, String> options, FieldIdEnum field, String key) {
    ValueComboBoxData value = fieldConfigVisitor.getComboBox(field);
    Object object = getDefaultFieldValue(field);
    String defaultValue = null;
    if (object instanceof TextSymbolizer.PolygonAlignOptions) {
        TextSymbolizer.PolygonAlignOptions option = (PolygonAlignOptions) object;
        defaultValue = option.toString();
    } else {
        defaultValue = (String) object;
    }
    if (defaultValue == null) {
        ConsoleManager.getInstance().error(this, "Failed to find default for field : " + field);
    } else if (value.getKey().compareToIgnoreCase(defaultValue) != 0) {
        options.put(key, value.getKey());
    }
}
Also used : PolygonAlignOptions(org.geotools.styling.TextSymbolizer.PolygonAlignOptions) TextSymbolizer(org.geotools.styling.TextSymbolizer) PolygonAlignOptions(org.geotools.styling.TextSymbolizer.PolygonAlignOptions) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData)

Example 35 with ValueComboBoxData

use of com.sldeditor.ui.widgets.ValueComboBoxData in project sldeditor by robward-scisys.

the class FieldConfigEnumTest method testGenerateExpression.

/**
 * Test method for {@link com.sldeditor.ui.detail.config.FieldConfigEnum#generateExpression()}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigEnum#populateExpression(java.lang.Object, org.opengis.filter.expression.Expression)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigEnum#populateField(java.lang.String)}. Test
 * method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigEnum#setTestValue(com.sldeditor.ui.detail.config.FieldId, java.lang.String)}.
 * Test method for {@link com.sldeditor.ui.detail.config.FieldConfigEnum#getEnumValue()}. Test
 * method for {@link com.sldeditor.ui.detail.config.FieldConfigEnum#getStringValue()}.
 */
@Test
public void testGenerateExpression() {
    SymbolTypeConfig s1 = new SymbolTypeConfig(null);
    s1.addOption("key1", "Value 1");
    s1.addOption("key2", "Value 2");
    s1.addOption("key3", "Value 3");
    s1.addField(FieldIdEnum.ANCHOR_POINT_H, true);
    s1.addField(FieldIdEnum.ANCHOR_POINT_V, false);
    List<SymbolTypeConfig> configList = new ArrayList<SymbolTypeConfig>();
    configList.add(s1);
    SymbolTypeConfig s2 = new SymbolTypeConfig(null);
    s2.addOption("key4", "Value 4");
    s2.addOption("key5", "Value 5");
    s2.addOption("key6", "Value 6");
    s2.addField(FieldIdEnum.ANGLE, true);
    s2.addField(FieldIdEnum.DESCRIPTION, false);
    configList.add(s2);
    boolean valueOnly = true;
    FieldConfigEnum field = new FieldConfigEnum(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly));
    field.undoAction(null);
    field.redoAction(null);
    field.addConfig(null);
    assertNull(field.getStringValue());
    field.addConfig(configList);
    // Try without creating the ui
    field.populateExpression(null);
    field.populateField((String) null);
    field.setTestValue(null, (String) null);
    // Now create the ui
    field.createUI();
    field.createUI();
    String expectedValue1 = "key2";
    field.populateField(expectedValue1);
    String actualValueString = field.getStringValue();
    assertTrue(expectedValue1.compareTo(actualValueString) == 0);
    ValueComboBoxData actualValue = field.getEnumValue();
    assertTrue(expectedValue1.compareTo(actualValue.getKey()) == 0);
    // Try valid/invalid option values
    assertTrue(field.isValidOption("key1"));
    assertTrue(field.isValidOption("key4"));
    assertFalse(field.isValidOption("key24"));
    assertFalse(field.isValidOption(null));
}
Also used : FieldConfigEnum(com.sldeditor.ui.detail.config.FieldConfigEnum) ArrayList(java.util.ArrayList) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) SymbolTypeConfig(com.sldeditor.ui.detail.config.symboltype.SymbolTypeConfig) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData) Test(org.junit.Test)

Aggregations

ValueComboBoxData (com.sldeditor.ui.widgets.ValueComboBoxData)39 ArrayList (java.util.ArrayList)13 ValueComboBox (com.sldeditor.ui.widgets.ValueComboBox)8 ActionEvent (java.awt.event.ActionEvent)8 ActionListener (java.awt.event.ActionListener)8 ValueComboBoxDataGroup (com.sldeditor.ui.widgets.ValueComboBoxDataGroup)7 Test (org.junit.Test)7 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)6 JPanel (javax.swing.JPanel)6 UndoEvent (com.sldeditor.common.undo.UndoEvent)5 Dimension (java.awt.Dimension)4 JLabel (javax.swing.JLabel)4 UndoActionInterface (com.sldeditor.common.undo.UndoActionInterface)3 GroupConfigInterface (com.sldeditor.ui.detail.config.base.GroupConfigInterface)3 FieldConfigMarker (com.sldeditor.ui.detail.config.symboltype.FieldConfigMarker)3 FieldPanel (com.sldeditor.ui.widgets.FieldPanel)3 BorderLayout (java.awt.BorderLayout)3 JCheckBox (javax.swing.JCheckBox)3 Expression (org.opengis.filter.expression.Expression)3 ColourRamp (com.sldeditor.colourramp.ColourRamp)2