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