Search in sources :

Example 36 with NamedLayer

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

the class SelectedSymbolTest method testReplacment.

/**
 * Test method for
 * {@link com.sldeditor.common.data.SelectedSymbol#removeRule(org.geotools.styling.Rule)}.
 */
@Test
public void testReplacment() {
    SelectedSymbol.destroyInstance();
    SelectedSymbol instance = SelectedSymbol.getInstance();
    Rule rule = DefaultSymbols.createNewRule();
    FeatureTypeStyle fts = DefaultSymbols.createNewFeatureTypeStyle();
    Style style = DefaultSymbols.createNewStyle();
    NamedLayer namedLayer = DefaultSymbols.createNewNamedLayer();
    StyledLayerDescriptor sld = DefaultSymbols.createNewSLD();
    PolygonSymbolizer polygonSymbolizer = DefaultSymbols.createDefaultPolygonSymbolizer();
    instance.createNewSLD(sld);
    instance.setSld(sld);
    instance.addNewStyledLayer(namedLayer);
    instance.setStyledLayer(namedLayer);
    instance.addNewStyle(style);
    instance.setStyle(style);
    instance.addNewFeatureTypeStyle(fts);
    instance.setFeatureTypeStyle(fts);
    instance.addNewRule(rule);
    instance.setRule(rule);
    instance.addSymbolizerToRule(polygonSymbolizer);
    instance.addNewRule(DefaultSymbols.createNewRule());
    instance.setSymbolizer(polygonSymbolizer);
    LineSymbolizer lineSymbolizer = DefaultSymbols.createDefaultLineSymbolizer();
    DummySLDTreeUpdated dummyTreeUpdated = new DummySLDTreeUpdated();
    instance.setTreeUpdateListener(dummyTreeUpdated);
    instance.replaceSymbolizer(lineSymbolizer);
    assertEquals(lineSymbolizer, instance.getSymbolizer());
    assertEquals(dummyTreeUpdated.objectOld, polygonSymbolizer);
    assertEquals(dummyTreeUpdated.objectNew, lineSymbolizer);
    Rule newRule = DefaultSymbols.createNewRule();
    newRule.setTitle("Replacement rule");
    instance.replaceRule(newRule);
    assertEquals(newRule, instance.getRule());
    assertNull(instance.getSymbolizer());
    FeatureTypeStyle newFts = DefaultSymbols.createNewFeatureTypeStyle();
    newFts.setName("Replacement fts");
    instance.replaceFeatureTypeStyle(newFts);
    assertEquals(newFts, instance.getFeatureTypeStyle());
    assertNull(instance.getRule());
    Style newStyle = DefaultSymbols.createNewStyle();
    newStyle.setName("Replacement style");
    instance.replaceStyle(newStyle);
    assertEquals(newStyle, instance.getStyle());
    assertNull(instance.getRule());
    NamedLayer newNamedLayer = DefaultSymbols.createNewNamedLayer();
    newNamedLayer.setName("Replacement named layer");
    instance.replaceStyledLayer(newNamedLayer);
    assertEquals(newNamedLayer, instance.getStyledLayer());
    assertNull(instance.getStyle());
}
Also used : SelectedSymbol(com.sldeditor.common.data.SelectedSymbol) StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) LineSymbolizer(org.geotools.styling.LineSymbolizer) 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 37 with NamedLayer

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

the class SelectedSymbolTest method testIsRasterSymbol.

@Test
public void testIsRasterSymbol() {
    SelectedSymbol.destroyInstance();
    SelectedSymbol instance = SelectedSymbol.getInstance();
    // Create point symbolizer
    StyledLayerDescriptor sld = DefaultSymbols.createNewPoint();
    instance.createNewSLD(sld);
    instance.setSld(sld);
    // No selection made
    assertFalse(instance.isRasterSymbol());
    Style style = ((NamedLayer) sld.layers().get(0)).styles().get(0);
    instance.setStyle(style);
    assertFalse(instance.isRasterSymbol());
    // Create polygon symbolizer
    SelectedSymbol.destroyInstance();
    instance = SelectedSymbol.getInstance();
    sld = DefaultSymbols.createNewPolygon();
    instance.createNewSLD(sld);
    instance.setSld(sld);
    // No selection made
    assertFalse(instance.isRasterSymbol());
    style = ((NamedLayer) sld.layers().get(0)).styles().get(0);
    instance.setStyle(style);
    assertFalse(instance.isRasterSymbol());
    // Create line symbolizer
    SelectedSymbol.destroyInstance();
    instance = SelectedSymbol.getInstance();
    sld = DefaultSymbols.createNewLine();
    instance.createNewSLD(sld);
    instance.setSld(sld);
    // No selection made
    assertFalse(instance.isRasterSymbol());
    style = ((NamedLayer) sld.layers().get(0)).styles().get(0);
    instance.setStyle(style);
    assertFalse(instance.isRasterSymbol());
    // Create raster symbolizer
    SelectedSymbol.destroyInstance();
    instance = SelectedSymbol.getInstance();
    sld = DefaultSymbols.createNewRaster();
    instance.createNewSLD(sld);
    instance.setSld(sld);
    // No selection made
    assertFalse(instance.isRasterSymbol());
    style = ((NamedLayer) sld.layers().get(0)).styles().get(0);
    instance.setStyle(style);
    assertTrue(instance.isRasterSymbol());
}
Also used : SelectedSymbol(com.sldeditor.common.data.SelectedSymbol) StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) NamedLayer(org.geotools.styling.NamedLayer) Test(org.junit.Test)

Example 38 with NamedLayer

use of org.geotools.styling.NamedLayer 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 39 with NamedLayer

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

the class NewPointSLDTest method testNewPointSLD.

/**
 * Test new point sld.
 */
@Test
public void testNewPointSLD() {
    NewPointSLD newData = new NewPointSLD();
    StyledLayerDescriptor sld = newData.create();
    assertTrue(sld.layers().size() == 1);
    StyledLayer styledLayer = sld.layers().get(0);
    NamedLayer namedLayer = (NamedLayer) styledLayer;
    Symbolizer symbolizer = namedLayer.styles().get(0).featureTypeStyles().get(0).rules().get(0).symbolizers().get(0);
    assertTrue(symbolizer instanceof PointSymbolizer);
}
Also used : NewPointSLD(com.sldeditor.create.sld.NewPointSLD) PointSymbolizer(org.geotools.styling.PointSymbolizer) StyledLayerDescriptor(org.geotools.styling.StyledLayerDescriptor) StyledLayer(org.geotools.styling.StyledLayer) NamedLayer(org.geotools.styling.NamedLayer) Symbolizer(org.geotools.styling.Symbolizer) PointSymbolizer(org.geotools.styling.PointSymbolizer) Test(org.junit.Test)

Example 40 with NamedLayer

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

the class NameLayerTreeItemTest method testGetTreeString.

/**
 * Test method for
 * {@link com.sldeditor.ui.tree.item.NameLayerTreeItem#getTreeString(java.lang.Object)}.
 */
@Test
public void testGetTreeString() {
    NameLayerTreeItem item = new NameLayerTreeItem();
    String actualValue = item.getTreeString(null, null);
    String expectedValue = String.format("%s : %s", Localisation.getString(SLDTreeTools.class, "TreeItem.namedlayer"), "");
    assertTrue(actualValue.compareTo(expectedValue) == 0);
    NamedLayer namedLayer = DefaultSymbols.createNewNamedLayer();
    actualValue = item.getTreeString(null, namedLayer);
    assertTrue(actualValue.compareTo(expectedValue) == 0);
    String expectedName = "test name";
    namedLayer.setName(expectedName);
    actualValue = item.getTreeString(null, namedLayer);
    expectedValue = String.format("%s : %s", Localisation.getString(SLDTreeTools.class, "TreeItem.namedlayer"), expectedName);
    assertTrue(actualValue.compareTo(expectedValue) == 0);
}
Also used : NamedLayer(org.geotools.styling.NamedLayer) NameLayerTreeItem(com.sldeditor.ui.tree.item.NameLayerTreeItem) SLDTreeTools(com.sldeditor.ui.tree.SLDTreeTools) Test(org.junit.Test)

Aggregations

NamedLayer (org.geotools.styling.NamedLayer)51 Style (org.geotools.styling.Style)44 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)44 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)42 Rule (org.geotools.styling.Rule)38 Test (org.junit.Test)34 PointSymbolizer (org.geotools.styling.PointSymbolizer)16 GraphicPanelFieldManager (com.sldeditor.ui.detail.GraphicPanelFieldManager)15 FieldConfigString (com.sldeditor.ui.detail.config.FieldConfigString)13 PolygonSymbolizer (org.geotools.styling.PolygonSymbolizer)13 LineSymbolizer (org.geotools.styling.LineSymbolizer)11 StyledLayer (org.geotools.styling.StyledLayer)10 Symbolizer (org.geotools.styling.Symbolizer)8 RasterSymbolizer (org.geotools.styling.RasterSymbolizer)7 StyleFactoryImpl (org.geotools.styling.StyleFactoryImpl)7 SLDData (com.sldeditor.common.data.SLDData)6 TextSymbolizer (org.geotools.styling.TextSymbolizer)6 FilterFactory (org.opengis.filter.FilterFactory)6 SelectedSymbol (com.sldeditor.common.data.SelectedSymbol)5 FieldConfigDouble (com.sldeditor.ui.detail.config.FieldConfigDouble)5