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 <[email protected]> wrote:

> From: Stefan Steiniger <[email protected]>
> Subject: Re: [JPP-Devel] how to refresh a layer in run time
> To: "OpenJump develop and use" <[email protected]>
> 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 <[email protected]>
> wrote:
> > 
> >> From: Stefan Steiniger <[email protected]>
> >> Subject: Re: [JPP-Devel] how to refresh a layer in
> run time
> >> To: "OpenJump develop and use" <[email protected]>
> >> 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
> <[email protected]
> >>> <mailto:[email protected]>>
> >> 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 /<[email protected]
> >>>      <mailto:[email protected]>>/*
> >> wrote:
> >>> 
> >>>          From: Larry
> >> Becker <[email protected]
> >>>         
> <mailto:[email protected]>>
> >>>          Subject:
> Re:
> >> [JPP-Devel] how to refresh a layer in run time
> >>>          To:
> "OpenJump
> >> develop and use"
> >>>          <[email protected]
> >>>         
> <mailto:[email protected]>>
> >>>          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
> >>>          <[email protected]
> >>>          <http://mc/[email protected]>>
> >> 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
> /<[email protected]
> >>>          
> >>    <http://mc/[email protected]>>/*
> >> wrote:
> >>> 
> >>>           
>   
> >>    From: Larry Becker <[email protected]
> >>>           
>   
> >>    <http://mc/[email protected]>>
> >>>           
>   
> >>    Subject: Re: [JPP-Devel] how to
> refresh a
> >> layer in run time
> >>>           
>   
> >>    To: "OpenJump develop and use"
> >>>           
>   
> >>    <[email protected]
> >>>           
>   
> >>    <http://mc/[email protected]>>
> >>>           
>   
> >>    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
> >>>           
>   
> >>    <[email protected]
> >>>           
>   
> >>    <http://mc/[email protected]>>
> >> 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
> >>>           
>     
> >>      <[email protected]
> >>>           
>     
> >>      <http://mc/[email protected]>>
> >> 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://sprint.com/first>
> >>>           
>     
> >>          -- http://p.sf.net/sfu/sprint-com-first
> >>>           
>     
> >>     
>    _______________________________________________
> >>>           
>     
> >>         
> Jump-pilot-devel
> >> mailing list
> >>>           
>     
> >>          [email protected]
> >>>           
>     
> >>          <http://mc/[email protected]>
> >>>           
>     
> >>          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://sprint.com/first> --
> >>>           
>   
> >>    http://p.sf.net/sfu/sprint-com-first
> >>>           
>   
> >>    -----Inline Attachment Follows-----
> >>> 
> >>>           
>   
> >>   
> _______________________________________________
> >>>           
>   
> >>    Jump-pilot-devel mailing list
> >>>           
>   
> >>    [email protected]
> >>>           
>   
> >>    <http://mc/[email protected]>
> >>>           
>   
> >>    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://sprint.com/first> --
> >>>           
>   http://p.sf.net/sfu/sprint-com-first
> >>>          
> >>   
> _______________________________________________
> >>>          
> >>    Jump-pilot-devel mailing list
> >>>           
>   [email protected]
> >>>          
> >>    <http://mc/[email protected]>
> >>>           
>   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://sprint.com/first> --
> >>>          http://p.sf.net/sfu/sprint-com-first
> >>> 
> >>>          -----Inline
> >> Attachment Follows-----
> >>>      
> >>   
> _______________________________________________
> >>>         
> Jump-pilot-devel
> >> mailing list
> >>>          [email protected]
> >>>          <http://mc/[email protected]>
> >>>          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://sprint.com/first> --
> >>>      http://p.sf.net/sfu/sprint-com-first
> >>>  
> >>   
> _______________________________________________
> >>>      Jump-pilot-devel mailing
> list
> >>>      [email protected]
> >>>      <mailto:[email protected]>
> >>>      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
> >>> [email protected]
> >>> 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
> >> [email protected]
> >> 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
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
> > 
> > 
> 
> -----Inline Attachment Follows-----
> 
> /*
>  * The Unified Mapping Platform (JUMP) is an extensible,
> interactive GUI 
>  * for visualizing and manipulating spatial features with
> geometry and attributes.
>  *
>  * JUMP is Copyright (C) 2003 Vivid Solutions
>  *
>  * This class implements extensions to JUMP and is
>  * Copyright (C) Stefan Steiniger.
>  * 
>  * This program is free software; you can redistribute it
> and/or
>  * modify it under the terms of the GNU General Public
> License
>  * as published by the Free Software Foundation; either
> version 2
>  * of the License, or (at your option) any later version.
>  * 
>  * This program is distributed in the hope that it will be
> useful,
>  * but WITHOUT ANY WARRANTY; without even the implied
> warranty of
>  * MERCHANTABILITY or FITNESS FOR A PARTICULAR
> PURPOSE.  See the
>  * GNU General Public License for more details.
>  * 
>  * You should have received a copy of the GNU General
> Public License
>  * along with this program; if not, write to the Free
> Software
>  * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
> MA  02111-1307, USA.
>  * 
>  * For more information, contact:
>  * Stefan Steiniger
>  * [email protected]
>  */
> 
> /*****************************************************
>  * created:         
> 08.July.2010
>  * last modified:      
>            
>     
>  *            
>         
>  * 
>  * @author sstein
>  * 
>  * description:
>  *     
>  *  
>  *****************************************************/
> 
> package ca.ucalgary.engg.moveantools.ojplugin.hranalysis;
> 
> import java.awt.Graphics2D;
> import java.awt.event.ActionEvent;
> import java.awt.event.ActionListener;
> import java.util.ArrayList;
> import java.util.Collection;
> import java.util.List;
> 
> import javax.swing.DefaultComboBoxModel;
> import javax.swing.JComboBox;
> 
> import org.openjump.core.apitools.FeatureCollectionTools;
> import org.openjump.core.apitools.FeatureSchemaTools;
> 
> import
> ca.ucalgary.engg.moveantools.util.TrackCalculationUtil;
> 
> import com.vividsolutions.jump.feature.Feature;
> import com.vividsolutions.jump.feature.FeatureCollection;
> import com.vividsolutions.jump.feature.FeatureDataset;
> import com.vividsolutions.jump.task.TaskMonitor;
> import com.vividsolutions.jump.workbench.WorkbenchContext;
> import com.vividsolutions.jump.workbench.model.Layer;
> import
> com.vividsolutions.jump.workbench.model.LayerEventType;
> import
> com.vividsolutions.jump.workbench.model.LayerManager;
> import
> com.vividsolutions.jump.workbench.model.StandardCategoryNames;
> import
> com.vividsolutions.jump.workbench.plugin.AbstractPlugIn;
> import
> com.vividsolutions.jump.workbench.plugin.EnableCheckFactory;
> import
> com.vividsolutions.jump.workbench.plugin.MultiEnableCheck;
> import
> com.vividsolutions.jump.workbench.plugin.PlugInContext;
> import
> com.vividsolutions.jump.workbench.plugin.ThreadedPlugIn;
> import com.vividsolutions.jump.workbench.ui.GUIUtil;
> import
> com.vividsolutions.jump.workbench.ui.LayerViewPanel;
> import
> com.vividsolutions.jump.workbench.ui.LayerViewPanelContext;
> import
> com.vividsolutions.jump.workbench.ui.MultiInputDialog;
> import
> com.vividsolutions.jump.workbench.ui.plugin.FeatureInstaller;
> import
> com.vividsolutions.jump.workbench.ui.renderer.RenderingManager;
> import
> com.vividsolutions.jump.workbench.ui.renderer.ThreadQueue;
> import
> com.vividsolutions.jump.workbench.ui.renderer.style.BasicStyle;
> import
> com.vividsolutions.jump.workbench.ui.style.CopyStylesPlugIn;
> 
> /**
>  * @description:
>  *    
>  * @author sstein
>  *
>  **/
> public class AsymptoteMoviePlugIn extends AbstractPlugIn
> implements ThreadedPlugIn{
> 
>     private String sSidebar ="Displays the Home
> Ranges created with the Asymptote Anlysis
> Function";   
>     private final String sLAYERPTS = "Layer with
> HomeRanges";
>     private FeatureCollection points =
> null;        
>     private Layer input = null;
>     private MultiInputDialog dialog;
>     private PlugInContext context = null;
>     private JComboBox jcb_attributeA = null;
>     
>     private String locAttribute = "";
>     private String sATTRIBUTEA = "time attribute
> [for ordering of features]";
>     
>     private RenderingManager
> renderingManager;
>     private LayerViewPanel panel = null;
>         
>     public void initialize(PlugInContext context)
> throws Exception {
>            
>         
>            
> FeatureInstaller featureInstaller = new
> FeatureInstaller(context.getWorkbenchContext());
>            
> featureInstaller.addMainMenuItem(
>              
>       this,   
>            
>            
>     //exe
>              
>       new String[] {"MOVEAN", "HR Analysis"},
>     //menu path
>              
>       "Asymptote Movie", 
>              
>      
> //AbstractPlugIn.createName(CalculateMinimumConvexPolygonPlugIn.class),
>              
>       false,   
>         //checkbox
>              
>       null,   
>         //icon
>              
>      
> createEnableCheck(context.getWorkbenchContext())); //enable
> check
>     }
> 
>     public static MultiEnableCheck
> createEnableCheck(WorkbenchContext workbenchContext) {
>         EnableCheckFactory checkFactory
> = new EnableCheckFactory(workbenchContext);
> 
>         return new MultiEnableCheck()
>                
>        
> .add(checkFactory.createAtLeastNLayersMustExistCheck(1));
>     }
>     
>     public boolean execute(PlugInContext
> context) throws Exception{
>         //Unlike ValidatePlugIn, here
> we always call #initDialog because we want
>         //to update the layer
> comboboxes.
>         initDialog(context);
>         dialog.setVisible(true);
>         if (!dialog.wasOKPressed()) {
>             return false;
>         }
>         else{
>            
> this.getDialogValues(dialog); 
>         }
>         return true;   
>     
>     }
>     
>     public void run(TaskMonitor monitor,
> PlugInContext context) throws Exception{     
>               
>            
> System.gc(); //flush garbage collector
>            
> this.context = context;
>            
> monitor.allowCancellationRequests();
>            
> FeatureCollection resultC = new
> FeatureDataset(this.points.getFeatureSchema());
>             //--
> clone the original layers style & make invisible
>             Collection
> stylesBuffer = this.input.cloneStyles();
>            
> this.input.setVisible(false);
>             //--
> order the objects
>            
> ArrayList<Feature> sortedFeatures =
> FeatureCollectionTools.sortFeatureListByAttributeBeginWithSmallest(this.points.getFeatures(),
> 
>            
>         locAttribute);
>            
> //-- add the first object
>            
> Feature oldFeature = sortedFeatures.get(0);
>            
> Feature oldoldFeature = oldFeature;
>            
> resultC.add(oldFeature);
>             int
> numFeatures = sortedFeatures.size();
>             Layer
> movieLayer = null;
>            
> if((resultC != null) && (resultC.size() > 0)){
>            
>     movieLayer =
> context.addLayer(StandardCategoryNames.SYSTEM, "movie",
> resultC);
>            
>     movieLayer.setDrawingLast(true);
>            
>     movieLayer.setStyles(stylesBuffer);
>            
>     for (int i = 1; i < numFeatures; i++)
> {
>            
>         monitor.report(i,
> numFeatures, "");
>            
>        
> if(monitor.isCancelRequested()){
>            
>             //--
> remove the temporary layer & make the original layer
> visible
>            
>            
> LayerManager lm = movieLayer.getLayerManager();
>            
>            
> lm.remove(movieLayer);
>            
>            
> this.input.setVisible(true);
>            
>            
> return;
>            
>         }
>            
>         Feature newFeature =
> sortedFeatures.get(i);
>            
>        
> movieLayer.setFeatureCollectionModified(false);
>            
>         //-- remove the
> secondLast item
>            
>        
> //   hence we will always display the new and
> the old item
>            
>        
> //   this may be smoother?
>            
>         if(i > 1){
>            
>            
> resultC.remove(oldoldFeature);    
>            
>         }
>            
>         //-- add the next
> item
>            
>        
> resultC.add(newFeature);
>            
>        
> movieLayer.setFeatureCollectionModified(true);
>            
>        
> movieLayer.fireLayerChanged(LayerEventType.APPEARANCE_CHANGED);
>            
>         oldoldFeature =
> oldFeature;
>            
>         oldFeature =
> newFeature;
>            
>         //-- waste some time
> by drawing the same thing again completly new 
>            
>         // to ensure rendering
> is finished
>            
>         /**
>            
>          * TODO:
>            
>          * put stuff
> for testing in a subclass for now. 
>            
>          * The
> problem is to get info about 
>            
>          * when
> rendering is finished. Larry said that SkyJUMP has a
> listener 
>            
>          * for that
> - but this one works not in all cases. [see his email from 
>            
>          * 9 July
> 2010: Plug-in showing change over time]
>            
>          */
>            
>        
> //this.wasteTime(resultC);
>            
>         Thread.sleep(30);
>            
>     }
>             } 
>             //--
> remove the temporary layer & make the original layer
> visible
>            
> LayerManager lm = movieLayer.getLayerManager();
>            
> lm.remove(movieLayer);
>            
> this.input.setVisible(true);
>         }
> 
>     private void initDialog(PlugInContext
> context) {
>         
>         dialog = new
> MultiInputDialog(context.getWorkbenchFrame(), "Asymptote
> Movie", true);
>        
> dialog.setSideBarDescription(sSidebar);
>         try {
>             JComboBox
> addLayerComboBoxRegions =
> dialog.addLayerComboBox(this.sLAYERPTS,
> context.getCandidateLayer(0), null,
> context.getLayerManager());
>         }
>         catch
> (IndexOutOfBoundsException e) {}
>         
>         List list =
> FeatureSchemaTools.getFieldsFromLayerWithoutGeometryAndString(context.getCandidateLayer(0));
>         Object valA =
> list.size()>0?list.iterator().next():null;
>         jcb_attributeA =
> dialog.addComboBox(this.sATTRIBUTEA, valA,
> list,this.sATTRIBUTEA);
>         if (list.size() == 0)
> jcb_attributeA.setEnabled(false);
>         
>        
> dialog.getComboBox(this.sLAYERPTS).addActionListener(new
> ActionListener() {
>             public void
> actionPerformed(ActionEvent e) {
>                
> List list = getFieldsFromLayerWithoutGeometryAndString();
>                 if
> (list.size() == 0) {
>                
>     jcb_attributeA.setModel(new
> DefaultComboBoxModel(new String[0]));
>                
>     jcb_attributeA.setEnabled(false);
>                 }
>                
> jcb_attributeA.setModel(new
> DefaultComboBoxModel(list.toArray(new String[0])));
>             }   
>         
>         });
>         
> //dialog.addDoubleField(T1, 20.0, 4);
>        
> GUIUtil.centreOnWindow(dialog);
>     }
>     
>     private void getDialogValues(MultiInputDialog
> dialog) {
>         this.input = 
> dialog.getLayer(this.sLAYERPTS);
>         this.points=
> this.input.getFeatureCollectionWrapper();
>         this.locAttribute =
> dialog.getText(this.sATTRIBUTEA); 
>       }
>     
>     private List
> getFieldsFromLayerWithoutGeometryAndString() {
>         return
> FeatureSchemaTools.getFieldsFromLayerWithoutGeometryAndString(dialog.getLayer(this.sLAYERPTS));
>     }
>     
>  
>     private void wasteTime(FeatureCollection
> fc) throws InterruptedException{
>         //-- create a new dummy
> pannel to have a clue when things are drawn
>         final Throwable[]
> throwable = new Throwable[] { null };
>         LayerManager dummyLM
> = new LayerManager();
>         LayerViewPanel
> dummyPanel = 
>            
> new LayerViewPanel( 
>            
>         new LayerManager(),
>            
>            
>     new LayerViewPanelContext() {
>            
>            
> public void setStatusMessage(String message) {
>            
>             }
> 
>            
>            
> public void warnUser(String warning) {
>            
>             }
> 
>            
>            
> public void handleThrowable(Throwable t) {
>            
>            
>     throwable[0] = t;
>            
>             }
>            
>         });
>         //-- here I render a
> dummy Layer so I know when things are drawn for sure.
>         //-- copied the part
> below from org.openjump.core.ui.plugin.file.LayerPrinter2
>         Layer dummyLayer =
> dummyLM.addLayer("huhu", "dummyLayer", fc);
>         renderingManager =
> dummyPanel.getRenderingManager();
>        
> renderingManager.renderAll();
>         /*
>         ThreadQueue
> runningThreads =
> renderingManager.getDefaultRendererThreadQueue();
>         while
> (runningThreads.getRunningThreads()>0){
>            
> //-- just wait
>            
> //System.out.println("waiting, i: " + i);
>            
> Thread.sleep(10);
>         }
>        
> dummyLM.remove(dummyLayer);
>         */
>     }
> }
> -----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
> [email protected]
> 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
[email protected]
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to