From 74636289e5d80370fb54d367881d79e3351e7ed1 Mon Sep 17 00:00:00 2001 From: Sandy Noble Date: Sat, 2 Jan 2016 22:00:12 +0000 Subject: [PATCH] Got the console working again. --- controlsSetup.pde | 14 +++++++++++++ polargraphcontroller.pde | 45 ++++++++++++++++++++++------------------ 2 files changed, 39 insertions(+), 20 deletions(-) diff --git a/controlsSetup.pde b/controlsSetup.pde index f55adc3..d59d62a 100644 --- a/controlsSetup.pde +++ b/controlsSetup.pde @@ -183,6 +183,18 @@ void updateNumberboxValues() initialiseNumberboxValues(getAllControls()); } +void initConsoleWindow() { + consoleArea = cp5.addTextarea("txt") + .setPosition(300, 100) + .setSize(400, 600) + .setFont(createFont("", 12)) + .setLineHeight(14) + .setColor(color(255)) + .setColorBackground(color(0, 200)) + .setColorForeground(color(255, 100)) + .setVisible(false); +} + Set buildControlsToLockIfBoxNotSpecified() { Set result = new HashSet(); @@ -220,6 +232,8 @@ Set buildControlsToLockIfImageNotLoaded() Map buildAllControls() { + + initConsoleWindow(); Map map = new HashMap(); diff --git a/polargraphcontroller.pde b/polargraphcontroller.pde index 6d799eb..5de4188 100644 --- a/polargraphcontroller.pde +++ b/polargraphcontroller.pde @@ -422,6 +422,9 @@ public Integer windowHeight = 400; public static Integer serialPortNumber = -1; +public Textarea consoleArea = null; +public Println console = null; +public PrintStream savedOut = null; Properties props = null; public static String propertiesFilename = "default.properties.txt"; @@ -485,9 +488,6 @@ public static final int VECTOR_FILTER_LOW_PASS = 0; String storeFilename = "comm.txt"; boolean overwriteExistingStoreFile = true; -//private static Logger logger; -public static Console console; -public boolean useWindowedConsole = false; static boolean drawingTraceShape = true; static boolean retraceShape = true; @@ -1684,12 +1684,7 @@ void keyPressed() } else if (checkKey(CONTROL) && checkKey(KeyEvent.VK_C)) { - if (isUseWindowedConsole()) - setUseWindowedConsole(false); - else - setUseWindowedConsole(true); - - initLogging(); + toggleShowConsole(); } else if (checkKey(CONTROL) && checkKey(KeyEvent.VK_S)) { @@ -1897,7 +1892,7 @@ void mouseWheel(int delta) void setChromaKey(PVector p) { - color col = getDisplayMachine().getPixelAtScreenCoords(p); + color col = getDisplayMachine().getPixelAtScreenCoords(p); chromaKeyColour = col; if (getDisplayMachine().pixelsCanBeExtracted() && isBoxSpecified()) { @@ -1919,6 +1914,26 @@ boolean isPreviewable(String command) } } +boolean toggleShowConsole() { + if (console == null) { + savedOut = System.out; + console = cp5.addConsole(consoleArea); + consoleArea.setVisible(true); + console.play(); + } + else { + console.pause(); + consoleArea.setVisible(false); + cp5.remove(console); + console = null; + System.setOut(savedOut); + } + + println("Ow"); + + return console == null; +} + /** This will comb the command queue and attempt to draw a picture of what it contains. Coordinates here are in pixels. @@ -3252,16 +3267,6 @@ Integer getBaudRate() return baudRate; } -boolean isUseWindowedConsole() -{ - return this.useWindowedConsole; -} - -void setUseWindowedConsole(boolean use) -{ - this.useWindowedConsole = use; -} - void initLogging() { try