1 31 package org.pdfbox.pdmodel.fdf; 32 33 import org.pdfbox.cos.COSArray; 34 import org.pdfbox.cos.COSBase; 35 import org.pdfbox.cos.COSDictionary; 36 37 import org.pdfbox.pdmodel.common.COSObjectable; 38 import org.pdfbox.pdmodel.common.PDRange; 39 40 46 public class FDFIconFit implements COSObjectable 47 { 48 private COSDictionary fit; 49 50 53 public static final String SCALE_OPTION_ALWAYS = "A"; 54 57 public static final String SCALE_OPTION_ONLY_WHEN_ICON_IS_BIGGER = "B"; 58 61 public static final String SCALE_OPTION_ONLY_WHEN_ICON_IS_SMALLER = "S"; 62 65 public static final String SCALE_OPTION_NEVER = "N"; 66 67 70 public static final String SCALE_TYPE_ANAMORPHIC = "A"; 71 74 public static final String SCALE_TYPE_PROPORTIONAL = "P"; 75 76 77 78 81 public FDFIconFit() 82 { 83 fit = new COSDictionary(); 84 } 85 86 91 public FDFIconFit( COSDictionary f ) 92 { 93 fit = f; 94 } 95 96 101 public COSBase getCOSObject() 102 { 103 return fit; 104 } 105 106 111 public COSDictionary getCOSDictionary() 112 { 113 return fit; 114 } 115 116 122 public String getScaleOption() 123 { 124 String retval = fit.getNameAsString( "SW" ); 125 if( retval == null ) 126 { 127 retval = SCALE_OPTION_ALWAYS; 128 } 129 return retval; 130 } 131 132 137 public void setScaleOption( String option ) 138 { 139 fit.setName( "SW", option ); 140 } 141 142 148 public String getScaleType() 149 { 150 String retval = fit.getNameAsString( "S" ); 151 if( retval == null ) 152 { 153 retval = SCALE_TYPE_PROPORTIONAL; 154 } 155 return retval; 156 } 157 158 163 public void setScaleType( String scale ) 164 { 165 fit.setName( "S", scale ); 166 } 167 168 180 public PDRange getFractionalSpaceToAllocate() 181 { 182 PDRange retval = null; 183 COSArray array = (COSArray)fit.getDictionaryObject( "A" ); 184 if( array == null ) 185 { 186 retval = new PDRange(); 187 retval.setMin( .5f ); 188 retval.setMax( .5f ); 189 setFractionalSpaceToAllocate( retval ); 190 } 191 else 192 { 193 retval = new PDRange( array ); 194 } 195 return retval; 196 } 197 198 203 public void setFractionalSpaceToAllocate( PDRange space ) 204 { 205 fit.setItem( "A", space ); 206 } 207 208 213 public boolean shouldScaleToFitAnnotation() 214 { 215 return fit.getBoolean( "FB", false ); 216 } 217 218 223 public void setScaleToFitAnnotation( boolean value ) 224 { 225 fit.setBoolean( "FB", value ); 226 } 227 } | Popular Tags |