Search in sources :

Example 1 with ValueComboBoxData

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

the class InLineFeatureModelTest method testUpdateCRS.

/**
 * Test method for {@link com.sldeditor.ui.detail.config.inlinefeature.InLineFeatureModel#updateCRS(com.sldeditor.ui.widgets.ValueComboBoxData)}.
 */
@Test
public void testUpdateCRS() {
    DummyInlineFeatureUpdated listener = new DummyInlineFeatureUpdated();
    InLineFeatureModel model = new InLineFeatureModel(listener);
    assertNull(model.getFeatureCollection());
    DummyInlineSLDFile testData1 = new DummyInlineSLDFile();
    UserLayer userLayer = (UserLayer) testData1.getSLD().layers().get(0);
    model.populate(userLayer);
    model.updateCRS(null);
    assertNull(userLayer.getInlineFeatureType().getGeometryDescriptor().getCoordinateReferenceSystem());
    ValueComboBoxData expectedCRS = new ValueComboBoxData("EPSG:2000", "Test CRS", VendorOptionManager.getInstance().getDefaultVendorOptionVersion());
    assertFalse(listener.hasInlineFeatureUpdatedCalled());
    model.updateCRS(expectedCRS);
    assertTrue(listener.hasInlineFeatureUpdatedCalled());
    String newCRSCode = userLayer.getInlineFeatureType().getGeometryDescriptor().getCoordinateReferenceSystem().getCoordinateSystem().getName().getCode();
    assertNotNull(newCRSCode);
}
Also used : InLineFeatureModel(com.sldeditor.ui.detail.config.inlinefeature.InLineFeatureModel) DummyInlineSLDFile(com.sldeditor.test.unit.datasource.impl.DummyInlineSLDFile) UserLayer(org.geotools.styling.UserLayer) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData) Test(org.junit.Test)

Example 2 with ValueComboBoxData

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

the class FieldConfigSymbolTypeTest method testGenerateExpression.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigSymbolType#generateExpression()}. Test
 * method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigSymbolType#populateExpression(java.lang.Object, org.opengis.filter.expression.Expression)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigSymbolType#populateField(java.lang.String)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigSymbolType#setTestValue(com.sldeditor.ui.detail.config.FieldId, java.lang.String)}.
 * Test method for {@link com.sldeditor.ui.detail.config.FieldConfigSymbolType#getEnumValue()}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigSymbolType#FieldConfigSymbolType(java.lang.Class, com.sldeditor.ui.detail.config.FieldId, java.lang.String, boolean)}.
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigSymbolType#getStringValue()}. Test method
 * for
 * {@link com.sldeditor.ui.detail.config.FieldConfigSymbolType#addField(com.sldeditor.ui.detail.config.symboltype.SymbolTypeInterface)}.
 */
@Test
public void testGenerateExpression() {
    boolean valueOnly = true;
    FieldConfigSymbolType field = new FieldConfigSymbolType(new FieldConfigCommonData(Integer.class, FieldIdEnum.NAME, "label", valueOnly));
    field.populateExpression(null);
    field.setTestValue(FieldIdEnum.UNKNOWN, (String) null);
    assertNull(field.getEnumValue());
    assertNull(field.getSelectedValueObj());
    assertNull(field.getSelectedValue());
    field.createUI();
    String expectedValue1 = "circle";
    field.populateExpression(expectedValue1);
    String actualValue1 = field.getStringValue();
    assertNull(actualValue1);
    FieldConfigMarker marker = new FieldConfigMarker(new FieldConfigCommonData(String.class, FieldIdEnum.ANGLE, "label", valueOnly), null, null, null);
    marker.createUI();
    List<ValueComboBoxData> dataList = new ArrayList<ValueComboBoxData>();
    dataList.add(new ValueComboBoxData("key 1", "Value 1", String.class));
    dataList.add(new ValueComboBoxData("key 2", "Value 2", Integer.class));
    dataList.add(new ValueComboBoxData("key 3", "Value 3", Boolean.class));
    List<ValueComboBoxDataGroup> combinedSymbolList = new ArrayList<ValueComboBoxDataGroup>();
    combinedSymbolList.add(new ValueComboBoxDataGroup(dataList));
    field.createUI();
    field.addField(marker);
    field.populate(null, combinedSymbolList);
    field.populateExpression(expectedValue1);
    actualValue1 = field.getStringValue();
    assertNull(actualValue1);
    String expectedValue2 = "key 2";
    field.populateExpression(expectedValue2);
    String actualValue2 = field.getStringValue();
    assertTrue(actualValue2.compareTo(field.getStringValue()) == 0);
    ValueComboBoxData actualValueObj2 = field.getEnumValue();
    assertNotNull(actualValueObj2.getKey());
    assertTrue(actualValueObj2.getKey().compareTo(expectedValue2) == 0);
    String expectedValue3 = "key 1";
    field.setTestValue(null, expectedValue3);
    String actualValue3 = field.getStringValue();
    assertTrue(expectedValue3.compareTo(actualValue3) == 0);
    String expectedValue4 = "key 3";
    field.populateField(expectedValue4);
    String actualValue4 = field.getStringValue();
    assertTrue(expectedValue4.compareTo(actualValue4) == 0);
    String expectedValue5 = "key 2";
    field.setSelectedItem(expectedValue5);
    String actualValue5 = field.getStringValue();
    assertTrue(expectedValue5.compareTo(actualValue5) == 0);
    ValueComboBoxData actualValueObj5 = field.getSelectedValueObj();
    assertNotNull(actualValueObj5.getKey());
    assertTrue(actualValueObj5.getKey().compareTo(expectedValue5) == 0);
    Class<?> actualValue6 = field.getSelectedValue();
    assertEquals(Integer.class, actualValue6);
}
Also used : ValueComboBoxDataGroup(com.sldeditor.ui.widgets.ValueComboBoxDataGroup) ArrayList(java.util.ArrayList) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData) FieldConfigMarker(com.sldeditor.ui.detail.config.symboltype.FieldConfigMarker) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigSymbolType(com.sldeditor.ui.detail.config.FieldConfigSymbolType) Test(org.junit.Test)

Example 3 with ValueComboBoxData

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

the class ColourRampConfigPanel method createTopPanel.

/**
 * Creates the top panel.
 */
private void createTopPanel() {
    JPanel topPanel = new JPanel();
    topPanel.setLayout(null);
    topPanel.setPreferredSize(new Dimension(BasePanel.FIELD_PANEL_WIDTH, BasePanel.WIDGET_HEIGHT));
    add(topPanel, BorderLayout.NORTH);
    List<ValueComboBoxData> dataList = new ArrayList<ValueComboBoxData>();
    if (colourRampMap != null) {
        for (ColourRampPanelInterface data : colourRampMap.keySet()) {
            Class<?> panel = null;
            if (data.getPanel() != null) {
                panel = data.getPanel().getClass();
            }
            String key = data.getTitle();
            ValueComboBoxData valueData = new ValueComboBoxData(key, data.getTitle(), panel);
            dataList.add(valueData);
            colourRampMapCache.put(key, data);
        }
    }
    typeComboBox = new ValueComboBox();
    typeComboBox.initialiseSingle(dataList);
    typeComboBox.setBounds(BasePanel.WIDGET_X_START, 0, BasePanel.WIDGET_EXTENDED_WIDTH, BasePanel.WIDGET_HEIGHT);
    topPanel.add(typeComboBox);
    typeComboBox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            typeChanged(typeComboBox.getSelectedValue());
        }
    });
}
Also used : JPanel(javax.swing.JPanel) ValueComboBox(com.sldeditor.ui.widgets.ValueComboBox) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) ArrayList(java.util.ArrayList) Dimension(java.awt.Dimension) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData)

Example 4 with ValueComboBoxData

use of com.sldeditor.ui.widgets.ValueComboBoxData 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 5 with ValueComboBoxData

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

the class ColourRampPanel method populateColourRamps.

/**
 * Populate colour ramps.
 *
 * @param reverseColours the reverse colours
 * @return the list
 */
private List<ValueComboBoxData> populateColourRamps(boolean reverseColours) {
    List<ValueComboBoxData> dataList = new ArrayList<ValueComboBoxData>();
    colourRampCache.clear();
    if (rampDataList != null) {
        for (ColourRamp data : rampDataList) {
            String key = data.toString();
            ValueComboBoxData valueData = new ValueComboBoxData(key, data.getImageIcon(reverseColours), getClass());
            dataList.add(valueData);
            colourRampCache.put(key, data);
        }
    }
    return dataList;
}
Also used : XMLTwoColourRamp(com.sldeditor.common.xml.ui.XMLTwoColourRamp) ColourRamp(com.sldeditor.colourramp.ColourRamp) ArrayList(java.util.ArrayList) ValueComboBoxData(com.sldeditor.ui.widgets.ValueComboBoxData)

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