use of com.sldeditor.ui.detail.config.FieldConfigColour in project sldeditor by robward-scisys.
the class FieldConfigTTFTest method testGetValue.
/**
* Test method for
* {@link com.sldeditor.ui.detail.config.symboltype.ttf.FieldConfigTTF#getValue(com.sldeditor.ui.detail.GraphicPanelFieldManager, org.opengis.filter.expression.Expression, boolean, boolean)}.
*/
@Test
public void testGetValue() {
GraphicPanelFieldManager fieldConfigManager = null;
Class<?> panelId = PointFillDetails.class;
fieldConfigManager = new GraphicPanelFieldManager(panelId);
FieldIdEnum colourFieldId = FieldIdEnum.FILL_COLOUR;
FieldConfigColour colourField = new FieldConfigColour(new FieldConfigCommonData(panelId, colourFieldId, "", false));
colourField.createUI();
String expectedColourValue = "#012345";
colourField.setTestValue(null, expectedColourValue);
fieldConfigManager.add(colourFieldId, colourField);
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);
boolean valueOnly = true;
FieldConfigTTF field = new FieldConfigTTF(new FieldConfigCommonData(String.class, FieldIdEnum.NAME, "test label", valueOnly), fillConfig, strokeConfig, null);
List<GraphicalSymbol> actualValue = field.getValue(null, null, false, false);
assertTrue(actualValue.isEmpty());
field.createUI();
actualValue = field.getValue(null, null, false, false);
assertTrue(actualValue.isEmpty());
actualValue = field.getValue(fieldConfigManager, null, false, false);
assertTrue(actualValue.size() == 1);
}
use of com.sldeditor.ui.detail.config.FieldConfigColour 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);
}
use of com.sldeditor.ui.detail.config.FieldConfigColour in project sldeditor by robward-scisys.
the class FieldConfigWKT method getValue.
/**
* Gets the value.
*
* @param fieldConfigManager the field config manager
* @param symbolType the symbol type
* @param fillEnabled the fill enabled
* @param strokeEnabled the stroke enabled
* @return the value
*/
@Override
public List<GraphicalSymbol> getValue(GraphicPanelFieldManager fieldConfigManager, Expression symbolType, boolean fillEnabled, boolean strokeEnabled) {
List<GraphicalSymbol> symbolList = new ArrayList<GraphicalSymbol>();
if (fieldConfigManager != null) {
Expression wellKnownName = null;
if (getConfigField() != null) {
wellKnownName = getConfigField().getExpression();
if (wellKnownName != null) {
Stroke stroke = null;
Fill fill = null;
// Stroke colour
FieldConfigBase field = null;
if (strokeEnabled) {
Expression expStrokeColour = null;
Expression expStrokeColourOpacity = null;
field = fieldConfigManager.get(this.strokeFieldConfig.getColour());
if (field != null) {
if (field instanceof FieldConfigColour) {
FieldConfigColour colourField = (FieldConfigColour) field;
expStrokeColour = colourField.getColourExpression();
}
}
// Stroke width
Expression strokeWidth = null;
field = fieldConfigManager.get(this.strokeFieldConfig.getWidth());
if (field != null) {
strokeWidth = field.getExpression();
}
// Opacity
field = fieldConfigManager.get(this.strokeFieldConfig.getOpacity());
if (field != null) {
expStrokeColourOpacity = field.getExpression();
}
stroke = getStyleFactory().createStroke(expStrokeColour, strokeWidth, expStrokeColourOpacity);
}
// Fill colour
if (fillEnabled) {
Expression expFillColour = null;
Expression expFillColourOpacity = null;
field = fieldConfigManager.get(this.fillFieldConfig.getColour());
if (field != null) {
if (field instanceof FieldConfigColour) {
FieldConfigColour colourField = (FieldConfigColour) field;
expFillColour = colourField.getColourExpression();
}
}
// Opacity
field = fieldConfigManager.get(this.fillFieldConfig.getOpacity());
if (field != null) {
expFillColourOpacity = field.getExpression();
}
fill = getStyleFactory().createFill(expFillColour, expFillColourOpacity);
}
Expression symbolSize = null;
field = fieldConfigManager.get(FieldIdEnum.STROKE_SYMBOL_SIZE);
if (field != null) {
symbolSize = field.getExpression();
}
Expression rotation = null;
Mark mark = getStyleFactory().createMark(wellKnownName, stroke, fill, symbolSize, rotation);
symbolList.add(mark);
}
}
}
return symbolList;
}
use of com.sldeditor.ui.detail.config.FieldConfigColour in project sldeditor by robward-scisys.
the class FieldConfigMarker method getFill.
/**
* Gets the fill.
*
* @param graphicFill the graphic fill
* @param fieldConfigManager the field config manager
* @return the fill
*/
@Override
public Fill getFill(GraphicFill graphicFill, GraphicPanelFieldManager fieldConfigManager) {
if (fieldConfigManager == null) {
return null;
}
Expression fillColour = null;
FieldConfigBase field = fieldConfigManager.get(fillFieldConfig.getColour());
if (field != null) {
if ((field instanceof FieldConfigColour) && field.isEnabled()) {
fillColour = ((FieldConfigColour) field).getColourExpression();
}
}
Expression fillColourOpacity = null;
field = fieldConfigManager.get(fillFieldConfig.getOpacity());
if (field != null) {
fillColourOpacity = field.getExpression();
}
GraphicFill _graphicFill = null;
Expression _fillColour = fillColour;
Expression _fillColourOpacity = fillColourOpacity;
if (graphicFill != null) {
List<GraphicalSymbol> symbolList = graphicFill.graphicalSymbols();
if ((symbolList != null) && (!symbolList.isEmpty())) {
GraphicalSymbol symbol = symbolList.get(0);
Mark mark = (Mark) symbol;
if (mark.getWellKnownName() != null) {
_graphicFill = graphicFill;
_fillColour = null;
_fillColourOpacity = null;
}
}
}
Fill fill = getStyleFactory().fill(_graphicFill, _fillColour, _fillColourOpacity);
return fill;
}
use of com.sldeditor.ui.detail.config.FieldConfigColour in project sldeditor by robward-scisys.
the class FilterManager method convertParameters.
/**
* Convert function parameters to ui components.
*
* @param panelId the panel id
* @param functionName the function name
* @return the list of ui components to display
*/
@Override
public List<GroupConfigInterface> convertParameters(Class<?> panelId, FunctionName functionName) {
List<GroupConfigInterface> groupConfigList = new ArrayList<GroupConfigInterface>();
if (functionName != null) {
GroupConfig groupConfig = new GroupConfig();
StringBuilder funcPrototypeStringBuilder = new StringBuilder();
funcPrototypeStringBuilder.append(functionName.getName());
funcPrototypeStringBuilder.append("(");
int argCount = functionName.getArgumentCount();
if (functionName.getArgumentCount() < 0) {
argCount *= -1;
}
for (int index = 0; index < argCount; index++) {
int argIndex = index;
if (argIndex >= functionName.getArguments().size()) {
argIndex = functionName.getArguments().size() - 1;
}
String label = functionName.getArgumentNames().get(argIndex);
Parameter<?> parameterType = functionName.getArguments().get(argIndex);
boolean valueOnly = false;
FieldIdEnum id = FieldIdEnum.UNKNOWN;
if (index > 0) {
funcPrototypeStringBuilder.append(", ");
}
Class<?> type = parameterType.getType();
funcPrototypeStringBuilder.append(type.getSimpleName());
FieldConfigBase fieldConfig = null;
FieldConfigCommonData commonData = new FieldConfigCommonData(panelId, id, label, valueOnly);
if (type == java.lang.Number.class) {
fieldConfig = new FieldConfigDouble(commonData);
} else if (type == Double.class) {
fieldConfig = new FieldConfigDouble(commonData);
} else if (type == Float.class) {
fieldConfig = new FieldConfigDouble(commonData);
} else if (type == Integer.class) {
fieldConfig = new FieldConfigInteger(commonData);
} else if (type == Long.class) {
fieldConfig = new FieldConfigInteger(commonData);
} else if (type == String.class) {
fieldConfig = new FieldConfigString(commonData, null);
} else if (type == Object.class) {
fieldConfig = new FieldConfigString(commonData, null);
} else if (type == Boolean.class) {
fieldConfig = new FieldConfigBoolean(commonData);
} else if (type == Geometry.class) {
fieldConfig = new FieldConfigGeometry(commonData, null);
} else if (type == org.opengis.geometry.Geometry.class) {
fieldConfig = new FieldConfigGeometry(commonData, null);
} else if (type == LineString.class) {
fieldConfig = new FieldConfigGeometry(commonData, null);
} else if (type == Date.class) {
fieldConfig = new FieldConfigDate(commonData);
} else if (type == Class.class) {
fieldConfig = new FieldConfigString(commonData, null);
} else if (type == Classifier.class) {
fieldConfig = new FieldConfigString(commonData, null);
} else if (type == Unit.class) {
fieldConfig = new FieldConfigMapUnits(commonData);
} else if (type == Comparable.class) {
fieldConfig = new FieldConfigString(commonData, null);
} else if (type == Color.class) {
fieldConfig = new FieldConfigColour(commonData);
} else {
ConsoleManager.getInstance().error(this, Localisation.getField(ExpressionPanelv2.class, "FilterManager.error1") + type.getName());
}
groupConfig.addField(fieldConfig);
}
funcPrototypeStringBuilder.append(")");
groupConfig.setLabel(funcPrototypeStringBuilder.toString());
groupConfigList.add(groupConfig);
}
return groupConfigList;
}
Aggregations