~ubuntu-branches/ubuntu/feisty/libitext-java/feisty

« back to all changes in this revision

Viewing changes to com/lowagie/text/pdf/PdfDestination.java

  • Committer: Bazaar Package Importer
  • Author(s): Gerardo Curiel
  • Date: 2006-09-21 00:08:53 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060921000853-le9rrpcnw9fc57sm
Tags: 1.4.5-1
* New upstream release
* debian/rules modified due to a new build.xml file
* Patched Pdfgraphics2d.java to remove privative dependencie on com.sun.image.codec.jpeg.*
  (more information on
  http://developer.classpath.org/mediation/ClasspathMigration#head-d4ee9efe53a641e29ffdcd96e985bf38bbc671c1 )
* ant/.ant.properties paths fixed
* Build package with the packages provided by java-gcj-compat-dev
* Removed unused README.Debian
* Removed unused debian/patches/01libitext-java-addbuildscript.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * $Id: PdfDestination.java,v 1.54 2005/05/04 14:33:11 blowagie Exp $
 
3
 * $Name:  $
 
4
 *
 
5
 * Copyright 1999, 2000, 2001, 2002 Bruno Lowagie
 
6
 *
 
7
 * The contents of this file are subject to the Mozilla Public License Version 1.1
 
8
 * (the "License"); you may not use this file except in compliance with the License.
 
9
 * You may obtain a copy of the License at http://www.mozilla.org/MPL/
 
10
 *
 
11
 * Software distributed under the License is distributed on an "AS IS" basis,
 
12
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 
13
 * for the specific language governing rights and limitations under the License.
 
14
 *
 
15
 * The Original Code is 'iText, a free JAVA-PDF library'.
 
16
 *
 
17
 * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
 
18
 * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
 
19
 * All Rights Reserved.
 
20
 * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
 
21
 * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
 
22
 *
 
23
 * Contributor(s): all the names of the contributors are added in the source code
 
24
 * where applicable.
 
25
 *
 
26
 * Alternatively, the contents of this file may be used under the terms of the
 
27
 * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
 
28
 * provisions of LGPL are applicable instead of those above.  If you wish to
 
29
 * allow use of your version of this file only under the terms of the LGPL
 
30
 * License and not to allow others to use your version of this file under
 
31
 * the MPL, indicate your decision by deleting the provisions above and
 
32
 * replace them with the notice and other provisions required by the LGPL.
 
33
 * If you do not delete the provisions above, a recipient may use your version
 
34
 * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
 
35
 *
 
36
 * This library is free software; you can redistribute it and/or modify it
 
37
 * under the terms of the MPL as stated above or under the terms of the GNU
 
38
 * Library General Public License as published by the Free Software Foundation;
 
39
 * either version 2 of the License, or any later version.
 
40
 *
 
41
 * This library is distributed in the hope that it will be useful, but WITHOUT
 
42
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 
43
 * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
 
44
 * details.
 
45
 *
 
46
 * If you didn't download this code from the following link, you should check if
 
47
 * you aren't using an obsolete version:
 
48
 * http://www.lowagie.com/iText/
 
49
 */
 
50
 
 
51
package com.lowagie.text.pdf;
 
52
 
 
53
/**
 
54
 * A <CODE>PdfColor</CODE> defines a Color (it's a <CODE>PdfArray</CODE> containing 3 values).
 
55
 *
 
56
 * @see         PdfDictionary
 
57
 */
 
58
 
 
59
public class PdfDestination extends PdfArray {
 
60
    
 
61
    // public static final member-variables
 
62
    
 
63
/** This is a possible destination type */
 
64
    public static final int XYZ = 0;
 
65
    
 
66
/** This is a possible destination type */
 
67
    public static final int FIT = 1;
 
68
    
 
69
/** This is a possible destination type */
 
70
    public static final int FITH = 2;
 
71
    
 
72
/** This is a possible destination type */
 
73
    public static final int FITV = 3;
 
74
    
 
75
/** This is a possible destination type */
 
76
    public static final int FITR = 4;
 
77
    
 
78
/** This is a possible destination type */
 
79
    public static final int FITB = 5;
 
80
    
 
81
/** This is a possible destination type */
 
82
    public static final int FITBH = 6;
 
83
    
 
84
/** This is a possible destination type */
 
85
    public static final int FITBV = 7;
 
86
    
 
87
    // member variables
 
88
    
 
89
/** Is the indirect reference to a page already added? */
 
90
    private boolean status = false;
 
91
    
 
92
    // constructors
 
93
    
 
94
/**
 
95
 * Constructs a new <CODE>PdfDestination</CODE>.
 
96
 * <P>
 
97
 * If <VAR>type</VAR> equals <VAR>FITB</VAR>, the bounding box of a page
 
98
 * will fit the window of the Reader. Otherwise the type will be set to
 
99
 * <VAR>FIT</VAR> so that the entire page will fit to the window.
 
100
 *
 
101
 * @param               type            The destination type
 
102
 */
 
103
    
 
104
    public PdfDestination(int type) {
 
105
        super();
 
106
        if (type == FITB) {
 
107
            add(PdfName.FITB);
 
108
        }
 
109
        else {
 
110
            add(PdfName.FIT);
 
111
        }
 
112
    }
 
113
    
 
114
/**
 
115
 * Constructs a new <CODE>PdfDestination</CODE>.
 
116
 * <P>
 
117
 * If <VAR>type</VAR> equals <VAR>FITBH</VAR> / <VAR>FITBV</VAR>,
 
118
 * the width / height of the bounding box of a page will fit the window
 
119
 * of the Reader. The parameter will specify the y / x coordinate of the
 
120
 * top / left edge of the window. If the <VAR>type</VAR> equals <VAR>FITH</VAR>
 
121
 * or <VAR>FITV</VAR> the width / height of the entire page will fit
 
122
 * the window and the parameter will specify the y / x coordinate of the
 
123
 * top / left edge. In all other cases the type will be set to <VAR>FITH</VAR>.
 
124
 *
 
125
 * @param               type            the destination type
 
126
 * @param               parameter       a parameter to combined with the destination type
 
127
 */
 
128
    
 
129
    public PdfDestination(int type, float parameter) {
 
130
        super(new PdfNumber(parameter));
 
131
        switch(type) {
 
132
            default:
 
133
                addFirst(PdfName.FITH);
 
134
                break;
 
135
            case FITV:
 
136
                addFirst(PdfName.FITV);
 
137
                break;
 
138
            case FITBH:
 
139
                addFirst(PdfName.FITBH);
 
140
                break;
 
141
            case FITBV:
 
142
                addFirst(PdfName.FITBV);
 
143
        }
 
144
    }
 
145
    
 
146
/** Constructs a new <CODE>PdfDestination</CODE>.
 
147
 * <P>
 
148
 * Display the page, with the coordinates (left, top) positioned
 
149
 * at the top-left corner of the window and the contents of the page magnified
 
150
 * by the factor zoom. A negative value for any of the parameters left or top, or a
 
151
 * zoom value of 0 specifies that the current value of that parameter is to be retained unchanged.
 
152
 * @param type must be a <VAR>PdfDestination.XYZ</VAR>
 
153
 * @param left the left value. Negative to place a null
 
154
 * @param top the top value. Negative to place a null
 
155
 * @param zoom The zoom factor. A value of 0 keeps the current value
 
156
 */
 
157
    
 
158
    public PdfDestination(int type, float left, float top, float zoom) {
 
159
        super(PdfName.XYZ);
 
160
        if (left < 0)
 
161
            add(PdfNull.PDFNULL);
 
162
        else
 
163
            add(new PdfNumber(left));
 
164
        if (top < 0)
 
165
            add(PdfNull.PDFNULL);
 
166
        else
 
167
            add(new PdfNumber(top));
 
168
        add(new PdfNumber(zoom));
 
169
    }
 
170
    
 
171
/** Constructs a new <CODE>PdfDestination</CODE>.
 
172
 * <P>
 
173
 * Display the page, with its contents magnified just enough
 
174
 * to fit the rectangle specified by the coordinates left, bottom, right, and top
 
175
 * entirely within the window both horizontally and vertically. If the required
 
176
 * horizontal and vertical magnification factors are different, use the smaller of
 
177
 * the two, centering the rectangle within the window in the other dimension.
 
178
 *
 
179
 * @param type must be PdfDestination.FITR
 
180
 * @param left a parameter
 
181
 * @param bottom a parameter
 
182
 * @param right a parameter
 
183
 * @param top a parameter
 
184
 * @since iText0.38
 
185
 */
 
186
    
 
187
    public PdfDestination(int type, float left, float bottom, float right, float top) {
 
188
        super(PdfName.FITR);
 
189
        add(new PdfNumber(left));
 
190
        add(new PdfNumber(bottom));
 
191
        add(new PdfNumber(right));
 
192
        add(new PdfNumber(top));
 
193
    }
 
194
    
 
195
    // methods
 
196
    
 
197
/**
 
198
 * Checks if an indirect reference to a page has been added.
 
199
 *
 
200
 * @return      <CODE>true</CODE> or <CODE>false</CODE>
 
201
 */
 
202
    
 
203
    public boolean hasPage() {
 
204
        return status;
 
205
    }
 
206
    
 
207
/** Adds the indirect reference of the destination page.
 
208
 *
 
209
 * @param page  an indirect reference
 
210
 * @return true if the page reference was added
 
211
 */
 
212
    
 
213
    public boolean addPage(PdfIndirectReference page) {
 
214
        if (!status) {
 
215
            addFirst(page);
 
216
            status = true;
 
217
            return true;
 
218
        }
 
219
        return false;
 
220
    }
 
221
}
 
 
b'\\ No newline at end of file'