001: /**
002: * Copyright (c) 2005, www.pdfbox.org
003: * All rights reserved.
004: *
005: * Redistribution and use in source and binary forms, with or without
006: * modification, are permitted provided that the following conditions are met:
007: *
008: * 1. Redistributions of source code must retain the above copyright notice,
009: * this list of conditions and the following disclaimer.
010: * 2. Redistributions in binary form must reproduce the above copyright notice,
011: * this list of conditions and the following disclaimer in the documentation
012: * and/or other materials provided with the distribution.
013: * 3. Neither the name of pdfbox; nor the names of its
014: * contributors may be used to endorse or promote products derived from this
015: * software without specific prior written permission.
016: *
017: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
018: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
019: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
020: * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
021: * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
022: * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
023: * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
024: * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
025: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
026: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
027: *
028: * http://www.pdfbox.org
029: *
030: */package org.pdfbox.pdmodel.interactive.documentnavigation.destination;
031:
032: import org.pdfbox.cos.COSArray;
033: import org.pdfbox.cos.COSBase;
034:
035: /**
036: * This represents a destination to a page at a x location and the height is magnified
037: * to just fit on the screen.
038: *
039: * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
040: * @version $Revision: 1.2 $
041: */
042: public class PDPageFitHeightDestination extends PDPageDestination {
043: /**
044: * The type of this destination.
045: */
046: protected static final String TYPE = "FitV";
047: /**
048: * The type of this destination.
049: */
050: protected static final String TYPE_BOUNDED = "FitBV";
051:
052: /**
053: * Default constructor.
054: *
055: */
056: public PDPageFitHeightDestination() {
057: super ();
058: array.growToSize(3);
059: array.setName(1, TYPE);
060:
061: }
062:
063: /**
064: * Constructor from an existing destination array.
065: *
066: * @param arr The destination array.
067: */
068: public PDPageFitHeightDestination(COSArray arr) {
069: super (arr);
070: }
071:
072: /**
073: * Get the left x coordinate. A return value of -1 implies that the current x-coordinate
074: * will be used.
075: *
076: * @return The left x coordinate.
077: */
078: public int getLeft() {
079: return array.getInt(2);
080: }
081:
082: /**
083: * Set the left x-coordinate, a value of -1 implies that the current x-coordinate
084: * will be used.
085: * @param x The left x coordinate.
086: */
087: public void setLeft(int x) {
088: array.growToSize(3);
089: if (x == -1) {
090: array.set(2, (COSBase) null);
091: } else {
092: array.setInt(2, x);
093: }
094: }
095:
096: /**
097: * A flag indicating if this page destination should just fit bounding box of the PDF.
098: *
099: * @return true If the destination should fit just the bounding box.
100: */
101: public boolean fitBoundingBox() {
102: return TYPE_BOUNDED.equals(array.getName(1));
103: }
104:
105: /**
106: * Set if this page destination should just fit the bounding box. The default is false.
107: *
108: * @param fitBoundingBox A flag indicating if this should fit the bounding box.
109: */
110: public void setFitBoundingBox(boolean fitBoundingBox) {
111: array.growToSize(2);
112: if (fitBoundingBox) {
113: array.setName(1, TYPE_BOUNDED);
114: } else {
115: array.setName(1, TYPE);
116: }
117: }
118: }
|