package org.RConsortium.RangeWare.AppWare.AppWareApplication.OpenMapApplication.PrintUtilties; import com.bbn.openmap.omGraphics.*; import java.awt.*; import com.bbn.openmap.Layer; import com.bbn.openmap.MapBean; import com.bbn.openmap.MapHandler; import com.bbn.openmap.event.ProjectionEvent; import com.bbn.openmap.layer.OMGraphicHandlerLayer; import com.bbn.openmap.layer.link.LinkConstants; import com.bbn.openmap.omGraphics.labeled.LabeledOMPoly; import com.bbn.openmap.proj.Projection; import com.bbn.openmap.proj.ProjectionFactory; import java.awt.geom.AffineTransform; import java.awt.print.PageFormat; import java.awt.print.Printable; import java.util.ArrayList; import java.util.Iterator; import javax.swing.JOptionPane; import javax.swing.RepaintManager; /** * AbstractMapBeanPrinter is a generic class for creating print jobs * with MapBeans in it. This class can be subclassed to add extra * printing code, for istance to add text labels, map thumbnails, or any * other "extra" printable in addition to the map itself. * * Any subclass must implement the print(...) method specified in interface * Printable. * * Subclasses may use the following functions in the implementation of the * print method: * * alignPaper(...) - aligns the paper so that (0,0) represents the upper left * corner of the printable area. * * drawMap(...) - draws the map to a specified area of the print with * the specified size. * * Protected variables layersToBePrinted and printProjection may also be * accessed, perhaps to manipulate an off-screen image. * * Modified from MapBeanPrinter.java distributed with openmap-4.6. * * @author Brian Sperlongano */ public abstract class AbstractMapBeanPrinter implements Printable { protected Layer[] layersToBePrinted; protected Projection mapProjection; protected Container bufferContainer; /** * Constructor * * @param layersToBePrinted Layers to print * @param printProj Projection to print * */ public AbstractMapBeanPrinter(Layer[] layersToBePrinted, Projection mapProj) { this.layersToBePrinted = layersToBePrinted; this.mapProjection = mapProj; } /** * Constructor * * @param mapHandlerToBePrinted MapHandler which contains the MapBean and * Layers to be printed. * */ public AbstractMapBeanPrinter(MapHandler mapHandlerToBePrinted) { bufferContainer = (MapBean)( mapHandlerToBePrinted.getAll("com.bbn.openmap.MapBean") .toArray()[0]); mapProjection = ((MapBean)bufferContainer) .getProjection().makeClone(); layersToBePrinted = convertToLayers (mapHandlerToBePrinted.getAll("com.bbn.openmap.Layer").toArray()); } /** * Constructor * * @param mapBean MapBean to be printed * */ public AbstractMapBeanPrinter(MapBean mapBean) { bufferContainer = mapBean; mapProjection = mapBean.getProjection().makeClone(); Component[] mapChildren = mapBean.getComponents(); ArrayList mapLayerArrayList = new ArrayList(); for(int i=0; i " + rdat[i]); } return rdat; } /** * Method disableDoubleBuffering * * @param c a Component * */ public static void disableDoubleBuffering(Component c) { RepaintManager currentManager = RepaintManager.currentManager(c); currentManager.setDoubleBufferingEnabled(false); } /** Re-enables double buffering globally. */ public static void enableDoubleBuffering(Component c) { RepaintManager currentManager = RepaintManager.currentManager(c); currentManager.setDoubleBufferingEnabled(true); } }