Class OutputManager

    • Constructor Detail

      • OutputManager

        OutputManager()
    • Method Detail

      • getLogPath

        protected abstract String getLogPath​(String fileName)
      • clipImageOrPasteText

        abstract String clipImageOrPasteText​(String text)
      • getClipboardText

        abstract String getClipboardText()
      • openOutputChannel

        abstract javajs.util.OC openOutputChannel​(double privateKey,
                                                  String fileName,
                                                  boolean asWriter,
                                                  boolean asAppend)
                                           throws IOException
        Throws:
        IOException
      • createSceneSet

        protected abstract String createSceneSet​(String sceneFile,
                                                 String type,
                                                 int width,
                                                 int height)
      • writeToOutputChannel

        private String writeToOutputChannel​(Map<String,​Object> params)
        From handleOutputToFile, write text, byte[], or image data to a file;
        Parameters:
        params -
        Returns:
        null (canceled) or byte[] or String message starting with OK or an error message; in the case of params.image != null, return the fileName
      • getOrSaveImage

        private Object getOrSaveImage​(Map<String,​Object> params)
                               throws Exception
        Creates an image of params.type form -- PNG, PNGJ, PNGT, JPG, JPG64, PDF, PPM, GIF, GIFT. From createImage and getImageAsBytes
        Parameters:
        params - include fileName, type, text, bytes, image, scripts, appendix, quality, outputStream, and type-specific parameters. If params.outputChannel != null, then we are passing back the data, and the channel will not be closed.
        Returns:
        bytes[] if params.fileName==null and params.outputChannel==null otherwise, return a message string or null
        Throws:
        Exception
      • getWrappedState

        Object getWrappedState​(String pngjName,
                               String[] scripts,
                               Object objImage,
                               javajs.util.OC pgjOut)
        Parameters:
        pngjName -
        scripts -
        objImage -
        pgjOut -
        Returns:
        either byte[] (a full ZIP file) or String (just an embedded state script)
      • createTheImage

        private boolean createTheImage​(Object objImage,
                                       String type,
                                       javajs.util.OC out,
                                       Map<String,​Object> params,
                                       String[] errRet)
        Parameters:
        objImage -
        type -
        out -
        params -
        errRet -
        Returns:
        byte array if needed
      • encodeImage

        private int[] encodeImage​(int width,
                                  int height,
                                  Object objImage)
                           throws Exception
        general image encoder, allows for BufferedImage, int[], or HTML5 2D canvas
        Parameters:
        width -
        height -
        objImage -
        Returns:
        linear int[] array of ARGB values
        Throws:
        Exception
      • getOutputChannel

        javajs.util.OC getOutputChannel​(String fileName,
                                        String[] fullPath)
      • processWriteOrCapture

        String processWriteOrCapture​(Map<String,​Object> params)
        Parameters:
        params - include fileName, type, text, bytes, scripts, quality, width, height, bsFrames, nVibes, fullPath
        Returns:
        message
      • processMultiFrameOutput

        private String processMultiFrameOutput​(String fileName,
                                               javajs.util.BS bsFrames,
                                               int nVibes,
                                               Map<String,​Object> params)
      • getRootExt

        private static Object getRootExt​(String fileName,
                                         String[] rootExt,
                                         int n)
      • getImageAsBytes

        byte[] getImageAsBytes​(String type,
                               int width,
                               int height,
                               int quality,
                               String[] errMsg)
        Called when a simple image is required -- from x=getProperty("image") or for a simple preview PNG image for inclusion in a ZIP file from write xxx.zip or xxx.jmol, or for a PNGJ or PNG image that is being posted because of a URL that contains "?POST?_PNG_" or ?POST?_PNGJ_" or ?POST?_PNGJBIN_".
        Parameters:
        type -
        width -
        height -
        quality -
        errMsg -
        Returns:
        image bytes or, if an error, null and an error message
      • writeFileData

        String writeFileData​(String fileName,
                             String type,
                             int modelIndex,
                             Object[] plotParameters)
        Generates file data and passes it on either to a FileOuputStream (Java) or via POSTing to a url using a ByteOutputStream (JavaScript)
        Parameters:
        fileName -
        type - one of: PDB PQR FILE PLOT
        modelIndex -
        plotParameters -
        Returns:
        "OK..." or "" or null
      • writeFrame

        private boolean writeFrame​(int n,
                                   String[] rootExt,
                                   Map<String,​Object> params,
                                   javajs.util.SB sb)
      • getOutputFileNameFromDialog

        private String getOutputFileNameFromDialog​(String fileName,
                                                   int quality,
                                                   Map<String,​Object> params)
      • handleOutputToFile

        protected String handleOutputToFile​(Map<String,​Object> params,
                                            boolean doCheck)
        general routine for creating an image or writing data to a file passes request to statusManager to pass along to app or applet jmolStatusListener interface
        Parameters:
        params - include: fileName: starts with ? → use file dialog; type: PNG, JPG, etc.; text: String to output; bytes: byte[] or null if an image; scripts for scenes; quality: for JPG and PNG; width: image width; height: image height; fullPath: String[] return
        doCheck -
        Returns:
        null (canceled) or a message starting with OK or an error message
      • logToFile

        void logToFile​(String data)
      • createZipSet

        private String createZipSet​(String script,
                                    String[] scripts,
                                    boolean includeRemoteFiles,
                                    javajs.util.OC out,
                                    String pngjName)
      • writeZipFile

        private String writeZipFile​(javajs.util.OC out,
                                    javajs.util.Lst<Object> fileNamesAndByteArrays,
                                    String msg,
                                    String pngjName)
        generic method to create a zip file based on http://www.exampledepot.com/egs/java.util.zip/CreateZip.html
        Parameters:
        out -
        fileNamesAndByteArrays - Vector of [filename1, bytes|null, filename2, bytes|null, ...]
        msg -
        pngjName - TODO
        Returns:
        msg bytes filename or errorMessage or byte[]
      • wrapPathForAllFiles

        protected String wrapPathForAllFiles​(String cmd,
                                             String strCatch)