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
11 * Semantum Oy - initial API and implementation
12 *******************************************************************************/
13 package org.simantics.spreadsheet.common;
15 import org.simantics.document.server.io.IColor;
16 import org.simantics.document.server.io.IFont;
17 import org.simantics.document.server.io.ITableCell;
19 public class TableCell implements ITableCell {
27 public IColor foreground;
28 public IColor background;
29 public boolean locked;
30 public int rowSpan = 1;
31 public int columnSpan = 1;
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) {
47 this.foreground = foreground;
48 this.background = background;
50 this.rowSpan = rowSpan;
51 this.columnSpan = columnSpan;
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());
61 public String getText() {
65 public int getColumn() {
69 public int getBorder() {
73 public int getAlign() {
81 public IFont getFont() {
86 public IColor getFGColor() {
91 public IColor getBGColor() {
96 public boolean getLocked() {
101 public int getRowSpan() {
106 public int getColumnSpan() {
111 public int hashCode() {
112 final int prime = 31;
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());
130 public boolean equals(Object obj) {
135 if (getClass() != obj.getClass())
137 TableCell other = (TableCell) obj;
138 if (align != other.align)
140 if (background == null) {
141 if (other.background != null)
143 } else if (!background.equals(other.background))
145 if (border != other.border)
147 if (column != other.column)
149 if (columnSpan != other.columnSpan)
152 if (other.font != null)
154 } else if (!font.equals(other.font))
156 if (foreground == null) {
157 if (other.foreground != null)
159 } else if (!foreground.equals(other.foreground))
161 if (locked != other.locked)
163 if (row != other.row)
165 if (rowSpan != other.rowSpan)
168 if (other.text != null)
170 } else if (!text.equals(other.text))