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