Re: [OpenMap Users] Layer randomly visible even though it shouldn't be

From: Don Dietrick <dietrick_at_bbn.com>
Date: Tue, 9 Aug 2005 19:49:39 -0400

Hi Joey,

What happens if you add the layers to the LayerHandler instead, using
the addLayer() method? You can use the LayerHandler to control the
layer visibility after that.

- Don

On Jul 27, 2005, at 2:51 PM, Joey Heinrich wrote:

> I had this issue a while back and it seemed to go away after
> changing some things, but after needing to change them back the
> issue has resurfaced and I can't figure it out. Basically, my
> dayNightLayer is visible sometimes when I load a map, even though
> it's setVisible method is set to false. Sometimes it appears
> everytime, other times it only shows up every 4th or 5th time I
> load a map. I've traced the variable controlling the visibility of
> the layer all the way up to when the map is displayed and it is
> still set to false. Also, we have the ability to toggle that
> layer's visibility on and off after loading the map, and even when
> it is randomly visible, it has to be toggled twice to get it to
> disappear. I'm gonna include the basics of the code below in the
> hopes that you might have some suggestions as to how I might
> troubleshoot this.
>
> try
> {
> mapHandler = new MapHandler();
> mapHandler.add( new MouseDelegator() );
> mapHandler.add( new NavMouseMode3() ); //NavMouseMode2
> with a few extras
> mapHandler.add ( getMapBean() );
> mapHandler.add( new LayerHandler() );
>
> getMapPanel().add( getMapBean(), "Center" );
>
> // set the projection
> switch( projectionType )
> {
> case LINEAR :
> setOpenMapProjection( getMapBean(),
> "com.bbn.openmap.proj.LLXY");
> break;
> case MERCATOR :
> // the default, so do nothing
> break;
> case PERSPECTIVE :
> setOpenMapProjection( getMapBean(),
> "com.bbn.openmap.proj.Orthographic " );
> break;
> default :
> throw new IllegalArgumentException( "Unrecognized
> projection type: " + projectionType );
> }
>
>
> // Get the current time for the corresponding workspace
> RunController controller = master.getController( workspace );
> double currTime = controller.getCurrentTime();
>
>
> // Add day/night shading
> Properties dayNightLayerProps = new Properties();
> dayNightLayerProps.put( "daynight.nighttimeColor",
> nightColor );
> getDayNightLayer().setProperties( "daynight",
> dayNightLayerProps );
> getDayNightLayer().setCurrentTime( false );
> getDayNightLayer().setOverlayTime( getTerminatorTime() );
>
> // For some reason, if the initial visibility is false,
> // resetting the visibility has no affect. So initialize
> // it to true, so that it can be reset later.
> getDayNightLayer().setVisible( true );
>
>
> // Add latitude and longitude lines
> Properties graticuleLayerProps = new Properties();
> graticuleLayerProps.put( "graticule.showRuler", "true" );
> graticuleLayerProps.put ( "show1And5Lines", "true" );
> graticuleLayerProps.put( "showRuler", "true" );
> getLatLonLayer().setProperties( graticuleLayerProps );
>
> // For some reason, if the initial visibility is false,
> // resetting the visibility has no affect. So initialize
> // it to true, so that it can be reset later.
> getLatLonLayer().setVisible( true );
>
> // Create a ShapeLayer to show world political boundaries.
> // Set the properties of the layer. This assumes that the
> // datafiles "dcwpo-browse.shp" and "dcwpo-browse.ssx" are in
> // a path specified in the CLASSPATH variable. These files
> // are distributed with OpenMap and reside in the toplevel
> // "share" subdirectory.
> setMapColorRagu();
>
> // Add the political layer to the map
> mapHandler.add( shapeLayer );
>
> mapHandler.add( getLatLonLayer() );
>
> // add additional custom layers here
> addLayers();
>
> mapHandler.add( getDayNightLayer() );
> }
> catch( MultipleSoloMapComponentException msmce )
> {
> handleException( msmce );
> }
>
> The dayNightLayer won't be visible at all unless it's set to
> visible when it's added to the map. I'm assuming this is normal?
> After this section of code, there is only one call to set the
> visibility of the dayNightLayer back to false. There is no other
> interaction with the layer at all before the map is displayed. Is
> this perhaps something I can change by hardcoding some properties
> into the properties file (Something I'm not too familiar with..)?
> The previous fix, which worked for whatever reason, was to add the
> layers to the mapBean and then the mapBean to the mapHandler. This
> fixed the issue but is no longer possible.
>
> Any help is greatly appreciated! Thanks!
>
> -Joey



=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Don Dietrick, dietrick_at_bbn.com
BBN Technologies, Cambridge, MA
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


--
[To unsubscribe to this list send an email to "majdart_at_bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Tue Aug 09 2005 - 19:50:36 EDT

This archive was generated by hypermail 2.3.0 : Tue Mar 28 2017 - 23:25:07 EDT