JsG2D
Date: 2019-10-22

org.jmol.awtjs2d

## Class JsG2D

- java.lang.Object
- - org.jmol.awtjs2d.JsG2D

- All Implemented Interfaces:
    GenericGraphics

      public class JsG2D
      extends java.lang.Object
      implements GenericGraphics

  generic 2D drawing methods -- JavaScript version
  Author:
    Bob Hanson hansonr@stolaf.edu

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `(package private) boolean` | `inPath`
    `(package private) boolean` | `isShifted`
    `private int` | `windowHeight`
    `private int` | `windowWidth`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `JsG2D()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `canDoLineTo()`
    `private void` | `doPoly(java.lang.Object g, int[] axPoints, int[] ayPoints, int nPoints, boolean doFill)`
    `void` | `doStroke(java.lang.Object g, boolean isBegin)`
    `void` | `drawCircle(java.lang.Object g, int x, int y, int diameter)`
    `void` | `drawGrayScaleImage(java.lang.Object g, java.lang.Object image, int destX0, int destY0, int destX1, int destY1, int srcX0, int srcY0, int srcX1, int srcY1)`
    `void` | `drawLine(java.lang.Object g, int x0, int y0, int x1, int y1)`
    `void` | `drawPolygon(java.lang.Object g, int[] ayPoints, int[] axPoints, int nPoints)`
    `void` | `drawRect(java.lang.Object g, int x, int y, int width, int height)`
    `void` | `drawString(java.lang.Object g, java.lang.String s, int x, int y)`
    `void` | `drawStringRotated(java.lang.Object g, java.lang.String s, int x, int y, double angle)`
    `void` | `fillBackground(java.lang.Object g, javajs.api.GenericColor bgcolor)`
    `void` | `fillCircle(java.lang.Object g, int x, int y, int diameter)`
    `void` | `fillPolygon(java.lang.Object g, int[] ayPoints, int[] axPoints, int nPoints)`
    `void` | `fillRect(java.lang.Object g, int x, int y, int width, int height)`
    `javajs.api.GenericColor` | `getColor1(int rgb)`
    `javajs.api.GenericColor` | `getColor3(int r, int g, int b)`
    `javajs.api.GenericColor` | `getColor4(int r, int g, int b, int a)`
    `void` | `lineTo(java.lang.Object g, int x2, int y2)`
    `java.lang.Object` | `newGrayScaleImage(java.lang.Object context, java.lang.Object image, int width, int height, int[] grayBuffer)`
    `Font` | `setFont(java.lang.Object g, Font font)`
    `void` | `setGraphicsColor(java.lang.Object g, javajs.api.GenericColor c)`
    `void` | `setStrokeBold(java.lang.Object g, boolean tf)`
    `void` | `setWindowParameters(int width, int height)`
    `void` | `translateScale(java.lang.Object g, double x, double y, double scale)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### windowWidth

          private int windowWidth

    - #### windowHeight

          private int windowHeight

    - #### isShifted

          boolean isShifted

    - #### inPath

          boolean inPath

  - ### Constructor Detail

    - #### JsG2D

          public JsG2D()

  - ### Method Detail

    - #### getColor4

          public javajs.api.GenericColor getColor4(int r,
                                                   int g,
                                                   int b,
                                                   int a)

      Specified by:
        `getColor4` in interface `GenericGraphics`

    - #### getColor3

          public javajs.api.GenericColor getColor3(int r,
                                                   int g,
                                                   int b)

      Specified by:
        `getColor3` in interface `GenericGraphics`

    - #### getColor1

          public javajs.api.GenericColor getColor1(int rgb)

      Specified by:
        `getColor1` in interface `GenericGraphics`

    - #### newGrayScaleImage

          public java.lang.Object newGrayScaleImage(java.lang.Object context,
                                                    java.lang.Object image,
                                                    int width,
                                                    int height,
                                                    int[] grayBuffer)

      Specified by:
        `newGrayScaleImage` in interface `GenericGraphics`

    - #### drawGrayScaleImage

          public void drawGrayScaleImage(java.lang.Object g,
                                         java.lang.Object image,
                                         int destX0,
                                         int destY0,
                                         int destX1,
                                         int destY1,
                                         int srcX0,
                                         int srcY0,
                                         int srcX1,
                                         int srcY1)

      Specified by:
        `drawGrayScaleImage` in interface `GenericGraphics`

    - #### drawLine

          public void drawLine(java.lang.Object g,
                               int x0,
                               int y0,
                               int x1,
                               int y1)

      Specified by:
        `drawLine` in interface `GenericGraphics`

    - #### drawCircle

          public void drawCircle(java.lang.Object g,
                                 int x,
                                 int y,
                                 int diameter)

      Specified by:
        `drawCircle` in interface `GenericGraphics`

    - #### drawPolygon

          public void drawPolygon(java.lang.Object g,
                                  int[] ayPoints,
                                  int[] axPoints,
                                  int nPoints)

      Specified by:
        `drawPolygon` in interface `GenericGraphics`

    - #### doPoly

          private void doPoly(java.lang.Object g,
                              int[] axPoints,
                              int[] ayPoints,
                              int nPoints,
                              boolean doFill)

      Parameters:
        `g` -
        `axPoints` -
        `ayPoints` -
        `nPoints` -
        `doFill` -

    - #### drawRect

          public void drawRect(java.lang.Object g,
                               int x,
                               int y,
                               int width,
                               int height)

      Specified by:
        `drawRect` in interface `GenericGraphics`

    - #### drawString

          public void drawString(java.lang.Object g,
                                 java.lang.String s,
                                 int x,
                                 int y)

      Specified by:
        `drawString` in interface `GenericGraphics`

    - #### drawStringRotated

          public void drawStringRotated(java.lang.Object g,
                                        java.lang.String s,
                                        int x,
                                        int y,
                                        double angle)

      Specified by:
        `drawStringRotated` in interface `GenericGraphics`

    - #### fillBackground

          public void fillBackground(java.lang.Object g,
                                     javajs.api.GenericColor bgcolor)

      Specified by:
        `fillBackground` in interface `GenericGraphics`

    - #### fillCircle

          public void fillCircle(java.lang.Object g,
                                 int x,
                                 int y,
                                 int diameter)

      Specified by:
        `fillCircle` in interface `GenericGraphics`

    - #### fillPolygon

          public void fillPolygon(java.lang.Object g,
                                  int[] ayPoints,
                                  int[] axPoints,
                                  int nPoints)

      Specified by:
        `fillPolygon` in interface `GenericGraphics`

    - #### fillRect

          public void fillRect(java.lang.Object g,
                               int x,
                               int y,
                               int width,
                               int height)

      Specified by:
        `fillRect` in interface `GenericGraphics`

    - #### setGraphicsColor

          public void setGraphicsColor(java.lang.Object g,
                                       javajs.api.GenericColor c)

      Specified by:
        `setGraphicsColor` in interface `GenericGraphics`

    - #### setFont

          public Font setFont(java.lang.Object g,
                              Font font)

      Specified by:
        `setFont` in interface `GenericGraphics`

    - #### setStrokeBold

          public void setStrokeBold(java.lang.Object g,
                                    boolean tf)

      Specified by:
        `setStrokeBold` in interface `GenericGraphics`

    - #### setWindowParameters

          public void setWindowParameters(int width,
                                          int height)

      Specified by:
        `setWindowParameters` in interface `GenericGraphics`

    - #### translateScale

          public void translateScale(java.lang.Object g,
                                     double x,
                                     double y,
                                     double scale)

      Specified by:
        `translateScale` in interface `GenericGraphics`

    - #### canDoLineTo

          public boolean canDoLineTo()

      Specified by:
        `canDoLineTo` in interface `GenericGraphics`

    - #### doStroke

          public void doStroke(java.lang.Object g,
                               boolean isBegin)

      Specified by:
        `doStroke` in interface `GenericGraphics`

    - #### lineTo

          public void lineTo(java.lang.Object g,
                             int x2,
                             int y2)

      Specified by:
        `lineTo` in interface `GenericGraphics`