Search in sources :

Example 1 with FunctionField

use of com.sldeditor.filter.v2.function.FunctionField 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 2 with FunctionField

use of com.sldeditor.filter.v2.function.FunctionField in project sldeditor by robward-scisys.

the class FunctionFieldTest method testFunctionField.

/**
 * Test method for {@link
 * com.sldeditor.filter.v2.function.FunctionField#FunctionField(com.sldeditor.ui.attribute.SubPanelUpdatedInterface,
 * com.sldeditor.filter.v2.function.FunctionNameInterface)}.
 */
@Test
void testFunctionField() {
    assertEquals("FunctionField", FunctionField.getPanelName());
    TestFunctionField obj = new TestFunctionField(new SubPanelUpdatedInterface() {

        @Override
        public void updateSymbol() {
        }

        @Override
        public void parameterAdded() {
        }
    }, FunctionManager.getInstance());
    List<String> functionList = obj.getFunctionList();
    assertTrue(functionList.isEmpty());
    assertNull(obj.getSelectedItem());
    obj.setPanelEnabled(true);
    obj.setDataType(String.class);
    functionList = obj.getFunctionList();
    Expression expression = obj.getExpression();
    assertNull(expression);
    assertTrue(!functionList.isEmpty());
    // FunctionExpression
    String selectedFunction1 = "Collection_Unique";
    obj.setSelectedFunction(selectedFunction1);
    assertEquals(selectedFunction1, obj.getSelectedItem());
    Expression uniqueExpression = obj.getExpression();
    System.out.println(uniqueExpression.toString());
    obj.addButtonPressed(null);
    // ConcatenateFunction
    String selectedFunction2 = "Concatenate";
    obj.setSelectedFunction(selectedFunction2);
    assertEquals(selectedFunction2, obj.getSelectedItem());
    Expression concatenateExpression = obj.getExpression();
    obj.addButtonPressed(null);
    System.out.println(concatenateExpression.toString());
    // Function
    String selectedFunction3 = "Interpolate";
    obj.setSelectedFunction(selectedFunction3);
    assertEquals(selectedFunction3, obj.getSelectedItem());
    Expression interpolateExpression = obj.getExpression();
    System.out.println(interpolateExpression.toString());
    obj.addButtonPressed(null);
    // Use setFunction
    // FunctionExpression
    obj.setFunction(uniqueExpression, new ExpressionNode());
    assertEquals(selectedFunction1, obj.getSelectedItem());
    expression = obj.getExpression();
    System.out.println(expression.toString());
    obj.addButtonPressed(null);
    // ConcatenateFunction
    obj.setFunction(concatenateExpression, new ExpressionNode());
    assertEquals(selectedFunction2, obj.getSelectedItem());
    expression = obj.getExpression();
    obj.addButtonPressed(null);
    System.out.println(expression.toString());
    // Function
    obj.setFunction(interpolateExpression, new ExpressionNode());
    assertEquals(selectedFunction3, obj.getSelectedItem());
    expression = obj.getExpression();
    System.out.println(expression.toString());
    obj.addButtonPressed(null);
    // Raster
    String selectedFunction4 = "strConcat";
    obj.setIsRasterSymbol(true);
    obj.setDataType(String.class);
    functionList = obj.getFunctionList();
    obj.setSelectedFunction(selectedFunction4);
    assertEquals(selectedFunction4, obj.getSelectedItem());
    Expression rasterExpression = obj.getExpression();
    System.out.println(rasterExpression.toString());
    obj.addButtonPressed(null);
    // Function
    obj.setFunction(rasterExpression, new ExpressionNode());
    assertEquals(selectedFunction4, obj.getSelectedItem());
    expression = obj.getExpression();
    System.out.println(expression.toString());
    obj.addButtonPressed(null);
    // Try a different expression
    FilterFactory ff = CommonFactoryFinder.getFilterFactory();
    obj.setFunction(ff.literal(0), new ExpressionNode());
    obj.setFunction(ff.property("test"), new ExpressionNode());
}
Also used : SubPanelUpdatedInterface(com.sldeditor.ui.attribute.SubPanelUpdatedInterface) Expression(org.opengis.filter.expression.Expression) ExpressionNode(com.sldeditor.filter.v2.expression.ExpressionNode) FilterFactory(org.opengis.filter.FilterFactory) Test(org.junit.jupiter.api.Test)

Aggregations

SubPanelUpdatedInterface (com.sldeditor.ui.attribute.SubPanelUpdatedInterface)2 ExpressionNode (com.sldeditor.filter.v2.expression.ExpressionNode)1 FunctionField (com.sldeditor.filter.v2.function.FunctionField)1 Dimension (java.awt.Dimension)1 BoxLayout (javax.swing.BoxLayout)1 JPanel (javax.swing.JPanel)1 JRadioButton (javax.swing.JRadioButton)1 Test (org.junit.jupiter.api.Test)1 FilterFactory (org.opengis.filter.FilterFactory)1 Expression (org.opengis.filter.expression.Expression)1