package cse1030.drawing; /** * Geometric transformation of a 2D point. Objects of this class can * transform a point, changing its coordinates. Alternatively, the * transformation can be applied to a point to produce a new point leaving the * original point unchanged. * * @author CSE1030Z * */ public abstract class Transformation { private String name; /** * Constructs a transformation with the given name. * * @param name the name of the transformation */ public Transformation(String name) { this.name = name; } /** * Get the name of the transformation. * * @return the name of the transformation */ public final String getName() { return this.name; } /** * Get a string representation of the transformation. This abstract * class provides an implementation that returns the name of the * transformation; subclasses are expected to override this * method to provide additional information about the transformation. * * @return the name of the transformation as a string * @see java.lang.Object#toString() */ public String toString() { return this.name; } /** * Transform a point changing its coordinates. * * @param p * the point to transform */ public abstract void transform(Point2D p); /** * Apply the transformation to a point to produce a new point leaving the * original point unchanged. * * @param p * the point to apply the transformation to * @return a new point equal to the transformation applied to the original * point */ public abstract Point2D apply(Point2D p); }