PageRenderTime 86ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 1ms

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

http://github.com/openmicroscopy/bioformats
Java | 373 lines | 173 code | 52 blank | 148 comment | 2 complexity | 5d4b991da958e2352bfafe58b5609bab 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 a line format record. The line format record controls how a line on a chart appears.
  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 LineFormatRecord
  46. extends Record
  47. {
  48. public final static short sid = 0x1007;
  49. private int field_1_lineColor;
  50. private short field_2_linePattern;
  51. public final static short LINE_PATTERN_SOLID = 0;
  52. public final static short LINE_PATTERN_DASH = 1;
  53. public final static short LINE_PATTERN_DOT = 2;
  54. public final static short LINE_PATTERN_DASH_DOT = 3;
  55. public final static short LINE_PATTERN_DASH_DOT_DOT = 4;
  56. public final static short LINE_PATTERN_NONE = 5;
  57. public final static short LINE_PATTERN_DARK_GRAY_PATTERN = 6;
  58. public final static short LINE_PATTERN_MEDIUM_GRAY_PATTERN = 7;
  59. public final static short LINE_PATTERN_LIGHT_GRAY_PATTERN = 8;
  60. private short field_3_weight;
  61. public final static short WEIGHT_HAIRLINE = -1;
  62. public final static short WEIGHT_NARROW = 0;
  63. public final static short WEIGHT_MEDIUM = 1;
  64. public final static short WEIGHT_WIDE = 2;
  65. private short field_4_format;
  66. private BitField auto = BitFieldFactory.getInstance(0x1);
  67. private BitField drawTicks = BitFieldFactory.getInstance(0x4);
  68. private BitField unknown = BitFieldFactory.getInstance(0x4);
  69. private short field_5_colourPaletteIndex;
  70. public LineFormatRecord()
  71. {
  72. }
  73. /**
  74. * Constructs a LineFormat record and sets its fields appropriately.
  75. *
  76. * @param in the RecordInputstream to read the record from
  77. */
  78. public LineFormatRecord(RecordInputStream in)
  79. {
  80. super(in);
  81. }
  82. /**
  83. * Checks the sid matches the expected side for this record
  84. *
  85. * @param id the expected sid.
  86. */
  87. protected void validateSid(short id)
  88. {
  89. if (id != sid)
  90. {
  91. throw new RecordFormatException("Not a LineFormat record");
  92. }
  93. }
  94. protected void fillFields(RecordInputStream in)
  95. {
  96. field_1_lineColor = in.readInt();
  97. field_2_linePattern = in.readShort();
  98. field_3_weight = in.readShort();
  99. field_4_format = in.readShort();
  100. field_5_colourPaletteIndex = in.readShort();
  101. }
  102. public String toString()
  103. {
  104. StringBuffer buffer = new StringBuffer();
  105. buffer.append("[LINEFORMAT]\n");
  106. buffer.append(" .lineColor = ")
  107. .append("0x").append(HexDump.toHex( getLineColor ()))
  108. .append(" (").append( getLineColor() ).append(" )");
  109. buffer.append(System.getProperty("line.separator"));
  110. buffer.append(" .linePattern = ")
  111. .append("0x").append(HexDump.toHex( getLinePattern ()))
  112. .append(" (").append( getLinePattern() ).append(" )");
  113. buffer.append(System.getProperty("line.separator"));
  114. buffer.append(" .weight = ")
  115. .append("0x").append(HexDump.toHex( getWeight ()))
  116. .append(" (").append( getWeight() ).append(" )");
  117. buffer.append(System.getProperty("line.separator"));
  118. buffer.append(" .format = ")
  119. .append("0x").append(HexDump.toHex( getFormat ()))
  120. .append(" (").append( getFormat() ).append(" )");
  121. buffer.append(System.getProperty("line.separator"));
  122. buffer.append(" .auto = ").append(isAuto()).append('\n');
  123. buffer.append(" .drawTicks = ").append(isDrawTicks()).append('\n');
  124. buffer.append(" .unknown = ").append(isUnknown()).append('\n');
  125. buffer.append(" .colourPaletteIndex = ")
  126. .append("0x").append(HexDump.toHex( getColourPaletteIndex ()))
  127. .append(" (").append( getColourPaletteIndex() ).append(" )");
  128. buffer.append(System.getProperty("line.separator"));
  129. buffer.append("[/LINEFORMAT]\n");
  130. return buffer.toString();
  131. }
  132. public int serialize(int offset, byte[] data)
  133. {
  134. int pos = 0;
  135. LittleEndian.putShort(data, 0 + offset, sid);
  136. LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
  137. LittleEndian.putInt(data, 4 + offset + pos, field_1_lineColor);
  138. LittleEndian.putShort(data, 8 + offset + pos, field_2_linePattern);
  139. LittleEndian.putShort(data, 10 + offset + pos, field_3_weight);
  140. LittleEndian.putShort(data, 12 + offset + pos, field_4_format);
  141. LittleEndian.putShort(data, 14 + offset + pos, field_5_colourPaletteIndex);
  142. return getRecordSize();
  143. }
  144. /**
  145. * Size of record (exluding 4 byte header)
  146. */
  147. public int getRecordSize()
  148. {
  149. return 4 + 4 + 2 + 2 + 2 + 2;
  150. }
  151. public short getSid()
  152. {
  153. return sid;
  154. }
  155. public Object clone() {
  156. LineFormatRecord rec = new LineFormatRecord();
  157. rec.field_1_lineColor = field_1_lineColor;
  158. rec.field_2_linePattern = field_2_linePattern;
  159. rec.field_3_weight = field_3_weight;
  160. rec.field_4_format = field_4_format;
  161. rec.field_5_colourPaletteIndex = field_5_colourPaletteIndex;
  162. return rec;
  163. }
  164. /**
  165. * Get the line color field for the LineFormat record.
  166. */
  167. public int getLineColor()
  168. {
  169. return field_1_lineColor;
  170. }
  171. /**
  172. * Set the line color field for the LineFormat record.
  173. */
  174. public void setLineColor(int field_1_lineColor)
  175. {
  176. this.field_1_lineColor = field_1_lineColor;
  177. }
  178. /**
  179. * Get the line pattern field for the LineFormat record.
  180. *
  181. * @return One of
  182. * LINE_PATTERN_SOLID
  183. * LINE_PATTERN_DASH
  184. * LINE_PATTERN_DOT
  185. * LINE_PATTERN_DASH_DOT
  186. * LINE_PATTERN_DASH_DOT_DOT
  187. * LINE_PATTERN_NONE
  188. * LINE_PATTERN_DARK_GRAY_PATTERN
  189. * LINE_PATTERN_MEDIUM_GRAY_PATTERN
  190. * LINE_PATTERN_LIGHT_GRAY_PATTERN
  191. */
  192. public short getLinePattern()
  193. {
  194. return field_2_linePattern;
  195. }
  196. /**
  197. * Set the line pattern field for the LineFormat record.
  198. *
  199. * @param field_2_linePattern
  200. * One of
  201. * LINE_PATTERN_SOLID
  202. * LINE_PATTERN_DASH
  203. * LINE_PATTERN_DOT
  204. * LINE_PATTERN_DASH_DOT
  205. * LINE_PATTERN_DASH_DOT_DOT
  206. * LINE_PATTERN_NONE
  207. * LINE_PATTERN_DARK_GRAY_PATTERN
  208. * LINE_PATTERN_MEDIUM_GRAY_PATTERN
  209. * LINE_PATTERN_LIGHT_GRAY_PATTERN
  210. */
  211. public void setLinePattern(short field_2_linePattern)
  212. {
  213. this.field_2_linePattern = field_2_linePattern;
  214. }
  215. /**
  216. * Get the weight field for the LineFormat record.
  217. *
  218. * @return One of
  219. * WEIGHT_HAIRLINE
  220. * WEIGHT_NARROW
  221. * WEIGHT_MEDIUM
  222. * WEIGHT_WIDE
  223. */
  224. public short getWeight()
  225. {
  226. return field_3_weight;
  227. }
  228. /**
  229. * Set the weight field for the LineFormat record.
  230. *
  231. * @param field_3_weight
  232. * One of
  233. * WEIGHT_HAIRLINE
  234. * WEIGHT_NARROW
  235. * WEIGHT_MEDIUM
  236. * WEIGHT_WIDE
  237. */
  238. public void setWeight(short field_3_weight)
  239. {
  240. this.field_3_weight = field_3_weight;
  241. }
  242. /**
  243. * Get the format field for the LineFormat record.
  244. */
  245. public short getFormat()
  246. {
  247. return field_4_format;
  248. }
  249. /**
  250. * Set the format field for the LineFormat record.
  251. */
  252. public void setFormat(short field_4_format)
  253. {
  254. this.field_4_format = field_4_format;
  255. }
  256. /**
  257. * Get the colour palette index field for the LineFormat record.
  258. */
  259. public short getColourPaletteIndex()
  260. {
  261. return field_5_colourPaletteIndex;
  262. }
  263. /**
  264. * Set the colour palette index field for the LineFormat record.
  265. */
  266. public void setColourPaletteIndex(short field_5_colourPaletteIndex)
  267. {
  268. this.field_5_colourPaletteIndex = field_5_colourPaletteIndex;
  269. }
  270. /**
  271. * Sets the auto field value.
  272. * automatic format
  273. */
  274. public void setAuto(boolean value)
  275. {
  276. field_4_format = auto.setShortBoolean(field_4_format, value);
  277. }
  278. /**
  279. * automatic format
  280. * @return the auto field value.
  281. */
  282. public boolean isAuto()
  283. {
  284. return auto.isSet(field_4_format);
  285. }
  286. /**
  287. * Sets the draw ticks field value.
  288. * draw tick marks
  289. */
  290. public void setDrawTicks(boolean value)
  291. {
  292. field_4_format = drawTicks.setShortBoolean(field_4_format, value);
  293. }
  294. /**
  295. * draw tick marks
  296. * @return the draw ticks field value.
  297. */
  298. public boolean isDrawTicks()
  299. {
  300. return drawTicks.isSet(field_4_format);
  301. }
  302. /**
  303. * Sets the unknown field value.
  304. * book marks this as reserved = 0 but it seems to do something
  305. */
  306. public void setUnknown(boolean value)
  307. {
  308. field_4_format = unknown.setShortBoolean(field_4_format, value);
  309. }
  310. /**
  311. * book marks this as reserved = 0 but it seems to do something
  312. * @return the unknown field value.
  313. */
  314. public boolean isUnknown()
  315. {
  316. return unknown.isSet(field_4_format);
  317. }
  318. } // END OF CLASS