Package org.jmol.viewer
Class OutputManager
java.lang.Object
org.jmol.viewer.OutputManager
- Direct Known Subclasses:
OutputManagerAwt
,OutputManagerJS
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate String
addPngFileBytes
(String name, byte[] ret, int iFile, Hashtable<Object, String> crcMap, boolean isSparDir, String newName, int ptSlash, javajs.util.Lst<Object> v) (package private) abstract String
clipImageOrPasteText
(String text) protected abstract String
createSceneSet
(String sceneFile, String type, int width, int height) private boolean
createTheImage
(Object objImage, String type, javajs.util.OC out, Map<String, Object> params, String[] errRet) private String
createZipSet
(String script, String[] scripts, boolean includeRemoteFiles, javajs.util.OC out, String pngjName) private int[]
encodeImage
(int width, int height, Object objImage) general image encoder, allows for BufferedImage, int[], or HTML5 2D canvas(package private) abstract String
(package private) 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_".private void
getImagePixels
(Object objImage, Map<String, Object> params) private static int
protected abstract String
getLogPath
(String fileName) private Object
getOrSaveImage
(Map<String, Object> params) Creates an image of params.type form -- PNG, PNGJ, PNGT, JPG, JPG64, PDF, PPM, GIF, GIFT.(package private) javajs.util.OC
getOutputChannel
(String fileName, String[] fullPath) private String
getOutputFileNameFromDialog
(String fileName, int quality, Map<String, Object> params) (package private) String
getOutputFromExport
(Map<String, Object> params) private static Object
getRootExt
(String fileName, String[] rootExt, int n) (package private) Object
getWrappedState
(String pngjName, String[] scripts, Object objImage, javajs.util.OC pgjOut) 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(package private) void
(package private) abstract javajs.util.OC
openOutputChannel
(double privateKey, String fileName, boolean asWriter, boolean asAppend) (package private) String
outputToFile
(Map<String, Object> params) private String
processMultiFrameOutput
(String fileName, javajs.util.BS bsFrames, int nVibes, Map<String, Object> params) (package private) String
processWriteOrCapture
(Map<String, Object> params) private String
setFullPath
(Map<String, Object> params, String fileName) (package private) String
setLogFile
(String value) (package private) OutputManager
protected String
wrapPathForAllFiles
(String cmd, String strCatch) (package private) 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)private boolean
writeFrame
(int n, String[] rootExt, Map<String, Object> params, javajs.util.SB sb) private String
writeToOutputChannel
(Map<String, Object> params) From handleOutputToFile, write text, byte[], or image data to a file;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
-
Field Details
-
vwr
-
privateKey
protected double privateKey -
SCENE_TAG
- See Also:
-
-
Constructor Details
-
OutputManager
OutputManager()
-
-
Method Details
-
getLogPath
-
clipImageOrPasteText
-
getClipboardText
-
openOutputChannel
abstract javajs.util.OC openOutputChannel(double privateKey, String fileName, boolean asWriter, boolean asAppend) throws IOException - Throws:
IOException
-
createSceneSet
-
setViewer
-
writeToOutputChannel
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
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
- 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) throws Exception- Parameters:
objImage
-type
-out
-params
-errRet
-- Returns:
- byte array if needed
- Throws:
Exception
-
getImagePixels
- Throws:
Exception
-
encodeImage
general image encoder, allows for BufferedImage, int[], or HTML5 2D canvas- Parameters:
width
-height
-objImage
-- Returns:
- linear int[] array of ARGB values
- Throws:
Exception
-
outputToFile
-
getOutputChannel
-
processWriteOrCapture
- Parameters:
params
- include fileName, type, text, bytes, scripts, quality, width, height, bsFrames, nVibes, fullPath- Returns:
- message
-
getInt
-
processMultiFrameOutput
-
getRootExt
-
setFullPath
-
getOutputFromExport
-
getImageAsBytes
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
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 PLOTmodelIndex
- for PLOT or PDB or PQR onlyplotParameters
-- Returns:
- "OK..." or "" or null
-
writeFrame
-
getOutputFileNameFromDialog
-
handleOutputToFile
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[] returndoCheck
-- Returns:
- null (canceled) or a message starting with OK or an error message
-
setLogFile
-
logToFile
-
createZipSet
-
addPngFileBytes
-
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
-