PageRenderTime 65ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

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

http://github.com/openmicroscopy/bioformats
Java | 236 lines | 103 code | 42 blank | 91 comment | 2 complexity | 6b43e315eb6620252c2c36e36cdec9ed 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. * Links text to an object on the chart or identifies it as the title.
  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 Andrew C. Oliver (acoliver at apache.org)
  44. */
  45. public class ObjectLinkRecord
  46. extends Record
  47. {
  48. public final static short sid = 0x1027;
  49. private short field_1_anchorId;
  50. public final static short ANCHOR_ID_CHART_TITLE = 1;
  51. public final static short ANCHOR_ID_Y_AXIS = 2;
  52. public final static short ANCHOR_ID_X_AXIS = 3;
  53. public final static short ANCHOR_ID_SERIES_OR_POINT = 4;
  54. public final static short ANCHOR_ID_Z_AXIS = 7;
  55. private short field_2_link1;
  56. private short field_3_link2;
  57. public ObjectLinkRecord()
  58. {
  59. }
  60. /**
  61. * Constructs a ObjectLink record and sets its fields appropriately.
  62. *
  63. * @param in the RecordInputstream to read the record from
  64. */
  65. public ObjectLinkRecord(RecordInputStream in)
  66. {
  67. super(in);
  68. }
  69. /**
  70. * Checks the sid matches the expected side for this record
  71. *
  72. * @param id the expected sid.
  73. */
  74. protected void validateSid(short id)
  75. {
  76. if (id != sid)
  77. {
  78. throw new RecordFormatException("Not a ObjectLink record");
  79. }
  80. }
  81. protected void fillFields(RecordInputStream in)
  82. {
  83. field_1_anchorId = in.readShort();
  84. field_2_link1 = in.readShort();
  85. field_3_link2 = in.readShort();
  86. }
  87. public String toString()
  88. {
  89. StringBuffer buffer = new StringBuffer();
  90. buffer.append("[OBJECTLINK]\n");
  91. buffer.append(" .anchorId = ")
  92. .append("0x").append(HexDump.toHex( getAnchorId ()))
  93. .append(" (").append( getAnchorId() ).append(" )");
  94. buffer.append(System.getProperty("line.separator"));
  95. buffer.append(" .link1 = ")
  96. .append("0x").append(HexDump.toHex( getLink1 ()))
  97. .append(" (").append( getLink1() ).append(" )");
  98. buffer.append(System.getProperty("line.separator"));
  99. buffer.append(" .link2 = ")
  100. .append("0x").append(HexDump.toHex( getLink2 ()))
  101. .append(" (").append( getLink2() ).append(" )");
  102. buffer.append(System.getProperty("line.separator"));
  103. buffer.append("[/OBJECTLINK]\n");
  104. return buffer.toString();
  105. }
  106. public int serialize(int offset, byte[] data)
  107. {
  108. int pos = 0;
  109. LittleEndian.putShort(data, 0 + offset, sid);
  110. LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
  111. LittleEndian.putShort(data, 4 + offset + pos, field_1_anchorId);
  112. LittleEndian.putShort(data, 6 + offset + pos, field_2_link1);
  113. LittleEndian.putShort(data, 8 + offset + pos, field_3_link2);
  114. return getRecordSize();
  115. }
  116. /**
  117. * Size of record (exluding 4 byte header)
  118. */
  119. public int getRecordSize()
  120. {
  121. return 4 + 2 + 2 + 2;
  122. }
  123. public short getSid()
  124. {
  125. return sid;
  126. }
  127. public Object clone() {
  128. ObjectLinkRecord rec = new ObjectLinkRecord();
  129. rec.field_1_anchorId = field_1_anchorId;
  130. rec.field_2_link1 = field_2_link1;
  131. rec.field_3_link2 = field_3_link2;
  132. return rec;
  133. }
  134. /**
  135. * Get the anchor id field for the ObjectLink record.
  136. *
  137. * @return One of
  138. * ANCHOR_ID_CHART_TITLE
  139. * ANCHOR_ID_Y_AXIS
  140. * ANCHOR_ID_X_AXIS
  141. * ANCHOR_ID_SERIES_OR_POINT
  142. * ANCHOR_ID_Z_AXIS
  143. */
  144. public short getAnchorId()
  145. {
  146. return field_1_anchorId;
  147. }
  148. /**
  149. * Set the anchor id field for the ObjectLink record.
  150. *
  151. * @param field_1_anchorId
  152. * One of
  153. * ANCHOR_ID_CHART_TITLE
  154. * ANCHOR_ID_Y_AXIS
  155. * ANCHOR_ID_X_AXIS
  156. * ANCHOR_ID_SERIES_OR_POINT
  157. * ANCHOR_ID_Z_AXIS
  158. */
  159. public void setAnchorId(short field_1_anchorId)
  160. {
  161. this.field_1_anchorId = field_1_anchorId;
  162. }
  163. /**
  164. * Get the link 1 field for the ObjectLink record.
  165. */
  166. public short getLink1()
  167. {
  168. return field_2_link1;
  169. }
  170. /**
  171. * Set the link 1 field for the ObjectLink record.
  172. */
  173. public void setLink1(short field_2_link1)
  174. {
  175. this.field_2_link1 = field_2_link1;
  176. }
  177. /**
  178. * Get the link 2 field for the ObjectLink record.
  179. */
  180. public short getLink2()
  181. {
  182. return field_3_link2;
  183. }
  184. /**
  185. * Set the link 2 field for the ObjectLink record.
  186. */
  187. public void setLink2(short field_3_link2)
  188. {
  189. this.field_3_link2 = field_3_link2;
  190. }
  191. } // END OF CLASS