Package HAL.Gui

Class OpenGL2DWindow

  • All Implemented Interfaces:
    Grid2D

    public class OpenGL2DWindow
    extends java.lang.Object
    implements Grid2D
    Created by rafael on 5/28/17.
    • Constructor Summary

      Constructors 
      Constructor Description
      OpenGL2DWindow​(int xPix, int yPix, int xDim, int yDim)
      the below constructors are variants of the above constructor with default values for some of the arguments
      OpenGL2DWindow​(int xPix, int yPix, int xDim, int yDim, boolean active)  
      OpenGL2DWindow​(java.lang.String title, int xPix, int yPix, int xDim, int yDim)  
      OpenGL2DWindow​(java.lang.String title, int xPix, int yPix, int xDim, int yDim, boolean active)
      creates a new OpenGL2DWindow
    • Method Summary

      Modifier and Type Method Description
      void Circle​(double x, double y, double rad, int color)
      draws a circle centered around x,y, subsequent circles will be drawn over top
      void Circle​(double x, double y, double rad, ColorIntGenerator ColorGen)
      draws a circle centered around x,y, subsequent circles will be drawn over top, the ColorGen function is used to generate the color of the circle and will not be called if the Gui is not active
      void Clear​(int clearColor)
      usually called before any other draw commands, sets the screen to a color.
      void Close()
      closes the gui
      void FanShape​(float centerX, float centerY, float scale, float[] points, int color)
      draws a fan shape around the center x and y, using the array of points to define the edges of the fan.
      void FanShape​(float centerX, float centerY, float scale, float[] points, ColorIntGenerator ColorGen)
      draws a fan shape around the center x and y, using the array of points to define the edges of the fan.
      boolean IsActive()
      returns whether the Gui is active (whether it exists)
      boolean IsClosed()
      returns true if the close button has been clicked in the Gui
      boolean IsWrapX()  
      boolean IsWrapY()  
      int Length()  
      void Line​(double x1, double y1, double x2, double y2, int color)
      draws a line between (x1,y1) and (x2,y2)
      void LineStrip​(double[] xs, double[] ys, int color)
      draws a series of lines between all x,y pairs
      void LineStrip​(double[] coords, int color)
      draws a series of lines between all x,y pairs, coords should store pairs as x,y,x,y...
      void Rectangle​(double x1, double y1, double x2, double y2, int color)
      draws a rectangle between (x1,y1) and (x2,y2) coded by Jill Gallaher
      void RectangleAtPoint​(double x, double y, double width, double height, int color)
      draws a rectangle centered at position x,y
      void SetPix​(int i, int color)
      duplicates UIGrid functionality, draws a rectangle large enough to fill one lattice position
      void SetPix​(int x, int y, int color)
      duplicates UIGrid functionality, draws a rectangle large enough to fill one lattice position
      void Square​(double x, double y, double rad, int color)  
      void TickPause​(int millis)
      call this once per step of your model, and the function will ensure that your model runs at the rate provided in millis.
      void ToGIF​(java.lang.String path)
      saves the current state image to a GIF image, call Update first
      void ToJPG​(java.lang.String path)
      saves the current state image to a JPG, call Update first
      void ToPNG​(java.lang.String path)
      saves the current state image to a PNG, call Update first
      void Update()
      renders all draw commands to the window
      int Xdim()  
      int Ydim()  
      • Methods inherited from class java.lang.Object

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

      • xPix

        public final int xPix
      • yPix

        public final int yPix
      • xDim

        public final int xDim
      • yDim

        public final int yDim
      • length

        public final int length
      • wrapX

        public boolean wrapX
      • wrapY

        public boolean wrapY
    • Constructor Detail

      • OpenGL2DWindow

        public OpenGL2DWindow​(java.lang.String title,
                              int xPix,
                              int yPix,
                              int xDim,
                              int yDim,
                              boolean active)
        creates a new OpenGL2DWindow
        Parameters:
        title - the title that will appear at the top of the window (default "")
        xPix - the length of the window in screen pixels
        yPix - the height of the window in screen pixels
        xDim - the length that the window will represent for drawing, should match the xDim of the model
        yDim - the height that the window will represent for drawing, should match the yDim of the model
        active - if set to false, the OpenGL2DWindow will not actually render and its methods will be skipped (default true)
      • OpenGL2DWindow

        public OpenGL2DWindow​(int xPix,
                              int yPix,
                              int xDim,
                              int yDim)
        the below constructors are variants of the above constructor with default values for some of the arguments
      • OpenGL2DWindow

        public OpenGL2DWindow​(int xPix,
                              int yPix,
                              int xDim,
                              int yDim,
                              boolean active)
      • OpenGL2DWindow

        public OpenGL2DWindow​(java.lang.String title,
                              int xPix,
                              int yPix,
                              int xDim,
                              int yDim)
    • Method Detail

      • TickPause

        public void TickPause​(int millis)
        call this once per step of your model, and the function will ensure that your model runs at the rate provided in millis. the function will take the amount time between calls into account to ensure a consistent tick rate.
      • Clear

        public void Clear​(int clearColor)
        usually called before any other draw commands, sets the screen to a color.
      • Update

        public void Update()
        renders all draw commands to the window
      • IsClosed

        public boolean IsClosed()
        returns true if the close button has been clicked in the Gui
      • Close

        public void Close()
        closes the gui
      • IsActive

        public boolean IsActive()
        returns whether the Gui is active (whether it exists)
      • SetPix

        public void SetPix​(int i,
                           int color)
        duplicates UIGrid functionality, draws a rectangle large enough to fill one lattice position
      • SetPix

        public void SetPix​(int x,
                           int y,
                           int color)
        duplicates UIGrid functionality, draws a rectangle large enough to fill one lattice position
      • Rectangle

        public void Rectangle​(double x1,
                              double y1,
                              double x2,
                              double y2,
                              int color)
        draws a rectangle between (x1,y1) and (x2,y2) coded by Jill Gallaher
      • RectangleAtPoint

        public void RectangleAtPoint​(double x,
                                     double y,
                                     double width,
                                     double height,
                                     int color)
        draws a rectangle centered at position x,y
      • Square

        public void Square​(double x,
                           double y,
                           double rad,
                           int color)
      • Circle

        public void Circle​(double x,
                           double y,
                           double rad,
                           int color)
        draws a circle centered around x,y, subsequent circles will be drawn over top
      • Circle

        public void Circle​(double x,
                           double y,
                           double rad,
                           ColorIntGenerator ColorGen)
        draws a circle centered around x,y, subsequent circles will be drawn over top, the ColorGen function is used to generate the color of the circle and will not be called if the Gui is not active
      • FanShape

        public void FanShape​(float centerX,
                             float centerY,
                             float scale,
                             float[] points,
                             ColorIntGenerator ColorGen)
        draws a fan shape around the center x and y, using the array of points to define the edges of the fan. used as part of the circle function
      • FanShape

        public void FanShape​(float centerX,
                             float centerY,
                             float scale,
                             float[] points,
                             int color)
        draws a fan shape around the center x and y, using the array of points to define the edges of the fan. used as part of the circle function
      • Line

        public void Line​(double x1,
                         double y1,
                         double x2,
                         double y2,
                         int color)
        draws a line between (x1,y1) and (x2,y2)
      • LineStrip

        public void LineStrip​(double[] xs,
                              double[] ys,
                              int color)
        draws a series of lines between all x,y pairs
      • LineStrip

        public void LineStrip​(double[] coords,
                              int color)
        draws a series of lines between all x,y pairs, coords should store pairs as x,y,x,y...
      • ToPNG

        public void ToPNG​(java.lang.String path)
        saves the current state image to a PNG, call Update first
      • ToJPG

        public void ToJPG​(java.lang.String path)
        saves the current state image to a JPG, call Update first
      • ToGIF

        public void ToGIF​(java.lang.String path)
        saves the current state image to a GIF image, call Update first
      • Xdim

        public int Xdim()
        Specified by:
        Xdim in interface Grid2D
      • Ydim

        public int Ydim()
        Specified by:
        Ydim in interface Grid2D
      • Length

        public int Length()
        Specified by:
        Length in interface Grid2D
      • IsWrapX

        public boolean IsWrapX()
        Specified by:
        IsWrapX in interface Grid2D
      • IsWrapY

        public boolean IsWrapY()
        Specified by:
        IsWrapY in interface Grid2D