I think I would like to phase out the use of clone; using the DuplicatingStyleVisitor as mentioned. There tends to be a lot of trouble with different "literals" that can be supported in an expression; not all of them implement clonable very well.
What are your thought on this? - could we remove support for clonable - were people able to find DuplicatingStyleVisitor in the user guide Jody On 29/05/2010, at 5:51 PM, Stefan Tzeggai (geb. Krüger) wrote: > Hi > > On Friday 28 May 2010 19:25:12 Enamul wrote: >> I might have found a bug with Cloneable implementation of Style. The issue >> seems to be with the cloning of rules. Here is a very simple test case that >> fails with the trunk code: >> >> Style clonedStyle = (Style) ((Cloneable) style).clone(); > > I guess that Style.clone does only a "shallow copy"; e.g. it created only a > new Style object, but all children are the same objects as in the original. > That would explain your described behaviour: > >> // get the first rule of the original style >> Rule rule = style.featureTypeStyles().get(0).rules().get(0); >> >> // get the first rule of the cloned style >> Rule clonedRule = clonedStyle.featureTypeStyles().get(0).rules().get(0); >> >> // let's remove all the symbolizers from the cloned rule >> clonedRule.symbolizers().clear(); >> >> System.out.println(rule.symbolizers().size()); >> >> The output of this test case would be 0, which is not the expected >> behavior. The issue seems to be in RuleImpl.clone(): > > In GeoTools you should use the DuplicatingStyleVisitor class, and not the > clone() method: > > http://docs.codehaus.org/display/GEOTDOC/08+StyleVisitor+use+with+DuplicatingStyleVisitor+and+RescaleStyleVisitor > > It can not only be used to duplicate a Style, but also duplicates Rules, > Symbolizers etc.. > > DuplicatingStyleVisitor xerox = new DuplicatingStyleVisitor(); > style.accepts( xerox ); > Style copy = (Style) xerox.getCopy(); > > Greetings, > Steve > -- > Geotools-based SLD editor: > http://en.geopblushing.org/AtlasStyler > Stefan Tzeggai (geb. Krüger) > > reclaim your net - http://tor.eff.org > enforce privacy - http://www.pgpi.org > pgp key id: 51B576FD - http://pgp.mit.edu > > Please note that according to the German law on data retention, > information on every electronic information exchange with me is > retained for a period of six months. > > > ------------------------------------------------------------------------------ > > _______________________________________________ > Geotools-gt2-users mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users ------------------------------------------------------------------------------ _______________________________________________ Geotools-gt2-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
