Class Platform

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

    public class Platform
    extends java.lang.Object
    implements 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 Detail

      • canvas

        java.lang.Object canvas
      • context

        java.lang.Object context
    • Constructor Detail

      • Platform

        public Platform()
    • Method Detail

      • getJsObjectInfo

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

        public boolean hasFocus​(java.lang.Object canvas)
        Specified by:
        hasFocus in interface 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 GenericPlatform
      • renderScreenImage

        public void renderScreenImage​(java.lang.Object context,
                                      java.lang.Object size)
        legacy apps will use this
        Specified by:
        renderScreenImage in interface 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 GenericPlatform
      • repaint

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

        public void setCursor​(int c,
                              java.lang.Object canvas)
        Specified by:
        setCursor in interface 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 GenericPlatform
      • grabPixels

        public int[] grabPixels​(java.lang.Object canvas,
                                int width,
                                int height,
                                int[] pixels,
                                int startRow,
                                int nRows)
        Specified by:
        grabPixels in interface 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 GenericPlatform
      • getTextPixels

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

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

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

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

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

        public boolean waitForDisplay​(java.lang.Object echoNameAndPath,
                                      java.lang.Object zipBytes)
                               throws java.lang.InterruptedException
        Description copied from interface: GenericPlatform
        can be ignored (return false) if platform cannot save images
        Specified by:
        waitForDisplay in interface 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: GenericPlatform
        can be ignored (return null) if platform cannot save images
        Specified by:
        createImage in interface GenericPlatform
        Parameters:
        name_path_bytes -
        Returns:
        image object or null if asynchronous
      • getFontAscent

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

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

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

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

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

        public java.lang.Object getURLContents​(java.net.URL url,
                                               byte[] outputBytes,
                                               java.lang.String post,
                                               boolean asString)
        Specified by:
        getURLContents in interface 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 GenericPlatform