/** * Returns the singleton point of this shape. Only applicable for point and circle shapes. * * @return */ public Point getPoint() { Preconditions.checkArgument(size()==1,"Shape does not have a single point"); return getPoint(0); }
/** * Returns the point at the given position. The position must be smaller than {@link #size()}. * * @param position * @return */ public Point getPoint(int position) { if (position<0 || position>=size()) throw new ArrayIndexOutOfBoundsException("Invalid position: " + position); return new Point(coordinates[0][position],coordinates[1][position]); }
@Override public String toString() { Type type = getType(); StringBuilder s = new StringBuilder(); s.append(type.toString().toLowerCase()); switch (type) { case POINT: s.append(getPoint().toString()); break; case CIRCLE: s.append(getPoint().toString()).append(":").append(getRadius()); break; default: s.append("["); for (int i=0;i<size();i++) { if (i>0) s.append(","); s.append(getPoint(i)); } s.append("]"); } return s.toString(); }
/** * Returns the singleton point of this shape. Only applicable for point and circle shapes. * * @return */ public Point getPoint() { Preconditions.checkArgument(size()==1,"Shape does not have a single point"); return getPoint(0); }
/** * Returns the point at the given position. The position must be smaller than {@link #size()}. * * @param position * @return */ public Point getPoint(int position) { if (position<0 || position>=size()) throw new ArrayIndexOutOfBoundsException("Invalid position: " + position); return new Point(coordinates[0][position],coordinates[1][position]); }
/** * Returns the singleton point of this shape. Only applicable for point and circle shapes. * * @return */ public Point getPoint() { Preconditions.checkArgument(size()==1,"Shape does not have a single point"); return getPoint(0); }
/** * Returns the point at the given position. The position must be smaller than {@link #size()}. * * @param position * @return */ public Point getPoint(int position) { if (position<0 || position>=size()) throw new ArrayIndexOutOfBoundsException("Invalid position: " + position); return new Point(coordinates[0][position],coordinates[1][position]); }
@Override public String toString() { Type type = getType(); StringBuilder s = new StringBuilder(); s.append(type.toString().toLowerCase()); switch (type) { case POINT: s.append(getPoint().toString()); break; case CIRCLE: s.append(getPoint().toString()).append(":").append(getRadius()); break; default: s.append("["); for (int i=0;i<size();i++) { if (i>0) s.append(","); s.append(getPoint(i)); } s.append("]"); } return s.toString(); }
@Override public String toString() { Type type = getType(); StringBuilder s = new StringBuilder(); s.append(type.toString().toLowerCase()); switch (type) { case POINT: s.append(getPoint().toString()); break; case CIRCLE: s.append(getPoint().toString()).append(":").append(getRadius()); break; default: s.append("["); for (int i=0;i<size();i++) { if (i>0) s.append(","); s.append(getPoint(i)); } s.append("]"); } return s.toString(); }