com.xj.anylogic.engine.presentation
Class ShapeGISMap

java.lang.Object
  extended by com.xj.anylogic.engine.presentation.Shape
      extended by com.xj.anylogic.engine.AbstractShapeGISMap
          extended by com.xj.anylogic.engine.presentation.ShapeGISMap
All Implemented Interfaces:
com.xj.anylogic.engine.internal.Child, Locatable2D, java.io.Serializable, java.lang.Cloneable

public class ShapeGISMap
extends AbstractShapeGISMap

GIS map projection manager and map renderer (persistent GIS Map shape which displays and map projection)
GIS map is a Shape and it can be placed on the model animation: it renders the associated map projection on the screen
This class provides several projection methods

General information:
Coordinates of any point are presented as:

The following order of coordinates is assumed: (longitude, latitude), uniformly with (x, y)
Implementation is based on OpenMap GIS

This object is only available in the AnyLogic Professional

Author:
XJ Technologies Company Ltd. www.anylogic.com
See Also:
Serialized Form

Nested Class Summary
static class ShapeGISMap.Layer
          Class which stores GIS map layer information
 
Field Summary
 
Fields inherited from class com.xj.anylogic.engine.presentation.Shape
UNKNOWN_NAME
 
Constructor Summary
ShapeGISMap(Presentable presentable, boolean ispublic, double x, double y, double width, double height, java.lang.String packagePrefix, ShapeGISMap.Layer[] layers, double centerLongitude, double centerLatitude, double mapScale, java.awt.Color mapBorderColor, java.awt.Color mapBackgroundColor)
          Constructs a GIS Map shape with specific attributes.
 
Method Summary
 boolean contains(double px, double py)
          Test if the shape contains the point with the given coordinates (relative to this shape's container, i.e. in the same system with the coordinates of this shape, x and y)
 double convertRotationAngleForward(double longitude, double latitude, double angle)
          Creates forward projection of the given rotation angle (direction) at the given point, to screen and returns rotation angle in screen coordinates
 double convertXForward(double longitude, double latitude)
          Creates forward projection of the given point to screen and returns x-coordinate
 double convertYForward(double longitude, double latitude)
          Creates forward projection of the given point to screen and returns y-coordinate
 float[] createTrajectory(double lonFrom, double latFrom, double lonTo, double latTo)
          Creates shortest path between two given points and returns it as polyline with N (=512) segments, as array of length 2(N+1)
First number in array is always 0, next numbers are (lon, lat)-pairs of polyline nodes, including beginning and end
This method is not designed to be called by user
 void destroy()
           
 void draw(Panel panel, java.awt.Graphics2D g, java.awt.geom.AffineTransform xform, boolean publicOnly)
          Draws the shape in a given context
 double getCenterLatitude()
          Returns the latitude of the map projection center, measured in degrees (-90 ...
 double getCenterLongitude()
          Returns the longitude of the map projection center, measured in degrees (-180 ...
 double getDistance(double lonFrom, double latFrom, double lonTo, double latTo)
          Returns distance, in meters, between 2 given points
 double getHeight()
          Returns the height of the shape.
 ShapeGISMap.Layer[] getLayers()
          Returns the array of layers used in this GIS Map
Returned array shouldn't be modified structurally: only items can be accessed for modification
 double getMapScale()
          Returns the scale of map projection
 double getMaxMapScale()
          Returns the maximum available scale of the map projection
 double getMinMapScale()
          Returns the minimum available scale of the map projection
 Presentable getPresentable()
          Returns the Presentable object (ActiveObject or Experiment) where this shape belongs to, or null.
 double getWidth()
          Returns the width of the shape.
 boolean onClickAt(double px, double py, boolean publicOnly)
          Tests if the GIS map contains the point with the given coordinates and, if yes, executes the reaction on click at that point.
 void pan(int toEast, int toNorth)
          Moves the map projection center
Parameters are amounts of delta in the resulting offset
One horizontal delta is a half of longitude difference from map projection center to the west/east bound of projection
One vertical delta is a half of latitude difference from map projection center to the south/north bound of projection
 boolean projectionContains(double longitude, double latitude)
          Returns true if the projection of the given point to screen is visible on this map
 void requestRedraw()
          Schedules projection recreation and map image rendering to the next animation update
 void restoreOwner(java.lang.Object owner)
          This method normally should not be called by user
This method restores owner of this object
The method is used in snapshot saving/loading
 void setCenterLatitude(double centerLatitude)
          Sets the latitude of the map projection center, measured in degrees (-90 ...
 void setCenterLongitude(double centerLongitude)
          Sets the longitude of the map projection center, measured in degrees (-180 ...
 void setHeight(double height)
          Sets the height of the shape.
 void setMapScale(double mapScale)
          Sets the scale of map projection
 void setProjectionCenter(double centerLongitude, double centerLatitude)
          Sets the center of the map projection
 void setWidth(double width)
          Sets the width of the shape.
 void zoomIn()
          Increases scale of map projection (x 2)
 void zoomOut()
          Decreases scale of map projection (x 1/2)
 
Methods inherited from class com.xj.anylogic.engine.AbstractShapeGISMap
clone, formatMapScale, onClick
 
Methods inherited from class com.xj.anylogic.engine.presentation.Shape
canHandleClick, getGroup, getName, getRotation, getScaleX, getScaleY, getX, getY, isVisible, setPos, setRotation, setScale, setScale, setScaleX, setScaleY, setVisible, setX, setY
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ShapeGISMap

public ShapeGISMap(Presentable presentable,
                   boolean ispublic,
                   double x,
                   double y,
                   double width,
                   double height,
                   java.lang.String packagePrefix,
                   ShapeGISMap.Layer[] layers,
                   double centerLongitude,
                   double centerLatitude,
                   double mapScale,
                   java.awt.Color mapBorderColor,
                   java.awt.Color mapBackgroundColor)
Constructs a GIS Map shape with specific attributes.

Parameters:
presentable - the presentable object owning this shape
ispublic - if true, the shape is visible on container's presentation
x - the x coordinate of the shape upper left corner
y - the y coordinate of the shape upper left corner
width - the width of the shape
height - the height of the shape
packagePrefix - the package name of original active object where this image is defined, formatted using '/' characters; with '/' character at the beginning and at the end
layers - the array of ShapeGISMap.Layer objects to be used and drawn
centerLongitude - the longitude of the map projection center, measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)
centerLatitude - the latitude of the map projection center, measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)
mapScale - the scale (ratio between meters on the screen and meters on the Earth surface), e.g. 1/100000 means "1 km in 1 cm"
Method Detail

setWidth

public void setWidth(double width)
Sets the width of the shape.

Parameters:
width - the width of the shape

getWidth

public double getWidth()
Returns the width of the shape.

Returns:
the width of the shape

setHeight

public void setHeight(double height)
Sets the height of the shape.

Parameters:
height - the height of the shape

getHeight

public double getHeight()
Returns the height of the shape.

Returns:
the height of the shape

onClickAt

public boolean onClickAt(double px,
                         double py,
                         boolean publicOnly)
Tests if the GIS map contains the point with the given coordinates and, if yes, executes the reaction on click at that point.

Overrides:
onClickAt in class Shape
Parameters:
px - the x coordinate of the click
py - the y coordinate of the click
publicOnly - if true, not public shape returns false
Returns:
true if the click has been handled AND further click processing is not needed, false otherwise

contains

public boolean contains(double px,
                        double py)
Description copied from class: Shape
Test if the shape contains the point with the given coordinates (relative to this shape's container, i.e. in the same system with the coordinates of this shape, x and y)

Specified by:
contains in class Shape
Parameters:
px - the x coordinate relative to this shape's container
py - the y coordinate relative to this shape's container
Returns:
true if the shape contains the point with the given coordinates

draw

public void draw(Panel panel,
                 java.awt.Graphics2D g,
                 java.awt.geom.AffineTransform xform,
                 boolean publicOnly)
Description copied from class: Shape
Draws the shape in a given context

Specified by:
draw in class Shape
Parameters:
panel - the panel where the drawing is done
g - the graphics where the drawing takes place
xform - the "original" transform that must be restored before drawing
publicOnly - if true, the shape is only drawn if it is public

getMapScale

public double getMapScale()
Description copied from class: AbstractShapeGISMap
Returns the scale of map projection

Specified by:
getMapScale in class AbstractShapeGISMap
Returns:
the scale (ratio between meters on the screen and meters on the Earth surface), e.g. 1/100000 means "1 km in 1 cm"

setMapScale

public void setMapScale(double mapScale)
Description copied from class: AbstractShapeGISMap
Sets the scale of map projection

Specified by:
setMapScale in class AbstractShapeGISMap
Parameters:
mapScale - the scale (ratio between meters on the screen and meters on the Earth surface), e.g. 1/100000 means "1 km in 1 cm"

getMinMapScale

public double getMinMapScale()
Description copied from class: AbstractShapeGISMap
Returns the minimum available scale of the map projection

Specified by:
getMinMapScale in class AbstractShapeGISMap
Returns:
the minimum available scale (ratio between meters on the screen and meters on the Earth surface), e.g. 1/100000 means "1 km in 1 cm"

getMaxMapScale

public double getMaxMapScale()
Description copied from class: AbstractShapeGISMap
Returns the maximum available scale of the map projection

Specified by:
getMaxMapScale in class AbstractShapeGISMap
Returns:
the maximum available scale (ratio between meters on the screen and meters on the Earth surface), e.g. 1/100000 means "1 km in 1 cm"

zoomIn

public void zoomIn()
Description copied from class: AbstractShapeGISMap
Increases scale of map projection (x 2)

Specified by:
zoomIn in class AbstractShapeGISMap

zoomOut

public void zoomOut()
Description copied from class: AbstractShapeGISMap
Decreases scale of map projection (x 1/2)

Specified by:
zoomOut in class AbstractShapeGISMap

pan

public void pan(int toEast,
                int toNorth)
Description copied from class: AbstractShapeGISMap
Moves the map projection center
Parameters are amounts of delta in the resulting offset
One horizontal delta is a half of longitude difference from map projection center to the west/east bound of projection
One vertical delta is a half of latitude difference from map projection center to the south/north bound of projection

Specified by:
pan in class AbstractShapeGISMap
Parameters:
toEast - number of horizontal deltas to be added to the projection center, if positive, center is moved to the East, if negative - to the West
toNorth - number of vertical deltas to be added to the projection center, if positive, center is moved to the North, if negative - to the South

getCenterLatitude

public double getCenterLatitude()
Description copied from class: AbstractShapeGISMap
Returns the latitude of the map projection center, measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)

Specified by:
getCenterLatitude in class AbstractShapeGISMap
Returns:
the latitude of the map projection center, measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)

getCenterLongitude

public double getCenterLongitude()
Description copied from class: AbstractShapeGISMap
Returns the longitude of the map projection center, measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)

Specified by:
getCenterLongitude in class AbstractShapeGISMap
Returns:
the longitude of the map projection center, measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)

setProjectionCenter

public void setProjectionCenter(double centerLongitude,
                                double centerLatitude)
Description copied from class: AbstractShapeGISMap
Sets the center of the map projection

Overrides:
setProjectionCenter in class AbstractShapeGISMap
Parameters:
centerLongitude - new longitude of the map projection center, measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)
centerLatitude - new latitude of the map projection center, measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)

setCenterLatitude

public void setCenterLatitude(double centerLatitude)
Description copied from class: AbstractShapeGISMap
Sets the latitude of the map projection center, measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)

Specified by:
setCenterLatitude in class AbstractShapeGISMap
Parameters:
centerLatitude - new latitude of the map projection center, measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)

setCenterLongitude

public void setCenterLongitude(double centerLongitude)
Description copied from class: AbstractShapeGISMap
Sets the longitude of the map projection center, measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)

Specified by:
setCenterLongitude in class AbstractShapeGISMap
Parameters:
centerLongitude - new longitude of the map projection center, measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)

convertXForward

public double convertXForward(double longitude,
                              double latitude)
Description copied from class: AbstractShapeGISMap
Creates forward projection of the given point to screen and returns x-coordinate

Specified by:
convertXForward in class AbstractShapeGISMap
Parameters:
longitude - the longitude of point, measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)
latitude - the latitude of point, measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)
Returns:
the x coordinate of screen-projection of the given point

convertYForward

public double convertYForward(double longitude,
                              double latitude)
Description copied from class: AbstractShapeGISMap
Creates forward projection of the given point to screen and returns y-coordinate

Specified by:
convertYForward in class AbstractShapeGISMap
Parameters:
longitude - the longitude of point, measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)
latitude - the latitude of point, measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)
Returns:
the y coordinate of screen-projection of the given point

convertRotationAngleForward

public double convertRotationAngleForward(double longitude,
                                          double latitude,
                                          double angle)
Description copied from class: AbstractShapeGISMap
Creates forward projection of the given rotation angle (direction) at the given point, to screen and returns rotation angle in screen coordinates

Specified by:
convertRotationAngleForward in class AbstractShapeGISMap
Parameters:
longitude - the longitude of point, measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)
latitude - the latitude of point, measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)
angle - the rotation angle measured in radians from East CCW (0 is East direction, PI/2 is North direction, etc.)
Returns:
the rotation angle measured in radians from model animation point (1, 0) CW around (0, 0) point (as Y-axis is directed downwards)

projectionContains

public boolean projectionContains(double longitude,
                                  double latitude)
Description copied from class: AbstractShapeGISMap
Returns true if the projection of the given point to screen is visible on this map

Specified by:
projectionContains in class AbstractShapeGISMap
Parameters:
longitude - the longitude of point, measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)
latitude - the latitude of point, measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)
Returns:
true if the projection of the given point to screen is visible on this map

createTrajectory

public float[] createTrajectory(double lonFrom,
                                double latFrom,
                                double lonTo,
                                double latTo)
Description copied from class: AbstractShapeGISMap
Creates shortest path between two given points and returns it as polyline with N (=512) segments, as array of length 2(N+1)
First number in array is always 0, next numbers are (lon, lat)-pairs of polyline nodes, including beginning and end
This method is not designed to be called by user

Parameters:
lonFrom - the longitude of the start point, measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)
latFrom - the latitude of the start point, measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)
lonTo - the longitude of the end point, measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)
latTo - the latitude of the end point, measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)
Returns:
array with the lon, lat pairs in degrees, including given ends

getDistance

public double getDistance(double lonFrom,
                          double latFrom,
                          double lonTo,
                          double latTo)
Description copied from class: AbstractShapeGISMap
Returns distance, in meters, between 2 given points

Specified by:
getDistance in class AbstractShapeGISMap
Parameters:
lonFrom - the longitude of the 1st point, measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)
latFrom - the latitude of the 1st point, measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)
lonTo - the longitude of the 2nd point, measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)
latTo - the latitude of the 2nd point, measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)
Returns:
the distance, in meters, between 2 given points

getLayers

public ShapeGISMap.Layer[] getLayers()
Returns the array of layers used in this GIS Map
Returned array shouldn't be modified structurally: only items can be accessed for modification

Returns:
the array of layers used in this GIS Map

requestRedraw

public void requestRedraw()
Schedules projection recreation and map image rendering to the next animation update


destroy

public void destroy()

getPresentable

public Presentable getPresentable()
Description copied from class: Shape
Returns the Presentable object (ActiveObject or Experiment) where this shape belongs to, or null.

Overrides:
getPresentable in class Shape
Returns:
the Presentable that owns this shape, or null

restoreOwner

public void restoreOwner(java.lang.Object owner)
Description copied from class: Shape
This method normally should not be called by user
This method restores owner of this object
The method is used in snapshot saving/loading

Specified by:
restoreOwner in interface com.xj.anylogic.engine.internal.Child
Overrides:
restoreOwner in class Shape
Parameters:
owner - owner of this object, usually ActiveObject, Experiment or ShapeGroup


Copyright © 1991-2008 XJ Technlogies. All Rights Reserved.