org.geotools.styling.visitor
Class DuplicatingStyleVisitor

Object
  extended by DuplicatingStyleVisitor
All Implemented Interfaces:
StyleVisitor
Direct Known Subclasses:
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
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 Summary
DuplicatingStyleVisitor()
           
DuplicatingStyleVisitor(StyleFactory styleFactory)
           
DuplicatingStyleVisitor(StyleFactory styleFactory, FilterFactory2 filterFactory)
           
 
Method Summary
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  Font[] copy(Font[] fonts)
          Null safe copy of font array.
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)
           
 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.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sf

protected final StyleFactory sf

ff

protected final FilterFactory2 ff

STRICT

protected boolean STRICT

copyFilter

protected final DuplicatingFilterVisitor copyFilter
We are using aggregation here to contain our DuplicatingFilterVisitor.


pages

protected Stack<Object> pages
This is our internal stack; used to maintain state as we copy sub elements.

Constructor Detail

DuplicatingStyleVisitor

public DuplicatingStyleVisitor()

DuplicatingStyleVisitor

public DuplicatingStyleVisitor(StyleFactory styleFactory)

DuplicatingStyleVisitor

public DuplicatingStyleVisitor(StyleFactory styleFactory,
                               FilterFactory2 filterFactory)
Method Detail

setStrict

public void setStrict(boolean strict)
True if we should enforce equality after a copy.

Parameters:
strict -

getCopy

public Object getCopy()

visit

public void visit(StyledLayerDescriptor sld)
Description copied from interface: StyleVisitor
Called when accept is called on a StyledLayerDescriptor.

Specified by:
visit in interface StyleVisitor
Parameters:
sld - The StyledLayerDescriptor to visit

visit

public void visit(NamedLayer layer)
Description copied from interface: StyleVisitor
Called when accept is called on a NamedLayer.

Specified by:
visit in interface StyleVisitor
Parameters:
layer - The NamedLayer to visit

visit

public void visit(UserLayer layer)
Description copied from interface: StyleVisitor
Called when accept is called on a UserLayer.

Specified by:
visit in interface StyleVisitor
Parameters:
layer - The UserLayer to visit

visit

public void visit(Style style)
Description copied from interface: StyleVisitor
Called when accept is called on a Style.

Specified by:
visit in interface StyleVisitor
Parameters:
style - The style to visit

visit

public void visit(Rule rule)
Description copied from interface: StyleVisitor
Called when accept is called on a rule

Specified by:
visit in interface StyleVisitor
Parameters:
rule - the rule to visit

visit

public void visit(FeatureTypeStyle fts)
Description copied from interface: StyleVisitor
Called when accept is called on a fetauretypestyle

Specified by:
visit in interface StyleVisitor
Parameters:
fts - the feature type styler to visit

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()) );
 

Parameters:
sion -
Returns:
copy of expression or null if expression was null

copy

protected Filter copy(Filter filter)
Null safe copy of filter.


copy

protected Graphic copy(Graphic graphic)
Null safe graphic copy

Parameters:
graphic -
Returns:
copy of graphic or null if not provided

copy

protected Fill copy(Fill fill)
Null safe fill copy

Parameters:
graphic -
Returns:
copy of graphic or null if not provided

copy

protected float[] copy(float[] array)
Null safe copy of float array.

Parameters:
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.

Parameters:
customProperties -
Returns:
copy of map

copy

protected Stroke copy(Stroke stroke)
Null safe copy of stroke.

Parameters:
stroke -
Returns:
copy of stroke if provided

copy

protected ShadedRelief copy(ShadedRelief shaded)
Null safe copy of shaded relief.

Parameters:
shaded -
Returns:
copy of shaded or null if not provided

copy

protected Description copy(Description desc)
Null safe copy of description

Parameters:
shaded -
Returns:
copy of shaded or null if not provided

copy

protected ExternalGraphic copy(ExternalGraphic externalGraphic)

copy

protected Mark copy(Mark mark)

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 ColorMap copy(ColorMap colorMap)

copy

protected SelectedChannelType[] copy(SelectedChannelType[] channels)

copy

protected SelectedChannelType copy(SelectedChannelType selectedChannelType)

copy

protected ChannelSelection copy(ChannelSelection channelSelection)

copy

protected Font[] copy(Font[] fonts)
Null safe copy of font array.

Right now style visitor does not let us visit fonts!

Parameters:
fonts -
Returns:
copy of provided fonts

copy

protected Font copy(Font font)
Null safe copy of a single font


copy

protected Halo copy(Halo halo)
Null safe copy of halo.

Parameters:
halo -
Returns:
copy of halo if provided

copy

protected Displacement copy(Displacement displacement)
Null safe copy of displacement.

Parameters:
displacement -
Returns:
copy of displacement if provided

copy

protected LabelPlacement copy(LabelPlacement placement)

copy

protected Symbol copy(Symbol symbol)

copy

protected AnchorPoint copy(AnchorPoint anchorPoint)
Null safe copy of anchor point.

Parameters:
anchorPoint -
Returns:
copy of anchor point if provided

visit

public void visit(Fill fill)
Description copied from interface: StyleVisitor
Called when accept is called on a fill

Specified by:
visit in interface StyleVisitor
Parameters:
fill - the fill to be visited

visit

public void visit(Stroke stroke)
Description copied from interface: StyleVisitor
Called when accept is called on a stroke

Specified by:
visit in interface StyleVisitor
Parameters:
stroke - the stroke to visit

visit

public void visit(Symbolizer sym)
Description copied from interface: StyleVisitor
since it is impossible to create a Symbolizer this method should generate an exception or warning.

Specified by:
visit in interface StyleVisitor
Parameters:
sym - the symbolizer to visit

visit

public void visit(PointSymbolizer ps)
Description copied from interface: StyleVisitor
Called when accept is called on a pointsymbolizer

Specified by:
visit in interface StyleVisitor
Parameters:
ps - the point symbolizer to visit

visit

public void visit(LineSymbolizer line)
Description copied from interface: StyleVisitor
Called when accept is called on a linesymbolizer

Specified by:
visit in interface StyleVisitor
Parameters:
line - the line symbolizer to visit

visit

public void visit(PolygonSymbolizer poly)
Description copied from interface: StyleVisitor
Called when accept is called on a polygon symbolizer

Specified by:
visit in interface StyleVisitor
Parameters:
poly - the polygon symbolizer to visit

visit

public void visit(TextSymbolizer text)
Description copied from interface: StyleVisitor
Called when accept is called on a textsymbolizer

Specified by:
visit in interface StyleVisitor
Parameters:
text - the text symbolizer to visit

visit

public void visit(RasterSymbolizer raster)
Description copied from interface: StyleVisitor
Called when accept is called on a rastersymbolizer

Specified by:
visit in interface StyleVisitor
Parameters:
raster - the raster symbolizer to visit

visit

public void visit(Graphic gr)
Description copied from interface: StyleVisitor
Called when accept is called on a graphic

Specified by:
visit in interface StyleVisitor
Parameters:
gr - the graphic to visit

visit

public void visit(Mark mark)
Description copied from interface: StyleVisitor
Called when accept is called on a mark

Specified by:
visit in interface StyleVisitor
Parameters:
mark - the mark to visit

visit

public void visit(ExternalGraphic exgr)
Description copied from interface: StyleVisitor
Called when accept is called on a external graphic

Specified by:
visit in interface StyleVisitor
Parameters:
exgr - the external graphic to visit

visit

public void visit(PointPlacement pp)
Description copied from interface: StyleVisitor
Called when accept is called on a Point Placement

Specified by:
visit in interface StyleVisitor
Parameters:
pp - the point placement to visit

visit

public void visit(AnchorPoint ap)
Description copied from interface: StyleVisitor
Called when accept is called on a anchor point

Specified by:
visit in interface StyleVisitor
Parameters:
ap - the anchor point to visit

visit

public void visit(Displacement dis)
Description copied from interface: StyleVisitor
Called when accept is called on a displacement

Specified by:
visit in interface StyleVisitor
Parameters:
dis - the displacement to visit

visit

public void visit(LinePlacement lp)
Description copied from interface: StyleVisitor
Called when accept is called on a Line Placement

Specified by:
visit in interface StyleVisitor
Parameters:
lp - the line placement to visit

visit

public void visit(Halo halo)
Description copied from interface: StyleVisitor
Called when accept is called on a halo

Specified by:
visit in interface StyleVisitor
Parameters:
halo - the halo to visit

visit

public void visit(FeatureTypeConstraint ftc)
Description copied from interface: StyleVisitor
Called when accept is called on a FeatureTypeConstraint.

Specified by:
visit in interface StyleVisitor
Parameters:
ftc - The FeatureTypeConstraint to visit

copy

protected Extent[] copy(Extent[] extents)

copy

protected Extent copy(Extent extent)

visit

public void visit(ColorMap colorMap)
Description copied from interface: StyleVisitor
Called when accept is called on a raster color map

Specified by:
visit in interface StyleVisitor
Parameters:
colorMap - the color map to visit

visit

public void visit(ColorMapEntry colorMapEntry)
Description copied from interface: StyleVisitor
Called when accept is called on a raster color map entry

Specified by:
visit in interface StyleVisitor
Parameters:
colorMapEntry - the color map to visit

visit

public void visit(ContrastEnhancement contrastEnhancement)
Description copied from interface: StyleVisitor
Called when accept is called on a raster ContrastEnhancement element

Specified by:
visit in interface StyleVisitor
Parameters:
contrastEnhancement - the ContrastEnhancement to visit.

visit

public void visit(ImageOutline outline)
Description copied from interface: StyleVisitor
Called when accept is called on a raster ImageOutline element

Specified by:
visit in interface StyleVisitor
Parameters:
outline - the ImageOutline to visit.

visit

public void visit(ChannelSelection cs)
Description copied from interface: StyleVisitor
Called when accept is called on a raster ChannelSelection element

Specified by:
visit in interface StyleVisitor
Parameters:
cs - the ChannelSelection to visit.

visit

public void visit(OverlapBehavior ob)
Description copied from interface: StyleVisitor
Called when accept is called on a raster OverlapBehavior element

Specified by:
visit in interface StyleVisitor

visit

public void visit(SelectedChannelType sct)
Description copied from interface: StyleVisitor
Called when accept is called on a raster SelectedChannelType element

Specified by:
visit in interface StyleVisitor

visit

public void visit(ShadedRelief sr)
Description copied from interface: StyleVisitor
Called when accept is called on a raster ShadedRelief element

Specified by:
visit in interface StyleVisitor


Copyright © 1996-2014 Geotools. All Rights Reserved.