com.partnersoft.v3x.apps.MapBrowser
Class RenderMold

java.lang.Object
  extended by com.partnersoft.v3x.apps.MapBrowser.RenderMold
All Implemented Interfaces:
java.io.Serializable

public class RenderMold
extends java.lang.Object
implements java.io.Serializable

A "mold" that controls the shape that map bits are rendered into.

Note well that the current implementation only deals with cartesian quadrant I (NE); i.e. that Y increases in the up or north direction and X increases in the right or east direction. When modifying the mold that has listeners (e.g. for a MapViewPanel) try to use only a single method call to modify the mold. Each method call only results in one ChangeEvent, cutting down on redraws etc. There are compound methods like rescaleAndRecenter() to help with this.

See Also:
Serialized Form

Constructor Summary
RenderMold()
           
RenderMold(Coord3D origin, int width, int height, Scale scale)
           
RenderMold(MapViewFrame frame)
           
 
Method Summary
 void addChangeListener(javax.swing.event.ChangeListener listener)
           
 void centerOn(Coord3D newCenter)
           
 void centerOn(double x, double y)
           
 void changeToMatch(RenderMold nother)
          Changes this rendermold to match the one given.
 java.lang.Object clone()
           
 boolean contains(int pixelX, int pixelY)
           
 Coord3D coordAt(int pixelX, int pixelY)
           
 Coord3D coordAt(java.awt.Point pixel)
           
 boolean covers(Coord3D coord)
           
 void fromMapViewFrame(MapViewFrame frame)
           
 Coord3D getCenter()
           
 java.lang.String getContent()
           
 MagicCookie getCookie()
          The serial cookie.
 Coord2D getDimensions()
           
 DoubleRectangle getExtents()
           
 int getHeight()
           
 boolean getInvertBackgroundColor()
           
 boolean getMonochromeBackground()
           
 Coord3D getNECorner()
           
 Coord3D getNWCorner()
           
 Coord3D getOrigin()
           
 DoubleRectangle getRotatedExtents()
           
 double getRotation()
           
 Scale getScale()
           
 Coord3D getSECorner()
           
 Coord3D getSWCorner()
          Purely for completeness; same as origin.
 int getWidth()
           
 boolean isPrinting()
           
 java.awt.Point pixelAt(Coord3D coord)
           
 void polylineToFastPath(FastPath path, int numPoints, FloatBuffer coords)
           
 void removeChangeListener(javax.swing.event.ChangeListener listener)
           
 void rescaleAndRecenter(Scale newScale, Coord3D newCenter)
          Another nice one.
 void rescaleButKeepCentered(Scale newScale)
          Another nice one.
 void resizeButKeepCentered(int newWidth, int newHeight)
          Here's a nice one.
 void rotateTo(double x, double y)
           
 void setContent(java.lang.String newContent)
           
 void setCoordToMatchPixel(Coord3D coord, int pixelX, int pixelY)
          Same as coordAt, but instead of creating a new one, reuses the supplied Coord3D for speed.
 void setHeight(int newHeight)
           
 void setInvertBackgroundColor(boolean newInvertBackgroundColor)
           
 void setMonochromeBackground(boolean newMonochromeBackground)
           
 void setOrigin(Coord3D newOrigin)
           
 void setPrinting(boolean newPrinting)
           
 void setRotation(double newRotation)
           
 void setScale(Scale newScale)
           
 void setWidth(int newWidth)
           
 RenderMold[][] tileByPixels(int tileWidth, int tileHeight)
           
 MapViewFrame toMapViewFrame()
           
 java.lang.String toString()
           
 int xToPixel(double x)
           
 int yToPixel(double y)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RenderMold

public RenderMold()

RenderMold

public RenderMold(Coord3D origin,
                  int width,
                  int height,
                  Scale scale)

RenderMold

public RenderMold(MapViewFrame frame)
Method Detail

xToPixel

public int xToPixel(double x)

yToPixel

public int yToPixel(double y)

pixelAt

public java.awt.Point pixelAt(Coord3D coord)

coordAt

public Coord3D coordAt(java.awt.Point pixel)

coordAt

public Coord3D coordAt(int pixelX,
                       int pixelY)

setCoordToMatchPixel

public void setCoordToMatchPixel(Coord3D coord,
                                 int pixelX,
                                 int pixelY)
Same as coordAt, but instead of creating a new one, reuses the supplied Coord3D for speed.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

covers

public boolean covers(Coord3D coord)

contains

public boolean contains(int pixelX,
                        int pixelY)

tileByPixels

public RenderMold[][] tileByPixels(int tileWidth,
                                   int tileHeight)

polylineToFastPath

public void polylineToFastPath(FastPath path,
                               int numPoints,
                               FloatBuffer coords)

getNWCorner

public Coord3D getNWCorner()

getNECorner

public Coord3D getNECorner()

getSECorner

public Coord3D getSECorner()

getSWCorner

public Coord3D getSWCorner()
Purely for completeness; same as origin.


getCenter

public Coord3D getCenter()

centerOn

public void centerOn(Coord3D newCenter)

centerOn

public void centerOn(double x,
                     double y)

rotateTo

public void rotateTo(double x,
                     double y)

resizeButKeepCentered

public void resizeButKeepCentered(int newWidth,
                                  int newHeight)
Here's a nice one. Resizes the mold without changing the center point Considered the "desired behavior" for stretching the map image. Also, only generates one ChangeEvent.


rescaleAndRecenter

public void rescaleAndRecenter(Scale newScale,
                               Coord3D newCenter)
Another nice one. Rescales the mold without changing the center point Considered the "desired behavior" for zooming the map image in. Also, only generates one ChangeEvent.


rescaleButKeepCentered

public void rescaleButKeepCentered(Scale newScale)
Another nice one. Rescales the mold without changing the center point Considered the "desired behavior" for zooming the map image out. Also, only generates one ChangeEvent.


getDimensions

public Coord2D getDimensions()

getExtents

public DoubleRectangle getExtents()

getRotatedExtents

public DoubleRectangle getRotatedExtents()

changeToMatch

public void changeToMatch(RenderMold nother)
Changes this rendermold to match the one given.


getCookie

public MagicCookie getCookie()
The serial cookie. Changes every time a property changes.


getOrigin

public Coord3D getOrigin()

setOrigin

public void setOrigin(Coord3D newOrigin)

getWidth

public int getWidth()

setWidth

public void setWidth(int newWidth)

getHeight

public int getHeight()

setHeight

public void setHeight(int newHeight)

getScale

public Scale getScale()

setScale

public void setScale(Scale newScale)

getContent

public java.lang.String getContent()

setContent

public void setContent(java.lang.String newContent)

getMonochromeBackground

public boolean getMonochromeBackground()

setMonochromeBackground

public void setMonochromeBackground(boolean newMonochromeBackground)

isPrinting

public boolean isPrinting()

setPrinting

public void setPrinting(boolean newPrinting)

getInvertBackgroundColor

public boolean getInvertBackgroundColor()

setInvertBackgroundColor

public void setInvertBackgroundColor(boolean newInvertBackgroundColor)

getRotation

public double getRotation()

setRotation

public void setRotation(double newRotation)

fromMapViewFrame

public void fromMapViewFrame(MapViewFrame frame)

addChangeListener

public void addChangeListener(javax.swing.event.ChangeListener listener)

removeChangeListener

public void removeChangeListener(javax.swing.event.ChangeListener listener)

toMapViewFrame

public MapViewFrame toMapViewFrame()