1 31 package org.pdfbox.pdmodel.common; 32 33 import org.pdfbox.cos.COSArray; 34 import org.pdfbox.cos.COSBase; 35 import org.pdfbox.cos.COSFloat; 36 import org.pdfbox.cos.COSNumber; 37 38 44 public class PDRange implements COSObjectable 45 { 46 private COSArray rangeArray; 47 private int startingIndex; 48 49 52 public PDRange() 53 { 54 rangeArray = new COSArray(); 55 rangeArray.add( new COSFloat( 0.0f ) ); 56 rangeArray.add( new COSFloat( 1.0f ) ); 57 startingIndex = 0; 58 } 59 60 65 public PDRange( COSArray range ) 66 { 67 rangeArray = range; 68 } 69 70 79 public PDRange( COSArray range, int index ) 80 { 81 rangeArray = range; 82 startingIndex = index; 83 } 84 85 90 public COSBase getCOSObject() 91 { 92 return rangeArray; 93 } 94 95 100 public COSArray getCOSArray() 101 { 102 return rangeArray; 103 } 104 105 110 public float getMin() 111 { 112 COSNumber min = (COSNumber)rangeArray.getObject( startingIndex*2 ); 113 return min.floatValue(); 114 } 115 116 121 public void setMin( float min ) 122 { 123 rangeArray.set( startingIndex*2, new COSFloat( min ) ); 124 } 125 126 131 public float getMax() 132 { 133 COSNumber max = (COSNumber)rangeArray.getObject( startingIndex*2+1 ); 134 return max.floatValue(); 135 } 136 137 142 public void setMax( float max ) 143 { 144 rangeArray.set( startingIndex*2+1, new COSFloat( max ) ); 145 } 146 } | Popular Tags |