00001 package edu.stanford.hci.r3.units.coordinates; 00002 00003 import edu.stanford.hci.r3.units.Percentage; 00004 import edu.stanford.hci.r3.units.Units; 00005 00018 public class PercentageCoordinates extends Coordinates { 00019 00024 public PercentageCoordinates(Percentage pctInX, Percentage pctInY) { 00025 super(pctInX, pctInY); 00026 } 00027 00031 public Units getActualValueInXDirection() { 00032 return ((Percentage) x).getActualValue(); 00033 } 00034 00038 public Units getActualValueInYDirection() { 00039 return ((Percentage) y).getActualValue(); 00040 } 00041 00048 public double getPercentageInXDirection() { 00049 return x.getValue(); 00050 } 00051 00055 public double getPercentageInYDirection() { 00056 return y.getValue(); 00057 } 00058 00065 public void setX(Units xCoord) { 00066 if (xCoord instanceof Percentage) { 00067 x = xCoord; 00068 } else { 00069 System.err.println("PercentageCoordinates: Incorrect type passed to setX(). [" 00070 + xCoord.getClass() + "]"); 00071 } 00072 } 00073 00080 public void setY(Units yCoord) { 00081 if (yCoord instanceof Percentage) { 00082 y = yCoord; 00083 } else { 00084 System.err.println("PercentageCoordinates: Incorrect type passed to setY(). [" 00085 + yCoord.getClass() + "]"); 00086 } 00087 } 00088 00092 public String toString() { 00093 return "PercentageCoordinates { \n" // 00094 + "\t" + x.toString() + ", \n" // 00095 + "\t" + y.toString() + "\n}"; 00096 } 00097 }