Search in sources :

Example 6 with UserLayer

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

the class InlineFeatureUtilsTest method testSetInlineFeatures.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.inlinefeature.InlineFeatureUtils#setInlineFeatures(org.geotools.styling.UserLayer, java.lang.String)}.
 */
@Test
public void testSetInlineFeatures() {
    UserLayer userLayer = DefaultSymbols.createNewUserLayer();
    InlineFeatureUtils.setInlineFeatures(null, null);
    InlineFeatureUtils.setInlineFeatures(userLayer, null);
    InlineFeatureUtils.setInlineFeatures(null, "");
    assertNull(userLayer.getInlineFeatureDatastore());
    InlineFeatureUtils.setInlineFeatures(userLayer, testInline2);
    assertNotNull(userLayer.getInlineFeatureDatastore());
}
Also used : UserLayer(org.geotools.styling.UserLayer) Test(org.junit.Test)

Example 7 with UserLayer

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

the class InlineFeatureUtilsTest method testDetermineGeometryType.

/**
 * Test method for
 * {@link com.sldeditor.ui.detail.config.inlinefeature.InlineFeatureUtils#determineGeometryType(org.opengis.feature.type.GeometryDescriptor, org.geotools.data.simple.SimpleFeatureCollection)}.
 */
@Test
public void testDetermineGeometryType() {
    // Test 1
    SLDData sldData = new SLDData(null, testInline1a);
    StyledLayerDescriptor sld = SLDUtils.createSLDFromString(sldData);
    UserLayer userLayer1 = (UserLayer) sld.layers().get(0);
    GeometryDescriptor geometryDescriptor = userLayer1.getInlineFeatureType().getGeometryDescriptor();
    String typeName = userLayer1.getInlineFeatureType().getTypeName();
    SimpleFeatureCollection simpleFeatureCollection = null;
    try {
        simpleFeatureCollection = userLayer1.getInlineFeatureDatastore().getFeatureSource(typeName).getFeatures();
    } catch (IOException e) {
        e.printStackTrace();
    }
    assertEquals(GeometryTypeEnum.UNKNOWN, InlineFeatureUtils.determineGeometryType(null, null));
    assertEquals(GeometryTypeEnum.UNKNOWN, InlineFeatureUtils.determineGeometryType(geometryDescriptor, null));
    assertEquals(GeometryTypeEnum.POLYGON, InlineFeatureUtils.determineGeometryType(geometryDescriptor, simpleFeatureCollection));
}
Also used : SLDData(com.sldeditor.common.data.SLDData) GeometryDescriptor(org.opengis.feature.type.GeometryDescriptor) StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) IOException(java.io.IOException) UserLayer(org.geotools.styling.UserLayer) SimpleFeatureCollection(org.geotools.data.simple.SimpleFeatureCollection) Test(org.junit.Test)

Example 8 with UserLayer

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

the class InlineDatastoreVisitor method visit.

/**
 * (non-Javadoc)
 * @see org.geotools.styling.visitor.DuplicatingStyleVisitor#visit(org.geotools.styling.UserLayer)
 */
public void visit(UserLayer layer) {
    Style[] style = layer.getUserStyles();
    int length = style.length;
    Style[] styleCopy = new Style[length];
    for (int i = 0; i < length; i++) {
        if (style[i] != null) {
            style[i].accept(this);
            styleCopy[i] = (Style) pages.pop();
        }
    }
    FeatureTypeConstraint[] lfc = layer.getLayerFeatureConstraints();
    FeatureTypeConstraint[] lfcCopy = new FeatureTypeConstraint[lfc.length];
    length = lfc.length;
    for (int i = 0; i < length; i++) {
        if (lfc[i] != null) {
            lfc[i].accept(this);
            lfcCopy[i] = (FeatureTypeConstraint) pages.pop();
        }
    }
    UserLayer copy = sf.createUserLayer();
    copy.setName(layer.getName());
    copy.setUserStyles(styleCopy);
    copy.setLayerFeatureConstraints(lfcCopy);
    // Reuse the existing inline feature data store
    copy.setInlineFeatureDatastore(layer.getInlineFeatureDatastore());
    copy.setInlineFeatureType(layer.getInlineFeatureType());
    if (STRICT && !copy.equals(layer)) {
        throw new IllegalStateException("Was unable to duplicate provided UserLayer:" + layer);
    }
    pages.push(copy);
}
Also used : FeatureTypeConstraint(org.geotools.styling.FeatureTypeConstraint) Style(org.geotools.styling.Style) UserLayer(org.geotools.styling.UserLayer) FeatureTypeConstraint(org.geotools.styling.FeatureTypeConstraint)

Example 9 with UserLayer

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

the class DataSourceImpl method getUserLayerFeatureSource.

/*
     * (non-Javadoc)
     * 
     * @see com.sldeditor.datasource.DataSourceInterface#getUserLayerFeatureSource()
     */
@Override
public // CHECKSTYLE:OFF
Map<UserLayer, FeatureSource<SimpleFeatureType, SimpleFeature>> getUserLayerFeatureSource() {
    // CHECKSTYLE:ON
    Map<UserLayer, FeatureSource<SimpleFeatureType, SimpleFeature>> map = new HashMap<UserLayer, FeatureSource<SimpleFeatureType, SimpleFeature>>();
    for (DataSourceInfo dsInfo : userLayerDataSourceInfo) {
        FeatureSource<SimpleFeatureType, SimpleFeature> features = dsInfo.getFeatures();
        UserLayer userLayer = dsInfo.getUserLayer();
        map.put(userLayer, features);
    }
    return map;
}
Also used : FeatureSource(org.geotools.data.FeatureSource) SimpleFeatureType(org.opengis.feature.simple.SimpleFeatureType) HashMap(java.util.HashMap) UserLayer(org.geotools.styling.UserLayer) SimpleFeature(org.opengis.feature.simple.SimpleFeature)

Example 10 with UserLayer

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

the class FieldConfigInlineFeature method redoAction.

/**
 * Redo action.
 *
 * @param undoRedoObject the undo/redo object
 */
@Override
public void redoAction(UndoInterface undoRedoObject) {
    if (undoRedoObject != null) {
        if (undoRedoObject.getNewValue() instanceof String) {
            String newValue = (String) undoRedoObject.getNewValue();
            UserLayer userLayer = DefaultSymbols.createNewUserLayer();
            InlineFeatureUtils.setInlineFeatures(userLayer, newValue);
            if (inlineGML != null) {
                inlineGML.setInlineFeatures(newValue);
            }
            if (inlineFeature != null) {
                inlineFeature.setInlineFeatures(userLayer);
            }
        }
    }
}
Also used : UserLayer(org.geotools.styling.UserLayer)

Aggregations

UserLayer (org.geotools.styling.UserLayer)29 Test (org.junit.Test)17 DummyInlineSLDFile (com.sldeditor.test.unit.datasource.impl.DummyInlineSLDFile)10 InLineFeatureModel (com.sldeditor.ui.detail.config.inlinefeature.InLineFeatureModel)8 Style (org.geotools.styling.Style)6 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)6 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)4 NamedLayer (org.geotools.styling.NamedLayer)4 Rule (org.geotools.styling.Rule)4 StyledLayer (org.geotools.styling.StyledLayer)4 UndoEvent (com.sldeditor.common.undo.UndoEvent)3 IOException (java.io.IOException)3 FeatureSource (org.geotools.data.FeatureSource)3 LineSymbolizer (org.geotools.styling.LineSymbolizer)3 PointSymbolizer (org.geotools.styling.PointSymbolizer)3 PolygonSymbolizer (org.geotools.styling.PolygonSymbolizer)3 SimpleFeatureType (org.opengis.feature.simple.SimpleFeatureType)3 SLDData (com.sldeditor.common.data.SLDData)2 FieldConfigCommonData (com.sldeditor.ui.detail.config.FieldConfigCommonData)2 FieldConfigInlineFeature (com.sldeditor.ui.detail.config.inlinefeature.FieldConfigInlineFeature)2