Package org.jmol.viewer
Class OutputManager
- java.lang.Object
-
- org.jmol.viewer.OutputManager
-
- Direct Known Subclasses:
OutputManagerAwt,OutputManagerJS
abstract class OutputManager extends Object
-
-
Field Summary
Fields Modifier and Type Field Description protected doubleprivateKeyprotected static StringSCENE_TAGprotected Viewervwr
-
Constructor Summary
Constructors Constructor Description OutputManager()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description private StringaddPngFileBytes(String name, byte[] ret, int iFile, Hashtable<Object,String> crcMap, boolean isSparDir, String newName, int ptSlash, javajs.util.Lst<Object> v)(package private) abstract StringclipImageOrPasteText(String text)protected abstract StringcreateSceneSet(String sceneFile, String type, int width, int height)private booleancreateTheImage(Object objImage, String type, javajs.util.OC out, Map<String,Object> params, String[] errRet)private StringcreateZipSet(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 StringgetClipboardText()(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 static intgetInt(Map<String,Object> params, String key, int def)protected abstract StringgetLogPath(String fileName)private ObjectgetOrSaveImage(Map<String,Object> params)Creates an image of params.type form -- PNG, PNGJ, PNGT, JPG, JPG64, PDF, PPM, GIF, GIFT.(package private) javajs.util.OCgetOutputChannel(String fileName, String[] fullPath)private StringgetOutputFileNameFromDialog(String fileName, int quality, Map<String,Object> params)(package private) StringgetOutputFromExport(Map<String,Object> params)private static ObjectgetRootExt(String fileName, String[] rootExt, int n)(package private) ObjectgetWrappedState(String pngjName, String[] scripts, Object objImage, javajs.util.OC pgjOut)protected StringhandleOutputToFile(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) voidlogToFile(String data)(package private) abstract javajs.util.OCopenOutputChannel(double privateKey, String fileName, boolean asWriter, boolean asAppend)(package private) StringoutputToFile(Map<String,Object> params)private StringprocessMultiFrameOutput(String fileName, javajs.util.BS bsFrames, int nVibes, Map<String,Object> params)(package private) StringprocessWriteOrCapture(Map<String,Object> params)private StringsetFullPath(Map<String,Object> params, String fileName)(package private) StringsetLogFile(String value)(package private) OutputManagersetViewer(Viewer vwr, double privateKey)protected StringwrapPathForAllFiles(String cmd, String strCatch)(package private) StringwriteFileData(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 booleanwriteFrame(int n, String[] rootExt, Map<String,Object> params, javajs.util.SB sb)private StringwriteToOutputChannel(Map<String,Object> params)From handleOutputToFile, write text, byte[], or image data to a file;private StringwriteZipFile(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 Detail
-
vwr
protected Viewer vwr
-
privateKey
protected double privateKey
-
SCENE_TAG
protected static final String SCENE_TAG
- See Also:
- Constant Field Values
-
-
Method Detail
-
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)
-
setViewer
OutputManager setViewer(Viewer vwr, double privateKey)
-
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 Exceptiongeneral image encoder, allows for BufferedImage, int[], or HTML5 2D canvas- Parameters:
width-height-objImage-- Returns:
- linear int[] array of ARGB values
- Throws:
Exception
-
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)
-
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 PLOTmodelIndex-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[] returndoCheck-- 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)
-
addPngFileBytes
private String addPngFileBytes(String name, byte[] ret, int iFile, Hashtable<Object,String> crcMap, boolean isSparDir, String newName, int ptSlash, javajs.util.Lst<Object> v)
-
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[]
-
-