1 47 package com.lowagie.text.pdf; 48 49 import java.io.IOException ; 50 54 public class PdfShadingPattern extends PdfDictionary { 55 56 protected PdfShading shading; 57 58 protected PdfWriter writer; 59 60 protected float matrix[] = {1, 0, 0, 1, 0, 0}; 61 62 protected PdfName patternName; 63 64 protected PdfIndirectReference patternReference; 65 66 67 public PdfShadingPattern(PdfShading shading) { 68 writer = shading.getWriter(); 69 put(PdfName.PATTERNTYPE, new PdfNumber(2)); 70 this.shading = shading; 71 } 72 73 PdfName getPatternName() { 74 return patternName; 75 } 76 77 PdfName getShadingName() { 78 return shading.getShadingName(); 79 } 80 81 PdfIndirectReference getPatternReference() { 82 if (patternReference == null) 83 patternReference = writer.getPdfIndirectReference(); 84 return patternReference; 85 } 86 87 PdfIndirectReference getShadingReference() { 88 return shading.getShadingReference(); 89 } 90 91 void setName(int number) { 92 patternName = new PdfName("P" + number); 93 } 94 95 void addToBody() throws IOException { 96 put(PdfName.SHADING, getShadingReference()); 97 put(PdfName.MATRIX, new PdfArray(matrix)); 98 writer.addToBody(this, getPatternReference()); 99 } 100 101 public void setMatrix(float matrix[]) { 102 if (matrix.length != 6) 103 throw new RuntimeException ("The matrix size must be 6."); 104 this.matrix = matrix; 105 } 106 107 public float[] getMatrix() { 108 return matrix; 109 } 110 111 public PdfShading getShading() { 112 return shading; 113 } 114 115 ColorDetails getColorDetails() { 116 return shading.getColorDetails(); 117 } 118 119 } 120 | Popular Tags |