Java Code Examples for org.geotools.styling.Graphic#getSize()

The following examples show how to use org.geotools.styling.Graphic#getSize() . 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: SLDEditorBufferedImageLegendGraphicBuilder.java    From sldeditor with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Gets a numeric value for the given graphic
 *
 * @param feature sample to be used for evals
 * @param pointSymbolizer symbolizer
 * @param defaultSize size to use is none can be taken from the graphic
 */
private double getGraphicSize(Feature feature, Graphic graphic, int defaultSize) {
    if (graphic != null) {
        Expression sizeExp = graphic.getSize();
        if (sizeExp instanceof Literal) {
            Object size = sizeExp.evaluate(feature);
            if (size != null) {
                if (size instanceof Double) {
                    return (Double) size;
                }
                try {
                    return Double.parseDouble(size.toString());
                } catch (NumberFormatException e) {
                    return defaultSize;
                }
            }
        }
    }
    return defaultSize;
}