org.geotools.styling.PointSymbolizer Java Examples
The following examples show how to use
org.geotools.styling.PointSymbolizer.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SymbolizerFilterVisitorTest.java From geomajas-project-server with GNU Affero General Public License v3.0 | 6 votes |
@Test public void testLabelsAndGeometries() throws IOException{ SymbolizerFilterVisitor visitor = new SymbolizerFilterVisitor(); visitor.setIncludeGeometry(true); visitor.setIncludeText(true); SLDParser parser = new SLDParser(styleFactory); parser.setInput(getClass().getResource("point_pointwithdefaultlabel.sld")); Style[] styles = parser.readXML(); Assert.assertEquals(1, styles.length); visitor.visit(styles[0]); Style copy = (Style) visitor.getCopy(); FeatureTypeStyle featureTypeStyle = copy.featureTypeStyles().iterator().next(); Rule rule = featureTypeStyle.rules().iterator().next(); Iterator<Symbolizer> it = rule.symbolizers().iterator(); Assert.assertTrue(it.next() instanceof PointSymbolizer); Assert.assertTrue(it.next() instanceof TextSymbolizer); Assert.assertFalse(it.hasNext()); }
Example #2
Source File: PointSymbolizerDetails.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** Update symbol. */ private void updateSymbol() { if (!Controller.getInstance().isPopulating()) { StandardData standardData = getStandardData(); Expression geometryField = ExtractGeometryField.getGeometryField(fieldConfigVisitor); PointSymbolizer pointSymbolizer = (PointSymbolizer) SelectedSymbol.getInstance().getSymbolizer(); if (pointSymbolizer != null) { pointSymbolizer.setName(standardData.getName()); pointSymbolizer.setDescription(standardData.getDescription()); pointSymbolizer.setUnitOfMeasure( (standardData.getUnit() != null) ? standardData.getUnit().getUnit() : null); pointSymbolizer.setGeometry(geometryField); this.fireUpdateSymbol(); } } }
Example #3
Source File: ExtractAttributes.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * (non-Javadoc) * * @see * org.geotools.styling.visitor.DuplicatingStyleVisitor#visit(org.geotools.styling.PointSymbolizer) */ @Override public void visit(PointSymbolizer ps) { PointSymbolizer copy = sf.getDefaultPointSymbolizer(); copy.setGeometry(copy(Point.class, ps.getGeometry())); copy.setUnitOfMeasure(ps.getUnitOfMeasure()); copy.setGraphic(copy(ps.getGraphic())); copy.getOptions().putAll(ps.getOptions()); if (STRICT && !copy.equals(ps)) { throw new IllegalStateException("Was unable to duplicate provided Graphic:" + ps); } pages.push(copy); }
Example #4
Source File: RuleRenderVisitor.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * (non-Javadoc) * * @see * org.geotools.styling.visitor.DuplicatingStyleVisitor#visit(org.geotools.styling.PointSymbolizer) */ public void visit(PointSymbolizer ps) { PointSymbolizer copy = sf.getDefaultPointSymbolizer(); copy.setGeometry(copy(ps.getGeometry())); copy.setUnitOfMeasure(ps.getUnitOfMeasure()); copy.setGraphic(copy(ps.getGraphic())); copy.getOptions().putAll(ps.getOptions()); if (STRICT) { if (!copy.equals(ps)) { throw new IllegalStateException("Was unable to duplicate provided Graphic:" + ps); } } pages.push(copy); }
Example #5
Source File: SymbolizerTreeItem.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * Default string. * * @param symbol the symbol * @return the string */ private String defaultString(Symbolizer symbol) { String name = ""; if (symbol instanceof PointSymbolizer) { name = DEFAULT_MARKER_NAME; } else if (symbol instanceof TextSymbolizer) { name = DEFAULT_TEXT_NAME; } else if (symbol instanceof LineSymbolizer) { name = DEFAULT_LINE_NAME; } else if (symbol instanceof PolygonSymbolizer) { name = DEFAULT_POLYGON_NAME; } else if (symbol instanceof RasterSymbolizer) { name = DEFAULT_RASTER_NAME; } return name; }
Example #6
Source File: SLDTree.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * Populate symbolizer. * * @param ruleTreeNode the rule tree node * @param symbolizer the symbolizer */ private void populateSymbolizer(DefaultMutableTreeNode ruleTreeNode, Symbolizer symbolizer) { DefaultMutableTreeNode symbolizerTreeNode = addObject(ruleTreeNode, symbolizer, true); if ((symbolizer instanceof PointSymbolizer) || (symbolizer instanceof PolygonSymbolizer)) { addObject( symbolizerTreeNode, SLDTreeLeafFactory.getInstance().getFill(symbolizer), true); } if ((symbolizer instanceof PolygonSymbolizer) || (symbolizer instanceof LineSymbolizer)) { addObject( symbolizerTreeNode, SLDTreeLeafFactory.getInstance().getStroke(symbolizer), true); } if (symbolizer instanceof RasterSymbolizer) { handleRasterSymbolizer(symbolizer, symbolizerTreeNode); } }
Example #7
Source File: PointFillDetails.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** Update symbol. */ private void updateSymbol() { if (!Controller.getInstance().isPopulating()) { Symbolizer symbolizer = SelectedSymbol.getInstance().getSymbolizer(); if (symbolizer instanceof PointSymbolizer) { PointSymbolizerImpl newPointSymbolizer = (PointSymbolizerImpl) symbolizer; Graphic graphic = getGraphic(); newPointSymbolizer.setGraphic(graphic); } this.fireUpdateSymbol(); } }
Example #8
Source File: SLDTreeLeafPoint.java From sldeditor with GNU General Public License v3.0 | 6 votes |
@Override public Fill getFill(Symbolizer symbolizer) { if (symbolizer instanceof PointSymbolizer) { PointSymbolizer point = (PointSymbolizer) symbolizer; Graphic graphic = point.getGraphic(); if (graphic != null) { List<GraphicalSymbol> symbolList = graphic.graphicalSymbols(); if ((symbolList != null) && !symbolList.isEmpty()) { GraphicalSymbol obj = symbolList.get(0); if (obj instanceof MarkImpl) { MarkImpl mark = (MarkImpl) obj; return mark.getFill(); } } } } return null; }
Example #9
Source File: SLDTreeLeafPoint.java From sldeditor with GNU General Public License v3.0 | 6 votes |
@Override public void createFill(Symbolizer symbolizer) { if (symbolizer instanceof PointSymbolizer) { PointSymbolizer point = (PointSymbolizer) symbolizer; Graphic graphic = point.getGraphic(); if (graphic == null) { graphic = styleFactory.createDefaultGraphic(); point.setGraphic(graphic); } if ((graphic != null) && graphic.graphicalSymbols().isEmpty()) { Mark mark = styleFactory.getDefaultMark(); graphic.graphicalSymbols().add(mark); } } }
Example #10
Source File: NewPointSLDTest.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** 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); }
Example #11
Source File: SLDTreeLeafFactoryTest.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * 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)); }
Example #12
Source File: SLDTreeLeafFactoryTest.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * 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)); }
Example #13
Source File: SLDTreeLeafFactoryTest.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * 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); }
Example #14
Source File: SimpleMarkerSymbol.java From sldeditor with GNU General Public License v3.0 | 6 votes |
@Override public void convert(Rule rule, JsonElement element, String layerName, int transparency) { if(element == null) return; if(rule == null) return; List<Symbolizer> symbolizerList = rule.symbolizers(); List<Graphic> markerList = convert(element); if(markerList != null) { for(Graphic marker : markerList) { PointSymbolizer pointSymbolizer = styleFactory.createPointSymbolizer(marker, null); symbolizerList.add(pointSymbolizer); } } }
Example #15
Source File: SymbolizerFilterVisitorTest.java From geomajas-project-server with GNU Affero General Public License v3.0 | 6 votes |
@Test public void testGeometries() throws IOException{ SymbolizerFilterVisitor visitor = new SymbolizerFilterVisitor(); visitor.setIncludeGeometry(true); visitor.setIncludeText(false); SLDParser parser = new SLDParser(styleFactory); parser.setInput(getClass().getResource("point_pointwithdefaultlabel.sld")); Style[] styles = parser.readXML(); Assert.assertEquals(1, styles.length); visitor.visit(styles[0]); Style copy = (Style) visitor.getCopy(); FeatureTypeStyle featureTypeStyle = copy.featureTypeStyles().iterator().next(); Rule rule = featureTypeStyle.rules().iterator().next(); Iterator<Symbolizer> it = rule.symbolizers().iterator(); Assert.assertTrue(it.next() instanceof PointSymbolizer); Assert.assertFalse(it.hasNext()); }
Example #16
Source File: SymbolizerFilterVisitor.java From geomajas-project-server with GNU Affero General Public License v3.0 | 6 votes |
protected boolean skipSymbolizer(Symbolizer symbolizer) { if (symbolizer instanceof TextSymbolizer) { if (!isIncludeText()) { return true; } } else if (symbolizer instanceof LineSymbolizer) { if (!isIncludeGeometry()) { return true; } } else if (symbolizer instanceof PointSymbolizer) { if (!isIncludeGeometry()) { return true; } } else if (symbolizer instanceof PolygonSymbolizer) { if (!isIncludeGeometry()) { return true; } } else if (symbolizer instanceof RasterSymbolizer) { if (!isIncludeGeometry()) { return true; } } return false; }
Example #17
Source File: StyleUtilities.java From hortonmachine with GNU General Public License v3.0 | 6 votes |
/** * Creates a default {@link Rule} for a point. * * @return the default rule. */ public static Rule createDefaultPointRule() { Graphic graphic = sf.createDefaultGraphic(); Mark circleMark = sf.getCircleMark(); circleMark.setFill(sf.createFill(ff.literal("#" + Integer.toHexString(Color.RED.getRGB() & 0xffffff)))); circleMark.setStroke(sf.createStroke(ff.literal("#" + Integer.toHexString(Color.BLACK.getRGB() & 0xffffff)), ff.literal(DEFAULT_WIDTH))); graphic.graphicalSymbols().clear(); graphic.graphicalSymbols().add(circleMark); graphic.setSize(ff.literal(DEFAULT_SIZE)); PointSymbolizer pointSymbolizer = sf.createPointSymbolizer(); Rule rule = sf.createRule(); rule.setName("New rule"); rule.symbolizers().add(pointSymbolizer); pointSymbolizer.setGraphic(graphic); return rule; }
Example #18
Source File: RuleWrapper.java From hortonmachine with GNU General Public License v3.0 | 6 votes |
/** * Returns the type of geometry/raster that the {@link SymbolizerWrapper} represents. * * @return the symbolizer type. */ public EGeometryType getType() { SymbolizerWrapper geometrySymbolizersWrapper = getGeometrySymbolizersWrapper(); if (geometrySymbolizersWrapper == null) { return null; } Symbolizer symbolizer = geometrySymbolizersWrapper.getSymbolizer(); if (symbolizer instanceof PointSymbolizer) { return EGeometryType.POINT; } else if (symbolizer instanceof LineSymbolizer) { return EGeometryType.LINESTRING; } else if (symbolizer instanceof PolygonSymbolizer) { return EGeometryType.POLYGON; } else if (symbolizer instanceof RasterSymbolizer) { throw new RuntimeException("Not implemented yet!"); } return null; }
Example #19
Source File: RuleWrapper.java From hortonmachine with GNU General Public License v3.0 | 6 votes |
private SymbolizerWrapper getWrapper( Symbolizer symbolizer ) { SymbolizerWrapper symbolizerWrapper = null; if (symbolizer instanceof PointSymbolizer) { symbolizerWrapper = new PointSymbolizerWrapper(symbolizer, this); } else if (symbolizer instanceof LineSymbolizer) { symbolizerWrapper = new LineSymbolizerWrapper(symbolizer, this); } else if (symbolizer instanceof PolygonSymbolizer) { symbolizerWrapper = new PolygonSymbolizerWrapper(symbolizer, this); } else if (symbolizer instanceof TextSymbolizer) { symbolizerWrapper = new TextSymbolizerWrapper(symbolizer, this, getType()); } else if (symbolizer instanceof RasterSymbolizer) { symbolizerWrapper = new RasterSymbolizerWrapper(symbolizer, this); } return symbolizerWrapper; }
Example #20
Source File: LineSymbolizerWrapper.java From hortonmachine with GNU General Public License v3.0 | 6 votes |
private void initEndPointSymbolizers() { for( Symbolizer x : super.getParent().getRule().getSymbolizers() ) { if (x instanceof PointSymbolizer) { PointSymbolizer pnt = (PointSymbolizer) x; Expression ex = pnt.getGeometry(); boolean endpnt = ex instanceof FilterFunction_endPoint; boolean startpnt = ex instanceof FilterFunction_startPoint; if (endpnt || startpnt) { GraphicalSymbol gs = pnt.getGraphic().graphicalSymbols().get(0); if (gs instanceof Mark) { String name = ((Mark) gs).getWellKnownName().evaluate(null, String.class); if (StyleUtilities.lineEndStyles.values().contains(name)) { if (endpnt) { endPointStyle = new PointSymbolizerWrapper(pnt, super.getParent()); } else if (startpnt) { startPointStyle = new PointSymbolizerWrapper(pnt, super.getParent()); } } } } } } }
Example #21
Source File: Utils.java From gama with GNU General Public License v3.0 | 6 votes |
/** * Create a default point style. * * @return the created style. */ public static Style createPointStyle() { final Graphic gr = styleFactory.createDefaultGraphic(); final Mark mark = styleFactory.getCircleMark(); mark.setStroke(styleFactory.createStroke(filterFactory.literal(Color.BLUE), filterFactory.literal(1))); mark.setFill(styleFactory.createFill(filterFactory.literal(Color.CYAN))); gr.graphicalSymbols().clear(); gr.graphicalSymbols().add(mark); gr.setSize(filterFactory.literal(5)); /* * Setting the geometryPropertyName arg to null signals that we want to draw the default geomettry of features */ final PointSymbolizer sym = styleFactory.createPointSymbolizer(gr, null); final Rule rule = styleFactory.createRule(); rule.symbolizers().add(sym); final FeatureTypeStyle fts = styleFactory.createFeatureTypeStyle(new Rule[] { rule }); final Style style = styleFactory.createStyle(); style.featureTypeStyles().add(fts); return style; }
Example #22
Source File: SelectedSymbolTest.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * Gets the graphic. * * @param symbolizer the symbolizer * @return the graphic */ private Graphic getGraphic(Symbolizer symbolizer) { Graphic graphic = null; if (symbolizer instanceof PointSymbolizerImpl) { PointSymbolizer pointSymbolizer = (PointSymbolizer) symbolizer; graphic = pointSymbolizer.getGraphic(); } else if (symbolizer instanceof PolygonSymbolizerImpl) { PolygonSymbolizer polygonSymbolizer = (PolygonSymbolizer) symbolizer; if (polygonSymbolizer != null) { Fill fill = polygonSymbolizer.getFill(); if (fill != null) { graphic = fill.getGraphicFill(); } } } return graphic; }
Example #23
Source File: SLDTreeLeafFactoryTest.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * 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); }
Example #24
Source File: SLDTreeLeafPointTest.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Test method for {@link * com.sldeditor.common.tree.leaf.SLDTreeLeafPoint#createStroke(org.opengis.style.Symbolizer)}. */ @Test public void testCreateStroke() { SLDTreeLeafPoint leaf = new SLDTreeLeafPoint(); PointSymbolizer pointSymbolizer = DefaultSymbols.createDefaultPointSymbolizer(); leaf.removeStroke(pointSymbolizer); // Does nothing }
Example #25
Source File: SLDTreeLeafPointTest.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Test method for {@link * com.sldeditor.common.tree.leaf.SLDTreeLeafPoint#removeStroke(org.opengis.style.Symbolizer)}. */ @Test public void testRemoveStroke() { SLDTreeLeafPoint leaf = new SLDTreeLeafPoint(); PointSymbolizer pointSymbolizer = DefaultSymbols.createDefaultPointSymbolizer(); leaf.removeStroke(pointSymbolizer); // Does nothing }
Example #26
Source File: SLDTreeLeafPointTest.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Test method for {@link * com.sldeditor.common.tree.leaf.SLDTreeLeafPoint#getStroke(org.opengis.style.Symbolizer)}. */ @Test public void testGetStroke() { SLDTreeLeafPoint leaf = new SLDTreeLeafPoint(); assertNull(leaf.getStroke(null)); assertNull(leaf.getStroke(DefaultSymbols.createDefaultPointSymbolizer())); PointSymbolizer pointSymbolizer = DefaultSymbols.createDefaultPointSymbolizer(); assertNull(leaf.getStroke(pointSymbolizer)); }
Example #27
Source File: SLDUtilsTest.java From sldeditor with GNU General Public License v3.0 | 5 votes |
@Test public void testCreateSLDFromStringGeoServer() { SLDData sldData = new SLDData(null, expectedSld); String geoserverUrl = "http://localhost:8080/geoserver"; GeoServerConnection connectionData = new GeoServerConnection(); try { connectionData.setUrl(new URL(geoserverUrl)); } catch (MalformedURLException e) { e.printStackTrace(); } sldData.setConnectionData(connectionData); StyledLayerDescriptor sld = SLDUtils.createSLDFromString(null); assertNull(sld); sld = SLDUtils.createSLDFromString(sldData); 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()); // Check resource locator geoserverUrl = geoserverUrl + "/styles/"; assertTrue(geoserverUrl.compareTo(sldData.getResourceLocator().toExternalForm()) == 0); }
Example #28
Source File: DefaultSymbols.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Creates the default point symbolizer. * * @return the point symbolizer */ public static PointSymbolizer createDefaultPointSymbolizer() { String geometryFieldName = null; Expression geometryField = ff.property(geometryFieldName); List<GraphicalSymbol> symbolList = new ArrayList<>(); Stroke stroke = null; AnchorPoint anchorPoint = null; Displacement displacement = null; Fill fill = styleFactory.createFill(ff.literal(DEFAULT_MARKER_COLOUR)); GraphicalSymbol symbol = styleFactory.mark(ff.literal(DEFAULT_MARKER_SYMBOL), fill, stroke); symbolList.add(symbol); Graphic graphic = styleFactory.graphic( symbolList, ff.literal(DEFAULT_COLOUR_OPACITY), ff.literal(DEFAULT_MARKER_SYMBOL_SIZE), ff.literal(0.0), anchorPoint, displacement); return styleFactory.pointSymbolizer( Localisation.getString(SLDTreeTools.class, "TreeItem.newMarker"), geometryField, null, null, graphic); }
Example #29
Source File: SLDTreeTools.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** Adds the new marker symbolizer. */ public void addNewMarker() { if (symbolTree == null) { return; } // Store current state of the SLD before the add Object oldValueObj = sldWriter.encodeSLD(null, SelectedSymbol.getInstance().getSld()); PointSymbolizer newPointSymbolizer = DefaultSymbols.createDefaultPointSymbolizer(); DefaultMutableTreeNode ruleNode = getRuleTreeNode(); SelectedSymbol.getInstance().addSymbolizerToRule(newPointSymbolizer); DefaultMutableTreeNode newNode = sldTree.addObject(ruleNode, newPointSymbolizer, true); // Select the item just added if (newNode != null) { sldTree.addObject( newNode, SLDTreeLeafFactory.getInstance().getFill(newPointSymbolizer), true); 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)); } }
Example #30
Source File: SLDTreeLeafPointTest.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Test method for {@link * com.sldeditor.common.tree.leaf.SLDTreeLeafPoint#getFill(org.opengis.style.Symbolizer)}. */ @Test public void testGetFill() { SLDTreeLeafPoint leaf = new SLDTreeLeafPoint(); assertNull(leaf.getFill(null)); assertNull(leaf.getFill(DefaultSymbols.createDefaultPolygonSymbolizer())); PointSymbolizer pointSymbolizer = DefaultSymbols.createDefaultPointSymbolizer(); Fill expectedFill = null; Graphic graphic = pointSymbolizer.getGraphic(); if (graphic != null) { List<GraphicalSymbol> symbolList = graphic.graphicalSymbols(); if ((symbolList != null) && !symbolList.isEmpty()) { GraphicalSymbol obj = symbolList.get(0); if (obj != null) { if (obj instanceof MarkImpl) { MarkImpl mark = (MarkImpl) obj; expectedFill = mark.getFill(); } } } } assertEquals(expectedFill, leaf.getFill(pointSymbolizer)); }