diff options
Diffstat (limited to 'src/jcgp/gui/console')
-rw-r--r-- | src/jcgp/gui/console/GUIConsole.java | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/jcgp/gui/console/GUIConsole.java b/src/jcgp/gui/console/GUIConsole.java index de4b378..b3d037c 100644 --- a/src/jcgp/gui/console/GUIConsole.java +++ b/src/jcgp/gui/console/GUIConsole.java @@ -15,12 +15,25 @@ import javafx.scene.layout.AnchorPane; import jcgp.backend.resources.Console; import jcgp.gui.GUI; +/** + * Console pane used by the GUI to display CGP output messages. + * This class realises {@code Console}. It consists of a JavaFX + * {@code TextArea} and a {@code StringBuffer}. The buffer is filled + * as print messages are queued. Calling {@code flush()} writes the + * contents of the buffer to the {@code TextArea} and empties the buffer. + * + * @see Console + * @author Eduardo Pedroni + * + */ public class GUIConsole extends AnchorPane implements Console { private TextArea textArea = new TextArea("Welcome to JCGP!\n"); - private StringBuffer printBuffer = new StringBuffer(); + /** + * Creates a new instance of this class. + */ public GUIConsole() { super(); textArea.setEditable(false); @@ -31,7 +44,10 @@ public class GUIConsole extends AnchorPane implements Console { * This has not been fixed as of 8/4/2014. * * The following code modifies the EventDispatcher to consume the right mouse - * button click, preventing the default menu from appearing. + * button click, preventing the default menu from appearing. It propagates the mouse + * click further so other elements will respond appropriately. + * + * TODO this should be refactored once the API is updated. */ final EventDispatcher initial = textArea.getEventDispatcher(); textArea.setEventDispatcher(new EventDispatcher() { @@ -76,6 +92,7 @@ public class GUIConsole extends AnchorPane implements Console { new SeparatorMenuItem(), clearConsole)); + // anchor the text area so it resizes automatically AnchorPane.setTopAnchor(textArea, GUI.RESIZE_MARGIN); AnchorPane.setBottomAnchor(textArea, 0.0); AnchorPane.setRightAnchor(textArea, 0.0); |