swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Multiple Value2dDisplay's on a single Raster


From: Ken Cline
Subject: Re: Multiple Value2dDisplay's on a single Raster
Date: Tue, 21 Apr 1998 23:04:57 -0400 (EDT)

On Tue, 21 Apr 1998, Ken Cline wrote:

> On Tue, 21 Apr 1998, Nelson Minar wrote:
> 
> > Can you just subclass Value2dDisplay and override the
> > offending method?
> 
> This is exactly what I did to implement my contour lines
> on top of the my elevation "gradient" display.
>
>   [snip]

What I wrote in my previous message was meant to server as
an example of how you could expand the Value2dDisplay class.
However, I suppose most of my code wouldn't really help you
out, Rick. Sorry!

I wanted to just add that I like the idea of subclassing
Value2dDisplay.  I was thinking that you could have a
`addDiscrete2d: (Discrete2d *) c  toDisplayAs: (char *) key'
method that would store each grid in a Map object.  Then,
your display method(s) could access the data sets using the
appropriate key and perform some algorithm to combine the
values and produce a color.

I did something similar to this with my GridMap class, but
instead of mapping multiple data sets to a raster I was
trying to abstract the agent interactions with data
structures.  That is, the agents refer to data sets (eg
elevation) with tags (eg "Elevation") instead of pointers to
the actual data structures.  By doing this, I could put the
data in anything I want; perhaps even into multiple objects.

A lot of the code in my GridMap does stuff like bounds
checking, get and put, and etc.; that is, it has a lot of
stuff other grid classes have.  Also the code depends
heavily on my other "spatial" library classes.

However, I've extracted some of the code (see below) which I
thought might be useful.  This is pretty straight forward
wrapper of the Map class.  One note though, I was planning
to use a char * [] called "reservedTags" to allow the user
to specify grids by generic terms, eg "ALL", "FIRST",
"LAST", etc.  I never finished implementing it, though...
[sigh]...  I'd really like to add that feature to all or
most collection objects.


@implementation GridMap
 
static char * reservedTags [] = { "ALL", NULL };
 
PHASE( Creating )
 
+createBegin: (id) aZone {
   GridMap * newGridMap = [ super createBegin: aZone ];
 
   newGridMap->gridMap = NULL;
 
   return newGridMap;
}
 
-createEnd {
   if ( !gridMap ) {
      gridMap = [ Map createBegin: [self getZone] ];
         [ gridMap setCompareFunction: &stringCaseCompare ];
      gridMap = [ gridMap createEnd ];
   }
 
   self = [ super createEnd ];
 
   return self;
}
 
+create: (id) aZone grid: (id <BdGrid>) aGrid tag: (char *) aTag {
   GridMap * newGridMap = [ GridMap create: aZone ];
 
   [ newGridMap->gridMap at: (id)aTag insert: aGrid ];
 
   return newGridMap;
}

PHASE( Setting )

 
PHASE( Using )
 
 
-(BOOL) isReservedTag: (char *) aTag {
   char ** string = NULL;
 
   if ( reservedTags == NULL ) return FALSE;
 
   string = reservedTags;
   while ( string != NULL && *string != NULL ) {
      if ( stringCaseCompare( (id)aTag, (id)*string ) == 0 )
         return TRUE;
      string++;
   }
 
   return FALSE;
}
 
-(BOOL) add: (char *) aTag values: (id <BdGrid>) aGrid {
   if ( [ self isReservedTag: aTag ] )
      raiseEvent( WarningMessage, "\t> Keyword `%s' is RESERVED.\n"  \
                                  "\t> Can not add data set with this 
keyword.\n", aTag );
   return [ gridMap at: (id)aTag insert: aGrid ];
}
 
-remove: (char *) aTag {
   if ( !gridMap ) return InvalidGrid;
   return [ gridMap removeKey: (id)aTag ];
}
 
-replace: (char *) aTag with: (id <BdGrid>) aGrid {
   if ( !gridMap ) return InvalidGrid;
   return [ gridMap at: (id)aTag replace: aGrid ];
}
 
 
-(id) get: (char *) aTag {
   if ( !gridMap ) return InvalidGrid;
   return (id <BdGrid>)[ gridMap at: (id)aTag ];
}

   ...
 
@end



_________________________________________________________
Ken Cline                             address@hidden
SAIC                                 VOICE (410) 571-0413
Annapolis, MD                          FAX (301) 261-8427





                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.
                  ==================================


reply via email to

[Prev in Thread] Current Thread [Next in Thread]