Class Platform

  • All Implemented Interfaces:
    javajs.api.FontManager, javajs.api.GenericPlatform
    Direct Known Subclasses:
    Platform

    public class Platform
    extends java.lang.Object
    implements javajs.api.GenericPlatform
    JavaScript 2D canvas version requires Ajax-based URL stream processing. Jmol "display" --> HTML5 "canvas" Jmol "image" --> HTML5 "canvas" (because we need width and height) Jmol "graphics" --> HTML5 "context(2d)" (one for display, one off-screen for fonts) Jmol "font" --> JmolFont Jmol "fontMetrics" --> HTML5 "context(2d)" (Not fully implemented)
    Author:
    Bob Hanson
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) java.lang.Object canvas  
      (package private) java.lang.Object context  
      (package private) javajs.api.PlatformViewer vwr  
      • Fields inherited from interface javajs.api.GenericPlatform

        CURSOR_CROSSHAIR, CURSOR_DEFAULT, CURSOR_HAND, CURSOR_MOVE, CURSOR_WAIT, CURSOR_ZOOM
    • Constructor Summary

      Constructors 
      Constructor Description
      Platform()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object allocateRgbImage​(int windowWidth, int windowHeight, int[] pBuffer, int windowSize, boolean backgroundTransparent, boolean isImageWrite)
      Create an "image" that is either a canvas with width/height/buf32 (from g3d.Platform32) or just an associative array with those (image writing
      void convertPointFromScreen​(java.lang.Object canvas, javajs.util.P3 ptTemp)  
      java.lang.Object createImage​(java.lang.Object name_path_bytes)
      can be ignored (return null) if platform cannot save images
      void disposeGraphics​(java.lang.Object gOffscreen)  
      void drawImage​(java.lang.Object context, java.lang.Object canvas, int x, int y, int width, int height, boolean isDTI)  
      int[] drawImageToBuffer​(java.lang.Object gOffscreen, java.lang.Object imageOffscreen, java.lang.Object canvas, int width, int height, int bgcolor)  
      void flushImage​(java.lang.Object imagePixelBuffer)  
      int fontStringWidth​(javajs.awt.Font font, java.lang.String text)  
      boolean forceAsyncLoad​(java.lang.String filename)  
      java.lang.Object getBufferedFileInputStream​(java.lang.String name)  
      java.lang.String getDateFormat​(java.lang.String isoType)  
      int getFontAscent​(java.lang.Object context)  
      int getFontDescent​(java.lang.Object context)  
      java.lang.Object getFontMetrics​(javajs.awt.Font font, java.lang.Object context)  
      void getFullScreenDimensions​(java.lang.Object canvas, int[] widthHeight)  
      java.lang.Object getGraphics​(java.lang.Object canvas)  
      javajs.api.GenericImageDialog getImageDialog​(java.lang.String title, java.util.Map<java.lang.String,​javajs.api.GenericImageDialog> imageMap)  
      int getImageHeight​(java.lang.Object canvas)  
      int getImageWidth​(java.lang.Object canvas)  
      java.lang.Object getJsObjectInfo​(java.lang.Object[] jsObject, java.lang.String method, java.lang.Object[] args)  
      java.lang.String getLocalUrl​(java.lang.String fileName)  
      javajs.api.GenericMenuInterface getMenuPopup​(java.lang.String menuStructure, char type)  
      javajs.api.GenericMouseInterface getMouseManager​(double privateKey, java.lang.Object display)  
      java.lang.Object getStaticGraphics​(java.lang.Object image, boolean backgroundTransparent)  
      int[] getTextPixels​(java.lang.String text, javajs.awt.Font font3d, java.lang.Object context, java.lang.Object image, int width, int height, int ascent)  
      java.lang.Object getURLContents​(java.net.URL url, byte[] outputBytes, java.lang.String post, boolean asString)  
      static java.lang.Object getURLContentsStatic​(java.net.URL url, byte[] outputBytes, java.lang.String post, boolean asString)
      In case this needs to be performed directly, without interface
      int[] grabPixels​(java.lang.Object canvas, int width, int height, int[] pixels, int startRow, int nRows)  
      boolean hasFocus​(java.lang.Object canvas)  
      boolean isHeadless()  
      boolean isSingleThreaded()  
      static JmolToJSmolInterface Jmol()  
      java.lang.Object newBufferedImage​(java.lang.Object image, int w, int h)  
      javajs.api.GenericFileInterface newFile​(java.lang.String name)  
      java.lang.Object newFont​(java.lang.String fontFace, boolean isBold, boolean isItalic, float fontSize)  
      java.lang.Object newOffScreenImage​(int w, int h)  
      void notifyEndOfRendering()  
      java.lang.String prompt​(java.lang.String label, java.lang.String data, java.lang.String[] list, boolean asButtons)  
      void renderScreenImage​(java.lang.Object context, java.lang.Object size)
      legacy apps will use this
      void repaint​(java.lang.Object canvas)  
      void requestFocusInWindow​(java.lang.Object canvas)  
      void setCursor​(int c, java.lang.Object canvas)  
      void setTransparentCursor​(java.lang.Object canvas)  
      void setViewer​(javajs.api.PlatformViewer vwr, java.lang.Object canvas)  
      boolean waitForDisplay​(java.lang.Object echoNameAndPath, java.lang.Object zipBytes)
      can be ignored (return false) if platform cannot save images
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • canvas

        java.lang.Object canvas
      • vwr

        javajs.api.PlatformViewer vwr
      • context

        java.lang.Object context
    • Constructor Detail

      • Platform

        public Platform()
    • Method Detail

      • setViewer

        public void setViewer​(javajs.api.PlatformViewer vwr,
                              java.lang.Object canvas)
        Specified by:
        setViewer in interface javajs.api.GenericPlatform
      • isSingleThreaded

        public boolean isSingleThreaded()
        Specified by:
        isSingleThreaded in interface javajs.api.GenericPlatform
      • getJsObjectInfo

        public java.lang.Object getJsObjectInfo​(java.lang.Object[] jsObject,
                                                java.lang.String method,
                                                java.lang.Object[] args)
        Specified by:
        getJsObjectInfo in interface javajs.api.GenericPlatform
      • isHeadless

        public boolean isHeadless()
        Specified by:
        isHeadless in interface javajs.api.GenericPlatform
      • getMouseManager

        public javajs.api.GenericMouseInterface getMouseManager​(double privateKey,
                                                                java.lang.Object display)
        Specified by:
        getMouseManager in interface javajs.api.GenericPlatform
      • convertPointFromScreen

        public void convertPointFromScreen​(java.lang.Object canvas,
                                           javajs.util.P3 ptTemp)
        Specified by:
        convertPointFromScreen in interface javajs.api.GenericPlatform
      • getFullScreenDimensions

        public void getFullScreenDimensions​(java.lang.Object canvas,
                                            int[] widthHeight)
        Specified by:
        getFullScreenDimensions in interface javajs.api.GenericPlatform
      • getMenuPopup

        public javajs.api.GenericMenuInterface getMenuPopup​(java.lang.String menuStructure,
                                                            char type)
        Specified by:
        getMenuPopup in interface javajs.api.GenericPlatform
      • hasFocus

        public boolean hasFocus​(java.lang.Object canvas)
        Specified by:
        hasFocus in interface javajs.api.GenericPlatform
      • prompt

        public java.lang.String prompt​(java.lang.String label,
                                       java.lang.String data,
                                       java.lang.String[] list,
                                       boolean asButtons)
        Specified by:
        prompt in interface javajs.api.GenericPlatform
      • renderScreenImage

        public void renderScreenImage​(java.lang.Object context,
                                      java.lang.Object size)
        legacy apps will use this
        Specified by:
        renderScreenImage in interface javajs.api.GenericPlatform
        Parameters:
        context -
        size -
      • drawImage

        public void drawImage​(java.lang.Object context,
                              java.lang.Object canvas,
                              int x,
                              int y,
                              int width,
                              int height,
                              boolean isDTI)
        Specified by:
        drawImage in interface javajs.api.GenericPlatform
      • requestFocusInWindow

        public void requestFocusInWindow​(java.lang.Object canvas)
        Specified by:
        requestFocusInWindow in interface javajs.api.GenericPlatform
      • repaint

        public void repaint​(java.lang.Object canvas)
        Specified by:
        repaint in interface javajs.api.GenericPlatform
      • setTransparentCursor

        public void setTransparentCursor​(java.lang.Object canvas)
        Specified by:
        setTransparentCursor in interface javajs.api.GenericPlatform
      • setCursor

        public void setCursor​(int c,
                              java.lang.Object canvas)
        Specified by:
        setCursor in interface javajs.api.GenericPlatform
      • allocateRgbImage

        public java.lang.Object allocateRgbImage​(int windowWidth,
                                                 int windowHeight,
                                                 int[] pBuffer,
                                                 int windowSize,
                                                 boolean backgroundTransparent,
                                                 boolean isImageWrite)
        Create an "image" that is either a canvas with width/height/buf32 (from g3d.Platform32) or just an associative array with those (image writing
        Specified by:
        allocateRgbImage in interface javajs.api.GenericPlatform
      • notifyEndOfRendering

        public void notifyEndOfRendering()
        Specified by:
        notifyEndOfRendering in interface javajs.api.GenericPlatform
      • disposeGraphics

        public void disposeGraphics​(java.lang.Object gOffscreen)
        Specified by:
        disposeGraphics in interface javajs.api.GenericPlatform
      • grabPixels

        public int[] grabPixels​(java.lang.Object canvas,
                                int width,
                                int height,
                                int[] pixels,
                                int startRow,
                                int nRows)
        Specified by:
        grabPixels in interface javajs.api.GenericPlatform
        Returns:
        pixels
      • drawImageToBuffer

        public int[] drawImageToBuffer​(java.lang.Object gOffscreen,
                                       java.lang.Object imageOffscreen,
                                       java.lang.Object canvas,
                                       int width,
                                       int height,
                                       int bgcolor)
        Specified by:
        drawImageToBuffer in interface javajs.api.GenericPlatform
      • getTextPixels

        public int[] getTextPixels​(java.lang.String text,
                                   javajs.awt.Font font3d,
                                   java.lang.Object context,
                                   java.lang.Object image,
                                   int width,
                                   int height,
                                   int ascent)
        Specified by:
        getTextPixels in interface javajs.api.GenericPlatform
      • flushImage

        public void flushImage​(java.lang.Object imagePixelBuffer)
        Specified by:
        flushImage in interface javajs.api.GenericPlatform
      • getGraphics

        public java.lang.Object getGraphics​(java.lang.Object canvas)
        Specified by:
        getGraphics in interface javajs.api.GenericPlatform
      • getImageHeight

        public int getImageHeight​(java.lang.Object canvas)
        Specified by:
        getImageHeight in interface javajs.api.GenericPlatform
      • getImageWidth

        public int getImageWidth​(java.lang.Object canvas)
        Specified by:
        getImageWidth in interface javajs.api.GenericPlatform
      • getStaticGraphics

        public java.lang.Object getStaticGraphics​(java.lang.Object image,
                                                  boolean backgroundTransparent)
        Specified by:
        getStaticGraphics in interface javajs.api.GenericPlatform
      • newBufferedImage

        public java.lang.Object newBufferedImage​(java.lang.Object image,
                                                 int w,
                                                 int h)
        Specified by:
        newBufferedImage in interface javajs.api.GenericPlatform
      • newOffScreenImage

        public java.lang.Object newOffScreenImage​(int w,
                                                  int h)
        Specified by:
        newOffScreenImage in interface javajs.api.GenericPlatform
      • waitForDisplay

        public boolean waitForDisplay​(java.lang.Object echoNameAndPath,
                                      java.lang.Object zipBytes)
                               throws java.lang.InterruptedException
        Description copied from interface: javajs.api.GenericPlatform
        can be ignored (return false) if platform cannot save images
        Specified by:
        waitForDisplay in interface javajs.api.GenericPlatform
        Returns:
        false only if this platform cannot save images
        Throws:
        java.lang.InterruptedException
      • createImage

        public java.lang.Object createImage​(java.lang.Object name_path_bytes)
        Description copied from interface: javajs.api.GenericPlatform
        can be ignored (return null) if platform cannot save images
        Specified by:
        createImage in interface javajs.api.GenericPlatform
        Parameters:
        name_path_bytes -
        Returns:
        image object or null if asynchronous
      • fontStringWidth

        public int fontStringWidth​(javajs.awt.Font font,
                                   java.lang.String text)
        Specified by:
        fontStringWidth in interface javajs.api.FontManager
      • getFontAscent

        public int getFontAscent​(java.lang.Object context)
        Specified by:
        getFontAscent in interface javajs.api.FontManager
      • getFontDescent

        public int getFontDescent​(java.lang.Object context)
        Specified by:
        getFontDescent in interface javajs.api.FontManager
      • getFontMetrics

        public java.lang.Object getFontMetrics​(javajs.awt.Font font,
                                               java.lang.Object context)
        Specified by:
        getFontMetrics in interface javajs.api.FontManager
      • newFont

        public java.lang.Object newFont​(java.lang.String fontFace,
                                        boolean isBold,
                                        boolean isItalic,
                                        float fontSize)
        Specified by:
        newFont in interface javajs.api.FontManager
      • getDateFormat

        public java.lang.String getDateFormat​(java.lang.String isoType)
        Specified by:
        getDateFormat in interface javajs.api.GenericPlatform
      • newFile

        public javajs.api.GenericFileInterface newFile​(java.lang.String name)
        Specified by:
        newFile in interface javajs.api.GenericPlatform
      • getBufferedFileInputStream

        public java.lang.Object getBufferedFileInputStream​(java.lang.String name)
        Specified by:
        getBufferedFileInputStream in interface javajs.api.GenericPlatform
      • getURLContents

        public java.lang.Object getURLContents​(java.net.URL url,
                                               byte[] outputBytes,
                                               java.lang.String post,
                                               boolean asString)
        Specified by:
        getURLContents in interface javajs.api.GenericPlatform
        Returns:
        may be javajs.util.SB or byte[] or java.io.InputStream
      • getURLContentsStatic

        public static java.lang.Object getURLContentsStatic​(java.net.URL url,
                                                            byte[] outputBytes,
                                                            java.lang.String post,
                                                            boolean asString)
        In case this needs to be performed directly, without interface
        Parameters:
        url -
        outputBytes -
        post -
        asString -
        Returns:
        String or byte[] or javajs.util.SB
      • getLocalUrl

        public java.lang.String getLocalUrl​(java.lang.String fileName)
        Specified by:
        getLocalUrl in interface javajs.api.GenericPlatform
      • getImageDialog

        public javajs.api.GenericImageDialog getImageDialog​(java.lang.String title,
                                                            java.util.Map<java.lang.String,​javajs.api.GenericImageDialog> imageMap)
        Specified by:
        getImageDialog in interface javajs.api.GenericPlatform
      • forceAsyncLoad

        public boolean forceAsyncLoad​(java.lang.String filename)
        Specified by:
        forceAsyncLoad in interface javajs.api.GenericPlatform