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.

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

A way to ensure that the pane tells its associated scales what the range of each is (before the scales need that information) is


Variable Index

 o axisScaleDefault
Default scale value to be used inplace of null.
 o DEPTH_OVERLAY
Depth value for a graphic element in the overlay layer.
 o DEPTH_UNDERLAY
Depth value for a graphic element in the underlay layer.

Constructor Index

 o GraphicPane()
Construct a GraphicPane.

Method Index

 o addGraphic(Graphic)
Add a graphic element at the default depth.
 o addGraphic(Graphic, int)
Add a graphic element at the given (discrete) depth.
 o beginZoomCenterSet()
Begin zoom center setting mode.
 o calculateBounds()
Calculate the union of the user coordinate bounds of the graphic elements in this container.
 o doLayout()
Override doLayout() to layout the Graphic elements.
 o endZoomCenterSet()
End zoom center setting mode.
 o getBoundsUC()
Return the user coordinate bounds of the graphic elements in this container.
 o getDepthMax()
Return the minimum depth of the graphic elements.
 o getDepthMin()
Return the minimum depth of the graphic elements.
 o getDepthShowMax()
Return the maximum depth of the graphic elements being shown.
 o getDepthShowMin()
Return the minimum depth of the graphic elements being shown.
 o getGraphicAt(int, int)
Implement Container.getComponentAt() equivalent that takes into account that graphic elements have an explicit depth.
 o getInsetsUC()
Return the user coordinate insets of the GraphicPane.
 o getMinimumSize()
Override getMinimumSize().
 o getPaintOnLayout()
Get the "paint on layout value.
 o getPreferredSize()
Override getPreferredSize().
 o getShowOverlay()
Whether graphic elements in the overlay layer are being shown.
 o getShowUnderlay()
Whether graphic elements in the underlay layer are being shown.
 o getViewportBounds()
Return the bounds of the viewport.
 o getXScale()
Return the X-axis scale associated with this object.
 o getYScale()
Return the Y-axis scale associated with this object.
 o mouseClicked(MouseEvent)
Implement MouseListener.mouseClicked(MouseEvent)
 o mouseEntered(MouseEvent)
Implement MouseEntered.mouseEntered(MouseEvent)
 o mouseExited(MouseEvent)
Implement MouseEntered.mouseExited(MouseEvent)
 o mousePressed(MouseEvent)
Implement MouseListener.mousePressed(MouseEvent)
 o mouseReleased(MouseEvent)
Implement MouseListener.mouseReleased(MouseEvent)
 o paint(Graphics)
Override paint(Graphics) to paint all the graphic elements in this container.
 o removeAll()
Remove all graphic elements from this container.
 o removeGraphic(Graphic)
Remove a graphic element from this container.
 o setBounds(int, int, int, int)
Override setBounds for implementation reasons.
 o setBoundsUC(double, double, double, double)
Set the user coordinate bounds to be used.
 o setBoundsUCXDim(double, double)
Set the user coordinate bounds to be used for X Dimension.
 o setBoundsUCYDim(double, double)
Set the user coordinate bounds to be used for Y Dimension.
 o setDepthShow(int, int)
 o setInsetsUC(double, double, double, double)
Set the user coordinate insets of the GraphicPane.
 o setInsetsUC(InsetsUC)
Set the user coordinate insets of the GraphicPane.
 o setPaintOnLayout(boolean)
Set the "paint on layout" value.
 o setShowOverlay(boolean)
Whether graphic elements in the overlay layer are to be shown.
 o setShowUnderlay(boolean)
Whether graphic elements in the underlay layer are to be shown.
 o setXScale(AxisScale)
Set the X-axis scale associated with this container.
 o setYScale(AxisScale)
Set the Y-axis scale associated with this container.
 o updateScaleRange()
Inform the associated scales the range of values to be covered by the scales (if it has changed).
 o xformPointAWT2UC(Point, PointUC)
Transform a Point from AWT (inside the GraphicPane) to user coordinates.
 o xformPointUC2AWT(PointUC, Point)
Transform a Point from user to AWT coordinates (inside the GraphicPane).
 o xformXAWT2UC(int)
Transform an AWT X coordinate (outside the GraphicPane) to a user coordinate.
 o xformXUC2AWT(double)
Transform a user X coordinate to an AWT coordinate (outside the GraphicPane).
 o xformYAWT2UC(int)
Transform an AWT Y coordinate (outside the GraphicPane) to a user coordinate.
 o xformYUC2AWT(double)
Transform a user Y coordinate to an AWT coordinate (outside the GraphicPane).

Variables

 o DEPTH_UNDERLAY
 public static final int DEPTH_UNDERLAY
Depth value for a graphic element in the underlay layer.

 o DEPTH_OVERLAY
 public static final int DEPTH_OVERLAY
Depth value for a graphic element in the overlay layer.

 o axisScaleDefault
 public static final AxisScale axisScaleDefault
Default scale value to be used inplace of null.

Constructors

 o GraphicPane
 public GraphicPane()
Construct a GraphicPane.

Methods

 o getBoundsUC
 public RectangleUC getBoundsUC()
Return the user coordinate bounds of the graphic elements in this container.

 o setBoundsUC
 public void setBoundsUC(double x,
                         double y,
                         double width,
                         double height)
Set the user coordinate bounds to be used.

 o setBoundsUCXDim
 public void setBoundsUCXDim(double x,
                             double width)
Set the user coordinate bounds to be used for X Dimension.

 o setBoundsUCYDim
 public void setBoundsUCYDim(double y,
                             double height)
Set the user coordinate bounds to be used for Y Dimension.

 o getInsetsUC
 public InsetsUC getInsetsUC()
Return the user coordinate insets of the GraphicPane.

 o setInsetsUC
 public void setInsetsUC(InsetsUC i)
Set the user coordinate insets of the GraphicPane.

 o setInsetsUC
 public void setInsetsUC(double top,
                         double left,
                         double bottom,
                         double right)
Set the user coordinate insets of the GraphicPane.

 o getDepthMin
 public int getDepthMin()
Return the minimum depth of the graphic elements.

 o getDepthMax
 public int getDepthMax()
Return the minimum depth of the graphic elements.

 o getDepthShowMin
 public int getDepthShowMin()
Return the minimum depth of the graphic elements being shown.

 o getDepthShowMax
 public int getDepthShowMax()
Return the maximum depth of the graphic elements being shown.

 o setDepthShow
 public void setDepthShow(int min,
                          int max)
 o getShowUnderlay
 public boolean getShowUnderlay()
Whether graphic elements in the underlay layer are being shown.

 o setShowUnderlay
 public void setShowUnderlay(boolean show)
Whether graphic elements in the underlay layer are to be shown.

 o getShowOverlay
 public boolean getShowOverlay()
Whether graphic elements in the overlay layer are being shown.

 o setShowOverlay
 public void setShowOverlay(boolean show)
Whether graphic elements in the overlay layer are to be shown.

 o 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.

 o getXScale
 public AxisScale getXScale()
Return the X-axis scale associated with this object.

 o 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).

 o getYScale
 public AxisScale getYScale()
Return the Y-axis scale associated with this object.

 o 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).

 o addGraphic
 public Graphic addGraphic(Graphic g,
                           int depth)
Add a graphic element at the given (discrete) depth.

 o addGraphic
 public Graphic addGraphic(Graphic g)
Add a graphic element at the default depth.

 o removeAll
 public synchronized void removeAll()
Remove all graphic elements from this container.

Overrides:
removeAll in class Container
 o removeGraphic
 public void removeGraphic(Graphic g)
Remove a graphic element from this container. Note: this method does not recalculate the user coordinate bounds.

 o calculateBounds
 public synchronized void calculateBounds()
Calculate the union of the user coordinate bounds of the graphic elements in this container.

 o getPaintOnLayout
 public boolean getPaintOnLayout()
Get the "paint on layout value.

 o 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
 o doLayout
 public synchronized void doLayout()
Override doLayout() to layout the Graphic elements.

Overrides:
doLayout in class Container
 o getGraphicAt
 public Graphic getGraphicAt(int x,
                             int y)
Implement Container.getComponentAt() equivalent that takes into account that graphic elements have an explicit depth.

 o getPreferredSize
 public Dimension getPreferredSize()
Override getPreferredSize().

Overrides:
getPreferredSize in class Container
 o getMinimumSize
 public Dimension getMinimumSize()
Override getMinimumSize().

Overrides:
getMinimumSize in class Container
 o paint
 public void paint(Graphics g)
Override paint(Graphics) to paint all the graphic elements in this container.

Overrides:
paint in class Container
 o setBounds
 public void setBounds(int x,
                       int y,
                       int width,
                       int height)
Override setBounds for implementation reasons.

Overrides:
setBounds in class Component
 o updateScaleRange
 public void updateScaleRange()
Inform the associated scales the range of values to be covered by the scales (if it has changed).

 o xformXUC2AWT
 public int xformXUC2AWT(double x)
Transform a user X coordinate to an AWT coordinate (outside the GraphicPane).

 o xformXAWT2UC
 public double xformXAWT2UC(int x)
Transform an AWT X coordinate (outside the GraphicPane) to a user coordinate.

 o xformYUC2AWT
 public int xformYUC2AWT(double y)
Transform a user Y coordinate to an AWT coordinate (outside the GraphicPane).

 o 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.

 o xformPointUC2AWT
 public synchronized Point xformPointUC2AWT(PointUC uc,
                                            Point awt)
Transform a Point from user to AWT coordinates (inside the GraphicPane).

 o xformPointAWT2UC
 public synchronized PointUC xformPointAWT2UC(Point awt,
                                              PointUC uc)
Transform a Point from AWT (inside the GraphicPane) to user coordinates.

 o mouseClicked
 public void mouseClicked(MouseEvent e)
Implement MouseListener.mouseClicked(MouseEvent)

 o mousePressed
 public void mousePressed(MouseEvent e)
Implement MouseListener.mousePressed(MouseEvent)

 o mouseReleased
 public void mouseReleased(MouseEvent e)
Implement MouseListener.mouseReleased(MouseEvent)

 o mouseEntered
 public void mouseEntered(MouseEvent e)
Implement MouseEntered.mouseEntered(MouseEvent)

 o mouseExited
 public void mouseExited(MouseEvent e)
Implement MouseEntered.mouseExited(MouseEvent)

 o beginZoomCenterSet
 public void beginZoomCenterSet()
Begin zoom center setting mode.

 o endZoomCenterSet
 public void endZoomCenterSet()
End zoom center setting mode.


All Packages  Class Hierarchy  This Package  Previous  Next  Index