2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 package org.apache.pdfbox.pdmodel.interactive.annotation;
19 import org.apache.pdfbox.cos.COSBase;
20 import org.apache.pdfbox.cos.COSDictionary;
21 import org.apache.pdfbox.cos.COSArray;
22 import org.apache.pdfbox.cos.COSInteger;
24 import org.apache.pdfbox.pdmodel.common.COSObjectable;
25 import org.apache.pdfbox.pdmodel.graphics.PDLineDashPattern;
28 * This class represents a PDF /BS entry the border style dictionary.
31 * @version $Revision: 1.1 $
33 public class PDBorderStyleDictionary implements COSObjectable
37 * The various values of the style for the border as defined in the PDF 1.6
38 * reference Table 8.13
42 * Constant for the name of a solid style.
44 public static final String STYLE_SOLID = "S";
47 * Constant for the name of a dashed style.
49 public static final String STYLE_DASHED = "D";
52 * Constant for the name of a beveled style.
54 public static final String STYLE_BEVELED = "B";
57 * Constant for the name of a inset style.
59 public static final String STYLE_INSET = "I";
62 * Constant for the name of a underline style.
64 public static final String STYLE_UNDERLINE = "U";
66 private COSDictionary dictionary;
71 public PDBorderStyleDictionary()
73 dictionary = new COSDictionary();
80 * a border style dictionary.
82 public PDBorderStyleDictionary( COSDictionary dict )
88 * returns the dictionary.
90 * @return the dictionary
92 public COSDictionary getDictionary()
98 * returns the dictionary.
100 * @return the dictionary
102 public COSBase getCOSObject()
108 * This will set the border width in points, 0 = no border.
111 * float the width in points
113 public void setWidth( float w )
115 getDictionary().setFloat( "W", w );
119 * This will retrieve the border width in points, 0 = no border.
121 * @return flaot the width of the border in points
123 public float getWidth()
125 return getDictionary().getFloat( "W", 1 );
129 * This will set the border style, see the STYLE_* constants for valid values.
132 * the border style to use
134 public void setStyle( String s )
136 getDictionary().setName( "S", s );
140 * This will retrieve the border style, see the STYLE_* constants for valid
143 * @return the style of the border
145 public String getStyle()
147 return getDictionary().getNameAsString( "S", STYLE_SOLID );
151 * This will set the dash style used for drawing the border.
154 * the dash style to use
156 public void setDashStyle( PDLineDashPattern d )
158 COSArray array = null;
161 array = d.getCOSDashPattern();
163 getDictionary().setItem( "D", array );
167 * This will retrieve the dash style used for drawing the border.
169 * @return the dash style of the border
171 public PDLineDashPattern getDashStyle()
173 COSArray d = (COSArray) getDictionary().getDictionaryObject( "D" );
177 d.add( COSInteger.THREE );
178 getDictionary().setItem( "D", d );
180 return new PDLineDashPattern( d, 0 );