PageRenderTime 107ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

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

http://github.com/openmicroscopy/bioformats
Java | 191 lines | 82 code | 39 blank | 70 comment | 2 complexity | 96745b68d3b0597f4ed83776e2060dbb 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. * Specifies the window's zoom magnification. If this record isn't present then the windows zoom is 100%. see p384 Excel Dev Kit
  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 SCLRecord
  46. extends Record
  47. {
  48. public final static short sid = 0xa0;
  49. private short field_1_numerator;
  50. private short field_2_denominator;
  51. public SCLRecord()
  52. {
  53. }
  54. /**
  55. * Constructs a SCL record and sets its fields appropriately.
  56. *
  57. * @param in the RecordInputstream to read the record from
  58. */
  59. public SCLRecord(RecordInputStream in)
  60. {
  61. super(in);
  62. }
  63. /**
  64. * Checks the sid matches the expected side for this record
  65. *
  66. * @param id the expected sid.
  67. */
  68. protected void validateSid(short id)
  69. {
  70. if (id != sid)
  71. {
  72. throw new RecordFormatException("Not a SCL record");
  73. }
  74. }
  75. protected void fillFields(RecordInputStream in)
  76. {
  77. field_1_numerator = in.readShort();
  78. field_2_denominator = in.readShort();
  79. }
  80. public String toString()
  81. {
  82. StringBuffer buffer = new StringBuffer();
  83. buffer.append("[SCL]\n");
  84. buffer.append(" .numerator = ")
  85. .append("0x").append(HexDump.toHex( getNumerator ()))
  86. .append(" (").append( getNumerator() ).append(" )");
  87. buffer.append(System.getProperty("line.separator"));
  88. buffer.append(" .denominator = ")
  89. .append("0x").append(HexDump.toHex( getDenominator ()))
  90. .append(" (").append( getDenominator() ).append(" )");
  91. buffer.append(System.getProperty("line.separator"));
  92. buffer.append("[/SCL]\n");
  93. return buffer.toString();
  94. }
  95. public int serialize(int offset, byte[] data)
  96. {
  97. int pos = 0;
  98. LittleEndian.putShort(data, 0 + offset, sid);
  99. LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
  100. LittleEndian.putShort(data, 4 + offset + pos, field_1_numerator);
  101. LittleEndian.putShort(data, 6 + offset + pos, field_2_denominator);
  102. return getRecordSize();
  103. }
  104. /**
  105. * Size of record (exluding 4 byte header)
  106. */
  107. public int getRecordSize()
  108. {
  109. return 4 + 2 + 2;
  110. }
  111. public short getSid()
  112. {
  113. return sid;
  114. }
  115. public Object clone() {
  116. SCLRecord rec = new SCLRecord();
  117. rec.field_1_numerator = field_1_numerator;
  118. rec.field_2_denominator = field_2_denominator;
  119. return rec;
  120. }
  121. /**
  122. * Get the numerator field for the SCL record.
  123. */
  124. public short getNumerator()
  125. {
  126. return field_1_numerator;
  127. }
  128. /**
  129. * Set the numerator field for the SCL record.
  130. */
  131. public void setNumerator(short field_1_numerator)
  132. {
  133. this.field_1_numerator = field_1_numerator;
  134. }
  135. /**
  136. * Get the denominator field for the SCL record.
  137. */
  138. public short getDenominator()
  139. {
  140. return field_2_denominator;
  141. }
  142. /**
  143. * Set the denominator field for the SCL record.
  144. */
  145. public void setDenominator(short field_2_denominator)
  146. {
  147. this.field_2_denominator = field_2_denominator;
  148. }
  149. } // END OF CLASS