本文整理汇总了Java中org.geotools.styling.PointSymbolizer.getGraphic方法的典型用法代码示例。如果您正苦于以下问题:Java PointSymbolizer.getGraphic方法的具体用法?Java PointSymbolizer.getGraphic怎么用?Java PointSymbolizer.getGraphic使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.geotools.styling.PointSymbolizer
的用法示例。
在下文中一共展示了PointSymbolizer.getGraphic方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFill
import org.geotools.styling.PointSymbolizer; //导入方法依赖的package包/类
@Override
public Fill getFill(Symbolizer symbolizer) {
if (symbolizer instanceof PointSymbolizer) {
PointSymbolizer point = (PointSymbolizer) symbolizer;
if (point != null) {
Graphic graphic = point.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;
return mark.getFill();
}
}
}
}
}
}
return null;
}
示例2: createFill
import org.geotools.styling.PointSymbolizer; //导入方法依赖的package包/类
@Override
public void createFill(Symbolizer symbolizer) {
if (symbolizer instanceof PointSymbolizer) {
PointSymbolizer point = (PointSymbolizer) symbolizer;
if (point != null) {
Graphic graphic = point.getGraphic();
if (graphic == null) {
graphic = styleFactory.createDefaultGraphic();
point.setGraphic(graphic);
}
if (graphic != null) {
if (graphic.graphicalSymbols().isEmpty()) {
Mark mark = styleFactory.getDefaultMark();
graphic.graphicalSymbols().add(mark);
}
}
}
}
}
示例3: getGraphic
import org.geotools.styling.PointSymbolizer; //导入方法依赖的package包/类
/**
* 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;
}
示例4: hasFill
import org.geotools.styling.PointSymbolizer; //导入方法依赖的package包/类
@Override
public boolean hasFill(Symbolizer symbolizer) {
if (symbolizer instanceof PointSymbolizer) {
PointSymbolizer point = (PointSymbolizer) symbolizer;
if (point != null) {
return (point.getGraphic() != null);
}
}
return false;
}
示例5: testGetFill
import org.geotools.styling.PointSymbolizer; //导入方法依赖的package包/类
/**
* 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));
}
示例6: pointFillWithAlpha
import org.geotools.styling.PointSymbolizer; //导入方法依赖的package包/类
/**
* Extracts the fill color with a given opacity from the
* {@link PointSymbolizer}.
*
* @param symbolizer
* the point symbolizer from which to get the color.
* @return the {@link Color} with transparency if available. Returns null if
* no color is available.
*/
public static Color pointFillWithAlpha(final PointSymbolizer symbolizer) {
if (symbolizer == null) {
return null;
}
final Graphic graphic = symbolizer.getGraphic();
if (graphic == null) {
return null;
}
for (final GraphicalSymbol gs : graphic.graphicalSymbols()) {
if (gs != null && gs instanceof Mark) {
final Mark mark = (Mark) gs;
final Fill fill = mark.getFill();
if (fill != null) {
Color colour = color(fill.getColor());
if (colour == null) {
return null;
}
Expression opacity = fill.getOpacity();
if (opacity == null)
opacity = ff.literal(1.0);
final float alpha = (float) Filters.asDouble(opacity);
colour = new Color(colour.getRed() / 255f, colour.getGreen() / 255f, colour.getBlue() / 255f,
alpha);
return colour;
}
}
}
return null;
}
示例7: pointStrokeColorWithAlpha
import org.geotools.styling.PointSymbolizer; //导入方法依赖的package包/类
/**
* Extracts the stroke color with a given opacity from the
* {@link PointSymbolizer}.
*
* @param symbolizer
* the point symbolizer from which to get the color.
* @return the {@link Color} with transparency if available. Returns null if
* no color is available.
*/
public static Color pointStrokeColorWithAlpha(final PointSymbolizer symbolizer) {
if (symbolizer == null) {
return null;
}
final Graphic graphic = symbolizer.getGraphic();
if (graphic == null) {
return null;
}
for (final GraphicalSymbol gs : graphic.graphicalSymbols()) {
if (gs != null && gs instanceof Mark) {
final Mark mark = (Mark) gs;
final Stroke stroke = mark.getStroke();
if (stroke != null) {
Color colour = color(stroke);
if (colour == null) {
return null;
}
Expression opacity = stroke.getOpacity();
if (opacity == null)
opacity = ff.literal(1.0);
final float alpha = (float) Filters.asDouble(opacity);
colour = new Color(colour.getRed() / 255f, colour.getGreen() / 255f, colour.getBlue() / 255f,
alpha);
return colour;
}
}
}
return null;
}
示例8: populate
import org.geotools.styling.PointSymbolizer; //导入方法依赖的package包/类
/**
* Populate.
*
* @param selectedSymbol the selected symbol
*/
/*
* (non-Javadoc)
*
* @see com.sldeditor.ui.iface.PopulateDetailsInterface#populate(com.sldeditor.ui.detail.selectedsymbol.SelectedSymbol)
*/
@Override
public void populate(SelectedSymbol selectedSymbol) {
Stroke stroke = null;
if (selectedSymbol != null) {
symbolizer = selectedSymbol.getSymbolizer();
if (symbolizer instanceof PointSymbolizer) {
PointSymbolizer pointSymbolizer = (PointSymbolizer) symbolizer;
Graphic graphic = pointSymbolizer.getGraphic();
List<GraphicalSymbol> graphicalSymbols = graphic.graphicalSymbols();
if (graphicalSymbols.size() > 0) {
GraphicalSymbol symbol = graphicalSymbols.get(0);
if (symbol instanceof MarkImpl) {
MarkImpl markerSymbol = (MarkImpl) symbol;
stroke = markerSymbol.getStroke();
}
}
} else if (symbolizer instanceof LineSymbolizer) {
LineSymbolizer lineSymbol = (LineSymbolizer) symbolizer;
stroke = lineSymbol.getStroke();
} else if (symbolizer instanceof PolygonSymbolizer) {
PolygonSymbolizer polygonSymbol = (PolygonSymbolizer) symbolizer;
stroke = polygonSymbol.getStroke();
}
}
Class<?> symbolizerClass = null;
if (symbolizer != null) {
symbolizerClass = symbolizer.getClass();
}
populateStroke(symbolizerClass, stroke);
}
示例9: createArrow
import org.geotools.styling.PointSymbolizer; //导入方法依赖的package包/类
/**
* Creates the arrow.
*
* @param angleFunction the angle function
* @param locationFunction the location function
* @param markerSymbol the marker symbol
* @param isSourceArrow the is source arrow
* @return the point symbolizer
*/
private static PointSymbolizer createArrow(FunctionName angleFunction,
FunctionName locationFunction, String markerSymbol, boolean isSourceArrow) {
String name = isSourceArrow
? Localisation.getString(SLDTreeTools.class, "TreeItem.sourceArrow")
: Localisation.getString(SLDTreeTools.class, "TreeItem.destArrow");
PointSymbolizer pointSymbolizer = createDefaultPointSymbolizer();
pointSymbolizer.setName(name);
Graphic graphic = pointSymbolizer.getGraphic();
graphic.setSize(ff.literal(DEFAULT_ARROW_SIZE));
List<GraphicalSymbol> graphicalSymbolList = graphic.graphicalSymbols();
MarkImpl mark = (MarkImpl) graphicalSymbolList.get(0);
Expression wellKnownName = ff.literal(markerSymbol);
mark.setWellKnownName(wellKnownName);
mark.getFill().setColor(ff.literal(DEFAULT_COLOUR));
// Arrow rotation
List<Expression> rotationArgumentList = new ArrayList<Expression>();
String geometryFieldName = "geom";
DataSourceInterface dsInfo = DataSourceFactory.getDataSource();
if (dsInfo != null) {
geometryFieldName = dsInfo.getGeometryFieldName();
}
rotationArgumentList.add(ff.property(geometryFieldName));
Expression rotation = FunctionManager.getInstance().createExpression(angleFunction,
rotationArgumentList);
if (isSourceArrow) {
graphic.setRotation(ff.add(ff.literal(DEGREES_180), rotation));
} else {
graphic.setRotation(rotation);
}
AnchorPoint anchorPoint = styleFactory.anchorPoint(ff.literal(0.5), ff.literal(0.5));
graphic.setAnchorPoint(anchorPoint);
// Set location of the arrow head
List<Expression> endPointArgumentList = new ArrayList<Expression>();
endPointArgumentList.add(ff.property(geometryFieldName));
Expression geometry = FunctionManager.getInstance().createExpression(locationFunction,
endPointArgumentList);
pointSymbolizer.setGeometry(geometry);
return pointSymbolizer;
}
示例10: externalGraphicSymbolVisitor
import org.geotools.styling.PointSymbolizer; //导入方法依赖的package包/类
/**
* Find the SLD graphical symbols.
*
* @param resourceLocator the resource locator
* @param sld the sld
* @param externalImageList the external image list
* @param process the process
*/
private static void externalGraphicSymbolVisitor(URL resourceLocator,
StyledLayerDescriptor sld, List<String> externalImageList,
ProcessGraphicSymbolInterface process) {
if (sld == null) {
return;
}
if (process == null) {
return;
}
for (StyledLayer styledLayer : sld.layers()) {
List<Style> styles = null;
if (styledLayer instanceof NamedLayer) {
NamedLayerImpl namedLayer = (NamedLayerImpl) styledLayer;
styles = namedLayer.styles();
} else if (styledLayer instanceof UserLayer) {
UserLayerImpl userLayer = (UserLayerImpl) styledLayer;
styles = userLayer.userStyles();
}
if (styles != null) {
for (Style style : styles) {
for (FeatureTypeStyle fts : style.featureTypeStyles()) {
for (Rule rule : fts.rules()) {
for (Symbolizer symbolizer : rule.symbolizers()) {
if (symbolizer instanceof PointSymbolizer) {
PointSymbolizer point = (PointSymbolizer) symbolizer;
if (point.getGraphic() != null) {
process.processGraphicalSymbol(resourceLocator,
point.getGraphic().graphicalSymbols(),
externalImageList);
}
} else if (symbolizer instanceof LineSymbolizer) {
LineSymbolizer line = (LineSymbolizer) symbolizer;
updateStroke(resourceLocator, line.getStroke(),
externalImageList,
process);
} else if (symbolizer instanceof PolygonSymbolizer) {
PolygonSymbolizer polygon = (PolygonSymbolizer) symbolizer;
updateStroke(resourceLocator, polygon.getStroke(),
externalImageList,
process);
updateFill(resourceLocator, polygon.getFill(),
externalImageList,
process);
}
}
}
}
}
}
}
}
示例11: getPointsStyle
import org.geotools.styling.PointSymbolizer; //导入方法依赖的package包/类
/**
* Create style for a points layer.
*
* @param schema
* @return a point style with labels.
*/
public static Style getPointsStyle( SimpleFeatureType schema ) {
Style style = SLD.createSimpleStyle(schema);
Rule origRule = style.featureTypeStyles().get(0).rules().get(0);
Symbolizer symbolizer = origRule.symbolizers().get(0);
PointSymbolizer pointSymbolizer = (PointSymbolizer) symbolizer;
Graphic graphic = pointSymbolizer.getGraphic();
// size
graphic.setSize(ff.literal("12"));
Mark pointMark = new MarkImpl();
pointMark.setWellKnownName(ff.literal("circle"));
graphic.graphicalSymbols().clear();
graphic.graphicalSymbols().add(pointMark);
Stroke stroke = pointMark.getStroke();
if (stroke == null) {
stroke = sf.createStroke(ff.literal("#940000"), ff.literal("1"), ff.literal("1"));
} else {
stroke.setColor(ff.literal("#940000"));
stroke.setOpacity(ff.literal("1"));
}
pointMark.setStroke(stroke);
Fill fill = pointMark.getFill();
if (fill == null) {
fill = sf.createFill(ff.literal("#FF0000"), ff.literal("0.5"));
} else {
fill.setColor(ff.literal("#FF0000"));
fill.setOpacity(ff.literal("0.5"));
}
pointMark.setFill(fill);
LabelPlacement labelPlacement = sf.createPointPlacement(sf.createAnchorPoint(ff.literal(0.0), ff.literal(0.0)),
sf.createDisplacement(ff.literal(0.0), ff.literal(0.0)), ff.literal(0.0));
Font font = sb.createFont("Arial", false, false, 12); //$NON-NLS-1$
TextSymbolizer textSymbolizer = sf.createTextSymbolizer(//
sf.createFill(ff.literal("#000000")), //
new Font[]{font}, //
null, //
ff.property(DataSource.TIMESTAMP_H), //
labelPlacement, //
null);
origRule.symbolizers().add(textSymbolizer);
// Rule rule = sf.createRule();
// rule.symbolizers().add(pointSymbolizer);
// rule.symbolizers().add(textSymbolizer);
//
// FeatureTypeStyle fts = sf.createFeatureTypeStyle(new Rule[]{rule});
// Style newStyle = sf.createStyle();
// newStyle.featureTypeStyles().add(fts);
return style;
}
示例12: updateSymbol
import org.geotools.styling.PointSymbolizer; //导入方法依赖的package包/类
/**
* Update symbol.
*/
private void updateSymbol() {
if (!Controller.getInstance().isPopulating()) {
Stroke stroke = getStroke();
if (symbolizer instanceof PointSymbolizer) {
PointSymbolizer pointSymbol = (PointSymbolizer) symbolizer;
Graphic graphic = pointSymbol.getGraphic();
GraphicalSymbol symbol = graphic.graphicalSymbols().get(0);
if (symbol instanceof MarkImpl) {
MarkImpl markerSymbol = (MarkImpl) symbol;
markerSymbol.setStroke(stroke);
SelectedSymbol.getInstance().replaceSymbolizer(pointSymbol);
this.fireUpdateSymbol();
}
} else if (symbolizer instanceof LineSymbolizer) {
LineSymbolizer lineSymbol = (LineSymbolizer) symbolizer;
lineSymbol.setStroke(stroke);
SelectedSymbol.getInstance().replaceSymbolizer(lineSymbol);
this.fireUpdateSymbol();
} else if (symbolizer instanceof PolygonSymbolizer) {
PolygonSymbolizer polygonSymbol = (PolygonSymbolizer) symbolizer;
polygonSymbol.setStroke(stroke);
SelectedSymbol.getInstance().replaceSymbolizer(polygonSymbol);
this.fireUpdateSymbol();
}
}
}