001: /* ====================================================================
002: Licensed to the Apache Software Foundation (ASF) under one or more
003: contributor license agreements. See the NOTICE file distributed with
004: this work for additional information regarding copyright ownership.
005: The ASF licenses this file to You under the Apache License, Version 2.0
006: (the "License"); you may not use this file except in compliance with
007: the License. You may obtain a copy of the License at
008:
009: http://www.apache.org/licenses/LICENSE-2.0
010:
011: Unless required by applicable law or agreed to in writing, software
012: distributed under the License is distributed on an "AS IS" BASIS,
013: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: See the License for the specific language governing permissions and
015: limitations under the License.
016: ==================================================================== */
017:
018: package org.apache.poi.hssf.record;
019:
020: import org.apache.poi.util.*;
021:
022: /**
023: * The area record is used to define a area chart.
024: * NOTE: This source is automatically generated please do not modify this file. Either subclass or
025: * remove the record in src/records/definitions.
026:
027: * @author Glen Stampoultzis (glens at apache.org)
028: */
029: public class AreaRecord extends Record {
030: public final static short sid = 0x101A;
031: private short field_1_formatFlags;
032: private BitField stacked = BitFieldFactory.getInstance(0x1);
033: private BitField displayAsPercentage = BitFieldFactory
034: .getInstance(0x2);
035: private BitField shadow = BitFieldFactory.getInstance(0x4);
036:
037: public AreaRecord() {
038:
039: }
040:
041: /**
042: * Constructs a Area record and sets its fields appropriately.
043: *
044: * @param in the RecordInputstream to read the record from
045: */
046:
047: public AreaRecord(RecordInputStream in) {
048: super (in);
049:
050: }
051:
052: /**
053: * Checks the sid matches the expected side for this record
054: *
055: * @param id the expected sid.
056: */
057: protected void validateSid(short id) {
058: if (id != sid) {
059: throw new RecordFormatException("Not a Area record");
060: }
061: }
062:
063: protected void fillFields(RecordInputStream in) {
064:
065: field_1_formatFlags = in.readShort();
066: }
067:
068: public String toString() {
069: StringBuffer buffer = new StringBuffer();
070:
071: buffer.append("[AREA]\n");
072: buffer.append(" .formatFlags = ").append("0x")
073: .append(HexDump.toHex(getFormatFlags())).append(" (")
074: .append(getFormatFlags()).append(" )");
075: buffer.append(System.getProperty("line.separator"));
076: buffer.append(" .stacked = ").append(
077: isStacked()).append('\n');
078: buffer.append(" .displayAsPercentage = ").append(
079: isDisplayAsPercentage()).append('\n');
080: buffer.append(" .shadow = ").append(
081: isShadow()).append('\n');
082:
083: buffer.append("[/AREA]\n");
084: return buffer.toString();
085: }
086:
087: public int serialize(int offset, byte[] data) {
088: int pos = 0;
089:
090: LittleEndian.putShort(data, 0 + offset, sid);
091: LittleEndian.putShort(data, 2 + offset,
092: (short) (getRecordSize() - 4));
093:
094: LittleEndian.putShort(data, 4 + offset + pos,
095: field_1_formatFlags);
096:
097: return getRecordSize();
098: }
099:
100: /**
101: * Size of record (exluding 4 byte header)
102: */
103: public int getRecordSize() {
104: return 4 + 2;
105: }
106:
107: public short getSid() {
108: return sid;
109: }
110:
111: public Object clone() {
112: AreaRecord rec = new AreaRecord();
113:
114: rec.field_1_formatFlags = field_1_formatFlags;
115: return rec;
116: }
117:
118: /**
119: * Get the format flags field for the Area record.
120: */
121: public short getFormatFlags() {
122: return field_1_formatFlags;
123: }
124:
125: /**
126: * Set the format flags field for the Area record.
127: */
128: public void setFormatFlags(short field_1_formatFlags) {
129: this .field_1_formatFlags = field_1_formatFlags;
130: }
131:
132: /**
133: * Sets the stacked field value.
134: * series is stacked
135: */
136: public void setStacked(boolean value) {
137: field_1_formatFlags = stacked.setShortBoolean(
138: field_1_formatFlags, value);
139: }
140:
141: /**
142: * series is stacked
143: * @return the stacked field value.
144: */
145: public boolean isStacked() {
146: return stacked.isSet(field_1_formatFlags);
147: }
148:
149: /**
150: * Sets the display as percentage field value.
151: * results displayed as percentages
152: */
153: public void setDisplayAsPercentage(boolean value) {
154: field_1_formatFlags = displayAsPercentage.setShortBoolean(
155: field_1_formatFlags, value);
156: }
157:
158: /**
159: * results displayed as percentages
160: * @return the display as percentage field value.
161: */
162: public boolean isDisplayAsPercentage() {
163: return displayAsPercentage.isSet(field_1_formatFlags);
164: }
165:
166: /**
167: * Sets the shadow field value.
168: * display a shadow for the chart
169: */
170: public void setShadow(boolean value) {
171: field_1_formatFlags = shadow.setShortBoolean(
172: field_1_formatFlags, value);
173: }
174:
175: /**
176: * display a shadow for the chart
177: * @return the shadow field value.
178: */
179: public boolean isShadow() {
180: return shadow.isSet(field_1_formatFlags);
181: }
182:
183: } // END OF CLASS
|