|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
gov.noaa.pmel.sgt.Layer
public class Layer
A Layer
contains a single Graph
object
and multiple LayerChild
objects.
There can be many Layer
objects associated with each
Pane
object and
the Layer
objects can share Transform
and Axis
objects, but are not
required to. The Layer
is also where keys
related to Color
, Vectors, and
Lines are attached. The can be at most one key of each type attached to a
Layer
.
The Layer
object transforms physical coordinates
to device coordinates. All objects that attach to a
Layer
use physical coordinates.
The exception to this is the Graph
object
(and its children), since these objects transform user
coordinates to physical coordinates.
The following is a simple example of using the Pane
,
Layer
, and SGLabel
objects
together. In this example, the Pane
and
Layer
objects are created such that,
in the absence of any resizing, 100 pixels is equal to 1.0
physical units. Two labels are created, the first contains
the current time and is located in the bottom left of
the Layer
. The second label is a title that is
positioned near the top and centered.
Pane pane; Layer layer; SGLabel title; SGLabel label; GeoDate stime; ... // // Instantiate Pane, Layer, and GeoDate objects. // pane = new Pane("test pane", new Dimension(400, 300)); pane.setLayout(new StackedLayout()); layer = new Layer("Test Layer", new Dimension2D(4.0, 3.0)); stime = new GeoDate(); // // Instatiate an SGLabel object as label, set its text to the // current time and position it near the lower-left corner // of the layer. // label = new SGLabel("test", stime.toString(), new Point2D.Double(0.05, 0.05)); // // Set properties for label. // label.setAlign(SGLabel.BOTTOM, SGLabel.LEFT); label.setColor(Color.magenta); label.setHeightP(0.15); label.setFont(new Font("Dialog", Font.PLAIN, 10)); // // Add label to layer. // layer.addChild(label); // // Instatiate an SGLabel object as title, set its text and position // it near the top of the layer and centered. Set the properties // for title. // title = new SGLabel("title", "SciGraph Test!", new Point2D.Double(2.125, 2.9)); title.setAlign(SGLabel.TOP, SGLabel.CENTER); title.setHeightP(0.25); title.setFont(new Font("Helvetica", Font.BOLD, 14)); // // Add title to layer and add layer to pane. // layer.addChild(title); pane.add(layer);
Pane
,
Graph
,
ColorKey
,
SGLabel
,
LineKey
,
GeoDate
,
Serialized FormNested Class Summary |
---|
Nested classes/interfaces inherited from class java.awt.Component |
---|
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary | |
---|---|
protected AbstractPane |
pane_
|
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
Layer()
Default constructor for Layer . |
|
Layer(java.lang.String id)
Create a Layer object. |
|
Layer(java.lang.String id,
Dimension2D psize)
Create a Layer object. |
Method Summary | |
---|---|
void |
addChild(LayerChild child)
Add a LayerChild to the Layer . |
java.util.Enumeration |
childElements()
Create a Enumeration for the
LayerChild 's associated with the Layer . |
java.util.Iterator |
childIterator()
|
Layer |
copy()
Copy the Layer and its attached classes. |
void |
draw(java.awt.Graphics g)
Draw the Layer and its attached classes. |
void |
drawDraggableItems(java.awt.Graphics g)
Used internally by sgt. |
LayerChild |
findChild(java.lang.String id)
Find LayerChild in Layer . |
Rectangle2D.Double |
getBoundsP()
Get the Layer bounds in physical coordinates. |
LayerChild |
getChild(java.lang.String labid)
Get a child associated with the Layer . |
LayerChild[] |
getChildren()
|
Graph |
getGraph()
Get the Graph attached to the layer. |
java.lang.String |
getId()
Get the Layer identifier. |
java.lang.Object |
getObjectAt(int x,
int y)
Find object associated with a MOUSE_DOWN event. |
java.lang.Object |
getObjectAt(int x,
int y,
boolean check)
Find object associated with a MOUSE_DOWN event. |
java.lang.Object |
getObjectAt(java.awt.Point pt,
boolean check)
Find object associated with a MOUSE_DOWN event. |
java.lang.Object[] |
getObjectsAt(int x,
int y,
boolean check)
Find objects associated with a MOUSE_DOWN event. |
AbstractPane |
getPane()
Get the Pane the Layer is associated
with. |
Dimension2D |
getSizeP()
Get the Layer size in physical coordinates. |
double |
getXDtoP(int xd)
Transform device units to physical for the x direction. |
protected double |
getXOffset()
|
int |
getXPtoD(double xp)
Transform physical units to device for x coordinate. |
double |
getXPtoD2(double xp)
Transform physical units to device for x coordinate. |
protected double |
getXSlope()
|
double |
getYDtoP(int yd)
Transform device units to physical for the y direction. |
protected double |
getYOffset()
|
int |
getYPtoD(double yp)
Transform physcial units to device for y coordinate. |
double |
getYPtoD2(double yp)
Transform physcial units to device for y coordinate. |
protected double |
getYSlope()
|
boolean |
isChildAttached(LayerChild child)
Tests if a LayerChild is attached to the
Layer . |
boolean |
isDataInLayer(java.lang.String id)
Checks to see if a data id matches that data attached to the Graph . |
void |
modified(java.lang.String mess)
Used internally by sgt. |
void |
removeAllChildren()
Remove all LayerChild objects from the Layer . |
void |
removeChild(LayerChild child)
Remove a LayerChild object from the Layer . |
void |
removeChild(java.lang.String labid)
Remove a LayerChild object from the Layer . |
void |
setBounds(int x,
int y,
int w,
int h)
Set the bounds of the Layer in device units. |
void |
setBounds(java.awt.Rectangle bnds)
Set the bounds of the Layer in device units. |
boolean |
setGraph(Graph gr)
Associate a graph with the layer. |
void |
setId(java.lang.String id)
Set the Layer identifier. |
void |
setLocation(int x,
int y)
Set the location of the Layer in device units. |
void |
setLocation(java.awt.Point pt)
Set the location of the Layer in device units. |
void |
setPane(AbstractPane p)
Set the Pane the Layer is associated with. |
void |
setSize(java.awt.Dimension sze)
Set the size of the Layer in device units. |
void |
setSize(int w,
int h)
Set the size of the Layer in device units. |
void |
setSizeP(Dimension2D psize)
Set the size of the Layer in physical coordinates. |
java.lang.String |
toString()
Get a String representation of the
Layer . |
Methods inherited from class java.awt.Component |
---|
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setMinimumSize, setName, setPreferredSize, setVisible, show, show, size, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validate |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected AbstractPane pane_
Constructor Detail |
---|
public Layer(java.lang.String id)
Layer
object.
The Layer
is created with a default
width and height equal to 1.0.
id
- identifier for Layerpublic Layer(java.lang.String id, Dimension2D psize)
Layer
object.
The Layer
is created with the specified
dimensions and identifier.
id
- identifier for Layerpsize
- The physical dimensions of the Layerpublic Layer()
Layer
.
The Layer
is created with an
empty identifier and a width and height equal to 1.0f.
Method Detail |
---|
public void setSize(java.awt.Dimension sze)
Layer
in device units.
setSize
in class java.awt.Component
sze
- dimension of the Layer
public void setSize(int w, int h)
Layer
in device units.
setSize
in class java.awt.Component
w
- width of the Layer
h
- height of the Layer
public void setLocation(java.awt.Point pt)
Layer
in device units.
setLocation
in class java.awt.Component
pt
- location of the Layer
public void setLocation(int x, int y)
Layer
in device units.
setLocation
in class java.awt.Component
x
- horizontal location of the Layer
y
- vertical location of the Layer
public void setBounds(int x, int y, int w, int h)
Layer
in device units.
setBounds
in class java.awt.Component
x
- horizontal location of the Layer
y
- vertical location of the Layer
w
- width of the Layer
h
- height of the Layer
public void setBounds(java.awt.Rectangle bnds)
Layer
in device units.
setBounds
in class java.awt.Component
bnds
- bounds of the Layer
public int getXPtoD(double xp)
xp
- x physical coordinate
public int getYPtoD(double yp)
yp
- y physical coordinate
public double getXPtoD2(double xp)
xp
- x physical coordinate
public double getYPtoD2(double yp)
yp
- y physical coordinate
protected double getXSlope()
protected double getYSlope()
protected double getXOffset()
protected double getYOffset()
public double getXDtoP(int xd)
xd
- device x coordinate
public double getYDtoP(int yd)
yd
- device y coordinate
public Layer copy()
Layer
and its attached classes.
public void draw(java.awt.Graphics g) throws PaneNotFoundException
draw
in interface LayerControl
g
- graphics context
PaneNotFoundException
- if a pane object is not foundpublic void drawDraggableItems(java.awt.Graphics g) throws PaneNotFoundException
LayerControl
drawDraggableItems
in interface LayerControl
g
- Graphics object.
PaneNotFoundException
- Pane not found.public boolean setGraph(Graph gr)
gr
- graph
Graph
public Graph getGraph()
Graph
attached to the layer.
Graph
.public void addChild(LayerChild child)
LayerChild
to the Layer
.
Each Layer
can contain as many children as needed.
child
- A LayerChild
SGLabel
,
LineKey
,
ColorKey
,
Ruler
public void removeChild(LayerChild child) throws ChildNotFoundException
LayerChild
object from the Layer
.
child
- A ChildLayer
object associated with the Layer
ChildNotFoundException
- The child is not associated with the Layer
SGLabel
,
LineKey
,
ColorKey
,
Ruler
public void removeChild(java.lang.String labid) throws ChildNotFoundException
LayerChild
object from the Layer
.
labid
- An identifier for a LayerChild
associated with the Layer
ChildNotFoundException
- The child is not associated with the Layer
SGLabel
,
LineKey
,
ColorKey
,
Ruler
public LayerChild findChild(java.lang.String id)
LayerChild
in Layer
.
id
- LayerChild identifier
public boolean isChildAttached(LayerChild child)
LayerChild
is attached to the
Layer
.
child
- LayerChild to test
public void removeAllChildren()
LayerChild
objects from the Layer
.
public LayerChild getChild(java.lang.String labid) throws ChildNotFoundException
Layer
.
labid
- A LayerChild
object identifier
ChildNotFoundException
- The child is not associated with the Layer
SGLabel
,
LineKey
,
ColorKey
,
Ruler
public java.util.Enumeration childElements()
Enumeration
for the
LayerChild
's associated with the Layer
.
Enumeration
for the LayerChild
objects.Enumeration
,
SGLabel
,
LineKey
,
ColorKey
,
Ruler
public java.util.Iterator childIterator()
public LayerChild[] getChildren()
public void setSizeP(Dimension2D psize)
Layer
in physical coordinates.
psize
- The physical size of the Layer
.public Dimension2D getSizeP()
Layer
size in physical coordinates.
This returns the physical coordinate size
of the Layer
.
Dimension2D
containing the physical size of the Layer
.Dimension2D
public Rectangle2D.Double getBoundsP()
Layer
bounds in physical coordinates.
The origin of the bounding rectangle,
for a Layer
, is always (0,0).
Rectangle2D.Double
containing the physical bounds of the Layer
.Rectangle2D.Double
public java.lang.String getId()
Layer
identifier.
getId
in interface LayerControl
public void setId(java.lang.String id)
Layer
identifier.
id
- identifierpublic void setPane(AbstractPane p)
Pane
the Layer
is associated with.
This method is called by Pane
when the
Pane.add
method is exectued.
setPane
in interface LayerControl
p
- The Pane
public AbstractPane getPane()
Pane
the Layer
is associated
with.
Pane
public void modified(java.lang.String mess)
mess
- messagepublic java.lang.Object getObjectAt(int x, int y, boolean check)
pt
- device coordinatescheck
- if true requires that object isSelectable
public java.lang.Object getObjectAt(int x, int y)
pt
- device coordinates
public java.lang.Object getObjectAt(java.awt.Point pt, boolean check)
pt
- device coordinatescheck
- if true requires that object isSelectable
public java.lang.Object[] getObjectsAt(int x, int y, boolean check)
x
- mouse coordinatey
- mouse coordinatecheck
- if selectable
public java.lang.String toString()
String
representation of the
Layer
.
toString
in class java.awt.Component
String
representationpublic boolean isDataInLayer(java.lang.String id)
Graph
.
id
- data identifier
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |