Search in sources :

Example 1 with FieldConfigMapUnits

use of com.sldeditor.ui.detail.config.FieldConfigMapUnits in project sldeditor by robward-scisys.

the class InstantiateFields method addFieldMapUnits.

/**
 * Adds the field map units.
 *
 * @param fieldData the field data
 * @return the field config base
 */
private FieldConfigBase addFieldMapUnits(FieldData fieldData) {
    FieldConfigMapUnits valueConfig = new FieldConfigMapUnits(fieldData.getCommonData());
    String defaultValueObj = ConfigDefaultFactory.getString(fieldData.getDefaultValue());
    if (defaultValueObj != null) {
        valueConfig.setDefaultValue(defaultValueObj);
        defaultFieldMap.put(fieldData.getId(), defaultValueObj);
    }
    return valueConfig;
}
Also used : FieldConfigMapUnits(com.sldeditor.ui.detail.config.FieldConfigMapUnits) FieldConfigString(com.sldeditor.ui.detail.config.FieldConfigString) XMLFieldConfigString(com.sldeditor.common.xml.ui.XMLFieldConfigString)

Example 2 with FieldConfigMapUnits

use of com.sldeditor.ui.detail.config.FieldConfigMapUnits in project sldeditor by robward-scisys.

the class ReadMapUnits method read.

/**
 * Read configuration file and store the configuration in the object.
 *
 * @param panelId the panel id
 * @param resourceString the resource string
 * @param fieldConfigMapUnits the field config map units
 * @return true, if successful
 */
public boolean read(Class<?> panelId, String resourceString, FieldConfigMapUnits fieldConfigMapUnits) {
    MapUnits mapUnits = (MapUnits) ParseXML.parseUIFile(resourceString, SCHEMA_RESOURCE, MapUnits.class);
    if (mapUnits == null) {
        return false;
    }
    Class<?> localisationClass = ReadPanelConfig.class;
    if (mapUnits.getLocalisation() != null) {
        try {
            localisationClass = Class.forName(mapUnits.getLocalisation());
        } catch (ClassNotFoundException e) {
            ConsoleManager.getInstance().exception(ReadMapUnits.class, e);
        }
    }
    XMLFieldConfigData xmlFieldConfig = mapUnits.getFieldConfigEnum();
    if (xmlFieldConfig instanceof XMLFieldConfigEnum) {
        String defaultValue = xmlFieldConfig.getDefault();
        XMLFieldConfigEnumValueList valueList = ((XMLFieldConfigEnum) xmlFieldConfig).getValueList();
        List<SymbolTypeConfig> configList = readValueListConfig(localisationClass, panelId, valueList);
        fieldConfigMapUnits.addConfig(configList);
        String defaultValueObj = ConfigDefaultFactory.getString(defaultValue);
        if (defaultValueObj != null) {
            fieldConfigMapUnits.setDefaultValue(defaultValueObj);
        }
    }
    return true;
}
Also used : XMLFieldConfigEnum(com.sldeditor.common.xml.ui.XMLFieldConfigEnum) MapUnits(com.sldeditor.common.xml.ui.MapUnits) FieldConfigMapUnits(com.sldeditor.ui.detail.config.FieldConfigMapUnits) XMLFieldConfigData(com.sldeditor.common.xml.ui.XMLFieldConfigData) XMLFieldConfigEnumValueList(com.sldeditor.common.xml.ui.XMLFieldConfigEnumValueList) SymbolTypeConfig(com.sldeditor.ui.detail.config.symboltype.SymbolTypeConfig)

Example 3 with FieldConfigMapUnits

use of com.sldeditor.ui.detail.config.FieldConfigMapUnits 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)

Aggregations

FieldConfigMapUnits (com.sldeditor.ui.detail.config.FieldConfigMapUnits)3 FieldConfigString (com.sldeditor.ui.detail.config.FieldConfigString)2 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)1 MapUnits (com.sldeditor.common.xml.ui.MapUnits)1 XMLFieldConfigData (com.sldeditor.common.xml.ui.XMLFieldConfigData)1 XMLFieldConfigEnum (com.sldeditor.common.xml.ui.XMLFieldConfigEnum)1 XMLFieldConfigEnumValueList (com.sldeditor.common.xml.ui.XMLFieldConfigEnumValueList)1 XMLFieldConfigString (com.sldeditor.common.xml.ui.XMLFieldConfigString)1 Disjoint (com.sldeditor.filter.v2.function.geometry.Disjoint)1 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)1 FieldConfigBoolean (com.sldeditor.ui.detail.config.FieldConfigBoolean)1 FieldConfigColour (com.sldeditor.ui.detail.config.FieldConfigColour)1 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)1 FieldConfigDate (com.sldeditor.ui.detail.config.FieldConfigDate)1 FieldConfigDouble (com.sldeditor.ui.detail.config.FieldConfigDouble)1 FieldConfigGeometry (com.sldeditor.ui.detail.config.FieldConfigGeometry)1 FieldConfigInteger (com.sldeditor.ui.detail.config.FieldConfigInteger)1 GroupConfig (com.sldeditor.ui.detail.config.base.GroupConfig)1 GroupConfigInterface (com.sldeditor.ui.detail.config.base.GroupConfigInterface)1 SymbolTypeConfig (com.sldeditor.ui.detail.config.symboltype.SymbolTypeConfig)1