Package HAL.Gui

Class OpenGL3DWindow

  • All Implemented Interfaces:
    Grid3D

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

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

      Modifier and Type Method Description
      void CelSphere​(double x, double y, double z, double rad, int color)
      draws a circle with a white dot and background black border to mark the outline of a cell
      void Circle​(double x, double y, double z, 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 z, 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 color)
      usually called before any other draw commands, sets the screen to a color.
      void ClearBox​(int clearColor, int lineColor)
      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 centerZ, 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 centerZ, float scale, float[] points, int color, float xdisp, float ydisp, float zdisp)
      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()  
      boolean IsWrapZ()  
      int Length()  
      void Line​(double x1, double y1, double z1, double x2, double y2, double z2, int color)
      draws a line between (x1,y1,z1) and (x2,y2,z2)
      void LineStrip​(double[] xs, double[] ys, double[] zs, int color)
      draws a series of lines between all x,y,z triplets
      void LineStrip​(double[] coords, int color)
      draws a series of lines between all x,y,z triplets, coords should store triplets as x,y,z,x,y,z...
      void RectangleXY​(double x1, double y1, double x2, double y2, double z, int color)
      draws a rectangle between (x1,y1,z) and (x2,y2,z)
      void RectangleXZ​(double x1, double z1, double x2, double z2, double y, int color)  
      void RectangleYZ​(double y1, double z1, double y2, double z2, double x, int color)  
      void SetPixXY​(int x, int y, int color)  
      void SetPixXZ​(int x, int z, int color)  
      void SetPixYZ​(int y, int z, 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()  
      int Zdim()  
      • Methods inherited from class java.lang.Object

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

      • xDim

        public final int xDim
      • yDim

        public final int yDim
      • zDim

        public final int zDim
      • length

        public final int length
      • xPix

        public final int xPix
      • yPix

        public final int yPix
    • Constructor Detail

      • OpenGL3DWindow

        public OpenGL3DWindow​(java.lang.String title,
                              int xPix,
                              int yPix,
                              int xDim,
                              int yDim,
                              int zDim,
                              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
        zDim - the depth that the window will represent for drawing, should match the zDim of the model
        active - if set to false, the OpenGL2DWindow will not actually render and its methods will be skipped (default true)
      • OpenGL3DWindow

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

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

        public OpenGL3DWindow​(java.lang.String title,
                              int xPix,
                              int yPix,
                              int xDim,
                              int yDim,
                              int zDim)
    • 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 color)
        usually called before any other draw commands, sets the screen to a color.
      • ClearBox

        public void ClearBox​(int clearColor,
                             int lineColor)
        usually called before any other draw commands, sets the screen to a color. and draws a box around the grid domain
      • 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)
      • CelSphere

        public void CelSphere​(double x,
                              double y,
                              double z,
                              double rad,
                              int color)
        draws a circle with a white dot and background black border to mark the outline of a cell
      • Circle

        public void Circle​(double x,
                           double y,
                           double z,
                           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 z,
                           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 centerZ,
                             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
      • SetPixXY

        public void SetPixXY​(int x,
                             int y,
                             int color)
      • SetPixXZ

        public void SetPixXZ​(int x,
                             int z,
                             int color)
      • SetPixYZ

        public void SetPixYZ​(int y,
                             int z,
                             int color)
      • RectangleXY

        public void RectangleXY​(double x1,
                                double y1,
                                double x2,
                                double y2,
                                double z,
                                int color)
        draws a rectangle between (x1,y1,z) and (x2,y2,z)
      • RectangleXZ

        public void RectangleXZ​(double x1,
                                double z1,
                                double x2,
                                double z2,
                                double y,
                                int color)
      • RectangleYZ

        public void RectangleYZ​(double y1,
                                double z1,
                                double y2,
                                double z2,
                                double x,
                                int color)
      • FanShape

        public void FanShape​(float centerX,
                             float centerY,
                             float centerZ,
                             float scale,
                             float[] points,
                             int color,
                             float xdisp,
                             float ydisp,
                             float zdisp)
        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 z1,
                         double x2,
                         double y2,
                         double z2,
                         int color)
        draws a line between (x1,y1,z1) and (x2,y2,z2)
      • LineStrip

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

        public void LineStrip​(double[] coords,
                              int color)
        draws a series of lines between all x,y,z triplets, coords should store triplets as x,y,z,x,y,z...
      • 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 Grid3D
      • Ydim

        public int Ydim()
        Specified by:
        Ydim in interface Grid3D
      • Zdim

        public int Zdim()
        Specified by:
        Zdim in interface Grid3D
      • Length

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

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

        public boolean IsWrapY()
        Specified by:
        IsWrapY in interface Grid3D
      • IsWrapZ

        public boolean IsWrapZ()
        Specified by:
        IsWrapZ in interface Grid3D