org.geotools.styling.Graphic Java Examples
The following examples show how to use
org.geotools.styling.Graphic.
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: 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 #2
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 #3
Source File: FieldConfigWindBarbs.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * Sets the value. * * @param symbolizerType the symbolizer type * @param fieldConfigManager the field config manager * @param multiOptionPanel the multi option panel * @param graphic the graphic * @param symbol the symbol */ @Override public void setValue( Class<?> symbolizerType, GraphicPanelFieldManager fieldConfigManager, FieldConfigSymbolType multiOptionPanel, Graphic graphic, GraphicalSymbol symbol) { if (symbol != null) { if (symbol instanceof Mark) { MarkImpl markerSymbol = (MarkImpl) symbol; if (getConfigField() != null) { getConfigField().populate(markerSymbol.getWellKnownName()); } if (multiOptionPanel != null) { multiOptionPanel.setSelectedItem(WINDBARB_SYMBOL_KEY); } } } }
Example #4
Source File: FieldConfigFilename.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * Sets the value. * * @param symbolizerType the symbolizer type * @param fieldConfigManager the field config manager * @param multiOptionPanel the multi option panel * @param graphic the graphic * @param symbol the symbol */ @Override public void setValue( Class<?> symbolizerType, GraphicPanelFieldManager fieldConfigManager, FieldConfigSymbolType multiOptionPanel, Graphic graphic, GraphicalSymbol symbol) { if (symbol instanceof ExternalGraphicImpl) { ExternalGraphicImpl markerSymbol = (ExternalGraphicImpl) symbol; if (externalGraphicPanel != null) { externalGraphicPanel.setValue(markerSymbol); } if (multiOptionPanel != null) { multiOptionPanel.setSelectedItem(EXTERNAL_SYMBOL_KEY); } FieldConfigBase opacity = fieldConfigManager.get(FieldIdEnum.OVERALL_OPACITY); if (opacity != null) { opacity.populate(graphic.getOpacity()); } } }
Example #5
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 #6
Source File: RuleDetails.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * @param existingRule * @return */ private Graphic[] updateLegend(org.geotools.styling.Rule existingRule) { int index; GraphicLegend existingLegend = existingRule.getLegend(); Graphic[] legendGraphics = null; if (existingLegend != null) { int legendGraphicCount = existingLegend.graphicalSymbols().size(); legendGraphics = new Graphic[legendGraphicCount]; index = 0; for (GraphicalSymbol graphicalSymbol : existingLegend.graphicalSymbols()) { legendGraphics[index] = (Graphic) graphicalSymbol; index++; } } else { legendGraphics = new Graphic[0]; } return legendGraphics; }
Example #7
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 #8
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 #9
Source File: SLDEditorBufferedImageLegendGraphicBuilder.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * Gets a numeric value for the given graphic * * @param feature sample to be used for evals * @param pointSymbolizer symbolizer * @param defaultSize size to use is none can be taken from the graphic */ private double getGraphicSize(Feature feature, Graphic graphic, int defaultSize) { if (graphic != null) { Expression sizeExp = graphic.getSize(); if (sizeExp instanceof Literal) { Object size = sizeExp.evaluate(feature); if (size != null) { if (size instanceof Double) { return (Double) size; } try { return Double.parseDouble(size.toString()); } catch (NumberFormatException e) { return defaultSize; } } } } return defaultSize; }
Example #10
Source File: GetMinimumVersionTest.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** Test method for PointFillDetails */ @Test public void testPointGetMinimumVersion() { PointFillDetails details = new PointFillDetails(); details.getMinimumVersion(null, null, null); Graphic graphic = styleFactory.createDefaultGraphic(); graphic.setDisplacement(styleFactory.createDisplacement(ff.literal(6.0), ff.literal(7.0))); graphic.setAnchorPoint(styleFactory.anchorPoint(ff.literal(6.0), ff.literal(7.0))); List<VendorOptionPresent> vendorOptionsPresentList = null; Object parentObj = null; details.getMinimumVersion(parentObj, graphic, vendorOptionsPresentList); vendorOptionsPresentList = new ArrayList<VendorOptionPresent>(); details.getMinimumVersion(parentObj, graphic, vendorOptionsPresentList); assertTrue(vendorOptionsPresentList.size() == 0); }
Example #11
Source File: GetMinimumVersionTest.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** Test method for StrokeDetails */ @Test public void testStrokeGetMinimumVersion() { StrokeDetails details = new StrokeDetails(); details.getMinimumVersion(null, null, null); Stroke stroke = styleFactory.createStroke(ff.literal("#654321"), ff.literal(3.2)); Graphic graphicStroke = styleFactory.createDefaultGraphic(); stroke.setGraphicStroke(graphicStroke); List<VendorOptionPresent> vendorOptionsPresentList = null; Object parentObj = null; details.getMinimumVersion(parentObj, stroke, vendorOptionsPresentList); vendorOptionsPresentList = new ArrayList<VendorOptionPresent>(); details.getMinimumVersion(parentObj, stroke, vendorOptionsPresentList); assertTrue(vendorOptionsPresentList.size() == 0); }
Example #12
Source File: MultiLayerMarkerSymbol.java From sldeditor with GNU General Public License v3.0 | 6 votes |
@Override public List<Graphic> convert(JsonElement element) { if (element == null) return null; List<Graphic> markList = null; JsonArray layerList = element.getAsJsonArray(); if (layerList.size() > 0) { markList = new ArrayList<Graphic>(); for (int index = 0; index < layerList.size(); index++) { JsonObject obj = layerList.get(index).getAsJsonObject(); List<Graphic> markerSymbolList = SymbolManager.getInstance().getMarkerList( obj.get(MultiLayerMarkerSymbolKeys.MARKER).getAsJsonObject()); if (markerSymbolList != null) { markList.addAll(markerSymbolList); } } } return markList; }
Example #13
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 #14
Source File: SymbolManager.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * Gets the marker list. * * @param jsonSymbol the json symbol * @return the marker list */ public List<Graphic> getMarkerList(JsonObject jsonSymbol) { List<Graphic> markList = null; for(String markSymbolType : markSymbolMap.keySet()) { JsonElement obj = jsonSymbol.get(markSymbolType); if(obj != null) { EsriMarkSymbolInterface esriMarkSymbol = markSymbolMap.get(markSymbolType); markList = esriMarkSymbol.convert(obj); break; } } return markList; }
Example #15
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 #16
Source File: GetMinimumVersionTest.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** Test method for PolygonFillDetails */ @Test public void testPolygonFillGetMinimumVersion() { PolygonFillDetails details = new PolygonFillDetails(); details.getMinimumVersion(null, null, null); Fill fill = styleFactory.createFill(ff.literal("#654321"), ff.literal(3.2)); Graphic graphicFill = styleFactory.createDefaultGraphic(); fill.setGraphicFill(graphicFill); List<VendorOptionPresent> vendorOptionsPresentList = null; Object parentObj = null; details.getMinimumVersion(parentObj, fill, vendorOptionsPresentList); vendorOptionsPresentList = new ArrayList<VendorOptionPresent>(); details.getMinimumVersion(parentObj, fill, vendorOptionsPresentList); assertTrue(vendorOptionsPresentList.size() == 0); }
Example #17
Source File: StyleGenerator.java From constellation with Apache License 2.0 | 5 votes |
private static Style createPointStyle() { final StyleFactory styleFactory = CommonFactoryFinder.getStyleFactory(); org.opengis.filter.FilterFactory filterFactory = CommonFactoryFinder.getFilterFactory(); final Mark mark = styleFactory.getCircleMark(); mark.setStroke(styleFactory.createStroke(filterFactory.literal(Color.BLUE), filterFactory.literal(1))); mark.setFill(styleFactory.createFill(filterFactory.literal(Color.CYAN))); final Graphic gr = styleFactory.getDefaultGraphic(); 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 geometry of features final PointSymbolizer sym = styleFactory.createPointSymbolizer(gr, null); // make rule final Rule rule = styleFactory.createRule(); rule.symbolizers().add(sym); final FeatureTypeStyle fts = styleFactory.createFeatureTypeStyle(new Rule[]{rule}); final Style style = styleFactory.createStyle(); style.getDescription().setTitle("Point Style"); style.featureTypeStyles().add(fts); return style; }
Example #18
Source File: StyleUtilities.java From hortonmachine with GNU General Public License v3.0 | 5 votes |
/** * Changes the rotation value inside a rule. * * @param rule the {@link Rule}. * @param newRotation the new rotation value in degrees. */ public static void changeRotation( Rule rule, int newRotation ) { PointSymbolizer pointSymbolizer = StyleUtilities.pointSymbolizerFromRule(rule); Graphic graphic = SLD.graphic(pointSymbolizer); graphic.setRotation(ff.literal(newRotation)); // Mark oldMark = SLDs.mark(pointSymbolizer); // oldMark.setSize(ff.literal(newRotation)); }
Example #19
Source File: DefaultSymbols.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Creates a default graphic fill. * * @return the fill */ public static Fill createDefaultGraphicFill() { Graphic graphicFill = styleFactory.createDefaultGraphic(); Expression colour = ff.literal(DEFAULT_FILL_COLOUR); Expression backgroundColour = null; Expression opacity = ff.literal(1.0); return styleFactory.createFill(colour, backgroundColour, opacity, graphicFill); }
Example #20
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 #21
Source File: FieldConfigArrow.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Sets the value. * * @param symbolizerType the symbolizer type * @param fieldConfigManager the field config manager * @param multiOptionPanel the multi option panel * @param graphic the graphic * @param symbol the symbol */ @Override public void setValue( Class<?> symbolizerType, GraphicPanelFieldManager fieldConfigManager, FieldConfigSymbolType multiOptionPanel, Graphic graphic, GraphicalSymbol symbol) { if ((symbol instanceof Mark) && (fieldConfigManager != null)) { MarkImpl markerSymbol = (MarkImpl) symbol; FillImpl fill = markerSymbol.getFill(); if (fill != null) { Expression expFillColour = fill.getColor(); Expression expFillColourOpacity = fill.getOpacity(); FieldConfigBase field = fieldConfigManager.get(FieldIdEnum.FILL_COLOUR); if (field != null) { field.populate(expFillColour); } field = fieldConfigManager.get(FieldIdEnum.OVERALL_OPACITY); if (field != null) { field.populate(expFillColourOpacity); } } if (arrowPanel != null) { arrowPanel.populateExpression(markerSymbol.getWellKnownName().toString()); } if (multiOptionPanel != null) { multiOptionPanel.setSelectedItem(ARROW_SYMBOL_KEY); } } }
Example #22
Source File: StyleUtilities.java From hortonmachine with GNU General Public License v3.0 | 5 votes |
/** * Collect all {@link ExternalGraphic}s from the given {@link Graphic}. * * @param graphic the graphic to check. * @return the extracted {@link ExternalGraphic}s. */ public static List<ExternalGraphic> externalGraphicsFromGraphic( Graphic graphic ) { List<ExternalGraphic> gList = new ArrayList<ExternalGraphic>(); for( GraphicalSymbol gs : graphic.graphicalSymbols() ) { if ((gs != null) && (gs instanceof ExternalGraphic)) { ExternalGraphic externalGraphic = (ExternalGraphic) gs; gList.add(externalGraphic); } } return gList; }
Example #23
Source File: SymbolTypeFactory.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Sets the symbol value. * * @param symbolizerType the symbolizer type * @param fieldConfigManager the field config manager * @param graphic the graphic * @param symbol the new value */ public void setValue( Class<?> symbolizerType, GraphicPanelFieldManager fieldConfigManager, Graphic graphic, GraphicalSymbol symbol) { for (FieldState panel : classMap.values()) { if ((panel != null) && panel.accept(symbol)) { panel.setValue( symbolizerType, fieldConfigManager, symbolTypeField, graphic, symbol); } } }
Example #24
Source File: StyleUtilities.java From hortonmachine with GNU General Public License v3.0 | 5 votes |
/** * Changes the size of a mark inside a rule. * * @param rule the {@link Rule}. * @param newSize the new size. */ public static void changeMarkSize( Rule rule, int newSize ) { PointSymbolizer pointSymbolizer = StyleUtilities.pointSymbolizerFromRule(rule); Graphic graphic = SLD.graphic(pointSymbolizer); graphic.setSize(ff.literal(newSize)); // Mark oldMark = SLDs.mark(pointSymbolizer); // oldMark.setSize(ff.literal(newSize)); // Graphic graphic = SLDs.graphic(pointSymbolizer); }
Example #25
Source File: StyleUtilities.java From hortonmachine with GNU General Public License v3.0 | 5 votes |
/** * Generates a style based on a graphic. * * @param graphicsPath the graphic. * @return the generated style. * @throws IOException */ public static StyleWrapper createStyleFromGraphic( File graphicsPath ) throws IOException { String name = graphicsPath.getName(); ExternalGraphic exGraphic = null; if (name.toLowerCase().endsWith(".png")) { exGraphic = sf.createExternalGraphic(graphicsPath.toURI().toURL(), "image/png"); } else if (name.toLowerCase().endsWith(".svg")) { exGraphic = sf.createExternalGraphic(graphicsPath.toURI().toURL(), "image/svg+xml"); } else if (name.toLowerCase().endsWith(".sld")) { StyledLayerDescriptor sld = readStyle(graphicsPath); Style style = SldUtilities.getDefaultStyle(sld); return new StyleWrapper(style); } if (exGraphic == null) { throw new IOException("Style could not be created!"); } Graphic gr = sf.createDefaultGraphic(); gr.graphicalSymbols().clear(); gr.graphicalSymbols().add(exGraphic); Expression size = ff.literal(20); gr.setSize(size); Rule rule = sf.createRule(); PointSymbolizer pointSymbolizer = sf.createPointSymbolizer(gr, null); rule.symbolizers().add(pointSymbolizer); FeatureTypeStyle featureTypeStyle = sf.createFeatureTypeStyle(); featureTypeStyle.rules().add(rule); Style namedStyle = sf.createStyle(); namedStyle.featureTypeStyles().add(featureTypeStyle); namedStyle.setName(FilenameUtils.removeExtension(name)); return new StyleWrapper(namedStyle); }
Example #26
Source File: SymbolizerWrapper.java From hortonmachine with GNU General Public License v3.0 | 5 votes |
/** * Set the stroke's {@link ExternalGraphic} path. * * <p>Currently one {@link ExternalGraphic} per {@link Symbolizer} is supported. * * <p>This is used for lines. * * @param externalGraphicPath the path to set. * @throws MalformedURLException */ public void setStrokeExternalGraphicStrokePath( String externalGraphicPath ) throws MalformedURLException { if (strokeExternalGraphicStroke == null) { Graphic graphic = null; LineSymbolizerWrapper lineSymbolizerWrapper = adapt(LineSymbolizerWrapper.class); PolygonSymbolizerWrapper polygonSymbolizerWrapper = adapt(PolygonSymbolizerWrapper.class); if (lineSymbolizerWrapper != null) { graphic = lineSymbolizerWrapper.getStrokeGraphicStroke(); if (graphic == null) { graphic = sb.createGraphic(); lineSymbolizerWrapper.setStrokeGraphicStroke(graphic); } } else if (polygonSymbolizerWrapper != null) { graphic = polygonSymbolizerWrapper.getStrokeGraphicStroke(); if (graphic == null) { graphic = sb.createGraphic(); polygonSymbolizerWrapper.setStrokeGraphicStroke(graphic); } } else { return; } graphic.graphicalSymbols().clear(); String urlStr = externalGraphicPath; if (!externalGraphicPath.startsWith("http:") && !externalGraphicPath.startsWith("file:")) { //$NON-NLS-1$ //$NON-NLS-2$ urlStr = "file:" + externalGraphicPath; //$NON-NLS-1$ } strokeExternalGraphicStroke = sb.createExternalGraphic(new URL(urlStr), getFormat(externalGraphicPath)); graphic.graphicalSymbols().add(strokeExternalGraphicStroke); } else { setExternalGraphicPath(externalGraphicPath, strokeExternalGraphicStroke); } }
Example #27
Source File: SymbolizerWrapper.java From hortonmachine with GNU General Public License v3.0 | 5 votes |
/** * Set the fill's {@link ExternalGraphic} path. * * <p>Currently one {@link ExternalGraphic} per {@link Symbolizer} is supported. * * <p>This is used for polygons. * * @param externalGraphicPath the path to set. * @throws MalformedURLException */ public void setFillExternalGraphicFillPath( String externalGraphicPath, double size ) throws MalformedURLException { Graphic graphic = null; PolygonSymbolizerWrapper polygonSymbolizerWrapper = adapt(PolygonSymbolizerWrapper.class); if (polygonSymbolizerWrapper != null) { graphic = polygonSymbolizerWrapper.getFillGraphicFill(); if (graphic == null) { graphic = sf.createDefaultGraphic(); } polygonSymbolizerWrapper.setFillGraphicFill(graphic); } else { return; } graphic.graphicalSymbols().clear(); String urlStr = externalGraphicPath; if (!externalGraphicPath.startsWith("http:") && !externalGraphicPath.startsWith("file:")) { //$NON-NLS-1$ //$NON-NLS-2$ urlStr = "file:" + externalGraphicPath; //$NON-NLS-1$ } if (fillExternalGraphicFill == null) { fillExternalGraphicFill = sb.createExternalGraphic(new URL(urlStr), getFormat(externalGraphicPath)); } else { setExternalGraphicPath(externalGraphicPath, fillExternalGraphicFill); } graphic.graphicalSymbols().add(fillExternalGraphicFill); FilterFactory ff = CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints()); graphic.setSize(ff.literal(size)); }
Example #28
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)); }
Example #29
Source File: GraphicViewer.java From gama with GNU General Public License v3.0 | 5 votes |
/** * TODO summary sentence for setGraphic ... * * @param graphic * @param mode * @param enabled */ public void setGraphic(final Graphic g, final Mode mode, final Color defaultColor) { Graphic graphic = g; boolean enabled = true; if (graphic == null) { final StyleBuilder builder = new StyleBuilder(); graphic = builder.createGraphic(null, builder.createMark(StyleBuilder.MARK_SQUARE, defaultColor), null); enabled = true; } this.width = SLDs.size(graphic); final String text = MessageFormat.format("{0,number,#0}", this.width); //$NON-NLS-1$ if (text != null) { this.size.setText(text); this.size.select(this.size.indexOf(text)); } boolean marked = false; if (graphic != null && graphic.graphicalSymbols() != null && !graphic.graphicalSymbols().isEmpty()) { for (final GraphicalSymbol symbol : graphic.graphicalSymbols()) { if (symbol instanceof Mark) { final Mark mark = (Mark) symbol; setMark(mark, mode); marked = true; break; } } } if (!marked) { setMark(null, mode); } this.enabled = this.enabled && enabled; }
Example #30
Source File: SLDExternalImagesTest.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Creates the graphic. * * @param url the url * @param styleFactory the style factory * @return the graphic */ private Graphic createGraphic(URL url, StyleFactory styleFactory) { List<GraphicalSymbol> symbolList = new ArrayList<GraphicalSymbol>(); ExternalGraphic externalGraphic = styleFactory.createExternalGraphic(url, "image/png"); symbolList.add(externalGraphic); Graphic graphicFill = styleFactory.graphicFill(symbolList, null, null, null, null, null); return graphicFill; }