Path: blob/master/src/java.desktop/share/classes/sun/print/OpenBook.java
41153 views
/*1* Copyright (c) 1998, 2000, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package sun.print;2627import java.awt.print.Pageable;28import java.awt.print.PageFormat;29import java.awt.print.Printable;3031/**32* A Book with an unknown number of pages where each33* page has the same format and painter. This class34* is used by PrinterJob to print Pageable jobs.35*/3637class OpenBook implements Pageable {3839/* Class Constants */4041/* Class Variables */4243/* Instance Variables */4445/**46* The format of all of the pages.47*/48private PageFormat mFormat;4950/**51* The object that will render all of the pages.52*/53private Printable mPainter;5455/* Instance Methods */5657/**58* Create a Pageable with an unknown number of pages59* where every page shares the same format and60* Printable.61*/62OpenBook(PageFormat format, Printable painter) {63mFormat = format;64mPainter = painter;65}6667/**68* This object does not know the number of pages.69*/70public int getNumberOfPages(){71return UNKNOWN_NUMBER_OF_PAGES;72}7374/**75* Return the PageFormat of the page specified by 'pageIndex'.76* @param pageIndex The zero based index of the page whose77* PageFormat is being requested.78* @return The PageFormat describing the size and orientation79*/80public PageFormat getPageFormat(int pageIndex) {81return mFormat;82}8384/**85* Return the Printable instance responsible for rendering86* the page specified by 'pageIndex'.87* @param pageIndex The zero based index of the page whose88* Printable is being requested.89* @return The Printable that will draw the page.90*/91public Printable getPrintable(int pageIndex)92throws IndexOutOfBoundsException93{94return mPainter;95}96}979899