Package org.geotools.styling.visitor
Class DuplicatingStyleVisitor
Object
DuplicatingStyleVisitor
- All Implemented Interfaces:
StyleVisitor
- Direct Known Subclasses:
ChannelSelectionUpdateStyleVisitor
,RenderingSelectorStyleVisitor
,RescaleStyleVisitor
,UomRescaleStyleVisitor
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
FieldsModifier and TypeFieldDescriptionprotected final DuplicatingFilterVisitor
We are using aggregation here to contain our DuplicatingFilterVisitor.protected final FilterFactory
This is our internal stack; used to maintain state as we copy sub elements.protected final StyleFactory
protected boolean
-
Constructor Summary
ConstructorsConstructorDescriptionDuplicatingStyleVisitor
(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
Modifier and TypeMethodDescriptionprotected float[]
copy
(float[] array) Null safe copy of float array.protected <K,
V> Map<K, V> Null safe map copy, used for external graphic custom properties.protected Expression
copy
(Expression expression) Null safe expression copy.protected Filter
Null safe copy of filter.protected AnchorPoint
copy
(AnchorPoint anchorPoint) Null safe copy of anchor point.protected ChannelSelection
copy
(ChannelSelection channelSelection) protected ColorMap
protected ColorMapEntry
copy
(ColorMapEntry entry) protected ContrastEnhancement
copy
(ContrastEnhancement contrast) protected Description
copy
(Description desc) Null safe copy of descriptionprotected Displacement
copy
(Displacement displacement) Null safe copy of displacement.protected Extent
protected Extent[]
protected ExternalGraphic
copy
(ExternalGraphic externalGraphic) protected Fill
Null safe fill copyprotected Font
Null safe copy of a single fontprotected Graphic
Null safe graphic copyprotected Halo
Null safe copy of halo.protected LabelPlacement
copy
(LabelPlacement placement) protected 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
Null safe copy of stroke.protected Symbol
protected Symbolizer
copy
(Symbolizer symbolizer) protected List<Expression>
copyExpressions
(List<Expression> expressions) Copy list of expressions.Null safe copy of font list.getCopy()
void
setStrict
(boolean strict) True if we should enforce equality after a copy.void
visit
(AnchorPoint ap) Called when accept is called on an anchor pointvoid
Called when accept is called on a rasterChannelSelection
elementvoid
Called when accept is called on a raster color mapvoid
visit
(ColorMapEntry colorMapEntry) Called when accept is called on a raster color map entryvoid
visit
(ContrastEnhancement contrastEnhancement) Called when accept is called on a raster ContrastEnhancement elementvoid
visit
(Displacement dis) Called when accept is called on a displacementvoid
visit
(ExternalGraphic exgr) Called when accept is called on an external graphicvoid
Called when accept is called on a FeatureTypeConstraint.void
visit
(FeatureTypeStyle fts) Called when accept is called on a fetauretypestylevoid
Called when accept is called on a fillvoid
Called when accept is called on a graphicvoid
Called when accept is called on a halovoid
visit
(ImageOutline outline) Called when accept is called on a rasterImageOutline
elementvoid
visit
(LinePlacement lp) Called when accept is called on a Line Placementvoid
visit
(LineSymbolizer line) Called when accept is called on a linesymbolizervoid
Called when accept is called on a markvoid
visit
(NamedLayer layer) Called when accept is called on a NamedLayer.void
visit
(OverlapBehavior ob) Called when accept is called on a rasterOverlapBehaviorEnum
elementvoid
visit
(PointPlacement pp) Called when accept is called on a Point Placementvoid
visit
(PointSymbolizer ps) Called when accept is called on a pointsymbolizervoid
visit
(PolygonSymbolizer poly) Called when accept is called on a polygon symbolizervoid
visit
(RasterSymbolizer raster) Called when accept is called on a rastersymbolizervoid
Called when accept is called on a rulevoid
visit
(SelectedChannelType sct) Called when accept is called on a rasterSelectedChannelType
elementvoid
visit
(ShadedRelief sr) Called when accept is called on a rasterShadedRelief
elementvoid
Called when accept is called on a strokevoid
Called when accept is called on a Style.void
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 textsymbolizervoid
Called when accept is called on a UserLayer.
-
Field Details
-
sf
-
ff
-
STRICT
protected boolean STRICT -
copyFilter
We are using aggregation here to contain our DuplicatingFilterVisitor. -
pages
This is our internal stack; used to maintain state as we copy sub elements.
-
-
Constructor Details
-
DuplicatingStyleVisitor
public DuplicatingStyleVisitor() -
DuplicatingStyleVisitor
-
DuplicatingStyleVisitor
-
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 Details
-
setStrict
public void setStrict(boolean strict) True if we should enforce equality after a copy. -
getCopy
-
visit
Description copied from interface:StyleVisitor
Called when accept is called on a StyledLayerDescriptor.- Specified by:
visit
in interfaceStyleVisitor
- Parameters:
sld
- The StyledLayerDescriptor to visit
-
visit
Description copied from interface:StyleVisitor
Called when accept is called on a NamedLayer.- Specified by:
visit
in interfaceStyleVisitor
- Parameters:
layer
- The NamedLayer to visit
-
visit
Description copied from interface:StyleVisitor
Called when accept is called on a UserLayer.- Specified by:
visit
in interfaceStyleVisitor
- Parameters:
layer
- The UserLayer to visit
-
visit
Description copied from interface:StyleVisitor
Called when accept is called on a Style.- Specified by:
visit
in interfaceStyleVisitor
- Parameters:
style
- The style to visit
-
visit
Description copied from interface:StyleVisitor
Called when accept is called on a rule- Specified by:
visit
in interfaceStyleVisitor
- Parameters:
rule
- the rule to visit
-
visit
Description copied from interface:StyleVisitor
Called when accept is called on a fetauretypestyle- Specified by:
visit
in interfaceStyleVisitor
- Parameters:
fts
- the feature type styler to visit
-
copyExpressions
Copy list of expressions.- Returns:
- copy of expressions or null if list was null
-
copy
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
Null safe copy of filter. -
copy
Null safe graphic copy- Returns:
- copy of graphic or null if not provided
-
copy
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
Null safe map copy, used for external graphic custom properties.- Returns:
- copy of map
-
copy
Null safe copy of stroke.- Returns:
- copy of stroke if provided
-
copy
Null safe copy of shaded relief.- Returns:
- copy of shaded or null if not provided
-
copy
Null safe copy of description- Returns:
- copy of shaded or null if not provided
-
copy
-
copy
-
copy
-
copy
-
copy
-
copy
-
copy
-
copy
-
copy
-
copy
-
copyFonts
Null safe copy of font list.Right now style visitor does not let us visit fonts!
- Returns:
- copy of provided fonts
-
copy
Null safe copy of a single font -
copy
Null safe copy of halo.- Returns:
- copy of halo if provided
-
copy
Null safe copy of displacement.- Returns:
- copy of displacement if provided
-
copy
-
copy
-
copy
Null safe copy of anchor point.- Returns:
- copy of anchor point if provided
-
visit
Description copied from interface:StyleVisitor
Called when accept is called on a fill- Specified by:
visit
in interfaceStyleVisitor
- Parameters:
fill
- the fill to be visited
-
visit
Description copied from interface:StyleVisitor
Called when accept is called on a stroke- Specified by:
visit
in interfaceStyleVisitor
- Parameters:
stroke
- the stroke to visit
-
visit
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 interfaceStyleVisitor
- Parameters:
sym
- the symbolizer to visit
-
visit
Description copied from interface:StyleVisitor
Called when accept is called on a pointsymbolizer- Specified by:
visit
in interfaceStyleVisitor
- Parameters:
ps
- the point symbolizer to visit
-
visit
Description copied from interface:StyleVisitor
Called when accept is called on a linesymbolizer- Specified by:
visit
in interfaceStyleVisitor
- Parameters:
line
- the line symbolizer to visit
-
visit
Description copied from interface:StyleVisitor
Called when accept is called on a polygon symbolizer- Specified by:
visit
in interfaceStyleVisitor
- Parameters:
poly
- the polygon symbolizer to visit
-
visit
Description copied from interface:StyleVisitor
Called when accept is called on a textsymbolizer- Specified by:
visit
in interfaceStyleVisitor
- Parameters:
text
- the text symbolizer to visit
-
visit
Description copied from interface:StyleVisitor
Called when accept is called on a rastersymbolizer- Specified by:
visit
in interfaceStyleVisitor
- Parameters:
raster
- the raster symbolizer to visit
-
visit
Description copied from interface:StyleVisitor
Called when accept is called on a graphic- Specified by:
visit
in interfaceStyleVisitor
- Parameters:
gr
- the graphic to visit
-
visit
Description copied from interface:StyleVisitor
Called when accept is called on a mark- Specified by:
visit
in interfaceStyleVisitor
- Parameters:
mark
- the mark to visit
-
visit
Description copied from interface:StyleVisitor
Called when accept is called on an external graphic- Specified by:
visit
in interfaceStyleVisitor
- Parameters:
exgr
- the external graphic to visit
-
visit
Description copied from interface:StyleVisitor
Called when accept is called on a Point Placement- Specified by:
visit
in interfaceStyleVisitor
- Parameters:
pp
- the point placement to visit
-
visit
Description copied from interface:StyleVisitor
Called when accept is called on an anchor point- Specified by:
visit
in interfaceStyleVisitor
- Parameters:
ap
- the anchor point to visit
-
visit
Description copied from interface:StyleVisitor
Called when accept is called on a displacement- Specified by:
visit
in interfaceStyleVisitor
- Parameters:
dis
- the displacement to visit
-
visit
Description copied from interface:StyleVisitor
Called when accept is called on a Line Placement- Specified by:
visit
in interfaceStyleVisitor
- Parameters:
lp
- the line placement to visit
-
visit
Description copied from interface:StyleVisitor
Called when accept is called on a halo- Specified by:
visit
in interfaceStyleVisitor
- Parameters:
halo
- the halo to visit
-
visit
Description copied from interface:StyleVisitor
Called when accept is called on a FeatureTypeConstraint.- Specified by:
visit
in interfaceStyleVisitor
- Parameters:
ftc
- The FeatureTypeConstraint to visit
-
copy
-
copy
-
visit
Description copied from interface:StyleVisitor
Called when accept is called on a raster color map- Specified by:
visit
in interfaceStyleVisitor
- Parameters:
colorMap
- the color map to visit
-
visit
Description copied from interface:StyleVisitor
Called when accept is called on a raster color map entry- Specified by:
visit
in interfaceStyleVisitor
- Parameters:
colorMapEntry
- the color map to visit
-
visit
Description copied from interface:StyleVisitor
Called when accept is called on a raster ContrastEnhancement element- Specified by:
visit
in interfaceStyleVisitor
- Parameters:
contrastEnhancement
- theContrastEnhancement
to visit.
-
visit
Description copied from interface:StyleVisitor
Called when accept is called on a rasterImageOutline
element- Specified by:
visit
in interfaceStyleVisitor
- Parameters:
outline
- theImageOutline
to visit.
-
visit
Description copied from interface:StyleVisitor
Called when accept is called on a rasterChannelSelection
element- Specified by:
visit
in interfaceStyleVisitor
- Parameters:
cs
- theChannelSelection
to visit.
-
visit
Description copied from interface:StyleVisitor
Called when accept is called on a rasterOverlapBehaviorEnum
element- Specified by:
visit
in interfaceStyleVisitor
- Parameters:
ob
- theOverlapBehaviorEnum
to visit.
-
visit
Description copied from interface:StyleVisitor
Called when accept is called on a rasterSelectedChannelType
element- Specified by:
visit
in interfaceStyleVisitor
- Parameters:
sct
- theSelectedChannelType
to visit.
-
visit
Description copied from interface:StyleVisitor
Called when accept is called on a rasterShadedRelief
element- Specified by:
visit
in interfaceStyleVisitor
- Parameters:
sr
- theShadedRelief
to visit.
-