1 31 package org.pdfbox.pdmodel.interactive.annotation; 32 33 import org.pdfbox.cos.COSBase; 34 import org.pdfbox.cos.COSDictionary; 35 import org.pdfbox.cos.COSArray; 36 import org.pdfbox.cos.COSInteger; 37 38 import org.pdfbox.pdmodel.common.COSObjectable; 39 import org.pdfbox.pdmodel.graphics.PDLineDashPattern; 40 41 47 public class PDBorderStyleDictionary implements COSObjectable 48 { 49 50 54 55 58 public static final String STYLE_SOLID = "S"; 59 60 63 public static final String STYLE_DASHED = "D"; 64 65 68 public static final String STYLE_BEVELED = "B"; 69 70 73 public static final String STYLE_INSET = "I"; 74 75 78 public static final String STYLE_UNDERLINE = "U"; 79 80 private COSDictionary dictionary; 81 82 85 public PDBorderStyleDictionary() 86 { 87 dictionary = new COSDictionary(); 88 } 89 90 96 public PDBorderStyleDictionary( COSDictionary dict ) 97 { 98 dictionary = dict; 99 } 100 101 106 public COSDictionary getDictionary() 107 { 108 return dictionary; 109 } 110 111 116 public COSBase getCOSObject() 117 { 118 return dictionary; 119 } 120 121 127 public void setWidth( float w ) 128 { 129 getDictionary().setFloat( "W", w ); 130 } 131 132 137 public float getWidth() 138 { 139 return getDictionary().getFloat( "W", 1 ); 140 } 141 142 148 public void setStyle( String s ) 149 { 150 getDictionary().setName( "S", s ); 151 } 152 153 159 public String getStyle() 160 { 161 return getDictionary().getNameAsString( "S", STYLE_SOLID ); 162 } 163 164 170 public void setDashStyle( PDLineDashPattern d ) 171 { 172 COSArray array = null; 173 if( d != null ) 174 { 175 array = d.getCOSDashPattern(); 176 } 177 getDictionary().setItem( "D", array ); 178 } 179 180 185 public PDLineDashPattern getDashStyle() 186 { 187 COSArray d = (COSArray) getDictionary().getDictionaryObject( "D" ); 188 if (d == null) 189 { 190 d = new COSArray(); 191 d.add( new COSInteger( 3 ) ); 192 getDictionary().setItem( "D", d ); 193 } 194 return new PDLineDashPattern( d, 0 ); 195 } 196 197 } | Popular Tags |