1 2 17 18 19 package org.apache.poi.hssf.usermodel; 20 21 import org.apache.poi.hssf.record.*; 22 import org.apache.poi.hssf.record.formula.Area3DPtg; 23 24 import java.util.ArrayList ; 25 import java.util.List ; 26 import java.util.Stack ; 27 28 33 public class HSSFChart 34 { 35 36 42 public void createBarChart( HSSFWorkbook workbook, HSSFSheet sheet ) 43 { 44 45 List records = new ArrayList (); 46 records.add( createMSDrawingObjectRecord() ); 47 records.add( createOBJRecord() ); 48 records.add( createBOFRecord() ); 49 records.add( createHeaderRecord() ); 50 records.add( createFooterRecord() ); 51 records.add( createHCenterRecord() ); 52 records.add( createVCenterRecord() ); 53 records.add( createPrintSetupRecord() ); 54 records.add( createFontBasisRecord1() ); 56 records.add( createFontBasisRecord2() ); 57 records.add( createProtectRecord() ); 58 records.add( createUnitsRecord() ); 59 records.add( createChartRecord( 0, 0, 30434904, 19031616 ) ); 60 records.add( createBeginRecord() ); 61 records.add( createSCLRecord( (short) 1, (short) 1 ) ); 62 records.add( createPlotGrowthRecord( 65536, 65536 ) ); 63 records.add( createFrameRecord1() ); 64 records.add( createBeginRecord() ); 65 records.add( createLineFormatRecord(true) ); 66 records.add( createAreaFormatRecord1() ); 67 records.add( createEndRecord() ); 68 records.add( createSeriesRecord() ); 69 records.add( createBeginRecord() ); 70 records.add( createTitleLinkedDataRecord() ); 71 records.add( createValuesLinkedDataRecord() ); 72 records.add( createCategoriesLinkedDataRecord() ); 73 records.add( createDataFormatRecord() ); 74 records.add( createSeriesToChartGroupRecord() ); 78 records.add( createEndRecord() ); 79 records.add( createSheetPropsRecord() ); 80 records.add( createDefaultTextRecord( DefaultDataLabelTextPropertiesRecord.CATEGORY_DATA_TYPE_ALL_TEXT_CHARACTERISTIC ) ); 81 records.add( createAllTextRecord() ); 82 records.add( createBeginRecord() ); 83 records.add( createFontIndexRecord( 5 ) ); 85 records.add( createDirectLinkRecord() ); 86 records.add( createEndRecord() ); 87 records.add( createDefaultTextRecord( (short) 3 ) ); records.add( createUnknownTextRecord() ); 89 records.add( createBeginRecord() ); 90 records.add( createFontIndexRecord( (short) 6 ) ); 91 records.add( createDirectLinkRecord() ); 92 records.add( createEndRecord() ); 93 94 records.add( createAxisUsedRecord( (short) 1 ) ); 95 createAxisRecords( records ); 96 97 records.add( createEndRecord() ); 98 records.add( createDimensionsRecord() ); 99 records.add( createSeriesIndexRecord(2) ); 100 records.add( createSeriesIndexRecord(1) ); 101 records.add( createSeriesIndexRecord(3) ); 102 records.add( createEOFRecord() ); 103 104 105 106 sheet.insertChartRecords( records ); 107 workbook.insertChartRecord(); 108 } 109 110 private EOFRecord createEOFRecord() 111 { 112 return new EOFRecord(); 113 } 114 115 private SeriesIndexRecord createSeriesIndexRecord( int index ) 116 { 117 SeriesIndexRecord r = new SeriesIndexRecord(); 118 r.setIndex((short)index); 119 return r; 120 } 121 122 private DimensionsRecord createDimensionsRecord() 123 { 124 DimensionsRecord r = new DimensionsRecord(); 125 r.setFirstRow(0); 126 r.setLastRow(31); 127 r.setFirstCol((short)0); 128 r.setLastCol((short)1); 129 return r; 130 } 131 132 private HCenterRecord createHCenterRecord() 133 { 134 HCenterRecord r = new HCenterRecord(); 135 r.setHCenter(false); 136 return r; 137 } 138 139 private VCenterRecord createVCenterRecord() 140 { 141 VCenterRecord r = new VCenterRecord(); 142 r.setVCenter(false); 143 return r; 144 } 145 146 private PrintSetupRecord createPrintSetupRecord() 147 { 148 PrintSetupRecord r = new PrintSetupRecord(); 149 r.setPaperSize((short)0); 150 r.setScale((short)18); 151 r.setPageStart((short)1); 152 r.setFitWidth((short)1); 153 r.setFitHeight((short)1); 154 r.setLeftToRight(false); 155 r.setLandscape(false); 156 r.setValidSettings(true); 157 r.setNoColor(false); 158 r.setDraft(false); 159 r.setNotes(false); 160 r.setNoOrientation(false); 161 r.setUsePage(false); 162 r.setHResolution((short)0); 163 r.setVResolution((short)0); 164 r.setHeaderMargin(0.5); 165 r.setFooterMargin(0.5); 166 r.setCopies((short)15); return r; 168 } 169 170 private FontBasisRecord createFontBasisRecord1() 171 { 172 FontBasisRecord r = new FontBasisRecord(); 173 r.setXBasis((short)9120); 174 r.setYBasis((short)5640); 175 r.setHeightBasis((short)200); 176 r.setScale((short)0); 177 r.setIndexToFontTable((short)5); 178 return r; 179 } 180 181 private FontBasisRecord createFontBasisRecord2() 182 { 183 FontBasisRecord r = createFontBasisRecord1(); 184 r.setIndexToFontTable((short)6); 185 return r; 186 } 187 188 private ProtectRecord createProtectRecord() 189 { 190 ProtectRecord r = new ProtectRecord(); 191 r.setProtect(false); 192 return r; 193 } 194 195 private FooterRecord createFooterRecord() 196 { 197 FooterRecord r = new FooterRecord(); 198 r.setFooter(null); 199 return r; 200 } 201 202 private HeaderRecord createHeaderRecord() 203 { 204 HeaderRecord r = new HeaderRecord(); 205 r.setHeader(null); 206 return r; 207 } 208 209 private BOFRecord createBOFRecord() 210 { 211 BOFRecord r = new BOFRecord(); 212 r.setVersion((short)600); 213 r.setType((short)20); 214 r.setBuild((short)0x1CFE); 215 r.setBuildYear((short)1997); 216 r.setHistoryBitMask(0x40C9); 217 r.setRequiredVersion(106); 218 return r; 219 } 220 221 private UnknownRecord createOBJRecord() 222 { 223 byte[] data = { 224 (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, 225 (byte) 0x87, (byte) 0x03, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, 226 }; 227 228 return new UnknownRecord( (short) 0x005D, (short) 0x001a, data ); 229 } 230 231 private UnknownRecord createMSDrawingObjectRecord() 232 { 233 236 byte[] data = { 237 (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, 238 (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, 239 (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, 240 (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, 241 (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, 242 (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, 243 (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, 244 (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, 245 (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, 246 (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, 247 (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, 248 (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, 249 (byte)0x00, (byte)0x00, (byte)0x11, (byte)0xF0, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00 250 }; 251 252 return new UnknownRecord((short)0x00EC, (short)0x00C8, data); 253 } 254 255 private void createAxisRecords( List records ) 256 { 257 records.add( createAxisParentRecord() ); 258 records.add( createBeginRecord() ); 259 records.add( createAxisRecord( AxisRecord.AXIS_TYPE_CATEGORY_OR_X_AXIS ) ); 260 records.add( createBeginRecord() ); 261 records.add( createCategorySeriesAxisRecord() ); 262 records.add( createAxisOptionsRecord() ); 263 records.add( createTickRecord1() ); 264 records.add( createEndRecord() ); 265 records.add( createAxisRecord( AxisRecord.AXIS_TYPE_VALUE_AXIS ) ); 266 records.add( createBeginRecord() ); 267 records.add( createValueRangeRecord() ); 268 records.add( createTickRecord2() ); 269 records.add( createAxisLineFormatRecord( AxisLineFormatRecord.AXIS_TYPE_MAJOR_GRID_LINE ) ); 270 records.add( createLineFormatRecord(false) ); 271 records.add( createEndRecord() ); 272 records.add( createPlotAreaRecord() ); 273 records.add( createFrameRecord2() ); 274 records.add( createBeginRecord() ); 275 records.add( createLineFormatRecord2() ); 276 records.add( createAreaFormatRecord2() ); 277 records.add( createEndRecord() ); 278 records.add( createChartFormatRecord() ); 279 records.add( createBeginRecord() ); 280 records.add( createBarRecord() ); 281 records.add( createLegendRecord() ); 283 records.add( createBeginRecord() ); 284 records.add( createTextRecord() ); 286 records.add( createBeginRecord() ); 287 records.add( createLinkedDataRecord() ); 289 records.add( createEndRecord() ); 290 records.add( createEndRecord() ); 291 records.add( createEndRecord() ); 292 records.add( createEndRecord() ); 293 } 294 295 private LinkedDataRecord createLinkedDataRecord() 296 { 297 LinkedDataRecord r = new LinkedDataRecord(); 298 r.setLinkType(LinkedDataRecord.LINK_TYPE_TITLE_OR_TEXT); 299 r.setReferenceType(LinkedDataRecord.REFERENCE_TYPE_DIRECT); 300 r.setCustomNumberFormat(false); 301 r.setIndexNumberFmtRecord((short)0); 302 r.setFormulaOfLink( new LinkedDataFormulaField() ); 303 return r; 304 } 305 306 private TextRecord createTextRecord() 307 { 308 TextRecord r = new TextRecord(); 309 r.setHorizontalAlignment(TextRecord.HORIZONTAL_ALIGNMENT_CENTER); 310 r.setVerticalAlignment(TextRecord.VERTICAL_ALIGNMENT_CENTER); 311 r.setDisplayMode((short)1); 312 r.setRgbColor(0x00000000); 313 r.setX(-37); 314 r.setY(-60); 315 r.setWidth(0); 316 r.setHeight(0); 317 r.setAutoColor(true); 318 r.setShowKey(false); 319 r.setShowValue(false); 320 r.setVertical(false); 321 r.setAutoGeneratedText(true); 322 r.setGenerated(true); 323 r.setAutoLabelDeleted(false); 324 r.setAutoBackground(true); 325 r.setRotation((short)0); 326 r.setShowCategoryLabelAsPercentage(false); 327 r.setShowValueAsPercentage(false); 328 r.setShowBubbleSizes(false); 329 r.setShowLabel(false); 330 r.setIndexOfColorValue((short)77); 331 r.setDataLabelPlacement((short)0); 332 r.setTextRotation((short)0); 333 return r; 334 } 335 336 private LegendRecord createLegendRecord() 337 { 338 LegendRecord r = new LegendRecord(); 339 r.setXAxisUpperLeft(3542); 340 r.setYAxisUpperLeft(1566); 341 r.setXSize(437); 342 r.setYSize(213); 343 r.setType(LegendRecord.TYPE_RIGHT); 344 r.setSpacing(LegendRecord.SPACING_MEDIUM); 345 r.setAutoPosition(true); 346 r.setAutoSeries(true); 347 r.setAutoXPositioning(true); 348 r.setAutoYPositioning(true); 349 r.setVertical(true); 350 r.setDataTable(false); 351 return r; 352 } 353 354 private BarRecord createBarRecord() 355 { 356 BarRecord r = new BarRecord(); 357 r.setBarSpace((short)0); 358 r.setCategorySpace((short)150); 359 r.setHorizontal(false); 360 r.setStacked(false); 361 r.setDisplayAsPercentage(false); 362 r.setShadow(false); 363 return r; 364 } 365 366 private ChartFormatRecord createChartFormatRecord() 367 { 368 ChartFormatRecord r = new ChartFormatRecord(); 369 r.setXPosition(0); 370 r.setYPosition(0); 371 r.setWidth(0); 372 r.setHeight(0); 373 r.setVaryDisplayPattern(false); 374 return r; 375 } 376 377 private PlotAreaRecord createPlotAreaRecord() 378 { 379 PlotAreaRecord r = new PlotAreaRecord( ); 380 return r; 381 } 382 383 private AxisLineFormatRecord createAxisLineFormatRecord( short format ) 384 { 385 AxisLineFormatRecord r = new AxisLineFormatRecord(); 386 r.setAxisType( format ); 387 return r; 388 } 389 390 private ValueRangeRecord createValueRangeRecord() 391 { 392 ValueRangeRecord r = new ValueRangeRecord(); 393 r.setMinimumAxisValue( 0.0 ); 394 r.setMaximumAxisValue( 0.0 ); 395 r.setMajorIncrement( 0 ); 396 r.setMinorIncrement( 0 ); 397 r.setCategoryAxisCross( 0 ); 398 r.setAutomaticMinimum( true ); 399 r.setAutomaticMaximum( true ); 400 r.setAutomaticMajor( true ); 401 r.setAutomaticMinor( true ); 402 r.setAutomaticCategoryCrossing( true ); 403 r.setLogarithmicScale( false ); 404 r.setValuesInReverse( false ); 405 r.setCrossCategoryAxisAtMaximum( false ); 406 r.setReserved( true ); return r; 408 } 409 410 private TickRecord createTickRecord1() 411 { 412 TickRecord r = new TickRecord(); 413 r.setMajorTickType( (byte) 2 ); 414 r.setMinorTickType( (byte) 0 ); 415 r.setLabelPosition( (byte) 3 ); 416 r.setBackground( (byte) 1 ); 417 r.setLabelColorRgb( 0 ); 418 r.setZero1( (short) 0 ); 419 r.setZero2( (short) 0 ); 420 r.setZero3( (short) 45 ); 421 r.setAutorotate( true ); 422 r.setAutoTextBackground( true ); 423 r.setRotation( (short) 0 ); 424 r.setAutorotate( true ); 425 r.setTickColor( (short) 77 ); 426 return r; 427 } 428 429 private TickRecord createTickRecord2() 430 { 431 TickRecord r = createTickRecord1(); 432 r.setZero3((short)0); 433 return r; 434 } 435 436 private AxisOptionsRecord createAxisOptionsRecord() 437 { 438 AxisOptionsRecord r = new AxisOptionsRecord(); 439 r.setMinimumCategory( (short) -28644 ); 440 r.setMaximumCategory( (short) -28715 ); 441 r.setMajorUnitValue( (short) 2 ); 442 r.setMajorUnit( (short) 0 ); 443 r.setMinorUnitValue( (short) 1 ); 444 r.setMinorUnit( (short) 0 ); 445 r.setBaseUnit( (short) 0 ); 446 r.setCrossingPoint( (short) -28644 ); 447 r.setDefaultMinimum( true ); 448 r.setDefaultMaximum( true ); 449 r.setDefaultMajor( true ); 450 r.setDefaultMinorUnit( true ); 451 r.setIsDate( true ); 452 r.setDefaultBase( true ); 453 r.setDefaultCross( true ); 454 r.setDefaultDateSettings( true ); 455 return r; 456 } 457 458 private CategorySeriesAxisRecord createCategorySeriesAxisRecord() 459 { 460 CategorySeriesAxisRecord r = new CategorySeriesAxisRecord(); 461 r.setCrossingPoint( (short) 1 ); 462 r.setLabelFrequency( (short) 1 ); 463 r.setTickMarkFrequency( (short) 1 ); 464 r.setValueAxisCrossing( true ); 465 r.setCrossesFarRight( false ); 466 r.setReversed( false ); 467 return r; 468 } 469 470 private AxisRecord createAxisRecord( short axisType ) 471 { 472 AxisRecord r = new AxisRecord(); 473 r.setAxisType( axisType ); 474 return r; 475 } 476 477 private AxisParentRecord createAxisParentRecord() 478 { 479 AxisParentRecord r = new AxisParentRecord(); 480 r.setAxisType( AxisParentRecord.AXIS_TYPE_MAIN ); 481 r.setX( 479 ); 482 r.setY( 221 ); 483 r.setWidth( 2995 ); 484 r.setHeight( 2902 ); 485 return r; 486 } 487 488 private AxisUsedRecord createAxisUsedRecord( short numAxis ) 489 { 490 AxisUsedRecord r = new AxisUsedRecord(); 491 r.setNumAxis( numAxis ); 492 return r; 493 } 494 495 private LinkedDataRecord createDirectLinkRecord() 496 { 497 LinkedDataRecord r = new LinkedDataRecord(); 498 r.setLinkType( LinkedDataRecord.LINK_TYPE_TITLE_OR_TEXT ); 499 r.setReferenceType( LinkedDataRecord.REFERENCE_TYPE_DIRECT ); 500 r.setCustomNumberFormat( false ); 501 r.setIndexNumberFmtRecord( (short) 0 ); 502 r.setFormulaOfLink( new LinkedDataFormulaField() ); 503 return r; 504 } 505 506 private FontIndexRecord createFontIndexRecord( int index ) 507 { 508 FontIndexRecord r = new FontIndexRecord(); 509 r.setFontIndex( (short) index ); 510 return r; 511 } 512 513 private TextRecord createAllTextRecord() 514 { 515 TextRecord r = new TextRecord(); 516 r.setHorizontalAlignment( TextRecord.HORIZONTAL_ALIGNMENT_CENTER ); 517 r.setVerticalAlignment( TextRecord.VERTICAL_ALIGNMENT_CENTER ); 518 r.setDisplayMode( TextRecord.DISPLAY_MODE_TRANSPARENT ); 519 r.setRgbColor( 0 ); 520 r.setX( -37 ); 521 r.setY( -60 ); 522 r.setWidth( 0 ); 523 r.setHeight( 0 ); 524 r.setAutoColor( true ); 525 r.setShowKey( false ); 526 r.setShowValue( true ); 527 r.setVertical( false ); 528 r.setAutoGeneratedText( true ); 529 r.setGenerated( true ); 530 r.setAutoLabelDeleted( false ); 531 r.setAutoBackground( true ); 532 r.setRotation( (short) 0 ); 533 r.setShowCategoryLabelAsPercentage( false ); 534 r.setShowValueAsPercentage( false ); 535 r.setShowBubbleSizes( false ); 536 r.setShowLabel( false ); 537 r.setIndexOfColorValue( (short) 77 ); 538 r.setDataLabelPlacement( (short) 0 ); 539 r.setTextRotation( (short) 0 ); 540 return r; 541 } 542 543 private TextRecord createUnknownTextRecord() 544 { 545 TextRecord r = new TextRecord(); 546 r.setHorizontalAlignment( TextRecord.HORIZONTAL_ALIGNMENT_CENTER ); 547 r.setVerticalAlignment( TextRecord.VERTICAL_ALIGNMENT_CENTER ); 548 r.setDisplayMode( TextRecord.DISPLAY_MODE_TRANSPARENT ); 549 r.setRgbColor( 0 ); 550 r.setX( -37 ); 551 r.setY( -60 ); 552 r.setWidth( 0 ); 553 r.setHeight( 0 ); 554 r.setAutoColor( true ); 555 r.setShowKey( false ); 556 r.setShowValue( false ); 557 r.setVertical( false ); 558 r.setAutoGeneratedText( true ); 559 r.setGenerated( true ); 560 r.setAutoLabelDeleted( false ); 561 r.setAutoBackground( true ); 562 r.setRotation( (short) 0 ); 563 r.setShowCategoryLabelAsPercentage( false ); 564 r.setShowValueAsPercentage( false ); 565 r.setShowBubbleSizes( false ); 566 r.setShowLabel( false ); 567 r.setIndexOfColorValue( (short) 77 ); 568 r.setDataLabelPlacement( (short) 11088 ); 569 r.setTextRotation( (short) 0 ); 570 return r; 571 } 572 573 private DefaultDataLabelTextPropertiesRecord createDefaultTextRecord( short categoryDataType ) 574 { 575 DefaultDataLabelTextPropertiesRecord r = new DefaultDataLabelTextPropertiesRecord(); 576 r.setCategoryDataType( categoryDataType ); 577 return r; 578 } 579 580 private SheetPropertiesRecord createSheetPropsRecord() 581 { 582 SheetPropertiesRecord r = new SheetPropertiesRecord(); 583 r.setChartTypeManuallyFormatted( false ); 584 r.setPlotVisibleOnly( true ); 585 r.setDoNotSizeWithWindow( false ); 586 r.setDefaultPlotDimensions( true ); 587 r.setAutoPlotArea( false ); 588 return r; 589 } 590 591 private SeriesToChartGroupRecord createSeriesToChartGroupRecord() 592 { 593 return new SeriesToChartGroupRecord(); 594 } 595 596 private DataFormatRecord createDataFormatRecord() 597 { 598 DataFormatRecord r = new DataFormatRecord(); 599 r.setPointNumber( (short) -1 ); 600 r.setSeriesIndex( (short) 0 ); 601 r.setSeriesNumber( (short) 0 ); 602 r.setUseExcel4Colors( false ); 603 return r; 604 } 605 606 private LinkedDataRecord createCategoriesLinkedDataRecord() 607 { 608 LinkedDataRecord r = new LinkedDataRecord(); 609 r.setLinkType( LinkedDataRecord.LINK_TYPE_CATEGORIES ); 610 r.setReferenceType( LinkedDataRecord.REFERENCE_TYPE_WORKSHEET ); 611 r.setCustomNumberFormat( false ); 612 r.setIndexNumberFmtRecord( (short) 0 ); 613 LinkedDataFormulaField formula = new LinkedDataFormulaField(); 614 Stack tokens = new Stack (); 615 Area3DPtg p = new Area3DPtg(); 616 p.setExternSheetIndex( (short) 0 ); 617 p.setFirstColumn( (short) 1 ); 618 p.setLastColumn( (short) 1 ); 619 p.setFirstRow( (short) 0 ); 620 p.setLastRow( (short) 31 ); 621 tokens.add( p ); 622 formula.setFormulaTokens( tokens ); 623 r.setFormulaOfLink( formula ); 624 return r; 625 } 626 627 private LinkedDataRecord createValuesLinkedDataRecord() 628 { 629 LinkedDataRecord r = new LinkedDataRecord(); 630 r.setLinkType( LinkedDataRecord.LINK_TYPE_VALUES ); 631 r.setReferenceType( LinkedDataRecord.REFERENCE_TYPE_WORKSHEET ); 632 r.setCustomNumberFormat( false ); 633 r.setIndexNumberFmtRecord( (short) 0 ); 634 LinkedDataFormulaField formula = new LinkedDataFormulaField(); 635 Stack tokens = new Stack (); 636 Area3DPtg p = new Area3DPtg(); 637 p.setExternSheetIndex( (short) 0 ); 638 p.setFirstColumn( (short) 0 ); 639 p.setLastColumn( (short) 0 ); 640 p.setFirstRow( (short) 0 ); 641 p.setLastRow( (short) 31 ); 642 tokens.add( p ); 643 formula.setFormulaTokens( tokens ); 644 r.setFormulaOfLink( formula ); 645 return r; 646 } 647 648 private LinkedDataRecord createTitleLinkedDataRecord() 649 { 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 { 661 SeriesRecord r = new SeriesRecord(); 662 r.setCategoryDataType( SeriesRecord.CATEGORY_DATA_TYPE_NUMERIC ); 663 r.setValuesDataType( SeriesRecord.VALUES_DATA_TYPE_NUMERIC ); 664 r.setNumCategories( (short) 32 ); 665 r.setNumValues( (short) 31 ); 666 r.setBubbleSeriesType( SeriesRecord.BUBBLE_SERIES_TYPE_NUMERIC ); 667 r.setNumBubbleValues( (short) 0 ); 668 return r; 669 } 670 671 private EndRecord createEndRecord() 672 { 673 return new EndRecord(); 674 } 675 676 private AreaFormatRecord createAreaFormatRecord1() 677 { 678 AreaFormatRecord r = new AreaFormatRecord(); 679 r.setForegroundColor( 16777215 ); r.setBackgroundColor( 0 ); r.setPattern( (short) 1 ); r.setAutomatic( true ); 683 r.setInvert( false ); 684 r.setForecolorIndex( (short) 78 ); 685 r.setBackcolorIndex( (short) 77 ); 686 return r; 687 } 688 689 private AreaFormatRecord createAreaFormatRecord2() 690 { 691 AreaFormatRecord r = new AreaFormatRecord(); 692 r.setForegroundColor(0x00c0c0c0); 693 r.setBackgroundColor(0x00000000); 694 r.setPattern((short)1); 695 r.setAutomatic(false); 696 r.setInvert(false); 697 r.setForecolorIndex((short)22); 698 r.setBackcolorIndex((short)79); 699 return r; 700 } 701 702 private LineFormatRecord createLineFormatRecord( boolean drawTicks ) 703 { 704 LineFormatRecord r = new LineFormatRecord(); 705 r.setLineColor( 0 ); 706 r.setLinePattern( LineFormatRecord.LINE_PATTERN_SOLID ); 707 r.setWeight( (short) -1 ); 708 r.setAuto( true ); 709 r.setDrawTicks( drawTicks ); 710 r.setColourPaletteIndex( (short) 77 ); return r; 712 } 713 714 private LineFormatRecord createLineFormatRecord2() 715 { 716 LineFormatRecord r = new LineFormatRecord(); 717 r.setLineColor( 0x00808080 ); 718 r.setLinePattern( (short) 0 ); 719 r.setWeight( (short) 0 ); 720 r.setAuto( false ); 721 r.setDrawTicks( false ); 722 r.setUnknown( false ); 723 r.setColourPaletteIndex( (short) 23 ); 724 return r; 725 } 726 727 private FrameRecord createFrameRecord1() 728 { 729 FrameRecord r = new FrameRecord(); 730 r.setBorderType( FrameRecord.BORDER_TYPE_REGULAR ); 731 r.setAutoSize( false ); 732 r.setAutoPosition( true ); 733 return r; 734 } 735 736 private FrameRecord createFrameRecord2() 737 { 738 FrameRecord r = new FrameRecord(); 739 r.setBorderType( FrameRecord.BORDER_TYPE_REGULAR ); 740 r.setAutoSize( true ); 741 r.setAutoPosition( true ); 742 return r; 743 } 744 745 private PlotGrowthRecord createPlotGrowthRecord( int horizScale, int vertScale ) 746 { 747 PlotGrowthRecord r = new PlotGrowthRecord(); 748 r.setHorizontalScale( horizScale ); 749 r.setVerticalScale( vertScale ); 750 return r; 751 } 752 753 private SCLRecord createSCLRecord( short numerator, short denominator ) 754 { 755 SCLRecord r = new SCLRecord(); 756 r.setDenominator( denominator ); 757 r.setNumerator( numerator ); 758 return r; 759 } 760 761 private BeginRecord createBeginRecord() 762 { 763 return new BeginRecord(); 764 } 765 766 private ChartRecord createChartRecord( int x, int y, int width, int height ) 767 { 768 ChartRecord r = new ChartRecord(); 769 r.setX( x ); 770 r.setY( y ); 771 r.setWidth( width ); 772 r.setHeight( height ); 773 return r; 774 } 775 776 private UnitsRecord createUnitsRecord() 777 { 778 UnitsRecord r = new UnitsRecord(); 779 r.setUnits( (short) 0 ); 780 return r; 781 } 782 } 783 | Popular Tags |