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 an x,y coordinate with a zoom setting.
037: * The default x,y,z will be whatever is the current value in the viewer application and
038: * are not required.
039: *
040: * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
041: * @version $Revision: 1.2 $
042: */
043: public class PDPageXYZDestination extends PDPageDestination {
044: /**
045: * The type of this destination.
046: */
047: protected static final String TYPE = "XYZ";
048:
049: /**
050: * Default constructor.
051: *
052: */
053: public PDPageXYZDestination() {
054: super ();
055: array.growToSize(5);
056: array.setName(1, TYPE);
057:
058: }
059:
060: /**
061: * Constructor from an existing destination array.
062: *
063: * @param arr The destination array.
064: */
065: public PDPageXYZDestination(COSArray arr) {
066: super (arr);
067: }
068:
069: /**
070: * Get the left x coordinate. A return value of -1 implies that the current x-coordinate
071: * will be used.
072: *
073: * @return The left x coordinate.
074: */
075: public int getLeft() {
076: return array.getInt(2);
077: }
078:
079: /**
080: * Set the left x-coordinate, a value of -1 implies that the current x-coordinate
081: * will be used.
082: * @param x The left x coordinate.
083: */
084: public void setLeft(int x) {
085: array.growToSize(3);
086: if (x == -1) {
087: array.set(2, (COSBase) null);
088: } else {
089: array.setInt(2, x);
090: }
091: }
092:
093: /**
094: * Get the top y coordinate. A return value of -1 implies that the current y-coordinate
095: * will be used.
096: *
097: * @return The top y coordinate.
098: */
099: public int getTop() {
100: return array.getInt(3);
101: }
102:
103: /**
104: * Set the top y-coordinate, a value of -1 implies that the current y-coordinate
105: * will be used.
106: * @param y The top ycoordinate.
107: */
108: public void setTop(int y) {
109: array.growToSize(4);
110: if (y == -1) {
111: array.set(3, (COSBase) null);
112: } else {
113: array.setInt(3, y);
114: }
115: }
116:
117: /**
118: * Get the zoom value. A return value of -1 implies that the current zoom
119: * will be used.
120: *
121: * @return The zoom value for the page.
122: */
123: public int getZoom() {
124: return array.getInt(4);
125: }
126:
127: /**
128: * Set the zoom value for the page, a value of -1 implies that the current zoom
129: * will be used.
130: * @param zoom The zoom value.
131: */
132: public void setZoom(int zoom) {
133: array.growToSize(5);
134: if (zoom == -1) {
135: array.set(4, (COSBase) null);
136: } else {
137: array.setInt(4, zoom);
138: }
139: }
140: }
|