Class JavaApplication2D

  • All Implemented Interfaces:
    java.awt.event.KeyListener, java.io.Serializable, java.util.EventListener

    public abstract class JavaApplication2D
    extends JavaApplication
    implements java.io.Serializable
    See Also:
    Serialized Form
    • Field Detail

      • m_iScrWidth

        protected int m_iScrWidth
        Screen width, height
      • m_iScrHeight

        protected int m_iScrHeight
        Screen width, height
      • m_akScreen

        protected byte[] m_akScreen
        Screen polygon
      • m_bClampToWindow

        protected boolean m_bClampToWindow
        Screen wraps or is clamped
      • m_bFlipScreen

        protected boolean m_bFlipScreen
        Set to true to flip the screen:
      • m_akFlipScreen

        protected byte[] m_akFlipScreen
        For right-handed drawing. The array m_akScreen is copied to m_akFlipScreen so that the rows are reversed.
    • Constructor Detail

      • JavaApplication2D

        public JavaApplication2D​(java.lang.String acWindowTitle,
                                 int iXPosition,
                                 int iYPosition,
                                 int iWidth,
                                 int iHeight,
                                 ColorRGBA rkBackgroundColor)
        Constructs a 2D application.
        Parameters:
        acWindowTitle - the window title
        iXPosition - window screen x-position
        iYPosition - window screen y-position
        iWidth - window width
        iHeight - window height
        rkBackgroundColor - background color
    • Method Detail

      • ClampToWindow

        public boolean ClampToWindow()
        Returns if the Screen wraps or is clamped
        Returns:
        true if the Screen is clamped, false if it wraps.
      • ClearScreen

        public void ClearScreen()
        Clears the screen polygon.
      • DoFlip

        public void DoFlip​(boolean bDoFlip)
        For right-handed drawing. You need only call DoFlip(true) once for an application. The default is 'false'.
        Parameters:
        bDoFlip - sets the flip screen flag.
      • DrawCircle

        public void DrawCircle​(int iXCenter,
                               int iYCenter,
                               int iRadius,
                               ColorRGB kColor,
                               boolean bSolid)
        Draw a circle centered at iXCenter, iYCenter
        Parameters:
        iXCenter - center x-position
        iYCenter - center y-position
        iRadius - circle radius
        kColor - color.
        bSolid - when true the circle is solid, when false it is an outline.
      • DrawLine

        public void DrawLine​(int iX0,
                             int iY0,
                             int iX1,
                             int iY1,
                             ColorRGB kColor)
        Draw a line from (iX0,iY0) to (iX1,iY1).
        Parameters:
        iX0 - start x-location.
        iY0 - start y-location.
        iX1 - end x-location.
        iY1 - end y-location.
        kColor - line color.
      • DrawRectangle

        public void DrawRectangle​(int iXMin,
                                  int iYMin,
                                  int iXMax,
                                  int iYMax,
                                  ColorRGB kColor,
                                  boolean bSolid)
        Draw a rectangle with lower-left corner (iXMin,iYMin) and upper-right corner (iXMax,iYMax).
        Parameters:
        iXMin - lower-left corner x-position
        iYMin - lower-left corner y-position
        iXMax - upper-right corner x-position
        iYMax - upper-right corner y-position
        kColor - color.
        bSolid - when true the rectangle is solid, when false it is an outline.
      • Fill

        public void Fill​(int iX,
                         int iY,
                         ColorRGB kFColor,
                         ColorRGB kBColor)
        Flood fill operation.
        Parameters:
        iX - start x-coordinate in pixels
        iY - start y-coordinate in pixels
        kFColor - the fill color.
        kBColor - the back-ground color.
      • GetPixel

        public ColorRGB GetPixel​(int iX,
                                 int iY)
        Returns the pixel color at the specified location.
        Parameters:
        iX - pixel x-location.
        iY - pixel y-location.
        Returns:
        the new pixel color.
      • OnInitialize

        public boolean OnInitialize()
        Initialize event callback.
        Overrides:
        OnInitialize in class JavaApplication
        Returns:
        true if successful initialization, false otherwise.
      • OnResize

        public void OnResize​(int iWidth,
                             int iHeight)
        Resize event callback.
        Overrides:
        OnResize in class JavaApplication
        Parameters:
        iWidth - new window width
        iHeight - new window height
      • ScreenOverlay

        public void ScreenOverlay()
        Allows you to do additional drawing after the screen polygon is drawn.
      • SetPixel

        public void SetPixel​(int iX,
                             int iY,
                             ColorRGB kColor)
        Sets the pixel color.
        Parameters:
        iX - pixel x-location.
        iY - pixel y-location.
        kColor - new pixel color.
      • SetThickPixel

        public void SetThickPixel​(int iX,
                                  int iY,
                                  int iThick,
                                  ColorRGB kColor)
        Sets a thick pixel color.
        Parameters:
        iX - pixel x-location.
        iY - pixel y-location.
        iThick - pixel thickness.
        kColor - new pixel color.
      • Index

        protected int Index​(int iX,
                            int iY)
        left-handed screen coordinates
        Parameters:
        iX - screen coordinate
        iY - screen coordinate
        Returns:
        left-handed screen coordinates.
      • IndexFlip

        protected int IndexFlip​(int iX,
                                int iY)
        right-handed screen coordinates
        Parameters:
        iX - screen coordinate
        iY - screen coordinate
        Returns:
        right-handed screen coordinates.