PamView.zoomer
Class Zoomer

java.lang.Object
  extended by PamView.zoomer.Zoomer

public class Zoomer
extends java.lang.Object

Class for handling multiple zoom and marked areas on a display.

The zoomer will generally handle both dragged rectangular zoom boxes and also more complicated polygons created by double clicking at a start point and then repeatedly single clicking until back at the start point

Author:
Doug Gillespie

Nested Class Summary
private  class Zoomer.ZoomerMouse
           
private  class Zoomer.ZoomIn
           
private  class Zoomer.ZoomOut
           
private  class Zoomer.ZoomRightOut
          Zoom right out back to the original scale before zooming
 
Field Summary
private  java.awt.Point mousePressPoint
           
private  ZoomPolygon newZoomPolygon
           
private  ZoomRectangle newZoomRectangle
           
private  ZoomShape topMostShape
           
private  java.awt.Component zoomableComponent
           
private  Zoomable zoomableThing
           
private  Zoomer.ZoomerMouse zoomerMouse
           
private  java.util.Vector<ZoomShape> zoomShapes
           
 
Constructor Summary
Zoomer(Zoomable zoomableThing, java.awt.Component zoomableComponent)
           
 
Method Summary
 int appendZoomMenuItems(java.awt.Container menu)
          Add menu items associated with zooming into a pre-existing menu.
private  boolean canZoomOut()
           
 void clearLatestShape()
           
 ZoomShape findLastZoom(int coodinateType)
           
 Zoomer.ZoomerMouse getZoomerMouse()
           
private  boolean haveZoomBox()
           
 boolean isInMark(java.awt.Component c, java.awt.Point pt)
           
 java.awt.Rectangle paintShape(java.awt.Graphics g, java.awt.Component c, boolean beforeOther)
          Paint the top most shape in the zoom sequence
protected  double pointXtoVal(int x)
          Convert a point in pixels to a value for the x scale
protected  double pointYtoVal(java.awt.Component c, int y)
          Convert a point in pixels to a value for the y scale
protected  java.awt.Point xyValToPoint(java.awt.Component c, double x, double y)
           
private  void zoomIn()
          Zoom in to the bounds of the next zoom shape
private  void zoomOut()
          Zoom out to the bounds of the preceding zoom shape
private  void zoomRightOut()
          Zoom right out to position of display prior to zooming
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

zoomableThing

private Zoomable zoomableThing

zoomShapes

private java.util.Vector<ZoomShape> zoomShapes

topMostShape

private ZoomShape topMostShape

zoomerMouse

private Zoomer.ZoomerMouse zoomerMouse

mousePressPoint

private java.awt.Point mousePressPoint

newZoomRectangle

private ZoomRectangle newZoomRectangle

newZoomPolygon

private ZoomPolygon newZoomPolygon

zoomableComponent

private java.awt.Component zoomableComponent
Constructor Detail

Zoomer

public Zoomer(Zoomable zoomableThing,
              java.awt.Component zoomableComponent)
Method Detail

paintShape

public java.awt.Rectangle paintShape(java.awt.Graphics g,
                                     java.awt.Component c,
                                     boolean beforeOther)
Paint the top most shape in the zoom sequence

This should be called twice from the paint function of the component hosting the zoom feature, once before other drawing and once after.

Parameters:
g - graphics
c - component to draw on
beforeOther - called before other drawing
Returns:
outer rectangle of drawing.

xyValToPoint

protected java.awt.Point xyValToPoint(java.awt.Component c,
                                      double x,
                                      double y)

pointXtoVal

protected double pointXtoVal(int x)
Convert a point in pixels to a value for the x scale

Parameters:
x - x in pixels
Returns:
scaled value in units such as time, bearing, etc.

pointYtoVal

protected double pointYtoVal(java.awt.Component c,
                             int y)
Convert a point in pixels to a value for the y scale

Parameters:
y - y in pixels
Returns:
scaled value in units such as time, bearing, etc.

isInMark

public boolean isInMark(java.awt.Component c,
                        java.awt.Point pt)
Parameters:
pt - Point on display in pixels.
Returns:
true if there is no mark or if the click is within the marked region

clearLatestShape

public void clearLatestShape()

appendZoomMenuItems

public int appendZoomMenuItems(java.awt.Container menu)
Add menu items associated with zooming into a pre-existing menu.

Parameters:
menu - menu
Returns:
number of items added.

haveZoomBox

private boolean haveZoomBox()

canZoomOut

private boolean canZoomOut()

zoomIn

private void zoomIn()
Zoom in to the bounds of the next zoom shape


zoomOut

private void zoomOut()
Zoom out to the bounds of the preceding zoom shape


zoomRightOut

private void zoomRightOut()
Zoom right out to position of display prior to zooming


getZoomerMouse

public Zoomer.ZoomerMouse getZoomerMouse()
Returns:
the zoomerMouse

findLastZoom

public ZoomShape findLastZoom(int coodinateType)