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 y location and the width 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 PDPageFitRectangleDestination extends PDPageDestination {
043: /**
044: * The type of this destination.
045: */
046: protected static final String TYPE = "FitR";
047:
048: /**
049: * Default constructor.
050: *
051: */
052: public PDPageFitRectangleDestination() {
053: super ();
054: array.growToSize(6);
055: array.setName(1, TYPE);
056:
057: }
058:
059: /**
060: * Constructor from an existing destination array.
061: *
062: * @param arr The destination array.
063: */
064: public PDPageFitRectangleDestination(COSArray arr) {
065: super (arr);
066: }
067:
068: /**
069: * Get the left x coordinate. A return value of -1 implies that the current x-coordinate
070: * will be used.
071: *
072: * @return The left x coordinate.
073: */
074: public int getLeft() {
075: return array.getInt(2);
076: }
077:
078: /**
079: * Set the left x-coordinate, a value of -1 implies that the current x-coordinate
080: * will be used.
081: * @param x The left x coordinate.
082: */
083: public void setLeft(int x) {
084: array.growToSize(3);
085: if (x == -1) {
086: array.set(2, (COSBase) null);
087: } else {
088: array.setInt(2, x);
089: }
090: }
091:
092: /**
093: * Get the bottom y coordinate. A return value of -1 implies that the current y-coordinate
094: * will be used.
095: *
096: * @return The bottom y coordinate.
097: */
098: public int getBottom() {
099: return array.getInt(3);
100: }
101:
102: /**
103: * Set the bottom y-coordinate, a value of -1 implies that the current y-coordinate
104: * will be used.
105: * @param y The bottom y coordinate.
106: */
107: public void setBottom(int y) {
108: array.growToSize(6);
109: if (y == -1) {
110: array.set(3, (COSBase) null);
111: } else {
112: array.setInt(3, y);
113: }
114: }
115:
116: /**
117: * Get the right x coordinate. A return value of -1 implies that the current x-coordinate
118: * will be used.
119: *
120: * @return The right x coordinate.
121: */
122: public int getRight() {
123: return array.getInt(4);
124: }
125:
126: /**
127: * Set the right x-coordinate, a value of -1 implies that the current x-coordinate
128: * will be used.
129: * @param x The right x coordinate.
130: */
131: public void setRight(int x) {
132: array.growToSize(6);
133: if (x == -1) {
134: array.set(4, (COSBase) null);
135: } else {
136: array.setInt(4, x);
137: }
138: }
139:
140: /**
141: * Get the top y coordinate. A return value of -1 implies that the current y-coordinate
142: * will be used.
143: *
144: * @return The top y coordinate.
145: */
146: public int getTop() {
147: return array.getInt(5);
148: }
149:
150: /**
151: * Set the top y-coordinate, a value of -1 implies that the current y-coordinate
152: * will be used.
153: * @param y The top ycoordinate.
154: */
155: public void setTop(int y) {
156: array.growToSize(6);
157: if (y == -1) {
158: array.set(5, (COSBase) null);
159: } else {
160: array.setInt(5, y);
161: }
162: }
163: }
|