Class Terminal
- java.lang.Object
-
- Core.Terminal
-
public class Terminal extends java.lang.ObjectBuilds 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 pixelsTerminal(int height, int width)Declares the Terminal Defines the size of the TerminalTerminal(java.lang.String title)Declares the terminal And sets the titleTerminal(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 voidaddKeyListener(java.awt.event.KeyListener listener)AddsKeyListenerto the Terminalvoidclear()Clears the terminal by setting the text to nothingchar[][]getCharMatrix()Gets the char matrix if setjava.awt.FontgetFont()Gives the set fontjavax.swing.JFramegetFrame()Gets the window builder of the Terminal class on which the terminal is createdint[][]getIntMatrix()Gets the int matrix if setTerminalScheduleUpdategetSchedule()Returns the set schedulejava.lang.String[][]getStringMatrix()Gets the string matrix if setbooleanisFullscreen()Checks is the Terminal window fullscreenbooleanisResizeable()Checks to see if the window is resizablevoidprint(java.lang.String text)OutputsStringto the terminalvoidprint(java.lang.String text, int r, int g, int b)OutputsStringto the terminal withColorby selecting the rgb valuesvoidprint(java.lang.String text, java.awt.Color color)OutputsStringto the terminal withColorvoidprintln()OutputsStringto the terminal and makes a new linevoidprintln(java.lang.String text)OutputsStringto the terminal and makes a new linevoidprintln(java.lang.String text, int r, int g, int b)OutputsStringto the terminal and makes a new line withColorby selecting the rgb valuesvoidprintln(java.lang.String text, java.awt.Color color)OutputsStringto the terminal and makes a new line withColorvoidprintMatrix()Prints the set matrix With some limitationsvoidprintMatrix(char[][] matrix)Prints a char matrix in the TerminalvoidprintMatrix(char[][] matrix, boolean clean)Clears the terminal and prints a char matrixvoidprintMatrix(int[][] matrix)Prints an int matrix in the TerminalvoidprintMatrix(int[][] matrix, boolean clean)Clears the terminal and prints an int matrixvoidprintMatrix(java.lang.String[][] matrix)Prints a String matrix in the TerminalvoidprintMatrix(java.lang.String[][] matrix, boolean clean)Clears the terminal and prints a String matrixjava.lang.StringreadLine()Reads the last line in the Terminal Limitations:voidremoveKeyListener(java.awt.event.KeyListener listener)Removes givenKeyListenervoidrun()Builds the terminal by executing all the specifications for thevoidsetBackgroundColor(int r, int g, int b)voidsetBackgroundColor(java.awt.Color backgroundColor)Sets theColorof the terminal backgroundvoidsetDelay(int delay)Sets the delay between executions in the schedule (in milliseconds)voidsetEditable(boolean editable)Sets whether you can type in the consolevoidsetFont(java.awt.Font font)Sets the font to a new onevoidsetFont(java.lang.String name)Sets the font to a new onevoidsetFont(java.lang.String name, int style)Sets the font to a new onevoidsetFont(java.lang.String name, int style, int size)Sets the font to a new onevoidsetFontColor(int r, int g, int b)Sets the font color to a new onevoidsetFontColor(java.awt.Color fontColor)Sets theColorof the terminal fontvoidsetFontSize(int fontSize)Changes the size of the fontvoidsetFullscreen(boolean fullscreen)Makes the Terminal window fullscreenvoidsetInitialDelay(int initialDelay)Sets the initial delay for the schedule (in milliseconds)voidsetMatrix(char[][] charMatrix)Sets matrix that can be printedvoidsetMatrix(int[][] intMatrix)Sets matrix that can be printedvoidsetMatrix(java.lang.String[][] stringMatrix)Sets matrix that can be printedvoidsetResizeable(boolean resizeable)Sets whether the Terminal window is resizable by the user On default is: truevoidsetSchedule(TerminalScheduleUpdate scheduleUpdate)Sets the periodic execution(schedule) for the terminalvoidsetText(java.lang.String text)Sets or overrides all the text shown in the terminalvoidstart()Starts the update schedulevoidstop()Closes the terminalvoidstopUpdate()Stops the schedule from running
-
-
-
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 pixelswidth- 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- Titleheight- The height in pixelswidth- 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 terminalThis 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 newTerminalScheduleUpdate
-
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 scheduleThis 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)
AddsKeyListenerto the TerminalYou have to build your KeyListener before you add it
- Parameters:
listener- addsKeyListener- See Also:
KeyListener
-
removeKeyListener
public void removeKeyListener(java.awt.event.KeyListener listener)
Removes givenKeyListener- 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- matrixclean- cleans the terminal
-
printMatrix
public void printMatrix(int[][] matrix, boolean clean)Clears the terminal and prints an int matrix- Parameters:
matrix- matrixclean- cleans the terminal
-
printMatrix
public void printMatrix(java.lang.String[][] matrix, boolean clean)Clears the terminal and prints a String matrix- Parameters:
matrix- matrixclean- 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)OutputsStringto the terminal withColorby selecting the rgb values- Parameters:
text- output textr- redg- greenb- blue
-
print
public void print(java.lang.String text, java.awt.Color color)OutputsStringto the terminal withColor- Parameters:
text- output textcolor- color
-
print
public void print(java.lang.String text)
OutputsStringto the terminal- Parameters:
text- output text
-
println
public void println()
OutputsStringto the terminal and makes a new line
-
println
public void println(java.lang.String text)
OutputsStringto 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)OutputsStringto the terminal and makes a new line withColorby selecting the rgb values- Parameters:
text- output textr- redg- greenb- blue
-
println
public void println(java.lang.String text, java.awt.Color color)OutputsStringto the terminal and makes a new line withColor- Parameters:
text- output textcolor- 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 theColorof the terminal background- Parameters:
backgroundColor- set the backgroundColor
-
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 theColorof the terminal font- Parameters:
fontColor- sets the fontColor
-
setFontColor
public void setFontColor(int r, int g, int b)Sets the font color to a new onethis can be done by selecting the rgb values of the color you want
- Parameters:
r- redg- greenb- blue
-
setFont
public void setFont(java.awt.Font font)
Sets the font to a new oneThis is done by making a new
Fontobject- Parameters:
font- setsFont
-
setFont
public void setFont(java.lang.String name, int style, int size)Sets the font to a new oneSets 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 fontstyle- the style of the fontsize- the font size
-
setFont
public void setFont(java.lang.String name, int style)Sets the font to a new oneSets 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 fontstyle- the style of the font
-
setFont
public void setFont(java.lang.String name)
Sets the font to a new oneSets 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
-
-