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