Package org.geotools.styling.visitor
Class DuplicatingStyleVisitor
- Object
-
- DuplicatingStyleVisitor
-
- All Implemented Interfaces:
StyleVisitor
- Direct Known Subclasses:
ChannelSelectionUpdateStyleVisitor,FeatureStyleScaleStyleVisitor,RenderingSelectorStyleVisitor,RescaleStyleVisitor,UomRescaleStyleVisitor
public class DuplicatingStyleVisitor extends Object implements StyleVisitor
Creates a deep copy of a Style, this class is *NOT THREAD SAFE*.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).
- Author:
- Jesse Eichar
-
-
Field Summary
Fields Modifier and Type Field Description protected DuplicatingFilterVisitorcopyFilterWe are using aggregation here to contain our DuplicatingFilterVisitor.protected FilterFactoryffprotected Stack<Object>pagesThis is our internal stack; used to maintain state as we copy sub elements.protected StyleFactorysfprotected booleanSTRICT
-
Constructor Summary
Constructors Constructor Description DuplicatingStyleVisitor()DuplicatingStyleVisitor(StyleFactory styleFactory)DuplicatingStyleVisitor(StyleFactory styleFactory, FilterFactory filterFactory)DuplicatingStyleVisitor(StyleFactory styleFactory, FilterFactory filterFactory, DuplicatingFilterVisitor filterCloner)Builds a new duplicating style visitor using a customDuplicatingStyleVisitor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected float[]copy(float[] array)Null safe copy of float array.protected <K,V>
Map<K,V>copy(Map<K,V> customProperties)Null safe map copy, used for external graphic custom properties.protected Expressioncopy(Expression expression)Null safe expression copy.protected Filtercopy(Filter filter)Null safe copy of filter.protected AnchorPointcopy(AnchorPoint anchorPoint)Null safe copy of anchor point.protected ChannelSelectioncopy(ChannelSelection channelSelection)protected ColorMapcopy(ColorMap colorMap)protected ColorMapEntrycopy(ColorMapEntry entry)protected ContrastEnhancementcopy(ContrastEnhancement contrast)protected Descriptioncopy(Description desc)Null safe copy of descriptionprotected Displacementcopy(Displacement displacement)Null safe copy of displacement.protected Extentcopy(Extent extent)protected Extent[]copy(Extent... extents)protected ExternalGraphiccopy(ExternalGraphic externalGraphic)protected Fillcopy(Fill fill)Null safe fill copyprotected Fontcopy(Font font)Null safe copy of a single fontprotected Graphiccopy(Graphic graphic)Null safe graphic copyprotected Halocopy(Halo halo)Null safe copy of halo.protected LabelPlacementcopy(LabelPlacement placement)protected Markcopy(Mark mark)protected OverlapBehaviorcopy(OverlapBehavior ob)protected SelectedChannelTypecopy(SelectedChannelType selectedChannelType)protected SelectedChannelType[]copy(SelectedChannelType... channels)protected ShadedReliefcopy(ShadedRelief shaded)Null safe copy of shaded relief.protected Strokecopy(Stroke stroke)Null safe copy of stroke.protected Symbolcopy(Symbol symbol)protected Symbolizercopy(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.ObjectgetCopy()voidsetStrict(boolean strict)True if we should enforce equality after a copy.voidvisit(AnchorPoint ap)Called when accept is called on an anchor pointvoidvisit(ChannelSelection cs)Called when accept is called on a rasterChannelSelectionelementvoidvisit(ColorMap colorMap)Called when accept is called on a raster color mapvoidvisit(ColorMapEntry colorMapEntry)Called when accept is called on a raster color map entryvoidvisit(ContrastEnhancement contrastEnhancement)Called when accept is called on a raster ContrastEnhancement elementvoidvisit(Displacement dis)Called when accept is called on a displacementvoidvisit(ExternalGraphic exgr)Called when accept is called on an external graphicvoidvisit(FeatureTypeConstraint ftc)Called when accept is called on a FeatureTypeConstraint.voidvisit(FeatureTypeStyle fts)Called when accept is called on a fetauretypestylevoidvisit(Fill fill)Called when accept is called on a fillvoidvisit(Graphic gr)Called when accept is called on a graphicvoidvisit(Halo halo)Called when accept is called on a halovoidvisit(ImageOutline outline)Called when accept is called on a rasterImageOutlineelementvoidvisit(LinePlacement lp)Called when accept is called on a Line Placementvoidvisit(LineSymbolizer line)Called when accept is called on a linesymbolizervoidvisit(Mark mark)Called when accept is called on a markvoidvisit(NamedLayer layer)Called when accept is called on a NamedLayer.voidvisit(OverlapBehavior ob)Called when accept is called on a rasterOverlapBehaviorEnumelementvoidvisit(PointPlacement pp)Called when accept is called on a Point Placementvoidvisit(PointSymbolizer ps)Called when accept is called on a pointsymbolizervoidvisit(PolygonSymbolizer poly)Called when accept is called on a polygon symbolizervoidvisit(RasterSymbolizer raster)Called when accept is called on a rastersymbolizervoidvisit(Rule rule)Called when accept is called on a rulevoidvisit(SelectedChannelType sct)Called when accept is called on a rasterSelectedChannelTypeelementvoidvisit(ShadedRelief sr)Called when accept is called on a rasterShadedReliefelementvoidvisit(Stroke stroke)Called when accept is called on a strokevoidvisit(Style style)Called when accept is called on a Style.voidvisit(StyledLayerDescriptor sld)Called when accept is called on a StyledLayerDescriptor.voidvisit(Symbolizer sym)since it is impossible to create a Symbolizer this method should generate an exception or warning.voidvisit(TextSymbolizer text)Called when accept is called on a textsymbolizervoidvisit(UserLayer layer)Called when accept is called on a UserLayer.
-
-
-
Field Detail
-
sf
protected final StyleFactory sf
-
ff
protected final FilterFactory ff
-
STRICT
protected boolean STRICT
-
copyFilter
protected final DuplicatingFilterVisitor copyFilter
We are using aggregation here to contain our DuplicatingFilterVisitor.
-
-
Constructor Detail
-
DuplicatingStyleVisitor
public DuplicatingStyleVisitor()
-
DuplicatingStyleVisitor
public DuplicatingStyleVisitor(StyleFactory styleFactory)
-
DuplicatingStyleVisitor
public DuplicatingStyleVisitor(StyleFactory styleFactory, FilterFactory filterFactory)
-
DuplicatingStyleVisitor
public DuplicatingStyleVisitor(StyleFactory styleFactory, FilterFactory filterFactory, DuplicatingFilterVisitor filterCloner)
Builds a new duplicating style visitor using a customDuplicatingStyleVisitor- Parameters:
styleFactory- Creates new style objects during style duplicationfilterFactory- Creates new filters and expressions during style duplicationfilterCloner- Copies filters during style duplication
-
-
Method Detail
-
setStrict
public void setStrict(boolean strict)
True if we should enforce equality after a copy.
-
getCopy
public Object getCopy()
-
visit
public void visit(StyledLayerDescriptor sld)
Description copied from interface:StyleVisitorCalled when accept is called on a StyledLayerDescriptor.- Specified by:
visitin interfaceStyleVisitor- Parameters:
sld- The StyledLayerDescriptor to visit
-
visit
public void visit(NamedLayer layer)
Description copied from interface:StyleVisitorCalled when accept is called on a NamedLayer.- Specified by:
visitin interfaceStyleVisitor- Parameters:
layer- The NamedLayer to visit
-
visit
public void visit(UserLayer layer)
Description copied from interface:StyleVisitorCalled when accept is called on a UserLayer.- Specified by:
visitin interfaceStyleVisitor- Parameters:
layer- The UserLayer to visit
-
visit
public void visit(Style style)
Description copied from interface:StyleVisitorCalled when accept is called on a Style.- Specified by:
visitin interfaceStyleVisitor- Parameters:
style- The style to visit
-
visit
public void visit(Rule rule)
Description copied from interface:StyleVisitorCalled when accept is called on a rule- Specified by:
visitin interfaceStyleVisitor- Parameters:
rule- the rule to visit
-
visit
public void visit(FeatureTypeStyle fts)
Description copied from interface:StyleVisitorCalled when accept is called on a fetauretypestyle- Specified by:
visitin interfaceStyleVisitor- Parameters:
fts- the feature type styler to visit
-
copyExpressions
protected List<Expression> copyExpressions(List<Expression> expressions)
Copy list of expressions.- Returns:
- copy of expressions or null if list was null
-
copy
protected Expression copy(Expression expression)
Null safe expression copy.This method will perform a null check, and save you some lines of code:
copy.setBackgroundColor( copyExpr( fill.getColor()) );- Returns:
- copy of expression or null if expression was null
-
copy
protected Graphic copy(Graphic graphic)
Null safe graphic copy- Returns:
- copy of graphic or null if not provided
-
copy
protected Fill copy(Fill fill)
Null safe fill copy- Returns:
- copy of graphic or null if not provided
-
copy
protected float[] copy(float[] array)
Null safe copy of float array.- Returns:
- copy of array or null if not provided
-
copy
protected <K,V> Map<K,V> copy(Map<K,V> customProperties)
Null safe map copy, used for external graphic custom properties.- Returns:
- copy of map
-
copy
protected Stroke copy(Stroke stroke)
Null safe copy of stroke.- Returns:
- copy of stroke if provided
-
copy
protected ShadedRelief copy(ShadedRelief shaded)
Null safe copy of shaded relief.- Returns:
- copy of shaded or null if not provided
-
copy
protected Description copy(Description desc)
Null safe copy of description- Returns:
- copy of shaded or null if not provided
-
copy
protected ExternalGraphic copy(ExternalGraphic externalGraphic)
-
copy
protected ColorMapEntry copy(ColorMapEntry entry)
-
copy
protected Symbolizer copy(Symbolizer symbolizer)
-
copy
protected OverlapBehavior copy(OverlapBehavior ob)
-
copy
protected ContrastEnhancement copy(ContrastEnhancement contrast)
-
copy
protected SelectedChannelType[] copy(SelectedChannelType... channels)
-
copy
protected SelectedChannelType copy(SelectedChannelType selectedChannelType)
-
copy
protected ChannelSelection copy(ChannelSelection channelSelection)
-
copyFonts
protected List<Font> copyFonts(List<Font> fonts)
Null safe copy of font list.Right now style visitor does not let us visit fonts!
- Returns:
- copy of provided fonts
-
copy
protected Displacement copy(Displacement displacement)
Null safe copy of displacement.- Returns:
- copy of displacement if provided
-
copy
protected LabelPlacement copy(LabelPlacement placement)
-
copy
protected AnchorPoint copy(AnchorPoint anchorPoint)
Null safe copy of anchor point.- Returns:
- copy of anchor point if provided
-
visit
public void visit(Fill fill)
Description copied from interface:StyleVisitorCalled when accept is called on a fill- Specified by:
visitin interfaceStyleVisitor- Parameters:
fill- the fill to be visited
-
visit
public void visit(Stroke stroke)
Description copied from interface:StyleVisitorCalled when accept is called on a stroke- Specified by:
visitin interfaceStyleVisitor- Parameters:
stroke- the stroke to visit
-
visit
public void visit(Symbolizer sym)
Description copied from interface:StyleVisitorsince it is impossible to create a Symbolizer this method should generate an exception or warning.- Specified by:
visitin interfaceStyleVisitor- Parameters:
sym- the symbolizer to visit
-
visit
public void visit(PointSymbolizer ps)
Description copied from interface:StyleVisitorCalled when accept is called on a pointsymbolizer- Specified by:
visitin interfaceStyleVisitor- Parameters:
ps- the point symbolizer to visit
-
visit
public void visit(LineSymbolizer line)
Description copied from interface:StyleVisitorCalled when accept is called on a linesymbolizer- Specified by:
visitin interfaceStyleVisitor- Parameters:
line- the line symbolizer to visit
-
visit
public void visit(PolygonSymbolizer poly)
Description copied from interface:StyleVisitorCalled when accept is called on a polygon symbolizer- Specified by:
visitin interfaceStyleVisitor- Parameters:
poly- the polygon symbolizer to visit
-
visit
public void visit(TextSymbolizer text)
Description copied from interface:StyleVisitorCalled when accept is called on a textsymbolizer- Specified by:
visitin interfaceStyleVisitor- Parameters:
text- the text symbolizer to visit
-
visit
public void visit(RasterSymbolizer raster)
Description copied from interface:StyleVisitorCalled when accept is called on a rastersymbolizer- Specified by:
visitin interfaceStyleVisitor- Parameters:
raster- the raster symbolizer to visit
-
visit
public void visit(Graphic gr)
Description copied from interface:StyleVisitorCalled when accept is called on a graphic- Specified by:
visitin interfaceStyleVisitor- Parameters:
gr- the graphic to visit
-
visit
public void visit(Mark mark)
Description copied from interface:StyleVisitorCalled when accept is called on a mark- Specified by:
visitin interfaceStyleVisitor- Parameters:
mark- the mark to visit
-
visit
public void visit(ExternalGraphic exgr)
Description copied from interface:StyleVisitorCalled when accept is called on an external graphic- Specified by:
visitin interfaceStyleVisitor- Parameters:
exgr- the external graphic to visit
-
visit
public void visit(PointPlacement pp)
Description copied from interface:StyleVisitorCalled when accept is called on a Point Placement- Specified by:
visitin interfaceStyleVisitor- Parameters:
pp- the point placement to visit
-
visit
public void visit(AnchorPoint ap)
Description copied from interface:StyleVisitorCalled when accept is called on an anchor point- Specified by:
visitin interfaceStyleVisitor- Parameters:
ap- the anchor point to visit
-
visit
public void visit(Displacement dis)
Description copied from interface:StyleVisitorCalled when accept is called on a displacement- Specified by:
visitin interfaceStyleVisitor- Parameters:
dis- the displacement to visit
-
visit
public void visit(LinePlacement lp)
Description copied from interface:StyleVisitorCalled when accept is called on a Line Placement- Specified by:
visitin interfaceStyleVisitor- Parameters:
lp- the line placement to visit
-
visit
public void visit(Halo halo)
Description copied from interface:StyleVisitorCalled when accept is called on a halo- Specified by:
visitin interfaceStyleVisitor- Parameters:
halo- the halo to visit
-
visit
public void visit(FeatureTypeConstraint ftc)
Description copied from interface:StyleVisitorCalled when accept is called on a FeatureTypeConstraint.- Specified by:
visitin interfaceStyleVisitor- Parameters:
ftc- The FeatureTypeConstraint to visit
-
visit
public void visit(ColorMap colorMap)
Description copied from interface:StyleVisitorCalled when accept is called on a raster color map- Specified by:
visitin interfaceStyleVisitor- Parameters:
colorMap- the color map to visit
-
visit
public void visit(ColorMapEntry colorMapEntry)
Description copied from interface:StyleVisitorCalled when accept is called on a raster color map entry- Specified by:
visitin interfaceStyleVisitor- Parameters:
colorMapEntry- the color map to visit
-
visit
public void visit(ContrastEnhancement contrastEnhancement)
Description copied from interface:StyleVisitorCalled when accept is called on a raster ContrastEnhancement element- Specified by:
visitin interfaceStyleVisitor- Parameters:
contrastEnhancement- theContrastEnhancementto visit.
-
visit
public void visit(ImageOutline outline)
Description copied from interface:StyleVisitorCalled when accept is called on a rasterImageOutlineelement- Specified by:
visitin interfaceStyleVisitor- Parameters:
outline- theImageOutlineto visit.
-
visit
public void visit(ChannelSelection cs)
Description copied from interface:StyleVisitorCalled when accept is called on a rasterChannelSelectionelement- Specified by:
visitin interfaceStyleVisitor- Parameters:
cs- theChannelSelectionto visit.
-
visit
public void visit(OverlapBehavior ob)
Description copied from interface:StyleVisitorCalled when accept is called on a rasterOverlapBehaviorEnumelement- Specified by:
visitin interfaceStyleVisitor- Parameters:
ob- theOverlapBehaviorEnumto visit.
-
visit
public void visit(SelectedChannelType sct)
Description copied from interface:StyleVisitorCalled when accept is called on a rasterSelectedChannelTypeelement- Specified by:
visitin interfaceStyleVisitor- Parameters:
sct- theSelectedChannelTypeto visit.
-
visit
public void visit(ShadedRelief sr)
Description copied from interface:StyleVisitorCalled when accept is called on a rasterShadedReliefelement- Specified by:
visitin interfaceStyleVisitor- Parameters:
sr- theShadedReliefto visit.
-
-