public class DuplicatingStyleVisitor extends Object implements StyleVisitor
This class makes use of an internal stack to story the copied result, retrieve with a call to getCopy() after visiting:
DuplicatingStyleVisitor copyStyle = new DuplicatingStyleVisitor();
rule.accepts( copyStyle );
Rule rule = (Rule) copyStyle.getCopy();
This class is often used as a base for an anoymous subclass where a style transformation is needed (such as removing PointSymbolizers or changing the scale - see RescaleStyleVisitor for an example).
Modifier and Type | Field and Description |
---|---|
protected DuplicatingFilterVisitor |
copyFilter
We are using aggregation here to contain our DuplicatingFilterVisitor.
|
protected FilterFactory2 |
ff |
protected Stack<Object> |
pages
This is our internal stack; used to maintain state as we copy sub elements.
|
protected StyleFactory |
sf |
protected boolean |
STRICT |
Constructor and Description |
---|
DuplicatingStyleVisitor() |
DuplicatingStyleVisitor(StyleFactory styleFactory) |
DuplicatingStyleVisitor(StyleFactory styleFactory,
FilterFactory2 filterFactory) |
Modifier and Type | Method and Description |
---|---|
protected AnchorPoint |
copy(AnchorPoint anchorPoint)
Null safe copy of anchor point.
|
protected ChannelSelection |
copy(ChannelSelection channelSelection) |
protected ColorMap |
copy(ColorMap colorMap) |
protected ColorMapEntry |
copy(ColorMapEntry entry) |
protected ContrastEnhancement |
copy(ContrastEnhancement contrast) |
protected Description |
copy(Description desc)
Null safe copy of description
|
protected Displacement |
copy(Displacement displacement)
Null safe copy of displacement.
|
protected Expression |
copy(Expression expression)
Null safe expression copy.
|
protected Extent |
copy(Extent extent) |
protected Extent[] |
copy(Extent[] extents) |
protected ExternalGraphic |
copy(ExternalGraphic externalGraphic) |
protected Fill |
copy(Fill fill)
Null safe fill copy
|
protected Filter |
copy(Filter filter)
Null safe copy of filter.
|
protected float[] |
copy(float[] array)
Null safe copy of float array.
|
protected Font |
copy(Font font)
Null safe copy of a single font
|
protected Graphic |
copy(Graphic graphic)
Null safe graphic copy
|
protected Halo |
copy(Halo halo)
Null safe copy of halo.
|
protected LabelPlacement |
copy(LabelPlacement placement) |
protected <K,V> Map<K,V> |
copy(Map<K,V> customProperties)
Null safe map copy, used for external graphic custom properties.
|
protected Mark |
copy(Mark mark) |
protected OverlapBehavior |
copy(OverlapBehavior ob) |
protected SelectedChannelType |
copy(SelectedChannelType selectedChannelType) |
protected SelectedChannelType[] |
copy(SelectedChannelType[] channels) |
protected ShadedRelief |
copy(ShadedRelief shaded)
Null safe copy of shaded relief.
|
protected Stroke |
copy(Stroke stroke)
Null safe copy of stroke.
|
protected Symbol |
copy(Symbol symbol) |
protected Symbolizer |
copy(Symbolizer symbolizer) |
protected List<Expression> |
copyExpressions(List<Expression> expressions)
Copy list of expressions.
|
protected List<Font> |
copyFonts(List<Font> fonts)
Null safe copy of font list.
|
Object |
getCopy() |
void |
setStrict(boolean strict)
True if we should enforce equality after a copy.
|
void |
visit(AnchorPoint ap)
Called when accept is called on a anchor point
|
void |
visit(ChannelSelection cs)
Called when accept is called on a raster
ChannelSelection element |
void |
visit(ColorMap colorMap)
Called when accept is called on a raster color map
|
void |
visit(ColorMapEntry colorMapEntry)
Called when accept is called on a raster color map entry
|
void |
visit(ContrastEnhancement contrastEnhancement)
Called when accept is called on a raster ContrastEnhancement element
|
void |
visit(Displacement dis)
Called when accept is called on a displacement
|
void |
visit(ExternalGraphic exgr)
Called when accept is called on a external graphic
|
void |
visit(FeatureTypeConstraint ftc)
Called when accept is called on a FeatureTypeConstraint.
|
void |
visit(FeatureTypeStyle fts)
Called when accept is called on a fetauretypestyle
|
void |
visit(Fill fill)
Called when accept is called on a fill
|
void |
visit(Graphic gr)
Called when accept is called on a graphic
|
void |
visit(Halo halo)
Called when accept is called on a halo
|
void |
visit(ImageOutline outline)
Called when accept is called on a raster
ImageOutline element |
void |
visit(LinePlacement lp)
Called when accept is called on a Line Placement
|
void |
visit(LineSymbolizer line)
Called when accept is called on a linesymbolizer
|
void |
visit(Mark mark)
Called when accept is called on a mark
|
void |
visit(NamedLayer layer)
Called when accept is called on a NamedLayer.
|
void |
visit(OverlapBehavior ob)
Called when accept is called on a raster
OverlapBehavior element |
void |
visit(PointPlacement pp)
Called when accept is called on a Point Placement
|
void |
visit(PointSymbolizer ps)
Called when accept is called on a pointsymbolizer
|
void |
visit(PolygonSymbolizer poly)
Called when accept is called on a polygon symbolizer
|
void |
visit(RasterSymbolizer raster)
Called when accept is called on a rastersymbolizer
|
void |
visit(Rule rule)
Called when accept is called on a rule
|
void |
visit(SelectedChannelType sct)
Called when accept is called on a raster
SelectedChannelType element |
void |
visit(ShadedRelief sr)
Called when accept is called on a raster
ShadedRelief element |
void |
visit(Stroke stroke)
Called when accept is called on a stroke
|
void |
visit(Style style)
Called when accept is called on a Style.
|
void |
visit(StyledLayerDescriptor sld)
Called when accept is called on a StyledLayerDescriptor.
|
void |
visit(Symbolizer sym)
since it is impossible to create a Symbolizer this method should generate an exception or
warning.
|
void |
visit(TextSymbolizer text)
Called when accept is called on a textsymbolizer
|
void |
visit(UserLayer layer)
Called when accept is called on a UserLayer.
|
protected final StyleFactory sf
protected final FilterFactory2 ff
protected boolean STRICT
protected final DuplicatingFilterVisitor copyFilter
public DuplicatingStyleVisitor()
public DuplicatingStyleVisitor(StyleFactory styleFactory)
public DuplicatingStyleVisitor(StyleFactory styleFactory, FilterFactory2 filterFactory)
public void setStrict(boolean strict)
strict
- public Object getCopy()
public void visit(StyledLayerDescriptor sld)
StyleVisitor
visit
in interface StyleVisitor
sld
- The StyledLayerDescriptor to visitpublic void visit(NamedLayer layer)
StyleVisitor
visit
in interface StyleVisitor
layer
- The NamedLayer to visitpublic void visit(UserLayer layer)
StyleVisitor
visit
in interface StyleVisitor
layer
- The UserLayer to visitpublic void visit(Style style)
StyleVisitor
visit
in interface StyleVisitor
style
- The style to visitpublic void visit(Rule rule)
StyleVisitor
visit
in interface StyleVisitor
rule
- the rule to visitpublic void visit(FeatureTypeStyle fts)
StyleVisitor
visit
in interface StyleVisitor
fts
- the feature type styler to visitprotected List<Expression> copyExpressions(List<Expression> expressions)
expressions
- protected Expression copy(Expression expression)
This method will perform a null check, and save you some lines of code:
copy.setBackgroundColor( copyExpr( fill.getColor()) );
sion
- protected Graphic copy(Graphic graphic)
graphic
- protected Fill copy(Fill fill)
graphic
- protected float[] copy(float[] array)
array
- protected <K,V> Map<K,V> copy(Map<K,V> customProperties)
customProperties
- protected Stroke copy(Stroke stroke)
stroke
- protected ShadedRelief copy(ShadedRelief shaded)
shaded
- protected Description copy(Description desc)
shaded
- protected ExternalGraphic copy(ExternalGraphic externalGraphic)
protected ColorMapEntry copy(ColorMapEntry entry)
protected Symbolizer copy(Symbolizer symbolizer)
protected OverlapBehavior copy(OverlapBehavior ob)
protected ContrastEnhancement copy(ContrastEnhancement contrast)
protected SelectedChannelType[] copy(SelectedChannelType[] channels)
protected SelectedChannelType copy(SelectedChannelType selectedChannelType)
protected ChannelSelection copy(ChannelSelection channelSelection)
protected List<Font> copyFonts(List<Font> fonts)
Right now style visitor does not let us visit fonts!
fonts
- protected Halo copy(Halo halo)
halo
- protected Displacement copy(Displacement displacement)
displacement
- protected LabelPlacement copy(LabelPlacement placement)
protected AnchorPoint copy(AnchorPoint anchorPoint)
anchorPoint
- public void visit(Fill fill)
StyleVisitor
visit
in interface StyleVisitor
fill
- the fill to be visitedpublic void visit(Stroke stroke)
StyleVisitor
visit
in interface StyleVisitor
stroke
- the stroke to visitpublic void visit(Symbolizer sym)
StyleVisitor
visit
in interface StyleVisitor
sym
- the symbolizer to visitpublic void visit(PointSymbolizer ps)
StyleVisitor
visit
in interface StyleVisitor
ps
- the point symbolizer to visitpublic void visit(LineSymbolizer line)
StyleVisitor
visit
in interface StyleVisitor
line
- the line symbolizer to visitpublic void visit(PolygonSymbolizer poly)
StyleVisitor
visit
in interface StyleVisitor
poly
- the polygon symbolizer to visitpublic void visit(TextSymbolizer text)
StyleVisitor
visit
in interface StyleVisitor
text
- the text symbolizer to visitpublic void visit(RasterSymbolizer raster)
StyleVisitor
visit
in interface StyleVisitor
raster
- the raster symbolizer to visitpublic void visit(Graphic gr)
StyleVisitor
visit
in interface StyleVisitor
gr
- the graphic to visitpublic void visit(Mark mark)
StyleVisitor
visit
in interface StyleVisitor
mark
- the mark to visitpublic void visit(ExternalGraphic exgr)
StyleVisitor
visit
in interface StyleVisitor
exgr
- the external graphic to visitpublic void visit(PointPlacement pp)
StyleVisitor
visit
in interface StyleVisitor
pp
- the point placement to visitpublic void visit(AnchorPoint ap)
StyleVisitor
visit
in interface StyleVisitor
ap
- the anchor point to visitpublic void visit(Displacement dis)
StyleVisitor
visit
in interface StyleVisitor
dis
- the displacement to visitpublic void visit(LinePlacement lp)
StyleVisitor
visit
in interface StyleVisitor
lp
- the line placement to visitpublic void visit(Halo halo)
StyleVisitor
visit
in interface StyleVisitor
halo
- the halo to visitpublic void visit(FeatureTypeConstraint ftc)
StyleVisitor
visit
in interface StyleVisitor
ftc
- The FeatureTypeConstraint to visitpublic void visit(ColorMap colorMap)
StyleVisitor
visit
in interface StyleVisitor
colorMap
- the color map to visitpublic void visit(ColorMapEntry colorMapEntry)
StyleVisitor
visit
in interface StyleVisitor
colorMapEntry
- the color map to visitpublic void visit(ContrastEnhancement contrastEnhancement)
StyleVisitor
visit
in interface StyleVisitor
contrastEnhancement
- the ContrastEnhancement
to visit.public void visit(ImageOutline outline)
StyleVisitor
ImageOutline
elementvisit
in interface StyleVisitor
outline
- the ImageOutline
to visit.public void visit(ChannelSelection cs)
StyleVisitor
ChannelSelection
elementvisit
in interface StyleVisitor
cs
- the ChannelSelection
to visit.public void visit(OverlapBehavior ob)
StyleVisitor
OverlapBehavior
elementvisit
in interface StyleVisitor
public void visit(SelectedChannelType sct)
StyleVisitor
SelectedChannelType
elementvisit
in interface StyleVisitor
public void visit(ShadedRelief sr)
StyleVisitor
ShadedRelief
elementvisit
in interface StyleVisitor
Copyright © 1996–2019 Geotools. All rights reserved.