This class inherits {@linkplain #x x} and {@linkplain #y y} fields.But despite their names, they don't need to be oriented toward {@linkplain AxisDirection#EAST East} and{@linkplain AxisDirection#NORTH North} respectively. The (x,y) axis can have anydirection and should be understood as ordinate 0 and ordinate 1 values instead. This is not specific to this implementation; in Java2D too, the visual axis orientation depend on the {@linkplain java.awt.Graphics2D#getTransform() affine transform in the graphics context}.
{@note The rational for avoiding axis orientation restriction is that otherDirectPosition
implementations do not have such restriction, and it would be hard to generalize. For example there is no clear "x" or "y" classification for North-East direction.}{@section Caution when used in collections}Do not mix instances of this class with ordinary {@link Point2D} instancesin a {@code HashSet} or as {@code HashMap} keys.It is not possible to meet both {@link Point2D#hashCode()} and {@link DirectPosition#hashCode()}contracts, and this class chooses to implements the later. Consequently, the {@link #hashCode()}method of this class is inconsistent with {@link Point2D#equals(Object)} but is consistent with{@link DirectPosition#equals(Object)}. In other words, it is safe to add instances of {@code DirectPosition2D} in a{@code HashSet
Note 1:
This class inherits {@linkplain #x x} and {@linkplain #y y} fields. But despite their names,they don't need to be oriented toward {@linkplain org.opengis.referencing.cs.AxisDirection#EAST East} and {@linkplain org.opengis.referencing.cs.AxisDirection#NORTH North}. The (x,y) axis can have any orientation and should be understood as "ordinate 0" and "ordinate 1" values instead. This is not specific to this implementation; in Java2D too, the visual axis orientation depend on the {@linkplain java.awt.Graphics2D#getTransform affine transform in the graphics context}.The rational for avoiding axis orientation restriction is that other {@link DirectPosition}implementation do not have such restriction, and it would be hard to generalize (what to do with {@linkplain org.opengis.referencing.cs.AxisDirection#NORTH_EAST North-East} direction?).
Note 2:
Do not mix instances of this class with ordinary {@link Point2D} instances in a{@link java.util.HashSet} or as {@link java.util.HashMap} keys. It is not possible tomeet both {@link Point2D#hashCode} and {@link DirectPosition#hashCode} contract, and this classchoose to implements the later. Concequently, {@link #hashCode} is inconsistent with{@link Point2D#equals} (but is consistent with {@link DirectPosition#equals}).@since 2.0 @source $URL$ @version $Id$ @author Martin Desruisseaux (IRD) @see DirectPosition1D @see GeneralDirectPosition @see java.awt.geom.Point2DIn other words, it is safe to add instances of {@code DirectPosition2D} in a{@code HashSet
}, but it is unsafe to add them in a {@code HashSet }. Collections that do not rely on {@link Object#hashCode}, like {@link java.util.ArrayList}, are safe in all cases.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|