]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.spreadsheet.common/src/org/simantics/spreadsheet/common/TableCell.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.spreadsheet.common / src / org / simantics / spreadsheet / common / TableCell.java
diff --git a/bundles/org.simantics.spreadsheet.common/src/org/simantics/spreadsheet/common/TableCell.java b/bundles/org.simantics.spreadsheet.common/src/org/simantics/spreadsheet/common/TableCell.java
new file mode 100644 (file)
index 0000000..89722ab
--- /dev/null
@@ -0,0 +1,176 @@
+/*******************************************************************************\r
+ * Copyright (c) 2013, 2014 Association for Decentralized \r
+ * Information Management in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the THTH Simantics \r
+ * Division Member Component License which accompanies this \r
+ * distribution, and is available at\r
+ * http://www.simantics.org/legal/sdmcl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     Semantum Oy - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.spreadsheet.common;\r
+\r
+import org.simantics.document.server.io.IColor;\r
+import org.simantics.document.server.io.IFont;\r
+import org.simantics.document.server.io.ITableCell;\r
+\r
+public class TableCell implements ITableCell {\r
+\r
+       public int column;\r
+       public int row;\r
+       public int border;\r
+       public int align;\r
+       public String text;\r
+       public IFont font;\r
+       public IColor foreground;\r
+       public IColor background;\r
+       public boolean locked;\r
+       public int rowSpan = 1;\r
+       public int columnSpan = 1;\r
+       \r
+       public TableCell() {\r
+               \r
+       }\r
+\r
+       public TableCell(int column, int row, int border, int align, String text,\r
+                       IFont font, IColor foreground, IColor background, boolean locked,\r
+                       int rowSpan, int columnSpan) {\r
+               super();\r
+               this.column = column;\r
+               this.row = row;\r
+               this.border = border;\r
+               this.align = align;\r
+               this.text = text;\r
+               this.font = font;\r
+               this.foreground = foreground;\r
+               this.background = background;\r
+               this.locked = locked;\r
+               this.rowSpan = rowSpan;\r
+               this.columnSpan = columnSpan;\r
+       }\r
+       \r
+       public TableCell(ITableCell other) {\r
+               this(other.getColumn(), other.getRow(), other.getBorder(), other.getAlign(),\r
+                               other.getText(),other.getFont(), other.getFGColor(), other.getBGColor(),\r
+                               other.getLocked(), other.getRowSpan(), other.getColumnSpan());\r
+       }\r
+       \r
+       @Override\r
+       public String getText() {\r
+               return text;\r
+       }\r
+       @Override\r
+       public int getColumn() {\r
+               return column;\r
+       }\r
+       @Override\r
+       public int getBorder() {\r
+               return border;\r
+       }\r
+       @Override\r
+       public int getAlign() {\r
+               return align;\r
+       }\r
+       @Override\r
+       public int getRow() {\r
+               return row;\r
+       }\r
+       @Override\r
+       public IFont getFont() {\r
+               return font;\r
+       }\r
+\r
+       @Override\r
+       public IColor getFGColor() {\r
+               return foreground;\r
+       }\r
+\r
+       @Override\r
+       public IColor getBGColor() {\r
+               return background;\r
+       }\r
+       \r
+       @Override\r
+       public boolean getLocked() {\r
+               return locked;\r
+       }\r
+       \r
+       @Override\r
+       public int getRowSpan() {\r
+               return rowSpan;\r
+       }\r
+       \r
+       @Override\r
+       public int getColumnSpan() {\r
+               return columnSpan;\r
+       }\r
+       \r
+       @Override\r
+       public int hashCode() {\r
+               final int prime = 31;\r
+               int result = 1;\r
+               result = prime * result + align;\r
+               result = prime * result\r
+                               + ((background == null) ? 0 : background.hashCode());\r
+               result = prime * result + border;\r
+               result = prime * result + column;\r
+               result = prime * result + columnSpan;\r
+               result = prime * result + ((font == null) ? 0 : font.hashCode());\r
+               result = prime * result\r
+                               + ((foreground == null) ? 0 : foreground.hashCode());\r
+               result = prime * result + (locked ? 1231 : 1237);\r
+               result = prime * result + row;\r
+               result = prime * result + rowSpan;\r
+               result = prime * result + ((text == null) ? 0 : text.hashCode());\r
+               return result;\r
+       }\r
+       @Override\r
+       public boolean equals(Object obj) {\r
+               if (this == obj)\r
+                       return true;\r
+               if (obj == null)\r
+                       return false;\r
+               if (getClass() != obj.getClass())\r
+                       return false;\r
+               TableCell other = (TableCell) obj;\r
+               if (align != other.align)\r
+                       return false;\r
+               if (background == null) {\r
+                       if (other.background != null)\r
+                               return false;\r
+               } else if (!background.equals(other.background))\r
+                       return false;\r
+               if (border != other.border)\r
+                       return false;\r
+               if (column != other.column)\r
+                       return false;\r
+               if (columnSpan != other.columnSpan)\r
+                       return false;\r
+               if (font == null) {\r
+                       if (other.font != null)\r
+                               return false;\r
+               } else if (!font.equals(other.font))\r
+                       return false;\r
+               if (foreground == null) {\r
+                       if (other.foreground != null)\r
+                               return false;\r
+               } else if (!foreground.equals(other.foreground))\r
+                       return false;\r
+               if (locked != other.locked)\r
+                       return false;\r
+               if (row != other.row)\r
+                       return false;\r
+               if (rowSpan != other.rowSpan)\r
+                       return false;\r
+               if (text == null) {\r
+                       if (other.text != null)\r
+                               return false;\r
+               } else if (!text.equals(other.text))\r
+                       return false;\r
+               return true;\r
+       }\r
+\r
+       \r
+}\r