From: Elton C. <elt...@ya...> - 2010-07-02 17:06:26
|
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 <bec...@gm...> wrote: From: Larry Becker <bec...@gm...> Subject: Re: [JPP-Devel] how to refresh a layer in run time To: "OpenJump develop and use" <jum...@li...> 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 <bec...@gm...> 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 <elt...@ya...> 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 Jum...@li... 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 Jum...@li... https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel |