Search in sources :

Example 11 with FeatureTypeConstraint

use of org.geotools.styling.FeatureTypeConstraint in project sldeditor by robward-scisys.

the class FieldConfigFeatureTypeConstraint method extentUpdated.

@Override
public void extentUpdated() {
    if (filterTable != null) {
        FeatureTypeConstraint ftc = filterModel.getFeatureTypeConstraint(filterTable.getSelectedRow());
        if (ftc != null) {
            extentModel.updateExtent(ftc);
        }
        featureTypeConstraintUpdated();
    }
}
Also used : FeatureTypeConstraint(org.geotools.styling.FeatureTypeConstraint)

Example 12 with FeatureTypeConstraint

use of org.geotools.styling.FeatureTypeConstraint in project sldeditor by robward-scisys.

the class FieldConfigFeatureTypeConstraint method createFilterTable.

/**
 * Creates the filter table.
 *
 * @param xPos the x pos
 * @param maxNoOfRows the max no of rows
 * @param fieldPanel the field panel
 */
private void createFilterTable(int xPos, int maxNoOfRows, FieldPanel fieldPanel) {
    filterTable = new JTable(filterModel);
    filterTable.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    filterTable.setBounds(xPos, 0, BasePanel.FIELD_PANEL_WIDTH, getRowY(maxNoOfRows - 2));
    filterTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                FeatureTypeConstraint ftc = filterModel.getFeatureTypeConstraint(filterTable.getSelectedRow());
                if (ftc != null) {
                    extentModel.populate(ftc.getExtents());
                    addExtentButton.setEnabled(true);
                    removeFTCButton.setEnabled(true);
                    int[] selectedColumns = filterTable.getSelectedColumns();
                    if (filterModel.isFilterColumn(selectedColumns)) {
                        FilterPanelInterface filterPanel = ExpressionPanelFactory.getFilterPanel(null);
                        String panelTitle = Localisation.getString(FieldConfigBase.class, "FieldConfigFeatureTypeConstraint.filterPanel");
                        filterPanel.configure(panelTitle, Object.class, SelectedSymbol.getInstance().isRasterSymbol());
                        filterPanel.populate(ftc.getFilter());
                        if (filterPanel.showDialog()) {
                            ftc.setFilter(filterPanel.getFilter());
                            filterModel.fireTableDataChanged();
                            featureTypeConstraintUpdated();
                        }
                    }
                }
            }
        }
    });
    JScrollPane scrollPanel = new JScrollPane(filterTable);
    scrollPanel.setBounds(xPos, BasePanel.WIDGET_HEIGHT, BasePanel.FIELD_PANEL_WIDTH, BasePanel.WIDGET_HEIGHT * (maxNoOfRows - 2));
    fieldPanel.add(scrollPanel);
    int buttonY = getRowY(maxNoOfRows - 1);
    // 
    // Add button
    // 
    addFTCButton = new JButton(Localisation.getString(FieldConfigBase.class, "FieldConfigFeatureTypeConstraint.add"));
    addFTCButton.setBounds(xPos + BasePanel.WIDGET_X_START, buttonY, BasePanel.WIDGET_BUTTON_WIDTH, BasePanel.WIDGET_HEIGHT);
    addFTCButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            addEntry();
        }
    });
    fieldPanel.add(addFTCButton);
    // 
    // Remove button
    // 
    removeFTCButton = new JButton(Localisation.getString(FieldConfigBase.class, "FieldConfigFeatureTypeConstraint.remove"));
    removeFTCButton.setBounds(xPos + BasePanel.WIDGET_BUTTON_WIDTH + BasePanel.WIDGET_X_START + 10, buttonY, BasePanel.WIDGET_BUTTON_WIDTH, BasePanel.WIDGET_HEIGHT);
    removeFTCButton.setEnabled(false);
    removeFTCButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            removeEntry();
        }
    });
    fieldPanel.add(removeFTCButton);
}
Also used : JScrollPane(javax.swing.JScrollPane) FilterPanelInterface(com.sldeditor.filter.FilterPanelInterface) FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) ActionEvent(java.awt.event.ActionEvent) ListSelectionEvent(javax.swing.event.ListSelectionEvent) JButton(javax.swing.JButton) FeatureTypeConstraint(org.geotools.styling.FeatureTypeConstraint) ListSelectionListener(javax.swing.event.ListSelectionListener) FeatureTypeConstraint(org.geotools.styling.FeatureTypeConstraint) ActionListener(java.awt.event.ActionListener) JTable(javax.swing.JTable)

Example 13 with FeatureTypeConstraint

use of org.geotools.styling.FeatureTypeConstraint in project sldeditor by robward-scisys.

the class FieldConfigFeatureTypeConstraint method featureTypeConstraintUpdated.

/*
     * (non-Javadoc)
     * 
     * @see com.sldeditor.ui.detail.config.featuretypeconstraint.FeatureTypeConstraintModelUpdateInterface#featureTypeConstraintUpdated()
     */
@Override
public void featureTypeConstraintUpdated() {
    List<FeatureTypeConstraint> ftc = filterModel.getFeatureTypeConstraint();
    UndoManager.getInstance().addUndoEvent(new UndoEvent(this, getFieldId(), oldValueObj, ftc));
    oldValueObj = ftc;
    valueUpdated();
}
Also used : UndoEvent(com.sldeditor.common.undo.UndoEvent) FeatureTypeConstraint(org.geotools.styling.FeatureTypeConstraint)

Example 14 with FeatureTypeConstraint

use of org.geotools.styling.FeatureTypeConstraint in project sldeditor by robward-scisys.

the class FieldConfigPopulationTest method testFieldConfigPopulation.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigPopulation#FieldConfigPopulation(com.sldeditor.ui.detail.GraphicPanelFieldManager)}.
 */
@Test
public void testFieldConfigPopulation() {
    FieldIdEnum fieldId = FieldIdEnum.UNKNOWN;
    FieldConfigPopulation obj = new FieldConfigPopulation(null);
    obj.populateBooleanField(fieldId, Boolean.TRUE);
    obj.populateComboBoxField(fieldId, "");
    obj.populateColourField(fieldId, null);
    obj.populateColourMapField(FieldIdEnum.ANCHOR_POINT_V, (ColorMap) null);
    obj.populateFontField(FieldIdEnum.ANCHOR_POINT_V, (Font) null);
    obj.populateTextField(fieldId, (String) null);
    obj.populateDoubleField(fieldId, (Double) null);
    obj.populateIntegerField(fieldId, (Integer) null);
    obj.populateField(fieldId, (Expression) null);
    obj.populateUserLayer(fieldId, (UserLayer) null);
    obj.populateFieldTypeConstraint(fieldId, (List<FeatureTypeConstraint>) null);
    assertNull(obj.getExpression(fieldId));
    assertFalse(obj.getBoolean(fieldId));
    assertEquals(0, obj.getInteger(fieldId));
    assertTrue(Math.abs(obj.getDouble(fieldId) - 0.0) < 0.001);
    assertTrue(obj.getText(fieldId).compareTo("") == 0);
    assertNull(obj.getComboBox(fieldId));
    assertNull(obj.getColourMap(fieldId));
    assertNull(obj.getFieldConfig(fieldId));
    assertNull(obj.getFeatureTypeConstraint(fieldId));
}
Also used : FieldConfigPopulation(com.sldeditor.ui.detail.config.FieldConfigPopulation) FeatureTypeConstraint(org.geotools.styling.FeatureTypeConstraint) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) Test(org.junit.Test)

Example 15 with FeatureTypeConstraint

use of org.geotools.styling.FeatureTypeConstraint in project sldeditor by robward-scisys.

the class FieldConfigBaseTest method testPopulateFieldString.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.FieldConfigBase#populateField(java.lang.String)}.
 */
@Test
public void testPopulateFieldString() {
    FieldIdEnum expectedFieldId = FieldIdEnum.NAME;
    String expectedLabel = "test label";
    TestFieldConfigBase field = new TestFieldConfigBase(new FieldConfigCommonData(String.class, expectedFieldId, expectedLabel, false));
    field.populateField("");
    field.setTestValue(expectedFieldId, "");
    field.populateField(42);
    field.setTestValue(expectedFieldId, 42);
    assertEquals(0, field.getIntValue());
    field.populateField(3.142);
    field.setTestValue(expectedFieldId, 3.142);
    assertTrue(Math.abs(field.getDoubleValue()) < 0.0001);
    field.populateField(new Date());
    field.populateField((ReferencedEnvelope) null);
    field.setTestValue(expectedFieldId, (ReferencedEnvelope) null);
    field.populateField((Id) null);
    field.populateField((TimePeriod) null);
    field.populateField((ProcessFunction) null);
    assertNull(field.getProcessFunction());
    field.populateField(true);
    field.setTestValue(expectedFieldId, true);
    assertEquals(false, field.getBooleanValue());
    field.populateField((ColorMap) null);
    field.setTestValue(expectedFieldId, (ColorMap) null);
    assertNull(field.getColourMap());
    field.populateField((List<FeatureTypeConstraint>) null);
    field.setTestValue(expectedFieldId, (List<FeatureTypeConstraint>) null);
    assertNull(field.getFeatureTypeConstraint());
    field.populateField((Font) null);
    assertNull(field.getFont());
    field.setTestValue(expectedFieldId, (Expression) null);
    assertNull(field.getEnumValue());
}
Also used : FeatureTypeConstraint(org.geotools.styling.FeatureTypeConstraint) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum) Date(java.util.Date) Test(org.junit.Test)

Aggregations

FeatureTypeConstraint (org.geotools.styling.FeatureTypeConstraint)18 Test (org.junit.Test)6 StyleFactoryImpl (org.geotools.styling.StyleFactoryImpl)4 StyledLayer (org.geotools.styling.StyledLayer)4 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)3 Extent (org.geotools.styling.Extent)3 Style (org.geotools.styling.Style)3 UndoEvent (com.sldeditor.common.undo.UndoEvent)2 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)2 GroupConfigInterface (com.sldeditor.ui.detail.config.base.GroupConfigInterface)2 MultiOptionGroup (com.sldeditor.ui.detail.config.base.MultiOptionGroup)2 FieldConfigFeatureTypeConstraint (com.sldeditor.ui.detail.config.featuretypeconstraint.FieldConfigFeatureTypeConstraint)2 Geometry (com.vividsolutions.jts.geom.Geometry)2 NamedLayerImpl (org.geotools.styling.NamedLayerImpl)2 RemoteOWS (org.geotools.styling.RemoteOWS)2 UserLayer (org.geotools.styling.UserLayer)2 UserLayerImpl (org.geotools.styling.UserLayerImpl)2 DataSourceInterface (com.sldeditor.datasource.DataSourceInterface)1 FilterPanelInterface (com.sldeditor.filter.FilterPanelInterface)1 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)1