Java Code Examples for org.opengis.filter.expression.Expression#toString()

The following examples show how to use org.opengis.filter.expression.Expression#toString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ColourUtils.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Gets the colour as an int value, i.e remove '#' symbol and 
 * convert the remaining hex values as a decimal.
 * <p>Returns 0 if colourExpression is null.
 *
 * @param colourExpression the colour expression
 * @return the int colour value
 */
public static int getIntColour(Expression colourExpression)
{
    if(colourExpression == null)
    {
        return 0;
    }
    
    String tmpColour = colourExpression.toString();
    
    if(tmpColour.startsWith("#"))
    {
        tmpColour = colourExpression.toString().substring(1);
    }
    
    int colour = Integer.parseInt(tmpColour, 16);
    
    return colour;
}
 
Example 2
Source File: ExternalGraphicDetails.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
/** Update symbol. */
private void updateSymbol() {
    if (!Controller.getInstance().isPopulating()) {

        Expression expression = fieldConfigVisitor.getExpression(FieldIdEnum.EXTERNAL_GRAPHIC);
        if (!lastURLValue.equals(expression.toString())) {
            externalURL = parseString(expression.toString());
            lastURLValue = expression.toString();
            UndoManager.getInstance()
                    .addUndoEvent(
                            new UndoEvent(
                                    this,
                                    FieldIdEnum.EXTERNAL_GRAPHIC,
                                    oldValueObj,
                                    externalURL));
            oldValueObj = externalURL;
        }

        if (parentObj != null) {
            parentObj.externalGraphicValueUpdated();
        }
    }
}
 
Example 3
Source File: FieldConfigGeometryField.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Populate expression.
 *
 * @param objValue the obj value
 */
/*
 * (non-Javadoc)
 *
 * @see com.sldeditor.ui.detail.config.FieldConfigBase#populateExpression(java.lang.Object)
 */
@Override
public void populateExpression(Object objValue) {
    String propertyName = null;

    if (objValue instanceof PropertyExistsFunction) {
        Expression e = ((PropertyExistsFunction) objValue).getParameters().get(0);
        propertyName = e.toString();
    } else if (objValue instanceof AttributeExpressionImpl) {
        propertyName = ((AttributeExpressionImpl) objValue).getPropertyName();
    } else if (objValue instanceof LiteralExpressionImpl) {
        propertyName =
                AttributeUtils.extract((String) ((LiteralExpressionImpl) objValue).getValue());
    }

    populateField(propertyName);
}
 
Example 4
Source File: ColourMapData.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Sets the colour.
 *
 * @param colourExpression the new colour
 */
public void setColour(Expression colourExpression) {
    this.colourExpression = colourExpression;
    if (colourExpression instanceof LiteralExpressionImpl) {
        colourString = ((LiteralExpressionImpl) colourExpression).toString();

        if (ColourUtils.validColourString(colourString)) {
            this.colour = ColourUtils.toColour(colourString);
        } else {
            this.colour = Color.white;
        }
    } else if (colourExpression instanceof Expression) {
        colourString = colourExpression.toString();
        this.colour = Color.white;
    }
}
 
Example 5
Source File: ExpressionSubPanel.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Populate expression.
 *
 * @param expression the expression
 */
public void populateExpression(Expression expression) {
    this.storedExpression = expression;

    String expressionString = "";

    if (expression != null) {
        expressionString = expression.toString();
    }
    expressionTextField.setText(expressionString);
}
 
Example 6
Source File: ArrowUtils.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Gets the expression as a string, if a null expression is supplied return the default value.
 *
 * @param expression the expression
 * @param attribute the attribute
 * @return the string
 */
private static String getExpression(Expression expression, String attribute) {
    String string;
    if (expression != null) {
        string = expression.toString();
    } else {
        initialise();
        string = String.valueOf(defaultMap.get(attribute));
    }
    return string;
}
 
Example 7
Source File: ColourUtils.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Gets the colour as an int value, i.e remove '#' symbol and convert the remaining hex values
 * as a decimal.
 *
 * <p>Returns 0 if colourExpression is null.
 *
 * @param colourExpression the colour expression
 * @return the int colour value
 */
public static int getIntColour(Expression colourExpression) {
    if (colourExpression == null) {
        return 0;
    }

    String tmpColour = colourExpression.toString();

    if (tmpColour.startsWith("#")) {
        tmpColour = colourExpression.toString().substring(1);
    }

    return Integer.parseInt(tmpColour, 16);
}
 
Example 8
Source File: FunctionExpressionUtils.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
/**
 * To string.
 *
 * @param expression the expression
 * @return the string
 */
public static String toString(Expression expression) {
    if (expression instanceof Collection_UniqueFunction) {
        return missingToString((Collection_UniqueFunction) expression);
    } else {
        return expression.toString();
    }
}
 
Example 9
Source File: FunctionInterfaceUtils.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
/**
 * To string.
 *
 * @param expression the expression
 * @return the string
 */
public static String toString(Expression expression) {
    if (expression instanceof RecodeFunction) {
        return missingToString((RecodeFunction) expression);
    } else if (expression instanceof StringTemplateFunction) {
        return missingToString((StringTemplateFunction) expression);
    } else if (expression instanceof ConstrastFunction) {
        return missingToString((ConstrastFunction) expression);
    } else if (expression instanceof LightenFunction) {
        return missingToString((LightenFunction) expression);
    } else if (expression instanceof JenksNaturalBreaksFunction) {
        return missingToString((JenksNaturalBreaksFunction) expression);
    } else if (expression instanceof CategorizeFunction) {
        return missingToString((CategorizeFunction) expression);
    } else if (expression instanceof UniqueIntervalFunction) {
        return missingToString((UniqueIntervalFunction) expression);
    } else if (expression instanceof GrayscaleFunction) {
        return missingToString((GrayscaleFunction) expression);
    } else if (expression instanceof QuantileFunction) {
        return missingToString((QuantileFunction) expression);
    } else if (expression instanceof ModuloFunction) {
        return missingToString((ModuloFunction) expression);
    } else if (expression instanceof StandardDeviationFunction) {
        return missingToString((StandardDeviationFunction) expression);
    } else if (expression instanceof EqualIntervalFunction) {
        return missingToString((EqualIntervalFunction) expression);
    } else {
        return expression.toString();
    }
}
 
Example 10
Source File: FunctionTableModel.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Gets the value at.
 *
 * @param rowIndex the row index
 * @param columnIndex the column index
 * @return the value at
 */
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
    ProcessFunctionParameterValue value = valueList.get(rowIndex);

    switch (columnIndex) {
        case COL_PARAMETER:
            return value.getName();
        case COL_TYPE:
            return value.getDataType();
        case COL_OPTIONAL:
            if (value.isOptional()) {
                return value.isIncluded();
            }
            break;
        case COL_VALUE:
            if (value.getObjectValue() != null) {
                Expression expression = value.getObjectValue().getExpression();
                if (expression != null) {
                    return expression.toString();
                }
            }
            break;
        default:
            break;
    }
    return null;
}
 
Example 11
Source File: FieldConfigTransformationTest.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Test method for {@link
 * com.sldeditor.ui.detail.config.transform.FieldConfigTransformation#populateExpression(java.lang.Object)}.
 * Test method for {@link
 * com.sldeditor.ui.detail.config.transform.FieldConfigTransformation#generateExpression()}.
 * Test method for {@link
 * com.sldeditor.ui.detail.config.transform.FieldConfigTransformation#getProcessFunction()}.
 */
@Test
public void testGenerateExpression() {
    boolean valueOnly = true;

    TestFieldConfigTransformation field =
            new TestFieldConfigTransformation(
                    new FieldConfigCommonData(
                            String.class, FieldIdEnum.NAME, "test label", valueOnly, false),
                    "edit",
                    "clear");
    Expression actualExpression = field.callGenerateExpression();
    assertNull(actualExpression);

    field.createUI();
    String expectedValue1 = "test string value";
    field.setTestValue(FieldIdEnum.UNKNOWN, expectedValue1);
    actualExpression = field.callGenerateExpression();
    assertNull(actualExpression);

    // Strings are ignored when calling populateExpression
    String expectedValue2 = "test string value as expression";
    field.populateExpression(expectedValue2);
    actualExpression = field.callGenerateExpression();
    assertNull(actualExpression);

    // Create process function
    ProcessFunction processFunction = createProcessFunction();
    field.populateExpression((ProcessFunction) null);
    field.populateExpression(processFunction);

    actualExpression = field.callGenerateExpression();
    String expectedValue3 = ParameterFunctionUtils.getString(processFunction);
    String string = actualExpression.toString();
    assertTrue(expectedValue3.compareTo(string) != 0);
    assertEquals(processFunction, field.getProcessFunction());
}
 
Example 12
Source File: FieldConfigMarker.java    From sldeditor with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 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) {
    if ((symbolType == null) || (fieldConfigManager == null)) {
        return null;
    }

    Expression symbolTypeExpression = null;

    String symbolTypeName = symbolType.toString();
    if (symbolTypeName.compareTo(SOLID_SYMBOL_KEY) != 0) {
        symbolTypeExpression = symbolType;
    }

    Fill fill = null;
    Stroke stroke = null;

    if (symbolTypeName.startsWith(GEOSERVER_MARKER_PREFIX)) {
        stroke = getGeoServerStrokeValue(fieldConfigManager);
    } else {
        Expression fillColour = null;

        FieldConfigBase field = fieldConfigManager.get(fillFieldConfig.getColour());
        if (field != null) {
            fillColour = ((FieldConfigColour) field).getColourExpression();
        }

        Expression fillColourOpacity = null;
        field = fieldConfigManager.get(fillFieldConfig.getOpacity());
        if (field != null) {
            fillColourOpacity = field.getExpression();
        }

        if (fillEnabled) {
            fill = getStyleFactory().fill(null, fillColour, fillColourOpacity);
        }

        if (strokeEnabled) {
            Expression strokeColour = null;
            field = fieldConfigManager.get(strokeFieldConfig.getColour());
            if (field != null) {
                strokeColour = ((FieldConfigColour) field).getColourExpression();
            }

            Expression strokeColourOpacity = null;
            field = fieldConfigManager.get(strokeFieldConfig.getOpacity());
            if (field != null) {
                strokeColourOpacity = field.getExpression();
            }

            Expression strokeWidth = null;
            field = fieldConfigManager.get(strokeFieldConfig.getWidth());
            if (field != null) {
                strokeWidth = field.getExpression();
            }

            stroke =
                    getStyleFactory()
                            .createStroke(strokeColour, strokeWidth, strokeColourOpacity);
        }
    }

    Mark markerSymbol = getStyleFactory().mark(symbolTypeExpression, fill, stroke);

    return SelectedSymbol.getInstance().getSymbolList(markerSymbol);
}
 
Example 13
Source File: FieldConfigTTF.java    From sldeditor with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Sets the value.
 *
 * @param symbolizerType the symbolizer type
 * @param fieldConfigManager the field config manager
 * @param multiOptionPanel the multi option panel
 * @param graphic the graphic
 * @param symbol the symbol
 */
@Override
public void setValue(
        Class<?> symbolizerType,
        GraphicPanelFieldManager fieldConfigManager,
        FieldConfigSymbolType multiOptionPanel,
        Graphic graphic,
        GraphicalSymbol symbol) {
    if (symbol == null) {
        return;
    }

    if (fieldConfigManager == null) {
        return;
    }

    MarkImpl markerSymbol = (MarkImpl) symbol;

    FillImpl fill = markerSymbol.getFill();

    Expression expFillColour = null;
    Expression expFillOpacity = null;

    if (fill != null) {
        expFillColour = fill.getColor();
        if (!isOverallOpacity(symbolizerType)) {
            expFillOpacity = fill.getOpacity();
        }
    }

    FieldConfigBase field = fieldConfigManager.get(fillFieldConfig.getColour());
    if (field != null) {
        field.populate(expFillColour);
    }

    // Opacity
    if (isOverallOpacity(symbolizerType)) {
        FieldConfigBase opacity = fieldConfigManager.get(FieldIdEnum.OVERALL_OPACITY);
        if (opacity != null) {
            opacity.populate(graphic.getOpacity());
        }
    }

    field = fieldConfigManager.get(fillFieldConfig.getOpacity());
    if (field != null) {
        field.populate(expFillOpacity);
    }

    Class<?> panelId = getCommonData().getPanelId();
    GroupConfigInterface fillGroup =
            fieldConfigManager.getGroup(panelId, fillFieldConfig.getGroup());

    if (fillGroup != null) {
        fillGroup.enable(expFillColour != null);
    }

    if (ttfPanel != null) {
        Expression wellKnownNameExpression = markerSymbol.getWellKnownName();
        String wellKnownName = null;
        if (wellKnownNameExpression != null) {
            wellKnownName = wellKnownNameExpression.toString();
        }
        ttfPanel.populateExpression(wellKnownName);
    }

    if (multiOptionPanel != null) {
        multiOptionPanel.setSelectedItem(TTF_SYMBOL_KEY);
    }
}
 
Example 14
Source File: ExtractGeometryField.java    From sldeditor with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Check if geometry field name is valid.
 *
 * @param geometryField the geometry field expression
 * @return true, if valid
 */
private static boolean validGeometryFieldName(Expression geometryField) {
    return ((geometryField != null)
            && (geometryField.toString() != null)
            && !geometryField.toString().trim().isEmpty());
}