[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Colormap/Zoomraster problem (?)
From: |
William T. Stockhausen |
Subject: |
Colormap/Zoomraster problem (?) |
Date: |
Thu, 31 Jan 2002 14:00:45 -0500 |
Hi,
I'm using the Swarm 2.2 pre-release (version 2, I think). I've run into a
problem when assigning a colormap to a zooomraster. I create 2 colormaps
and 3 zoomrasters in a GUI ObserverSwarm using the code snippet:
// First, create colormaps: this is a global resource, the information
// here can be used by lots of different objects.
cmDensity = new ColormapImpl (getZone ());
cmHabitat = new ColormapImpl (getZone ());
// Colours [0,255) are assigned to the range Red [0, 1), for densities
for (int i = 0; i < 255; i++)
cmDensity.setColor$ToRed$Green$Blue ((byte) i, (double) i / 255.0, 0,
0);
System.out.println ("Set cmDensity.");
// set various colors for habitat
cmHabitat.setColor$ToName ((byte) 0, "white");
cmHabitat.setColor$ToName ((byte) 1, "black");
// Next, create 2d windows for display.
System.out.println ("Creating zrBenthicHabitat.");
zrBenthicHabitat =
CreateZoomRaster("zrBenthicHabitat","_zrBenthicHabitatDeath_",
cmHabitat,"Benthic Habitat Map");
System.out.println ("Creating zrPlanktonicDensity.");
zrPlanktonicDensity =
CreateZoomRaster("zrPlanktonicDensity","_zrPlanktonicDensityDeath_",
cmDensity,"Planktonic Density
Map");
System.out.println ("Creating zrBenthicDensity.");
zrBenthicDensity =
CreateZoomRaster("zrBenthicDensity","_zrBenthicDensityDeath_", <--error
happens on this call
cmDensity,"Benthic Density Map");
to CreateZoomRaster
where CreateZoomRaster is the following method:
//--------------------------------------------------------------------------
--------
private ZoomRaster CreateZoomRaster(String zrName, String zrDeath,
Colormap cmO, String zrTitle) {
ZoomRasterImpl zrT;
//System.out.println ("Creating ZoomRaster\n");
zrT = new ZoomRasterImpl (getZone (), zrName);
try {
zrT.enableDestroyNotification$notificationMethod
(this,
new Selector (getClass (), zrDeath, false));
} catch (Exception e) {
System.err.println ("Exception " + zrDeath + ": "
+ e.getMessage ());
}
//System.out.println ("Setting ZoomRaster\n");
zrT.setColormap (cmO);
<--error occurs on this line
zrT.setZoomFactor (1);
zrT.setWidth$Height (modelSwarm.getWorldX (), modelSwarm.getWorldY ());
zrT.setWindowTitle (zrTitle);
zrT.pack(); // draw the window.
//System.out.println ("Returning ZoomRaster.\n");
return zrT;
} // private ZoomRaster CreateZoomRaster
//--------------------------------------------------------------------------
----------
The two colormaps and the 1st two zoomrasters get created fine. When the
third zoomraster (zrBenthicDensity) is created, I get the following error
when the program attempts the line "zrT.setColormap (cmO);" in
CreateZoomRaster:
*** event raised for error: InvalidArgument
*** function: _i_Colormap__setColor_ToName_(), file:
/src/Swarm/swarm/src/tkobjc/Colormap.m, line: 64
attempted to set color 255 twice
*** execution terminating due to error
/src/Swarm/swarm/src/defobj/Symbol.m:173 -[Error(c) _raiseEvent:]
0 [sig] 0`ÃÝ 337 open_stackdumpfile: Dumping stack trace to
java.exe.stackdump
As far as I can tell, I'm not changing the colormap (cmDensity) at all--I'm
just assigning it to the new zoomraster. Any ideas?
1. Do I need to create another colormap, so that each zoomraster uses a
unique colormap?
2. Or should I only be creating one colormap and using it for each
zoomraster? [Previously, the code ran fine when I (accidentally,
as it
happens) assigned just one colormap (cmHabitat) to all three
zoomrasters--although the colors weren't what I expected for the
two
Density zoomrasters.]
Thanks for any and all help!
Buck
***********************************************************************
*William T. Stockhausen e-mail: address@hidden *
*Senior Marine Scientist voice : 804-684-7643 *
*Virginia Institute of Marine Science fax : 804-684-7250 *
*College of William and Mary http://www.vims.edu/~buck *
*Greate Road *
*Gloucester Point, VA 23062-1346 *
***********************************************************************
==================================
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.