PageRenderTime 77ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/components/forks/poi/src/loci/poi/hssf/record/PaneRecord.java

http://github.com/openmicroscopy/bioformats
Java | 281 lines | 134 code | 46 blank | 101 comment | 2 complexity | b394b1d5fa7c9bc3bd4bf75ee59242f3 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, Apache-2.0, BSD-2-Clause, MPL-2.0-no-copyleft-exception
  1. /*
  2. * #%L
  3. * Fork of Apache Jakarta POI.
  4. * %%
  5. * Copyright (C) 2008 - 2013 Open Microscopy Environment:
  6. * - Board of Regents of the University of Wisconsin-Madison
  7. * - Glencoe Software, Inc.
  8. * - University of Dundee
  9. * %%
  10. * Licensed under the Apache License, Version 2.0 (the "License");
  11. * you may not use this file except in compliance with the License.
  12. * You may obtain a copy of the License at
  13. *
  14. * http://www.apache.org/licenses/LICENSE-2.0
  15. *
  16. * Unless required by applicable law or agreed to in writing, software
  17. * distributed under the License is distributed on an "AS IS" BASIS,
  18. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  19. * See the License for the specific language governing permissions and
  20. * limitations under the License.
  21. * #L%
  22. */
  23. /* ====================================================================
  24. Licensed to the Apache Software Foundation (ASF) under one or more
  25. contributor license agreements. See the NOTICE file distributed with
  26. this work for additional information regarding copyright ownership.
  27. The ASF licenses this file to You under the Apache License, Version 2.0
  28. (the "License"); you may not use this file except in compliance with
  29. the License. You may obtain a copy of the License at
  30. http://www.apache.org/licenses/LICENSE-2.0
  31. Unless required by applicable law or agreed to in writing, software
  32. distributed under the License is distributed on an "AS IS" BASIS,
  33. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  34. See the License for the specific language governing permissions and
  35. limitations under the License.
  36. ==================================================================== */
  37. package loci.poi.hssf.record;
  38. import loci.poi.util.*;
  39. /**
  40. * Describes the frozen and unfozen panes.
  41. * NOTE: This source is automatically generated please do not modify this file. Either subclass or
  42. * remove the record in src/records/definitions.
  43. * @author Glen Stampoultzis (glens at apache.org)
  44. */
  45. public class PaneRecord
  46. extends Record
  47. {
  48. public final static short sid = 0x41;
  49. private short field_1_x;
  50. private short field_2_y;
  51. private short field_3_topRow;
  52. private short field_4_leftColumn;
  53. private short field_5_activePane;
  54. public final static short ACTIVE_PANE_LOWER_RIGHT = 0;
  55. public final static short ACTIVE_PANE_UPPER_RIGHT = 1;
  56. public final static short ACTIVE_PANE_LOWER_LEFT = 2;
  57. public final static short ACTIVE_PANE_UPER_LEFT = 3;
  58. public PaneRecord()
  59. {
  60. }
  61. /**
  62. * Constructs a Pane record and sets its fields appropriately.
  63. *
  64. * @param in the RecordInputstream to read the record from
  65. */
  66. public PaneRecord(RecordInputStream in)
  67. {
  68. super(in);
  69. }
  70. /**
  71. * Checks the sid matches the expected side for this record
  72. *
  73. * @param id the expected sid.
  74. */
  75. protected void validateSid(short id)
  76. {
  77. if (id != sid)
  78. {
  79. throw new RecordFormatException("Not a Pane record");
  80. }
  81. }
  82. protected void fillFields(RecordInputStream in)
  83. {
  84. field_1_x = in.readShort();
  85. field_2_y = in.readShort();
  86. field_3_topRow = in.readShort();
  87. field_4_leftColumn = in.readShort();
  88. field_5_activePane = in.readShort();
  89. }
  90. public String toString()
  91. {
  92. StringBuffer buffer = new StringBuffer();
  93. buffer.append("[PANE]\n");
  94. buffer.append(" .x = ")
  95. .append("0x").append(HexDump.toHex( getX ()))
  96. .append(" (").append( getX() ).append(" )");
  97. buffer.append(System.getProperty("line.separator"));
  98. buffer.append(" .y = ")
  99. .append("0x").append(HexDump.toHex( getY ()))
  100. .append(" (").append( getY() ).append(" )");
  101. buffer.append(System.getProperty("line.separator"));
  102. buffer.append(" .topRow = ")
  103. .append("0x").append(HexDump.toHex( getTopRow ()))
  104. .append(" (").append( getTopRow() ).append(" )");
  105. buffer.append(System.getProperty("line.separator"));
  106. buffer.append(" .leftColumn = ")
  107. .append("0x").append(HexDump.toHex( getLeftColumn ()))
  108. .append(" (").append( getLeftColumn() ).append(" )");
  109. buffer.append(System.getProperty("line.separator"));
  110. buffer.append(" .activePane = ")
  111. .append("0x").append(HexDump.toHex( getActivePane ()))
  112. .append(" (").append( getActivePane() ).append(" )");
  113. buffer.append(System.getProperty("line.separator"));
  114. buffer.append("[/PANE]\n");
  115. return buffer.toString();
  116. }
  117. public int serialize(int offset, byte[] data)
  118. {
  119. int pos = 0;
  120. LittleEndian.putShort(data, 0 + offset, sid);
  121. LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
  122. LittleEndian.putShort(data, 4 + offset + pos, field_1_x);
  123. LittleEndian.putShort(data, 6 + offset + pos, field_2_y);
  124. LittleEndian.putShort(data, 8 + offset + pos, field_3_topRow);
  125. LittleEndian.putShort(data, 10 + offset + pos, field_4_leftColumn);
  126. LittleEndian.putShort(data, 12 + offset + pos, field_5_activePane);
  127. return getRecordSize();
  128. }
  129. /**
  130. * Size of record (exluding 4 byte header)
  131. */
  132. public int getRecordSize()
  133. {
  134. return 4 + 2 + 2 + 2 + 2 + 2;
  135. }
  136. public short getSid()
  137. {
  138. return sid;
  139. }
  140. public Object clone() {
  141. PaneRecord rec = new PaneRecord();
  142. rec.field_1_x = field_1_x;
  143. rec.field_2_y = field_2_y;
  144. rec.field_3_topRow = field_3_topRow;
  145. rec.field_4_leftColumn = field_4_leftColumn;
  146. rec.field_5_activePane = field_5_activePane;
  147. return rec;
  148. }
  149. /**
  150. * Get the x field for the Pane record.
  151. */
  152. public short getX()
  153. {
  154. return field_1_x;
  155. }
  156. /**
  157. * Set the x field for the Pane record.
  158. */
  159. public void setX(short field_1_x)
  160. {
  161. this.field_1_x = field_1_x;
  162. }
  163. /**
  164. * Get the y field for the Pane record.
  165. */
  166. public short getY()
  167. {
  168. return field_2_y;
  169. }
  170. /**
  171. * Set the y field for the Pane record.
  172. */
  173. public void setY(short field_2_y)
  174. {
  175. this.field_2_y = field_2_y;
  176. }
  177. /**
  178. * Get the top row field for the Pane record.
  179. */
  180. public short getTopRow()
  181. {
  182. return field_3_topRow;
  183. }
  184. /**
  185. * Set the top row field for the Pane record.
  186. */
  187. public void setTopRow(short field_3_topRow)
  188. {
  189. this.field_3_topRow = field_3_topRow;
  190. }
  191. /**
  192. * Get the left column field for the Pane record.
  193. */
  194. public short getLeftColumn()
  195. {
  196. return field_4_leftColumn;
  197. }
  198. /**
  199. * Set the left column field for the Pane record.
  200. */
  201. public void setLeftColumn(short field_4_leftColumn)
  202. {
  203. this.field_4_leftColumn = field_4_leftColumn;
  204. }
  205. /**
  206. * Get the active pane field for the Pane record.
  207. *
  208. * @return One of
  209. * ACTIVE_PANE_LOWER_RIGHT
  210. * ACTIVE_PANE_UPPER_RIGHT
  211. * ACTIVE_PANE_LOWER_LEFT
  212. * ACTIVE_PANE_UPER_LEFT
  213. */
  214. public short getActivePane()
  215. {
  216. return field_5_activePane;
  217. }
  218. /**
  219. * Set the active pane field for the Pane record.
  220. *
  221. * @param field_5_activePane
  222. * One of
  223. * ACTIVE_PANE_LOWER_RIGHT
  224. * ACTIVE_PANE_UPPER_RIGHT
  225. * ACTIVE_PANE_LOWER_LEFT
  226. * ACTIVE_PANE_UPER_LEFT
  227. */
  228. public void setActivePane(short field_5_activePane)
  229. {
  230. this.field_5_activePane = field_5_activePane;
  231. }
  232. } // END OF CLASS