001: /* SwingML
002: * Copyright (C) 2002 Robert Morris.
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 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
016: * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
017: * Boston, MA 02111-1307, USA.
018: *
019: * Authors:
020: * Robert Morris <robertj@morris.net>
021: *
022: */
023:
024: package org.swingml.model;
025:
026: import java.awt.*;
027: import java.util.*;
028: import java.util.List;
029:
030: /**
031: * This class contains the settings and some utility methods that describe the
032: * data passed in from the SwingML document and should therefore be provided
033: * to a GridBagCellComponent object.
034: *
035: * @see org.swingml.component.GridBagCellComponent
036: */
037: public class GridBagCellModel extends GridBagBaseModel {
038:
039: private Vector m_children = null;
040: private int m_column = -1;
041: private int m_row = -1;
042:
043: public GridBagCellModel() {
044: super ();
045: }
046:
047: /**
048: * @see swingml.model.ContainerModel#addChild(Object)
049: */
050: public void addChild(Object anObject) {
051: this .getChildren().add(anObject);
052: }
053:
054: /**
055: * @see swingml.model.ContainerModel#getChildren()
056: */
057: public List getChildren() {
058: if (this .m_children == null) {
059: this .m_children = new Vector();
060: }
061: return this .m_children;
062: }
063:
064: /**
065: * Retrieves a valid instance of the @see java.awt.GridBagConstraints
066: * class. This GridBagConstaints instance is applied to all components
067: * in the Vector returned by the getChildren() method.
068: */
069: public GridBagConstraints getConstraints() {
070: GridBagConstraints theCon = super .getConstraints();
071: theCon.gridy = this .m_row;
072: theCon.gridx = this .m_column;
073:
074: return theCon;
075: }
076:
077: /**
078: * @see swingml.model.ContainerModel#getLayout()
079: */
080: public String getLayout() {
081: return null;
082: }
083:
084: /**
085: * Sets the horizontal space within a GridBagLayout to place all contained components.
086: *
087: * @param column The horizontal coordinate within the GridBagLayout to place all
088: * contained components.
089: */
090: public void setColumn(int aColumn) {
091: this .m_column = aColumn;
092: }
093:
094: /**
095: * Sets the vertical space within a GridBagLayout to place all contained components.
096: *
097: * @param row The vertical coordinate within the GridBagLayout to place all contained
098: * components.
099: */
100: public void setRow(int aRow) {
101: this .m_row = aRow;
102: }
103:
104: /**
105: * @see org.swingml.SwingMLModel#validate()
106: */
107: public void validate() {
108: super.validate();
109: }
110: }
|