public abstract class IlvAbstractBaseGrid extends IlvManagerLayer implements IlvManagerViewDecoration, IlvManagerLightViewDecoration
paintGrid(Graphics2D, IlvTransformer)
method. For example, the
following code can be used to display an automatically scaled
longitude/latitude grid.
IlvManagerView view=new IlvManagerView(); ... IlvLatLonGrid grid = new IlvLatLonGrid(); grid.setAutoScaled(true); grid.setGridColor(Color.lightGray); grid.setTextColor(Color.blue); view.getManager().addLayer(grid);To have a non printed grid use
view.addViewDecoration(grid);
If
you want the grid to be printed, use instead:
view.getManager().addLayer(grid);
Modifier and Type | Field and Description |
---|---|
protected Line2D |
bottomLine
Current border lines of the visible rectangle - set in the
paint(Graphics, IlvManagerView) method. |
protected static FontRenderContext |
FRC
Font render context used to draw text.
|
protected Line2D |
leftLine
Current border lines of the visible rectangle - set in the
paint(Graphics, IlvManagerView) method. |
protected Line2D |
rightLine
Current border lines of the visible rectangle - set in the
paint(Graphics, IlvManagerView) method. |
protected IlvPoint |
tmp1
Temporary point used to prevent the allocation of new ones for each
transformation.
|
protected IlvPoint |
tmp2
Temporary point used to prevent the allocation of new ones for each
transformation.
|
protected Line2D |
topLine
Current border lines of the visible rectangle - set in the
paint(Graphics, IlvManagerView) method. |
protected Rectangle2D |
visibleRect
Current visible view rect - set in the
paint(Graphics, IlvManagerView) method. |
Constructor and Description |
---|
IlvAbstractBaseGrid()
Default constructor.
|
IlvAbstractBaseGrid(IlvInputStream stream)
Creates a grid by reading parameters from the stream.
|
Modifier and Type | Method and Description |
---|---|
void |
addObject(IlvGraphic obj)
Overridden method to prevent objects being added on this layer.
|
protected boolean |
checkPointInsideView(double lon,
double lat)
Checks if the lat/lon coordinates passed are inside the view visible
rectangle.
|
void |
draw(Graphics dst,
IlvManagerView v)
Paints the grid in the specified view.
|
protected void |
drawImpl(Graphics dst,
IlvManagerView v)
Draws the grid content in the specified view.
|
protected void |
drawLine(Graphics2D dst,
IlvTransformer t,
IlvPoint p1,
IlvPoint p2,
Object label,
boolean drawLine)
Utility to draw a grid line and its label.
|
protected void |
drawString(Graphics2D dst,
IlvTransformer t,
IlvPoint p,
String label)
Utility to draw a label text.
|
protected void |
drawText(Graphics2D g,
Point2D point,
Object label,
boolean horizontal,
int alignment)
Utility to draw a label text.
|
Point |
getAwtCoordinatesFromLatLon(double lon,
double lat)
Computes the awt point on the view from lat/lon coordinates in radians.
|
int |
getBaseTextDirection()
Returns the base text direction of labels on top of the grid lines.
|
protected IlvCoordinateTransformation |
getCoordinateTransformation()
Returns the transformation to use to transform view coordinates to
geographic system.
|
IlvPoint |
getGraphicFromLatLonCoordinate(double lon,
double lat,
IlvPoint rtn)
Computes an
IlvPoint for placing IlvGraphic objects on the view from
lat/lon coordinates. |
Color |
getGridColor()
Returns the color to use for the grid lines.
|
protected IlvCoordinateTransformation |
getInverseCoordinateTransformation()
Returns the transformation to use to transform geographic system to view
coordinates.
|
IlvCoordinate |
getLatLonFromAwtCoordinates(int x,
int y)
Computes the longitude/latitude of an awt based point on the view (such
as used by MouseEvent).
|
IlvCoordinate |
getLatLonFromGraphicCoordinate(IlvPoint point)
Computes an IlvCoordinate containing lat/lon in radians, from a set of xy
IlvGraphic coordinates.
|
int |
getSmoothness()
Returns the smoothness factor, that is, the number of intermediary points
between each line crossing.
|
double |
getStep()
Returns the distance between successive grid lines.
|
Color |
getTextColor()
Returns the color used to draw labels on top of the grid lines.
|
Font |
getTextFont()
Returns the font used to draw labels on top of the grid lines.
|
Color |
getTextOutlineColor()
Returns the color used to outline labels on top of the grid lines.
|
protected double |
getViewScale()
Returns the current view scale.
|
protected IlvTransformer |
getViewTransformer()
Returns the current view transformer.
|
boolean |
isAutoScaled()
Returns the autoscaling state (true by default).
|
protected boolean |
isLightPainting()
This flag indicates grids to try to paint "lightly".
|
protected boolean |
isTextRTL(String str)
Determines, in which order (left-to-right or right-to-left)
the grid text should be displayed.
|
boolean |
isTextVisible()
Returns
true if the lines crossing the screen border should display text. |
boolean |
isVisible(IlvManagerView v)
Returns
true if the layer is visible in the specified view. |
void |
paint(Graphics dst,
IlvManagerView v)
Paints the grid in the specified view.
|
abstract void |
paintGrid(Graphics2D dst,
IlvTransformer t)
Paints the grid.
|
void |
paintLight(Graphics dst,
IlvManagerView v)
Paints the decoration in the specified view using a "quick" or light
rendering.
|
void |
print(Graphics dst,
IlvRect area,
IlvTransformer t)
Prints the grid in the specified area.
|
void |
setAutoScaled(boolean autoScaled)
Activates/Deactivates the autoscaling dst.setClip(oldClip);
mechanism.
|
void |
setBaseTextDirection(int textDir)
Sets the base text direction of grid labels.
|
void |
setGridColor(Color gridColor)
Sets the color used to draw grid lines.
|
protected void |
setScale(double scale)
Sets the current transformer and scale to use for the view.
|
void |
setSmoothness(int smoothness)
Sets the smoothness factor (that is, the number of intermediary points between
each line crossing) A value above 1 is recommended for better appearance.
|
void |
setStep(double step)
Sets the distance between successive grid lines (if autoscaling is not
activated).
|
void |
setTextColor(Color textColor)
Sets the color used to draw grid labels.
|
void |
setTextFont(Font textFont)
Sets the Font used to draw grid labels.
|
void |
setTextOutlineColor(Color textOutlineColor)
Sets the color used to outline grid labels.
|
void |
setTextVisible(boolean textVisible)
Indicates whether the lines crossing screen border should display their lat/lon text.
|
protected void |
setTransformer(IlvTransformer t)
Sets the current transformer to use for the view.
|
void |
setVisibleOnlyOnView(IlvManagerView visibleView)
Forces the grid to be displayed only on the specified view.
|
protected void |
setVisibleRect(Rectangle2D r)
Sets the rectangle within which the grid may be drawn.
|
protected void |
updateTransforms(IlvManager m)
Searches and updates the coordinate transformations to use, according to
the coordinate system set on the manager.
|
void |
updateViewParameters(IlvManagerView v)
Sets grid parameters for next draw.
|
void |
write(IlvOutputStream stream)
Writes the layer to an output stream.
|
addVisibilityFilter, computeBBox, getAlpha, getIndex, getManager, getName, getNamedProperty, getProperty, getVisibilityFilters, isSelectable, isTemporarilyHidden, isVisible, removeNamedProperty, removeVisibilityFilter, setAlpha, setManager, setName, setNamedProperty, setProperty, writeIt
afterUpdate, beforeUpdate, collectObjects, collectSelectableObjects, deleteAll, getCardinal, getElements, getIndex, getManagers, getManagersCount, getObject, getObject, getSelectableObject, getSubsequentRemoveThreshold, isQuadtreeEnabled, isZOrdering, map, mapInside, mapInside, mapIntersects, mapIntersects, removeObject, setIndex, SetInitialNumberOfNonZoomablesCapacity, SetInitialNumberOfObjectsCapacity, setQuadtreeEnabled, setSubsequentRemoveThreshold, setZOrdering
protected static final FontRenderContext FRC
protected transient Line2D bottomLine
paint(Graphics, IlvManagerView)
method. Used by
drawLine(Graphics2D, IlvTransformer, IlvPoint, IlvPoint, Object, boolean)
to detect intersections at which to place labels.protected transient Line2D leftLine
paint(Graphics, IlvManagerView)
method. Used by
drawLine(Graphics2D, IlvTransformer, IlvPoint, IlvPoint, Object, boolean)
to detect intersections at which labels can be placed.protected transient Line2D rightLine
paint(Graphics, IlvManagerView)
method. Used by
drawLine(Graphics2D, IlvTransformer, IlvPoint, IlvPoint, Object, boolean)
to detect intersections at which labels can be placed.protected final transient IlvPoint tmp1
protected final transient IlvPoint tmp2
tmp1
protected transient Line2D topLine
paint(Graphics, IlvManagerView)
method. Used by
drawLine(Graphics2D, IlvTransformer, IlvPoint, IlvPoint, Object, boolean)
to detect intersections at which labels can be placed.protected transient Rectangle2D visibleRect
paint(Graphics, IlvManagerView)
method. Used by
drawLine(Graphics2D, IlvTransformer, IlvPoint, IlvPoint, Object, boolean)
to detect intersections at which labels can be placed.public IlvAbstractBaseGrid()
public IlvAbstractBaseGrid(IlvInputStream stream)
stream
- Stream to read from.public void addObject(IlvGraphic obj)
addObject
in class IlvIndexedSet
obj
- Graphic Object.public void draw(Graphics dst, IlvManagerView v)
super.draw()
.
The actual drawing code is done in
drawImpl(Graphics, IlvManagerView)
.draw
in class IlvManagerLayer
dst
- The Graphics to paint to.v
- The manager view.IlvManagerView.setLayerCached(int, boolean)
protected void drawImpl(Graphics dst, IlvManagerView v)
Note: as updateViewParameters(IlvManagerView)
is called
for optimization issues, a grid will only be able to draw one at a time.
This is true even if you are using multiple threads.
drawImpl
in class IlvManagerLayer
dst
- The Graphics
object to paint to.v
- The manager view.IlvManagerLayer.draw(Graphics, IlvManagerView)
public void updateViewParameters(IlvManagerView v)
v
- View for which to retrieve parameters.public Point getAwtCoordinatesFromLatLon(double lon, double lat) throws IlvCoordinateTransformationException
lon
- Longitude in radians.lat
- latitude in radians.IlvCoordinate
with latitude and longitude in radians.IlvCoordinateTransformationException
getGraphicFromLatLonCoordinate(double, double, IlvPoint)
public IlvPoint getGraphicFromLatLonCoordinate(double lon, double lat, IlvPoint rtn) throws IlvCoordinateTransformationException
IlvPoint
for placing IlvGraphic
objects on the view from
lat/lon coordinates.lon
- Longitude in radians.lat
- Latitude in radians.rtn
- The returned point or null.IlvPoint
of an IlvGraphic
inside the view.IlvCoordinateTransformationException
IlvCoordinateTransformation.transform(IlvCoordinate, IlvCoordinate)
public Color getGridColor()
setGridColor(Color)
public IlvCoordinate getLatLonFromAwtCoordinates(int x, int y) throws IlvCoordinateTransformationException
x
- AWT x coordinate.y
- AWT y coordinate.IlvCoordinate
with latitude and longitude in radians.IlvCoordinateTransformationException
getLatLonFromGraphicCoordinate(IlvPoint)
public IlvCoordinate getLatLonFromGraphicCoordinate(IlvPoint point) throws IlvCoordinateTransformationException
point
- Coordinate of an IlvGraphic
inside the view.IlvCoordinate
with latitude and longitude in radians.IlvCoordinateTransformationException
getCoordinateTransformation()
,
IlvCoordinateTransformation.transform(IlvCoordinate, IlvCoordinate)
public int getSmoothness()
setSmoothness(int)
public double getStep()
setStep(double)
public Color getTextColor()
setTextColor(Color)
public Color getTextOutlineColor()
setTextOutlineColor(Color)
public Font getTextFont()
setTextFont(Font)
public boolean isAutoScaled()
true
if autoscaling is activated.setAutoScaled(boolean)
public int getBaseTextDirection()
setBaseTextDirection(int)
public boolean isVisible(IlvManagerView v)
true
if the layer is visible in the specified view.
This method checks the visibility of the layer itself, the visibility of
the layer for the specified view, and then calls the visibility filters.isVisible
in class IlvManagerLayer
v
- The view of the manager.IlvManagerLayer.isVisible(ilog.views.IlvManagerView)
public void paint(Graphics dst, IlvManagerView v)
updateViewParameters(IlvManagerView)
for optimization issues, a grid will be able to draw only once at a time - even if using multiple threads.paint
in interface IlvManagerViewDecoration
dst
- The Graphics to paint to.v
- The manager view.public abstract void paintGrid(Graphics2D dst, IlvTransformer t)
dst
- The Graphics to paint the grid onto.t
- The view transformer to use.public void paintLight(Graphics dst, IlvManagerView v)
paintLight
in interface IlvManagerLightViewDecoration
dst
- The Graphics to paint to.v
- The manager view.IlvManagerLightViewDecoration.paintLight(java.awt.Graphics,ilog.views.IlvManagerView)
public void print(Graphics dst, IlvRect area, IlvTransformer t)
print
in class IlvManagerLayer
dst
- The Graphics to paint to.area
- The visible area to print.t
- The view transformer.public void setAutoScaled(boolean autoScaled)
autoScaled
- Should be true
to activate autoscaling.setStep(double)
public void setGridColor(Color gridColor)
gridColor
- Color to use to draw grid lines.public void setSmoothness(int smoothness)
smoothness
- The smoothness factor.public void setStep(double step)
step
- The distance.public void setTextColor(Color textColor)
textColor
- Color to use to draw grid labels.public void setTextOutlineColor(Color textOutlineColor)
textOutlineColor
- Color to use to outline grid labels.public void setTextFont(Font textFont)
textFont
- Font to use to draw grid labels.public void setVisibleOnlyOnView(IlvManagerView visibleView)
visibleView
parameter is not null, the isVisible(IlvManagerView)
method will only return true
for this view. Use this method to prevent
the grid from painting on an overview, for example.visibleView
- Only view for which the grid will be displayed.isVisible(IlvManagerView)
public void setBaseTextDirection(int textDir)
textDir
- Base text direction of grid labels.protected boolean isTextRTL(String str)
str
- Texttrue
, if given text should be
displayed in right-to-left order, otherwise returns false
protected void setScale(double scale)
scale
- Scale of the view.protected void setTransformer(IlvTransformer t)
t
- Transformer to use.protected void setVisibleRect(Rectangle2D r)
r
- Visible rectangle of the view.protected boolean checkPointInsideView(double lon, double lat)
lon
- Longitude in radians.lat
- Latitude in radians.true
if the point is inside the visible rect.protected void drawLine(Graphics2D dst, IlvTransformer t, IlvPoint p1, IlvPoint p2, Object label, boolean drawLine)
dst
- The Graphics to paint to.t
- The IlvTransformer
to use.p1
- The view related first point of the linep2
- The view related second point of the line.label
- The label to draw.drawLine
- If false
, this method will only draw the eventual text.drawText(Graphics2D, Point2D, Object, boolean, int)
protected void drawString(Graphics2D dst, IlvTransformer t, IlvPoint p, String label)
dst
- The Graphics to paint to.t
- The IlvTransformer
to use.p
- The view related reference IlvPoint
.label
- The label to draw.drawText(Graphics2D, Point2D, Object, boolean, int)
protected void drawText(Graphics2D g, Point2D point, Object label, boolean horizontal, int alignment)
g
- The Graphics to paint to.point
- Swing view coordinates of the text reference point.label
- Can be either an AttributedCharacterIterator
or a regular
object.horizontal
- true
if the string must be horizontal.alignment
- Indicates if the text is centered after or before the
reference point. Alignment can be either:
protected IlvCoordinateTransformation getCoordinateTransformation()
protected IlvCoordinateTransformation getInverseCoordinateTransformation()
protected double getViewScale()
protected IlvTransformer getViewTransformer()
protected boolean isLightPainting()
true
if painting is light.IlvManagerLightViewDecoration
protected void updateTransforms(IlvManager m)
m
- Manager.public void write(IlvOutputStream stream) throws IOException
IlvManagerLayer
to store your
own information. If you override the method, you
may call super.write(stream)
after
your own saving instructions. Calling the superclass method
will dump the graphic objects stored in the layer.write
in interface IlvPersistentObject
write
in class IlvManagerLayer
stream
- the output streamIOException
- thrown when an exception occurs during
the write operation for this object.IlvManagerLayer.write(ilog.views.io.IlvOutputStream)
public boolean isTextVisible()
true
if the lines crossing the screen border should display text.true
if the lines crossing the screen border should display text.public void setTextVisible(boolean textVisible)
textVisible
- The visibility of text.© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.