Package Core

Class Terminal


  • public class Terminal
    extends java.lang.Object
    Builds an external terminal that is more intuitive and customizable than the normal IDE terminal
    Version:
    1.0.3-beta
    Author:
    TMG8047KG
    • Constructor Summary

      Constructors 
      Constructor Description
      Terminal()
      Declares the terminal Default size 450x650 pixels
      Terminal​(int height, int width)
      Declares the Terminal Defines the size of the Terminal
      Terminal​(java.lang.String title)
      Declares the terminal And sets the title
      Terminal​(java.lang.String title, int height, int width)
      Declares the terminal Defines the size and the name of the Terminal
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addKeyListener​(java.awt.event.KeyListener listener)
      Adds KeyListener to the Terminal
      void clear()
      Clears the terminal by setting the text to nothing
      char[][] getCharMatrix()
      Gets the char matrix if set
      java.awt.Font getFont()
      Gives the set font
      javax.swing.JFrame getFrame()
      Gets the window builder of the Terminal class on which the terminal is created
      int[][] getIntMatrix()
      Gets the int matrix if set
      TerminalScheduleUpdate getSchedule()
      Returns the set schedule
      java.lang.String[][] getStringMatrix()
      Gets the string matrix if set
      boolean isFullscreen()
      Checks is the Terminal window fullscreen
      boolean isResizeable()
      Checks to see if the window is resizable
      void print​(java.lang.String text)
      Outputs String to the terminal
      void print​(java.lang.String text, int r, int g, int b)
      Outputs String to the terminal with Color by selecting the rgb values
      void print​(java.lang.String text, java.awt.Color color)
      Outputs String to the terminal with Color
      void println()
      Outputs String to the terminal and makes a new line
      void println​(java.lang.String text)
      Outputs String to the terminal and makes a new line
      void println​(java.lang.String text, int r, int g, int b)
      Outputs String to the terminal and makes a new line with Color by selecting the rgb values
      void println​(java.lang.String text, java.awt.Color color)
      Outputs String to the terminal and makes a new line with Color
      void printMatrix()
      Prints the set matrix With some limitations
      void printMatrix​(char[][] matrix)
      Prints a char matrix in the Terminal
      void printMatrix​(char[][] matrix, boolean clean)
      Clears the terminal and prints a char matrix
      void printMatrix​(int[][] matrix)
      Prints an int matrix in the Terminal
      void printMatrix​(int[][] matrix, boolean clean)
      Clears the terminal and prints an int matrix
      void printMatrix​(java.lang.String[][] matrix)
      Prints a String matrix in the Terminal
      void printMatrix​(java.lang.String[][] matrix, boolean clean)
      Clears the terminal and prints a String matrix
      java.lang.String readLine()
      Reads the last line in the Terminal Limitations:
      void removeKeyListener​(java.awt.event.KeyListener listener)
      Removes given KeyListener
      void run()
      Builds the terminal by executing all the specifications for the
      void setBackgroundColor​(int r, int g, int b)  
      void setBackgroundColor​(java.awt.Color backgroundColor)
      Sets the Color of the terminal background
      void setDelay​(int delay)
      Sets the delay between executions in the schedule (in milliseconds)
      void setEditable​(boolean editable)
      Sets whether you can type in the console
      void setFont​(java.awt.Font font)
      Sets the font to a new one
      void setFont​(java.lang.String name)
      Sets the font to a new one
      void setFont​(java.lang.String name, int style)
      Sets the font to a new one
      void setFont​(java.lang.String name, int style, int size)
      Sets the font to a new one
      void setFontColor​(int r, int g, int b)
      Sets the font color to a new one
      void setFontColor​(java.awt.Color fontColor)
      Sets the Color of the terminal font
      void setFontSize​(int fontSize)
      Changes the size of the font
      void setFullscreen​(boolean fullscreen)
      Makes the Terminal window fullscreen
      void setInitialDelay​(int initialDelay)
      Sets the initial delay for the schedule (in milliseconds)
      void setMatrix​(char[][] charMatrix)
      Sets matrix that can be printed
      void setMatrix​(int[][] intMatrix)
      Sets matrix that can be printed
      void setMatrix​(java.lang.String[][] stringMatrix)
      Sets matrix that can be printed
      void setResizeable​(boolean resizeable)
      Sets whether the Terminal window is resizable by the user On default is: true
      void setSchedule​(TerminalScheduleUpdate scheduleUpdate)
      Sets the periodic execution(schedule) for the terminal
      void setText​(java.lang.String text)
      Sets or overrides all the text shown in the terminal
      void start()
      Starts the update schedule
      void stop()
      Closes the terminal
      void stopUpdate()
      Stops the schedule from running
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Terminal

        public Terminal()
        Declares the terminal Default size 450x650 pixels
      • Terminal

        public Terminal​(java.lang.String title)
        Declares the terminal And sets the title
        Parameters:
        title - Title
      • Terminal

        public Terminal​(int height,
                        int width)
        Declares the Terminal Defines the size of the Terminal
        Parameters:
        height - The height in pixels
        width - The width in pixels
      • Terminal

        public Terminal​(java.lang.String title,
                        int height,
                        int width)
        Declares the terminal Defines the size and the name of the Terminal
        Parameters:
        title - Title
        height - The height in pixels
        width - The width in pixels
    • Method Detail

      • getFrame

        public javax.swing.JFrame getFrame()
        Gets the window builder of the Terminal class on which the terminal is created
        Returns:
        Returns the Terminal window builder
      • getSchedule

        public TerminalScheduleUpdate getSchedule()
        Returns the set schedule
        Returns:
        Returns schedule
      • setSchedule

        public void setSchedule​(TerminalScheduleUpdate scheduleUpdate)
        Sets the periodic execution(schedule) for the terminal

        This method executes by default 2 times in a second you can change the value of the delay to change how many times in a second to execute

        Documentation on how use watch the GitHub
        Parameters:
        scheduleUpdate - adds new TerminalScheduleUpdate
      • setDelay

        public void setDelay​(int delay)
        Sets the delay between executions in the schedule (in milliseconds)
        Parameters:
        delay - delay in milliseconds
      • setInitialDelay

        public void setInitialDelay​(int initialDelay)
        Sets the initial delay for the schedule (in milliseconds)
        Parameters:
        initialDelay - delay in milliseconds
      • start

        public void start()
        Starts the update schedule

        This starts a loop that constantly executes the update method from TerminalScheduleUpdate

      • stopUpdate

        public void stopUpdate()
        Stops the schedule from running
      • addKeyListener

        public void addKeyListener​(java.awt.event.KeyListener listener)
        Adds KeyListener to the Terminal

        You have to build your KeyListener before you add it

        Parameters:
        listener - adds KeyListener
        See Also:
        KeyListener
      • removeKeyListener

        public void removeKeyListener​(java.awt.event.KeyListener listener)
        Removes given KeyListener
        Parameters:
        listener - Removes listener
      • setEditable

        public void setEditable​(boolean editable)
        Sets whether you can type in the console
        Parameters:
        editable - Enables/Disables editing
      • setMatrix

        public void setMatrix​(int[][] intMatrix)
        Sets matrix that can be printed
        Parameters:
        intMatrix - set matrix
        See Also:
        printMatrix()
      • setMatrix

        public void setMatrix​(char[][] charMatrix)
        Sets matrix that can be printed
        Parameters:
        charMatrix - set matrix
        See Also:
        printMatrix()
      • setMatrix

        public void setMatrix​(java.lang.String[][] stringMatrix)
        Sets matrix that can be printed
        Parameters:
        stringMatrix - set matrix
        See Also:
        printMatrix()
      • printMatrix

        public void printMatrix​(char[][] matrix,
                                boolean clean)
        Clears the terminal and prints a char matrix
        Parameters:
        matrix - matrix
        clean - cleans the terminal
      • printMatrix

        public void printMatrix​(int[][] matrix,
                                boolean clean)
        Clears the terminal and prints an int matrix
        Parameters:
        matrix - matrix
        clean - cleans the terminal
      • printMatrix

        public void printMatrix​(java.lang.String[][] matrix,
                                boolean clean)
        Clears the terminal and prints a String matrix
        Parameters:
        matrix - matrix
        clean - cleans the terminal
      • printMatrix

        public void printMatrix​(char[][] matrix)
        Prints a char matrix in the Terminal
        Parameters:
        matrix - matrix
      • printMatrix

        public void printMatrix​(int[][] matrix)
        Prints an int matrix in the Terminal
        Parameters:
        matrix - matrix
      • printMatrix

        public void printMatrix​(java.lang.String[][] matrix)
        Prints a String matrix in the Terminal
        Parameters:
        matrix - matrix
      • printMatrix

        public void printMatrix()
        Prints the set matrix With some limitations
      • getIntMatrix

        public int[][] getIntMatrix()
        Gets the int matrix if set
        Returns:
        int matrix
      • getCharMatrix

        public char[][] getCharMatrix()
        Gets the char matrix if set
        Returns:
        char matrix
      • getStringMatrix

        public java.lang.String[][] getStringMatrix()
        Gets the string matrix if set
        Returns:
        string matrix
      • stop

        public void stop()
        Closes the terminal
      • setText

        public void setText​(java.lang.String text)
        Sets or overrides all the text shown in the terminal
        Parameters:
        text - sets text
      • print

        public void print​(java.lang.String text,
                          int r,
                          int g,
                          int b)
        Outputs String to the terminal with Color by selecting the rgb values
        Parameters:
        text - output text
        r - red
        g - green
        b - blue
      • print

        public void print​(java.lang.String text,
                          java.awt.Color color)
        Outputs String to the terminal with Color
        Parameters:
        text - output text
        color - color
      • print

        public void print​(java.lang.String text)
        Outputs String to the terminal
        Parameters:
        text - output text
      • println

        public void println()
        Outputs String to the terminal and makes a new line
      • println

        public void println​(java.lang.String text)
        Outputs String to the terminal and makes a new line
        Parameters:
        text - output text
      • println

        public void println​(java.lang.String text,
                            int r,
                            int g,
                            int b)
        Outputs String to the terminal and makes a new line with Color by selecting the rgb values
        Parameters:
        text - output text
        r - red
        g - green
        b - blue
      • println

        public void println​(java.lang.String text,
                            java.awt.Color color)
        Outputs String to the terminal and makes a new line with Color
        Parameters:
        text - output text
        color - color
      • clear

        public void clear()
        Clears the terminal by setting the text to nothing
      • readLine

        public java.lang.String readLine()
        Reads the last line in the Terminal Limitations:

        Pasting text with more than one line is not going to read the lines on top Always reads the last line even if nothing is typed Stops the execution for the most of the things

        Returns:
        Last line in the Terminal
      • setBackgroundColor

        public void setBackgroundColor​(java.awt.Color backgroundColor)
        Sets the Color of the terminal background
        Parameters:
        backgroundColor - set the background Color
      • setBackgroundColor

        public void setBackgroundColor​(int r,
                                       int g,
                                       int b)
      • setFontSize

        public void setFontSize​(int fontSize)
        Changes the size of the font
        Parameters:
        fontSize - size
      • setFontColor

        public void setFontColor​(java.awt.Color fontColor)
        Sets the Color of the terminal font
        Parameters:
        fontColor - sets the font Color
      • setFontColor

        public void setFontColor​(int r,
                                 int g,
                                 int b)
        Sets the font color to a new one

        this can be done by selecting the rgb values of the color you want

        Parameters:
        r - red
        g - green
        b - blue
      • setFont

        public void setFont​(java.awt.Font font)
        Sets the font to a new one

        This is done by making a new Font object

        Parameters:
        font - sets Font
      • setFont

        public void setFont​(java.lang.String name,
                            int style,
                            int size)
        Sets the font to a new one

        Sets the font by giving it the name of the font as well as the desired style and size

        The styles can be bold, italics and so on (default = 0)

        Parameters:
        name - the name of the font
        style - the style of the font
        size - the font size
      • setFont

        public void setFont​(java.lang.String name,
                            int style)
        Sets the font to a new one

        Sets the font by giving it the name of the font as well as the desired style

        The styles can be bold, italics and so on (default = 0)

        Parameters:
        name - the name of the font
        style - the style of the font
      • setFont

        public void setFont​(java.lang.String name)
        Sets the font to a new one

        Sets the font by giving it the name of the font

        Parameters:
        name - the name of the font
      • getFont

        public java.awt.Font getFont()
        Gives the set font
        Returns:
        font
      • setResizeable

        public void setResizeable​(boolean resizeable)
        Sets whether the Terminal window is resizable by the user On default is: true
        Parameters:
        resizeable - False to lock resizing
      • isResizeable

        public boolean isResizeable()
        Checks to see if the window is resizable
        Returns:
        True if resizable, else false.
      • setFullscreen

        public void setFullscreen​(boolean fullscreen)
        Makes the Terminal window fullscreen
        Parameters:
        fullscreen - True for fullscreen
      • isFullscreen

        public boolean isFullscreen()
        Checks is the Terminal window fullscreen
        Returns:
        False if not fullscreen
      • run

        public void run()
        Builds the terminal by executing all the specifications for the