View Javadoc

1   /**********************************************
2    * Copyright (C) 2010 Lukas Laag
3    * This file is part of svgreal.
4    * 
5    * svgreal is free software: you can redistribute it and/or modify
6    * it under the terms of the GNU General Public License as published by
7    * the Free Software Foundation, either version 3 of the License, or
8    * (at your option) any later version.
9    * 
10   * svgreal is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   * GNU General Public License for more details.
14   * 
15   * You should have received a copy of the GNU General Public License
16   * along with svgreal.  If not, see http://www.gnu.org/licenses/
17   **********************************************/
18  package org.vectomatic.svg.edit.client.gxt.layout;
19  
20  import com.extjs.gxt.ui.client.widget.layout.LayoutData;
21  
22  /**
23   * Class to position layers in containers which use
24   * AbsoluteLayerLayout.
25   * @author laaglu
26   */
27  public class AbsoluteLayerLayoutData extends LayoutData {
28  	public static final int HORIZONTAL_ATTACH_LEFT = 0x01;
29  	public static final int HORIZONTAL_ATTACH_RIGHT = 0x02;
30  	public static final int VERTICAL_ATTACH_TOP = 0x04;
31  	public static final int VERTICAL_ATTACH_BOTTOM = 0x08;
32  	private int attachmentFlags;
33  	private int horizontalOffset;
34  	private int verticalOffset;
35  	private int width;
36  	private int height;
37  	private int zIndex;
38  	/**
39  	 * Constructor
40  	 * @param attachmentFlags
41  	 * A combination of an horizontal attachment flag and
42  	 * a vertical attachment flag
43  	 * @param horizontalOffset
44  	 * The distance to the horizontal attachment point
45  	 * @param verticalOffset
46  	 * The distance to the vertical attachment point
47  	 * @param width
48  	 * The width (if 0, it will adjust to the container width)
49  	 * @param height
50  	 * The height (if 0, it will adjust to the container height)
51  	 * @param zIndex
52  	 * The z index
53  	 */
54  	public AbsoluteLayerLayoutData(
55  			int attachmentFlags,
56  			int horizontalOffset,
57  			int verticalOffset,
58  			int width,
59  			int height,
60  			int zIndex) {
61  		this.attachmentFlags = attachmentFlags;
62  		assert((attachmentFlags & (HORIZONTAL_ATTACH_LEFT|HORIZONTAL_ATTACH_RIGHT)) != 0);
63  		assert((attachmentFlags & (VERTICAL_ATTACH_TOP|VERTICAL_ATTACH_BOTTOM)) != 0);
64  		this.horizontalOffset = horizontalOffset;
65  		this.verticalOffset = verticalOffset;
66  		this.width = width;
67  		this.height = height;
68  		this.zIndex = zIndex;
69  	}
70  	public boolean isAttachedLeft() {
71  		return (attachmentFlags & HORIZONTAL_ATTACH_LEFT) != 0;
72  	}
73  	public boolean isAttachedRight() {
74  		return (attachmentFlags & HORIZONTAL_ATTACH_RIGHT) != 0;
75  	}
76  	public boolean isAttachedTop() {
77  		return (attachmentFlags & VERTICAL_ATTACH_TOP) != 0;
78  	}
79  	public boolean isAttachedBottom() {
80  		return (attachmentFlags & VERTICAL_ATTACH_BOTTOM) != 0;
81  	}
82  	public int getHeight() {
83  		return height;
84  	}
85  	public int getWidth() {
86  		return width;
87  	}
88  	public int getHorizontalOffset() {
89  		return horizontalOffset;
90  	}
91  	public int getVerticalOffset() {
92  		return verticalOffset;
93  	}
94  	public int getZIndex() {
95  		return zIndex;
96  	}
97  }