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.usermodel;
019:
020: import org.apache.poi.hssf.record.*;
021: import org.apache.poi.hssf.record.formula.Area3DPtg;
022:
023: import java.util.ArrayList;
024: import java.util.List;
025: import java.util.Stack;
026:
027: /**
028: * Has methods for construction of a chart object.
029: *
030: * @author Glen Stampoultzis (glens at apache.org)
031: */
032: public class HSSFChart {
033:
034: /**
035: * Creates a bar chart. API needs some work. :)
036: * <p>
037: * NOTE: Does not yet work... checking it in just so others
038: * can take a look.
039: */
040: public void createBarChart(HSSFWorkbook workbook, HSSFSheet sheet) {
041:
042: List records = new ArrayList();
043: records.add(createMSDrawingObjectRecord());
044: records.add(createOBJRecord());
045: records.add(createBOFRecord());
046: records.add(createHeaderRecord());
047: records.add(createFooterRecord());
048: records.add(createHCenterRecord());
049: records.add(createVCenterRecord());
050: records.add(createPrintSetupRecord());
051: // unknown 33
052: records.add(createFontBasisRecord1());
053: records.add(createFontBasisRecord2());
054: records.add(createProtectRecord());
055: records.add(createUnitsRecord());
056: records.add(createChartRecord(0, 0, 30434904, 19031616));
057: records.add(createBeginRecord());
058: records.add(createSCLRecord((short) 1, (short) 1));
059: records.add(createPlotGrowthRecord(65536, 65536));
060: records.add(createFrameRecord1());
061: records.add(createBeginRecord());
062: records.add(createLineFormatRecord(true));
063: records.add(createAreaFormatRecord1());
064: records.add(createEndRecord());
065: records.add(createSeriesRecord());
066: records.add(createBeginRecord());
067: records.add(createTitleLinkedDataRecord());
068: records.add(createValuesLinkedDataRecord());
069: records.add(createCategoriesLinkedDataRecord());
070: records.add(createDataFormatRecord());
071: // records.add(createBeginRecord());
072: // unknown
073: // records.add(createEndRecord());
074: records.add(createSeriesToChartGroupRecord());
075: records.add(createEndRecord());
076: records.add(createSheetPropsRecord());
077: records
078: .add(createDefaultTextRecord(DefaultDataLabelTextPropertiesRecord.CATEGORY_DATA_TYPE_ALL_TEXT_CHARACTERISTIC));
079: records.add(createAllTextRecord());
080: records.add(createBeginRecord());
081: // unknown
082: records.add(createFontIndexRecord(5));
083: records.add(createDirectLinkRecord());
084: records.add(createEndRecord());
085: records.add(createDefaultTextRecord((short) 3)); // eek, undocumented text type
086: records.add(createUnknownTextRecord());
087: records.add(createBeginRecord());
088: records.add(createFontIndexRecord((short) 6));
089: records.add(createDirectLinkRecord());
090: records.add(createEndRecord());
091:
092: records.add(createAxisUsedRecord((short) 1));
093: createAxisRecords(records);
094:
095: records.add(createEndRecord());
096: records.add(createDimensionsRecord());
097: records.add(createSeriesIndexRecord(2));
098: records.add(createSeriesIndexRecord(1));
099: records.add(createSeriesIndexRecord(3));
100: records.add(createEOFRecord());
101:
102: sheet.insertChartRecords(records);
103: workbook.insertChartRecord();
104: }
105:
106: private EOFRecord createEOFRecord() {
107: return new EOFRecord();
108: }
109:
110: private SeriesIndexRecord createSeriesIndexRecord(int index) {
111: SeriesIndexRecord r = new SeriesIndexRecord();
112: r.setIndex((short) index);
113: return r;
114: }
115:
116: private DimensionsRecord createDimensionsRecord() {
117: DimensionsRecord r = new DimensionsRecord();
118: r.setFirstRow(0);
119: r.setLastRow(31);
120: r.setFirstCol((short) 0);
121: r.setLastCol((short) 1);
122: return r;
123: }
124:
125: private HCenterRecord createHCenterRecord() {
126: HCenterRecord r = new HCenterRecord();
127: r.setHCenter(false);
128: return r;
129: }
130:
131: private VCenterRecord createVCenterRecord() {
132: VCenterRecord r = new VCenterRecord();
133: r.setVCenter(false);
134: return r;
135: }
136:
137: private PrintSetupRecord createPrintSetupRecord() {
138: PrintSetupRecord r = new PrintSetupRecord();
139: r.setPaperSize((short) 0);
140: r.setScale((short) 18);
141: r.setPageStart((short) 1);
142: r.setFitWidth((short) 1);
143: r.setFitHeight((short) 1);
144: r.setLeftToRight(false);
145: r.setLandscape(false);
146: r.setValidSettings(true);
147: r.setNoColor(false);
148: r.setDraft(false);
149: r.setNotes(false);
150: r.setNoOrientation(false);
151: r.setUsePage(false);
152: r.setHResolution((short) 0);
153: r.setVResolution((short) 0);
154: r.setHeaderMargin(0.5);
155: r.setFooterMargin(0.5);
156: r.setCopies((short) 15); // what the ??
157: return r;
158: }
159:
160: private FontBasisRecord createFontBasisRecord1() {
161: FontBasisRecord r = new FontBasisRecord();
162: r.setXBasis((short) 9120);
163: r.setYBasis((short) 5640);
164: r.setHeightBasis((short) 200);
165: r.setScale((short) 0);
166: r.setIndexToFontTable((short) 5);
167: return r;
168: }
169:
170: private FontBasisRecord createFontBasisRecord2() {
171: FontBasisRecord r = createFontBasisRecord1();
172: r.setIndexToFontTable((short) 6);
173: return r;
174: }
175:
176: private ProtectRecord createProtectRecord() {
177: ProtectRecord r = new ProtectRecord();
178: r.setProtect(false);
179: return r;
180: }
181:
182: private FooterRecord createFooterRecord() {
183: FooterRecord r = new FooterRecord();
184: r.setFooter(null);
185: return r;
186: }
187:
188: private HeaderRecord createHeaderRecord() {
189: HeaderRecord r = new HeaderRecord();
190: r.setHeader(null);
191: return r;
192: }
193:
194: private BOFRecord createBOFRecord() {
195: BOFRecord r = new BOFRecord();
196: r.setVersion((short) 600);
197: r.setType((short) 20);
198: r.setBuild((short) 0x1CFE);
199: r.setBuildYear((short) 1997);
200: r.setHistoryBitMask(0x40C9);
201: r.setRequiredVersion(106);
202: return r;
203: }
204:
205: private UnknownRecord createOBJRecord() {
206: byte[] data = { (byte) 0x15, (byte) 0x00, (byte) 0x12,
207: (byte) 0x00, (byte) 0x05, (byte) 0x00, (byte) 0x02,
208: (byte) 0x00, (byte) 0x11, (byte) 0x60, (byte) 0x00,
209: (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0xB8,
210: (byte) 0x03, (byte) 0x87, (byte) 0x03, (byte) 0x00,
211: (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
212: (byte) 0x00, (byte) 0x00, (byte) 0x00, };
213:
214: return new UnknownRecord((short) 0x005D, data);
215: }
216:
217: private UnknownRecord createMSDrawingObjectRecord() {
218: // Since we haven't created this object yet we'll just put in the raw
219: // form for the moment.
220:
221: byte[] data = { (byte) 0x0F, (byte) 0x00, (byte) 0x02,
222: (byte) 0xF0, (byte) 0xC0, (byte) 0x00, (byte) 0x00,
223: (byte) 0x00, (byte) 0x10, (byte) 0x00, (byte) 0x08,
224: (byte) 0xF0, (byte) 0x08, (byte) 0x00, (byte) 0x00,
225: (byte) 0x00, (byte) 0x02, (byte) 0x00, (byte) 0x00,
226: (byte) 0x00, (byte) 0x02, (byte) 0x04, (byte) 0x00,
227: (byte) 0x00, (byte) 0x0F, (byte) 0x00, (byte) 0x03,
228: (byte) 0xF0, (byte) 0xA8, (byte) 0x00, (byte) 0x00,
229: (byte) 0x00, (byte) 0x0F, (byte) 0x00, (byte) 0x04,
230: (byte) 0xF0, (byte) 0x28, (byte) 0x00, (byte) 0x00,
231: (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x09,
232: (byte) 0xF0, (byte) 0x10, (byte) 0x00, (byte) 0x00,
233: (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
234: (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
235: (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
236: (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
237: (byte) 0x00, (byte) 0x02, (byte) 0x00, (byte) 0x0A,
238: (byte) 0xF0, (byte) 0x08, (byte) 0x00, (byte) 0x00,
239: (byte) 0x00, (byte) 0x00, (byte) 0x04, (byte) 0x00,
240: (byte) 0x00, (byte) 0x05, (byte) 0x00, (byte) 0x00,
241: (byte) 0x00, (byte) 0x0F, (byte) 0x00, (byte) 0x04,
242: (byte) 0xF0, (byte) 0x70, (byte) 0x00, (byte) 0x00,
243: (byte) 0x00, (byte) 0x92, (byte) 0x0C, (byte) 0x0A,
244: (byte) 0xF0, (byte) 0x08, (byte) 0x00, (byte) 0x00,
245: (byte) 0x00, (byte) 0x02, (byte) 0x04, (byte) 0x00,
246: (byte) 0x00, (byte) 0x00, (byte) 0x0A, (byte) 0x00,
247: (byte) 0x00, (byte) 0x93, (byte) 0x00, (byte) 0x0B,
248: (byte) 0xF0, (byte) 0x36, (byte) 0x00, (byte) 0x00,
249: (byte) 0x00, (byte) 0x7F, (byte) 0x00, (byte) 0x04,
250: (byte) 0x01, (byte) 0x04, (byte) 0x01, (byte) 0xBF,
251: (byte) 0x00, (byte) 0x08, (byte) 0x00, (byte) 0x08,
252: (byte) 0x00, (byte) 0x81, (byte) 0x01, (byte) 0x4E,
253: (byte) 0x00, (byte) 0x00, (byte) 0x08, (byte) 0x83,
254: (byte) 0x01, (byte) 0x4D, (byte) 0x00, (byte) 0x00,
255: (byte) 0x08, (byte) 0xBF, (byte) 0x01, (byte) 0x10,
256: (byte) 0x00, (byte) 0x11, (byte) 0x00, (byte) 0xC0,
257: (byte) 0x01, (byte) 0x4D, (byte) 0x00, (byte) 0x00,
258: (byte) 0x08, (byte) 0xFF, (byte) 0x01, (byte) 0x08,
259: (byte) 0x00, (byte) 0x08, (byte) 0x00, (byte) 0x3F,
260: (byte) 0x02, (byte) 0x00, (byte) 0x00, (byte) 0x02,
261: (byte) 0x00, (byte) 0xBF, (byte) 0x03, (byte) 0x00,
262: (byte) 0x00, (byte) 0x08, (byte) 0x00, (byte) 0x00,
263: (byte) 0x00, (byte) 0x10, (byte) 0xF0, (byte) 0x12,
264: (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
265: (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0xC0,
266: (byte) 0x02, (byte) 0x0A, (byte) 0x00, (byte) 0xF4,
267: (byte) 0x00, (byte) 0x0E, (byte) 0x00, (byte) 0x66,
268: (byte) 0x01, (byte) 0x20, (byte) 0x00, (byte) 0xE9,
269: (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x11,
270: (byte) 0xF0, (byte) 0x00, (byte) 0x00, (byte) 0x00,
271: (byte) 0x00 };
272:
273: return new UnknownRecord((short) 0x00EC, data);
274: }
275:
276: private void createAxisRecords(List records) {
277: records.add(createAxisParentRecord());
278: records.add(createBeginRecord());
279: records
280: .add(createAxisRecord(AxisRecord.AXIS_TYPE_CATEGORY_OR_X_AXIS));
281: records.add(createBeginRecord());
282: records.add(createCategorySeriesAxisRecord());
283: records.add(createAxisOptionsRecord());
284: records.add(createTickRecord1());
285: records.add(createEndRecord());
286: records.add(createAxisRecord(AxisRecord.AXIS_TYPE_VALUE_AXIS));
287: records.add(createBeginRecord());
288: records.add(createValueRangeRecord());
289: records.add(createTickRecord2());
290: records
291: .add(createAxisLineFormatRecord(AxisLineFormatRecord.AXIS_TYPE_MAJOR_GRID_LINE));
292: records.add(createLineFormatRecord(false));
293: records.add(createEndRecord());
294: records.add(createPlotAreaRecord());
295: records.add(createFrameRecord2());
296: records.add(createBeginRecord());
297: records.add(createLineFormatRecord2());
298: records.add(createAreaFormatRecord2());
299: records.add(createEndRecord());
300: records.add(createChartFormatRecord());
301: records.add(createBeginRecord());
302: records.add(createBarRecord());
303: // unknown 1022
304: records.add(createLegendRecord());
305: records.add(createBeginRecord());
306: // unknown 104f
307: records.add(createTextRecord());
308: records.add(createBeginRecord());
309: // unknown 104f
310: records.add(createLinkedDataRecord());
311: records.add(createEndRecord());
312: records.add(createEndRecord());
313: records.add(createEndRecord());
314: records.add(createEndRecord());
315: }
316:
317: private LinkedDataRecord createLinkedDataRecord() {
318: LinkedDataRecord r = new LinkedDataRecord();
319: r.setLinkType(LinkedDataRecord.LINK_TYPE_TITLE_OR_TEXT);
320: r.setReferenceType(LinkedDataRecord.REFERENCE_TYPE_DIRECT);
321: r.setCustomNumberFormat(false);
322: r.setIndexNumberFmtRecord((short) 0);
323: r.setFormulaOfLink(new LinkedDataFormulaField());
324: return r;
325: }
326:
327: private TextRecord createTextRecord() {
328: TextRecord r = new TextRecord();
329: r
330: .setHorizontalAlignment(TextRecord.HORIZONTAL_ALIGNMENT_CENTER);
331: r.setVerticalAlignment(TextRecord.VERTICAL_ALIGNMENT_CENTER);
332: r.setDisplayMode((short) 1);
333: r.setRgbColor(0x00000000);
334: r.setX(-37);
335: r.setY(-60);
336: r.setWidth(0);
337: r.setHeight(0);
338: r.setAutoColor(true);
339: r.setShowKey(false);
340: r.setShowValue(false);
341: r.setVertical(false);
342: r.setAutoGeneratedText(true);
343: r.setGenerated(true);
344: r.setAutoLabelDeleted(false);
345: r.setAutoBackground(true);
346: r.setRotation((short) 0);
347: r.setShowCategoryLabelAsPercentage(false);
348: r.setShowValueAsPercentage(false);
349: r.setShowBubbleSizes(false);
350: r.setShowLabel(false);
351: r.setIndexOfColorValue((short) 77);
352: r.setDataLabelPlacement((short) 0);
353: r.setTextRotation((short) 0);
354: return r;
355: }
356:
357: private LegendRecord createLegendRecord() {
358: LegendRecord r = new LegendRecord();
359: r.setXAxisUpperLeft(3542);
360: r.setYAxisUpperLeft(1566);
361: r.setXSize(437);
362: r.setYSize(213);
363: r.setType(LegendRecord.TYPE_RIGHT);
364: r.setSpacing(LegendRecord.SPACING_MEDIUM);
365: r.setAutoPosition(true);
366: r.setAutoSeries(true);
367: r.setAutoXPositioning(true);
368: r.setAutoYPositioning(true);
369: r.setVertical(true);
370: r.setDataTable(false);
371: return r;
372: }
373:
374: private BarRecord createBarRecord() {
375: BarRecord r = new BarRecord();
376: r.setBarSpace((short) 0);
377: r.setCategorySpace((short) 150);
378: r.setHorizontal(false);
379: r.setStacked(false);
380: r.setDisplayAsPercentage(false);
381: r.setShadow(false);
382: return r;
383: }
384:
385: private ChartFormatRecord createChartFormatRecord() {
386: ChartFormatRecord r = new ChartFormatRecord();
387: r.setXPosition(0);
388: r.setYPosition(0);
389: r.setWidth(0);
390: r.setHeight(0);
391: r.setVaryDisplayPattern(false);
392: return r;
393: }
394:
395: private PlotAreaRecord createPlotAreaRecord() {
396: PlotAreaRecord r = new PlotAreaRecord();
397: return r;
398: }
399:
400: private AxisLineFormatRecord createAxisLineFormatRecord(short format) {
401: AxisLineFormatRecord r = new AxisLineFormatRecord();
402: r.setAxisType(format);
403: return r;
404: }
405:
406: private ValueRangeRecord createValueRangeRecord() {
407: ValueRangeRecord r = new ValueRangeRecord();
408: r.setMinimumAxisValue(0.0);
409: r.setMaximumAxisValue(0.0);
410: r.setMajorIncrement(0);
411: r.setMinorIncrement(0);
412: r.setCategoryAxisCross(0);
413: r.setAutomaticMinimum(true);
414: r.setAutomaticMaximum(true);
415: r.setAutomaticMajor(true);
416: r.setAutomaticMinor(true);
417: r.setAutomaticCategoryCrossing(true);
418: r.setLogarithmicScale(false);
419: r.setValuesInReverse(false);
420: r.setCrossCategoryAxisAtMaximum(false);
421: r.setReserved(true); // what's this do??
422: return r;
423: }
424:
425: private TickRecord createTickRecord1() {
426: TickRecord r = new TickRecord();
427: r.setMajorTickType((byte) 2);
428: r.setMinorTickType((byte) 0);
429: r.setLabelPosition((byte) 3);
430: r.setBackground((byte) 1);
431: r.setLabelColorRgb(0);
432: r.setZero1((short) 0);
433: r.setZero2((short) 0);
434: r.setZero3((short) 45);
435: r.setAutorotate(true);
436: r.setAutoTextBackground(true);
437: r.setRotation((short) 0);
438: r.setAutorotate(true);
439: r.setTickColor((short) 77);
440: return r;
441: }
442:
443: private TickRecord createTickRecord2() {
444: TickRecord r = createTickRecord1();
445: r.setZero3((short) 0);
446: return r;
447: }
448:
449: private AxisOptionsRecord createAxisOptionsRecord() {
450: AxisOptionsRecord r = new AxisOptionsRecord();
451: r.setMinimumCategory((short) -28644);
452: r.setMaximumCategory((short) -28715);
453: r.setMajorUnitValue((short) 2);
454: r.setMajorUnit((short) 0);
455: r.setMinorUnitValue((short) 1);
456: r.setMinorUnit((short) 0);
457: r.setBaseUnit((short) 0);
458: r.setCrossingPoint((short) -28644);
459: r.setDefaultMinimum(true);
460: r.setDefaultMaximum(true);
461: r.setDefaultMajor(true);
462: r.setDefaultMinorUnit(true);
463: r.setIsDate(true);
464: r.setDefaultBase(true);
465: r.setDefaultCross(true);
466: r.setDefaultDateSettings(true);
467: return r;
468: }
469:
470: private CategorySeriesAxisRecord createCategorySeriesAxisRecord() {
471: CategorySeriesAxisRecord r = new CategorySeriesAxisRecord();
472: r.setCrossingPoint((short) 1);
473: r.setLabelFrequency((short) 1);
474: r.setTickMarkFrequency((short) 1);
475: r.setValueAxisCrossing(true);
476: r.setCrossesFarRight(false);
477: r.setReversed(false);
478: return r;
479: }
480:
481: private AxisRecord createAxisRecord(short axisType) {
482: AxisRecord r = new AxisRecord();
483: r.setAxisType(axisType);
484: return r;
485: }
486:
487: private AxisParentRecord createAxisParentRecord() {
488: AxisParentRecord r = new AxisParentRecord();
489: r.setAxisType(AxisParentRecord.AXIS_TYPE_MAIN);
490: r.setX(479);
491: r.setY(221);
492: r.setWidth(2995);
493: r.setHeight(2902);
494: return r;
495: }
496:
497: private AxisUsedRecord createAxisUsedRecord(short numAxis) {
498: AxisUsedRecord r = new AxisUsedRecord();
499: r.setNumAxis(numAxis);
500: return r;
501: }
502:
503: private LinkedDataRecord createDirectLinkRecord() {
504: LinkedDataRecord r = new LinkedDataRecord();
505: r.setLinkType(LinkedDataRecord.LINK_TYPE_TITLE_OR_TEXT);
506: r.setReferenceType(LinkedDataRecord.REFERENCE_TYPE_DIRECT);
507: r.setCustomNumberFormat(false);
508: r.setIndexNumberFmtRecord((short) 0);
509: r.setFormulaOfLink(new LinkedDataFormulaField());
510: return r;
511: }
512:
513: private FontIndexRecord createFontIndexRecord(int index) {
514: FontIndexRecord r = new FontIndexRecord();
515: r.setFontIndex((short) index);
516: return r;
517: }
518:
519: private TextRecord createAllTextRecord() {
520: TextRecord r = new TextRecord();
521: r
522: .setHorizontalAlignment(TextRecord.HORIZONTAL_ALIGNMENT_CENTER);
523: r.setVerticalAlignment(TextRecord.VERTICAL_ALIGNMENT_CENTER);
524: r.setDisplayMode(TextRecord.DISPLAY_MODE_TRANSPARENT);
525: r.setRgbColor(0);
526: r.setX(-37);
527: r.setY(-60);
528: r.setWidth(0);
529: r.setHeight(0);
530: r.setAutoColor(true);
531: r.setShowKey(false);
532: r.setShowValue(true);
533: r.setVertical(false);
534: r.setAutoGeneratedText(true);
535: r.setGenerated(true);
536: r.setAutoLabelDeleted(false);
537: r.setAutoBackground(true);
538: r.setRotation((short) 0);
539: r.setShowCategoryLabelAsPercentage(false);
540: r.setShowValueAsPercentage(false);
541: r.setShowBubbleSizes(false);
542: r.setShowLabel(false);
543: r.setIndexOfColorValue((short) 77);
544: r.setDataLabelPlacement((short) 0);
545: r.setTextRotation((short) 0);
546: return r;
547: }
548:
549: private TextRecord createUnknownTextRecord() {
550: TextRecord r = new TextRecord();
551: r
552: .setHorizontalAlignment(TextRecord.HORIZONTAL_ALIGNMENT_CENTER);
553: r.setVerticalAlignment(TextRecord.VERTICAL_ALIGNMENT_CENTER);
554: r.setDisplayMode(TextRecord.DISPLAY_MODE_TRANSPARENT);
555: r.setRgbColor(0);
556: r.setX(-37);
557: r.setY(-60);
558: r.setWidth(0);
559: r.setHeight(0);
560: r.setAutoColor(true);
561: r.setShowKey(false);
562: r.setShowValue(false);
563: r.setVertical(false);
564: r.setAutoGeneratedText(true);
565: r.setGenerated(true);
566: r.setAutoLabelDeleted(false);
567: r.setAutoBackground(true);
568: r.setRotation((short) 0);
569: r.setShowCategoryLabelAsPercentage(false);
570: r.setShowValueAsPercentage(false);
571: r.setShowBubbleSizes(false);
572: r.setShowLabel(false);
573: r.setIndexOfColorValue((short) 77);
574: r.setDataLabelPlacement((short) 11088);
575: r.setTextRotation((short) 0);
576: return r;
577: }
578:
579: private DefaultDataLabelTextPropertiesRecord createDefaultTextRecord(
580: short categoryDataType) {
581: DefaultDataLabelTextPropertiesRecord r = new DefaultDataLabelTextPropertiesRecord();
582: r.setCategoryDataType(categoryDataType);
583: return r;
584: }
585:
586: private SheetPropertiesRecord createSheetPropsRecord() {
587: SheetPropertiesRecord r = new SheetPropertiesRecord();
588: r.setChartTypeManuallyFormatted(false);
589: r.setPlotVisibleOnly(true);
590: r.setDoNotSizeWithWindow(false);
591: r.setDefaultPlotDimensions(true);
592: r.setAutoPlotArea(false);
593: return r;
594: }
595:
596: private SeriesToChartGroupRecord createSeriesToChartGroupRecord() {
597: return new SeriesToChartGroupRecord();
598: }
599:
600: private DataFormatRecord createDataFormatRecord() {
601: DataFormatRecord r = new DataFormatRecord();
602: r.setPointNumber((short) -1);
603: r.setSeriesIndex((short) 0);
604: r.setSeriesNumber((short) 0);
605: r.setUseExcel4Colors(false);
606: return r;
607: }
608:
609: private LinkedDataRecord createCategoriesLinkedDataRecord() {
610: LinkedDataRecord r = new LinkedDataRecord();
611: r.setLinkType(LinkedDataRecord.LINK_TYPE_CATEGORIES);
612: r.setReferenceType(LinkedDataRecord.REFERENCE_TYPE_WORKSHEET);
613: r.setCustomNumberFormat(false);
614: r.setIndexNumberFmtRecord((short) 0);
615: LinkedDataFormulaField formula = new LinkedDataFormulaField();
616: Stack tokens = new Stack();
617: Area3DPtg p = new Area3DPtg();
618: p.setExternSheetIndex((short) 0);
619: p.setFirstColumn((short) 1);
620: p.setLastColumn((short) 1);
621: p.setFirstRow((short) 0);
622: p.setLastRow((short) 31);
623: tokens.add(p);
624: formula.setFormulaTokens(tokens);
625: r.setFormulaOfLink(formula);
626: return r;
627: }
628:
629: private LinkedDataRecord createValuesLinkedDataRecord() {
630: LinkedDataRecord r = new LinkedDataRecord();
631: r.setLinkType(LinkedDataRecord.LINK_TYPE_VALUES);
632: r.setReferenceType(LinkedDataRecord.REFERENCE_TYPE_WORKSHEET);
633: r.setCustomNumberFormat(false);
634: r.setIndexNumberFmtRecord((short) 0);
635: LinkedDataFormulaField formula = new LinkedDataFormulaField();
636: Stack tokens = new Stack();
637: Area3DPtg p = new Area3DPtg();
638: p.setExternSheetIndex((short) 0);
639: p.setFirstColumn((short) 0);
640: p.setLastColumn((short) 0);
641: p.setFirstRow((short) 0);
642: p.setLastRow((short) 31);
643: tokens.add(p);
644: formula.setFormulaTokens(tokens);
645: r.setFormulaOfLink(formula);
646: return r;
647: }
648:
649: private LinkedDataRecord createTitleLinkedDataRecord() {
650: LinkedDataRecord r = new LinkedDataRecord();
651: r.setLinkType(LinkedDataRecord.LINK_TYPE_TITLE_OR_TEXT);
652: r.setReferenceType(LinkedDataRecord.REFERENCE_TYPE_DIRECT);
653: r.setCustomNumberFormat(false);
654: r.setIndexNumberFmtRecord((short) 0);
655: r.setFormulaOfLink(new LinkedDataFormulaField());
656: return r;
657: }
658:
659: private SeriesRecord createSeriesRecord() {
660: SeriesRecord r = new SeriesRecord();
661: r.setCategoryDataType(SeriesRecord.CATEGORY_DATA_TYPE_NUMERIC);
662: r.setValuesDataType(SeriesRecord.VALUES_DATA_TYPE_NUMERIC);
663: r.setNumCategories((short) 32);
664: r.setNumValues((short) 31);
665: r.setBubbleSeriesType(SeriesRecord.BUBBLE_SERIES_TYPE_NUMERIC);
666: r.setNumBubbleValues((short) 0);
667: return r;
668: }
669:
670: private EndRecord createEndRecord() {
671: return new EndRecord();
672: }
673:
674: private AreaFormatRecord createAreaFormatRecord1() {
675: AreaFormatRecord r = new AreaFormatRecord();
676: r.setForegroundColor(16777215); // RGB Color
677: r.setBackgroundColor(0); // RGB Color
678: r.setPattern((short) 1); // TODO: Add Pattern constants to record
679: r.setAutomatic(true);
680: r.setInvert(false);
681: r.setForecolorIndex((short) 78);
682: r.setBackcolorIndex((short) 77);
683: return r;
684: }
685:
686: private AreaFormatRecord createAreaFormatRecord2() {
687: AreaFormatRecord r = new AreaFormatRecord();
688: r.setForegroundColor(0x00c0c0c0);
689: r.setBackgroundColor(0x00000000);
690: r.setPattern((short) 1);
691: r.setAutomatic(false);
692: r.setInvert(false);
693: r.setForecolorIndex((short) 22);
694: r.setBackcolorIndex((short) 79);
695: return r;
696: }
697:
698: private LineFormatRecord createLineFormatRecord(boolean drawTicks) {
699: LineFormatRecord r = new LineFormatRecord();
700: r.setLineColor(0);
701: r.setLinePattern(LineFormatRecord.LINE_PATTERN_SOLID);
702: r.setWeight((short) -1);
703: r.setAuto(true);
704: r.setDrawTicks(drawTicks);
705: r.setColourPaletteIndex((short) 77); // what colour is this?
706: return r;
707: }
708:
709: private LineFormatRecord createLineFormatRecord2() {
710: LineFormatRecord r = new LineFormatRecord();
711: r.setLineColor(0x00808080);
712: r.setLinePattern((short) 0);
713: r.setWeight((short) 0);
714: r.setAuto(false);
715: r.setDrawTicks(false);
716: r.setUnknown(false);
717: r.setColourPaletteIndex((short) 23);
718: return r;
719: }
720:
721: private FrameRecord createFrameRecord1() {
722: FrameRecord r = new FrameRecord();
723: r.setBorderType(FrameRecord.BORDER_TYPE_REGULAR);
724: r.setAutoSize(false);
725: r.setAutoPosition(true);
726: return r;
727: }
728:
729: private FrameRecord createFrameRecord2() {
730: FrameRecord r = new FrameRecord();
731: r.setBorderType(FrameRecord.BORDER_TYPE_REGULAR);
732: r.setAutoSize(true);
733: r.setAutoPosition(true);
734: return r;
735: }
736:
737: private PlotGrowthRecord createPlotGrowthRecord(int horizScale,
738: int vertScale) {
739: PlotGrowthRecord r = new PlotGrowthRecord();
740: r.setHorizontalScale(horizScale);
741: r.setVerticalScale(vertScale);
742: return r;
743: }
744:
745: private SCLRecord createSCLRecord(short numerator, short denominator) {
746: SCLRecord r = new SCLRecord();
747: r.setDenominator(denominator);
748: r.setNumerator(numerator);
749: return r;
750: }
751:
752: private BeginRecord createBeginRecord() {
753: return new BeginRecord();
754: }
755:
756: private ChartRecord createChartRecord(int x, int y, int width,
757: int height) {
758: ChartRecord r = new ChartRecord();
759: r.setX(x);
760: r.setY(y);
761: r.setWidth(width);
762: r.setHeight(height);
763: return r;
764: }
765:
766: private UnitsRecord createUnitsRecord() {
767: UnitsRecord r = new UnitsRecord();
768: r.setUnits((short) 0);
769: return r;
770: }
771: }
|