i have problem to change style in mapdisplaylab for 2 IDs

10 messages Options
Embed this post
Permalink
dadar

i have problem to change style in mapdisplaylab for 2 IDs

Reply Threaded More More options
Print post
Permalink
right now i'm trying to make 2 area in the map change the style
when i try it only the last one that change the style
i'm using the class in MapDisplayLab to edit the style
when i read the code, i think i must pass an array of IDs to displaySelectedFeature class.
Is that right?? or I'm wrong??
i try to make an array of IDs but i have an error can anyone tell me what should i do with this error?
example

Set<FeatureId> [] IDs = null;

is that right to make array of Set<FeatureId> ??
then how can i set how big the array is

sorry if i'm confusing all of you
i'm still beginner at this

Darmawan
Jody Garnett-2

Re: [Geotools-gt2-users] i have problem to change style in mapdisplaylab for 2 IDs

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
Hi Darmawan; it is a bit frustrating to work through Nabble (throws our count of the user list off).


I am keen to know more about your error; can you provide a stacktrace? The style classes have recently been clobbered by myself in a quality assurance run; and I am concerned that I may of introduced an error.

The right way to produce a Set<FeatureId> is something like:

Set<FeatureId> selection = new HashSet<FeatureId>();
selection.add( filterFactory.featureId( "foo.1" ) );
selection.add( filterFactory.featureId( "foo.47" ) );

I did not quite follow what yo ument by 2 area in th emap change the style? Do you have two MapLayers?

Cheers,
Jody

On 17/10/2009, at 7:19 PM, dadar (via Nabble) wrote:

right now i'm trying to make 2 area in the map change the style
when i try it only the last one that change the style
i'm using the class in MapDisplayLab to edit the style
when i read the code, i think i must pass an array of IDs to displaySelectedFeature class.
Is that right?? or I'm wrong??
i try to make an array of IDs but i have an error can anyone tell me what should i do with this error?
example

Set<FeatureId> [] IDs = null;

is that right to make array of Set<FeatureId> ??
then how can i set how big the array is

sorry if i'm confusing all of you
i'm still beginner at this

Darmawan

dadar

Re: [Geotools-gt2-users] i have problem to change style in mapdisplaylab for 2 IDs

Reply Threaded More More options
Print post
Permalink
thx jody
what i want is:
1. how can i create array of Set<FeatureId>??
 
i declared it like this
            Set<FeatureId> [] IDs;
after that when i try to fill []
            IDs= new Set<FeatureId> [2];
there is an error generic array creation
am i wrong when i declared it?

2. how can i change the color of two area in map?

what i mean is like in MapDisplayClass there is SelectFeature that change the color of the area when we click it
is same like that but i want two area at the same time change its color
i tried to change the code like this but only the last IDs that change the color
how can i set the style of two area at the same time??

public void displaySelectedFeatures(Set<FeatureId> IDs,Set<FeatureId> IDs2) {
        Style style = null;

            if (IDs.isEmpty()) {
                style = createDefaultStyle();
                mapFrame.getMapContext().getLayer(0).setStyle(style);
            } else {
                style = createSelectedStyle(IDs);
                mapFrame.getMapContext().getLayer(0).setStyle(style);
            }

        if (IDs2.isEmpty()) {
                style = createDefaultStyle();
                mapFrame.getMapContext().getLayer(0).setStyle(style);
            } else {
                style = createSelectedStyle(IDs2);
                mapFrame.getMapContext().getLayer(0).setStyle(style);
            }

        mapFrame.getMapPane().repaint();
    }


Darmawan

Jody Garnett-2 wrote:
Hi Darmawan; it is a bit frustrating to work through Nabble (throws  
our count of the user list off).


I am keen to know more about your error; can you provide a stacktrace?  
The style classes have recently been clobbered by myself in a quality  
assurance run; and I am concerned that I may of introduced an error.

The right way to produce a Set<FeatureId> is something like:

Set<FeatureId> selection = new HashSet<FeatureId>();
selection.add( filterFactory.featureId( "foo.1" ) );
selection.add( filterFactory.featureId( "foo.47" ) );

I did not quite follow what yo ument by 2 area in th emap change the  
style? Do you have two MapLayers?

Cheers,
Jody

On 17/10/2009, at 7:19 PM, dadar (via Nabble) wrote:

> right now i'm trying to make 2 area in the map change the style
> when i try it only the last one that change the style
> i'm using the class in MapDisplayLab to edit the style
> when i read the code, i think i must pass an array of IDs to  
> displaySelectedFeature class.
> Is that right?? or I'm wrong??
> i try to make an array of IDs but i have an error can anyone tell me  
> what should i do with this error?
> example
>
> Set<FeatureId> [] IDs = null;
>
> is that right to make array of Set<FeatureId> ??
> then how can i set how big the array is
>
> sorry if i'm confusing all of you
> i'm still beginner at this
>
> Darmawan
>
> This email was sent by Jody Garnett-2 (via Nabble)
> Your replies will appear at http://n2.nabble.com/i-have-problem-to-change-style-in-mapdisplaylab-for-2-IDs-tp3840063p3840063.html
> To receive all replies by email, subscribe to this discussion
>
Jody Garnett-2

Re: i have problem to change style in mapdisplaylab for 2 IDs

Reply Threaded More More options
Print post
Permalink
In reply to this post by dadar
Hi guy; better keep this on the email list (rather then email me  
directly).

On 17/10/2009, at 8:58 PM, dadar (via Nabble) wrote:

> thx jody
> what i want is:
> 1. how can i create array of Set<FeatureId>??
>
> i declared it like this
>             Set<FeatureId> [] IDs;
> after that when i try to fill []
>             IDs= new Set<FeatureId> [2];
> there is an error generic array creation
> am i wrong when i declared it?

To create a FeatureId you need to use a FilterFactory - but I think  
you got that part.
The method should accept a single Set<FeatureId> (not an array of  
Set<FeatureId> ). My first reply showed how to create a HashSet; do  
you need more information on how to use the  java collection classes;  
why are you using an array?

> 2. how can i change the color of two area in map?
>
> what i mean is like in MapDisplayClass there is SelectFeature that  
> change the color of the area when we click it
> is same like that but i want two area at the same time change its  
> color
> i tried to change the code like this but only the last IDs that  
> change the color
> how can i set the style of two area at the same time??

The example method createSelectedStyle( IDs ) is an example. Go into  
that method and see how it makes a Style? You will need to make your  
own Style; your Style should have two rules; one for each feature you  
want to isolate for special treatment; each Rule will have a different  
list of symbolizers descrbing how to draw the features that match that  
Rule.

You may wish to read the StyleLayerDescriptor specification which  
contains examples of how to define a style in xml.

Jody


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Geotools-gt2-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
Jody Garnett-2

Re: [Geotools-gt2-users] i have problem to change style in mapdisplaylab for 2 IDs

Reply Threaded More More options
Print post
Permalink
In reply to this post by dadar
Hi guy; better keep this on the email list (rather then email me  
directly).

On 17/10/2009, at 8:58 PM, dadar (via Nabble) wrote:

> thx jody
> what i want is:
> 1. how can i create array of Set<FeatureId>??
>
> i declared it like this
>             Set<FeatureId> [] IDs;
> after that when i try to fill []
>             IDs= new Set<FeatureId> [2];
> there is an error generic array creation
> am i wrong when i declared it?

To create a FeatureId you need to use a FilterFactory - but I think  
you got that part.
The method should accept a single Set<FeatureId> (not an array of  
Set<FeatureId> ). My first reply showed how to create a HashSet; do  
you need more information on how to use the  java collection classes;  
why are you using an array?

> 2. how can i change the color of two area in map?
>
> what i mean is like in MapDisplayClass there is SelectFeature that  
> change the color of the area when we click it
> is same like that but i want two area at the same time change its  
> color
> i tried to change the code like this but only the last IDs that  
> change the color
> how can i set the style of two area at the same time??

The example method createSelectedStyle( IDs ) is an example. Go into  
that method and see how it makes a Style? You will need to make your  
own Style; your Style should have two rules; one for each feature you  
want to isolate for special treatment; each Rule will have a different  
list of symbolizers descrbing how to draw the features that match that  
Rule.

You may wish to read the StyleLayerDescriptor specification which  
contains examples of how to define a style in xml.

Jody

dadar

Re: [Geotools-gt2-users] i have problem to change style in mapdisplaylab for 2 IDs

Reply Threaded More More options
Print post
Permalink


> thx jody
> what i want is:
> 1. how can i create array of Set<FeatureId>??
>
> i declared it like this
>             Set<FeatureId> [] IDs;
> after that when i try to fill []
>             IDs= new Set<FeatureId> [2];
> there is an error generic array creation
> am i wrong when i declared it?

> To create a FeatureId you need to use a FilterFactory - but I think  
> you got that part.
> The method should accept a single Set<FeatureId> (not an array of  
> Set<FeatureId> ). My first reply showed how to create a HashSet; do  
> you need more information on how to use the  java collection classes;  
> why are you using an array?

jody, i'm trying to change some of the class in MapDisplayLab so i can use it for my program like this one:
        void selectFeatures(double [] posisix, double [] posisiy)
so i sent an array of some area position in the map after i calculate it, after this i want to change the color of area based in the position that i sent.
In the displaySelectedFeatures we use IDs to set the style so i think maybe i need to make an array of Set<FeatureId> to do it and sent it (change the parameter
in displaySelectedFeatures into
public void displaySelectedFeatures(Set<FeatureId> [] IDs) )
what do u think? am i wrong with my thought?

> 2. how can i change the color of two area in map?
>
> what i mean is like in MapDisplayClass there is SelectFeature that  
> change the color of the area when we click it
> is same like that but i want two area at the same time change its  
> color
> i tried to change the code like this but only the last IDs that  
> change the color
> how can i set the style of two area at the same time??

> The example method createSelectedStyle( IDs ) is an example. Go into  
> that method and see how it makes a Style? You will need to make your  
> own Style; your Style should have two rules; one for each feature you  
> want to isolate for special treatment; each Rule will have a different  
> list of symbolizers descrbing how to draw the features that match that  
> Rule.

> You may wish to read the StyleLayerDescriptor specification which  
> contains examples of how to define a style in xml.

I understand that createSelectedStyle (IDs) is method to set style based in IDs before diplaying it in map
what i need is how can I set 2 or more IDs style, then displaying it
                if (IDs.isEmpty()) {
                style = createDefaultStyle();
                                mapFrame.getMapContext().getLayer(0).setStyle(style);
            } else {
                style = createSelectedStyle(IDs);
                                mapFrame.getMapContext().getLayer(0).setStyle(style);
            }

        if (IDs2.isEmpty()) {
                style = createDefaultStyle();
                                mapFrame.getMapContext().getLayer(0).setStyle(style);
            } else {
                style = createSelectedStyle(IDs2);
                                mapFrame.getMapContext().getLayer(0).setStyle(style);
            }
                       
        mapFrame.getMapPane().repaint();
               
i try to change the source code in displaySelectedFeatures like above
so i sent 2 IDs and set the style before i repaint it
all i get is only IDs2 color that change into yellow color
how do i get both of it (IDs and IDs2) change color into yellow
Jody Garnett-2

Re: i have problem to change style in mapdisplaylab for 2 IDs

Reply Threaded More More options
Print post
Permalink
Hi dadar:


You are missing something.

Each call to setStyle( style ) replaces the previous style; so at the  
end of the day your code example is only showing
the last style.

I repeat:

style = createSelectedStyle(IDs);
mapFrame.getMapContext().getLayer(0).setStyle(style);

Will make a style showing the IDs set selected; and then ask Layer 0  
to draw with that style.

Then you go on to do ...

style = createSelectedStyle(IDs2);
mapFrame.getMapContext().getLayer(0).setStyle(style);

This will will make a style showing the IDs2 set selected; and then  
ask Layer 0 to draw with that style.

So at the end of the day when you ask it repaint it will try and  
display IDs2 (since that is the last way you asked Layer 0 ) tot draw.

To fix this.... do the following once.

Set<FeatureIds> selectedIds = new HashSet<FetureIds>();

selectedIds().addAll( IDs );
selectedIds().addAll( IDs2 );

//selectedIds now has all the stuff you want selected
style = createSelectedStyle(selectedIds);
mapFrame.getMapContext().getLayer(0).setStyle(style);

This is what I tried to say in my 1st reply to you.
Jody

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Geotools-gt2-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
dadar

Re: i have problem to change style in mapdisplaylab for 2 IDs

Reply Threaded More More options
Print post
Permalink
oooh i see jody
so in Set<FeatureIds> we can add another IDs to it
i don't get your point before lol

just 1 problem
if i do what you tell me :
 Set<FeatureIds> selectedIds = new HashSet<FetureIds>();

selectedIds().addAll( IDs );
selectedIds().addAll( IDs2 );

//selectedIds now has all the stuff you want selected
style = createSelectedStyle(selectedIds);
mapFrame.getMapContext().getLayer(0).setStyle(style);

then when i displayed it in the map, color of the IDs will be same
how to make the color different for each IDs??
what i asked you before is example how to change some IDs style so i can understand my problem
how i can change the style for each IDs when i call createSelectedStyle method??

thank you before
Darmawan
Jody Garnett-2 wrote:
Hi dadar:


You are missing something.

Each call to setStyle( style ) replaces the previous style; so at the  
end of the day your code example is only showing
the last style.

I repeat:

style = createSelectedStyle(IDs);
mapFrame.getMapContext().getLayer(0).setStyle(style);

Will make a style showing the IDs set selected; and then ask Layer 0  
to draw with that style.

Then you go on to do ...

style = createSelectedStyle(IDs2);
mapFrame.getMapContext().getLayer(0).setStyle(style);

This will will make a style showing the IDs2 set selected; and then  
ask Layer 0 to draw with that style.

So at the end of the day when you ask it repaint it will try and  
display IDs2 (since that is the last way you asked Layer 0 ) tot draw.

To fix this.... do the following once.

Set<FeatureIds> selectedIds = new HashSet<FetureIds>();

selectedIds().addAll( IDs );
selectedIds().addAll( IDs2 );

//selectedIds now has all the stuff you want selected
style = createSelectedStyle(selectedIds);
mapFrame.getMapContext().getLayer(0).setStyle(style);

This is what I tried to say in my 1st reply to you.
Jody

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Geotools-gt2-users mailing list
Geotools-gt2-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
Jody Garnett-2

Re: [Geotools-gt2-users] i have problem to change style in mapdisplaylab for 2 IDs

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
No problem.

To get different colors you will want to create multiple rules; each with their own description of how to draw. And bundle them up into a single style.  Time to look at how that createSelectedStyle function works.

Read over:

Jody

style = createSelectedStyle(selectedIds);
mapFrame.getMapContext().getLayer(0).setStyle(style);

then when i displayed it in the map, color of the IDs will be same
how to make the color different for each IDs??
what i asked you before is example how to change some IDs style so i can understand my problem
how i can change the style for each IDs when i call createSelectedStyle method??

thank you before
Darmawan


dadar

Re: [Geotools-gt2-users] i have problem to change style in mapdisplaylab for 2 IDs

Reply Threaded More More options
Print post
Permalink
in createSelectedStyle i get that this code:
        Rule selectedRule = createRule(SELECTED_COLOUR, SELECTED_COLOUR);
        selectedRule.setFilter(ff.id(IDs));

        Rule otherRule = createRule(LINE_COLOUR, FILL_COLOUR);
        otherRule.setElseFilter(true);

        FeatureTypeStyle fts = sf.createFeatureTypeStyle();
        fts.rules().add(selectedRule);
        fts.rules().add(otherRule);

is to create color rules between IDs and other area that i don't select right??
but if i create a new rule for other one, how i set it for each area while all the data is in 1 variable (IDs)??

Darmawan

Jody Garnett-2 wrote:
No problem.

To get different colors you will want to create multiple rules; each  
with their own description of how to draw. And bundle them up into a  
single style.  Time to look at how that createSelectedStyle function  
works.

Read over:
- http://docs.codehaus.org/display/GEOTDOC/04+Styling
- http://www.opengeospatial.org/standards/sld

Jody

> style = createSelectedStyle(selectedIds);
> mapFrame.getMapContext().getLayer(0).setStyle(style);
>
> then when i displayed it in the map, color of the IDs will be same
> how to make the color different for each IDs??
> what i asked you before is example how to change some IDs style so i  
> can understand my problem
> how i can change the style for each IDs when i call  
> createSelectedStyle method??
>
> thank you before
> Darmawan
>