Search in sources :

Example 41 with PolygonSymbolizer

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

the class SelectedSymbolTest method testGetSLD.

@Test
public void testGetSLD() {
    SelectedSymbol.destroyInstance();
    SelectedSymbol instance = SelectedSymbol.getInstance();
    // CHECKSTYLE:OFF
    Rule rule = DefaultSymbols.createNewRule();
    FeatureTypeStyle fts = DefaultSymbols.createNewFeatureTypeStyle();
    Style style = DefaultSymbols.createNewStyle();
    NamedLayer namedLayer = DefaultSymbols.createNewNamedLayer();
    StyledLayerDescriptor sld = DefaultSymbols.createNewSLD();
    PolygonSymbolizer symbolizer = DefaultSymbols.createDefaultPolygonSymbolizer();
    // CHECKSTYLE:ON
    instance.createNewSLD(sld);
    instance.setSld(sld);
    System.out.println("Select named layer");
    instance.addNewStyledLayer(namedLayer);
    instance.setStyledLayer(namedLayer);
    assertEquals(namedLayer, instance.getStyledLayer());
    assertNull(instance.getRule());
    assertNull(instance.getStyle());
    assertNull(instance.getFeatureTypeStyle());
    assertNull(instance.getSymbolizer());
    System.out.println("Select style");
    instance.addNewStyle(style);
    instance.setStyle(style);
    assertEquals(namedLayer, instance.getStyledLayer());
    assertEquals(style, instance.getStyle());
    assertNull(instance.getFeatureTypeStyle());
    assertNull(instance.getRule());
    assertNull(instance.getSymbolizer());
    System.out.println("Select feature type style");
    instance.addNewFeatureTypeStyle(fts);
    instance.setFeatureTypeStyle(fts);
    assertEquals(namedLayer, instance.getStyledLayer());
    assertEquals(style, instance.getStyle());
    assertEquals(fts, instance.getFeatureTypeStyle());
    assertNull(instance.getRule());
    assertNull(instance.getSymbolizer());
    System.out.println("Select rule");
    instance.addNewRule(rule);
    instance.setRule(rule);
    assertEquals(namedLayer, instance.getStyledLayer());
    assertEquals(style, instance.getStyle());
    assertEquals(fts, instance.getFeatureTypeStyle());
    assertEquals(rule, instance.getRule());
    assertNull(instance.getSymbolizer());
    assertTrue(instance.hasOnlyOneRule());
    System.out.println("Select symbolizer");
    instance.addSymbolizerToRule(symbolizer);
    instance.addNewRule(DefaultSymbols.createNewRule());
    assertFalse(instance.hasOnlyOneRule());
    assertEquals(-1, instance.getSymbolIndex());
    instance.setSymbolizer(symbolizer);
    assertEquals(namedLayer, instance.getStyledLayer());
    assertEquals(style, instance.getStyle());
    assertEquals(fts, instance.getFeatureTypeStyle());
    assertEquals(rule, instance.getRule());
    assertEquals(symbolizer, instance.getSymbolizer());
    assertEquals(0, instance.getSymbolIndex());
    // Get SLD structure
    StyledLayerDescriptor actualSLD = instance.getSld();
    assertEquals(sld, actualSLD);
    StyledLayer[] actualStyledLayers = actualSLD.getStyledLayers();
    assertEquals(1, actualStyledLayers.length);
    NamedLayer actualNamedLayer = (NamedLayer) actualStyledLayers[0];
    assertEquals(namedLayer, actualNamedLayer);
    Style[] actualStyle = actualNamedLayer.getStyles();
    assertEquals(1, actualStyle.length);
    assertEquals(style, actualStyle[0]);
    assertEquals(1, style.featureTypeStyles().size());
    FeatureTypeStyle actualFeatureTypeStyle = style.featureTypeStyles().get(0);
    assertEquals(fts, actualFeatureTypeStyle);
    List<Rule> actualRules = actualFeatureTypeStyle.rules();
    assertEquals(2, actualRules.size());
    Rule actualRule = actualRules.get(0);
    assertEquals(rule, actualRule);
    assertEquals(1, actualRule.symbolizers().size());
    assertEquals(symbolizer, actualRule.symbolizers().get(0));
}
Also used : SelectedSymbol(com.sldeditor.common.data.SelectedSymbol) StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) StyledLayer(org.geotools.styling.StyledLayer) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) Rule(org.geotools.styling.Rule) NamedLayer(org.geotools.styling.NamedLayer) Test(org.junit.Test)

Example 42 with PolygonSymbolizer

use of org.geotools.styling.PolygonSymbolizer 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 PolygonSymbolizer

use of org.geotools.styling.PolygonSymbolizer 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 PolygonSymbolizer

use of org.geotools.styling.PolygonSymbolizer 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 PolygonSymbolizer

use of org.geotools.styling.PolygonSymbolizer 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

PolygonSymbolizer (org.geotools.styling.PolygonSymbolizer)65 Test (org.junit.Test)28 PointSymbolizer (org.geotools.styling.PointSymbolizer)25 LineSymbolizer (org.geotools.styling.LineSymbolizer)24 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)19 Rule (org.geotools.styling.Rule)18 Style (org.geotools.styling.Style)18 Symbolizer (org.geotools.styling.Symbolizer)15 Fill (org.geotools.styling.Fill)14 NamedLayer (org.geotools.styling.NamedLayer)12 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)12 Stroke (org.geotools.styling.Stroke)10 RasterSymbolizer (org.geotools.styling.RasterSymbolizer)9 TextSymbolizer (org.geotools.styling.TextSymbolizer)9 SLDTreeLeafPolygon (com.sldeditor.common.tree.leaf.SLDTreeLeafPolygon)8 Graphic (org.geotools.styling.Graphic)8 ArrayList (java.util.ArrayList)7 Expression (org.opengis.filter.expression.Expression)7 JsonObject (com.google.gson.JsonObject)5 SelectedSymbol (com.sldeditor.common.data.SelectedSymbol)5