// 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 xaal.objects.XaalObject; public class Offset { public static final String N = "N"; public static final String NE = "NE"; public static final String E = "E"; public static final String SE = "SE"; public static final String S = "S"; public static final String SW = "SW"; public static final String W = "W"; public static final String NW = "NW"; public static final String C = "C"; public static final String CENTER = "CENTER"; private int x, y; private XaalObject baseObj; private String anchor = "C"; public Offset() { super(); } /** * @return the x */ public int getX() { return x; } /** * @param x the x to set */ public void setX(int x) { this.x = x; } /** * @return the y */ public int getY() { return y; } /** * @param y the y to set */ public void setY(int y) { this.y = y; } /** * @return the baseObj */ public XaalObject getBaseObj() { return baseObj; } /** * @param baseObj the baseObj to set */ public void setBaseObj(XaalObject baseObj) { this.baseObj = baseObj; } /** * @return the anchor */ public String getAnchor() { return anchor; } /** * @param anchor the anchor to set */ public void setAnchor(String anchor) { this.anchor = anchor; } public int getOffsetX() { if (baseObj == null) { return getX(); } else { return getX() + baseObj.getAnchorCoordinate(getAnchor())[0]; } } public int getOffsetY() { if (baseObj == null) { return getY(); } else { return getY() + baseObj.getAnchorCoordinate(getAnchor())[1]; } } public String toString() { return "(" + x + ","+y+") " + getAnchor() + " of " + baseObj.getId(); } }