gt: 		int y = (screen.height - getHeight()) / 2;
context: /*
   * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
   * Santa Clara, California 95054, U.S.A. All rights reserved.
   *
   * This library is free software; you can redistribute it and/or
   * modify it under the terms of the GNU Lesser General Public
   * License as published by the Free Software Foundation; either
   * version 2.1 of the License, or (at your option) any later version.
   * 
   * This library is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   * Lesser General Public License for more details.
   * 
   * You should have received a copy of the GNU Lesser General Public
   * License along with this library; if not, write to the Free Software
   * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   */
  package org.loboevolution.pdf;
  
  import java.awt.BorderLayout;
  import java.awt.Color;
  import java.awt.Dimension;
  import java.awt.Toolkit;
  import java.awt.event.KeyEvent;
  import java.awt.event.KeyListener;
  import java.awt.print.Book;
  import java.awt.print.PageFormat;
  import java.awt.print.PrinterJob;
  import java.io.File;
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.RandomAccessFile;
  import java.lang.reflect.InvocationTargetException;
  import java.net.SocketTimeoutException;
  import java.net.URL;
  import java.net.URLConnection;
  import java.nio.ByteBuffer;
  import java.nio.channels.FileChannel;
  import java.util.logging.Level;
  import java.util.logging.Logger;
  
  import javax.swing.Icon;
  import javax.swing.ImageIcon;
  import javax.swing.JDialog;
  import javax.swing.JFrame;
  import javax.swing.JMenu;
  import javax.swing.JMenuBar;
  import javax.swing.JOptionPane;
  import javax.swing.JScrollPane;
  import javax.swing.JSplitPane;
  import javax.swing.JTree;
  import javax.swing.ScrollPaneConstants;
  import javax.swing.SwingUtilities;
  import javax.swing.WindowConstants;
  import javax.swing.event.TreeSelectionEvent;
  import javax.swing.event.TreeSelectionListener;
  
  import org.loboevolution.net.HttpNetwork;
  import org.loboevolution.pdfview.OutlineNode;
  import org.loboevolution.pdfview.PDFDestination;
  import org.loboevolution.pdfview.PDFFile;
  import org.loboevolution.pdfview.PDFObject;
  import org.loboevolution.pdfview.PDFPage;
  import org.loboevolution.pdfview.action.CloseOutlineAction;
  import org.loboevolution.pdfview.action.FitAction;
  import org.loboevolution.pdfview.action.FitHeightAction;
  import org.loboevolution.pdfview.action.GoToAction;
  import org.loboevolution.pdfview.action.OutlineAction;
  import org.loboevolution.pdfview.action.PDFAction;
  import org.loboevolution.pdfview.action.PrintAction;
  import org.loboevolution.pdfview.action.SetupAction;
  import org.loboevolution.pdfview.action.ThumbAction;
  import org.loboevolution.pdfview.action.ZoomInAction;
  import org.loboevolution.pdfview.action.ZoomOutAction;
  
  /**
   * The Class PDFViewer.
   *
    *
    *
   */
  public class PDFViewer extends JFrame implements KeyListener, PageChangeListener, TreeSelectionListener {
  
  	/** The Constant serialVersionUID. */
  	private static final long serialVersionUID = 1L;
  	
  	/** The Constant logger. */
  	private static final Logger logger = Logger.getLogger(PDFViewer.class.getName());
  	
  	private final float ZOOM_FACTOR = 1.2f;
  	
  	private final int MIN_ZOOM_SIZE = 100;
  	
  	private final int MAX_ZOOM_SIZE = 4000;
  
  	/** The Constant TITLE. */
  	public static final String TITLE = "LoboEvolution PDF Viewer";
  
  	/** The current PDFFile. */
  	protected transient PDFFile curFile;
  
  	/** the name of the current document. */
  	private String docName;
  
  	/** The split between thumbs and page. */
  	private JSplitPane split;
  
  	/** The thumbnail scroll pane. */
  	private JScrollPane thumbscroll;
  
  	/** The thumbnail display. */
  	private transient ThumbPanel thumbs;
  
  	/** The page display. */
  	protected transient PagePanel page;
  
  	/** The full screen page display, or null if not in full screen mode. */
  	protected transient PagePanel fspp;
  	
  	/** The current page number (starts at 0), or -1 if no page. */
  	protected int curpage = -1;
  
  	/** The page format for printing. */
  	private transient PageFormat pformat = PrinterJob.getPrinterJob().defaultPage();
  
  	/** true if the thumb panel should exist at all. */
  	private boolean doThumb = true;
  
  	/** a thread that pre-loads the next page for faster response. */
  	private transient PagePreparer pagePrep;
  
  	/** the window containing the pdf outline, or null if one doesn't exist. */
  	private JDialog olf;
  	
  	/** The scroll page. */
  	JScrollPane scrollPage;
  	
  	/** The nav tool bar. */
  	private NavigationToolbar navToolbar;
  	
  	/** The pb. */
  	private PageBuilder pb;
  		
  	/** The setup action. */
  	private SetupAction pageSetupAction;
  	
  	/** The print action. */
  	private PrintAction printAction;
  		
  	/** The zoom tool action. */
  	private FitHeightAction fitHeightAction;
  	
  	/** The fit in window action. */
  	private FitAction fitAction;
  	
  	/** The thumb action. */
  	private ThumbAction thumbAction;
  	
  	/** The outline action. */
  	private OutlineAction outAction;
  	
  	/** The close outline action. */
  	private CloseOutlineAction closeOutline;
  	
  	/** The zoom in action. */
  	private ZoomInAction zoomInAction;
  	
  	/** The zoom out action. */
  	private ZoomOutAction zoomOutAction; 
  
  	/**
  	 * Create a new PdfDialog based on a user, with or without a thumbnail
  	 * panel.
  	 *
  	 * @param useThumbs
  	 *            true if the thumb panel should exist, false if not.
  	 */
  	public PDFViewer(boolean useThumbs) {
  		super(TITLE);
  		createAndShowGUI(useThumbs);
  	}
  
  	private void createAndShowGUI(boolean useThumbs) {
  		doThumb = useThumbs;
  		pageSetupAction = new SetupAction(this);
  		printAction = new PrintAction(this); 
  		fitHeightAction = new FitHeightAction(this);
  		fitAction = new FitAction(this);
  		pb = new PageBuilder(this);
  		outAction = new OutlineAction(this);
  		closeOutline = new CloseOutlineAction(this);
  		zoomInAction  = new ZoomInAction(this, ZOOM_FACTOR);
  		zoomOutAction = new ZoomOutAction(this, 1f/ZOOM_FACTOR);
  		init();
  	}
  
  	/**
  	 * Initialize this PdfDialog by creating the GUI.
  	 */
  	protected void init() {
  		page = new PagePanel();
  		page.addKeyListener(this);
  		scrollPage = new JScrollPane(page);
  		if (doThumb) {
  			split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
  			split.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, thumbAction);
  			split.setOneTouchExpandable(true);
  			thumbs = new ThumbPanel(null);
  			thumbscroll = new JScrollPane(thumbs, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
  			split.setLeftComponent(thumbscroll);
  			split.setRightComponent(scrollPage);
  			add(split, BorderLayout.CENTER);
  		} else {
  			add(scrollPage, BorderLayout.CENTER);
  		}
  		
  		navToolbar = new NavigationToolbar(this);
  		navToolbar.setFloatable(false);
  		add(navToolbar, BorderLayout.SOUTH);
  		
  		JMenuBar mb = new JMenuBar();
  		JMenu file = new JMenu("File");
  		file.add(pageSetupAction);
  		file.addSeparator();
  		file.add(printAction);
  		mb.add(file);
  		
  		JMenu jmZoom = new JMenu("Zoom");
  		jmZoom.add(fitHeightAction);
  		jmZoom.addSeparator();
  		jmZoom.add(fitAction);
  		jmZoom.addSeparator();
  		jmZoom.add(zoomInAction);
  		jmZoom.addSeparator();
  		jmZoom.add(zoomOutAction);
  		mb.add(jmZoom);
  		
  		JMenu nav = new JMenu("Navigation");
  		nav.add(outAction);
  		nav.addSeparator();
  		nav.add(closeOutline);
  		mb.add(nav);
  		
  		setJMenuBar(mb);
  		
  		setEnabling();
  		pack();
  		
  		Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
  		int x = (screen.width - getWidth()) / 2;
  