Search in sources :

Example 6 with ExpressionPanelv2

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);
}
Also used : FunctionField(com.sldeditor.filter.v2.function.FunctionField) JPanel(javax.swing.JPanel) JRadioButton(javax.swing.JRadioButton) SubPanelUpdatedInterface(com.sldeditor.ui.attribute.SubPanelUpdatedInterface) BoxLayout(javax.swing.BoxLayout) Dimension(java.awt.Dimension)

Example 7 with ExpressionPanelv2

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());
}
Also used : JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) SubPanelUpdatedInterface(com.sldeditor.ui.attribute.SubPanelUpdatedInterface) BorderLayout(java.awt.BorderLayout) JLabel(javax.swing.JLabel) FilterField(com.sldeditor.filter.v2.function.FilterField)

Example 8 with ExpressionPanelv2

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;
}
Also used : FieldConfigDate(com.sldeditor.ui.detail.config.FieldConfigDate) FieldConfigGeometry(com.sldeditor.ui.detail.config.FieldConfigGeometry) FieldConfigDouble(com.sldeditor.ui.detail.config.FieldConfigDouble) ArrayList(java.util.ArrayList) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) LineString(org.locationtech.jts.geom.LineString) Classifier(org.geotools.filter.function.Classifier) RangedClassifier(org.geotools.filter.function.RangedClassifier) FieldConfigMapUnits(com.sldeditor.ui.detail.config.FieldConfigMapUnits) GroupConfig(com.sldeditor.ui.detail.config.base.GroupConfig) FieldConfigColour(com.sldeditor.ui.detail.config.FieldConfigColour) GroupConfigInterface(com.sldeditor.ui.detail.config.base.GroupConfigInterface) FieldConfigBoolean(com.sldeditor.ui.detail.config.FieldConfigBoolean) FieldConfigInteger(com.sldeditor.ui.detail.config.FieldConfigInteger) FieldConfigBase(com.sldeditor.ui.detail.config.FieldConfigBase) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) FieldConfigBoolean(com.sldeditor.ui.detail.config.FieldConfigBoolean) FieldConfigDouble(com.sldeditor.ui.detail.config.FieldConfigDouble) Point(org.locationtech.jts.geom.Point) Disjoint(com.sldeditor.filter.v2.function.geometry.Disjoint) MultiPoint(org.locationtech.jts.geom.MultiPoint) Date(java.util.Date) FieldConfigDate(com.sldeditor.ui.detail.config.FieldConfigDate) FieldConfigInteger(com.sldeditor.ui.detail.config.FieldConfigInteger) Geometry(org.locationtech.jts.geom.Geometry) FieldConfigGeometry(com.sldeditor.ui.detail.config.FieldConfigGeometry) FieldConfigCommonData(com.sldeditor.ui.detail.config.FieldConfigCommonData) FieldIdEnum(com.sldeditor.common.xml.ui.FieldIdEnum)

Example 9 with ExpressionPanelv2

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);
}
Also used : ExpressionPanelv2(com.sldeditor.filter.v2.expression.ExpressionPanelv2) ExpressionNode(com.sldeditor.filter.v2.expression.ExpressionNode) Test(org.junit.jupiter.api.Test)

Example 10 with ExpressionPanelv2

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());
}
Also used : ExpressionPanelv2(com.sldeditor.filter.v2.expression.ExpressionPanelv2) ExpressionNode(com.sldeditor.filter.v2.expression.ExpressionNode) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)8 ExpressionPanelv2 (com.sldeditor.filter.v2.expression.ExpressionPanelv2)7 ExpressionNode (com.sldeditor.filter.v2.expression.ExpressionNode)4 FilterNode (com.sldeditor.filter.v2.expression.FilterNode)3 SubPanelUpdatedInterface (com.sldeditor.ui.attribute.SubPanelUpdatedInterface)2 FieldConfigInteger (com.sldeditor.ui.detail.config.FieldConfigInteger)2 FieldConfigString (com.sldeditor.ui.detail.config.FieldConfigString)2 ArrayList (java.util.ArrayList)2 JPanel (javax.swing.JPanel)2 FilterFactory (org.opengis.filter.FilterFactory)2 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)1 FilterConfigInterface (com.sldeditor.filter.v2.function.FilterConfigInterface)1 FilterField (com.sldeditor.filter.v2.function.FilterField)1 FunctionField (com.sldeditor.filter.v2.function.FunctionField)1 Disjoint (com.sldeditor.filter.v2.function.geometry.Disjoint)1 Overlaps (com.sldeditor.filter.v2.function.geometry.Overlaps)1 And (com.sldeditor.filter.v2.function.logic.And)1 IsLike (com.sldeditor.filter.v2.function.misc.IsLike)1 IsNull (com.sldeditor.filter.v2.function.misc.IsNull)1 IsBetween (com.sldeditor.filter.v2.function.property.IsBetween)1