Search in sources :

Example 6 with FeatureTypeConstraint

use of org.geotools.styling.FeatureTypeConstraint in project sldeditor by robward-scisys.

the class ExtentModel method updateExtent.

/**
 * Update extents of a feature type constraint.
 *
 * @param ftc the feature type constraint to update
 */
public void updateExtent(FeatureTypeConstraint ftc) {
    if (ftc == null) {
        return;
    }
    if (!extentList.isEmpty()) {
        Extent[] extentArray = new Extent[extentList.size()];
        int index = 0;
        for (Extent extent : extentList) {
            Extent newExtent = styleFactory.createExtent(extent.getName(), extent.getValue());
            extentArray[index] = newExtent;
            index++;
        }
        ftc.setExtents(extentArray);
    }
}
Also used : Extent(org.geotools.styling.Extent) FeatureTypeConstraint(org.geotools.styling.FeatureTypeConstraint)

Example 7 with FeatureTypeConstraint

use of org.geotools.styling.FeatureTypeConstraint in project sldeditor by robward-scisys.

the class FeatureTypeConstraintModel method populate.

/**
 * Populate.
 *
 * @param ftcList the ftc list
 */
public void populate(List<FeatureTypeConstraint> ftcList) {
    this.ftcList.clear();
    if (ftcList != null) {
        for (FeatureTypeConstraint ftc : ftcList) {
            FeatureTypeConstraint newFTC = styleFactory.createFeatureTypeConstraint(ftc.getFeatureTypeName(), ftc.getFilter(), new Extent[0]);
            this.ftcList.add(newFTC);
        }
    }
    this.fireTableDataChanged();
}
Also used : FeatureTypeConstraint(org.geotools.styling.FeatureTypeConstraint)

Example 8 with FeatureTypeConstraint

use of org.geotools.styling.FeatureTypeConstraint in project sldeditor by robward-scisys.

the class FeatureTypeConstraintModel method setValueAt.

/**
 * Sets the value at.
 *
 * @param aValue the a value
 * @param rowIndex the row index
 * @param columnIndex the column index
 */
@Override
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
    if ((rowIndex < 0) || (rowIndex >= getRowCount())) {
        return;
    }
    if ((columnIndex < 0) || (columnIndex >= getColumnCount())) {
        return;
    }
    FeatureTypeConstraint ftc = ftcList.get(rowIndex);
    switch(columnIndex) {
        case COL_NAME:
            {
                String name = (String) aValue;
                ftc.setFeatureTypeName(name);
            }
            break;
        case COL_FILTER:
            break;
        default:
            break;
    }
    this.fireTableDataChanged();
    if (parentObj != null) {
        parentObj.featureTypeConstraintUpdated();
    }
}
Also used : FeatureTypeConstraint(org.geotools.styling.FeatureTypeConstraint)

Example 9 with FeatureTypeConstraint

use of org.geotools.styling.FeatureTypeConstraint in project sldeditor by robward-scisys.

the class UserLayerDetails method updateSymbol.

/**
 * Update symbol.
 *
 * @param changedField the changed field
 */
private void updateSymbol(FieldIdEnum changedField) {
    if (!Controller.getInstance().isPopulating()) {
        UserLayer userLayer = getStyleFactory().createUserLayer();
        String name = fieldConfigVisitor.getText(FieldIdEnum.NAME);
        userLayer.setName(name);
        // Feature type constraints
        List<FeatureTypeConstraint> ftcList = fieldConfigVisitor.getFeatureTypeConstraint(FieldIdEnum.LAYER_FEATURE_CONSTRAINTS);
        if ((ftcList != null) && !ftcList.isEmpty()) {
            FeatureTypeConstraint[] ftcArray = new FeatureTypeConstraint[ftcList.size()];
            userLayer.setLayerFeatureConstraints(ftcList.toArray(ftcArray));
        }
        // Source
        GroupConfigInterface group = getGroup(GroupIdEnum.USER_LAYER_SOURCE);
        if (group != null) {
            MultiOptionGroup userLayerSourceGroup = (MultiOptionGroup) group;
            OptionGroup selectedOption = userLayerSourceGroup.getSelectedOptionGroup();
            switch(selectedOption.getId()) {
                case REMOTE_OWS_OPTION:
                    {
                        RemoteOWS remoteOWS = new RemoteOWSImpl();
                        String service = fieldConfigVisitor.getText(FieldIdEnum.REMOTE_OWS_SERVICE);
                        remoteOWS.setService(service);
                        String onlineResource = fieldConfigVisitor.getText(FieldIdEnum.REMOTE_OWS_ONLINERESOURCE);
                        remoteOWS.setOnlineResource(onlineResource);
                        userLayer.setRemoteOWS(remoteOWS);
                    }
                    break;
                case INLINE_FEATURE_OPTION:
                    {
                        String inlineFeatures = fieldConfigVisitor.getText(FieldIdEnum.INLINE_FEATURE);
                        if ((inlineFeatures != null) && (!inlineFeatures.isEmpty())) {
                            InlineFeatureUtils.setInlineFeatures(userLayer, inlineFeatures);
                        }
                    }
                    break;
                default:
                    break;
            }
        }
        StyledLayer existingStyledLayer = SelectedSymbol.getInstance().getStyledLayer();
        if (existingStyledLayer instanceof UserLayerImpl) {
            UserLayerImpl existingUserLayer = (UserLayerImpl) existingStyledLayer;
            for (Style style : existingUserLayer.userStyles()) {
                userLayer.addUserStyle(style);
            }
        }
        SelectedSymbol.getInstance().replaceStyledLayer(userLayer);
        // reduces creation of datasources
        if (changedField != null) {
            if (changedField == FieldIdEnum.INLINE_FEATURE) {
                DataSourceInterface dataSource = DataSourceFactory.getDataSource();
                if (dataSource != null) {
                    dataSource.updateUserLayers();
                }
            }
        }
        this.fireUpdateSymbol();
    }
}
Also used : RemoteOWS(org.geotools.styling.RemoteOWS) StyledLayer(org.geotools.styling.StyledLayer) RemoteOWSImpl(org.geotools.styling.RemoteOWSImpl) DataSourceInterface(com.sldeditor.datasource.DataSourceInterface) FeatureTypeConstraint(org.geotools.styling.FeatureTypeConstraint) OptionGroup(com.sldeditor.ui.detail.config.base.OptionGroup) MultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup) UserLayerImpl(org.geotools.styling.UserLayerImpl) Style(org.geotools.styling.Style) GroupConfigInterface(com.sldeditor.ui.detail.config.base.GroupConfigInterface) UserLayer(org.geotools.styling.UserLayer) MultiOptionGroup(com.sldeditor.ui.detail.config.base.MultiOptionGroup)

Example 10 with FeatureTypeConstraint

use of org.geotools.styling.FeatureTypeConstraint in project sldeditor by robward-scisys.

the class FeatureTypeConstraintModel method addNewEntry.

/**
 * Adds the new entry.
 */
public void addNewEntry() {
    FeatureTypeConstraint ftc = styleFactory.createFeatureTypeConstraint(DEFAULT_NAME, Filter.INCLUDE, new Extent[0]);
    ftcList.add(ftc);
    this.fireTableDataChanged();
    if (parentObj != null) {
        parentObj.featureTypeConstraintUpdated();
    }
}
Also used : FeatureTypeConstraint(org.geotools.styling.FeatureTypeConstraint)

Aggregations

FeatureTypeConstraint (org.geotools.styling.FeatureTypeConstraint)18 Test (org.junit.Test)6 StyleFactoryImpl (org.geotools.styling.StyleFactoryImpl)4 StyledLayer (org.geotools.styling.StyledLayer)4 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)3 Extent (org.geotools.styling.Extent)3 Style (org.geotools.styling.Style)3 UndoEvent (com.sldeditor.common.undo.UndoEvent)2 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)2 GroupConfigInterface (com.sldeditor.ui.detail.config.base.GroupConfigInterface)2 MultiOptionGroup (com.sldeditor.ui.detail.config.base.MultiOptionGroup)2 FieldConfigFeatureTypeConstraint (com.sldeditor.ui.detail.config.featuretypeconstraint.FieldConfigFeatureTypeConstraint)2 Geometry (com.vividsolutions.jts.geom.Geometry)2 NamedLayerImpl (org.geotools.styling.NamedLayerImpl)2 RemoteOWS (org.geotools.styling.RemoteOWS)2 UserLayer (org.geotools.styling.UserLayer)2 UserLayerImpl (org.geotools.styling.UserLayerImpl)2 DataSourceInterface (com.sldeditor.datasource.DataSourceInterface)1 FilterPanelInterface (com.sldeditor.filter.FilterPanelInterface)1 FieldConfigBase (com.sldeditor.ui.detail.config.FieldConfigBase)1