// ********************************************************************** // // // // BBN Technologies, a Verizon Company // 10 Moulton Street // Cambridge, MA 02138 // (617) 873-8000 // // Copyright (C) BBNT Solutions LLC. All rights reserved. // // // ********************************************************************** // // $Source: /cvs/distapps/openmap/src/openmap/com/bbn/openmap/image/MapBeanPrinter.java,v $ // $RCSfile: MapBeanPrinter.java,v $ // $Revision: 1.2 $ // $Date: 2004/01/26 18:18:08 $ // $Author: dietrick $ // // ********************************************************************** package com.bbn.openmap.image; import com.bbn.openmap.MapBean; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.print.PageFormat; /** * A simple utility class to print a MapBean and * rescale it to fit the printed page. Modified from * MapBeanPrinter.java distributed with openmap-4.6. This is a very * simple example of how to use AbstractMapBeanPrinter. * */ public class DefaultMapBeanPrinter extends AbstractMapBeanPrinter { /** * Constructor * * @param mapBean MapBean to print */ public DefaultMapBeanPrinter(MapBean mapBean) { super(mapBean); } /** * Prints a MapBean full-size, scaled, proportional. * * @param g a Graphics * @param pageFormat a PageFormat * @param pageIndex an int * * @return an int * * @author Brian Sperlongano */ public int print(Graphics g, PageFormat pageFormat, int pageIndex) { if (pageIndex > 0) { return(NO_SUCH_PAGE); } else { //Align paper to printable area alignPaper(g, pageFormat); //Prints a MapBean scaled to fit the page, with correct aspect ratio drawMapBean(g, pageFormat, 0, 0, 1.0d, 1.0d, true); return(PAGE_EXISTS); } } }