Previous ION Java User's Guide: Building ION Applets and Applications Next

Direct Graphics in ION

The ION Device

IDL uses the concept of a current graphics device when creating and displaying IDL Direct Graphics. When the ION Server requests graphics from IDL, it automatically sets the current graphics device to 'ion'; graphics output from IDL is sent directly to the ION Server. You do not need to explicitly set the graphics device to 'ion' unless you have explicitly used the IDL SET_PLOT procedure to change the current device to some other device.

For example, suppose you wish to include a "Print" button in a Java application. Your applet might include something like the following:

ion.executeIDLCommand("SET_PLOT, 'printer'")  
execute more IDL commands to draw an image on the printer  
ion.executeIDLCommand("SET_PLOT, 'ion'")  

 


Note
The IDL TVRD function is not supported by the ION Device.

Keywords Accepted by the ION Device

The following keywords to the IDL DEVICE routine are available when the current graphics device is set to 'ion'. Except where indicated, keywords to the ION device work just as they do for other IDL graphics devices.

COPY

Use this keyword to copy a rectangular area of pixels from one region of a window to another. COPY should be set to a six or seven element array: [Xs, Ys, Nx, Ny, Xd, Yd, W], where: (Xs, Ys) is the lower left corner of the source rectangle, (Nx, Ny) are the number of columns and rows in the rectangle, and (Xd, Yd) is the coordinate of the destination rectangle. Optionally, W is the index of the window from which the pixels should be copied to the current window. If it is not supplied, the current window is used as both the source and destination.

DECOMPOSED

This keyword is used to control the way in which graphics color index values are interpreted when using displays with decomposed color (TrueColor visuals). This keyword has no effect with other types of visuals.

Set this keyword to 1 to cause color indices to be interpreted as 3, 8-bit color indices where the least-significant 8 bits contain the red value, the next 8 bits contain the green value, and the most-significant 8 bits contain the blue value. This is the way IDL has always interpreted pixels when using visual classes with decomposed color.

Set this keyword to 0 to cause the least-significant 8 bits of the color index value to be interpreted as a PseudoColor index. This setting allows users with TrueColor displays to use IDL programs written for standard, PseudoColor displays without modification.

In older versions of IDL, color index values higher than !D.N_COLORS-1 were clipped to !D.N_COLORS-1 in the higher level graphics routines. In some cases, this clipping caused the exclusive-OR graphics mode to malfunction with raster displays. This clipping has been removed. Programs that incorrectly specified color indices higher than !D.N_COLORS-1 will now probably exhibit different behavior.

FONT

Set this keyword to a scalar string specifying the name of the font used when the hardware font is selected.


Note
The hardware fonts available are supplied by Java itself, not the platform on which IDL is running. Java's font system supplies several standard fonts. These font names will map to different actual fonts on different platforms, but will always be handled gracefully by Java. If you specify a different font, Java will substitute one of the standard fonts automatically.


Tip
Avoid using device fonts for performance reasons. See Tips for Increasing Execution Speed in ION Java.

Note that hardware fonts cannot be rotated, scaled, or projected, and that the "!" commands accepted for vector fonts for subscripts and superscripts may not work. When generating three-dimensional plots, it is best to use the vector-drawn characters because IDL can draw them in perspective with the rest of the plot.

The GET_FONTNAMES keyword, described below, can be used to retrieve a list of available fonts.

The FONT keyword should be set to a string with the following form:

DEVICE, FONT="font*modifier1*modifier2*...modifiern"  

where the asterisk (*) acts as a delimiter between the font's name (font) and any modifiers. The string is not case sensitive. Modifiers are simply "keywords" that change aspects of the selected font. Valid modifiers are:

For example, the following commands tell ION to use TrueType fonts, change the font, and then make a simple plot:

ion.executeIDLCommand("!P.FONT = 1")  
ion.executeIDLCommand("DEVICE, FONT = 'Helvetica Bold Italic, 
/TT_FONT'")  
ion.executeIDLCommand("PLOT, FINDGEN(10), TITLE = 'IDL Plot'")  

GET_CURRENT_FONT

Set this keyword to a named variable in which the name of the current font is returned as a scalar string.

GET_FONTNAMES

Set this keyword to a named variable in which a string array containing the names of available fonts is returned. If no fonts are found, a null scalar string is returned. This keyword must be used in conjunction with the FONT keyword. Set the FONT keyword to a scalar string containing the name of the desired font or a wildcard.

GET_GRAPHICS_FUNCTION

Set this keyword to a named variable that returns the value of the current graphics function (which is set with the SET_GRAPHICS_FUNCTION keyword). This can be used to remember the current graphics function, change it temporarily, and then restore it. See the SET_GRAPHICS_FUNCTION keyword for an example.

GET_SCREEN_SIZE

Set this keyword to a named variable in which to return a two-word array that contains the width and height of the server's screen, in pixels.

SET_CHARACTER_SIZE

The standard size and vertical spacing of vector-drawn fonts can be changed by specifying this keyword with a two-element vector. The first element specifies the new character width and thus the height of the characters (because vector-drawn fonts have a fixed aspect ratio). The second element specifies the vertical distance between lines. The default produces a character that is approximately 8 pixels wide, with 12 pixels between lines.

SET_GRAPHICS_FUNCTION

Most window systems allow applications to specify the graphics function. This is a logical function which specifies how the source pixel values generated by a graphics operation are combined with the pixel values already present on the screen. ION supports only the following two of the fifteen graphics functions supported by IDL Direct Graphics:

Table 5-1: Graphics Functions Supported by IDL Direct Graphics

Table 5-1: Graphics Functions Supported by IDL Direct Graphics
Logical Function
Code
Definition
GXcopy
3
source
GXxor
6
source XOR destination

The default graphics function is GXcopy, which causes new pixels to completely overwrite any previous pixels. Not all functions are available on all window systems.

See "IDL Graphics Devices" in the IDL Reference Guide for more information about how IDL handles graphics devices.

  IDL Online Help (March 06, 2007)