Search in sources :

Example 6 with DataSourceAttributeData

use of com.sldeditor.datasource.attribute.DataSourceAttributeData in project sldeditor by robward-scisys.

the class DataSourceAttributeModel method addNewField.

/**
 * Adds the new field.
 */
public void addNewField() {
    int index = valueMap.size();
    String name = String.format("%s_%d", DEFAULT_NEW_FIELD_NAME, index);
    Class<?> fieldType = DEFAULT_NEW_FIELD_TYPE;
    Object value = CreateSampleData.getFieldTypeValue(index, name, fieldType, null);
    DataSourceAttributeData newField = new DataSourceAttributeData(name, fieldType, value);
    valueList.add(newField);
    valueMap.put(newField.getName(), newField);
}
Also used : DataSourceAttributeData(com.sldeditor.datasource.attribute.DataSourceAttributeData) LineString(com.vividsolutions.jts.geom.LineString) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) Point(com.vividsolutions.jts.geom.Point) MultiPoint(com.vividsolutions.jts.geom.MultiPoint)

Example 7 with DataSourceAttributeData

use of com.sldeditor.datasource.attribute.DataSourceAttributeData in project sldeditor by robward-scisys.

the class DataSourceAttributeModel method retrieveData.

/**
 * Retrieve data.
 *
 * @return the map
 */
public List<DataSourceAttributeData> retrieveData() {
    List<DataSourceAttributeData> attributeList = new ArrayList<DataSourceAttributeData>();
    for (int row = 0; row < this.getRowCount(); row++) {
        String name = (String) this.getValueAt(row, FIELD_COLUMN_ID);
        Object objValue = this.getValueAt(row, VALUE_COLUMN_ID);
        DataSourceAttributeData existingData = valueMap.get(name);
        if (existingData != null) {
            DataSourceAttributeData data = new DataSourceAttributeData(name, existingData.getType(), objValue);
            attributeList.add(data);
        }
    }
    return attributeList;
}
Also used : DataSourceAttributeData(com.sldeditor.datasource.attribute.DataSourceAttributeData) ArrayList(java.util.ArrayList) LineString(com.vividsolutions.jts.geom.LineString) MultiLineString(com.vividsolutions.jts.geom.MultiLineString) Point(com.vividsolutions.jts.geom.Point) MultiPoint(com.vividsolutions.jts.geom.MultiPoint)

Example 8 with DataSourceAttributeData

use of com.sldeditor.datasource.attribute.DataSourceAttributeData in project sldeditor by robward-scisys.

the class DataSourceAttributeModel method removeFields.

/**
 * Removes the fields.
 *
 * @param selectedRowIndexes the selected row indexes
 */
public void removeFields(int[] selectedRowIndexes) {
    if (selectedRowIndexes != null) {
        int index = selectedRowIndexes.length - 1;
        while (index >= 0) {
            int rowIndex = selectedRowIndexes[index];
            if ((rowIndex >= 0) && (rowIndex < valueList.size())) {
                DataSourceAttributeData data = valueList.remove(rowIndex);
                if (data != null) {
                    valueMap.remove(data.getName());
                }
            }
            index--;
        }
    }
}
Also used : DataSourceAttributeData(com.sldeditor.datasource.attribute.DataSourceAttributeData) Point(com.vividsolutions.jts.geom.Point) MultiPoint(com.vividsolutions.jts.geom.MultiPoint)

Example 9 with DataSourceAttributeData

use of com.sldeditor.datasource.attribute.DataSourceAttributeData in project sldeditor by robward-scisys.

the class DataSourceAttributeModel method populate.

/**
 * Populate model.
 *
 * @param attributeList the attribute list
 */
public void populate(List<DataSourceAttributeData> attributeList) {
    valueList.clear();
    valueMap.clear();
    if (attributeList != null) {
        for (DataSourceAttributeData data : attributeList) {
            valueList.add(data);
            valueMap.put(data.getName(), data);
        }
    }
}
Also used : DataSourceAttributeData(com.sldeditor.datasource.attribute.DataSourceAttributeData)

Example 10 with DataSourceAttributeData

use of com.sldeditor.datasource.attribute.DataSourceAttributeData in project sldeditor by robward-scisys.

the class SLDEditorFileHandler method readSLDEditorFile.

/**
 * Read sld editor file.
 *
 * @param file the file
 * @return the SLD data
 */
private SLDDataInterface readSLDEditorFile(File file) {
    SLDDataInterface sldData = null;
    DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder documentBuilder;
    try {
        documentBuilder = documentBuilderFactory.newDocumentBuilder();
        Document document = documentBuilder.parse(file);
        String sldFile = extractTextData(document, SLDEditorFileHandler.SLD_ELEMENT);
        DataSourcePropertiesInterface dataSourceProperties = DataSourceProperties.decodeXML(document, SLDEditorFileHandler.DATASOURCE_ELEMENT);
        List<VersionData> vendorOptionList = extractVendorOptionData(document, SLDEditorFileHandler.VENDOR_OPTION_ELEMENT);
        File f = new File(sldFile);
        String sldContents = readFile(f, Charset.defaultCharset());
        sldData = new SLDData(new StyleWrapper(sldFile), sldContents);
        sldData.setDataSourceProperties(dataSourceProperties);
        sldData.setVendorOptionList(vendorOptionList);
        List<DataSourceAttributeData> fieldList = null;
        sldData.setFieldList(fieldList);
        sldData.setSLDFile(f);
        sldData.setReadOnly(false);
        sldData.setSldEditorFile(file);
        List<EnvVar> envVarList = extractEnvironmentVariables(document, SLDEditorFileHandler.ENVVAR_ELEMENT);
        sldData.setEnvVarList(envVarList);
        LegendOptionData legendOption = LegendOptionData.decodeXML(document, SLDEditorFileHandler.LEGEND_OPTION_ELEMENT);
        sldData.setLegendOptions(legendOption);
    } catch (ParserConfigurationException e) {
        ConsoleManager.getInstance().exception(this, e);
    } catch (SAXException e) {
        ConsoleManager.getInstance().exception(this, e);
    } catch (IOException e) {
        ConsoleManager.getInstance().exception(this, e);
    }
    return sldData;
}
Also used : SLDData(com.sldeditor.common.data.SLDData) DataSourceAttributeData(com.sldeditor.datasource.attribute.DataSourceAttributeData) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) IOException(java.io.IOException) Document(org.w3c.dom.Document) DataSourcePropertiesInterface(com.sldeditor.common.DataSourcePropertiesInterface) LegendOptionData(com.sldeditor.ui.legend.option.LegendOptionData) SAXException(org.xml.sax.SAXException) SLDDataInterface(com.sldeditor.common.SLDDataInterface) DocumentBuilder(javax.xml.parsers.DocumentBuilder) StyleWrapper(com.sldeditor.common.data.StyleWrapper) VersionData(com.sldeditor.common.vendoroption.VersionData) EnvVar(com.sldeditor.filter.v2.envvar.EnvVar) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) SLDEditorFile(com.sldeditor.datasource.SLDEditorFile) File(java.io.File)

Aggregations

DataSourceAttributeData (com.sldeditor.datasource.attribute.DataSourceAttributeData)40 Test (org.junit.Test)23 ExtractAttributes (com.sldeditor.datasource.impl.ExtractAttributes)12 ArrayList (java.util.ArrayList)11 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)10 Rule (org.geotools.styling.Rule)8 Filter (org.opengis.filter.Filter)8 LineString (com.vividsolutions.jts.geom.LineString)5 SLDDataInterface (com.sldeditor.common.SLDDataInterface)4 DataSourceAttributeList (com.sldeditor.datasource.attribute.DataSourceAttributeList)4 Point (com.vividsolutions.jts.geom.Point)4 IOException (java.io.IOException)4 SimpleFeature (org.opengis.feature.simple.SimpleFeature)4 SimpleFeatureType (org.opengis.feature.simple.SimpleFeatureType)4 DataSourceImpl (com.sldeditor.datasource.impl.DataSourceImpl)3 MultiLineString (com.vividsolutions.jts.geom.MultiLineString)3 MultiPoint (com.vividsolutions.jts.geom.MultiPoint)3 AttributeDescriptor (org.opengis.feature.type.AttributeDescriptor)3 SLDData (com.sldeditor.common.data.SLDData)2 CreateDataSourceInterface (com.sldeditor.datasource.impl.CreateDataSourceInterface)2