All Packages Class Hierarchy This Package Previous Next Index
Class GraphicPlotter.GraphicPane
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Container
|
+----GraphicPlotter.MagnifiableContainer
|
+----GraphicPlotter.GraphicPane
- public final class GraphicPane
- extends MagnifiableContainer
- implements MouseListener
Contains Graphic elements to be viewed. It is a specialized and
restricted container. It particular, because it 1) maintains it own
collection of Components that have been added to it and 2) uses its
own layout manager that cannot be changed, the following Container
methods are not meaningful.
- add, however addGraphic(Graphic g) is defined
by this class.
- getComponent, getComponents and
getComponentCount.
- getLayout and setLayout
- paintComponents, however paint is defined by
this class
This container keeps track of the union of the bounds of the graphic
elements that have been added to it. That bounds is returned by
getBoundsUC. That bounds may to set by calling
setBoundsUC.
There is a relationship between a GraphicPane and the AxisScales
associated with it that is not independently maintained by these
objects. A container that contains a pane and associated scales
must help to maintain this relationship. Specifically, each
AxisScale needs to know the range of values that it covers in
order to implement its getPreferredSize and paint methods.
A simple approach would be to have a pane tell its associated
scales what the range is whenever it changes. Typically the range
changes when a graphic element is added to the pane. However, this
class is designed to be able to have a very large number of
graphic elements added to it. Invoking a method on each scale
when the range changes would significantly increase the code
path length of the addGraphic method.
The approach that is used is to have a pane tell its associated
scales what the range of each is when its getPreferredSize method
is invoked. This apporach works as long as the getPreferredSize
method is invoked on the pane before it is invoked on the scales.
However, the order in which the getPreferredSize method is invoked
for each component is not specified. Usually, what works is
- have the pane and associated scales be components in the same
container, and
- add the pane to that container before the scales.
A way to ensure that the pane tells its associated scales what the
range of each is (before the scales need that information) is
-
axisScaleDefault
- Default scale value to be used inplace of null.
-
DEPTH_OVERLAY
- Depth value for a graphic element in the overlay layer.
-
DEPTH_UNDERLAY
- Depth value for a graphic element in the underlay layer.
-
GraphicPane()
- Construct a GraphicPane.
-
addGraphic(Graphic)
- Add a graphic element at the default depth.
-
addGraphic(Graphic, int)
- Add a graphic element at the given (discrete) depth.
-
beginZoomCenterSet()
- Begin zoom center setting mode.
-
calculateBounds()
- Calculate the union of the user coordinate bounds of the graphic
elements in this container.
-
doLayout()
- Override doLayout() to layout the Graphic elements.
-
endZoomCenterSet()
- End zoom center setting mode.
-
getBoundsUC()
- Return the user coordinate bounds of the graphic elements in
this container.
-
getDepthMax()
- Return the minimum depth of the graphic elements.
-
getDepthMin()
- Return the minimum depth of the graphic elements.
-
getDepthShowMax()
- Return the maximum depth of the graphic elements being shown.
-
getDepthShowMin()
- Return the minimum depth of the graphic elements being shown.
-
getGraphicAt(int, int)
- Implement Container.getComponentAt() equivalent that takes into
account that graphic elements have an explicit depth.
-
getInsetsUC()
- Return the user coordinate insets of the GraphicPane.
-
getMinimumSize()
- Override getMinimumSize().
-
getPaintOnLayout()
- Get the "paint on layout value.
-
getPreferredSize()
- Override getPreferredSize().
-
getShowOverlay()
- Whether graphic elements in the overlay layer are being shown.
-
getShowUnderlay()
- Whether graphic elements in the underlay layer are being shown.
-
getViewportBounds()
- Return the bounds of the viewport.
-
getXScale()
- Return the X-axis scale associated with this object.
-
getYScale()
- Return the Y-axis scale associated with this object.
-
mouseClicked(MouseEvent)
- Implement MouseListener.mouseClicked(MouseEvent)
-
mouseEntered(MouseEvent)
- Implement MouseEntered.mouseEntered(MouseEvent)
-
mouseExited(MouseEvent)
- Implement MouseEntered.mouseExited(MouseEvent)
-
mousePressed(MouseEvent)
- Implement MouseListener.mousePressed(MouseEvent)
-
mouseReleased(MouseEvent)
- Implement MouseListener.mouseReleased(MouseEvent)
-
paint(Graphics)
- Override paint(Graphics) to paint all the graphic elements in this
container.
-
removeAll()
- Remove all graphic elements from this container.
-
removeGraphic(Graphic)
- Remove a graphic element from this container.
-
setBounds(int, int, int, int)
- Override setBounds for implementation reasons.
-
setBoundsUC(double, double, double, double)
- Set the user coordinate bounds to be used.
-
setBoundsUCXDim(double, double)
- Set the user coordinate bounds to be used for X Dimension.
-
setBoundsUCYDim(double, double)
- Set the user coordinate bounds to be used for Y Dimension.
-
setDepthShow(int, int)
-
-
setInsetsUC(double, double, double, double)
- Set the user coordinate insets of the GraphicPane.
-
setInsetsUC(InsetsUC)
- Set the user coordinate insets of the GraphicPane.
-
setPaintOnLayout(boolean)
- Set the "paint on layout" value.
-
setShowOverlay(boolean)
- Whether graphic elements in the overlay layer are to be shown.
-
setShowUnderlay(boolean)
- Whether graphic elements in the underlay layer are to be shown.
-
setXScale(AxisScale)
- Set the X-axis scale associated with this container.
-
setYScale(AxisScale)
- Set the Y-axis scale associated with this container.
-
updateScaleRange()
- Inform the associated scales the range of values to be covered
by the scales (if it has changed).
-
xformPointAWT2UC(Point, PointUC)
- Transform a Point from AWT (inside the GraphicPane) to user
coordinates.
-
xformPointUC2AWT(PointUC, Point)
- Transform a Point from user to AWT coordinates (inside the
GraphicPane).
-
xformXAWT2UC(int)
- Transform an AWT X coordinate (outside the GraphicPane) to a
user coordinate.
-
xformXUC2AWT(double)
- Transform a user X coordinate to an AWT coordinate (outside
the GraphicPane).
-
xformYAWT2UC(int)
- Transform an AWT Y coordinate (outside the GraphicPane) to a
user coordinate.
-
xformYUC2AWT(double)
- Transform a user Y coordinate to an AWT coordinate (outside
the GraphicPane).
DEPTH_UNDERLAY
public static final int DEPTH_UNDERLAY
- Depth value for a graphic element in the underlay layer.
DEPTH_OVERLAY
public static final int DEPTH_OVERLAY
- Depth value for a graphic element in the overlay layer.
axisScaleDefault
public static final AxisScale axisScaleDefault
- Default scale value to be used inplace of null.
GraphicPane
public GraphicPane()
- Construct a GraphicPane.
getBoundsUC
public RectangleUC getBoundsUC()
- Return the user coordinate bounds of the graphic elements in
this container.
setBoundsUC
public void setBoundsUC(double x,
double y,
double width,
double height)
- Set the user coordinate bounds to be used.
setBoundsUCXDim
public void setBoundsUCXDim(double x,
double width)
- Set the user coordinate bounds to be used for X Dimension.
setBoundsUCYDim
public void setBoundsUCYDim(double y,
double height)
- Set the user coordinate bounds to be used for Y Dimension.
getInsetsUC
public InsetsUC getInsetsUC()
- Return the user coordinate insets of the GraphicPane.
setInsetsUC
public void setInsetsUC(InsetsUC i)
- Set the user coordinate insets of the GraphicPane.
setInsetsUC
public void setInsetsUC(double top,
double left,
double bottom,
double right)
- Set the user coordinate insets of the GraphicPane.
getDepthMin
public int getDepthMin()
- Return the minimum depth of the graphic elements.
getDepthMax
public int getDepthMax()
- Return the minimum depth of the graphic elements.
getDepthShowMin
public int getDepthShowMin()
- Return the minimum depth of the graphic elements being shown.
getDepthShowMax
public int getDepthShowMax()
- Return the maximum depth of the graphic elements being shown.
setDepthShow
public void setDepthShow(int min,
int max)
getShowUnderlay
public boolean getShowUnderlay()
- Whether graphic elements in the underlay layer are being shown.
setShowUnderlay
public void setShowUnderlay(boolean show)
- Whether graphic elements in the underlay layer are to be shown.
getShowOverlay
public boolean getShowOverlay()
- Whether graphic elements in the overlay layer are being shown.
setShowOverlay
public void setShowOverlay(boolean show)
- Whether graphic elements in the overlay layer are to be shown.
getViewportBounds
public Rectangle getViewportBounds()
- Return the bounds of the viewport. Note: the fields of the
returned object must not be modified. Returning an object
whose fields must not be modified (as opposed to returning a new
object) reduces the number of temporary objects created by the
program, thus reducing the amount of garbage collecting.
getXScale
public AxisScale getXScale()
- Return the X-axis scale associated with this object.
setXScale
public void setXScale(AxisScale scale)
- Set the X-axis scale associated with this container. A scale
argument of
null
is replaced with a reference to a
default scale object (eliminating the need to check for null
before every use of the scale object).
getYScale
public AxisScale getYScale()
- Return the Y-axis scale associated with this object.
setYScale
public void setYScale(AxisScale scale)
- Set the Y-axis scale associated with this container. A scale
argument of
null
is replaced with a reference to a
default scale object (eliminating the need to check for null
before every use of the scale object).
addGraphic
public Graphic addGraphic(Graphic g,
int depth)
- Add a graphic element at the given (discrete) depth.
addGraphic
public Graphic addGraphic(Graphic g)
- Add a graphic element at the default depth.
removeAll
public synchronized void removeAll()
- Remove all graphic elements from this container.
- Overrides:
- removeAll in class Container
removeGraphic
public void removeGraphic(Graphic g)
- Remove a graphic element from this container. Note: this
method does not recalculate the user coordinate bounds.
calculateBounds
public synchronized void calculateBounds()
- Calculate the union of the user coordinate bounds of the graphic
elements in this container.
getPaintOnLayout
public boolean getPaintOnLayout()
- Get the "paint on layout value.
setPaintOnLayout
public boolean setPaintOnLayout(boolean value)
- Set the "paint on layout" value. Normally its value is false so
that the graphic elements are repainted if their location or size
is changed during layout. When the value is true, the layout
method does not return until after the painting has completed.
This is useful for application that update the screen periodically
to show the graphic elements added so far. Such applications
do not want to restart the timer until after the painting has
completed.
- Returns:
- the previous value
doLayout
public synchronized void doLayout()
- Override doLayout() to layout the Graphic elements.
- Overrides:
- doLayout in class Container
getGraphicAt
public Graphic getGraphicAt(int x,
int y)
- Implement Container.getComponentAt() equivalent that takes into
account that graphic elements have an explicit depth.
getPreferredSize
public Dimension getPreferredSize()
- Override getPreferredSize().
- Overrides:
- getPreferredSize in class Container
getMinimumSize
public Dimension getMinimumSize()
- Override getMinimumSize().
- Overrides:
- getMinimumSize in class Container
paint
public void paint(Graphics g)
- Override paint(Graphics) to paint all the graphic elements in this
container.
- Overrides:
- paint in class Container
setBounds
public void setBounds(int x,
int y,
int width,
int height)
- Override setBounds for implementation reasons.
- Overrides:
- setBounds in class Component
updateScaleRange
public void updateScaleRange()
- Inform the associated scales the range of values to be covered
by the scales (if it has changed).
xformXUC2AWT
public int xformXUC2AWT(double x)
- Transform a user X coordinate to an AWT coordinate (outside
the GraphicPane).
xformXAWT2UC
public double xformXAWT2UC(int x)
- Transform an AWT X coordinate (outside the GraphicPane) to a
user coordinate.
xformYUC2AWT
public int xformYUC2AWT(double y)
- Transform a user Y coordinate to an AWT coordinate (outside
the GraphicPane).
xformYAWT2UC
public double xformYAWT2UC(int y)
- Transform an AWT Y coordinate (outside the GraphicPane) to a
user coordinate. An AWT Y coordinate of MAX_VALUE transforms
to the minimum user Y coordinate.
xformPointUC2AWT
public synchronized Point xformPointUC2AWT(PointUC uc,
Point awt)
- Transform a Point from user to AWT coordinates (inside the
GraphicPane).
xformPointAWT2UC
public synchronized PointUC xformPointAWT2UC(Point awt,
PointUC uc)
- Transform a Point from AWT (inside the GraphicPane) to user
coordinates.
mouseClicked
public void mouseClicked(MouseEvent e)
- Implement MouseListener.mouseClicked(MouseEvent)
mousePressed
public void mousePressed(MouseEvent e)
- Implement MouseListener.mousePressed(MouseEvent)
mouseReleased
public void mouseReleased(MouseEvent e)
- Implement MouseListener.mouseReleased(MouseEvent)
mouseEntered
public void mouseEntered(MouseEvent e)
- Implement MouseEntered.mouseEntered(MouseEvent)
mouseExited
public void mouseExited(MouseEvent e)
- Implement MouseEntered.mouseExited(MouseEvent)
beginZoomCenterSet
public void beginZoomCenterSet()
- Begin zoom center setting mode.
endZoomCenterSet
public void endZoomCenterSet()
- End zoom center setting mode.
All Packages Class Hierarchy This Package Previous Next Index