001: /*
002: * Copyright (C) 2004 TiongHiang Lee
003: *
004: * This library is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License as published by the Free Software Foundation; either
007: * version 2.1 of the License, or (at your option) any later version.
008: *
009: * This library is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public
015: * License along with this library; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017: *
018: * Email: thlee@onemindsoft.org
019: */
020: package org.onemind.swingweb.templaterender.layout;
021:
022: import java.awt.Component;
023:
024: /**
025: * This is used to contain the components in sorted order, from top to bottom, left to right
026: * @author TiongHiang Lee
027: *
028: */
029: public class ComponentCell {
030: /** the component **/
031: private Component _com;
032:
033: /** the starting row **/
034: private int _row = 0;
035:
036: /** the starting col **/
037: private int _col = 0;
038:
039: /** the row span * */
040: private int _rowspan = 1;
041:
042: /** the column span * */
043: private int _colspan = 1;
044:
045: /** whether start new row * */
046: private boolean _startRow = false;
047:
048: /** whether end a row * */
049: private boolean _endRow = false;
050:
051: /** the starting x **/
052: private int startX;
053:
054: /** the starting y **/
055: private int startY;
056:
057: /**
058: * Constructor
059: * @param com the component
060: */
061: public ComponentCell(Component com) {
062: _com = com;
063: }
064:
065: /**
066: * Get the column span
067: * @return the column span
068: */
069: public final int getColspan() {
070: return _colspan;
071: }
072:
073: /**
074: * Get the row span
075: * @return the row span
076: */
077: public final int getRowspan() {
078: return _rowspan;
079: }
080:
081: /**
082: * Whether this component starting a new row
083: * @return true if new row
084: */
085: public final boolean isStartRow() {
086: return _startRow;
087: }
088:
089: /**
090: * Set the column span
091: * @param i the column span
092: */
093: public final void setColspan(int i) {
094: _colspan = i;
095: }
096:
097: /**
098: * Set the row span
099: * @param i the row span
100: */
101: public final void setRowspan(int i) {
102: _rowspan = i;
103: }
104:
105: /**
106: * Set whether start a row
107: * @param b true if start a row
108: */
109: public final void setStartRow(boolean b) {
110: _startRow = b;
111: }
112:
113: /**
114: * Get the component
115: * @return the component
116: */
117: public final Component getComponent() {
118: return _com;
119: }
120:
121: /**
122: * {@inheritDoc}
123: */
124: public final String toString() {
125: StringBuffer sb = new StringBuffer();
126: sb.append(getComponent());
127: sb.append("startRow = " + _startRow + " endRow = " + _endRow
128: + " rowspan = " + _rowspan + " colspan = " + _colspan);
129: return sb.toString();
130: }
131:
132: /**
133: * Whether ending a row
134: * @return true if is end row
135: */
136: public final boolean isEndRow() {
137: return _endRow;
138: }
139:
140: /**
141: * Set end row
142: * @param b end row
143: */
144: public final void setEndRow(boolean b) {
145: _endRow = b;
146: }
147:
148: /**
149: * Return the startX
150: * @return the startX.
151: */
152: public final int getStartX() {
153: return startX;
154: }
155:
156: /**
157: * Set the startX
158: * @param startX The startX to set.
159: */
160: public final void setStartX(int startX) {
161: this .startX = startX;
162: }
163:
164: /**
165: * Return the startY
166: * @return the startY.
167: */
168: public final int getStartY() {
169: return startY;
170: }
171:
172: /**
173: * Set the startY
174: * @param startY The startY to set.
175: */
176: public final void setStartY(int startY) {
177: this .startY = startY;
178: }
179:
180: /**
181: * Return the col
182: * @return the col.
183: */
184: public final int getCol() {
185: return _col;
186: }
187:
188: /**
189: * Set the col
190: * @param col The col to set.
191: */
192: public final void setCol(int col) {
193: _col = col;
194: }
195:
196: /**
197: * Return the row
198: * @return the row.
199: */
200: public final int getRow() {
201: return _row;
202: }
203:
204: /**
205: * Set the row
206: * @param row The row to set.
207: */
208: public final void setRow(int row) {
209: _row = row;
210: }
211: }
|