PageRenderTime 368ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

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

http://github.com/openmicroscopy/bioformats
Java | 239 lines | 114 code | 43 blank | 82 comment | 2 complexity | 39d4d226beb8a7d0ca3e3036ccaefefa 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. * The chart record is used to define the location and size of a chart.
  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 ChartRecord
  46. extends Record
  47. {
  48. public final static short sid = 0x1002;
  49. private int field_1_x;
  50. private int field_2_y;
  51. private int field_3_width;
  52. private int field_4_height;
  53. public ChartRecord()
  54. {
  55. }
  56. /**
  57. * Constructs a Chart record and sets its fields appropriately.
  58. *
  59. * @param in the RecordInputstream to read the record from
  60. */
  61. public ChartRecord(RecordInputStream in)
  62. {
  63. super(in);
  64. }
  65. /**
  66. * Checks the sid matches the expected side for this record
  67. *
  68. * @param id the expected sid.
  69. */
  70. protected void validateSid(short id)
  71. {
  72. if (id != sid)
  73. {
  74. throw new RecordFormatException("Not a Chart record");
  75. }
  76. }
  77. protected void fillFields(RecordInputStream in)
  78. {
  79. field_1_x = in.readInt();
  80. field_2_y = in.readInt();
  81. field_3_width = in.readInt();
  82. field_4_height = in.readInt();
  83. }
  84. public String toString()
  85. {
  86. StringBuffer buffer = new StringBuffer();
  87. buffer.append("[CHART]\n");
  88. buffer.append(" .x = ")
  89. .append("0x").append(HexDump.toHex( getX ()))
  90. .append(" (").append( getX() ).append(" )");
  91. buffer.append(System.getProperty("line.separator"));
  92. buffer.append(" .y = ")
  93. .append("0x").append(HexDump.toHex( getY ()))
  94. .append(" (").append( getY() ).append(" )");
  95. buffer.append(System.getProperty("line.separator"));
  96. buffer.append(" .width = ")
  97. .append("0x").append(HexDump.toHex( getWidth ()))
  98. .append(" (").append( getWidth() ).append(" )");
  99. buffer.append(System.getProperty("line.separator"));
  100. buffer.append(" .height = ")
  101. .append("0x").append(HexDump.toHex( getHeight ()))
  102. .append(" (").append( getHeight() ).append(" )");
  103. buffer.append(System.getProperty("line.separator"));
  104. buffer.append("[/CHART]\n");
  105. return buffer.toString();
  106. }
  107. public int serialize(int offset, byte[] data)
  108. {
  109. int pos = 0;
  110. LittleEndian.putShort(data, 0 + offset, sid);
  111. LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
  112. LittleEndian.putInt(data, 4 + offset + pos, field_1_x);
  113. LittleEndian.putInt(data, 8 + offset + pos, field_2_y);
  114. LittleEndian.putInt(data, 12 + offset + pos, field_3_width);
  115. LittleEndian.putInt(data, 16 + offset + pos, field_4_height);
  116. return getRecordSize();
  117. }
  118. /**
  119. * Size of record (exluding 4 byte header)
  120. */
  121. public int getRecordSize()
  122. {
  123. return 4 + 4 + 4 + 4 + 4;
  124. }
  125. public short getSid()
  126. {
  127. return sid;
  128. }
  129. public Object clone() {
  130. ChartRecord rec = new ChartRecord();
  131. rec.field_1_x = field_1_x;
  132. rec.field_2_y = field_2_y;
  133. rec.field_3_width = field_3_width;
  134. rec.field_4_height = field_4_height;
  135. return rec;
  136. }
  137. /**
  138. * Get the x field for the Chart record.
  139. */
  140. public int getX()
  141. {
  142. return field_1_x;
  143. }
  144. /**
  145. * Set the x field for the Chart record.
  146. */
  147. public void setX(int field_1_x)
  148. {
  149. this.field_1_x = field_1_x;
  150. }
  151. /**
  152. * Get the y field for the Chart record.
  153. */
  154. public int getY()
  155. {
  156. return field_2_y;
  157. }
  158. /**
  159. * Set the y field for the Chart record.
  160. */
  161. public void setY(int field_2_y)
  162. {
  163. this.field_2_y = field_2_y;
  164. }
  165. /**
  166. * Get the width field for the Chart record.
  167. */
  168. public int getWidth()
  169. {
  170. return field_3_width;
  171. }
  172. /**
  173. * Set the width field for the Chart record.
  174. */
  175. public void setWidth(int field_3_width)
  176. {
  177. this.field_3_width = field_3_width;
  178. }
  179. /**
  180. * Get the height field for the Chart record.
  181. */
  182. public int getHeight()
  183. {
  184. return field_4_height;
  185. }
  186. /**
  187. * Set the height field for the Chart record.
  188. */
  189. public void setHeight(int field_4_height)
  190. {
  191. this.field_4_height = field_4_height;
  192. }
  193. } // END OF CLASS