PageRenderTime 68ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

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

http://github.com/openmicroscopy/bioformats
Java | 468 lines | 231 code | 61 blank | 176 comment | 2 complexity | f830119a54fbded3cacdc1c72a3a308d 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. * Defines a legend for 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 Andrew C. Oliver (acoliver at apache.org)
  44. */
  45. public class LegendRecord
  46. extends Record
  47. {
  48. public final static short sid = 0x1015;
  49. private int field_1_xAxisUpperLeft;
  50. private int field_2_yAxisUpperLeft;
  51. private int field_3_xSize;
  52. private int field_4_ySize;
  53. private byte field_5_type;
  54. public final static byte TYPE_BOTTOM = 0;
  55. public final static byte TYPE_CORNER = 1;
  56. public final static byte TYPE_TOP = 2;
  57. public final static byte TYPE_RIGHT = 3;
  58. public final static byte TYPE_LEFT = 4;
  59. public final static byte TYPE_UNDOCKED = 7;
  60. private byte field_6_spacing;
  61. public final static byte SPACING_CLOSE = 0;
  62. public final static byte SPACING_MEDIUM = 1;
  63. public final static byte SPACING_OPEN = 2;
  64. private short field_7_options;
  65. private BitField autoPosition = BitFieldFactory.getInstance(0x1);
  66. private BitField autoSeries = BitFieldFactory.getInstance(0x2);
  67. private BitField autoXPositioning = BitFieldFactory.getInstance(0x4);
  68. private BitField autoYPositioning = BitFieldFactory.getInstance(0x8);
  69. private BitField vertical = BitFieldFactory.getInstance(0x10);
  70. private BitField dataTable = BitFieldFactory.getInstance(0x20);
  71. public LegendRecord()
  72. {
  73. }
  74. /**
  75. * Constructs a Legend record and sets its fields appropriately.
  76. *
  77. * @param in the RecordInputstream to read the record from
  78. */
  79. public LegendRecord(RecordInputStream in)
  80. {
  81. super(in);
  82. }
  83. /**
  84. * Checks the sid matches the expected side for this record
  85. *
  86. * @param id the expected sid.
  87. */
  88. protected void validateSid(short id)
  89. {
  90. if (id != sid)
  91. {
  92. throw new RecordFormatException("Not a Legend record");
  93. }
  94. }
  95. protected void fillFields(RecordInputStream in)
  96. {
  97. field_1_xAxisUpperLeft = in.readInt();
  98. field_2_yAxisUpperLeft = in.readInt();
  99. field_3_xSize = in.readInt();
  100. field_4_ySize = in.readInt();
  101. field_5_type = in.readByte();
  102. field_6_spacing = in.readByte();
  103. field_7_options = in.readShort();
  104. }
  105. public String toString()
  106. {
  107. StringBuffer buffer = new StringBuffer();
  108. buffer.append("[LEGEND]\n");
  109. buffer.append(" .xAxisUpperLeft = ")
  110. .append("0x").append(HexDump.toHex( getXAxisUpperLeft ()))
  111. .append(" (").append( getXAxisUpperLeft() ).append(" )");
  112. buffer.append(System.getProperty("line.separator"));
  113. buffer.append(" .yAxisUpperLeft = ")
  114. .append("0x").append(HexDump.toHex( getYAxisUpperLeft ()))
  115. .append(" (").append( getYAxisUpperLeft() ).append(" )");
  116. buffer.append(System.getProperty("line.separator"));
  117. buffer.append(" .xSize = ")
  118. .append("0x").append(HexDump.toHex( getXSize ()))
  119. .append(" (").append( getXSize() ).append(" )");
  120. buffer.append(System.getProperty("line.separator"));
  121. buffer.append(" .ySize = ")
  122. .append("0x").append(HexDump.toHex( getYSize ()))
  123. .append(" (").append( getYSize() ).append(" )");
  124. buffer.append(System.getProperty("line.separator"));
  125. buffer.append(" .type = ")
  126. .append("0x").append(HexDump.toHex( getType ()))
  127. .append(" (").append( getType() ).append(" )");
  128. buffer.append(System.getProperty("line.separator"));
  129. buffer.append(" .spacing = ")
  130. .append("0x").append(HexDump.toHex( getSpacing ()))
  131. .append(" (").append( getSpacing() ).append(" )");
  132. buffer.append(System.getProperty("line.separator"));
  133. buffer.append(" .options = ")
  134. .append("0x").append(HexDump.toHex( getOptions ()))
  135. .append(" (").append( getOptions() ).append(" )");
  136. buffer.append(System.getProperty("line.separator"));
  137. buffer.append(" .autoPosition = ").append(isAutoPosition()).append('\n');
  138. buffer.append(" .autoSeries = ").append(isAutoSeries()).append('\n');
  139. buffer.append(" .autoXPositioning = ").append(isAutoXPositioning()).append('\n');
  140. buffer.append(" .autoYPositioning = ").append(isAutoYPositioning()).append('\n');
  141. buffer.append(" .vertical = ").append(isVertical()).append('\n');
  142. buffer.append(" .dataTable = ").append(isDataTable()).append('\n');
  143. buffer.append("[/LEGEND]\n");
  144. return buffer.toString();
  145. }
  146. public int serialize(int offset, byte[] data)
  147. {
  148. int pos = 0;
  149. LittleEndian.putShort(data, 0 + offset, sid);
  150. LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
  151. LittleEndian.putInt(data, 4 + offset + pos, field_1_xAxisUpperLeft);
  152. LittleEndian.putInt(data, 8 + offset + pos, field_2_yAxisUpperLeft);
  153. LittleEndian.putInt(data, 12 + offset + pos, field_3_xSize);
  154. LittleEndian.putInt(data, 16 + offset + pos, field_4_ySize);
  155. data[ 20 + offset + pos ] = field_5_type;
  156. data[ 21 + offset + pos ] = field_6_spacing;
  157. LittleEndian.putShort(data, 22 + offset + pos, field_7_options);
  158. return getRecordSize();
  159. }
  160. /**
  161. * Size of record (exluding 4 byte header)
  162. */
  163. public int getRecordSize()
  164. {
  165. return 4 + 4 + 4 + 4 + 4 + 1 + 1 + 2;
  166. }
  167. public short getSid()
  168. {
  169. return sid;
  170. }
  171. public Object clone() {
  172. LegendRecord rec = new LegendRecord();
  173. rec.field_1_xAxisUpperLeft = field_1_xAxisUpperLeft;
  174. rec.field_2_yAxisUpperLeft = field_2_yAxisUpperLeft;
  175. rec.field_3_xSize = field_3_xSize;
  176. rec.field_4_ySize = field_4_ySize;
  177. rec.field_5_type = field_5_type;
  178. rec.field_6_spacing = field_6_spacing;
  179. rec.field_7_options = field_7_options;
  180. return rec;
  181. }
  182. /**
  183. * Get the x axis upper left field for the Legend record.
  184. */
  185. public int getXAxisUpperLeft()
  186. {
  187. return field_1_xAxisUpperLeft;
  188. }
  189. /**
  190. * Set the x axis upper left field for the Legend record.
  191. */
  192. public void setXAxisUpperLeft(int field_1_xAxisUpperLeft)
  193. {
  194. this.field_1_xAxisUpperLeft = field_1_xAxisUpperLeft;
  195. }
  196. /**
  197. * Get the y axis upper left field for the Legend record.
  198. */
  199. public int getYAxisUpperLeft()
  200. {
  201. return field_2_yAxisUpperLeft;
  202. }
  203. /**
  204. * Set the y axis upper left field for the Legend record.
  205. */
  206. public void setYAxisUpperLeft(int field_2_yAxisUpperLeft)
  207. {
  208. this.field_2_yAxisUpperLeft = field_2_yAxisUpperLeft;
  209. }
  210. /**
  211. * Get the x size field for the Legend record.
  212. */
  213. public int getXSize()
  214. {
  215. return field_3_xSize;
  216. }
  217. /**
  218. * Set the x size field for the Legend record.
  219. */
  220. public void setXSize(int field_3_xSize)
  221. {
  222. this.field_3_xSize = field_3_xSize;
  223. }
  224. /**
  225. * Get the y size field for the Legend record.
  226. */
  227. public int getYSize()
  228. {
  229. return field_4_ySize;
  230. }
  231. /**
  232. * Set the y size field for the Legend record.
  233. */
  234. public void setYSize(int field_4_ySize)
  235. {
  236. this.field_4_ySize = field_4_ySize;
  237. }
  238. /**
  239. * Get the type field for the Legend record.
  240. *
  241. * @return One of
  242. * TYPE_BOTTOM
  243. * TYPE_CORNER
  244. * TYPE_TOP
  245. * TYPE_RIGHT
  246. * TYPE_LEFT
  247. * TYPE_UNDOCKED
  248. */
  249. public byte getType()
  250. {
  251. return field_5_type;
  252. }
  253. /**
  254. * Set the type field for the Legend record.
  255. *
  256. * @param field_5_type
  257. * One of
  258. * TYPE_BOTTOM
  259. * TYPE_CORNER
  260. * TYPE_TOP
  261. * TYPE_RIGHT
  262. * TYPE_LEFT
  263. * TYPE_UNDOCKED
  264. */
  265. public void setType(byte field_5_type)
  266. {
  267. this.field_5_type = field_5_type;
  268. }
  269. /**
  270. * Get the spacing field for the Legend record.
  271. *
  272. * @return One of
  273. * SPACING_CLOSE
  274. * SPACING_MEDIUM
  275. * SPACING_OPEN
  276. */
  277. public byte getSpacing()
  278. {
  279. return field_6_spacing;
  280. }
  281. /**
  282. * Set the spacing field for the Legend record.
  283. *
  284. * @param field_6_spacing
  285. * One of
  286. * SPACING_CLOSE
  287. * SPACING_MEDIUM
  288. * SPACING_OPEN
  289. */
  290. public void setSpacing(byte field_6_spacing)
  291. {
  292. this.field_6_spacing = field_6_spacing;
  293. }
  294. /**
  295. * Get the options field for the Legend record.
  296. */
  297. public short getOptions()
  298. {
  299. return field_7_options;
  300. }
  301. /**
  302. * Set the options field for the Legend record.
  303. */
  304. public void setOptions(short field_7_options)
  305. {
  306. this.field_7_options = field_7_options;
  307. }
  308. /**
  309. * Sets the auto position field value.
  310. * automatic positioning (1=docked)
  311. */
  312. public void setAutoPosition(boolean value)
  313. {
  314. field_7_options = autoPosition.setShortBoolean(field_7_options, value);
  315. }
  316. /**
  317. * automatic positioning (1=docked)
  318. * @return the auto position field value.
  319. */
  320. public boolean isAutoPosition()
  321. {
  322. return autoPosition.isSet(field_7_options);
  323. }
  324. /**
  325. * Sets the auto series field value.
  326. * excel 5 only (true)
  327. */
  328. public void setAutoSeries(boolean value)
  329. {
  330. field_7_options = autoSeries.setShortBoolean(field_7_options, value);
  331. }
  332. /**
  333. * excel 5 only (true)
  334. * @return the auto series field value.
  335. */
  336. public boolean isAutoSeries()
  337. {
  338. return autoSeries.isSet(field_7_options);
  339. }
  340. /**
  341. * Sets the auto x positioning field value.
  342. * position of legend on the x axis is automatic
  343. */
  344. public void setAutoXPositioning(boolean value)
  345. {
  346. field_7_options = autoXPositioning.setShortBoolean(field_7_options, value);
  347. }
  348. /**
  349. * position of legend on the x axis is automatic
  350. * @return the auto x positioning field value.
  351. */
  352. public boolean isAutoXPositioning()
  353. {
  354. return autoXPositioning.isSet(field_7_options);
  355. }
  356. /**
  357. * Sets the auto y positioning field value.
  358. * position of legend on the y axis is automatic
  359. */
  360. public void setAutoYPositioning(boolean value)
  361. {
  362. field_7_options = autoYPositioning.setShortBoolean(field_7_options, value);
  363. }
  364. /**
  365. * position of legend on the y axis is automatic
  366. * @return the auto y positioning field value.
  367. */
  368. public boolean isAutoYPositioning()
  369. {
  370. return autoYPositioning.isSet(field_7_options);
  371. }
  372. /**
  373. * Sets the vertical field value.
  374. * vertical or horizontal legend (1 or 0 respectively). Always 0 if not automatic.
  375. */
  376. public void setVertical(boolean value)
  377. {
  378. field_7_options = vertical.setShortBoolean(field_7_options, value);
  379. }
  380. /**
  381. * vertical or horizontal legend (1 or 0 respectively). Always 0 if not automatic.
  382. * @return the vertical field value.
  383. */
  384. public boolean isVertical()
  385. {
  386. return vertical.isSet(field_7_options);
  387. }
  388. /**
  389. * Sets the data table field value.
  390. * 1 if chart contains data table
  391. */
  392. public void setDataTable(boolean value)
  393. {
  394. field_7_options = dataTable.setShortBoolean(field_7_options, value);
  395. }
  396. /**
  397. * 1 if chart contains data table
  398. * @return the data table field value.
  399. */
  400. public boolean isDataTable()
  401. {
  402. return dataTable.isSet(field_7_options);
  403. }
  404. } // END OF CLASS