Search in sources :

Example 6 with FieldConfigInteger

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

the class FieldConfigIntegerTest method testSetEnabled.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigInteger#internal_setEnabled(boolean)}. Test
 * method for {@link com.sldeditor.ui.detail.config.FieldConfigInteger#isEnabled()}. Test method
 * for {@link com.sldeditor.ui.detail.config.FieldConfigInteger#createUI(javax.swing.Box)}.
 */
@Test
public void testSetEnabled() {
    // Value only, no attribute/expression dropdown
    boolean valueOnly = true;
    FieldConfigInteger field = new FieldConfigInteger(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly));
    // 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;
    FieldConfigInteger field2 = new FieldConfigInteger(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly));
    // 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 : FieldConfigInteger(com.sldeditor.ui.detail.config.FieldConfigInteger) FieldConfigInteger(com.sldeditor.ui.detail.config.FieldConfigInteger) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) Test(org.junit.Test)

Example 7 with FieldConfigInteger

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

the class FieldConfigPopulationTest method testExpression.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#populateField(com.sldeditor.ui.detail.config.FieldId, org.opengis.filter.expression.Expression)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#populateField(com.sldeditor.common.xml.ui.FieldIdEnum, org.opengis.filter.expression.Expression)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#getExpression(com.sldeditor.ui.detail.config.FieldId)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#getExpression(com.sldeditor.common.xml.ui.FieldIdEnum)}.
 */
@Test
public void testExpression() {
    FieldIdEnum fieldId = FieldIdEnum.DESCRIPTION;
    GraphicPanelFieldManager fieldConfigManager = new GraphicPanelFieldManager(String.class);
    FieldConfigInteger intField = new FieldConfigInteger(new FieldConfigCommonData(Geometry.class, fieldId, "label", true));
    intField.createUI();
    fieldConfigManager.add(fieldId, intField);
    FieldConfigPopulation obj = new FieldConfigPopulation(fieldConfigManager);
    int expectedValue = 1256;
    StyleBuilder styleBuilder = new StyleBuilder();
    Expression expression = styleBuilder.literalExpression(expectedValue);
    obj.populateField(fieldId, expression);
    LiteralExpressionImpl actualValue = (LiteralExpressionImpl) obj.getExpression(fieldId);
    assertEquals(expectedValue, ((Integer) actualValue.getValue()).intValue());
    actualValue = (LiteralExpressionImpl) obj.getExpression(fieldId);
    assertEquals(expectedValue, ((Integer) actualValue.getValue()).intValue());
    // This shouldn't work as it does not know about the field
    FieldIdEnum wrongFieldEnum = FieldIdEnum.ELSE_FILTER;
    obj.populateField(wrongFieldEnum, expression);
    assertNull(obj.getExpression(wrongFieldEnum));
    // Try with null
    obj.populateField(fieldId, null);
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) FieldConfigPopulation(com.sldeditor.ui.detail.config.FieldConfigPopulation) FieldConfigInteger(com.sldeditor.ui.detail.config.FieldConfigInteger) Expression(org.opengis.filter.expression.Expression) LiteralExpressionImpl(org.geotools.filter.LiteralExpressionImpl) 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) FeatureTypeConstraint(org.geotools.styling.FeatureTypeConstraint) Test(org.junit.Test)

Example 8 with FieldConfigInteger

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

the class FieldConfigPopulationTest method testGetFieldConfig.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#getFieldConfig(com.sldeditor.ui.detail.config.FieldId)}.
 */
@Test
public void testGetFieldConfig() {
    FieldIdEnum fieldId = FieldIdEnum.DESCRIPTION;
    GraphicPanelFieldManager fieldConfigManager = new GraphicPanelFieldManager(String.class);
    FieldConfigInteger intField = new FieldConfigInteger(new FieldConfigCommonData(Geometry.class, fieldId, "label", true));
    intField.createUI();
    fieldConfigManager.add(fieldId, intField);
    FieldConfigPopulation obj = new FieldConfigPopulation(fieldConfigManager);
    assertNotNull(obj.getFieldConfig(fieldId));
    FieldIdEnum wrongFieldEnum = FieldIdEnum.ELSE_FILTER;
    assertNull(obj.getFieldConfig(wrongFieldEnum));
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) FieldConfigPopulation(com.sldeditor.ui.detail.config.FieldConfigPopulation) FieldConfigInteger(com.sldeditor.ui.detail.config.FieldConfigInteger) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) GraphicPanelFieldManager(com.sldeditor.ui.detail.GraphicPanelFieldManager) Test(org.junit.Test)

Example 9 with FieldConfigInteger

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

the class ColourRampPanel method createFieldPanel.

/**
 * Creates the field panel.
 */
private void createFieldPanel() {
    JPanel tablePanel = new JPanel();
    tablePanel.setLayout(new BorderLayout());
    panel.add(tablePanel, BorderLayout.CENTER);
    JPanel dataPanel = new JPanel();
    tablePanel.add(dataPanel, BorderLayout.NORTH);
    dataPanel.setLayout(new BoxLayout(dataPanel, BoxLayout.Y_AXIS));
    minValueSpinner = new FieldConfigInteger(new FieldConfigCommonData(getClass(), FieldIdEnum.UNKNOWN, Localisation.getField(ColourRampConfigPanel.class, "ColourRampPanel.minValue"), true));
    minValueSpinner.createUI();
    FieldPanel fieldPanel = minValueSpinner.getPanel();
    dataPanel.add(fieldPanel);
    JButton resetValueButton = new JButton(Localisation.getString(ColourRampConfigPanel.class, "ColourRampPanel.reset"));
    minValueSpinner.addUI(resetValueButton, 20, BasePanel.WIDGET_BUTTON_WIDTH, BasePanel.WIDGET_HEIGHT);
    minValueSpinner.populateField(0);
    resetValueButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (parentObj != null) {
                ColourMapModel model = parentObj.getColourMapModel();
                populate(model.getColourMap());
            }
        }
    });
    maxValueSpinner = new FieldConfigInteger(new FieldConfigCommonData(getClass(), FieldIdEnum.UNKNOWN, Localisation.getField(ColourRampConfigPanel.class, "ColourRampPanel.maxValue"), true));
    maxValueSpinner.createUI();
    maxValueSpinner.populateField(100);
    dataPanel.add(maxValueSpinner.getPanel());
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
    buttonPanel.setSize(BasePanel.FIELD_PANEL_WIDTH, BasePanel.WIDGET_HEIGHT);
    JButton applyButton = new JButton(Localisation.getString(ColourRampConfigPanel.class, "common.apply"));
    applyButton.setPreferredSize(new Dimension(BasePanel.WIDGET_BUTTON_WIDTH, BasePanel.WIDGET_HEIGHT));
    applyButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (parentObj != null) {
                ColourRampData data = new ColourRampData();
                data.setMaxValue(maxValueSpinner.getIntValue());
                data.setMinValue(minValueSpinner.getIntValue());
                data.setReverseColours(reverseCheckbox.isSelected());
                ValueComboBoxData selectedItem = (ValueComboBoxData) rampComboBox.getSelectedItem();
                ColourRamp colourRamp = colourRampCache.get(selectedItem.getKey());
                data.setColourRamp(colourRamp);
                parentObj.colourRampUpdate(data);
            }
        }
    });
    buttonPanel.add(applyButton);
    dataPanel.add(buttonPanel);
}
Also used : JPanel(javax.swing.JPanel) FieldConfigInteger(com.sldeditor.ui.detail.config.FieldConfigInteger) FlowLayout(java.awt.FlowLayout) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) Dimension(java.awt.Dimension) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData) BorderLayout(java.awt.BorderLayout) ActionListener(java.awt.event.ActionListener) XMLTwoColourRamp(com.sldeditor.common.xml.ui.XMLTwoColourRamp) ColourRamp(com.sldeditor.colourramp.ColourRamp) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldPanel(com.sldeditor.ui.widgets.FieldPanel) ColourRampConfigPanel(com.sldeditor.colourramp.ColourRampConfigPanel) ColourMapModel(com.sldeditor.ui.detail.config.colourmap.ColourMapModel)

Example 10 with FieldConfigInteger

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

the class FontSizePanel method createUI.

/**
 * Creates the UI.
 */
private void createUI() {
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    value = new FieldConfigInteger(new FieldConfigCommonData(getClass(), FieldIdEnum.FONT_SIZE, Localisation.getField(BatchUpdateFontPanel.class, "BatchUpdateFontPanel.fontSize"), true, false, false));
    value.createUI();
    value.addDataChangedListener(this);
    add(value.getPanel());
    populate(null);
}
Also used : FieldConfigInteger(com.sldeditor.ui.detail.config.FieldConfigInteger) BoxLayout(javax.swing.BoxLayout) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData)

Aggregations

FieldConfigInteger (com.sldeditor.ui.detail.config.FieldConfigInteger)16 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)14 Test (org.junit.Test)11 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)4 Geometry (com.vividsolutions.jts.geom.Geometry)4 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)3 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)3 FieldConfigPopulation (com.sldeditor.ui.detail.config.FieldConfigPopulation)3 FieldConfigBoolean (com.sldeditor.ui.detail.config.FieldConfigBoolean)2 FieldConfigDouble (com.sldeditor.ui.detail.config.FieldConfigDouble)2 BoxLayout (javax.swing.BoxLayout)2 LiteralExpressionImpl (org.geotools.filter.LiteralExpressionImpl)2 FeatureTypeConstraint (org.geotools.styling.FeatureTypeConstraint)2 Expression (org.opengis.filter.expression.Expression)2 ColourRamp (com.sldeditor.colourramp.ColourRamp)1 ColourRampConfigPanel (com.sldeditor.colourramp.ColourRampConfigPanel)1 UndoEvent (com.sldeditor.common.undo.UndoEvent)1 XMLTwoColourRamp (com.sldeditor.common.xml.ui.XMLTwoColourRamp)1 Disjoint (com.sldeditor.filter.v2.function.geometry.Disjoint)1 FieldConfigColour (com.sldeditor.ui.detail.config.FieldConfigColour)1