Package icsbep.sgt contains the core classes from the Scientific Graphics Toolkit (SGT). SGT is not a general purpose graphics package, but rather tools to enable scientific graphics to be easily incorporated into applets.
SGT has three main components: the pane, the layer, and the graph, shown in Figure 2‑200. The pane extends the classes Container and JLayeredPane. The layer is defined in physical units and is used to build plots. The graph is defined in user units, contains the axes, and renders the data. All the graphics are drawn on the pane. In class Pane all drawing is done in "device" coordinates or pixels. By default, the Pane object is drawn on the screen, although it is designed to allow drawing in an offscreen buffer that can be printed for applications.

Several layers can be associated with a single pane. The Layer class insulates the developer from the details of device coordinates by using "physical" coordinates. Physical coordinates are a right-hand coordinate systems with an origin of (0.0, 0.0) in the lower-left-hand corner. Physical coordinates have the same scale in both the vertical and horizontal directions. For example, a Layer object that is 5.0 units wide and 3.0 units high can be scaled on the screen by resizing the Pane object without any distortion. The Layer class is responsible for displaying labels, rulers, and keys or legends for color, vectors, or lines. A Layer object can contain a single Graph instance.
Class Graph transforms user coordinates (e.g. cm/sec, time, degC, or meters) to physical coordinates. This class also handles the display of axes and data. Subclasses of the Graph class are capable of creating Cartesian, polar, and map graphs. Currently only Cartesian graphs are supported. For Cartesian graphs, several different axes (log, plain and time), transforms (linear, log, and table lookup), and CartesianGraph (point, line, vector, and grid) classes are available. These classes may be combined in various ways, as shown in Figure 2‑201.

While only one dataset may be plotted per Layer object, co-plotting is supported by allowing layers to use the same transform objects. The order in which layers are plotted can be changed, allowing the user to control what is obscured.
Methods, in package icsbep.graph.sgt, use the following naming convention. Method names with the suffix P denote physical units, U user units and D device units. Variables with the prefix p, u, t, or d are coordinates of type physical, user, time, or device, respectively.
All graphics are rendered when the draw() method is invoked.
Mouse Events
Mouse events are processed by the JPane object to support object selection and zooming. Object selection is accomplished by left clicking the mouse on the desired object. The JPane instance then fires a PropertyChangeEvent of type "objectSelected" that can be listened for by the user's application. The user application then invokes the getSelectedObject method. Zooming is accomplished in several steps:
1) Begin a zoom operation by pressing the left button.
2) Describe a zoom rectangle by dragging the mouse with the left button down.
3) Finish the zoom operation by releasing the left mouse button.
When the mouse button has been released JPane fires a PropertyChangeEvent of type "zoomRectangle" that can be listened for by the users application. The user application can then obtain the zoom rectangle by invoking the getZoomBounds method.
Common Methods
Several common methods appear in these SGT classes: