Oh, I figured the first answer was a little too obvious. 8-)

As to where the CTS object is coming from, I think it is
LayerTreeModel.getChildren():

        if (parent instanceof Layer
                && ColorThemingStyle.get((Layer) parent).isEnabled()) {
...

 ColorThemingStyle.get() is:

        public static ColorThemingStyle get(Layer layer) {
                if ((ColorThemingStyle) layer.getStyle(ColorThemingStyle.class) 
== null) {
                        ColorThemingStyle colorThemingStyle = new 
ColorThemingStyle(
                                        pickNonSpatialAttributeName(layer
                                                
.getFeatureCollectionWrapper().getFeatureSchema()),
                                        new HashMap(), new 
BasicStyle(Color.lightGray));
                        layer.addStyle(colorThemingStyle);
                }
                return (ColorThemingStyle) 
layer.getStyle(ColorThemingStyle.class);
        }

It seems to always add a CTS if one is not found.  A very strange side effect.

regards,
Larry
On 9/11/07, Malte Weller <[EMAIL PROTECTED]> wrote:
> Hi Larry,
>
> thanks for your reply.
>
> I know that the CTS added first should be removed first. ;-)
> But I was only able to remove that after I added the second one.
>
> In my Thread I look at the Style-List of my new Layer if it holds a CTS
> Object.
> If so, I try to remove it because my new CTS Object should be used.
> Surprisingly I could not remove it. It will added immediately  at the
> end of the List again.
> For example at the beginning it was in the middle of the List and now I
> find it at the end.
> I can remove a BasicStyle Object without any problems.
> It is only possible to remove the first CTS Object from the List after I
> added my new one.
>
> I think, I should be able to remove the first CTS  from the list without
> any trouble like the BasicStyle and not only after I added a second one.
> Maybe, the use of a Thread causes this problem ?
>
> Greetings from Hannover,
> Malte
>
> Larry Becker schrieb:
> > Hi Malte,
> >
> >    If I understand you correctly, I guess I'm not surprised at the
> > fact that a Style added first would be removed first since the
> > underlying data structure is an ArrayList.  The javadoc for ArrayList
> > says that list.remove(o) will delete the first occurance of o in list.
> >
> > regards,
> > Larry Becker
> >
> > On 9/10/07, Malte Weller <[EMAIL PROTECTED]> wrote:
> >
> >> Hello List,
> >>
> >> I use a Thread to create several Layers from a Database.
> >> My run-Method calls two other Methods.
> >> First one to create and add the layers.
> >> Second one to create a ColorThemingStyle-Object to add this to the
> >> created Layer.
> >>
> >> If the Layer holds a ColorThemingStyle-Object it should be removed and
> >> the new one should be added.
> >> By default my new Layers are holding a ColorThemingStyle-Object (Does
> >> anybody know where this one will be added to the Layers Style List ?).
> >>
> >> Immediately after I removed the "default" CTS-Object from the List it
> >> will be added again at the end.
> >> So I cannot remove this "default" CTS-Object.
> >> After I added my new CTS-Object it looks like that the "default"
> >> CTS-Object is still be used instead.
> >>
> >> I found a workaround for that.
> >> I add my new CTS-Object first and then I remove a CTS-Object with
> >>
> >> "layer.removeStyle(ColorThemingStyle.get(layer));
> >>
> >> Surprisingly the "default" CTS-Object has been removed and the new CTS
> >> is shown.
> >>
> >> Can anybody varify this behaviour and has a explanation for it ?
> >>
> >> Greetings from Hannover,
> >> Malte
> >>
> >>
> >>
> >> -------------------------------------------------------------------------
> >> This SF.net email is sponsored by: Microsoft
> >> Defy all challenges. Microsoft(R) Visual Studio 2005.
> >> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> >> _______________________________________________
> >> Jump-pilot-devel mailing list
> >> Jump-pilot-devel@lists.sourceforge.net
> >> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
> >>
> >>
> >>
> >>
> >
> >
> >
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2005.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Jump-pilot-devel mailing list
> Jump-pilot-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
>
>
>


-- 
http://amusingprogrammer.blogspot.com/

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to