// XAAL toolkit // Copyright (C) 2009 Ville Karavirta // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . package xaal.objects.graphical; import java.awt.Rectangle; import xaal.objects.Xaal; import xaal.objects.XaalObject; /** * @author vkaravir * * To change the template for this generated type comment go to * Window>Preferences>Java>Code Generation>Code and Comments */ public class Coordinate extends XaalObject implements Cloneable { public int x, y; //private String id; private Offset offset; /** A private counter used when generating element id's */ //private static int count = 1; /** * */ public Coordinate(Xaal xaalDoc) { super(xaalDoc); } public Coordinate(Xaal xaalDoc, int x, int y) { super(xaalDoc); this.x = x; this.y = y; } public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * @return */ public int getX() { return x; } /** * @return Returns the y. */ public int getY() { return y; } /** * @param y * The y to set. */ public void setY(int y) { this.y = y; } /** * @param x * The x to set. */ public void setX(int x) { this.x = x; } /** * @return Returns the id. */ /* public String getId() { if (id == null) { id = generateId(); } return id; }*/ /** * @param id The id to set. */ /*public void setId(String id) { this.id = id; }*/ /** * @return Returns the offset. */ public Offset getOffset() { return offset; } /** * @param offset The offset to set. */ public void setOffset(Offset offset) { this.offset = offset; } public boolean equalsIgnoreId(Coordinate coord) { // TODO offsets if (coord.getX() == getX() && coord.getY() == getY()) return true; return false; } /** Returns the absolute x-coordinate. This is the same as using * getX() + getOffset().getX(). * @return */ public int getAbsoluteX() { if (getOffset() == null) { return getX(); } return getX() + getOffset().getOffsetX(); } /** Returns the absolute y-coordinate. This is the same as using * getY() + getOffset().getY(). * @return */ public int getAbsoluteY() { if (getOffset() == null) { return getY(); } return getY() + getOffset().getOffsetY(); } /** * Generates a unique id for this coordinate. * * @return A unique id. */ /*protected String generateId() { String cName = getClass().getName(); return cName.substring(cName.lastIndexOf('.') + 1) + count++; }*/ public String toString() { return "(" + getX() + "," + getY() + ")"; } public Rectangle getBounds() { return new Rectangle(0,0,0,0); } }