Search in sources :

Example 41 with PointSymbolizer

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

the class SLDUtilsTest method testReadSLDFile.

@Test
public void testReadSLDFile() {
    try {
        File tmpFile = File.createTempFile(getClass().getSimpleName(), ".sld");
        FileWriter fileWriter = new FileWriter(tmpFile);
        fileWriter.write(expectedSld);
        fileWriter.flush();
        fileWriter.close();
        StyledLayerDescriptor sld = SLDUtils.readSLDFile(null);
        assertNull(sld);
        sld = SLDUtils.readSLDFile(tmpFile);
        StyledLayer[] styledLayers = sld.getStyledLayers();
        NamedLayer namedLayer = (NamedLayer) styledLayers[0];
        Style[] actualStyles = namedLayer.getStyles();
        PointSymbolizer pointSymbolizer = (PointSymbolizer) actualStyles[0].featureTypeStyles().get(0).rules().get(0).symbolizers().get(0);
        MarkImpl mark = (MarkImpl) pointSymbolizer.getGraphic().graphicalSymbols().get(0);
        assertEquals("circle", mark.getWellKnownName().toString());
        tmpFile.delete();
    } catch (IOException e) {
        e.printStackTrace();
        fail("Failed to create test file");
    }
}
Also used : PointSymbolizer(org.geotools.styling.PointSymbolizer) StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) StyledLayer(org.geotools.styling.StyledLayer) FileWriter(java.io.FileWriter) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) MarkImpl(org.geotools.styling.MarkImpl) IOException(java.io.IOException) File(java.io.File) NamedLayer(org.geotools.styling.NamedLayer) Test(org.junit.Test)

Example 42 with PointSymbolizer

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

the class SLDTreeLeafFactoryTest method testUpdateFill.

/**
 * Test method for
 * {@link com.sldeditor.common.tree.leaf.SLDTreeLeafFactory#updateFill(boolean, org.opengis.style.Symbolizer)}.
 */
@Test
public void testUpdateFill() {
    assertNull(SLDTreeLeafFactory.getInstance().updateFill(true, null));
    PolygonSymbolizer polygonSymbolizer = DefaultSymbols.createDefaultPolygonSymbolizer();
    assertEquals(SLDTreeLeafFactory.getInstance().updateFill(false, polygonSymbolizer), styleFactory.getDefaultFill());
    assertTrue(SLDTreeLeafFactory.getInstance().updateFill(true, polygonSymbolizer) != null);
    PointSymbolizer pointSymbolizer = DefaultSymbols.createDefaultPointSymbolizer();
    assertEquals(SLDTreeLeafFactory.getInstance().updateFill(false, pointSymbolizer), styleFactory.getDefaultFill());
    assertTrue(SLDTreeLeafFactory.getInstance().updateFill(true, pointSymbolizer) != null);
    LineSymbolizer lineSymbolizer = DefaultSymbols.createDefaultLineSymbolizer();
    assertEquals(SLDTreeLeafFactory.getInstance().updateFill(false, lineSymbolizer), styleFactory.getDefaultFill());
    assertEquals(SLDTreeLeafFactory.getInstance().updateFill(true, lineSymbolizer), styleFactory.getDefaultFill());
    TextSymbolizer textSymbolizer = DefaultSymbols.createDefaultTextSymbolizer();
    assertEquals(SLDTreeLeafFactory.getInstance().updateFill(false, textSymbolizer), styleFactory.getDefaultFill());
    assertEquals(SLDTreeLeafFactory.getInstance().updateFill(true, textSymbolizer), styleFactory.getDefaultFill());
}
Also used : PointSymbolizer(org.geotools.styling.PointSymbolizer) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) TextSymbolizer(org.geotools.styling.TextSymbolizer) LineSymbolizer(org.geotools.styling.LineSymbolizer) Test(org.junit.Test)

Example 43 with PointSymbolizer

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

the class SLDTreeLeafFactoryTest method testIsItemSelected.

/**
 * Test method for
 * {@link com.sldeditor.common.tree.leaf.SLDTreeLeafFactory#isItemSelected(java.lang.Object, org.geotools.styling.Symbolizer)}.
 */
@Test
public void testIsItemSelected() {
    assertFalse(SLDTreeLeafFactory.getInstance().isItemSelected(null, null));
    PolygonSymbolizer polygonSymbolizer = DefaultSymbols.createDefaultPolygonSymbolizer();
    assertTrue(SLDTreeLeafFactory.getInstance().isItemSelected(styleFactory.getDefaultFill(), polygonSymbolizer));
    assertTrue(SLDTreeLeafFactory.getInstance().isItemSelected(styleFactory.getDefaultStroke(), polygonSymbolizer));
    PointSymbolizer pointSymbolizer = DefaultSymbols.createDefaultPointSymbolizer();
    assertTrue(SLDTreeLeafFactory.getInstance().isItemSelected(styleFactory.getDefaultFill(), pointSymbolizer));
    assertFalse(SLDTreeLeafFactory.getInstance().isItemSelected(styleFactory.getDefaultStroke(), pointSymbolizer));
    LineSymbolizer lineSymbolizer = DefaultSymbols.createDefaultLineSymbolizer();
    assertFalse(SLDTreeLeafFactory.getInstance().isItemSelected(styleFactory.getDefaultFill(), lineSymbolizer));
    assertTrue(SLDTreeLeafFactory.getInstance().isItemSelected(styleFactory.getDefaultStroke(), lineSymbolizer));
    TextSymbolizer textSymbolizer = DefaultSymbols.createDefaultTextSymbolizer();
    assertFalse(SLDTreeLeafFactory.getInstance().isItemSelected(styleFactory.getDefaultFill(), textSymbolizer));
    assertFalse(SLDTreeLeafFactory.getInstance().isItemSelected(styleFactory.getDefaultStroke(), textSymbolizer));
}
Also used : PointSymbolizer(org.geotools.styling.PointSymbolizer) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) TextSymbolizer(org.geotools.styling.TextSymbolizer) LineSymbolizer(org.geotools.styling.LineSymbolizer) Test(org.junit.Test)

Example 44 with PointSymbolizer

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

the class SLDTreeLeafFactoryTest method testHasFill.

/**
 * Test method for
 * {@link com.sldeditor.common.tree.leaf.SLDTreeLeafFactory#hasFill(org.opengis.style.Symbolizer)}.
 */
@Test
public void testHasFill() {
    PolygonSymbolizer polygonSymbolizer = DefaultSymbols.createDefaultPolygonSymbolizer();
    PointSymbolizer pointSymbolizer = DefaultSymbols.createDefaultPointSymbolizer();
    // CHECKSTYLE:OFF
    LineSymbolizer lineSymbolizer = DefaultSymbols.createDefaultLineSymbolizer();
    TextSymbolizer textSymbolizer = DefaultSymbols.createDefaultTextSymbolizer();
    // CHECKSTYLE:ON
    assertFalse(SLDTreeLeafFactory.getInstance().hasFill(null));
    assertTrue(SLDTreeLeafFactory.getInstance().hasFill(polygonSymbolizer));
    assertTrue(SLDTreeLeafFactory.getInstance().hasFill(pointSymbolizer));
    assertFalse(SLDTreeLeafFactory.getInstance().hasFill(lineSymbolizer));
    assertFalse(SLDTreeLeafFactory.getInstance().hasFill(textSymbolizer));
}
Also used : PointSymbolizer(org.geotools.styling.PointSymbolizer) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) TextSymbolizer(org.geotools.styling.TextSymbolizer) LineSymbolizer(org.geotools.styling.LineSymbolizer) Test(org.junit.Test)

Example 45 with PointSymbolizer

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

the class SLDTreeLeafFactoryTest method testGetStroke.

/**
 * Test method for
 * {@link com.sldeditor.common.tree.leaf.SLDTreeLeafFactory#getStroke(org.opengis.style.Symbolizer)}.
 */
@Test
public void testGetStroke() {
    PolygonSymbolizer polygonSymbolizer = DefaultSymbols.createDefaultPolygonSymbolizer();
    // CHECKSTYLE:OFF
    PointSymbolizer pointSymbolizer = DefaultSymbols.createDefaultPointSymbolizer();
    LineSymbolizer lineSymbolizer = DefaultSymbols.createDefaultLineSymbolizer();
    TextSymbolizer textSymbolizer = DefaultSymbols.createDefaultTextSymbolizer();
    // CHECKSTYLE:ON
    assertNull(SLDTreeLeafFactory.getInstance().getStroke(null));
    assertTrue(SLDTreeLeafFactory.getInstance().getStroke(polygonSymbolizer) != null);
    assertTrue(SLDTreeLeafFactory.getInstance().getStroke(lineSymbolizer) != null);
    // Returns default stroke
    assertTrue(SLDTreeLeafFactory.getInstance().getStroke(pointSymbolizer) != null);
    assertTrue(SLDTreeLeafFactory.getInstance().getStroke(textSymbolizer) != null);
}
Also used : PointSymbolizer(org.geotools.styling.PointSymbolizer) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) TextSymbolizer(org.geotools.styling.TextSymbolizer) LineSymbolizer(org.geotools.styling.LineSymbolizer) Test(org.junit.Test)

Aggregations

PointSymbolizer (org.geotools.styling.PointSymbolizer)67 Test (org.junit.Test)32 PolygonSymbolizer (org.geotools.styling.PolygonSymbolizer)25 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)23 LineSymbolizer (org.geotools.styling.LineSymbolizer)23 Style (org.geotools.styling.Style)22 Rule (org.geotools.styling.Rule)19 Graphic (org.geotools.styling.Graphic)16 NamedLayer (org.geotools.styling.NamedLayer)13 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)13 Symbolizer (org.geotools.styling.Symbolizer)12 TextSymbolizer (org.geotools.styling.TextSymbolizer)10 GraphicalSymbol (org.opengis.style.GraphicalSymbol)9 SLDTreeLeafPoint (com.sldeditor.common.tree.leaf.SLDTreeLeafPoint)8 MarkImpl (org.geotools.styling.MarkImpl)8 Point (com.vividsolutions.jts.geom.Point)7 FeatureStyle (org.polymap.core.style.model.FeatureStyle)7 PointStyle (org.polymap.core.style.model.feature.PointStyle)7 Fill (org.geotools.styling.Fill)6 RasterSymbolizer (org.geotools.styling.RasterSymbolizer)6