From: <doc...@us...> - 2007-12-05 05:32:12
|
Revision: 201 http://openpcl.svn.sourceforge.net/openpcl/?rev=201&view=rev Author: documentsystems Date: 2007-12-04 21:32:17 -0800 (Tue, 04 Dec 2007) Log Message: ----------- Howard Hoagland. Changed the executeAfterUiIsShowing() method to do an additional force to redraw the PCL page at very end of the startup sequence if run from an applet. Modified Paths: -------------- openpcl/src/com/openpcl/viewer/OpenPCLViewer.java Modified: openpcl/src/com/openpcl/viewer/OpenPCLViewer.java =================================================================== --- openpcl/src/com/openpcl/viewer/OpenPCLViewer.java 2007-12-05 05:30:13 UTC (rev 200) +++ openpcl/src/com/openpcl/viewer/OpenPCLViewer.java 2007-12-05 05:32:17 UTC (rev 201) @@ -89,7 +89,7 @@ * 1. As a PCL viewer. This is the normal user mode.<br> *<br> * or<br> - * 2. As a JPanel imbedded in your Java app's layout anywhere you wish. Your app can call the methods shown + * 2. As a JPanel embedded in your Java app's layout anywhere you wish. Your app can call the methods shown * in the Interface IOpenPCL to control how the OpenPCLViewer JPanel looks on screen and to control * its behavior. OpenPCLViewer's own toolbar buttons and events call these same Interface methods to control * it that and external app can call. You can hide the toolbar and/or JTree of PCL page nodes and call all the @@ -103,7 +103,7 @@ *<br> * More details about it:<br> * For (1), when OpenPCLViewer is run as the main app, its main() method runs which calls it's constructor. - * In this case, it will instantiate and show the JFrame PosSimpleJFrame, then imbed itself as a JPanel into + * In this case, it will instantiate and show the JFrame PosSimpleJFrame, then embed itself as a JPanel into * PosSimpleJFrame's layout. This requires no user programming and it does this as the ready to run PCL viewer.<br> *<br> * For (2), if you've written a Java app already and you want to put a JPanel in your app that is a PCL viewer, @@ -112,7 +112,7 @@ * and pass your app's JFrame in the constructor. Doing it this way, the OpenPCLViewer main() is never run * because your app's main() is the main(). Since OpenPCLViewer is a subclass of JPanel, it needs a reference to * the JFrame where this JPanel will be contained so that JDialogs and JOptionPanes can be modal on the - * passed in JFrame as the parent frame. For the 2nd paramater which is the "String pArgs[]" you can pass + * passed in JFrame as the parent frame. For the 2nd parameter which is the "String pArgs[]" you can pass * null if you don't want to specify any command line options or the name of a PCL file to open and view * at program startup time. Then you would add the OpenPCLViewer panel into your app's layout in any place you wish. * If you don't want the JTree or toolbar or status bar, you can turn those off independently by calling public @@ -120,7 +120,7 @@ * you have in your app that you want to control the PCL Viewer JPanel with, then hide OpenPCLViewer's toolbar * and make your event listener code call the OpenPCLViewer's public api interface methods that are in IOpenPCL.<br> * <br> - * For (3), If you want to *not* imbed the OpenPCLViewer JPanel in your app, and instead the only thing you want + * For (3), If you want to *not* embed the OpenPCLViewer JPanel in your app, and instead the only thing you want * is the BufferedImage bitmap that PclRenderImage draws from the PCL bytes, then you can use the classed in the * pclrenderimage.jar file directly and not have the openpcl.jar file there at run time. In this case, your app * needs to have all the UI code since you're going the bare bones route and not using any classes in the @@ -133,7 +133,9 @@ * 3c. Put the java.awt.image.BufferedImage (that is returned from the renderImage...() methods) on the screen, * or pass it along to a client who is in charge of putting it on the client's screen.<br> * - * @author DocMagic, Document Systems Inc, Howard H 9/20/06 + * @author DocMagic, Document Systems Inc, Howard Hoagland.<br> + * The major viewing and printing functionality written 5/13/06 to 9/20/06.<br> + * Added more printing variations and more features and command line options after that. */ public class OpenPCLViewer extends JPanel implements IOpenPCL, IPluginHooksOpenPCL { private static final long serialVersionUID = 1L; @@ -141,7 +143,7 @@ // Instance variables protected String mAppName = "OpenPCL Viewer"; protected String mAppDescription = " - Free Open Source PCL Viewer for the World"; - protected String mAppVersion = "Version 0.08 September 7, 2007"; + protected String mAppVersion = "Version 0.08 December 7, 2007"; private Frame mParentFrame = null; private JApplet mJApplet = null; @@ -510,7 +512,11 @@ // After the JFrame is visible, if the user had put a file to open on the command line, then open the file now, // and any other code that must be executed after the UI is showing on the screen - executeAfterUiIsShowing(); + if (mPosStartupOptions.getModeToRun() != PosStartupOptions.sModeToRunApplet) { + // Don't call the below if this JPanel is in an applet because the applet will call the below method + // after the applet puts this JPanel in the applet on the screen + executeAfterUiIsShowing(); + } } // Find the Frame of the Browser that the applet is running in, or else make a new not visible Frame @@ -591,12 +597,23 @@ * Code that needs to execute after the UI is showing on the screen upon app startup. * @author howard 9/20/06 */ - protected void executeAfterUiIsShowing() { + public void executeAfterUiIsShowing() { String tOpenFile = mPosStartupOptions.getCommandLineFileToOpen(); // If there is a file name on the command line then open the file to view if (tOpenFile != null && tOpenFile.length() > 0) { actionOpenLocalFileSpecified(tOpenFile); - if (mPosViewSelected != null) { mPosViewSelected.getPosTree().selectPage1(); } + if (mPosViewSelected != null) { + mPosViewSelected.getPosTree().selectPage1(); + + if (mPosStartupOptions.getModeToRun() == PosStartupOptions.sModeToRunApplet) { + // When this app is put in an applet, the initial file to automatically open and show doesn't show unless the below is done + // so that the automatic drawing of the PCL page is kicked off again doing the "force zoom to width" + int tParentFrameWidth = mParentFrame.getWidth(); + int tParentFrameHeight = mParentFrame.getHeight(); + mParentFrame.setSize(tParentFrameWidth - 2, tParentFrameHeight); + mParentFrame.setSize(tParentFrameWidth, tParentFrameHeight); + } + } } } @@ -1996,9 +2013,16 @@ String tLoadFileErrorString = loadFromFileSplitIntoSeparatePclPages(pFilePathAndFileName); if (tLoadFileErrorString != null) { + mPosViewSelected.freeUpMemory(); + mPosViewSelected = null; // Success on creating the new Mdi view but error on splitting the Pcl bytes into separate pages. // Could be file not found or no bytes in the file when opened - JOptionPane.showMessageDialog(mParentFrame, tLoadFileErrorString, "Error", JOptionPane.ERROR_MESSAGE); + JOptionPane.showMessageDialog(mParentFrame, tLoadFileErrorString + + "\nA full absolute directory path is required. No default directory is assumed.\n" + + "Example if the file is to be read from c:/temp\n" + + " 1. Copy the file to c:/temp\n" + + " 2. For the file to open at startup time, specify c:/temp/filename.ext instead of filename.ext", + "Error", JOptionPane.ERROR_MESSAGE); return; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |