Open GoogleCodeExporter opened 8 years ago
Well in Java all objects are passed by reference so thats normal behaviour. One
could argue whether the behaviour you describe is a bug or not. A StyleInfo
object is meant to be for one component and belongs to it and changes according
to the component.
We could of course make copies of the color when setting it. But if we for
example make a color animation we are creating many new color objects each
frame which is to avoid in real time graphics and because of garbage collection.
So I have to think about this somemore. Feel free to add your thoughts.
Original comment by sirhc.f...@gmail.com
on 13 Oct 2010 at 1:17
Ah, good point. Perhaps the shape could make a defensive copy of a StyleInfo
it gets by setStyleInfo(). That shouldn't happen too often, right? I think my
expectation is that if I setup a StyleInfo object to apply to many shapes,
setStyleInfo() should have the same effect every time. This doesn't hold under
the conditions described before. On the other hand, if "A StyleInfo object is
meant to be for one component and belongs to it," then I suppose it's
reasonable for me to make a copy of my StyleInfo object for each call I make to
setStyleInfo(). If that's the case, a copy constructor for StyleInfo would be
super handy. (e.g., "new StyleInfo(oldStyleInfo);")
Original comment by jpkiffme...@gmail.com
on 13 Oct 2010 at 4:34
Original issue reported on code.google.com by
jpkiffme...@gmail.com
on 17 Sep 2010 at 12:04