KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > compiere > apps > ALayoutConstraint


1 /******************************************************************************
2  * The contents of this file are subject to the Compiere License Version 1.1
3  * ("License"); You may not use this file except in compliance with the License
4  * You may obtain a copy of the License at http://www.compiere.org/license.html
5  * Software distributed under the License is distributed on an "AS IS" basis,
6  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
7  * the specific language governing rights and limitations under the License.
8  * The Original Code is Compiere ERP & CRM Business Solution
9  * The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
10  * Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke, parts
11  * created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
12  * Contributor(s): ______________________________________.
13  *****************************************************************************/

14 package org.compiere.apps;
15
16 import org.compiere.util.Log;
17
18 /**
19  * Application Layout Constraint to indicate grid position (immutable)
20  *
21  * @author Jorg Janke
22  * @version $Id: ALayoutConstraint.java,v 1.4 2003/10/10 00:59:46 jjanke Exp $
23  */

24 public class ALayoutConstraint implements Comparable JavaDoc
25 {
26     /**
27      * Layout Constraint to indicate grid position
28      * @param row row 0..x
29      * @param col column 0..x
30      */

31     public ALayoutConstraint(int row, int col)
32     {
33         m_row = row;
34         m_col = col;
35     } // ALayoutConstraint
36

37     /**
38      * Create Next in Row
39      * @return ALayoutConstraint for additional column in same row
40      */

41     public ALayoutConstraint createNext()
42     {
43         return new ALayoutConstraint(m_row, m_col+1);
44     } // createNext
45

46     private int m_row;
47     private int m_col;
48
49     /**
50      * Get Row
51      * @return roe no
52      */

53     public int getRow()
54     {
55         return m_row;
56     } // getRow
57

58     /**
59      * Get Column
60      * @return col no
61      */

62     public int getCol()
63     {
64         return m_col;
65     } // getCol
66

67     /**
68      * Compares this object with the specified object for order. Returns a
69      * negative integer, zero, or a positive integer as this object is less
70      * than, equal to, or greater than the specified object.<p>
71      *
72      * @param o the Object to be compared.
73      * @return a negative integer if this object is less than the specified object,
74      * zero if equal,
75      * or a positive integer if this object is greater than the specified object.
76      */

77     public int compareTo(Object JavaDoc o)
78     {
79         ALayoutConstraint comp = null;
80         if (o instanceof ALayoutConstraint)
81             comp = (ALayoutConstraint)o;
82         if (comp == null)
83             return +111;
84
85         // Row compare
86
int rowComp = m_row - comp.getRow();
87         if (rowComp != 0)
88             return rowComp;
89         // Column compare
90
return m_col - comp.getCol();
91     } // compareTo
92

93     /**
94      * Is Object Equal
95      * @param o
96      * @return true if equal
97      */

98     public boolean equals(Object JavaDoc o)
99     {
100         if (o instanceof ALayoutConstraint)
101             return compareTo(o) == 0;
102         return false;
103     } // equal
104

105     /**
106      * To String
107      * @return info
108      */

109     public String JavaDoc toString()
110     {
111         return "ALayoutConstraint [Row=" + m_row + ", Col=" + m_col + "]";
112     } // toString
113

114 } // ALayoutConstraint
115
Popular Tags