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();
}
}
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);
}
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();
}
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));
}
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());
}
Aggregations