com.partnersoft.geometry.lonlat
Interface LonlatShape<T extends LonlatShape>

All Superinterfaces:
Immutable, java.lang.Iterable<LonlatPoint>
All Known Implementing Classes:
LonlatPoint

public interface LonlatShape<T extends LonlatShape>
extends Immutable, java.lang.Iterable<LonlatPoint>

Generic supertype for all shapes in the (longitude, latitude) coordinate space.

Defines basic methods and enforces immutability and iterability. In addition, shapes must be defined in such a way that translation and uniform scaling do not change their class. Other types of affine transform may change the class. For example, scaling a square by the same factor in both dimensions always results in a square. Translating it by moving it any amount in either dimension always results in a square. However, scaling it by one factor in X and another factor in Y, or applying shears, results in something not a square.

Subclasses should generally provide themselves as the generic type parameter T. For example:

 public class LonlatPoint implements LonlatShape<LonlatPoint> {
 
This clever construction allows you to use e.g. scale() on a shape of declared type without having to cast the result:
 LonlatPoint original = new LonlatPoint(100, 100);
 LonlatPoint scaled = original.scale(5);
 
Copyright 2007 Partner Software, Inc.

Version:
$Id: LonlatShape.java 1012 2007-11-24 18:30:02Z paul $
Author:
Paul Reavis

Method Summary
 T scale(double factor)
          Return a scaled version of the shape by multiplying all coordinates by the given factor in both dimensions.
 T translate(double offsetX, double offsetY)
          Translate the shape by adding all coordinates to the given x and y offsets.
 
Methods inherited from interface java.lang.Iterable
iterator
 

Method Detail

scale

T scale(double factor)
Return a scaled version of the shape by multiplying all coordinates by the given factor in both dimensions. This resulting shape must be of the same class as the original.

Parameters:
factor - scaling factor
Returns:
scaled result

translate

T translate(double offsetX,
            double offsetY)
Translate the shape by adding all coordinates to the given x and y offsets. The resulting shape must be of the same class as the original.

Parameters:
offsetX - offset for the x dimension
offsetY - offset for the y dimension
Returns:
offset result