use of com.sldeditor.filter.v2.expression.ExpressionPanelv2 in project sldeditor by robward-scisys.
the class ExpressionSubPanel method setUpFunctionPanel.
/**
* Sets the up function panel.
*/
protected void setUpFunctionPanel() {
JPanel panelFunction = new JPanel();
panelFunction.setBorder(null);
panelFunction.setLayout(new BoxLayout(panelFunction, BoxLayout.X_AXIS));
rdbtnFunction = new JRadioButton(Localisation.getString(ExpressionPanelv2.class, "ExpressionPanelv2.function"));
rdbtnFunction.setMinimumSize(new Dimension(100, 20));
rdbtnFunction.setPreferredSize(new Dimension(100, 20));
panelFunction.add(rdbtnFunction);
rdbtnFunction.setActionCommand(FUNCTION);
buttonGroup.add(rdbtnFunction);
functionPanel = new FunctionField(new SubPanelUpdatedInterface() {
@Override
public void updateSymbol() {
buttonGroup.setSelected(rdbtnFunction.getModel(), true);
updateButtonState(true);
}
@Override
public void parameterAdded() {
if (parentObj != null) {
parentObj.dataApplied();
}
}
}, FunctionManager.getInstance());
panelFunction.add(functionPanel);
box.add(panelFunction);
}
use of com.sldeditor.filter.v2.expression.ExpressionPanelv2 in project sldeditor by robward-scisys.
the class FilterSubPanel method createUI.
/**
* Creates the ui.
*/
private void createUI() {
setLayout(new BorderLayout());
box = Box.createVerticalBox();
add(box, BorderLayout.CENTER);
//
// Filter panel
//
JPanel panelFilter = new JPanel(new FlowLayout());
JLabel lblFilter = new JLabel(Localisation.getString(ExpressionPanelv2.class, "ExpressionPanelv2.filter"));
panelFilter.add(lblFilter);
filterPanel = new FilterField(new SubPanelUpdatedInterface() {
@Override
public void updateSymbol() {
updateButtonState(true);
}
@Override
public void parameterAdded() {
// Do nothing
}
}, FilterManager.getInstance());
panelFilter.add(filterPanel);
box.add(panelFilter);
box.add(createAddRemoveFilterPanel());
box.add(createApplyRevertPanel());
}
use of com.sldeditor.filter.v2.expression.ExpressionPanelv2 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<>();
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, true);
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;
}
use of com.sldeditor.filter.v2.expression.ExpressionPanelv2 in project sldeditor by robward-scisys.
the class ExpressionNodeTest method testSetName.
/**
* Test method for {@link
* com.sldeditor.filter.v2.expression.ExpressionNode#setName(java.lang.String)}.
*/
@Test
public void testSetName() {
String expectedName = "test";
ExpressionNode node = new ExpressionNode();
assertTrue(node.toString().compareTo(Localisation.getString(ExpressionPanelv2.class, "ExpressionPanelv2.expressionNotSet")) == 0);
node.setName(expectedName);
assertTrue(node.toString().compareTo(expectedName + " : " + Localisation.getString(ExpressionPanelv2.class, "ExpressionPanelv2.expressionNotSet")) == 0);
}
use of com.sldeditor.filter.v2.expression.ExpressionPanelv2 in project sldeditor by robward-scisys.
the class ExpressionNodeTest method testSetExpressionType.
/**
* Test method for {@link
* com.sldeditor.filter.v2.expression.ExpressionNode#setExpressionType(com.sldeditor.filter.v2.expression.ExpressionTypeEnum)}.
* Test method for {@link
* com.sldeditor.filter.v2.expression.ExpressionNode#getExpressionType()}.
*/
@Test
public void testSetExpressionType() {
ExpressionNode node = new ExpressionNode();
assertTrue(node.toString().compareTo(Localisation.getString(ExpressionPanelv2.class, "ExpressionPanelv2.expressionNotSet")) == 0);
node.setExpressionType(ExpressionTypeEnum.LITERAL);
assertEquals(ExpressionTypeEnum.LITERAL, node.getExpressionType());
assertTrue(node.toString().compareTo(Localisation.getString(ExpressionPanelv2.class, "ExpressionPanelv2.literalNotSet")) == 0);
node.setExpressionType(ExpressionTypeEnum.PROPERTY);
assertEquals(ExpressionTypeEnum.PROPERTY, node.getExpressionType());
assertTrue(node.toString().compareTo(Localisation.getString(ExpressionPanelv2.class, "ExpressionPanelv2.propertyNotSet")) == 0);
assertNull(node.getExpression());
}
Aggregations