Search in sources :

Example 1 with FieldConfigSlider

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

the class ColourMapEntryPanel method createUI.

/**
 * Creates the UI.
 *
 * @param panelId the panel id
 */
private void createUI(Class<?> panelId) {
    TitledBorder title = BorderFactory.createTitledBorder(Localisation.getString(FieldConfigBase.class, "ColourMapEntryPanel.title"));
    setBorder(title);
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    label = new FieldConfigString(new FieldConfigCommonData(panelId, FieldIdEnum.RASTER_COLOURMAP_ENTRY_LABEL, Localisation.getField(FieldConfigBase.class, "ColourMapEntryPanel.label"), true, true, true), null);
    label.createUI();
    label.addDataChangedListener(this);
    fieldList.add(label);
    add(label.getPanel());
    colour = new FieldConfigColour(new FieldConfigCommonData(panelId, FieldIdEnum.RASTER_COLOURMAP_ENTRY_COLOUR, Localisation.getField(FieldConfigBase.class, "ColourMapEntryPanel.colour"), false, true, true));
    colour.createUI();
    colour.addDataChangedListener(this);
    fieldList.add(colour);
    add(colour.getPanel());
    opacity = new FieldConfigSlider(new FieldConfigCommonData(panelId, FieldIdEnum.RASTER_COLOURMAP_ENTRY_OPACITY, Localisation.getField(FieldConfigBase.class, "ColourMapEntryPanel.opacity"), false, true, true));
    opacity.createUI();
    opacity.addDataChangedListener(this);
    fieldList.add(opacity);
    add(opacity.getPanel());
    quantity = new FieldConfigDouble(new FieldConfigCommonData(panelId, FieldIdEnum.RASTER_COLOURMAP_ENTRY_QUANTITY, Localisation.getField(FieldConfigBase.class, "ColourMapEntryPanel.quantity"), false, true, true));
    quantity.createUI();
    quantity.addDataChangedListener(this);
    fieldList.add(quantity);
    add(quantity.getPanel());
    JPanel buttonPanel = new JPanel();
    // 
    // Apply button
    // 
    applyButton = new JButton(Localisation.getString(FieldConfigBase.class, "common.apply"));
    applyButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (parentObj != null) {
                ColourMapData data = new ColourMapData();
                data.setLabel(label.getStringValue());
                data.setColour(colour.getColourExpression());
                data.setOpacity(opacity.getExpression());
                data.setQuantity(quantity.getExpression());
                parentObj.colourMapEntryUpdated(data);
            }
        }
    });
    buttonPanel.add(applyButton);
    // 
    // Cancel button
    // 
    cancelButton = new JButton(Localisation.getString(FieldConfigBase.class, "common.cancel"));
    cancelButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            setVisible(false);
        }
    });
    buttonPanel.add(cancelButton);
    add(buttonPanel);
}
Also used : JPanel(javax.swing.JPanel) FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) FieldConfigDouble(com.sldeditor.ui.detail.config.FieldConfigDouble) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) FieldConfigSlider(com.sldeditor.ui.detail.config.FieldConfigSlider) TitledBorder(javax.swing.border.TitledBorder) ActionListener(java.awt.event.ActionListener) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigColour(com.sldeditor.ui.detail.config.FieldConfigColour)

Example 2 with FieldConfigSlider

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

the class ColourMapEntryPanel method createUI.

/**
 * Creates the UI.
 *
 * @param panelId the panel id
 * @param suppressUndoEvents the suppress undo events
 */
private void createUI(Class<?> panelId, boolean suppressUndoEvents) {
    TitledBorder title = BorderFactory.createTitledBorder(Localisation.getString(FieldConfigBase.class, "ColourMapEntryPanel.title"));
    setBorder(title);
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    label = new FieldConfigString(new FieldConfigCommonData(panelId, FieldIdEnum.RASTER_COLOURMAP_ENTRY_LABEL, Localisation.getField(FieldConfigBase.class, "ColourMapEntryPanel.label"), true, true, true), null);
    label.createUI();
    label.addDataChangedListener(this);
    fieldList.add(label);
    add(label.getPanel());
    colour = new FieldConfigColour(new FieldConfigCommonData(panelId, FieldIdEnum.RASTER_COLOURMAP_ENTRY_COLOUR, Localisation.getField(FieldConfigBase.class, "ColourMapEntryPanel.colour"), false, true, suppressUndoEvents));
    colour.createUI();
    colour.addDataChangedListener(this);
    fieldList.add(colour);
    add(colour.getPanel());
    opacity = new FieldConfigSlider(new FieldConfigCommonData(panelId, FieldIdEnum.RASTER_COLOURMAP_ENTRY_OPACITY, Localisation.getField(FieldConfigBase.class, "ColourMapEntryPanel.opacity"), false, true, suppressUndoEvents));
    opacity.createUI();
    opacity.addDataChangedListener(this);
    fieldList.add(opacity);
    add(opacity.getPanel());
    quantity = new FieldConfigDouble(new FieldConfigCommonData(panelId, FieldIdEnum.RASTER_COLOURMAP_ENTRY_QUANTITY, Localisation.getField(FieldConfigBase.class, "ColourMapEntryPanel.quantity"), false, true, suppressUndoEvents));
    quantity.createUI();
    quantity.addDataChangedListener(this);
    fieldList.add(quantity);
    add(quantity.getPanel());
    JPanel buttonPanel = new JPanel();
    // 
    // Apply button
    // 
    applyButton = new JButton(Localisation.getString(FieldConfigBase.class, "common.apply"));
    applyButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (parentObj != null) {
                ColourMapData data = new ColourMapData();
                data.setLabel(label.getStringValue());
                data.setColour(colour.getColourExpression());
                data.setOpacity(opacity.getExpression());
                data.setQuantity(quantity.getExpression());
                parentObj.colourMapEntryUpdated(data);
            }
        }
    });
    buttonPanel.add(applyButton);
    // 
    // Cancel button
    // 
    JButton cancelButton = new JButton(Localisation.getString(FieldConfigBase.class, "common.cancel"));
    cancelButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            setVisible(false);
        }
    });
    buttonPanel.add(cancelButton);
    add(buttonPanel);
}
Also used : JPanel(javax.swing.JPanel) FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) FieldConfigDouble(com.sldeditor.ui.detail.config.FieldConfigDouble) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) FieldConfigSlider(com.sldeditor.ui.detail.config.FieldConfigSlider) TitledBorder(javax.swing.border.TitledBorder) ActionListener(java.awt.event.ActionListener) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigColour(com.sldeditor.ui.detail.config.FieldConfigColour)

Example 3 with FieldConfigSlider

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

the class InstantiateFields method addFieldSlider.

/**
 * Adds the field slider.
 *
 * @param fieldData the field data
 * @return the field config base
 */
private FieldConfigBase addFieldSlider(FieldData fieldData) {
    XMLFieldConfigSlider xmlSlider = (XMLFieldConfigSlider) fieldData.getXmlFieldConfig();
    FieldConfigSlider sliderConfig = new FieldConfigSlider(fieldData.getCommonData());
    sliderConfig.setDefaultValue(xmlSlider.getDefaultValue());
    Double defaultValueObj = ConfigDefaultFactory.getDouble(fieldData.getDefaultValue());
    if (defaultValueObj != null) {
        sliderConfig.setDefaultValue(defaultValueObj);
        defaultFieldMap.put(fieldData.getId(), defaultValueObj);
    }
    return sliderConfig;
}
Also used : XMLFieldConfigSlider(com.sldeditor.common.xml.ui.XMLFieldConfigSlider) FieldConfigSlider(com.sldeditor.ui.detail.config.FieldConfigSlider) XMLFieldConfigSlider(com.sldeditor.common.xml.ui.XMLFieldConfigSlider) FieldConfigDouble(com.sldeditor.ui.detail.config.FieldConfigDouble) XMLFieldConfigDouble(com.sldeditor.common.xml.ui.XMLFieldConfigDouble)

Example 4 with FieldConfigSlider

use of com.sldeditor.ui.detail.config.FieldConfigSlider 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, false), 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, false));
    colourField.createUI();
    String expectedColourValue = "#012345";
    colourField.setTestValue(null, expectedColourValue);
    double expectedOpacityValue = 0.72;
    FieldConfigSlider opacityField = new FieldConfigSlider(new FieldConfigCommonData(panelId, colourFieldId, "", false, false));
    opacityField.createUI();
    opacityField.populateField(expectedOpacityValue);
    FieldConfigBase symbolSelectionField = new FieldConfigSymbolType(new FieldConfigCommonData(panelId, colourFieldId, "", false, 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.jupiter.api.Test)

Example 5 with FieldConfigSlider

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

the class FieldConfigMarkerTest method testPopulateFieldOverrideMap.

/**
 * Test method for {@link
 * com.sldeditor.ui.detail.config.symboltype.FieldConfigMarker#populateFieldOverrideMap(java.lang.Class,
 * com.sldeditor.ui.detail.FieldEnableState)}.
 */
@Test
public void testPopulateFieldOverrideMap() {
    // Test it with non null values
    FieldIdEnum colourFieldId = FieldIdEnum.FILL_COLOUR;
    Class<?> panelId = PointFillDetails.class;
    FieldConfigColour colourField = new FieldConfigColour(new FieldConfigCommonData(panelId, colourFieldId, "", false, false));
    colourField.createUI();
    String expectedColourValue = "#012345";
    colourField.setTestValue(null, expectedColourValue);
    double expectedOpacityValue = 0.72;
    FieldConfigSlider opacityField = new FieldConfigSlider(new FieldConfigCommonData(panelId, colourFieldId, "", false, false));
    opacityField.createUI();
    opacityField.populateField(expectedOpacityValue);
    FieldConfigBase symbolSelectionField = new FieldConfigSymbolType(new FieldConfigCommonData(panelId, colourFieldId, "", false, false));
    symbolSelectionField.createUI();
    GraphicPanelFieldManager fieldConfigManager = new GraphicPanelFieldManager(panelId);
    fieldConfigManager.add(colourFieldId, colourField);
    FieldIdEnum opacityFieldId = FieldIdEnum.OVERALL_OPACITY;
    fieldConfigManager.add(opacityFieldId, opacityField);
    FieldIdEnum symbolSelectionFieldId = FieldIdEnum.SYMBOL_TYPE;
    fieldConfigManager.add(symbolSelectionFieldId, symbolSelectionField);
    ColourFieldConfig strokeConfig = new ColourFieldConfig(GroupIdEnum.STROKE, FieldIdEnum.STROKE_STROKE_COLOUR, FieldIdEnum.OVERALL_OPACITY, FieldIdEnum.STROKE_FILL_WIDTH);
    boolean valueOnly = true;
    ColourFieldConfig fillConfig = new ColourFieldConfig(GroupIdEnum.FILL, FieldIdEnum.FILL_COLOUR, FieldIdEnum.OVERALL_OPACITY, FieldIdEnum.STROKE_WIDTH);
    FieldConfigMarker field = new FieldConfigMarker(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly, false), fillConfig, strokeConfig, null);
    field.populateFieldOverrideMap(String.class, null);
    field.populateFieldOverrideMap(PointSymbolizerDetails.class, null);
}
Also used : FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) FieldConfigSlider(com.sldeditor.ui.detail.config.FieldConfigSlider) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) FieldConfigMarker(com.sldeditor.ui.detail.config.symboltype.FieldConfigMarker) ColourFieldConfig(com.sldeditor.ui.detail.ColourFieldConfig) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigColour(com.sldeditor.ui.detail.config.FieldConfigColour) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) PointFillDetails(com.sldeditor.ui.detail.PointFillDetails) FieldConfigSymbolType(com.sldeditor.ui.detail.config.FieldConfigSymbolType) Test(org.junit.jupiter.api.Test)

Aggregations

FieldConfigSlider (com.sldeditor.ui.detail.config.FieldConfigSlider)28 Test (org.junit.jupiter.api.Test)25 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)22 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)17 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)15 FieldConfigColour (com.sldeditor.ui.detail.config.FieldConfigColour)14 FieldConfigSymbolType (com.sldeditor.ui.detail.config.FieldConfigSymbolType)14 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)13 PointFillDetails (com.sldeditor.ui.detail.PointFillDetails)12 ColourFieldConfig (com.sldeditor.ui.detail.ColourFieldConfig)10 FieldConfigDouble (com.sldeditor.ui.detail.config.FieldConfigDouble)9 StyleBuilder (org.geotools.styling.StyleBuilder)9 Mark (org.geotools.styling.Mark)7 FieldConfigMarker (com.sldeditor.ui.detail.config.symboltype.FieldConfigMarker)6 FieldConfigString (com.sldeditor.ui.detail.config.FieldConfigString)5 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)5 NamedLayer (org.geotools.styling.NamedLayer)5 Rule (org.geotools.styling.Rule)5 Style (org.geotools.styling.Style)5 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)5