com.partnersoft.maps.app
Class MapViewLogic

java.lang.Object
  extended by com.partnersoft.maps.app.MapViewLogic

public class MapViewLogic
extends java.lang.Object

Nonvisual plumbing for controlling a MapView.

Author:
Paul Reavis Copyright 2002 Partner Software, Inc.

Constructor Summary
MapViewLogic(MapApp app)
           
 
Method Summary
 void addViewListener(MapViewListener listener)
           
 void clearRotation()
           
 void discretePan(int countX, int countY)
          This is a base function for discrete panning.
 void discreteZoom(int count)
          Base function for discrete zooming.
 void dragPan(double buttonDownX, double buttonDownY, int buttonDownPixelX, int buttonDownPixelY, int startX, int startY, int endX, int endY)
           
 void dragRotate(double buttonDownX, double buttonDownY, int buttonDownPixelX, int buttonDownPixelY, int startX, int startY, int endX, int endY)
           
 void dragStart()
          This is important to keep the undo from being annoyingly fine-grained.
 void dragStop()
           
 void dragZoom(double buttonDownX, double buttonDownY, int buttonDownPixelX, int buttonDownPixelY, int startX, int startY, int endX, int endY)
           
 void ensureVisible(double x, double y)
          Ensures that the given coordinate is visible.
 java.lang.String getLegend()
           
 int getNearestZoomTo(double scale)
           
 MapViewState getState()
           
 void goHome()
           
 void incrementalZoom(double locusX, double locusY, int locusPixelX, int locusPixelY, int amount)
          Incremental zoom.
 void incrementalZoom(int amount)
           
protected  void initialize()
          Initializes the view from preferences.
 void pan(double deltaX, double deltaY)
          Panning by map coordinates.
 void panDown()
          Convenience method for discrete panning down.
 void panDownLeft()
          Down and left.
 void panDownRight()
          Down and right.
 void panLeft()
          Convenience method for discrete panning left.
 void panRight()
          Convenience method for discrete panning right.
 void panUp()
          Convenience method for discrete panning up.
 void panUpLeft()
          Up and left.
 void panUpRight()
          Up and right.
 void pixelCenterOn(int pixelX, int pixelY)
          Centers on a given pixel.
 void pixelPan(int startPixelX, int startPixelY, int endPixelX, int endPixelY)
          Panning by pixel.
 void pixelRotate(int startX, int startY, int endX, int endY)
           
 void pixelZoom(int pixelsRight, int pixelsDown)
          Zooming by pixel.
 void removeViewListener(MapViewListener listener)
           
 void rotate(double theta)
          Rotate a bit.
 void setCenter(double x, double y)
          Sets the center of the map view.
 void setCoordinateDisplay(double x, double y)
          Sets the coordinate display and grid display fields.
 void setEverything(double centerX, double centerY, double scale, double rotation, int baselineMillis)
          Sets everything.
 void setEverything(java.lang.String legendName, double centerX, double centerY, double scale, double rotation, int baselineMillis)
          Sets everything.
 void setGroupVisibility(java.lang.String mapsetName, java.lang.String groupName, boolean visible)
           
 void setLegend(java.lang.String legendName)
          Sets the current legend, by name.
 void setMeasureDisplay(double x, double y)
           
 void setMeasureDisplay(java.lang.String whatnot)
           
 void setScale(double newScale)
          Sets the scale to a specific amount.
 void setZoom(int newZoom)
          Sets the current zoom (which also sets the scale).
 void sliderScale(double fraction)
          Sets the scale expressed as a fraction from 0.0 to 1.0.
 void updateLegendList()
           
 void zoom(double centerX, double centerY)
          Zooming by coordinates.
 void zoomIn()
          Zoom in (increase detail).
 int zoomNearest(double scale)
           
 void zoomOut()
          Zoom out (decrease detail).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MapViewLogic

public MapViewLogic(MapApp app)
Method Detail

initialize

protected void initialize()
Initializes the view from preferences.


setLegend

public void setLegend(java.lang.String legendName)
Sets the current legend, by name.


getLegend

public java.lang.String getLegend()

zoom

public void zoom(double centerX,
                 double centerY)
Zooming by coordinates. Zooms in and centers at the same time. pixel space so be aware that positive Y is down, not up.


setZoom

public void setZoom(int newZoom)
Sets the current zoom (which also sets the scale). Resets partial zoom to 50.


setCenter

public void setCenter(double x,
                      double y)
Sets the center of the map view.


ensureVisible

public void ensureVisible(double x,
                          double y)
Ensures that the given coordinate is visible. If not, it centers it on the screen.


setEverything

public void setEverything(double centerX,
                          double centerY,
                          double scale,
                          double rotation,
                          int baselineMillis)
Sets everything.


setEverything

public void setEverything(java.lang.String legendName,
                          double centerX,
                          double centerY,
                          double scale,
                          double rotation,
                          int baselineMillis)
Sets everything.


zoomNearest

public int zoomNearest(double scale)

getNearestZoomTo

public int getNearestZoomTo(double scale)

goHome

public void goHome()

setGroupVisibility

public void setGroupVisibility(java.lang.String mapsetName,
                               java.lang.String groupName,
                               boolean visible)

pan

public void pan(double deltaX,
                double deltaY)
Panning by map coordinates. Pans the view the amount given.


discreteZoom

public void discreteZoom(int count)
Base function for discrete zooming. Bumps you from the current fixed zoom to a different zoom based on the count - positive means finer detail zooms, negative means lower detail.


discretePan

public void discretePan(int countX,
                        int countY)
This is a base function for discrete panning. Increment is 1/3 view width. The counts are number of increments up or right; negative indicates down or left.


pixelPan

public void pixelPan(int startPixelX,
                     int startPixelY,
                     int endPixelX,
                     int endPixelY)
Panning by pixel. Counts are in pixel space so be aware that positive Y is down, not up.


pixelZoom

public void pixelZoom(int pixelsRight,
                      int pixelsDown)
Zooming by pixel. Counts are in pixel space so be aware that positive Y is down, not up.


pixelCenterOn

public void pixelCenterOn(int pixelX,
                          int pixelY)
Centers on a given pixel. The coordinate is in pixel space relative to the top left of the MapView; be aware that positive Y is down, not up.


incrementalZoom

public void incrementalZoom(double locusX,
                            double locusY,
                            int locusPixelX,
                            int locusPixelY,
                            int amount)
Incremental zoom.


incrementalZoom

public void incrementalZoom(int amount)

rotate

public void rotate(double theta)
Rotate a bit.


pixelRotate

public void pixelRotate(int startX,
                        int startY,
                        int endX,
                        int endY)

dragPan

public void dragPan(double buttonDownX,
                    double buttonDownY,
                    int buttonDownPixelX,
                    int buttonDownPixelY,
                    int startX,
                    int startY,
                    int endX,
                    int endY)

dragRotate

public void dragRotate(double buttonDownX,
                       double buttonDownY,
                       int buttonDownPixelX,
                       int buttonDownPixelY,
                       int startX,
                       int startY,
                       int endX,
                       int endY)

dragZoom

public void dragZoom(double buttonDownX,
                     double buttonDownY,
                     int buttonDownPixelX,
                     int buttonDownPixelY,
                     int startX,
                     int startY,
                     int endX,
                     int endY)

clearRotation

public void clearRotation()

setScale

public void setScale(double newScale)
Sets the scale to a specific amount. Zoom and partial zoom will be set as closely as possible.


dragStart

public void dragStart()
This is important to keep the undo from being annoyingly fine-grained. Call this method, then any number of drag methods, then call it again. See the usage in MapViewMouseHandler, which is what it's written for anyway. Remember to call dragStop() when you're done.


dragStop

public void dragStop()

setCoordinateDisplay

public void setCoordinateDisplay(double x,
                                 double y)
Sets the coordinate display and grid display fields.


setMeasureDisplay

public void setMeasureDisplay(double x,
                              double y)

setMeasureDisplay

public void setMeasureDisplay(java.lang.String whatnot)

panLeft

public void panLeft()
Convenience method for discrete panning left.


panRight

public void panRight()
Convenience method for discrete panning right.


panUp

public void panUp()
Convenience method for discrete panning up.


panDown

public void panDown()
Convenience method for discrete panning down.


panUpLeft

public void panUpLeft()
Up and left.


panDownLeft

public void panDownLeft()
Down and left.


panUpRight

public void panUpRight()
Up and right.


panDownRight

public void panDownRight()
Down and right.


zoomIn

public void zoomIn()
Zoom in (increase detail).


zoomOut

public void zoomOut()
Zoom out (decrease detail).


sliderScale

public void sliderScale(double fraction)
Sets the scale expressed as a fraction from 0.0 to 1.0. This is used by the scale slider control. Note, however, that the fraction does not represent a linear percentage scale, but rather one that is scale dependent, since zooming at lower scales should be more fine-grained than at higher scales. Currently the method used is logarithmic, but this cannot be depended upon.


updateLegendList

public void updateLegendList()

getState

public MapViewState getState()

addViewListener

public void addViewListener(MapViewListener listener)

removeViewListener

public void removeViewListener(MapViewListener listener)