package com.bbn.openmap.image; import com.bbn.openmap.Layer; import com.bbn.openmap.MapBean; import com.bbn.openmap.MapHandler; import com.bbn.openmap.proj.Projection; import java.awt.Graphics; 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 layers Set of layers to print * @param proj Geospatial area to print * * @version 9/23/2004 */ public DefaultMapBeanPrinter(Layer[] layers, Projection proj) { super(layers, proj); } /** * Constructor * * @param mapHandler a MapHandler */ public DefaultMapBeanPrinter(MapHandler mapHandler) { super(mapHandler); } /** * 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 drawMap(g, pageFormat, 0, 0, 1.0d, 1.0d, true); return(PAGE_EXISTS); } } }