es.prodevelop.gvsig.mobile.fmap.viewport
Class ViewPort

java.lang.Object
  extended byes.prodevelop.gvsig.mobile.fmap.viewport.ViewPort
All Implemented Interfaces:
Persistible

public class ViewPort
extends java.lang.Object
implements Persistible

Clase con atributos de la vista. 050211, jmorell: Añado los Grados como unidad de mapa.

Author:
Vicente Caballero Navarro

Field Summary
static double ARROW_KEYS_FACTOR
           
static int CENTIMETRO
           
static int GRADOS
           
static int KILOMETROS
           
static int METROS
           
static int MILIMETRO
           
static int MILLAS
           
static int PIES
           
static int PULGADAS
           
static int YARDAS
           
 
Constructor Summary
ViewPort(IProjection p)
          Crea un nuevo ViewPort.
 
Method Summary
 boolean addViewPortListener(ViewPortListener arg0)
          Añade un ViewPortListener al extentListener.
 int fromMapDistance(double d)
          Devuelve la distancia en pixels a partir de una distancia real.
 java.awt.geom.Point2D fromMapPoint(double x, double y)
          Devuelve un punto en pixels a partir de una coordenada X e Y real.
 java.awt.geom.Point2D fromMapPoint(java.awt.geom.Point2D point)
          Devuelve el punto en pixels a partir de un punto real.
 java.awt.geom.Rectangle2D fromMapRectangle(java.awt.geom.Rectangle2D r)
           
 java.awt.geom.Rectangle2D getAdjustedExtent()
          Returns the extent currently covered by the view.
 java.awt.geom.AffineTransform getAffineTransform()
          Devuelve la matriz de transformación.
 java.util.HashMap getAttributeValues(java.lang.reflect.Field[] attributes, java.lang.Object obj)
           
 java.awt.Color getBackColor()
          Devuelve el color de fondo.
 double getDist1pixel()
          Devuelve la distancia real de un pixel.
 double getDist3pixel()
          Devuelve la distancia real de tres pixel.
 int getDistanceUnits()
          Devuelve la unidad de medida en la que queremos realizar nuestras mediciones y en la que se nos mostrará toda la información.
 java.awt.geom.Rectangle2D getExtent()
           When the zoom changes (for instance when using the zoom in or zoom out tools, but also zooming to a selected feature or shape) the extent that covers that area is the value returned by this method.
 ExtentHistory getExtents()
          Devuelve los Extents anteriores almacenados.
 int getImageHeight()
          Devuelve la altura de la imagen.
 java.awt.Dimension getImageSize()
          Devuelve las dimensiones de la imagen.
 int getImageWidth()
          Devuelve la anchura de la imagen.
 int getMapUnits()
          Devuelve la unidad de medida del mapa, es la unidad de medida en la que está la cartográfia que cargamos, normalmente en metros.
 java.awt.geom.Point2D getOffset()
          The offset is the position where to start drawing.
 IProjection getProjection()
          Devuelve la proyección.
 double getScale()
          Devuelve la escala.
 boolean hasNextExtent()
           
 boolean hasPreviousExtent()
           
 boolean moveExtent(double x, double y, boolean repaint)
           
 void refreshExtent(boolean repaint)
          Refresca el extent.
 boolean removeViewPortListener(ViewPortListener arg0)
          Borra el ViewPortListener que se pasa como parámetro delos extentListener.
 boolean scaleExtent(double d, boolean repaint)
           
 void setAdjustable(boolean adjustable)
          Sets the adjustable option, so the extent is automatically adjusted to view aspect.
 void setAffineTransform(java.awt.geom.AffineTransform at)
          Método que solo lo utilizamos a la hora de imprimir.
 void setDist1pixel(double dist1pixel)
          Inserta la distancia real de un pixel.
 void setDist3pixel(double dist3pixel)
          Inserta la distancia real de tres pixels.
 void setDistanceUnits(int distanceUnits)
          Inserta la unidad de medida en la que queremos realizar nuestras mediciones y en la que se nos mostrará toda la información.
 void setExtent(java.awt.geom.Rectangle2D r, boolean repaint)
          Inserta el extent.
 void setImageSize(java.awt.Dimension imageSize)
          Inserta las dimensiones de la imagen.
 void setMapUnits(int mapUnits)
          Inserta la unidad de medida del mapa, es la unidad de medida en la que está la cartográfia que cargamos, normalmente en metros.
 void setNextExtent()
          Rellena el extent siguiente como actual.
 void setOffset(java.awt.geom.Point2D p)
          Inserta la desviación.
 void setPreviousExtent()
          Rellena el extent anterior como actual.
 void setProjection(IProjection proj)
          Inserta la proyección.
 double toMapDistance(int d)
          Devuelve la distancia real a partir de la distancia en pixels.
 java.awt.geom.Point2D toMapPoint(int x, int y)
          Devuelve un punto real a partir de una coordenada X e Y en pixels.
 java.awt.geom.Point2D toMapPoint(java.awt.geom.Point2D pScreen)
          Devuelve un punto real a partir de un punto en pixels.
 java.awt.geom.Rectangle2D toMapRectangle(java.awt.geom.Rectangle2D r)
           
 java.lang.String toString()
          Devuelve el String con datos del ViewPort.
 java.lang.StringBuffer toXML(java.lang.String name)
          Gets a description of this object as a XML string
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ARROW_KEYS_FACTOR

public static final double ARROW_KEYS_FACTOR
See Also:
Constant Field Values

KILOMETROS

public static int KILOMETROS

METROS

public static int METROS

CENTIMETRO

public static int CENTIMETRO

MILIMETRO

public static int MILIMETRO

MILLAS

public static int MILLAS

YARDAS

public static int YARDAS

PIES

public static int PIES

PULGADAS

public static int PULGADAS

GRADOS

public static int GRADOS
Constructor Detail

ViewPort

public ViewPort(IProjection p)
Crea un nuevo ViewPort.

Parameters:
p - Proyección.
Method Detail

setAdjustable

public void setAdjustable(boolean adjustable)
Sets the adjustable option, so the extent is automatically adjusted to view aspect.

Parameters:
adjustable - boolean Adjustable.

addViewPortListener

public boolean addViewPortListener(ViewPortListener arg0)
Añade un ViewPortListener al extentListener.

Parameters:
arg0 - ViewPortListener.
Returns:
True si ha sido añadida correctamente.

removeViewPortListener

public boolean removeViewPortListener(ViewPortListener arg0)
Borra el ViewPortListener que se pasa como parámetro delos extentListener.

Parameters:
arg0 - ViewPortListener.
Returns:
True si ha sido borrado correctamente.

fromMapDistance

public int fromMapDistance(double d)
Devuelve la distancia en pixels a partir de una distancia real.

Parameters:
d - Distancia real.
Returns:
Distancia en pixels.

fromMapPoint

public java.awt.geom.Point2D fromMapPoint(double x,
                                          double y)
Devuelve un punto en pixels a partir de una coordenada X e Y real.

Parameters:
x - Coordenada X real.
y - Coordenada Y real.
Returns:
Punto en pixels.

fromMapPoint

public java.awt.geom.Point2D fromMapPoint(java.awt.geom.Point2D point)
Devuelve el punto en pixels a partir de un punto real.

Parameters:
point - Punto real.
Returns:
Punto en pixels.

toMapPoint

public java.awt.geom.Point2D toMapPoint(int x,
                                        int y)
Devuelve un punto real a partir de una coordenada X e Y en pixels.

Parameters:
x - Coordenada X en pixels.
y - Coordenada Y en pixels.
Returns:
Punto real.

toMapRectangle

public java.awt.geom.Rectangle2D toMapRectangle(java.awt.geom.Rectangle2D r)

toMapDistance

public double toMapDistance(int d)
Devuelve la distancia real a partir de la distancia en pixels.

Parameters:
d - Distancia en pixels.
Returns:
Distancia real.

toMapPoint

public java.awt.geom.Point2D toMapPoint(java.awt.geom.Point2D pScreen)
Devuelve un punto real a partir de un punto en pixels.

Parameters:
pScreen - Punto en pixels.
Returns:
Punto real.
Throws:
java.lang.RuntimeException

setPreviousExtent

public void setPreviousExtent()
Rellena el extent anterior como actual.


setNextExtent

public void setNextExtent()
Rellena el extent siguiente como actual.


hasNextExtent

public boolean hasNextExtent()

hasPreviousExtent

public boolean hasPreviousExtent()

getExtent

public java.awt.geom.Rectangle2D getExtent()

When the zoom changes (for instance when using the zoom in or zoom out tools, but also zooming to a selected feature or shape) the extent that covers that area is the value returned by this method. It is not the actual area shown in the view because it does not care about the aspect ratio. However, any part of the real world contained in this extent is shown in the view.

Probably this is not what you are looking for. If you are looking for the complete extent currently shown, you must use getAdjustedExtent() method which returns the extent that contains this one but regarding the current view's aspect ratio.

Returns:
Extent.

setExtent

public void setExtent(java.awt.geom.Rectangle2D r,
                      boolean repaint)
Inserta el extent.

Parameters:
r - Extent.

refreshExtent

public void refreshExtent(boolean repaint)
Refresca el extent.


getScale

public double getScale()
Devuelve la escala. Debe estar siempre actualizada y no calcularse nunca aquí pues se utiliza en el dibujado para cada geometría

Returns:
Escala.

getAffineTransform

public java.awt.geom.AffineTransform getAffineTransform()
Devuelve la matriz de transformación.

Returns:
Matriz de transformación.

getImageSize

public java.awt.Dimension getImageSize()
Devuelve las dimensiones de la imagen.

Returns:
Returns the imageSize.

setImageSize

public void setImageSize(java.awt.Dimension imageSize)
Inserta las dimensiones de la imagen.

Parameters:
imageSize - The imageSize to set.

setOffset

public void setOffset(java.awt.geom.Point2D p)
Inserta la desviación.

Parameters:
p - Punto.

getOffset

public java.awt.geom.Point2D getOffset()
The offset is the position where to start drawing. The offset of a View is always (0, 0) because the drawing area fits with the full window area. But in a Layout it is up to the place where the FFrameView is located.


getBackColor

public java.awt.Color getBackColor()
Devuelve el color de fondo.

Returns:
Color de fondo.

getAdjustedExtent

public java.awt.geom.Rectangle2D getAdjustedExtent()
Returns the extent currently covered by the view.

Returns:
Returns the adjustedExtent.

getDistanceUnits

public int getDistanceUnits()
Devuelve la unidad de medida en la que queremos realizar nuestras mediciones y en la que se nos mostrará toda la información.

Returns:
Returns the distanceUnits.

setDistanceUnits

public void setDistanceUnits(int distanceUnits)
Inserta la unidad de medida en la que queremos realizar nuestras mediciones y en la que se nos mostrará toda la información.

Parameters:
distanceUnits - The distanceUnits to set.

getMapUnits

public int getMapUnits()
Devuelve la unidad de medida del mapa, es la unidad de medida en la que está la cartográfia que cargamos, normalmente en metros.

Returns:
Returns the mapUnits.

setMapUnits

public void setMapUnits(int mapUnits)
Inserta la unidad de medida del mapa, es la unidad de medida en la que está la cartográfia que cargamos, normalmente en metros.

Parameters:
mapUnits - The mapUnits to set.

getImageWidth

public int getImageWidth()
Devuelve la anchura de la imagen.

Returns:
anchura en pixels de la imagen.

getImageHeight

public int getImageHeight()
Devuelve la altura de la imagen.

Returns:
altura de la imagen.

getDist1pixel

public double getDist1pixel()
Devuelve la distancia real de un pixel.

Returns:
Distancia real de un pixel.

setDist1pixel

public void setDist1pixel(double dist1pixel)
Inserta la distancia real de un pixel.

Parameters:
dist1pixel - Distancia real de un pixel.

getDist3pixel

public double getDist3pixel()
Devuelve la distancia real de tres pixel.

Returns:
Distancia real de tres pixel.

setDist3pixel

public void setDist3pixel(double dist3pixel)
Inserta la distancia real de tres pixels.

Parameters:
dist3pixel - Distancia real de tres pixels.

getExtents

public ExtentHistory getExtents()
Devuelve los Extents anteriores almacenados.

Returns:
Returns the extents.

getProjection

public IProjection getProjection()
Devuelve la proyección.

Returns:
Returns the proj.

setProjection

public void setProjection(IProjection proj)
Inserta la proyección.

Parameters:
proj - The proj to set.

setAffineTransform

public void setAffineTransform(java.awt.geom.AffineTransform at)
Método que solo lo utilizamos a la hora de imprimir. NO lanza un calculateAffineTransform, ni recalcula el adjustedExtent. TODO: Para evitar este método, habría que redefinir el interfaz RasterAdapter, y que recibiera un ViewPortData.

Parameters:
at -

toString

public java.lang.String toString()
Devuelve el String con datos del ViewPort.

Returns:
Cadena con datos del ViewPort.

fromMapRectangle

public java.awt.geom.Rectangle2D fromMapRectangle(java.awt.geom.Rectangle2D r)

scaleExtent

public boolean scaleExtent(double d,
                           boolean repaint)

getAttributeValues

public java.util.HashMap getAttributeValues(java.lang.reflect.Field[] attributes,
                                            java.lang.Object obj)

toXML

public java.lang.StringBuffer toXML(java.lang.String name)
Description copied from interface: Persistible
Gets a description of this object as a XML string

Specified by:
toXML in interface Persistible
Parameters:
name - name of the main element
Returns:
a description of this object as a XML string

moveExtent

public boolean moveExtent(double x,
                          double y,
                          boolean repaint)