|
SGT Home | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--gov.noaa.pmel.sgt.Pane
The Pane
class is extended from java.awt.Container
and is the basis for the gov.noaa.pmel.sgt
package.
The Java scientific graphics toolkit is designed to allow a
graphics client developer a great deal of flexibility and freedom.
sgt
is a package that greatly aids a developer in
creating graphics applets. sgt
is not a general
purpose graphics package, but provides the tools to enable
scientific graphics to be easily incorporated into Applets
.
sgt
has three main components, the "pane", on which
all graphics are drawn. The Pane
is a fairly simple
class and all drawing is done in "device" coordinates (pixels).
By default, the Pane
will draw on the screen, but it is
designed to allow drawing in an offscreen buffer that can be
printed (for applications).
The next component is the Layer
. 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 and have the same scale in both the vertical
and horizontal directions. Thus, a Layer
that is
5.0 units wide and 3.0 units high can be made larger and smaller
on the screen by resizing the Pane
, but will not be
distorted. The Layer
class is responsible for
displaying labels, keys (color, vector, and line), and rulers.
A Layer
can contain a single Graph
.
Finally, the Graph
component transforms from
user coordinates (e.g. cm/sec, time, degC, or meters) to
physical coordinates. The Graph
classes handle the display of axes and data. Children of
the Graph
class are capable of creating Cartesian,
polar, and map graphics. For Cartesian graphs, several different
axes (log, plain and time), transforms (linear, log, and
tablelookup), and CartesianGraph
(pixel,
line, vector, and contour) classes are available. These classes can be
combined in almost any combination.
While only one dataset may be plotted per Layer
,
co-plotting is supported by allowing layers to use the same
transform objects. The order that the layers are plotted can
be changed, allowing the developer (or user) to control what
may be obscured.
Member functions, in package gov.noaa.pmel.sgt
,
follow the following naming convention. Member functions that
have a P, U, or nothing at the end of the
function name are of type double in Physical
units, type double in User units, and type int in Device
units, respectively.
Variables that start with 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. JPane
then fires a PropertyChangeEvent
of type
"objectSelected" that can be listened for by the users 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 release 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.
An example of object selection and zooming can be found in the
JPane
documentation.
Layer
,
Graph
,
Graphics
, Serialized FormFields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface gov.noaa.pmel.sgt.AbstractPane |
BOTTOM, CENTER, LEFT, MIDDLE, RIGHT, SPECIFIED_LOCATION, TOP |
Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
Pane()
Default constructor. |
|
Pane(java.lang.String id,
java.awt.Dimension size)
Constructs a Pane . |
Method Summary | |
java.awt.Component |
add(java.awt.Component comp)
Adds the specified component to the end of the Pane . |
java.awt.Component |
add(java.awt.Component comp,
int index)
Adds the specified component to the Pane at the
given position. |
void |
add(java.awt.Component comp,
java.lang.Object constraints)
Adds the specified component to the end of this Pane . |
void |
add(java.awt.Component comp,
java.lang.Object constraints,
int index)
Adds the specified component to the end of this Pane
at the specified index. |
java.awt.Component |
add(java.lang.String name,
java.awt.Component comp)
Adds the specified component to this Pane . |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener l)
Add a PropertyChangeListener to the list. |
void |
draw()
The AbstractPane and all of the attached Classes
will be drawn. |
void |
draw(java.awt.Graphics g)
The AbstractPane and all of the attached Classes
will be drawn. |
void |
draw(java.awt.Graphics g,
int width,
int height)
The AbstractPane and all of the attached Classes
will be drawn. |
java.awt.Rectangle |
getBounds()
Get the bounding rectangle in pixels (device units). |
java.awt.Component |
getComponent()
Get the Component associated with
the pane. |
Layer |
getFirstLayer()
Get the first Layer associated with the Pane |
java.lang.String |
getId()
Get the Pane identifier. |
Layer |
getLayer(java.lang.String id)
Get the Layer associated with the
Pane indicated by the id. |
Layer |
getLayerFromDataId(java.lang.String id)
Get the Layer associated with the
Pane indicated by the data id. |
java.awt.Dimension |
getMaximumSize()
Returns the maximum size of this container. |
java.awt.Dimension |
getMinimumSize()
Returns the minimum size of this container. |
java.lang.Object |
getObjectAt(int x,
int y)
Get the current selected object at a point. |
int |
getPageHAlign()
Get horizontal alignment |
java.awt.Point |
getPageOrigin()
Get the printer page origin. |
java.awt.Dimension |
getPageSize()
Get the printer page size. |
int |
getPageVAlign()
Get vertical alignment. |
java.awt.Dimension |
getPreferredSize()
Returns the preferred size of this container. |
java.lang.Object |
getSelectedObject()
Return the last object selected. |
static StrokeDrawer |
getStrokeDrawer()
Internal access to jdk1.1 or Java2D line drawing. |
java.awt.Rectangle |
getZoomBounds()
Return the device coordinates of the zoom action. |
void |
init()
No initialization required by Pane. |
boolean |
isBatch()
Is batching turned on? |
boolean |
isModified()
Has the plot been modified? |
boolean |
isPrinter()
Test if the current Graphics object is a printer. |
void |
moveLayerDown(Layer lyr)
Move the Layer down in the stack. |
void |
moveLayerDown(java.lang.String id)
Move the Layer down in the stack. |
void |
moveLayerUp(Layer lyr)
Move the Layer up in the stack. |
void |
moveLayerUp(java.lang.String id)
Move the Layer up in the stack. |
void |
paint(java.awt.Graphics g)
Override of the parent paint method. |
void |
processMouseEvent(java.awt.event.MouseEvent event)
Overrides the default event methods. |
void |
processMouseMotionEvent(java.awt.event.MouseEvent event)
|
void |
removePropertyChangeListener(java.beans.PropertyChangeListener l)
Remove the PropertyChangeListener from the list. |
void |
setBatch(boolean batch)
Turn on/off batching of updates to the pane. |
void |
setBatch(boolean batch,
java.lang.String msg)
Turn on/off batching of updates to the pane. |
void |
setId(java.lang.String id)
Set the Pane identifier |
void |
setModified(boolean mod,
java.lang.String mess)
Notify the pane that something has changed and a redraw is required. |
void |
setPageAlign(int vert,
int horz)
Set alignment. |
void |
setPageHAlign(int horz)
Set horizontal alignment. |
void |
setPageOrigin(java.awt.Point p)
Set the printer page origin. |
void |
setPageVAlign(int vert)
Set vertical alignment. |
void |
setSelectedObject(java.lang.Object obj)
Primarily used internally by sgt. |
void |
setSize(java.awt.Dimension d)
Set the size. |
java.lang.String |
toString()
Get a String representatinof the
Pane . |
void |
update(java.awt.Graphics g)
Updates the Pane |
Methods inherited from class java.awt.Container |
addContainerListener, addNotify, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getListeners, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, remove, remove, removeAll, removeContainerListener, removeNotify, setFont, setLayout, validate |
Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, disable, dispatchEvent, enable, enable, enableInputMethods, getAccessibleContext, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setVisible, show, show, size, transferFocus |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public Pane(java.lang.String id, java.awt.Dimension size)
Pane
.id
- the Pane
identifiersize
- the size of the Pane
in pixelspublic Pane()
import gov.noaa.pmel.sgt.Pane; ... Pane pane; ... pane = new Pane("main graph", new Dimension(400, 500)); pane.setLayout(new StackedLayout()); ...
StackedLayout
Method Detail |
public void draw()
AbstractPane
AbstractPane
and all of the attached Classes
will be drawn. Drawing will occur in an offscreen image and then
copied to the screen. A new offscreen image is created on the
first call to draw() or if the size of the pane has been
changed. The offscreen image will be used as a "double" buffer
when the screen requires redrawing.
Each Layer
that has been added will be drawn in the
order added, except if that order has been change using the
moveLayerUp()
or moveLayerDown()
methods.
draw
in interface AbstractPane
gov.noaa.pmel.sgt.AbstractPane
Graphics
,
Layer
public void init()
init
in interface AbstractPane
public void draw(java.awt.Graphics g)
AbstractPane
AbstractPane
and all of the attached Classes
will be drawn. Drawing will occur using the supplied
Graphics
object.draw
in interface AbstractPane
gov.noaa.pmel.sgt.AbstractPane
g
- User supplied Graphics
objectGraphics
public void draw(java.awt.Graphics g, int width, int height)
AbstractPane
AbstractPane
and all of the attached Classes
will be drawn. Drawing will occur using the supplied
Graphics
object. And clipping will be done to the
width and height.draw
in interface AbstractPane
gov.noaa.pmel.sgt.AbstractPane
g
- User supplied Graphics
objectwidth
- clipping widthheight
- clipping heightGraphics
public boolean isPrinter()
AbstractPane
Graphics
object is a printer.isPrinter
in interface AbstractPane
gov.noaa.pmel.sgt.AbstractPane
public static StrokeDrawer getStrokeDrawer()
public java.awt.Dimension getPageSize()
AbstractPane
getPageSize
in interface AbstractPane
gov.noaa.pmel.sgt.AbstractPane
public void update(java.awt.Graphics g)
Pane
update
in class java.awt.Container
java.awt.Container
g
- the specified Graphics windowComponent.update(java.awt.Graphics)
public void paint(java.awt.Graphics g)
paint
method. This method should not be
called by a user.paint
in class java.awt.Container
java.awt.Container
g
- the specified Graphics windowComponent.update(java.awt.Graphics)
public java.awt.Component add(java.awt.Component comp)
Pane
.add
in class java.awt.Container
comp
- the component to be addedpublic java.awt.Component add(java.awt.Component comp, int index)
Pane
at the
given position.add
in class java.awt.Container
comp
- the component to be addedindex
- the position at which to insert the component, or -1
to insert the component at the end.public void add(java.awt.Component comp, java.lang.Object constraints)
Pane
.
Also notifies the layout manager to add the component to this
Pane
's layout using the specified constraints object.add
in class java.awt.Container
comp
- the component to be addedconstraints
- an object expressing layout constraints for
this componentpublic void add(java.awt.Component comp, java.lang.Object constraints, int index)
Pane
at the specified index.
Also notifies the layout manager to add the component to this
Pane
's layout using the specified constraints object.add
in class java.awt.Container
comp
- the component to be addedconstraints
- an object expressing layout constraints for
this componentindex
- the position in the Pane
's list at which to
insert the component -1 means insert at the end.public java.awt.Component add(java.lang.String name, java.awt.Component comp)
Pane
. It
is strongly advised to use add(Component, Object), in place
of this method.add
in class java.awt.Container
public java.awt.Rectangle getBounds()
AbstractPane
getBounds
in interface AbstractPane
getBounds
in class java.awt.Component
gov.noaa.pmel.sgt.AbstractPane
public java.lang.String getId()
AbstractPane
Pane
identifier.getId
in interface AbstractPane
gov.noaa.pmel.sgt.AbstractPane
String
containing the Pane
identifier.public void setId(java.lang.String id)
AbstractPane
Pane
identifiersetId
in interface AbstractPane
public void setPageAlign(int vert, int horz)
AbstractPane
setPageAlign
in interface AbstractPane
gov.noaa.pmel.sgt.AbstractPane
vert
- vertical alignmenthorz
- horizontal alignmentpublic void setPageVAlign(int vert)
AbstractPane
TOP
,
MIDDLE
, and BOTTOM
for vert and
LEFT
, CENTER
, and RIGHT
for horz.setPageVAlign
in interface AbstractPane
gov.noaa.pmel.sgt.AbstractPane
vert
- vertical alignmentAbstractPane.TOP
,
AbstractPane.MIDDLE
,
AbstractPane.BOTTOM
,
AbstractPane.LEFT
,
AbstractPane.CENTER
,
AbstractPane.RIGHT
public void setPageHAlign(int horz)
AbstractPane
TOP
,
MIDDLE
, and BOTTOM
.setPageHAlign
in interface AbstractPane
gov.noaa.pmel.sgt.AbstractPane
horz
- horizontal alignmentAbstractPane.TOP
,
AbstractPane.MIDDLE
,
AbstractPane.BOTTOM
public int getPageVAlign()
AbstractPane
LEFT
, CENTER
, and RIGHT
.getPageVAlign
in interface AbstractPane
gov.noaa.pmel.sgt.AbstractPane
AbstractPane.LEFT
,
AbstractPane.CENTER
,
AbstractPane.RIGHT
public int getPageHAlign()
AbstractPane
getPageHAlign
in interface AbstractPane
gov.noaa.pmel.sgt.AbstractPane
public void setPageOrigin(java.awt.Point p)
AbstractPane
setPageOrigin
in interface AbstractPane
public java.awt.Point getPageOrigin()
AbstractPane
getPageOrigin
in interface AbstractPane
public void setSize(java.awt.Dimension d)
setSize
in class java.awt.Component
java.awt.Component
d
- The dimension specifying the new size
of this component.Component.setSize(int, int)
,
Component.setBounds(int, int, int, int)
public Layer getFirstLayer()
AbstractPane
Layer
associated with the Pane
getFirstLayer
in interface AbstractPane
gov.noaa.pmel.sgt.AbstractPane
Layer
objectpublic Layer getLayer(java.lang.String id) throws LayerNotFoundException
AbstractPane
Layer
associated with the
Pane
indicated by the id.getLayer
in interface AbstractPane
gov.noaa.pmel.sgt.AbstractPane
id
- identifier.LayerNotFoundException
- The Layer
indicated by the id was not found.public Layer getLayerFromDataId(java.lang.String id) throws LayerNotFoundException
AbstractPane
Layer
associated with the
Pane
indicated by the data id.getLayerFromDataId
in interface AbstractPane
gov.noaa.pmel.sgt.AbstractPane
id
- data identifierLayerNotFoundException
- The Layer
indicated by the id was not found.SGTData
public void moveLayerUp(Layer lyr) throws LayerNotFoundException
Layer
up in the stack.
The order of the layers determine when they
are drawn. Moving the Layer
up causes the
Layer
to be drawn later and over earlier
layers.lyr
- Layer
object.LayerNotFoundException
- The specified Layer
was not found in the list.Layer
public void moveLayerUp(java.lang.String id) throws LayerNotFoundException
Layer
up in the stack.
The order of the layers determine when they
are drawn. Moving the Layer
up causes the
Layer
to be drawn later and over earlier
layers.id
- identifier.LayerNotFoundException
- The specified Layer
was not found in the list.Layer
public void moveLayerDown(Layer lyr) throws LayerNotFoundException
Layer
down in the stack.
The order of the layers determine when they
are drawn. Moving the Layer
down causes the
Layer
to be drawn earlier.lyr
- Layer
object.LayerNotFoundException
- The specified Layer
was not found in the list.Layer
public void moveLayerDown(java.lang.String id) throws LayerNotFoundException
Layer
down in the stack.
The order of the layers determine when they
are drawn. Moving the Layer
down causes the
Layer
to be drawn earlier.id
- identifierLayerNotFoundException
- The specified Layer
was not found in the list.Layer
public java.lang.Object getSelectedObject()
AbstractPane
Layer
s currently connected to the
pane. AbstractPane
tests
each layer after a MOUSE_DOWN event for an object whose bounding box
contains the mouse. The pane object then passes the event on to the next
level.getSelectedObject
in interface AbstractPane
public void setSelectedObject(java.lang.Object obj)
AbstractPane
setSelectedObject
in interface AbstractPane
public void processMouseEvent(java.awt.event.MouseEvent event)
public void processMouseMotionEvent(java.awt.event.MouseEvent event)
public java.awt.Rectangle getZoomBounds()
AbstractPane
getZoomBounds
in interface AbstractPane
gov.noaa.pmel.sgt.AbstractPane
public java.lang.Object getObjectAt(int x, int y)
AbstractPane
getObjectAt
in interface AbstractPane
public java.awt.Component getComponent()
AbstractPane
Component
associated with
the pane.getComponent
in interface AbstractPane
public java.awt.Dimension getMaximumSize()
java.awt.Container
getMaximumSize
in class java.awt.Container
java.awt.Container
Container.getPreferredSize()
public java.awt.Dimension getMinimumSize()
java.awt.Container
getMinimumSize
in class java.awt.Container
java.awt.Container
Dimension
that represents
the minimum size of this container.Container.getPreferredSize()
,
Container.getLayout()
,
LayoutManager.minimumLayoutSize(java.awt.Container)
,
Component.getMinimumSize()
public java.awt.Dimension getPreferredSize()
java.awt.Container
getPreferredSize
in class java.awt.Container
java.awt.Container
Dimension
that represents
the preferred size of this container.Container.getMinimumSize()
,
Container.getLayout()
,
LayoutManager.preferredLayoutSize(java.awt.Container)
,
Component.getPreferredSize()
public java.lang.String toString()
String
representatinof the
Pane
.toString
in class java.awt.Component
String
representationpublic void setBatch(boolean batch, java.lang.String msg)
AbstractPane
true
property change events will
not cause pane to redraw. When batching is
turned back on if the pane has been modified it
will then redraw.setBatch
in interface AbstractPane
public void setBatch(boolean batch)
AbstractPane
true
property change events will
not cause pane to redraw. When batching is
turned back on if the pane has been modified it
will then redraw.setBatch
in interface AbstractPane
public boolean isBatch()
AbstractPane
isBatch
in interface AbstractPane
public void setModified(boolean mod, java.lang.String mess)
AbstractPane
setModified
in interface AbstractPane
public boolean isModified()
AbstractPane
isModified
in interface AbstractPane
public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
AbstractPane
Pane
and JPane
include
"objectSelected" and "zoomRectangle".addPropertyChangeListener
in interface AbstractPane
addPropertyChangeListener
in class java.awt.Component
java.awt.Component
listener
- The PropertyChangeListener to be addedpublic void removePropertyChangeListener(java.beans.PropertyChangeListener l)
AbstractPane
removePropertyChangeListener
in interface AbstractPane
removePropertyChangeListener
in class java.awt.Component
java.awt.Component
listener
- The PropertyChangeListener to be removed
|
SGT Home | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |