org.geotools.renderer.j2d
Class MarkIterator

java.lang.Object
  extended byorg.geotools.renderer.j2d.MarkIterator
Direct Known Subclasses:
RenderedGridMarks.Iterator

public abstract class MarkIterator
extends java.lang.Object

Provides the mechanism for RenderedGridMarks layer to return the appearance of their marks. This class allows the layer to retrieve the appearance of its marks a mark at a time. The default implementation paints circles at mark locations. Subclasses must implement at least the following methods:

Si, ? la position de chaque marque, on souhaite dessiner une figure orientable dans l'espace (par exemple une fl?che de courant ou une ellipse de mar?e), la classe d?riv?e pourra red?finir une ou plusieurs des m?thodes ci-dessous. Red?finir ces m?thodes permet par exemple de dessiner des fl?ches dont la forme exacte (par exemple une, deux ou trois t?tes) et la couleur varie avec l'amplitude, la direction ou d'autres crit?res de votre choix.

Version:
$Id: MarkIterator.java 17672 2006-01-19 00:25:55Z desruisseaux $
Author:
Martin Desruisseaux

Constructor Summary
MarkIterator()
          Construct a mark iterator.
 
Method Summary
 double amplitude()
          Returns the horizontal amplitude for the current mark.
 double direction()
          Returns the arithmetic direction for the current mark.
 java.awt.Font font()
          Returns the font for current label.
 java.awt.Shape geographicArea()
          Returns the geographic area around the current mark, or null if none.
protected  javax.swing.Action getAction(GeoMouseEvent event)
          Returns an action text for the current mark, or null if none.
abstract  int getIteratorPosition()
          Returns the current iterator position.
protected  java.lang.String getToolTipText(GeoMouseEvent event)
          Returns a tooltip text for the current mark, or null if none.
 java.lang.String label()
          Returns the label for the current mark, or null if none.
 LegendPosition labelPosition()
          Returns the label position relative to the mark's position.
 java.awt.image.RenderedImage markIcon()
          Returns the icon for the current mark, or null if none.
 java.awt.Paint markPaint()
          Returns the paint for current mark.
 java.awt.Shape markShape()
          Returns the geometric shape for the current mark.
abstract  boolean next()
          Moves the iterator to the next marks.
protected  void paint(java.awt.Graphics2D graphics, java.awt.Shape geographicArea, java.awt.Shape markShape, java.awt.image.RenderedImage markIcon, java.awt.geom.AffineTransform iconXY, java.awt.font.GlyphVector label, java.awt.geom.Point2D.Float labelXY)
          Paint a mark, its geographic area and its label.
abstract  java.awt.geom.Point2D position()
          Returns the (x,y) coordinates for the current mark.
abstract  void setIteratorPosition(int index)
          Moves the iterator the specified mark.
 boolean visible()
          Returns true if the current mark should be painted.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MarkIterator

public MarkIterator()
Construct a mark iterator. The MarkIterator is initially positioned before the first mark. A call to next() must be done before the first mark can be read.

Method Detail

getIteratorPosition

public abstract int getIteratorPosition()
Returns the current iterator position. A newly created MarkIterator will returns -1, since new iterators are initially positioned before the first mark.


setIteratorPosition

public abstract void setIteratorPosition(int index)
                                  throws java.lang.IllegalArgumentException
Moves the iterator the specified mark. A call to setIteratorPosition(0) moves the iterator on the first mark. A call to setIteratorPosition(-1) moves the iterator to the front of this MarkIterator object, just before the first mark (i.e. in the same position as when this MarkIterator object was just created).

Parameters:
index - The new position (0 for the first mark, 1 for the second one, etc.).
Throws:
java.lang.IllegalArgumentException - if index is smaller than -1 or greater than the last position allowed.

next

public abstract boolean next()
Moves the iterator to the next marks. A MarkIterator is initially positioned before the first mark; the first call to the method next() makes the first mark the current mark; the second call makes the second mark the current mark, and so on. This method is usually invoked in a while loop as below:
 MarkIterator it = layer.getMarkIterator();
 while (it.next()) {
     // Query current mark properties here...
 }
 

Returns:
true if the new current mark is valid; false if there are no more marks.

visible

public boolean visible()
Returns true if the current mark should be painted. The default implementation returns always true.


position

public abstract java.awt.geom.Point2D position()
                                        throws org.opengis.referencing.operation.TransformException
Returns the (x,y) coordinates for the current mark. Coordinates must be expressed according the layer's coordinate system (a geographic one by default). This method can returns null if the current mark location is unknow.

Throws:
org.opengis.referencing.operation.TransformException - if a transform was required and failed.
See Also:
geographicArea()

amplitude

public double amplitude()
Returns the horizontal amplitude for the current mark. This amplitude tells how big a mark should be painted. It is useful for painting wind arrows or some other quantifiable marks. The default implementation returns always 1.


direction

public double direction()
Returns the arithmetic direction for the current mark. This angle must be expressed in arithmetic radians (i.e. angle 0 point toward the right and angles increase counter-clockwise). This information is useful for painting wind arrows for example. The default implementation returns always 0.


markShape

public java.awt.Shape markShape()
Returns the geometric shape for the current mark. This shape may be mark dependent, or be the same for all marks. This shape must be centred at the origin (0,0) and its coordinates must be expressed in dots (1/72 of inch). For example in order to paint wind arrows, this shape should be oriented toward positives x (i.e. toward 0 arithmetic radians), has a base centred at (0,0) and have a raisonable size (for example 16×4 pixels). The method RenderedMarks.paint(RenderingContext) will automatically takes care of rotation, translation and scale in order to adjust this model to each mark properties. The default implementation returns a circle centred at (0,0) with a diameter of 10 dots.

The returned shape should be treated as immutable. Implementations are encouraged to return shared instances as much as possible.


markIcon

public java.awt.image.RenderedImage markIcon()
Returns the icon for the current mark, or null if none. The default implementation returns always null.


geographicArea

public java.awt.Shape geographicArea()
Returns the geographic area around the current mark, or null if none. This area must be expressed according the layer's coordinate system. Usually (but not mandatory), this area will contains the point returned by position(). A typical use of this method is for painting the land which belong to a building (the mark). The default implementation returns always null, which means that this layer paint marks without geographic area.


font

public java.awt.Font font()
Returns the font for current label. The default implementation returns a default font, which is rendering dependent.


label

public java.lang.String label()
Returns the label for the current mark, or null if none. The default implementation returns always null.


labelPosition

public LegendPosition labelPosition()
Returns the label position relative to the mark's position. The default implementation returns always LegendPosition.CENTER.


markPaint

public java.awt.Paint markPaint()
Returns the paint for current mark.


paint

protected void paint(java.awt.Graphics2D graphics,
                     java.awt.Shape geographicArea,
                     java.awt.Shape markShape,
                     java.awt.image.RenderedImage markIcon,
                     java.awt.geom.AffineTransform iconXY,
                     java.awt.font.GlyphVector label,
                     java.awt.geom.Point2D.Float labelXY)
Paint a mark, its geographic area and its label. This method is automatically invoked from RenderedMarks.paint(RenderingContext) at rendering time. Subclasses can override this method in order to gets finer control on the rendering process of marks (e.g. colors, stroke, painting order, etc.). The default implementation use the following pseudo-code:
   if (geographicArea != null) {
       graphics.setColor(some default color);
       graphics.draw(geographicArea);
   }
   if (markIcon != null) {
       graphics.drawRenderedImage(markIcon, iconXY);
   }
   if (markShape != null) {
       graphics.setPaint(markPaint());
       graphics.fill(markShape);
   }
   if (label != null) {
       graphics.setColor(some default color);
       graphics.drawGlyphVector(label, labelXY.x, labelXY.y);
   }
 

Parameters:
graphics - The graphics where painting while occurs. The affine transform is set to the Java2D default, also know as the text coordinate system in this library.
geographicArea - The geographic area which belong to the mark, or null if none. This shape is already transformed in the Java2D coordinate system.
markShape - The shape for the mark, or null if none. This shape is already transformed in the Java2D coordinate system.
markIcon - The icon for the mark, or null if none.
iconXY - The affine transform to apply on markIcon. May be null if markIcon was null.
label - The label to draw, or null if none.
labelXY - The label position. May be null if label was null.

getToolTipText

protected java.lang.String getToolTipText(GeoMouseEvent event)
Returns a tooltip text for the current mark, or null if none. The default implementation returns always null. Note: This method is not a commited part of the API. It may moves elsewhere in a future version.

Parameters:
event - The mouse event.
Returns:
The tool tip text for the current mark, or null if none.

getAction

protected javax.swing.Action getAction(GeoMouseEvent event)
Returns an action text for the current mark, or null if none. This method may be call for example on mouse click. The action doesn't need to be executed immediately. For example it may be put in a tool bar, or saved in a macro recorder. The default implementation returns always null. Note: This method is not a commited part of the API. It may moves elsewhere in a future version.

Parameters:
event - The mouse event.
Returns:
The action for the current mark, or null if none.


Copyright © GeoTools. All Rights Reserved.