Search in sources :

Example 11 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 12 with FieldConfigSlider

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

the class FieldConfigSliderTest method testGenerateExpression.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigSlider#generateExpression()}. Test method
 * for
 * {@link com.sldeditor.ui.detail.config.FieldConfigSlider#populateExpression(java.lang.Object, org.opengis.filter.expression.Expression)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigSlider#populateField(java.lang.Double)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigSlider#setTestValue(com.sldeditor.ui.detail.config.FieldId, double)}.
 * Test method for {@link com.sldeditor.ui.detail.config.FieldConfigSlider#getDoubleValue()}.
 */
@Test
public void testGenerateExpression() {
    boolean valueOnly = true;
    FieldConfigSlider field = new FieldConfigSlider(new FieldConfigCommonData(Double.class, FieldIdEnum.NAME, "label", valueOnly));
    double defaultDefaultValue = 0.5;
    double expectedValue = 1.0;
    field.populateField(expectedValue);
    double actualValue = field.getDoubleValue();
    assertTrue(Math.abs(actualValue - defaultDefaultValue) < 0.001);
    field.setTestValue(null, expectedValue);
    actualValue = field.getDoubleValue();
    assertTrue(Math.abs(actualValue - defaultDefaultValue) < 0.001);
    field.populateExpression(null);
    actualValue = field.getDoubleValue();
    assertTrue(Math.abs(actualValue - defaultDefaultValue) < 0.001);
    field.createUI();
    field.populateField(expectedValue);
    actualValue = field.getDoubleValue();
    assertTrue(Math.abs(actualValue - expectedValue) < 0.001);
    double expectedValue2 = 0.14;
    field.setTestValue(null, expectedValue2);
    actualValue = field.getDoubleValue();
    assertTrue(Math.abs(actualValue - expectedValue2) < 0.001);
    Integer expectedValue3a = Integer.valueOf(1);
    field.populateExpression(expectedValue3a);
    actualValue = field.getDoubleValue();
    assertTrue(Math.abs(actualValue - expectedValue3a) < 0.001);
    Double expectedValue3c = Double.valueOf(0.4);
    field.populateExpression(expectedValue3c);
    actualValue = field.getDoubleValue();
    assertTrue(Math.abs(actualValue - expectedValue3c) < 0.001);
    double expectedValue3d = 0.87;
    String expectedValue3dString = String.valueOf(expectedValue3d);
    field.populateExpression(expectedValue3dString);
    actualValue = field.getDoubleValue();
    assertTrue(Math.abs(actualValue - expectedValue3d) < 0.001);
}
Also used : FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigSlider(com.sldeditor.ui.detail.config.FieldConfigSlider) Test(org.junit.Test)

Example 13 with FieldConfigSlider

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

the class FieldConfigSliderTest method testRevertToDefaultValue.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigSlider#revertToDefaultValue()}. Test method
 * for {@link com.sldeditor.ui.detail.config.FieldConfigSlider#setDefaultValue(double)}.
 */
@Test
public void testRevertToDefaultValue() {
    boolean valueOnly = true;
    FieldConfigSlider field = new FieldConfigSlider(new FieldConfigCommonData(Double.class, FieldIdEnum.NAME, "label", valueOnly));
    double defaultDefaultValue = 0.5;
    field.revertToDefaultValue();
    assertTrue(Math.abs(field.getDoubleValue() - defaultDefaultValue) < 0.001);
    field.createUI();
    field.createUI();
    Double expectedDefaultValue = 0.42;
    field.setDefaultValue(expectedDefaultValue);
    field.revertToDefaultValue();
    assertTrue(Math.abs(field.getDoubleValue() - expectedDefaultValue) < 0.001);
    assertTrue(String.valueOf(expectedDefaultValue).compareTo(field.getStringValue()) == 0);
}
Also used : FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigSlider(com.sldeditor.ui.detail.config.FieldConfigSlider) Test(org.junit.Test)

Example 14 with FieldConfigSlider

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

the class FieldConfigSliderTest method testAttributeSelection.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigSlider#attributeSelection(java.lang.String)}.
 */
@Test
public void testAttributeSelection() {
    boolean valueOnly = true;
    FieldConfigSlider field = new FieldConfigSlider(new FieldConfigCommonData(Double.class, FieldIdEnum.NAME, "label", valueOnly));
    field.attributeSelection(null);
// Do nothing
}
Also used : FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigSlider(com.sldeditor.ui.detail.config.FieldConfigSlider) Test(org.junit.Test)

Example 15 with FieldConfigSlider

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

the class FieldConfigMarkerTest method testSetValue.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.symboltype.FieldConfigMarker#setValue(com.sldeditor.ui.detail.GraphicPanelFieldManager, com.sldeditor.ui.detail.config.FieldConfigSymbolType, org.opengis.style.GraphicalSymbol)}.
 */
@Test
public void testSetValue() {
    GraphicPanelFieldManager fieldConfigManager = null;
    Class<?> panelId = PointFillDetails.class;
    fieldConfigManager = new GraphicPanelFieldManager(panelId);
    // Test it with non null values
    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);
    boolean valueOnly = true;
    ColourFieldConfig fillConfig = new ColourFieldConfig(GroupIdEnum.FILL, FieldIdEnum.FILL_COLOUR, FieldIdEnum.OVERALL_OPACITY, FieldIdEnum.STROKE_WIDTH);
    ColourFieldConfig strokeConfig = new ColourFieldConfig(GroupIdEnum.STROKE, FieldIdEnum.STROKE_STROKE_COLOUR, FieldIdEnum.OVERALL_OPACITY, FieldIdEnum.STROKE_FILL_WIDTH);
    FieldConfigMarker field2 = new FieldConfigMarker(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly), fillConfig, strokeConfig, null);
    field2.setValue(null, null, null, null, null);
    field2.setValue(null, fieldConfigManager, null, null, null);
    StyleBuilder styleBuilder = new StyleBuilder();
    Mark marker = styleBuilder.createMark("star");
    field2.setValue(null, null, null, null, marker);
    field2.setValue(null, fieldConfigManager, null, null, marker);
}
Also used : FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) StyleBuilder(org.geotools.styling.StyleBuilder) FieldConfigSlider(com.sldeditor.ui.detail.config.FieldConfigSlider) Mark(org.geotools.styling.Mark) 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) PointFillDetails(com.sldeditor.ui.detail.PointFillDetails) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) FieldConfigSymbolType(com.sldeditor.ui.detail.config.FieldConfigSymbolType) Test(org.junit.Test)

Aggregations

FieldConfigSlider (com.sldeditor.ui.detail.config.FieldConfigSlider)25 Test (org.junit.Test)24 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)20 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)17 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)14 FieldConfigSymbolType (com.sldeditor.ui.detail.config.FieldConfigSymbolType)14 PointFillDetails (com.sldeditor.ui.detail.PointFillDetails)13 FieldConfigColour (com.sldeditor.ui.detail.config.FieldConfigColour)13 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)12 ColourFieldConfig (com.sldeditor.ui.detail.ColourFieldConfig)10 StyleBuilder (org.geotools.styling.StyleBuilder)9 Mark (org.geotools.styling.Mark)7 FieldConfigDouble (com.sldeditor.ui.detail.config.FieldConfigDouble)6 FieldConfigMarker (com.sldeditor.ui.detail.config.symboltype.FieldConfigMarker)6 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 Expression (org.opengis.filter.expression.Expression)5