Search in sources :

Example 11 with TextSymbolizer

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

the class SLDTreeTools method addNewText.

/**
 * Adds the new text symbolizer.
 */
public void addNewText() {
    if (symbolTree == null) {
        return;
    }
    // Store current state of the SLD before the add
    Object oldValueObj = sldWriter.encodeSLD(null, SelectedSymbol.getInstance().getSld());
    TextSymbolizer newTextSymbolizer = DefaultSymbols.createDefaultTextSymbolizer();
    DefaultMutableTreeNode ruleNode = getRuleTreeNode();
    SelectedSymbol.getInstance().addSymbolizerToRule(newTextSymbolizer);
    DefaultMutableTreeNode newNode = sldTree.addObject(ruleNode, newTextSymbolizer, true);
    // Select the item just added
    if (newNode != null) {
        SLDTreeManager.getInstance().rebuildTree((SLDTree) sldTree);
        TreePath newPath = getPath(newNode);
        symbolTree.setSelectionPath(newPath);
        // Store current state of the SLD after the add
        Object newValueObj = sldWriter.encodeSLD(null, SelectedSymbol.getInstance().getSld());
        UndoManager.getInstance().addUndoEvent(new UndoEvent(sldTree.getUndoObject(), getClass().getName(), oldValueObj, newValueObj));
    }
}
Also used : UndoEvent(com.sldeditor.common.undo.UndoEvent) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) TreePath(javax.swing.tree.TreePath) TextSymbolizer(org.geotools.styling.TextSymbolizer)

Example 12 with TextSymbolizer

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

the class SLDTreeLeafFactoryTest method testUpdateStroke.

/**
 * Test method for
 * {@link com.sldeditor.common.tree.leaf.SLDTreeLeafFactory#updateStroke(boolean, org.opengis.style.Symbolizer)}.
 */
@Test
public void testUpdateStroke() {
    assertNull(SLDTreeLeafFactory.getInstance().updateStroke(true, null));
    PolygonSymbolizer polygonSymbolizer = DefaultSymbols.createDefaultPolygonSymbolizer();
    assertEquals(SLDTreeLeafFactory.getInstance().updateStroke(false, polygonSymbolizer), styleFactory.getDefaultStroke());
    assertTrue(SLDTreeLeafFactory.getInstance().updateStroke(true, polygonSymbolizer) != null);
    PointSymbolizer pointSymbolizer = DefaultSymbols.createDefaultPointSymbolizer();
    assertEquals(SLDTreeLeafFactory.getInstance().updateStroke(false, pointSymbolizer), styleFactory.getDefaultStroke());
    assertTrue(SLDTreeLeafFactory.getInstance().updateStroke(true, pointSymbolizer) != null);
    LineSymbolizer lineSymbolizer = DefaultSymbols.createDefaultLineSymbolizer();
    assertEquals(SLDTreeLeafFactory.getInstance().updateStroke(false, lineSymbolizer), styleFactory.getDefaultStroke());
    assertEquals(SLDTreeLeafFactory.getInstance().updateStroke(true, lineSymbolizer), styleFactory.getDefaultStroke());
    TextSymbolizer textSymbolizer = DefaultSymbols.createDefaultTextSymbolizer();
    assertEquals(SLDTreeLeafFactory.getInstance().updateStroke(false, textSymbolizer), styleFactory.getDefaultStroke());
    assertEquals(SLDTreeLeafFactory.getInstance().updateStroke(true, textSymbolizer), styleFactory.getDefaultStroke());
}
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 13 with TextSymbolizer

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

the class SLDTreeLeafFactoryTest method testGetFill.

/**
 * Test method for
 * {@link com.sldeditor.common.tree.leaf.SLDTreeLeafFactory#getFill(org.opengis.style.Symbolizer)}.
 */
@Test
public void testGetFill() {
    PolygonSymbolizer polygonSymbolizer = DefaultSymbols.createDefaultPolygonSymbolizer();
    PointSymbolizer pointSymbolizer = DefaultSymbols.createDefaultPointSymbolizer();
    // CHECKSTYLE:OFF
    LineSymbolizer lineSymbolizer = DefaultSymbols.createDefaultLineSymbolizer();
    TextSymbolizer textSymbolizer = DefaultSymbols.createDefaultTextSymbolizer();
    // CHECKSTYLE:ON
    assertNull(SLDTreeLeafFactory.getInstance().getFill(null));
    assertTrue(SLDTreeLeafFactory.getInstance().getFill(polygonSymbolizer) != null);
    assertTrue(SLDTreeLeafFactory.getInstance().getFill(pointSymbolizer) != null);
    // Returns default fill
    assertTrue(SLDTreeLeafFactory.getInstance().getFill(lineSymbolizer) != null);
    assertTrue(SLDTreeLeafFactory.getInstance().getFill(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)

Example 14 with TextSymbolizer

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

the class SLDTreeLeafFactoryTest method testHasStroke.

/**
 * Test method for
 * {@link com.sldeditor.common.tree.leaf.SLDTreeLeafFactory#hasStroke(org.opengis.style.Symbolizer)}.
 */
@Test
public void testHasStroke() {
    PolygonSymbolizer polygonSymbolizer = DefaultSymbols.createDefaultPolygonSymbolizer();
    PointSymbolizer pointSymbolizer = DefaultSymbols.createDefaultPointSymbolizer();
    // CHECKSTYLE:OFF
    LineSymbolizer lineSymbolizer = DefaultSymbols.createDefaultLineSymbolizer();
    TextSymbolizer textSymbolizer = DefaultSymbols.createDefaultTextSymbolizer();
    // CHECKSTYLE:ON
    assertFalse(SLDTreeLeafFactory.getInstance().hasStroke(null));
    assertTrue(SLDTreeLeafFactory.getInstance().hasStroke(polygonSymbolizer));
    assertFalse(SLDTreeLeafFactory.getInstance().hasStroke(pointSymbolizer));
    assertTrue(SLDTreeLeafFactory.getInstance().hasStroke(lineSymbolizer));
    assertFalse(SLDTreeLeafFactory.getInstance().hasStroke(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 15 with TextSymbolizer

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

the class SLDTreeLeafTextTest method testRemoveStroke.

/**
 * Test method for {@link com.sldeditor.common.tree.leaf.SLDTreeLeafText#removeStroke(org.opengis.style.Symbolizer)}.
 */
@Test
public void testRemoveStroke() {
    SLDTreeLeafText leaf = new SLDTreeLeafText();
    TextSymbolizer textSymbolizer = DefaultSymbols.createDefaultTextSymbolizer();
    leaf.removeStroke(textSymbolizer);
// Does nothing
}
Also used : TextSymbolizer(org.geotools.styling.TextSymbolizer) SLDTreeLeafText(com.sldeditor.common.tree.leaf.SLDTreeLeafText) Test(org.junit.Test)

Aggregations

TextSymbolizer (org.geotools.styling.TextSymbolizer)33 Test (org.junit.Test)19 Font (org.geotools.styling.Font)9 PointSymbolizer (org.geotools.styling.PointSymbolizer)9 Rule (org.geotools.styling.Rule)9 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)8 LineSymbolizer (org.geotools.styling.LineSymbolizer)8 PolygonSymbolizer (org.geotools.styling.PolygonSymbolizer)8 Style (org.geotools.styling.Style)8 StyledLayerDescriptor (org.geotools.styling.StyledLayerDescriptor)6 NamedLayer (org.geotools.styling.NamedLayer)5 SLDTreeLeafText (com.sldeditor.common.tree.leaf.SLDTreeLeafText)4 SLDData (com.sldeditor.common.data.SLDData)3 StyleWrapper (com.sldeditor.common.data.StyleWrapper)3 SLDWriterInterface (com.sldeditor.common.output.SLDWriterInterface)3 VendorOptionPresent (com.sldeditor.common.vendoroption.minversion.VendorOptionPresent)3 FieldIdEnum (com.sldeditor.common.xml.ui.FieldIdEnum)3 BatchUpdateFontData (com.sldeditor.tool.batchupdatefont.BatchUpdateFontData)3 StyleFactoryImpl (org.geotools.styling.StyleFactoryImpl)3 Symbolizer (org.geotools.styling.Symbolizer)3