]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.spreadsheet.common/src/org/simantics/spreadsheet/common/TableCell.java
ListIndexRoots request
[simantics/platform.git] / bundles / org.simantics.spreadsheet.common / src / org / simantics / spreadsheet / common / TableCell.java
1 /*******************************************************************************
2  * Copyright (c) 2013, 2014 Association for Decentralized 
3  * Information Management in Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the THTH Simantics 
6  * Division Member Component License which accompanies this 
7  * distribution, and is available at
8  * http://www.simantics.org/legal/sdmcl-v10.html
9  *
10  * Contributors:
11  *     Semantum Oy - initial API and implementation
12  *******************************************************************************/
13 package org.simantics.spreadsheet.common;
14
15 import org.simantics.document.server.io.IColor;
16 import org.simantics.document.server.io.IFont;
17 import org.simantics.document.server.io.ITableCell;
18
19 public class TableCell implements ITableCell {
20
21         public int column;
22         public int row;
23         public int border;
24         public int align;
25         public String text;
26         public IFont font;
27         public IColor foreground;
28         public IColor background;
29         public boolean locked;
30         public int rowSpan = 1;
31         public int columnSpan = 1;
32         
33         public TableCell() {
34                 
35         }
36
37         public TableCell(int column, int row, int border, int align, String text,
38                         IFont font, IColor foreground, IColor background, boolean locked,
39                         int rowSpan, int columnSpan) {
40                 super();
41                 this.column = column;
42                 this.row = row;
43                 this.border = border;
44                 this.align = align;
45                 this.text = text;
46                 this.font = font;
47                 this.foreground = foreground;
48                 this.background = background;
49                 this.locked = locked;
50                 this.rowSpan = rowSpan;
51                 this.columnSpan = columnSpan;
52         }
53         
54         public TableCell(ITableCell other) {
55                 this(other.getColumn(), other.getRow(), other.getBorder(), other.getAlign(),
56                                 other.getText(),other.getFont(), other.getFGColor(), other.getBGColor(),
57                                 other.getLocked(), other.getRowSpan(), other.getColumnSpan());
58         }
59         
60         @Override
61         public String getText() {
62                 return text;
63         }
64         @Override
65         public int getColumn() {
66                 return column;
67         }
68         @Override
69         public int getBorder() {
70                 return border;
71         }
72         @Override
73         public int getAlign() {
74                 return align;
75         }
76         @Override
77         public int getRow() {
78                 return row;
79         }
80         @Override
81         public IFont getFont() {
82                 return font;
83         }
84
85         @Override
86         public IColor getFGColor() {
87                 return foreground;
88         }
89
90         @Override
91         public IColor getBGColor() {
92                 return background;
93         }
94         
95         @Override
96         public boolean getLocked() {
97                 return locked;
98         }
99         
100         @Override
101         public int getRowSpan() {
102                 return rowSpan;
103         }
104         
105         @Override
106         public int getColumnSpan() {
107                 return columnSpan;
108         }
109         
110         @Override
111         public int hashCode() {
112                 final int prime = 31;
113                 int result = 1;
114                 result = prime * result + align;
115                 result = prime * result
116                                 + ((background == null) ? 0 : background.hashCode());
117                 result = prime * result + border;
118                 result = prime * result + column;
119                 result = prime * result + columnSpan;
120                 result = prime * result + ((font == null) ? 0 : font.hashCode());
121                 result = prime * result
122                                 + ((foreground == null) ? 0 : foreground.hashCode());
123                 result = prime * result + (locked ? 1231 : 1237);
124                 result = prime * result + row;
125                 result = prime * result + rowSpan;
126                 result = prime * result + ((text == null) ? 0 : text.hashCode());
127                 return result;
128         }
129         @Override
130         public boolean equals(Object obj) {
131                 if (this == obj)
132                         return true;
133                 if (obj == null)
134                         return false;
135                 if (getClass() != obj.getClass())
136                         return false;
137                 TableCell other = (TableCell) obj;
138                 if (align != other.align)
139                         return false;
140                 if (background == null) {
141                         if (other.background != null)
142                                 return false;
143                 } else if (!background.equals(other.background))
144                         return false;
145                 if (border != other.border)
146                         return false;
147                 if (column != other.column)
148                         return false;
149                 if (columnSpan != other.columnSpan)
150                         return false;
151                 if (font == null) {
152                         if (other.font != null)
153                                 return false;
154                 } else if (!font.equals(other.font))
155                         return false;
156                 if (foreground == null) {
157                         if (other.foreground != null)
158                                 return false;
159                 } else if (!foreground.equals(other.foreground))
160                         return false;
161                 if (locked != other.locked)
162                         return false;
163                 if (row != other.row)
164                         return false;
165                 if (rowSpan != other.rowSpan)
166                         return false;
167                 if (text == null) {
168                         if (other.text != null)
169                                 return false;
170                 } else if (!text.equals(other.text))
171                         return false;
172                 return true;
173         }
174
175         
176 }