public class IlvMapRenderer extends IlvFilterSDMRenderer
IlvMapRenderer
is a filtering renderer that displays a
background map behind the nodes and the links of the grapher.
The map is specified as the URL of a Perforce JViews .ivl
file
that will be loaded into the grapher associated with the SDM engine. This
.ivl
file can contain a vectorial map, one or more bitmaps, or
the definition of one or more "load-on-demand" layers that will load the map
according to the visible part of the grapher.
The map renderer can be initialized very simply in the style sheet using a declaration like:
SDM { Map : "maps/world.ivl"; }
The map file must contain the projection information corresponding to the
map. The projection will be used by the renderer to place the SDM nodes
automatically at the correct location depending on the values of their
"latitude"
and "longitude"
properties.
The "latitude"
and "longitude"
properties can be
defined directly in the SDM data model, or they can be defined in the style
sheet. For example, if the nodes of your data model have properties named
"LAT"
and "LONG"
instead of "latitude"
and "longitude"
, you must add the following declarations in the
style sheet:
node { latitude : "@LAT"; longitude : "@LONG"; }
The latitude and longitude can be specified in several formats:
xxDxx'xx"L
, where L
is
one of the following: N
, S
, E
or
W
. The string will be converted using the method
IlvProjectionUtil.DMSToRadian(java.lang.String)
.
addLatitudeLongitudeFormat(java.lang.String, boolean)
.
For example:
<node id="Quebec"> <property name="name">Quebec</property> <property name="longitude">70D59'W</property> <property name="latitude">46D49'N</property> </node>
Or:
<node id="Quebec"> <property name="name">Quebec</property> <property name="longitude">-1.2389</property> <property name="latitude">0.8171</property> </node>
Modifier and Type | Field and Description |
---|---|
static String |
LATITUDE_PROPERTY
LATITUDE_PROPERTY is the name used for the latitude property. |
static String |
LONGITUDE_PROPERTY
LONGITUDE_PROPERTY is the name used for the longitude
property. |
static String |
X_PROPERTY
X_PROPERTY is the name used for the x property, i.e. the x
coordinate of the symbol on the grapher, in the KERNEL system. |
static String |
Y_PROPERTY
Y_PROPERTY is the name used for the y property, i.e. the y
coordinate of the symbol on the grapher, in the KERNEL system. |
_renderer
PSEUDOCLASS_PREFIX
Constructor and Description |
---|
IlvMapRenderer()
Creates a new symbol renderer with a
null filtered renderer. |
IlvMapRenderer(IlvSDMRenderer renderer)
Creates a new symbol renderer for a specified filtered renderer.
|
Modifier and Type | Method and Description |
---|---|
static void |
addLatitudeLongitudeFormat(String format,
boolean latitude)
Registers a new format for converting strings to latitudes or longitudes.
|
IlvRect |
computeBBox(IlvSDMEngine engine,
IlvManagerView view,
IlvTransformer t)
This method calls the filtered renderer's
computeBBox method. |
static double |
convertLatLong(Object value,
boolean latitude)
Utility to convert an SDM value to either a latitude or longitude.
|
IlvGraphic |
createLinkGraphic(IlvSDMEngine engine,
Object link,
IlvGraphic from,
IlvGraphic to)
This method simply calls the
createLinkGraphic method
of the filtered renderer. |
IlvGraphic |
createNodeGraphic(IlvSDMEngine engine,
Object node)
This method simply calls the
createNodeGraphic method
of the filtered renderer. |
Object |
getGraphicProperty(IlvSDMEngine engine,
Object object,
String property,
String[] pseudoClass,
Class targetClass)
This method is overridden to handle requests for the
"x" and
"y" properties. |
static IlvMapRenderer |
getInstance(IlvSDMEngine engine)
Convenient function to get the IlvMapRenderer instance which belongs to the
specified SDM engine.
|
String |
getMap()
Returns the name of the map file displayed.
|
String |
getParameter()
This method calls
getMap() . |
IlvRect |
getRegionOfInterest()
Returns the "region of interest" on which the SDM view should be centered.
|
double |
getRegionOfInterestMargin()
Returns the margin that is left around the objects when the region of
interest is computed automatically.
|
boolean |
isAutoRegionOfInterest()
Indicates whether the automatic computation of the region of interest is
enabled.
|
boolean |
isFitToContentsAllowed()
Returns whether fitToContent() is performed during PrepareRendering()
processing.
|
boolean |
isHideInvalidNodesAndLinks()
Indicates whether or not nodes that are not within the limits tolerated by
the map projection will be hidden.
|
boolean |
isUsingThreads()
Indicates whether the map read should use threads to load images and/or map
data sources.
|
void |
prepareRendering(IlvSDMEngine engine)
Loads the map file into the grapher associated with the SDM engine.
|
void |
propertiesChanged(IlvSDMEngine engine,
Object object,
Collection<String> propertyNames,
IlvGraphic graphic)
Overridden methods for performance improvements.
|
void |
removeAll(IlvSDMEngine engine)
Removes all the layers contained in the map file.
|
void |
setAutoRegionOfInterest(boolean auto)
Enables or disables the automatic computation of the region of interest
from the position of the objects contained in the SDM data model.
|
void |
setEngine(IlvSDMEngine engine)
Sets the
IlvSDMEngine instance that has created
this renderer. |
void |
setFitToContentsAllowed(boolean activated)
If true, PrepareRendering() performs a fitToContents().
|
void |
setHideInvalidNodesAndLinks(boolean hideInvalidNodesAndLinks)
Indicates whether or not nodes that are not within the limits tolerated by
the map projection will be hidden.
|
void |
setMap(String map)
Sets the name of the map file to display.
|
void |
setParameter(String parameter)
This method calls
setMap(java.lang.String) . |
void |
setRegionOfInterest(IlvRect regionOfInterest)
Sets the "region of interest" on which the SDM view should be centered and
zoomed.
|
void |
setRegionOfInterestMargin(double percent)
Sets the margin that is left around the objects when the region of interest
is computed automatically.
|
void |
setUsingThreads(boolean usingThreads)
Determines whether the map read should use threads to load images and/or
map data sources.
|
void |
updateObjectProperties(IlvSDMEngine engine,
Object object,
String property,
Object value,
String[] pseudoClasses)
This method updates the latitude and longitude properties of an object when
its corresponding graphic object has been moved in the grapher.
|
addLinkGraphic, addNodeGraphic, customize, getEncapsulatedGraphic, getFilteredRenderer, getLinkConnectionRectangle, linkGraphicAdded, moveResizeNodeGraphic, nodeGraphicAdded, nodeGraphicBBoxChanged, processServerAction, removeLinkGraphic, removeNodeGraphic, renderingDone, setFilteredRenderer
addViewListeners, callMoveResizeNodeGraphic, convert, convert, getAlias, getAuxiliaryBean, getAuxiliaryBeans, getEngine, getLinkConnectionRectangle, getLocation, needsViewListeners, propertyChanged, removeViewListeners, setAlias, setLayerName
public static String LONGITUDE_PROPERTY
LONGITUDE_PROPERTY
is the name used for the longitude
property.public static String LATITUDE_PROPERTY
LATITUDE_PROPERTY
is the name used for the latitude property.public static String X_PROPERTY
X_PROPERTY
is the name used for the x property, i.e. the x
coordinate of the symbol on the grapher, in the KERNEL system.public static String Y_PROPERTY
Y_PROPERTY
is the name used for the y property, i.e. the y
coordinate of the symbol on the grapher, in the KERNEL system.public IlvMapRenderer(IlvSDMRenderer renderer)
renderer
- The filtered renderer.public IlvMapRenderer()
null
filtered renderer.public void prepareRendering(IlvSDMEngine engine)
prepareRendering
in class IlvFilterSDMRenderer
engine
- The SDM engine.public void removeAll(IlvSDMEngine engine)
removeAll
in class IlvFilterSDMRenderer
engine
- The SDM engine.public Object getGraphicProperty(IlvSDMEngine engine, Object object, String property, String[] pseudoClass, Class targetClass)
"x"
and
"y"
properties.
When these properties are requested, the method reads the values of the
LATITUDE_PROPERTY
and LONGITUDE_PROPERTY
properties for the node, projects them using the projection contained in
the map file, and returns the projected coordinates.
getGraphicProperty
in class IlvFilterSDMRenderer
engine
- The SDM engine.object
- The data object that is being rendered.property
- The name of the graphic property.pseudoClass
- The pseudo-class of the object. This parameter can be
null
.targetClass
- The class of the object on which the property will be set. The
method can introspect the class to determine the type of the
property, and convert the value if necessary. If this argument is
null
, the property should be returned without
conversion.public void propertiesChanged(IlvSDMEngine engine, Object object, Collection<String> propertyNames, IlvGraphic graphic)
propertiesChanged
in class IlvFilterSDMRenderer
engine
- The SDM engine associated with the grapher in
which the graphic object is displayed.object
- The data object whose property has changed.propertyNames
- The names of the properties that have been modified.graphic
- The graphic object associated with object
.IlvFilterSDMRenderer.propertiesChanged(ilog.views.sdm.IlvSDMEngine, java.lang.Object, java.util.Collection<java.lang.String>, ilog.views.IlvGraphic)
public void updateObjectProperties(IlvSDMEngine engine, Object object, String property, Object value, String[] pseudoClasses)
Basically, this method does the inverse job of getGraphicProperty(ilog.views.sdm.IlvSDMEngine, java.lang.Object, java.lang.String, java.lang.String[], java.lang.Class)
.
It applies the inverse projection to the x and y coordinates, and updates
the latitude and longitude properties of the data object with the resulting
values.
updateObjectProperties
in class IlvFilterSDMRenderer
engine
- The SDM engine.object
- The data object.property
- The name of the graphic property.value
- The new value of the property.pseudoClasses
- The pseudo-classes of the objects. This parameter can be
null
.public static double convertLatLong(Object value, boolean latitude) throws IlvConvertException
value
- value of the property (usually retrieved with
IlvSDMNode.getProperty(String)
).latitude
- true to decode the value as a latitude.IlvConvertException
- if the property cannot be decoded.public void setMap(String map)
map
- A string containing the URL of an .ivl
file
containing the cartographic information. The map file must contain
the definition of a projection.public String getMap()
public void setRegionOfInterest(IlvRect regionOfInterest)
The region of interest can be computed automatically to fit the position of
the objects contained in the SDM data model, by calling
setAutoRegionOfInterest(true)
.
The default region of interest is null
, which means that the
view will display the whole map.
regionOfInterest
- The new region of interest, in manager coordinates.setAutoRegionOfInterest(boolean)
public IlvRect getRegionOfInterest()
setRegionOfInterest(ilog.views.IlvRect)
public void setAutoRegionOfInterest(boolean auto)
By default, the automatic computation of the region of interest is disabled.
auto
- If true
, the region of interest will be computed to
fit the bounding rectangles of all the objects of the SDM data
model. If this parameter is false
, the region of
interest is left unchanged.setRegionOfInterest(ilog.views.IlvRect)
public boolean isAutoRegionOfInterest()
setAutoRegionOfInterest(boolean)
public void setRegionOfInterestMargin(double percent)
10
, the region of interest will be 10% bigger than the
bounding rectangle of all the objects.
5
.percent
- The new margin, expressed as a percentage of the bounding
rectangle of all the objects.public double getRegionOfInterestMargin()
setRegionOfInterestMargin(double)
public IlvRect computeBBox(IlvSDMEngine engine, IlvManagerView view, IlvTransformer t)
computeBBox
method.computeBBox
in class IlvFilterSDMRenderer
engine
- The SDM engine.view
- The manager view for which the bounding rectangle is computed.t
- The transformer used to compute the bbox
.
A null
value is equivalent to an identity transformer.IlvFilterSDMRenderer.computeBBox(ilog.views.sdm.IlvSDMEngine,
ilog.views.IlvManagerView, ilog.views.IlvTransformer)
public static void addLatitudeLongitudeFormat(String format, boolean latitude)
The format string must contain one sequence of each of the characters
d
(for degree), m
(for minutes), and
s
(for seconds). Optionally, the format may contain one of the
characters N
, S
, E
and
W
. The string is converted to a negative latitude or longitude
if it contains the characters S
or W
, or if it
starts with a -
(minus) character.
A string can be converted using a format only if the string has exactly the
same length as the format. The sequences of d
, s
and m
characters must match a sequence of the same length of
decimal digits. All other characters in the format must match exactly the
character at the same position in the string, including the N
,
S
, E
, W
and -
(minus)
characters.
For example, the format "dddmmssW"
will match the string
"1113902W"
, but will not match "952700W"
because
the number of digits does not fit.
The following set of formats are pre-registered:
"dddmmssN"
"dddmmssS"
"dddmmssE"
"dddmmssW"
"ddmmssN"
"ddmmssS"
"ddmmssE"
"ddmmssW"
format
- The new format to register.latitude
- If true
, the format will be used to convert strings
to latitudes, otherwise the format will be used to convert strings
to longitudes.public boolean isFitToContentsAllowed()
public void setFitToContentsAllowed(boolean activated)
activated
- the new valuepublic void setParameter(String parameter)
setMap(java.lang.String)
.setParameter
in class IlvSDMRenderer
parameter
- The value of the parameter.public String getParameter()
getMap()
.getParameter
in class IlvSDMRenderer
IlvSDMRenderer.setParameter(java.lang.String)
public static IlvMapRenderer getInstance(IlvSDMEngine engine)
engine
- the SDM enginepublic boolean isUsingThreads()
IlvMapInputStream.setGeneratingImage(Boolean)
public void setUsingThreads(boolean usingThreads)
usingThreads
- true if threads should be authorized.public void setEngine(IlvSDMEngine engine)
IlvSDMEngine
instance that has created
this renderer. This method is called by the SDM engine, you should not
call it directly.setEngine
in class IlvSDMRenderer
IlvSDMRenderer.setEngine(ilog.views.sdm.IlvSDMEngine)
public IlvGraphic createNodeGraphic(IlvSDMEngine engine, Object node)
createNodeGraphic
method
of the filtered renderer. This method has been overridden to hide the graphic object if
it has invalid coordinates.createNodeGraphic
in class IlvFilterSDMRenderer
engine
- The SDM engine associated with the grapher in
which the graphic object will be added.node
- The data node to translate into an IlvGraphic
.createNodeGraphic(IlvSDMEngine, Object)
public IlvGraphic createLinkGraphic(IlvSDMEngine engine, Object link, IlvGraphic from, IlvGraphic to)
createLinkGraphic
method
of the filtered renderer. This method has been overridden to hide the link if one of
its extremities has invalid coordinates.createLinkGraphic
in class IlvFilterSDMRenderer
engine
- The SDM engine associated with the grapher in
which the graphic object will be added.link
- The data link to translate into an IlvGraphic
.from
- The graphic object associated with the source node of the link.to
- The graphic object associated with the destination node of the link.createNodeGraphic(IlvSDMEngine, Object)
public boolean isHideInvalidNodesAndLinks()
true
if nodes with invalid coordinates will be hidden.public void setHideInvalidNodesAndLinks(boolean hideInvalidNodesAndLinks)
true
.hideInvalidNodesAndLinks
- true
if invalid nodes will be hidden.© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.