Search in sources :

Example 21 with FieldIdEnum

use of com.sldeditor.common.xml.ui.FieldIdEnum in project sldeditor by robward-scisys.

the class FieldConfigPopulationTest method testColourMap.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#populateColourMapField(com.sldeditor.common.xml.ui.FieldIdEnum, org.geotools.styling.ColorMap)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#getColourMap(com.sldeditor.common.xml.ui.FieldIdEnum)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#getColourMap(com.sldeditor.ui.detail.config.FieldId)}.
 */
@Test
public void testColourMap() {
    FieldIdEnum fieldId = FieldIdEnum.DESCRIPTION;
    GraphicPanelFieldManager fieldConfigManager = new GraphicPanelFieldManager(String.class);
    FieldConfigColourMap colourMapField = new FieldConfigColourMap(new FieldConfigCommonData(Geometry.class, fieldId, "label", true));
    colourMapField.createUI();
    fieldConfigManager.add(fieldId, colourMapField);
    ColorMap expectedValue = new ColorMapImpl();
    ColorMapEntry entry = new ColorMapEntryImpl();
    StyleBuilder styleBuilder = new StyleBuilder();
    entry.setColor(styleBuilder.colorExpression(Color.PINK));
    entry.setQuantity(styleBuilder.literalExpression(2.3));
    expectedValue.addColorMapEntry(entry);
    FieldConfigPopulation obj = new FieldConfigPopulation(fieldConfigManager);
    obj.populateColourMapField(fieldId, expectedValue);
    assertEquals(expectedValue.getColorMapEntries().length, obj.getColourMap(fieldId).getColorMapEntries().length);
    // This shouldn't work as it does not know about the field
    FieldIdEnum wrongFieldEnum = FieldIdEnum.ELSE_FILTER;
    obj.populateColourMapField(wrongFieldEnum, expectedValue);
    assertNull(obj.getColourMap(wrongFieldEnum));
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) FieldConfigPopulation(com.sldeditor.ui.detail.config.FieldConfigPopulation) ColorMapImpl(org.geotools.styling.ColorMapImpl) FieldConfigColourMap(com.sldeditor.ui.detail.config.colourmap.FieldConfigColourMap) ColorMapEntryImpl(org.geotools.styling.ColorMapEntryImpl) ColorMap(org.geotools.styling.ColorMap) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) StyleBuilder(org.geotools.styling.StyleBuilder) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) ColorMapEntry(org.geotools.styling.ColorMapEntry) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) Test(org.junit.Test)

Example 22 with FieldIdEnum

use of com.sldeditor.common.xml.ui.FieldIdEnum in project sldeditor by robward-scisys.

the class FieldConfigPopulationTest method testIsTreeDataUpdated.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#isTreeDataUpdated()}. Test method
 * for {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#resetTreeDataUpdated()}.
 */
@Test
public void testIsTreeDataUpdated() {
    FieldIdEnum fieldId = FieldIdEnum.DESCRIPTION;
    GraphicPanelFieldManager fieldConfigManager = new GraphicPanelFieldManager(String.class);
    FieldConfigString stringField = new FieldConfigString(new FieldConfigCommonData(Geometry.class, fieldId, "label", true), "button text");
    stringField.createUI();
    fieldConfigManager.add(fieldId, stringField);
    FieldConfigPopulation obj = new FieldConfigPopulation(fieldConfigManager);
    assertFalse(obj.isTreeDataUpdated());
    // Set data
    String expectedValue = "test string";
    obj.populateTextField(fieldId, expectedValue);
    assertTrue(expectedValue.compareTo(obj.getText(fieldId)) == 0);
    assertFalse(obj.isTreeDataUpdated());
    // Simulate a key being pressed
    expectedValue = "test string1";
    stringField.populateField(expectedValue);
    // Data is different so flag should have changed
    assertTrue(expectedValue.compareTo(obj.getText(fieldId)) == 0);
    assertTrue(obj.isTreeDataUpdated());
    obj.resetTreeDataUpdated();
    assertFalse(obj.isTreeDataUpdated());
    // Populate the same data again and the flag should not have changed
    obj.populateTextField(fieldId, expectedValue);
    assertTrue(expectedValue.compareTo(obj.getText(fieldId)) == 0);
    assertFalse(obj.isTreeDataUpdated());
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) FieldConfigPopulation(com.sldeditor.ui.detail.config.FieldConfigPopulation) 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) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) Test(org.junit.Test)

Example 23 with FieldIdEnum

use of com.sldeditor.common.xml.ui.FieldIdEnum in project sldeditor by robward-scisys.

the class FieldConfigPopulationTest method testFont.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#populateFontField(com.sldeditor.common.xml.ui.FieldIdEnum, org.geotools.styling.Font)}.
 */
@Test
public void testFont() {
    FieldIdEnum fieldId = FieldIdEnum.DESCRIPTION;
    GraphicPanelFieldManager fieldConfigManager = new GraphicPanelFieldManager(String.class);
    FieldConfigFont fontField = new FieldConfigFont(new FieldConfigCommonData(Geometry.class, fieldId, "label", true));
    fontField.createUI();
    fieldConfigManager.add(fieldId, fontField);
    FieldConfigPopulation obj = new FieldConfigPopulation(fieldConfigManager);
    StyleBuilder styleBuilder = new StyleBuilder();
    Font expectedValue = styleBuilder.createFont(java.awt.Font.decode(null));
    obj.populateFontField(fieldId, expectedValue);
    // This shouldn't work as it does not know about the field
    FieldIdEnum wrongFieldEnum = FieldIdEnum.ELSE_FILTER;
    obj.populateFontField(wrongFieldEnum, expectedValue);
}
Also used : FieldConfigFont(com.sldeditor.ui.detail.config.font.FieldConfigFont) Geometry(com.vividsolutions.jts.geom.Geometry) FieldConfigPopulation(com.sldeditor.ui.detail.config.FieldConfigPopulation) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) StyleBuilder(org.geotools.styling.StyleBuilder) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) FieldConfigFont(com.sldeditor.ui.detail.config.font.FieldConfigFont) Font(org.geotools.styling.Font) Test(org.junit.Test)

Example 24 with FieldIdEnum

use of com.sldeditor.common.xml.ui.FieldIdEnum in project sldeditor by robward-scisys.

the class ExpressionSubPanel method displayExpression.

/**
 * Display expression.
 *
 * @param node the node
 */
private void displayExpression(ExpressionNode node) {
    if (panelLiteral.getComponentCount() == 2) {
        panelLiteral.remove(1);
    }
    if (node == null) {
        return;
    }
    fieldConfig = PanelField.getField(ExpressionPanelv2.class, "ExpressionSubPanel.value", node.getType());
    if (fieldConfig != null) {
        fieldConfig.createUI();
        fieldConfig.addDataChangedListener(new UpdateSymbolInterface() {

            @Override
            public void dataChanged(FieldIdEnum changedField) {
                buttonGroup.setSelected(rdbtnLiteral.getModel(), true);
                updateButtonState(true);
            }
        });
        panelLiteral.add(fieldConfig.getPanel());
        // Reset the fields
        dataSourceAttributePanel.setAttribute(null);
        functionPanel.setFunction(null);
        dataSourceAttributePanel.setDataType(node.getType());
        Expression expression = node.getExpression();
        if (expression instanceof AttributeExpressionImpl) {
            dataSourceAttributePanel.setAttribute(expression);
            buttonGroup.setSelected(rdbtnAttribute.getModel(), true);
        } else if (expression instanceof EnvFunction) {
            envVarField.setEnvironmentVariable(expression);
            buttonGroup.setSelected(rdbtnEnvVar.getModel(), true);
        } else if (expression instanceof FunctionExpressionImpl) {
            functionPanel.setFunction(expression);
            buttonGroup.setSelected(rdbtnFunction.getModel(), true);
        } else {
            fieldConfig.populate(expression);
            buttonGroup.setSelected(rdbtnLiteral.getModel(), true);
        }
    }
    Dimension boxSize = box.getPreferredSize();
    setPreferredSize(boxSize);
    revalidate();
}
Also used : EnvFunction(org.geotools.filter.function.EnvFunction) Expression(org.opengis.filter.expression.Expression) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) UpdateSymbolInterface(com.sldeditor.ui.iface.UpdateSymbolInterface) Dimension(java.awt.Dimension) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) FunctionExpressionImpl(org.geotools.filter.FunctionExpressionImpl)

Example 25 with FieldIdEnum

use of com.sldeditor.common.xml.ui.FieldIdEnum in project sldeditor by robward-scisys.

the class BasePanel method handleFieldState.

/**
 * Handle field state for a specific combo box field.
 *
 * @param fieldId the field id
 */
protected void handleFieldState(FieldIdEnum fieldId) {
    FieldConfigBase fieldConfig = fieldConfigManager.get(fieldId);
    if (fieldConfig != null) {
        if (fieldConfig instanceof FieldConfigEnum) {
            FieldConfigEnum fieldEnum = (FieldConfigEnum) fieldConfig;
            Map<FieldIdEnum, Boolean> stateMap = fieldEnum.getFieldEnableState();
            if (stateMap != null) {
                for (FieldIdEnum fieldKey : stateMap.keySet()) {
                    enableField(fieldKey, stateMap.get(fieldKey));
                }
            }
        }
    } else {
        ConsoleManager.getInstance().error(this, String.format("handleFieldState - %s : %s", Localisation.getString(StandardPanel.class, "StandardPanel.unknownField"), fieldId));
    }
}
Also used : FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) FieldConfigEnum(com.sldeditor.ui.detail.config.FieldConfigEnum) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum)

Aggregations

FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)83 Test (org.junit.Test)55 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)54 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)33 FieldConfigString (com.sldeditor.ui.detail.config.FieldConfigString)28 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)27 FieldConfigColour (com.sldeditor.ui.detail.config.FieldConfigColour)17 PointFillDetails (com.sldeditor.ui.detail.PointFillDetails)16 StyleBuilder (org.geotools.styling.StyleBuilder)14 ColourFieldConfig (com.sldeditor.ui.detail.ColourFieldConfig)13 FieldConfigPopulation (com.sldeditor.ui.detail.config.FieldConfigPopulation)13 Geometry (com.vividsolutions.jts.geom.Geometry)13 Expression (org.opengis.filter.expression.Expression)13 FieldConfigSlider (com.sldeditor.ui.detail.config.FieldConfigSlider)12 FieldConfigSymbolType (com.sldeditor.ui.detail.config.FieldConfigSymbolType)12 GroupIdEnum (com.sldeditor.common.xml.ui.GroupIdEnum)10 GroupConfigInterface (com.sldeditor.ui.detail.config.base.GroupConfigInterface)8 ArrayList (java.util.ArrayList)8 Mark (org.geotools.styling.Mark)7 StrokeDetails (com.sldeditor.ui.detail.StrokeDetails)6