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

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

http://github.com/openmicroscopy/bioformats
Java | 295 lines | 138 code | 49 blank | 108 comment | 2 complexity | 69234ab0f89a1423014b59939498f118 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 bar record is used to define a bar 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 BarRecord
  46. extends Record
  47. {
  48. public final static short sid = 0x1017;
  49. private short field_1_barSpace;
  50. private short field_2_categorySpace;
  51. private short field_3_formatFlags;
  52. private BitField horizontal = BitFieldFactory.getInstance(0x1);
  53. private BitField stacked = BitFieldFactory.getInstance(0x2);
  54. private BitField displayAsPercentage = BitFieldFactory.getInstance(0x4);
  55. private BitField shadow = BitFieldFactory.getInstance(0x8);
  56. public BarRecord()
  57. {
  58. }
  59. /**
  60. * Constructs a Bar record and sets its fields appropriately.
  61. *
  62. * @param in the RecordInputstream to read the record from
  63. */
  64. public BarRecord(RecordInputStream in)
  65. {
  66. super(in);
  67. }
  68. /**
  69. * Checks the sid matches the expected side for this record
  70. *
  71. * @param id the expected sid.
  72. */
  73. protected void validateSid(short id)
  74. {
  75. if (id != sid)
  76. {
  77. throw new RecordFormatException("Not a Bar record");
  78. }
  79. }
  80. protected void fillFields(RecordInputStream in)
  81. {
  82. field_1_barSpace = in.readShort();
  83. field_2_categorySpace = in.readShort();
  84. field_3_formatFlags = in.readShort();
  85. }
  86. public String toString()
  87. {
  88. StringBuffer buffer = new StringBuffer();
  89. buffer.append("[BAR]\n");
  90. buffer.append(" .barSpace = ")
  91. .append("0x").append(HexDump.toHex( getBarSpace ()))
  92. .append(" (").append( getBarSpace() ).append(" )");
  93. buffer.append(System.getProperty("line.separator"));
  94. buffer.append(" .categorySpace = ")
  95. .append("0x").append(HexDump.toHex( getCategorySpace ()))
  96. .append(" (").append( getCategorySpace() ).append(" )");
  97. buffer.append(System.getProperty("line.separator"));
  98. buffer.append(" .formatFlags = ")
  99. .append("0x").append(HexDump.toHex( getFormatFlags ()))
  100. .append(" (").append( getFormatFlags() ).append(" )");
  101. buffer.append(System.getProperty("line.separator"));
  102. buffer.append(" .horizontal = ").append(isHorizontal()).append('\n');
  103. buffer.append(" .stacked = ").append(isStacked()).append('\n');
  104. buffer.append(" .displayAsPercentage = ").append(isDisplayAsPercentage()).append('\n');
  105. buffer.append(" .shadow = ").append(isShadow()).append('\n');
  106. buffer.append("[/BAR]\n");
  107. return buffer.toString();
  108. }
  109. public int serialize(int offset, byte[] data)
  110. {
  111. int pos = 0;
  112. LittleEndian.putShort(data, 0 + offset, sid);
  113. LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
  114. LittleEndian.putShort(data, 4 + offset + pos, field_1_barSpace);
  115. LittleEndian.putShort(data, 6 + offset + pos, field_2_categorySpace);
  116. LittleEndian.putShort(data, 8 + offset + pos, field_3_formatFlags);
  117. return getRecordSize();
  118. }
  119. /**
  120. * Size of record (exluding 4 byte header)
  121. */
  122. public int getRecordSize()
  123. {
  124. return 4 + 2 + 2 + 2;
  125. }
  126. public short getSid()
  127. {
  128. return sid;
  129. }
  130. public Object clone() {
  131. BarRecord rec = new BarRecord();
  132. rec.field_1_barSpace = field_1_barSpace;
  133. rec.field_2_categorySpace = field_2_categorySpace;
  134. rec.field_3_formatFlags = field_3_formatFlags;
  135. return rec;
  136. }
  137. /**
  138. * Get the bar space field for the Bar record.
  139. */
  140. public short getBarSpace()
  141. {
  142. return field_1_barSpace;
  143. }
  144. /**
  145. * Set the bar space field for the Bar record.
  146. */
  147. public void setBarSpace(short field_1_barSpace)
  148. {
  149. this.field_1_barSpace = field_1_barSpace;
  150. }
  151. /**
  152. * Get the category space field for the Bar record.
  153. */
  154. public short getCategorySpace()
  155. {
  156. return field_2_categorySpace;
  157. }
  158. /**
  159. * Set the category space field for the Bar record.
  160. */
  161. public void setCategorySpace(short field_2_categorySpace)
  162. {
  163. this.field_2_categorySpace = field_2_categorySpace;
  164. }
  165. /**
  166. * Get the format flags field for the Bar record.
  167. */
  168. public short getFormatFlags()
  169. {
  170. return field_3_formatFlags;
  171. }
  172. /**
  173. * Set the format flags field for the Bar record.
  174. */
  175. public void setFormatFlags(short field_3_formatFlags)
  176. {
  177. this.field_3_formatFlags = field_3_formatFlags;
  178. }
  179. /**
  180. * Sets the horizontal field value.
  181. * true to display horizontal bar charts, false for vertical
  182. */
  183. public void setHorizontal(boolean value)
  184. {
  185. field_3_formatFlags = horizontal.setShortBoolean(field_3_formatFlags, value);
  186. }
  187. /**
  188. * true to display horizontal bar charts, false for vertical
  189. * @return the horizontal field value.
  190. */
  191. public boolean isHorizontal()
  192. {
  193. return horizontal.isSet(field_3_formatFlags);
  194. }
  195. /**
  196. * Sets the stacked field value.
  197. * stack displayed values
  198. */
  199. public void setStacked(boolean value)
  200. {
  201. field_3_formatFlags = stacked.setShortBoolean(field_3_formatFlags, value);
  202. }
  203. /**
  204. * stack displayed values
  205. * @return the stacked field value.
  206. */
  207. public boolean isStacked()
  208. {
  209. return stacked.isSet(field_3_formatFlags);
  210. }
  211. /**
  212. * Sets the display as percentage field value.
  213. * display chart values as a percentage
  214. */
  215. public void setDisplayAsPercentage(boolean value)
  216. {
  217. field_3_formatFlags = displayAsPercentage.setShortBoolean(field_3_formatFlags, value);
  218. }
  219. /**
  220. * display chart values as a percentage
  221. * @return the display as percentage field value.
  222. */
  223. public boolean isDisplayAsPercentage()
  224. {
  225. return displayAsPercentage.isSet(field_3_formatFlags);
  226. }
  227. /**
  228. * Sets the shadow field value.
  229. * display a shadow for the chart
  230. */
  231. public void setShadow(boolean value)
  232. {
  233. field_3_formatFlags = shadow.setShortBoolean(field_3_formatFlags, value);
  234. }
  235. /**
  236. * display a shadow for the chart
  237. * @return the shadow field value.
  238. */
  239. public boolean isShadow()
  240. {
  241. return shadow.isSet(field_3_formatFlags);
  242. }
  243. } // END OF CLASS