I had a look at some of the style model objects implementations. I
notice the equals() methods all look for an instance of the same Impl
class, and not of the actual interface. For example FillImpl:
public boolean equals(Object oth) {
if (this == oth) {
return true;
}
if (oth instanceof FillImpl) {
FillImpl other = (FillImpl) oth;
return Utilities.equals(this.color, other.color) &&
Utilities.equals(this.backgroundColor,
other.backgroundColor) &&
Utilities.equals(this.opacity, other.opacity) &&
Utilities.equals(this.graphicFill, other.graphicFill);
}
return false;
}
Isn't this a problem? If someone comes along with their own
implementation of Fill, this comparison will fail even if they are
identifical in every other case.
-Justin
Jody Garnett wrote:
Jody Garnett wrote:
I do not see facilities in the toolkit for duplicating Filter /
Expression / Style.
I am finding some errors in the test cases as bad assumptions are made
about Symbolizer reuse ....
Found a scary example of Styles being cloned in a test case:
Style clone = (Style) ((Cloneable)style).clone();
assertClone(style,clone);
Indeed this does seem to be supported -- up until RuleImpl.
Basically we need to duplicate our Expressions - I will also note that this
is flawed as written
public Object clone() {
try {
RuleImpl clone = (RuleImpl) super.clone();
clone.graphics = new GTList(clone,"graphics");
clone.symbolizers = new GTList(clone,"symbolizers");
clone.filter = filter; // TODO: we must duplicate!
Graphic[] legends = new Graphic[graphics.size()];
for (int i = 0; i < legends.length; i++) {
Graphic legend = (Graphic) graphics.get(i);
legends[i] = (Graphic) ((Cloneable) legend).clone();
}
clone.setLegendGraphic(legends);
Symbolizer[] symbArray = new Symbolizer[symbolizers.size()];
for (int i = 0; i < symbArray.length; i++) {
Symbolizer symb = (Symbolizer) symbolizers.get(i);
symbArray[i] = (Symbolizer) ((Cloneable) symb).clone();
}
clone.setSymbolizers(symbArray);
return clone;
} catch (CloneNotSupportedException e) {
throw new RuntimeException("This will never happen", e);
}
}
That is this is a semi deep copy. Sigh. Must revisit when
Filter/Expression duplication
is available.
Jody
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log
files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel
--
Justin Deoliveira
The Open Planning Project
http://topp.openplans.org
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel