Make a bit of a start on being able to edit chart titles, based on the email to user...
[poi.git] / src / scratchpad / src / org / apache / poi / hssf / usermodel / HSSFChart.java
blobd708a5c1daf31f8ba73675101c1b77f17075c336
2 /* ====================================================================
3 Licensed to the Apache Software Foundation (ASF) under one or more
4 contributor license agreements. See the NOTICE file distributed with
5 this work for additional information regarding copyright ownership.
6 The ASF licenses this file to You under the Apache License, Version 2.0
7 (the "License"); you may not use this file except in compliance with
8 the License. You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17 ==================================================================== */
20 package org.apache.poi.hssf.usermodel;
22 import org.apache.poi.hssf.record.*;
23 import org.apache.poi.hssf.record.formula.Area3DPtg;
25 import java.util.ArrayList;
26 import java.util.Iterator;
27 import java.util.List;
28 import java.util.Stack;
30 /**
31 * Has methods for construction of a chart object.
33 * @author Glen Stampoultzis (glens at apache.org)
35 public class HSSFChart
37 private ChartRecord chartRecord;
38 private SeriesRecord seriesRecord;
40 private ChartTitleFormatRecord chartTitleFormat;
41 private SeriesTextRecord chartTitleText;
43 private HSSFChart(ChartRecord chartRecord) {
44 this.chartRecord = chartRecord;
47 /**
48 * Creates a bar chart. API needs some work. :)
49 * <p>
50 * NOTE: Does not yet work... checking it in just so others
51 * can take a look.
53 public void createBarChart( HSSFWorkbook workbook, HSSFSheet sheet )
56 List records = new ArrayList();
57 records.add( createMSDrawingObjectRecord() );
58 records.add( createOBJRecord() );
59 records.add( createBOFRecord() );
60 records.add( createHeaderRecord() );
61 records.add( createFooterRecord() );
62 records.add( createHCenterRecord() );
63 records.add( createVCenterRecord() );
64 records.add( createPrintSetupRecord() );
65 // unknown 33
66 records.add( createFontBasisRecord1() );
67 records.add( createFontBasisRecord2() );
68 records.add( createProtectRecord() );
69 records.add( createUnitsRecord() );
70 records.add( createChartRecord( 0, 0, 30434904, 19031616 ) );
71 records.add( createBeginRecord() );
72 records.add( createSCLRecord( (short) 1, (short) 1 ) );
73 records.add( createPlotGrowthRecord( 65536, 65536 ) );
74 records.add( createFrameRecord1() );
75 records.add( createBeginRecord() );
76 records.add( createLineFormatRecord(true) );
77 records.add( createAreaFormatRecord1() );
78 records.add( createEndRecord() );
79 records.add( createSeriesRecord() );
80 records.add( createBeginRecord() );
81 records.add( createTitleLinkedDataRecord() );
82 records.add( createValuesLinkedDataRecord() );
83 records.add( createCategoriesLinkedDataRecord() );
84 records.add( createDataFormatRecord() );
85 // records.add(createBeginRecord());
86 // unknown
87 // records.add(createEndRecord());
88 records.add( createSeriesToChartGroupRecord() );
89 records.add( createEndRecord() );
90 records.add( createSheetPropsRecord() );
91 records.add( createDefaultTextRecord( DefaultDataLabelTextPropertiesRecord.CATEGORY_DATA_TYPE_ALL_TEXT_CHARACTERISTIC ) );
92 records.add( createAllTextRecord() );
93 records.add( createBeginRecord() );
94 // unknown
95 records.add( createFontIndexRecord( 5 ) );
96 records.add( createDirectLinkRecord() );
97 records.add( createEndRecord() );
98 records.add( createDefaultTextRecord( (short) 3 ) ); // eek, undocumented text type
99 records.add( createUnknownTextRecord() );
100 records.add( createBeginRecord() );
101 records.add( createFontIndexRecord( (short) 6 ) );
102 records.add( createDirectLinkRecord() );
103 records.add( createEndRecord() );
105 records.add( createAxisUsedRecord( (short) 1 ) );
106 createAxisRecords( records );
108 records.add( createEndRecord() );
109 records.add( createDimensionsRecord() );
110 records.add( createSeriesIndexRecord(2) );
111 records.add( createSeriesIndexRecord(1) );
112 records.add( createSeriesIndexRecord(3) );
113 records.add( createEOFRecord() );
117 sheet.insertChartRecords( records );
118 workbook.insertChartRecord();
122 * Returns all the charts for the given sheet.
124 * NOTE: Does not yet work... checking it in just so others
125 * can take a look.
127 public static HSSFChart[] getSheetCharts(HSSFSheet sheet) {
128 List charts = new ArrayList();
129 HSSFChart lastChart = null;
131 // Find records of interest
132 List records = sheet.getSheet().getRecords();
133 for(Iterator it = records.iterator(); it.hasNext();) {
134 Record r = (Record)it.next();
135 System.err.println(r);
137 if(r instanceof DrawingRecord) {
138 DrawingRecord dr = (DrawingRecord)r;
141 if(r instanceof ChartRecord) {
142 lastChart = new HSSFChart((ChartRecord)r);
143 charts.add(lastChart);
145 if(r instanceof SeriesRecord) {
146 lastChart.seriesRecord = (SeriesRecord)r;
148 if(r instanceof ChartTitleFormatRecord) {
149 lastChart.chartTitleFormat =
150 (ChartTitleFormatRecord)r;
152 if(r instanceof SeriesTextRecord) {
153 lastChart.chartTitleText =
154 (SeriesTextRecord)r;
158 return (HSSFChart[])
159 charts.toArray( new HSSFChart[charts.size()] );
164 * Returns the chart's title, if there is one,
165 * or null if not
167 public String getChartTitle() {
168 if(chartTitleText != null) {
169 return chartTitleText.getText();
171 return null;
175 * Changes the chart's title, but only if there
176 * was one already.
177 * TODO - add in the records if not
179 public void setChartTitle(String title) {
180 if(chartTitleText != null) {
181 chartTitleText.setText(title);
182 } else {
183 throw new IllegalStateException("No chart title found to change");
189 private EOFRecord createEOFRecord()
191 return new EOFRecord();
194 private SeriesIndexRecord createSeriesIndexRecord( int index )
196 SeriesIndexRecord r = new SeriesIndexRecord();
197 r.setIndex((short)index);
198 return r;
201 private DimensionsRecord createDimensionsRecord()
203 DimensionsRecord r = new DimensionsRecord();
204 r.setFirstRow(0);
205 r.setLastRow(31);
206 r.setFirstCol((short)0);
207 r.setLastCol((short)1);
208 return r;
211 private HCenterRecord createHCenterRecord()
213 HCenterRecord r = new HCenterRecord();
214 r.setHCenter(false);
215 return r;
218 private VCenterRecord createVCenterRecord()
220 VCenterRecord r = new VCenterRecord();
221 r.setVCenter(false);
222 return r;
225 private PrintSetupRecord createPrintSetupRecord()
227 PrintSetupRecord r = new PrintSetupRecord();
228 r.setPaperSize((short)0);
229 r.setScale((short)18);
230 r.setPageStart((short)1);
231 r.setFitWidth((short)1);
232 r.setFitHeight((short)1);
233 r.setLeftToRight(false);
234 r.setLandscape(false);
235 r.setValidSettings(true);
236 r.setNoColor(false);
237 r.setDraft(false);
238 r.setNotes(false);
239 r.setNoOrientation(false);
240 r.setUsePage(false);
241 r.setHResolution((short)0);
242 r.setVResolution((short)0);
243 r.setHeaderMargin(0.5);
244 r.setFooterMargin(0.5);
245 r.setCopies((short)15); // what the ??
246 return r;
249 private FontBasisRecord createFontBasisRecord1()
251 FontBasisRecord r = new FontBasisRecord();
252 r.setXBasis((short)9120);
253 r.setYBasis((short)5640);
254 r.setHeightBasis((short)200);
255 r.setScale((short)0);
256 r.setIndexToFontTable((short)5);
257 return r;
260 private FontBasisRecord createFontBasisRecord2()
262 FontBasisRecord r = createFontBasisRecord1();
263 r.setIndexToFontTable((short)6);
264 return r;
267 private ProtectRecord createProtectRecord()
269 ProtectRecord r = new ProtectRecord();
270 r.setProtect(false);
271 return r;
274 private FooterRecord createFooterRecord()
276 FooterRecord r = new FooterRecord();
277 r.setFooter(null);
278 return r;
281 private HeaderRecord createHeaderRecord()
283 HeaderRecord r = new HeaderRecord();
284 r.setHeader(null);
285 return r;
288 private BOFRecord createBOFRecord()
290 BOFRecord r = new BOFRecord();
291 r.setVersion((short)600);
292 r.setType((short)20);
293 r.setBuild((short)0x1CFE);
294 r.setBuildYear((short)1997);
295 r.setHistoryBitMask(0x40C9);
296 r.setRequiredVersion(106);
297 return r;
300 private UnknownRecord createOBJRecord()
302 byte[] data = {
303 (byte) 0x15, (byte) 0x00, (byte) 0x12, (byte) 0x00, (byte) 0x05, (byte) 0x00, (byte) 0x02, (byte) 0x00, (byte) 0x11, (byte) 0x60, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0xB8, (byte) 0x03,
304 (byte) 0x87, (byte) 0x03, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
307 return new UnknownRecord( (short) 0x005D, data );
310 private UnknownRecord createMSDrawingObjectRecord()
312 // Since we haven't created this object yet we'll just put in the raw
313 // form for the moment.
315 byte[] data = {
316 (byte)0x0F, (byte)0x00, (byte)0x02, (byte)0xF0, (byte)0xC0, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x10, (byte)0x00, (byte)0x08, (byte)0xF0, (byte)0x08, (byte)0x00, (byte)0x00, (byte)0x00,
317 (byte)0x02, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x02, (byte)0x04, (byte)0x00, (byte)0x00, (byte)0x0F, (byte)0x00, (byte)0x03, (byte)0xF0, (byte)0xA8, (byte)0x00, (byte)0x00, (byte)0x00,
318 (byte)0x0F, (byte)0x00, (byte)0x04, (byte)0xF0, (byte)0x28, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x01, (byte)0x00, (byte)0x09, (byte)0xF0, (byte)0x10, (byte)0x00, (byte)0x00, (byte)0x00,
319 (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
320 (byte)0x02, (byte)0x00, (byte)0x0A, (byte)0xF0, (byte)0x08, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x04, (byte)0x00, (byte)0x00, (byte)0x05, (byte)0x00, (byte)0x00, (byte)0x00,
321 (byte)0x0F, (byte)0x00, (byte)0x04, (byte)0xF0, (byte)0x70, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x92, (byte)0x0C, (byte)0x0A, (byte)0xF0, (byte)0x08, (byte)0x00, (byte)0x00, (byte)0x00,
322 (byte)0x02, (byte)0x04, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x0A, (byte)0x00, (byte)0x00, (byte)0x93, (byte)0x00, (byte)0x0B, (byte)0xF0, (byte)0x36, (byte)0x00, (byte)0x00, (byte)0x00,
323 (byte)0x7F, (byte)0x00, (byte)0x04, (byte)0x01, (byte)0x04, (byte)0x01, (byte)0xBF, (byte)0x00, (byte)0x08, (byte)0x00, (byte)0x08, (byte)0x00, (byte)0x81, (byte)0x01, (byte)0x4E, (byte)0x00,
324 (byte)0x00, (byte)0x08, (byte)0x83, (byte)0x01, (byte)0x4D, (byte)0x00, (byte)0x00, (byte)0x08, (byte)0xBF, (byte)0x01, (byte)0x10, (byte)0x00, (byte)0x11, (byte)0x00, (byte)0xC0, (byte)0x01,
325 (byte)0x4D, (byte)0x00, (byte)0x00, (byte)0x08, (byte)0xFF, (byte)0x01, (byte)0x08, (byte)0x00, (byte)0x08, (byte)0x00, (byte)0x3F, (byte)0x02, (byte)0x00, (byte)0x00, (byte)0x02, (byte)0x00,
326 (byte)0xBF, (byte)0x03, (byte)0x00, (byte)0x00, (byte)0x08, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x10, (byte)0xF0, (byte)0x12, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
327 (byte)0x04, (byte)0x00, (byte)0xC0, (byte)0x02, (byte)0x0A, (byte)0x00, (byte)0xF4, (byte)0x00, (byte)0x0E, (byte)0x00, (byte)0x66, (byte)0x01, (byte)0x20, (byte)0x00, (byte)0xE9, (byte)0x00,
328 (byte)0x00, (byte)0x00, (byte)0x11, (byte)0xF0, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00
331 return new UnknownRecord((short)0x00EC, data);
334 private void createAxisRecords( List records )
336 records.add( createAxisParentRecord() );
337 records.add( createBeginRecord() );
338 records.add( createAxisRecord( AxisRecord.AXIS_TYPE_CATEGORY_OR_X_AXIS ) );
339 records.add( createBeginRecord() );
340 records.add( createCategorySeriesAxisRecord() );
341 records.add( createAxisOptionsRecord() );
342 records.add( createTickRecord1() );
343 records.add( createEndRecord() );
344 records.add( createAxisRecord( AxisRecord.AXIS_TYPE_VALUE_AXIS ) );
345 records.add( createBeginRecord() );
346 records.add( createValueRangeRecord() );
347 records.add( createTickRecord2() );
348 records.add( createAxisLineFormatRecord( AxisLineFormatRecord.AXIS_TYPE_MAJOR_GRID_LINE ) );
349 records.add( createLineFormatRecord(false) );
350 records.add( createEndRecord() );
351 records.add( createPlotAreaRecord() );
352 records.add( createFrameRecord2() );
353 records.add( createBeginRecord() );
354 records.add( createLineFormatRecord2() );
355 records.add( createAreaFormatRecord2() );
356 records.add( createEndRecord() );
357 records.add( createChartFormatRecord() );
358 records.add( createBeginRecord() );
359 records.add( createBarRecord() );
360 // unknown 1022
361 records.add( createLegendRecord() );
362 records.add( createBeginRecord() );
363 // unknown 104f
364 records.add( createTextRecord() );
365 records.add( createBeginRecord() );
366 // unknown 104f
367 records.add( createLinkedDataRecord() );
368 records.add( createEndRecord() );
369 records.add( createEndRecord() );
370 records.add( createEndRecord() );
371 records.add( createEndRecord() );
374 private LinkedDataRecord createLinkedDataRecord()
376 LinkedDataRecord r = new LinkedDataRecord();
377 r.setLinkType(LinkedDataRecord.LINK_TYPE_TITLE_OR_TEXT);
378 r.setReferenceType(LinkedDataRecord.REFERENCE_TYPE_DIRECT);
379 r.setCustomNumberFormat(false);
380 r.setIndexNumberFmtRecord((short)0);
381 r.setFormulaOfLink( new LinkedDataFormulaField() );
382 return r;
385 private TextRecord createTextRecord()
387 TextRecord r = new TextRecord();
388 r.setHorizontalAlignment(TextRecord.HORIZONTAL_ALIGNMENT_CENTER);
389 r.setVerticalAlignment(TextRecord.VERTICAL_ALIGNMENT_CENTER);
390 r.setDisplayMode((short)1);
391 r.setRgbColor(0x00000000);
392 r.setX(-37);
393 r.setY(-60);
394 r.setWidth(0);
395 r.setHeight(0);
396 r.setAutoColor(true);
397 r.setShowKey(false);
398 r.setShowValue(false);
399 r.setVertical(false);
400 r.setAutoGeneratedText(true);
401 r.setGenerated(true);
402 r.setAutoLabelDeleted(false);
403 r.setAutoBackground(true);
404 r.setRotation((short)0);
405 r.setShowCategoryLabelAsPercentage(false);
406 r.setShowValueAsPercentage(false);
407 r.setShowBubbleSizes(false);
408 r.setShowLabel(false);
409 r.setIndexOfColorValue((short)77);
410 r.setDataLabelPlacement((short)0);
411 r.setTextRotation((short)0);
412 return r;
415 private LegendRecord createLegendRecord()
417 LegendRecord r = new LegendRecord();
418 r.setXAxisUpperLeft(3542);
419 r.setYAxisUpperLeft(1566);
420 r.setXSize(437);
421 r.setYSize(213);
422 r.setType(LegendRecord.TYPE_RIGHT);
423 r.setSpacing(LegendRecord.SPACING_MEDIUM);
424 r.setAutoPosition(true);
425 r.setAutoSeries(true);
426 r.setAutoXPositioning(true);
427 r.setAutoYPositioning(true);
428 r.setVertical(true);
429 r.setDataTable(false);
430 return r;
433 private BarRecord createBarRecord()
435 BarRecord r = new BarRecord();
436 r.setBarSpace((short)0);
437 r.setCategorySpace((short)150);
438 r.setHorizontal(false);
439 r.setStacked(false);
440 r.setDisplayAsPercentage(false);
441 r.setShadow(false);
442 return r;
445 private ChartFormatRecord createChartFormatRecord()
447 ChartFormatRecord r = new ChartFormatRecord();
448 r.setXPosition(0);
449 r.setYPosition(0);
450 r.setWidth(0);
451 r.setHeight(0);
452 r.setVaryDisplayPattern(false);
453 return r;
456 private PlotAreaRecord createPlotAreaRecord()
458 PlotAreaRecord r = new PlotAreaRecord( );
459 return r;
462 private AxisLineFormatRecord createAxisLineFormatRecord( short format )
464 AxisLineFormatRecord r = new AxisLineFormatRecord();
465 r.setAxisType( format );
466 return r;
469 private ValueRangeRecord createValueRangeRecord()
471 ValueRangeRecord r = new ValueRangeRecord();
472 r.setMinimumAxisValue( 0.0 );
473 r.setMaximumAxisValue( 0.0 );
474 r.setMajorIncrement( 0 );
475 r.setMinorIncrement( 0 );
476 r.setCategoryAxisCross( 0 );
477 r.setAutomaticMinimum( true );
478 r.setAutomaticMaximum( true );
479 r.setAutomaticMajor( true );
480 r.setAutomaticMinor( true );
481 r.setAutomaticCategoryCrossing( true );
482 r.setLogarithmicScale( false );
483 r.setValuesInReverse( false );
484 r.setCrossCategoryAxisAtMaximum( false );
485 r.setReserved( true ); // what's this do??
486 return r;
489 private TickRecord createTickRecord1()
491 TickRecord r = new TickRecord();
492 r.setMajorTickType( (byte) 2 );
493 r.setMinorTickType( (byte) 0 );
494 r.setLabelPosition( (byte) 3 );
495 r.setBackground( (byte) 1 );
496 r.setLabelColorRgb( 0 );
497 r.setZero1( (short) 0 );
498 r.setZero2( (short) 0 );
499 r.setZero3( (short) 45 );
500 r.setAutorotate( true );
501 r.setAutoTextBackground( true );
502 r.setRotation( (short) 0 );
503 r.setAutorotate( true );
504 r.setTickColor( (short) 77 );
505 return r;
508 private TickRecord createTickRecord2()
510 TickRecord r = createTickRecord1();
511 r.setZero3((short)0);
512 return r;
515 private AxisOptionsRecord createAxisOptionsRecord()
517 AxisOptionsRecord r = new AxisOptionsRecord();
518 r.setMinimumCategory( (short) -28644 );
519 r.setMaximumCategory( (short) -28715 );
520 r.setMajorUnitValue( (short) 2 );
521 r.setMajorUnit( (short) 0 );
522 r.setMinorUnitValue( (short) 1 );
523 r.setMinorUnit( (short) 0 );
524 r.setBaseUnit( (short) 0 );
525 r.setCrossingPoint( (short) -28644 );
526 r.setDefaultMinimum( true );
527 r.setDefaultMaximum( true );
528 r.setDefaultMajor( true );
529 r.setDefaultMinorUnit( true );
530 r.setIsDate( true );
531 r.setDefaultBase( true );
532 r.setDefaultCross( true );
533 r.setDefaultDateSettings( true );
534 return r;
537 private CategorySeriesAxisRecord createCategorySeriesAxisRecord()
539 CategorySeriesAxisRecord r = new CategorySeriesAxisRecord();
540 r.setCrossingPoint( (short) 1 );
541 r.setLabelFrequency( (short) 1 );
542 r.setTickMarkFrequency( (short) 1 );
543 r.setValueAxisCrossing( true );
544 r.setCrossesFarRight( false );
545 r.setReversed( false );
546 return r;
549 private AxisRecord createAxisRecord( short axisType )
551 AxisRecord r = new AxisRecord();
552 r.setAxisType( axisType );
553 return r;
556 private AxisParentRecord createAxisParentRecord()
558 AxisParentRecord r = new AxisParentRecord();
559 r.setAxisType( AxisParentRecord.AXIS_TYPE_MAIN );
560 r.setX( 479 );
561 r.setY( 221 );
562 r.setWidth( 2995 );
563 r.setHeight( 2902 );
564 return r;
567 private AxisUsedRecord createAxisUsedRecord( short numAxis )
569 AxisUsedRecord r = new AxisUsedRecord();
570 r.setNumAxis( numAxis );
571 return r;
574 private LinkedDataRecord createDirectLinkRecord()
576 LinkedDataRecord r = new LinkedDataRecord();
577 r.setLinkType( LinkedDataRecord.LINK_TYPE_TITLE_OR_TEXT );
578 r.setReferenceType( LinkedDataRecord.REFERENCE_TYPE_DIRECT );
579 r.setCustomNumberFormat( false );
580 r.setIndexNumberFmtRecord( (short) 0 );
581 r.setFormulaOfLink( new LinkedDataFormulaField() );
582 return r;
585 private FontIndexRecord createFontIndexRecord( int index )
587 FontIndexRecord r = new FontIndexRecord();
588 r.setFontIndex( (short) index );
589 return r;
592 private TextRecord createAllTextRecord()
594 TextRecord r = new TextRecord();
595 r.setHorizontalAlignment( TextRecord.HORIZONTAL_ALIGNMENT_CENTER );
596 r.setVerticalAlignment( TextRecord.VERTICAL_ALIGNMENT_CENTER );
597 r.setDisplayMode( TextRecord.DISPLAY_MODE_TRANSPARENT );
598 r.setRgbColor( 0 );
599 r.setX( -37 );
600 r.setY( -60 );
601 r.setWidth( 0 );
602 r.setHeight( 0 );
603 r.setAutoColor( true );
604 r.setShowKey( false );
605 r.setShowValue( true );
606 r.setVertical( false );
607 r.setAutoGeneratedText( true );
608 r.setGenerated( true );
609 r.setAutoLabelDeleted( false );
610 r.setAutoBackground( true );
611 r.setRotation( (short) 0 );
612 r.setShowCategoryLabelAsPercentage( false );
613 r.setShowValueAsPercentage( false );
614 r.setShowBubbleSizes( false );
615 r.setShowLabel( false );
616 r.setIndexOfColorValue( (short) 77 );
617 r.setDataLabelPlacement( (short) 0 );
618 r.setTextRotation( (short) 0 );
619 return r;
622 private TextRecord createUnknownTextRecord()
624 TextRecord r = new TextRecord();
625 r.setHorizontalAlignment( TextRecord.HORIZONTAL_ALIGNMENT_CENTER );
626 r.setVerticalAlignment( TextRecord.VERTICAL_ALIGNMENT_CENTER );
627 r.setDisplayMode( TextRecord.DISPLAY_MODE_TRANSPARENT );
628 r.setRgbColor( 0 );
629 r.setX( -37 );
630 r.setY( -60 );
631 r.setWidth( 0 );
632 r.setHeight( 0 );
633 r.setAutoColor( true );
634 r.setShowKey( false );
635 r.setShowValue( false );
636 r.setVertical( false );
637 r.setAutoGeneratedText( true );
638 r.setGenerated( true );
639 r.setAutoLabelDeleted( false );
640 r.setAutoBackground( true );
641 r.setRotation( (short) 0 );
642 r.setShowCategoryLabelAsPercentage( false );
643 r.setShowValueAsPercentage( false );
644 r.setShowBubbleSizes( false );
645 r.setShowLabel( false );
646 r.setIndexOfColorValue( (short) 77 );
647 r.setDataLabelPlacement( (short) 11088 );
648 r.setTextRotation( (short) 0 );
649 return r;
652 private DefaultDataLabelTextPropertiesRecord createDefaultTextRecord( short categoryDataType )
654 DefaultDataLabelTextPropertiesRecord r = new DefaultDataLabelTextPropertiesRecord();
655 r.setCategoryDataType( categoryDataType );
656 return r;
659 private SheetPropertiesRecord createSheetPropsRecord()
661 SheetPropertiesRecord r = new SheetPropertiesRecord();
662 r.setChartTypeManuallyFormatted( false );
663 r.setPlotVisibleOnly( true );
664 r.setDoNotSizeWithWindow( false );
665 r.setDefaultPlotDimensions( true );
666 r.setAutoPlotArea( false );
667 return r;
670 private SeriesToChartGroupRecord createSeriesToChartGroupRecord()
672 return new SeriesToChartGroupRecord();
675 private DataFormatRecord createDataFormatRecord()
677 DataFormatRecord r = new DataFormatRecord();
678 r.setPointNumber( (short) -1 );
679 r.setSeriesIndex( (short) 0 );
680 r.setSeriesNumber( (short) 0 );
681 r.setUseExcel4Colors( false );
682 return r;
685 private LinkedDataRecord createCategoriesLinkedDataRecord()
687 LinkedDataRecord r = new LinkedDataRecord();
688 r.setLinkType( LinkedDataRecord.LINK_TYPE_CATEGORIES );
689 r.setReferenceType( LinkedDataRecord.REFERENCE_TYPE_WORKSHEET );
690 r.setCustomNumberFormat( false );
691 r.setIndexNumberFmtRecord( (short) 0 );
692 LinkedDataFormulaField formula = new LinkedDataFormulaField();
693 Stack tokens = new Stack();
694 Area3DPtg p = new Area3DPtg();
695 p.setExternSheetIndex( (short) 0 );
696 p.setFirstColumn( (short) 1 );
697 p.setLastColumn( (short) 1 );
698 p.setFirstRow( (short) 0 );
699 p.setLastRow( (short) 31 );
700 tokens.add( p );
701 formula.setFormulaTokens( tokens );
702 r.setFormulaOfLink( formula );
703 return r;
706 private LinkedDataRecord createValuesLinkedDataRecord()
708 LinkedDataRecord r = new LinkedDataRecord();
709 r.setLinkType( LinkedDataRecord.LINK_TYPE_VALUES );
710 r.setReferenceType( LinkedDataRecord.REFERENCE_TYPE_WORKSHEET );
711 r.setCustomNumberFormat( false );
712 r.setIndexNumberFmtRecord( (short) 0 );
713 LinkedDataFormulaField formula = new LinkedDataFormulaField();
714 Stack tokens = new Stack();
715 Area3DPtg p = new Area3DPtg();
716 p.setExternSheetIndex( (short) 0 );
717 p.setFirstColumn( (short) 0 );
718 p.setLastColumn( (short) 0 );
719 p.setFirstRow( (short) 0 );
720 p.setLastRow( (short) 31 );
721 tokens.add( p );
722 formula.setFormulaTokens( tokens );
723 r.setFormulaOfLink( formula );
724 return r;
727 private LinkedDataRecord createTitleLinkedDataRecord()
729 LinkedDataRecord r = new LinkedDataRecord();
730 r.setLinkType( LinkedDataRecord.LINK_TYPE_TITLE_OR_TEXT );
731 r.setReferenceType( LinkedDataRecord.REFERENCE_TYPE_DIRECT );
732 r.setCustomNumberFormat( false );
733 r.setIndexNumberFmtRecord( (short) 0 );
734 r.setFormulaOfLink( new LinkedDataFormulaField() );
735 return r;
738 private SeriesRecord createSeriesRecord()
740 SeriesRecord r = new SeriesRecord();
741 r.setCategoryDataType( SeriesRecord.CATEGORY_DATA_TYPE_NUMERIC );
742 r.setValuesDataType( SeriesRecord.VALUES_DATA_TYPE_NUMERIC );
743 r.setNumCategories( (short) 32 );
744 r.setNumValues( (short) 31 );
745 r.setBubbleSeriesType( SeriesRecord.BUBBLE_SERIES_TYPE_NUMERIC );
746 r.setNumBubbleValues( (short) 0 );
747 return r;
750 private EndRecord createEndRecord()
752 return new EndRecord();
755 private AreaFormatRecord createAreaFormatRecord1()
757 AreaFormatRecord r = new AreaFormatRecord();
758 r.setForegroundColor( 16777215 ); // RGB Color
759 r.setBackgroundColor( 0 ); // RGB Color
760 r.setPattern( (short) 1 ); // TODO: Add Pattern constants to record
761 r.setAutomatic( true );
762 r.setInvert( false );
763 r.setForecolorIndex( (short) 78 );
764 r.setBackcolorIndex( (short) 77 );
765 return r;
768 private AreaFormatRecord createAreaFormatRecord2()
770 AreaFormatRecord r = new AreaFormatRecord();
771 r.setForegroundColor(0x00c0c0c0);
772 r.setBackgroundColor(0x00000000);
773 r.setPattern((short)1);
774 r.setAutomatic(false);
775 r.setInvert(false);
776 r.setForecolorIndex((short)22);
777 r.setBackcolorIndex((short)79);
778 return r;
781 private LineFormatRecord createLineFormatRecord( boolean drawTicks )
783 LineFormatRecord r = new LineFormatRecord();
784 r.setLineColor( 0 );
785 r.setLinePattern( LineFormatRecord.LINE_PATTERN_SOLID );
786 r.setWeight( (short) -1 );
787 r.setAuto( true );
788 r.setDrawTicks( drawTicks );
789 r.setColourPaletteIndex( (short) 77 ); // what colour is this?
790 return r;
793 private LineFormatRecord createLineFormatRecord2()
795 LineFormatRecord r = new LineFormatRecord();
796 r.setLineColor( 0x00808080 );
797 r.setLinePattern( (short) 0 );
798 r.setWeight( (short) 0 );
799 r.setAuto( false );
800 r.setDrawTicks( false );
801 r.setUnknown( false );
802 r.setColourPaletteIndex( (short) 23 );
803 return r;
806 private FrameRecord createFrameRecord1()
808 FrameRecord r = new FrameRecord();
809 r.setBorderType( FrameRecord.BORDER_TYPE_REGULAR );
810 r.setAutoSize( false );
811 r.setAutoPosition( true );
812 return r;
815 private FrameRecord createFrameRecord2()
817 FrameRecord r = new FrameRecord();
818 r.setBorderType( FrameRecord.BORDER_TYPE_REGULAR );
819 r.setAutoSize( true );
820 r.setAutoPosition( true );
821 return r;
824 private PlotGrowthRecord createPlotGrowthRecord( int horizScale, int vertScale )
826 PlotGrowthRecord r = new PlotGrowthRecord();
827 r.setHorizontalScale( horizScale );
828 r.setVerticalScale( vertScale );
829 return r;
832 private SCLRecord createSCLRecord( short numerator, short denominator )
834 SCLRecord r = new SCLRecord();
835 r.setDenominator( denominator );
836 r.setNumerator( numerator );
837 return r;
840 private BeginRecord createBeginRecord()
842 return new BeginRecord();
845 private ChartRecord createChartRecord( int x, int y, int width, int height )
847 ChartRecord r = new ChartRecord();
848 r.setX( x );
849 r.setY( y );
850 r.setWidth( width );
851 r.setHeight( height );
852 return r;
855 private UnitsRecord createUnitsRecord()
857 UnitsRecord r = new UnitsRecord();
858 r.setUnits( (short) 0 );
859 return r;