-
Notifications
You must be signed in to change notification settings - Fork 0
Console & ConsoleObserver
These classes were implemented to make it easier to print informations to the console. Also, they enable you to not print the text to the console, but to save them and notify "ConsoleObserver"-Objects with the new text, if something gets printed to the console, so that you could for example set up a textarea in a gui to be your console.
The Console-Class has a few simple static methods. They will be explained here:
-
private static int indentionLevelis the level of indention used when callingprintlnIndented([...]). -
private static printingToConsoledetermines, whether the print methods are outputting the text to the actual console viaSystem.out.print(). -
private static String consoleTextis where all lines printed will be stored in. -
private static ArrayList<ConsoleObservers> observersis a list of objects implementing the classConsoleObserver(see below), which will be notified, if something gets printed.
This method simply adds the String given by object.toString() to the console text (and, if printingToConsole is true, to the actual console) (this will from here on be reffered to as 'printing') without generating a new line or indenting.
This method simply prints the String given by object.toString() after a generated new line (via '\n').
This method simply prints the String given by object.toString() after a generated new line (via '\n') and tab-indentions specified by the attribute indentionLevel.
This method simply prints the String given by object.toString() after a generated new line (via '\n') and tab-indentions specified by the parameter indentionLevel.
This method increases the attribute indentionLevel by 1.
This method decreases the attribute indentionLevel by 1.
Adds the ConsoleObserver observer to the list of Console observers getting notified, if something gets printed.
Removes the ConsoleObserver observer from the list of Console observers getting notified, if something gets printed.
The ConsoleObserver-Interface allows objects to receive notifications, when the console updates.
This method gets called everytime something gets printed to the console, if the object implementing the interface is added to the console's static observer-list.
Practical examples, tips and tricks will follow soon.