Re: [JPP-Devel] how to refresh a layer in run time

2010-07-17 Thread Elton Chan
Hi Stefan,

Your code really helps.

I can refresh a layer now.

What I did is to do all recurrent task in the  run(TaskMonitor monitor, 
PlugInContext context) function. Create a layer, and retrieve dataset from 
database by creating a recordset _RS, then loop it using the following code

while (_RS.next()){
if(monitor.isCancelRequested()){return;}
updatePostgisLayer(Changing, _RS); // this update a specify attribute to 
control color.
monitor.report(count, 100, Evolution);
count++;
Thread.sleep(1000L); // delay a bit so that you can see the changes.
Changing.fireLayerChanged(LayerEventType.APPEARANCE_CHANGED); //refresh
}

BTW, in your code, I see that you are using
movieLayer.setFeatureCollectionModified(true);
and
movieLayer.setFeatureCollectionModified(false);

In what circumstance, you need to use it.

Many Thanks,
Elton

--- On Wed, 7/14/10, Stefan Steiniger sst...@geo.uzh.ch wrote:

 From: Stefan Steiniger sst...@geo.uzh.ch
 Subject: Re: [JPP-Devel] how to refresh a layer in run time
 To: OpenJump develop and use jump-pilot-devel@lists.sourceforge.net
 Date: Wednesday, July 14, 2010, 5:50 PM
 Hei Elton,
 
 my experimental code is attached. But not sure if it helps
 you.
 on vi.. maybe you have to apply the style? or the trick is
 done by firing the layer-changed event? haven't tested.
 
 stefan
 
 Elton Chan wrote:
  Hi Stefan,
  
  Could you send me your code for my testing as I would
 like to see how do you update the layerpanel according to
 order and then update the layerpanel.
  
  BTW, following are conditions for my case.
  i. all features to be displayed are stored in one
 polygon layer;
  ii. all features will be displayed at any time step;
  iii. For each time step, an attribute that controls
 feature's color would be updated from an event table. The
 event table stores order, polygon id and color code.
  iv. After color is updated for all features, it will
 be shown on the layerpanel.
  
  However, the problem I encountered is at step iv. that
 althrough the attribute can be updated without problem, it
 cannot be shown/refresh on the layerpanel.
  
  For your case, I wonder if you could create a sql
 query to retrieve particular feature and display at a time.
 (assume you are using postgis)
  
  Thanks,
  Elton
  
  --- On Tue, 7/13/10, Stefan Steiniger sst...@geo.uzh.ch
 wrote:
  
  From: Stefan Steiniger sst...@geo.uzh.ch
  Subject: Re: [JPP-Devel] how to refresh a layer in
 run time
  To: OpenJump develop and use jump-pilot-devel@lists.sourceforge.net
  Date: Tuesday, July 13, 2010, 12:15 AM
  mhm.. not really a solution.
  
  I assume that
  - all features to be displayed are stored in one
 layer
  - only one(!) feature needs to be displayed at a
 time step
  - one attribute of the layer has the information
 about the
  the order the features are to be displayed.
  
  Then I just display the features after each other
 by
  modifying the FeatureCollection of the Layer.
  
  Of course I can send the code if someone wants to
 see/use
  it.
  
  So, quite a bit of assumptions which works for my
 special
  case - seing how a bear home range evolves over
 time with the number of
  new GPS points collected (a home range is a
 polygon or a multi
  polygon and I have almost as much polygons as GPS
 point).
  
  stefan
  
  Larry Becker schrieb:
  Hi Elton,
  
     Make your loop variable a class
  variable.  Have the loop control and 
  attribute update inside the event
 handler.  While
  the loop is still 
  going invoke the event handler again, also
 from within
  the event 
  handler.  Once you have set up the event
 handler
  and invoked it once, 
  just fall off the end of the execute
 routine.  I
  would give an example,  
  but I'm away from my development system.
  
     It sounds like Stefan also has a
 need
  for animation.  Perhaps he will 
  show you his solution.
  
  Larry
  
  On Fri, Jul 9, 2010 at 10:41 PM, Elton Chan
 elton.c...@yahoo.com
  mailto:elton.c...@yahoo.com
  wrote:
       Dear Larry,
  
       Could you tell me how it
  works? It seems a loop is required for
       continous update an
 attribute.
  How can it be replaced by a event
       handler?
  
       Thanks,
       Elton
  
  
       --- On *Fri, 7/2/10,
 Larry
  Becker /becker.la...@gmail.com
       mailto:becker.la...@gmail.com/*
  wrote:
  
           From: Larry
  Becker becker.la...@gmail.com
          
 mailto:becker.la...@gmail.com
           Subject:
 Re:
  [JPP-Devel] how to refresh a layer in run time
           To:
 OpenJump
  develop and use
           jump-pilot-devel@lists.sourceforge.net
          
 mailto:jump-pilot-devel@lists.sourceforge.net
           Date:
 Friday,
  July 2, 2010, 5:33 PM
  
           Hi Elton,
  
             I
 think
  you are going to have to restructure you code from
 a
           loop to be
 an
  event handler that triggers itself until the end
           of some
  counter.  That is the only sure way to play
 nice with
           the GUI.
  
           Larry
  
  

Re: [JPP-Devel] how to refresh a layer in run time

2010-07-17 Thread Stefan Steiniger
Hei Elton,

great that my code helped you.
on your question:

 BTW, in your code, I see that you are using
 movieLayer.setFeatureCollectionModified(true);
 and
 movieLayer.setFeatureCollectionModified(false);
 
  In what circumstance, you need to use it.
 

well, I am not really sure -  switch it off (false) and on (true) - to 
avoid that events are fired until all changes are done. Because I think 
as soon as I change a Layer/FeatureCollection it will fire an event and 
redrawing processes start (actually usually EditTransactions would be 
used to modify a layer, for instance when drawing tools are used).
However, I may be wrong here - mixed up my memories. Maybe I should 
study other plugins... but well.. currently my time is limited for 
proper/fool-proof development

stefan

--
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
___
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel


Re: [JPP-Devel] how to refresh a layer in run time

2010-07-14 Thread Stefan Steiniger

Hei Elton,

my experimental code is attached. But not sure if it helps you.
on vi.. maybe you have to apply the style? or the trick is done by 
firing the layer-changed event? haven't tested.


stefan

Elton Chan wrote:

Hi Stefan,

Could you send me your code for my testing as I would like to see how do you 
update the layerpanel according to order and then update the layerpanel.

BTW, following are conditions for my case.
i. all features to be displayed are stored in one polygon layer;
ii. all features will be displayed at any time step;
iii. For each time step, an attribute that controls feature's color would be 
updated from an event table. The event table stores order, polygon id and color 
code.
iv. After color is updated for all features, it will be shown on the layerpanel.

However, the problem I encountered is at step iv. that althrough the attribute 
can be updated without problem, it cannot be shown/refresh on the layerpanel.

For your case, I wonder if you could create a sql query to retrieve particular 
feature and display at a time. (assume you are using postgis)

Thanks,
Elton

--- On Tue, 7/13/10, Stefan Steiniger sst...@geo.uzh.ch wrote:


From: Stefan Steiniger sst...@geo.uzh.ch
Subject: Re: [JPP-Devel] how to refresh a layer in run time
To: OpenJump develop and use jump-pilot-devel@lists.sourceforge.net
Date: Tuesday, July 13, 2010, 12:15 AM
mhm.. not really a solution.

I assume that
- all features to be displayed are stored in one layer
- only one(!) feature needs to be displayed at a time step
- one attribute of the layer has the information about the
the order the 
features are to be displayed.


Then I just display the features after each other by
modifying the 
FeatureCollection of the Layer.


Of course I can send the code if someone wants to see/use
it.

So, quite a bit of assumptions which works for my special
case - seing 
how a bear home range evolves over time with the number of
new GPS 
points collected (a home range is a polygon or a multi
polygon and I 
have almost as much polygons as GPS point).


stefan

Larry Becker schrieb:

Hi Elton,

   Make your loop variable a class
variable.  Have the loop control and 

attribute update inside the event handler.  While
the loop is still 

going invoke the event handler again, also from within
the event 

handler.  Once you have set up the event handler
and invoked it once, 

just fall off the end of the execute routine.  I
would give an example,  

but I'm away from my development system.

   It sounds like Stefan also has a need
for animation.  Perhaps he will 

show you his solution.

Larry

On Fri, Jul 9, 2010 at 10:41 PM, Elton Chan elton.c...@yahoo.com
mailto:elton.c...@yahoo.com

wrote:

 Dear Larry,

 Could you tell me how it

works? It seems a loop is required for

 continous update an attribute.

How can it be replaced by a event

 handler?

 Thanks,
 Elton


 --- On *Fri, 7/2/10, Larry

Becker /becker.la...@gmail.com

 mailto:becker.la...@gmail.com/*

wrote:


 From: Larry

Becker becker.la...@gmail.com

 mailto:becker.la...@gmail.com
 Subject: Re:

[JPP-Devel] how to refresh a layer in run time

 To: OpenJump

develop and use

 jump-pilot-devel@lists.sourceforge.net
 mailto:jump-pilot-devel@lists.sourceforge.net
 Date: Friday,

July 2, 2010, 5:33 PM


 Hi Elton,

   I think

you are going to have to restructure you code from a

 loop to be an

event handler that triggers itself until the end

 of some

counter.  That is the only sure way to play nice with

 the GUI.

 Larry

 On Fri, Jul 2,

2010 at 12:06 PM, Elton Chan

 elton.c...@yahoo.com
 http://mc/compose?to=elton.c...@yahoo.com

wrote:

 Hi

Larry,
 

   I've tried the LayerView Panel().repaint()
with
 

   InvokeAndWait(). However, the layerpanel
still cannot refesh
 

   and the for loop continues until all
finishing all the
 

   Recordset.
 

   The following code is added after
attribute update:

 if

(SwingUtilities.isEventDispatchThread()) {
   
 
   context.getLayerViewPanel().repaint();
   
 
   System.out.println(repaint!!);

 Always
 

   hit this line.
   

 }
   

 else {
   
 
   SwingUtilities.invokeAndWait(new Runnable(

) {
   
 
   public void run( ) {
   
   
 
   context.getLayerViewPanel().repaint();
   
   
 System.out.println(repaint!!!);
   

}
   

 });
   

 }
 

   Any idea?


 

   --- On *Thu, 7/1/10, Larry Becker /becker.la...@gmail.com
 

   http://mc/compose?to=becker.la...@gmail.com/*
wrote:


 

   From: Larry Becker 

Re: [JPP-Devel] how to refresh a layer in run time

2010-07-12 Thread Stefan Steiniger
mhm.. not really a solution.

I assume that
- all features to be displayed are stored in one layer
- only one(!) feature needs to be displayed at a time step
- one attribute of the layer has the information about the the order the 
features are to be displayed.

Then I just display the features after each other by modifying the 
FeatureCollection of the Layer.

Of course I can send the code if someone wants to see/use it.

So, quite a bit of assumptions which works for my special case - seing 
how a bear home range evolves over time with the number of new GPS 
points collected (a home range is a polygon or a multi polygon and I 
have almost as much polygons as GPS point).

stefan

Larry Becker schrieb:
 Hi Elton,
 
   Make your loop variable a class variable.  Have the loop control and 
 attribute update inside the event handler.  While the loop is still 
 going invoke the event handler again, also from within the event 
 handler.  Once you have set up the event handler and invoked it once, 
 just fall off the end of the execute routine.  I would give an example,  
 but I'm away from my development system.
 
   It sounds like Stefan also has a need for animation.  Perhaps he will 
 show you his solution.
 
 Larry
 
 On Fri, Jul 9, 2010 at 10:41 PM, Elton Chan elton.c...@yahoo.com 
 mailto:elton.c...@yahoo.com wrote:
 
 Dear Larry,
 
 Could you tell me how it works? It seems a loop is required for
 continous update an attribute. How can it be replaced by a event
 handler?
 
 Thanks,
 Elton
 
 
 --- On *Fri, 7/2/10, Larry Becker /becker.la...@gmail.com
 mailto:becker.la...@gmail.com/* wrote:
 
 
 From: Larry Becker becker.la...@gmail.com
 mailto:becker.la...@gmail.com
 Subject: Re: [JPP-Devel] how to refresh a layer in run time
 To: OpenJump develop and use
 jump-pilot-devel@lists.sourceforge.net
 mailto:jump-pilot-devel@lists.sourceforge.net
 Date: Friday, July 2, 2010, 5:33 PM
 
 
 Hi Elton,
 
   I think you are going to have to restructure you code from a
 loop to be an event handler that triggers itself until the end
 of some counter.  That is the only sure way to play nice with
 the GUI.
 
 Larry
 
 On Fri, Jul 2, 2010 at 12:06 PM, Elton Chan
 elton.c...@yahoo.com
 http://mc/compose?to=elton.c...@yahoo.com wrote:
 
 Hi Larry,
 
 I've tried the LayerView Panel().repaint() with
 InvokeAndWait(). However, the layerpanel still cannot refesh
 and the for loop continues until all finishing all the
 Recordset.
 
 The following code is added after attribute update:
 if (SwingUtilities.isEventDispatchThread()) {
 context.getLayerViewPanel().repaint();
 System.out.println(repaint!!);  Always
 hit this line.
 }
 else {
 SwingUtilities.invokeAndWait(new Runnable( ) {
 public void run( ) {
 context.getLayerViewPanel().repaint();
 System.out.println(repaint!!!);
}
 });
 }
 
 Any idea?
 
 
 --- On *Thu, 7/1/10, Larry Becker /becker.la...@gmail.com
 http://mc/compose?to=becker.la...@gmail.com/* wrote:
 
 
 From: Larry Becker becker.la...@gmail.com
 http://mc/compose?to=becker.la...@gmail.com
 Subject: Re: [JPP-Devel] how to refresh a layer in run time
 To: OpenJump develop and use
 jump-pilot-devel@lists.sourceforge.net
 http://mc/compose?to=jump-pilot-de...@lists.sourceforge.net
 Date: Thursday, July 1, 2010, 2:30 PM
 
 
 Sorry, Elton, not NIls.  I answered so many questions
 that I got confused about who I was answering.  :-)
 
 On Thu, Jul 1, 2010 at 8:24 AM, Larry Becker
 becker.la...@gmail.com
 http://mc/compose?to=becker.la...@gmail.com wrote:
 
 Hi Nils,
 
   I believe you might be running into problems
 updating because your loop is blocking the GUI
 thread.  You might try a LayerViewPanel.repaint()
 using invokeAndWait().
 
 Larry
 
 
 On Thu, Jul 1, 2010 at 6:42 AM, Elton Chan
 elton.c...@yahoo.com
 http://mc/compose?to=elton.c...@yahoo.com wrote:
 
 Hi there,
 
 I would like to refresh a layer after changing
 attribute of each feature in the layer based on

Re: [JPP-Devel] how to refresh a layer in run time

2010-07-12 Thread Elton Chan
Hi Stefan,

Could you send me your code for my testing as I would like to see how do you 
update the layerpanel according to order and then update the layerpanel.

BTW, following are conditions for my case.
i. all features to be displayed are stored in one polygon layer;
ii. all features will be displayed at any time step;
iii. For each time step, an attribute that controls feature's color would be 
updated from an event table. The event table stores order, polygon id and color 
code.
iv. After color is updated for all features, it will be shown on the layerpanel.

However, the problem I encountered is at step iv. that althrough the attribute 
can be updated without problem, it cannot be shown/refresh on the layerpanel.

For your case, I wonder if you could create a sql query to retrieve particular 
feature and display at a time. (assume you are using postgis)

Thanks,
Elton

--- On Tue, 7/13/10, Stefan Steiniger sst...@geo.uzh.ch wrote:

 From: Stefan Steiniger sst...@geo.uzh.ch
 Subject: Re: [JPP-Devel] how to refresh a layer in run time
 To: OpenJump develop and use jump-pilot-devel@lists.sourceforge.net
 Date: Tuesday, July 13, 2010, 12:15 AM
 mhm.. not really a solution.
 
 I assume that
 - all features to be displayed are stored in one layer
 - only one(!) feature needs to be displayed at a time step
 - one attribute of the layer has the information about the
 the order the 
 features are to be displayed.
 
 Then I just display the features after each other by
 modifying the 
 FeatureCollection of the Layer.
 
 Of course I can send the code if someone wants to see/use
 it.
 
 So, quite a bit of assumptions which works for my special
 case - seing 
 how a bear home range evolves over time with the number of
 new GPS 
 points collected (a home range is a polygon or a multi
 polygon and I 
 have almost as much polygons as GPS point).
 
 stefan
 
 Larry Becker schrieb:
  Hi Elton,
  
    Make your loop variable a class
 variable.  Have the loop control and 
  attribute update inside the event handler.  While
 the loop is still 
  going invoke the event handler again, also from within
 the event 
  handler.  Once you have set up the event handler
 and invoked it once, 
  just fall off the end of the execute routine.  I
 would give an example,  
  but I'm away from my development system.
  
    It sounds like Stefan also has a need
 for animation.  Perhaps he will 
  show you his solution.
  
  Larry
  
  On Fri, Jul 9, 2010 at 10:41 PM, Elton Chan elton.c...@yahoo.com
 
  mailto:elton.c...@yahoo.com
 wrote:
  
      Dear Larry,
  
      Could you tell me how it
 works? It seems a loop is required for
      continous update an attribute.
 How can it be replaced by a event
      handler?
  
      Thanks,
      Elton
  
  
      --- On *Fri, 7/2/10, Larry
 Becker /becker.la...@gmail.com
      mailto:becker.la...@gmail.com/*
 wrote:
  
  
          From: Larry
 Becker becker.la...@gmail.com
          mailto:becker.la...@gmail.com
          Subject: Re:
 [JPP-Devel] how to refresh a layer in run time
          To: OpenJump
 develop and use
          jump-pilot-devel@lists.sourceforge.net
          mailto:jump-pilot-devel@lists.sourceforge.net
          Date: Friday,
 July 2, 2010, 5:33 PM
  
  
          Hi Elton,
  
            I think
 you are going to have to restructure you code from a
          loop to be an
 event handler that triggers itself until the end
          of some
 counter.  That is the only sure way to play nice with
          the GUI.
  
          Larry
  
          On Fri, Jul 2,
 2010 at 12:06 PM, Elton Chan
          elton.c...@yahoo.com
          http://mc/compose?to=elton.c...@yahoo.com
 wrote:
  
              Hi
 Larry,
  
          
    I've tried the LayerView Panel().repaint()
 with
          
    InvokeAndWait(). However, the layerpanel
 still cannot refesh
          
    and the for loop continues until all
 finishing all the
          
    Recordset.
  
          
    The following code is added after
 attribute update:
              if
 (SwingUtilities.isEventDispatchThread()) {
                
          
    context.getLayerViewPanel().repaint();
                
          
    System.out.println(repaint!!);
  Always
          
    hit this line.
                
          }
                
          else {
                
          
    SwingUtilities.invokeAndWait(new Runnable(
 ) {
                
              
    public void run( ) {
                
                
  
    context.getLayerViewPanel().repaint();
                
                
      System.out.println(repaint!!!);
                
                 }
                
              });
                
          }
  
          
    Any idea?
  
  
          
    --- On *Thu, 7/1/10, Larry Becker /becker.la...@gmail.com
          
    http://mc/compose?to=becker.la...@gmail.com/*
 wrote:
  
  
              
    From: Larry Becker becker.la...@gmail.com
              
    

Re: [JPP-Devel] how to refresh a layer in run time

2010-07-09 Thread Elton Chan
Dear Larry,

Could you tell me how it works? It seems a loop is required for continous 
update an attribute. How can it be replaced by a event handler?

Thanks,
Elton

--- On Fri, 7/2/10, Larry Becker becker.la...@gmail.com wrote:

From: Larry Becker becker.la...@gmail.com
Subject: Re: [JPP-Devel] how to refresh a layer in run time
To: OpenJump develop and use jump-pilot-devel@lists.sourceforge.net
Date: Friday, July 2, 2010, 5:33 PM

Hi Elton,

  I think you are going to have to restructure you code from a loop to be an 
event handler that triggers itself until the end of some counter.  That is the 
only sure way to play nice with the GUI.

Larry


On Fri, Jul 2, 2010 at 12:06 PM, Elton Chan elton.c...@yahoo.com wrote:

Hi Larry,

I've tried the LayerView Panel().repaint() with InvokeAndWait(). However, the 
layerpanel still cannot refesh and the for loop continues until all finishing 
all the Recordset.


The following code is added after attribute update:
if (SwingUtilities.isEventDispatchThread()) {
                context.getLayerViewPanel().repaint();
                System.out.println(repaint!!);  Always hit this line.

            }
            else {
        SwingUtilities.invokeAndWait(new Runnable( ) {
   
     public void run( ) {
            context.getLayerViewPanel().repaint();
            System.out.println(repaint!!!);
       }
        });

            }

Any idea?


--- On Thu, 7/1/10, Larry Becker becker.la...@gmail.com wrote:


From: Larry Becker
 becker.la...@gmail.com
Subject: Re: [JPP-Devel] how to refresh a layer in run time
To: OpenJump develop and use jump-pilot-devel@lists.sourceforge.net

Date: Thursday, July 1, 2010, 2:30 PM

Sorry, Elton, not NIls.  I answered so many questions that I got confused about 
who I was answering.  :-)

On Thu, Jul 1, 2010 at 8:24 AM, Larry Becker becker.la...@gmail.com wrote:


Hi Nils,

  I believe you might be running into problems updating because your loop is 
blocking the GUI thread.  You might try a LayerViewPanel.repaint() using 
invokeAndWait().



Larry


On Thu, Jul 1, 2010 at 6:42 AM, Elton Chan elton.c...@yahoo.com wrote:



Hi there,



I would like to refresh a layer after changing attribute of each feature in the 
layer based on an event table. The event table records attribute assigned to 
each feature at specified stage. Following is the schema of the event table:






Event(

StageID int, // StageID defines sequence of the event

Feature01 int, // value to be assigned to feature 01

Feature02 int, // value to be assigned to feature 02

...

Feature10 int)



Based on the StageID sequence, values for each feature would be retrieved and 
updated to corresponding feature. Finally,  update value would be visualized by 
unique colortheming. However, it seems the layer refreshing can only be 
effective outside the ResultSet loop of the event table.






The following is the program codes:



Inside execute(PlugInContext context)

// get a layer

lyr = context.getLayerManager().getLayer(postgis);

//create a Resultset RS

ResultSet RS stat.executeQuery(select * from Event);

while (RS.next())

{

updatePostgisLayer(lyr, RS);//This function updates feature in the layer

}

 layer refreshes after the looping all the resultset.



My question is how to refresh the layer once attribute values are updated for 
each each row of the RecordSet, i.e. immediately after the updatePostgisLayer 
function.



If I change the query to retrieve specify row (i.e. single row only), layer can 
be refreshed. But it requires to activate it manually for each update.



I tried to add lyr.fireLayerChanged(LayerEventType.APPEARANCE_CHANGED);

or lyr.fireAppearanceChanged() after the updatePostgisLayer function but it 
didn't work.



Anyone can help?



thanks,

Elton









--

This SF.net email is sponsored by Sprint

What will you do first with EVO, the first 4G phone?

Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first

___

Jump-pilot-devel mailing list

Jump-pilot-devel@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel






-Inline Attachment Follows-

--
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?

Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
-Inline Attachment Follows-


___
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 Sprint

What will you do first with EVO, the first 4G phone?

Visit sprint.com/first -- 

Re: [JPP-Devel] how to refresh a layer in run time

2010-07-09 Thread Larry Becker
Hi Elton,

  Make your loop variable a class variable.  Have the loop control and
attribute update inside the event handler.  While the loop is still going
invoke the event handler again, also from within the event handler.  Once
you have set up the event handler and invoked it once, just fall off the end
of the execute routine.  I would give an example,  but I'm away from my
development system.

  It sounds like Stefan also has a need for animation.  Perhaps he will show
you his solution.

Larry

On Fri, Jul 9, 2010 at 10:41 PM, Elton Chan elton.c...@yahoo.com wrote:

 Dear Larry,

 Could you tell me how it works? It seems a loop is required for continous
 update an attribute. How can it be replaced by a event handler?

 Thanks,
 Elton


 --- On *Fri, 7/2/10, Larry Becker becker.la...@gmail.com* wrote:


 From: Larry Becker becker.la...@gmail.com
 Subject: Re: [JPP-Devel] how to refresh a layer in run time
 To: OpenJump develop and use jump-pilot-devel@lists.sourceforge.net
 Date: Friday, July 2, 2010, 5:33 PM


 Hi Elton,

   I think you are going to have to restructure you code from a loop to be
 an event handler that triggers itself until the end of some counter.  That
 is the only sure way to play nice with the GUI.

 Larry

 On Fri, Jul 2, 2010 at 12:06 PM, Elton Chan 
 elton.c...@yahoo.comhttp://mc/compose?to=elton.c...@yahoo.com
  wrote:

 Hi Larry,

 I've tried the LayerView Panel().repaint() with InvokeAndWait(). However,
 the layerpanel still cannot refesh and the for loop continues until all
 finishing all the Recordset.

 The following code is added after attribute update:
 if (SwingUtilities.isEventDispatchThread()) {
 context.getLayerViewPanel().repaint();
 System.out.println(repaint!!);  Always hit this
 line.
 }
 else {
 SwingUtilities.invokeAndWait(new Runnable( ) {
 public void run( ) {
 context.getLayerViewPanel().repaint();
 System.out.println(repaint!!!);
}
 });
 }

 Any idea?


 --- On *Thu, 7/1/10, Larry Becker 
 becker.la...@gmail.comhttp://mc/compose?to=becker.la...@gmail.com
 * wrote:


 From: Larry Becker 
 becker.la...@gmail.comhttp://mc/compose?to=becker.la...@gmail.com
 
 Subject: Re: [JPP-Devel] how to refresh a layer in run time
 To: OpenJump develop and use 
 jump-pilot-devel@lists.sourceforge.nethttp://mc/compose?to=jump-pilot-de...@lists.sourceforge.net
 
 Date: Thursday, July 1, 2010, 2:30 PM


 Sorry, Elton, not NIls.  I answered so many questions that I got confused
 about who I was answering.  :-)

 On Thu, Jul 1, 2010 at 8:24 AM, Larry Becker 
 becker.la...@gmail.comhttp://mc/compose?to=becker.la...@gmail.com
  wrote:

 Hi Nils,

   I believe you might be running into problems updating because your loop
 is blocking the GUI thread.  You might try a LayerViewPanel.repaint() using
 invokeAndWait().

 Larry


 On Thu, Jul 1, 2010 at 6:42 AM, Elton Chan 
 elton.c...@yahoo.comhttp://mc/compose?to=elton.c...@yahoo.com
  wrote:

 Hi there,

 I would like to refresh a layer after changing attribute of each feature
 in the layer based on an event table. The event table records attribute
 assigned to each feature at specified stage. Following is the schema of the
 event table:

 Event(
 StageID int, // StageID defines sequence of the event
 Feature01 int, // value to be assigned to feature 01
 Feature02 int, // value to be assigned to feature 02
 ...
 Feature10 int)

 Based on the StageID sequence, values for each feature would be
 retrieved and updated to corresponding feature. Finally,  update value 
 would
 be visualized by unique colortheming. However, it seems the layer 
 refreshing
 can only be effective outside the ResultSet loop of the event table.

 The following is the program codes:

 Inside execute(PlugInContext context)
 // get a layer
 lyr = context.getLayerManager().getLayer(postgis);
 //create a Resultset RS
 ResultSet RS stat.executeQuery(select * from Event);
 while (RS.next())
 {
 updatePostgisLayer(lyr, RS);//This function updates feature in the layer
 }
  layer refreshes after the looping all the resultset.

 My question is how to refresh the layer once attribute values are
 updated for each each row of the RecordSet, i.e. immediately after the
 updatePostgisLayer function.

 If I change the query to retrieve specify row (i.e. single row only),
 layer can be refreshed. But it requires to activate it manually for each
 update.

 I tried to add lyr.fireLayerChanged(LayerEventType.APPEARANCE_CHANGED);
 or lyr.fireAppearanceChanged() after the updatePostgisLayer function but
 it didn't work.

 Anyone can help?

 thanks,
 Elton





 --
 This SF.net email is sponsored by Sprint
 What will you do first with EVO, the first 4G phone?
 Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
 

Re: [JPP-Devel] how to refresh a layer in run time

2010-07-02 Thread Elton Chan
Hi Larry,

I've tried the LayerView Panel().repaint() with InvokeAndWait(). However, the 
layerpanel still cannot refesh and the for loop continues until all finishing 
all the Recordset.

The following code is added after attribute update:
if (SwingUtilities.isEventDispatchThread()) {
                context.getLayerViewPanel().repaint();
                System.out.println(repaint!!);  Always hit this line.
            }
            else {
        SwingUtilities.invokeAndWait(new Runnable( ) {
        public void run( ) {
            context.getLayerViewPanel().repaint();
            System.out.println(repaint!!!);
       }
        });
            }

Any idea?


--- On Thu, 7/1/10, Larry Becker becker.la...@gmail.com wrote:

From: Larry Becker becker.la...@gmail.com
Subject: Re: [JPP-Devel] how to refresh a layer in run time
To: OpenJump develop and use jump-pilot-devel@lists.sourceforge.net
Date: Thursday, July 1, 2010, 2:30 PM

Sorry, Elton, not NIls.  I answered so many questions that I got confused about 
who I was answering.  :-)

On Thu, Jul 1, 2010 at 8:24 AM, Larry Becker becker.la...@gmail.com wrote:

Hi Nils,

  I believe you might be running into problems updating because your loop is 
blocking the GUI thread.  You might try a LayerViewPanel.repaint() using 
invokeAndWait().


Larry


On Thu, Jul 1, 2010 at 6:42 AM, Elton Chan elton.c...@yahoo.com wrote:


Hi there,



I would like to refresh a layer after changing attribute of each feature in the 
layer based on an event table. The event table records attribute assigned to 
each feature at specified stage. Following is the schema of the event table:





Event(

StageID int, // StageID defines sequence of the event

Feature01 int, // value to be assigned to feature 01

Feature02 int, // value to be assigned to feature 02

...

Feature10 int)



Based on the StageID sequence, values for each feature would be retrieved and 
updated to corresponding feature. Finally,  update value would be visualized by 
unique colortheming. However, it seems the layer refreshing can only be 
effective outside the ResultSet loop of the event table.





The following is the program codes:



Inside execute(PlugInContext context)

// get a layer

lyr = context.getLayerManager().getLayer(postgis);

//create a Resultset RS

ResultSet RS stat.executeQuery(select * from Event);

while (RS.next())

{

updatePostgisLayer(lyr, RS);//This function updates feature in the layer

}

 layer refreshes after the looping all the resultset.



My question is how to refresh the layer once attribute values are updated for 
each each row of the RecordSet, i.e. immediately after the updatePostgisLayer 
function.



If I change the query to retrieve specify row (i.e. single row only), layer can 
be refreshed. But it requires to activate it manually for each update.



I tried to add lyr.fireLayerChanged(LayerEventType.APPEARANCE_CHANGED);

or lyr.fireAppearanceChanged() after the updatePostgisLayer function but it 
didn't work.



Anyone can help?



thanks,

Elton









--

This SF.net email is sponsored by Sprint

What will you do first with EVO, the first 4G phone?

Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first

___

Jump-pilot-devel mailing list

Jump-pilot-devel@lists.sourceforge.net

https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel






-Inline Attachment Follows-

--
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
-Inline Attachment Follows-

___
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 Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first___
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel


Re: [JPP-Devel] how to refresh a layer in run time

2010-07-02 Thread Larry Becker
Hi Elton,

  I think you are going to have to restructure you code from a loop to be an
event handler that triggers itself until the end of some counter.  That is
the only sure way to play nice with the GUI.

Larry

On Fri, Jul 2, 2010 at 12:06 PM, Elton Chan elton.c...@yahoo.com wrote:

 Hi Larry,

 I've tried the LayerView Panel().repaint() with InvokeAndWait(). However,
 the layerpanel still cannot refesh and the for loop continues until all
 finishing all the Recordset.

 The following code is added after attribute update:
 if (SwingUtilities.isEventDispatchThread()) {
 context.getLayerViewPanel().repaint();
 System.out.println(repaint!!);  Always hit this line.
 }
 else {
 SwingUtilities.invokeAndWait(new Runnable( ) {
 public void run( ) {
 context.getLayerViewPanel().repaint();
 System.out.println(repaint!!!);
}
 });
 }

 Any idea?


 --- On *Thu, 7/1/10, Larry Becker becker.la...@gmail.com* wrote:


 From: Larry Becker becker.la...@gmail.com
 Subject: Re: [JPP-Devel] how to refresh a layer in run time
 To: OpenJump develop and use jump-pilot-devel@lists.sourceforge.net
 Date: Thursday, July 1, 2010, 2:30 PM


 Sorry, Elton, not NIls.  I answered so many questions that I got confused
 about who I was answering.  :-)

 On Thu, Jul 1, 2010 at 8:24 AM, Larry Becker 
 becker.la...@gmail.comhttp://mc/compose?to=becker.la...@gmail.com
  wrote:

 Hi Nils,

   I believe you might be running into problems updating because your loop
 is blocking the GUI thread.  You might try a LayerViewPanel.repaint() using
 invokeAndWait().

 Larry


 On Thu, Jul 1, 2010 at 6:42 AM, Elton Chan 
 elton.c...@yahoo.comhttp://mc/compose?to=elton.c...@yahoo.com
  wrote:

 Hi there,

 I would like to refresh a layer after changing attribute of each feature
 in the layer based on an event table. The event table records attribute
 assigned to each feature at specified stage. Following is the schema of the
 event table:

 Event(
 StageID int, // StageID defines sequence of the event
 Feature01 int, // value to be assigned to feature 01
 Feature02 int, // value to be assigned to feature 02
 ...
 Feature10 int)

 Based on the StageID sequence, values for each feature would be retrieved
 and updated to corresponding feature. Finally,  update value would be
 visualized by unique colortheming. However, it seems the layer refreshing
 can only be effective outside the ResultSet loop of the event table.

 The following is the program codes:

 Inside execute(PlugInContext context)
 // get a layer
 lyr = context.getLayerManager().getLayer(postgis);
 //create a Resultset RS
 ResultSet RS stat.executeQuery(select * from Event);
 while (RS.next())
 {
 updatePostgisLayer(lyr, RS);//This function updates feature in the layer
 }
  layer refreshes after the looping all the resultset.

 My question is how to refresh the layer once attribute values are updated
 for each each row of the RecordSet, i.e. immediately after the
 updatePostgisLayer function.

 If I change the query to retrieve specify row (i.e. single row only),
 layer can be refreshed. But it requires to activate it manually for each
 update.

 I tried to add lyr.fireLayerChanged(LayerEventType.APPEARANCE_CHANGED);
 or lyr.fireAppearanceChanged() after the updatePostgisLayer function but
 it didn't work.

 Anyone can help?

 thanks,
 Elton





 --
 This SF.net email is sponsored by Sprint
 What will you do first with EVO, the first 4G phone?
 Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
 ___
 Jump-pilot-devel mailing list
 Jump-pilot-devel@lists.sourceforge.nethttp://mc/compose?to=jump-pilot-de...@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel




 -Inline Attachment Follows-



 --
 This SF.net email is sponsored by Sprint
 What will you do first with EVO, the first 4G phone?
 Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first

 -Inline Attachment Follows-


 ___
 Jump-pilot-devel mailing list
 Jump-pilot-devel@lists.sourceforge.nethttp://mc/compose?to=jump-pilot-de...@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel




 --
 This SF.net email is sponsored by Sprint
 What will you do first with EVO, the first 4G phone?
 Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
 ___
 Jump-pilot-devel mailing list
 Jump-pilot-devel@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel



[JPP-Devel] how to refresh a layer in run time

2010-07-01 Thread Elton Chan
Hi there,

I would like to refresh a layer after changing attribute of each feature in the 
layer based on an event table. The event table records attribute assigned to 
each feature at specified stage. Following is the schema of the event table:

Event(
StageID int, // StageID defines sequence of the event
Feature01 int, // value to be assigned to feature 01
Feature02 int, // value to be assigned to feature 02
...
Feature10 int)

Based on the StageID sequence, values for each feature would be retrieved and 
updated to corresponding feature. Finally,  update value would be visualized by 
unique colortheming. However, it seems the layer refreshing can only be 
effective outside the ResultSet loop of the event table.

The following is the program codes:

Inside execute(PlugInContext context)
// get a layer
lyr = context.getLayerManager().getLayer(postgis);
//create a Resultset RS
ResultSet RS stat.executeQuery(select * from Event);
while (RS.next())
{
updatePostgisLayer(lyr, RS);//This function updates feature in the layer
}
 layer refreshes after the looping all the resultset.

My question is how to refresh the layer once attribute values are updated for 
each each row of the RecordSet, i.e. immediately after the updatePostgisLayer 
function.

If I change the query to retrieve specify row (i.e. single row only), layer can 
be refreshed. But it requires to activate it manually for each update.

I tried to add lyr.fireLayerChanged(LayerEventType.APPEARANCE_CHANGED);
or lyr.fireAppearanceChanged() after the updatePostgisLayer function but it 
didn't work. 

Anyone can help?

thanks,
Elton


  

--
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
___
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel


Re: [JPP-Devel] how to refresh a layer in run time

2010-07-01 Thread Larry Becker
Hi Nils,

  I believe you might be running into problems updating because your loop is
blocking the GUI thread.  You might try a LayerViewPanel.repaint() using
invokeAndWait().

Larry

On Thu, Jul 1, 2010 at 6:42 AM, Elton Chan elton.c...@yahoo.com wrote:

 Hi there,

 I would like to refresh a layer after changing attribute of each feature in
 the layer based on an event table. The event table records attribute
 assigned to each feature at specified stage. Following is the schema of the
 event table:

 Event(
 StageID int, // StageID defines sequence of the event
 Feature01 int, // value to be assigned to feature 01
 Feature02 int, // value to be assigned to feature 02
 ...
 Feature10 int)

 Based on the StageID sequence, values for each feature would be retrieved
 and updated to corresponding feature. Finally,  update value would be
 visualized by unique colortheming. However, it seems the layer refreshing
 can only be effective outside the ResultSet loop of the event table.

 The following is the program codes:

 Inside execute(PlugInContext context)
 // get a layer
 lyr = context.getLayerManager().getLayer(postgis);
 //create a Resultset RS
 ResultSet RS stat.executeQuery(select * from Event);
 while (RS.next())
 {
 updatePostgisLayer(lyr, RS);//This function updates feature in the layer
 }
  layer refreshes after the looping all the resultset.

 My question is how to refresh the layer once attribute values are updated
 for each each row of the RecordSet, i.e. immediately after the
 updatePostgisLayer function.

 If I change the query to retrieve specify row (i.e. single row only), layer
 can be refreshed. But it requires to activate it manually for each update.

 I tried to add lyr.fireLayerChanged(LayerEventType.APPEARANCE_CHANGED);
 or lyr.fireAppearanceChanged() after the updatePostgisLayer function but it
 didn't work.

 Anyone can help?

 thanks,
 Elton





 --
 This SF.net email is sponsored by Sprint
 What will you do first with EVO, the first 4G phone?
 Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
 ___
 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 Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first___
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel


Re: [JPP-Devel] how to refresh a layer in run time

2010-07-01 Thread Larry Becker
Sorry, Elton, not NIls.  I answered so many questions that I got confused
about who I was answering.  :-)

On Thu, Jul 1, 2010 at 8:24 AM, Larry Becker becker.la...@gmail.com wrote:

 Hi Nils,

   I believe you might be running into problems updating because your loop
 is blocking the GUI thread.  You might try a LayerViewPanel.repaint() using
 invokeAndWait().

 Larry


 On Thu, Jul 1, 2010 at 6:42 AM, Elton Chan elton.c...@yahoo.com wrote:

 Hi there,

 I would like to refresh a layer after changing attribute of each feature
 in the layer based on an event table. The event table records attribute
 assigned to each feature at specified stage. Following is the schema of the
 event table:

 Event(
 StageID int, // StageID defines sequence of the event
 Feature01 int, // value to be assigned to feature 01
 Feature02 int, // value to be assigned to feature 02
 ...
 Feature10 int)

 Based on the StageID sequence, values for each feature would be retrieved
 and updated to corresponding feature. Finally,  update value would be
 visualized by unique colortheming. However, it seems the layer refreshing
 can only be effective outside the ResultSet loop of the event table.

 The following is the program codes:

 Inside execute(PlugInContext context)
 // get a layer
 lyr = context.getLayerManager().getLayer(postgis);
 //create a Resultset RS
 ResultSet RS stat.executeQuery(select * from Event);
 while (RS.next())
 {
 updatePostgisLayer(lyr, RS);//This function updates feature in the layer
 }
  layer refreshes after the looping all the resultset.

 My question is how to refresh the layer once attribute values are updated
 for each each row of the RecordSet, i.e. immediately after the
 updatePostgisLayer function.

 If I change the query to retrieve specify row (i.e. single row only),
 layer can be refreshed. But it requires to activate it manually for each
 update.

 I tried to add lyr.fireLayerChanged(LayerEventType.APPEARANCE_CHANGED);
 or lyr.fireAppearanceChanged() after the updatePostgisLayer function but
 it didn't work.

 Anyone can help?

 thanks,
 Elton





 --
 This SF.net email is sponsored by Sprint
 What will you do first with EVO, the first 4G phone?
 Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
 ___
 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 Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first___
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel