diff --git a/java/src/processing/mode/java/pdex/CompilationChecker.java b/java/src/processing/mode/java/pdex/CompilationChecker.java index fcdae6e71..7c97dfa31 100644 --- a/java/src/processing/mode/java/pdex/CompilationChecker.java +++ b/java/src/processing/mode/java/pdex/CompilationChecker.java @@ -374,7 +374,7 @@ public class CompilationChecker { prob = new IProblem[problems.size()]; int count = 0; for (Iterator it = problems.iterator(); it.hasNext();) { - IProblem problem = (IProblem) it.next(); + IProblem problem = it.next(); prob[count++] = problem; } } diff --git a/java/src/processing/mode/java/pdex/JavadocHelper.java b/java/src/processing/mode/java/pdex/JavadocHelper.java index e55b8b632..b566e4d4d 100644 --- a/java/src/processing/mode/java/pdex/JavadocHelper.java +++ b/java/src/processing/mode/java/pdex/JavadocHelper.java @@ -66,7 +66,7 @@ public class JavadocHelper { String methodName = docFile.getName().substring(0, docFile.getName().indexOf('_')); //System.out.println(methodName); for (Iterator it = elm.iterator(); it.hasNext();) { - Element ele = (Element) it.next(); + Element ele = it.next(); msg = "
" + ele.html() + "
"; //mat.replaceAll(""); diff --git a/java/src/processing/mode/java/tweak/Handle.java b/java/src/processing/mode/java/tweak/Handle.java index 2d5fdae16..d636f6fe7 100644 --- a/java/src/processing/mode/java/tweak/Handle.java +++ b/java/src/processing/mode/java/tweak/Handle.java @@ -26,257 +26,273 @@ import java.math.BigDecimal; import java.util.Comparator; import java.util.Locale; + public class Handle { - public String type; - public String name; - public String strValue; - public String strNewValue; - public int varIndex; - public int startChar; - public int endChar; - public int newStartChar; - public int newEndChar; - public int line; - int tabIndex; - int decimalPlaces; // number of digits after the decimal point - float incValue; + public String type; + public String name; + public String strValue; + public String strNewValue; + public int varIndex; + public int startChar; + public int endChar; + public int newStartChar; + public int newEndChar; + public int line; + int tabIndex; + int decimalPlaces; // number of digits after the decimal point + float incValue; - java.lang.Number value, newValue; - String strDiff; + java.lang.Number value, newValue; + String strDiff; - // connect with color control box - ColorControlBox colorBox; + // connect with color control box + ColorControlBox colorBox; - // interface - int x, y, width, height; - int xCenter, xCurrent, xLast; - HProgressBar progBar = null; - String textFormat; + // interface + int x, y, width, height; + int xCenter, xCurrent, xLast; + HProgressBar progBar = null; + String textFormat; - // the client that sends the changes - UDPTweakClient tweakClient; + // the client that sends the changes + UDPTweakClient tweakClient; - public Handle(String t, String n, int vi, String v, int ti, int l, int sc, - int ec, int dp) { - type = t; - name = n; - varIndex = vi; - strValue = v; - tabIndex = ti; - line = l; - startChar = sc; - endChar = ec; - decimalPlaces = dp; - incValue = (float) (1 / Math.pow(10, decimalPlaces)); + public Handle(String t, String n, int vi, String v, int ti, int l, int sc, + int ec, int dp) { + type = t; + name = n; + varIndex = vi; + strValue = v; + tabIndex = ti; + line = l; + startChar = sc; + endChar = ec; + decimalPlaces = dp; - if (type == "int") { - value = newValue = Integer.parseInt(strValue); - strNewValue = strValue; - textFormat = "%d"; - } else if (type == "hex") { - Long val = Long.parseLong(strValue.substring(2, strValue.length()), - 16); - value = newValue = val.intValue(); - strNewValue = strValue; - textFormat = "0x%x"; - } else if (type == "webcolor") { - Long val = Long.parseLong(strValue.substring(1, strValue.length()), - 16); - val = val | 0xff000000; - value = newValue = val.intValue(); - strNewValue = strValue; - textFormat = "#%06x"; - } else if (type == "float") { - value = newValue = Float.parseFloat(strValue); - strNewValue = strValue; - textFormat = "%.0" + decimalPlaces + "f"; - } + incValue = (float) (1 / Math.pow(10, decimalPlaces)); - newStartChar = startChar; - newEndChar = endChar; - } + if ("int".equals(type)) { + value = newValue = Integer.parseInt(strValue); + strNewValue = strValue; + textFormat = "%d"; - public void initInterface(int x, int y, int width, int height) { - this.x = x; - this.y = y; - this.width = width; - this.height = height; + } else if ("hex".equals(type)) { + Long val = Long.parseLong(strValue.substring(2, strValue.length()), 16); + value = newValue = val.intValue(); + strNewValue = strValue; + textFormat = "0x%x"; - // create drag ball - progBar = new HProgressBar(height, width); - } + } else if ("webcolor".equals(type)) { + Long val = Long.parseLong(strValue.substring(1, strValue.length()), 16); + val = val | 0xff000000; + value = newValue = val.intValue(); + strNewValue = strValue; + textFormat = "#%06x"; - public void setCenterX(int mx) { - xLast = xCurrent = xCenter = mx; - } + } else if ("float".equals(type)) { + value = newValue = Float.parseFloat(strValue); + strNewValue = strValue; + textFormat = "%.0" + decimalPlaces + "f"; + } - public void setCurrentX(int mx) { - xLast = xCurrent; - xCurrent = mx; + newStartChar = startChar; + newEndChar = endChar; + } - progBar.setPos(xCurrent - xCenter); - updateValue(); - } + public void initInterface(int x, int y, int width, int height) { + this.x = x; + this.y = y; + this.width = width; + this.height = height; - public void resetProgress() { - progBar.setPos(0); - } + // create drag ball + progBar = new HProgressBar(height, width); + } - public void updateValue() { - float change = getChange(); - if (type == "int") { - if (newValue.intValue() + (int) change > Integer.MAX_VALUE - || newValue.intValue() + (int) change < Integer.MIN_VALUE) { - change = 0; - return; - } - setValue(newValue.intValue() + (int) change); - } else if (type == "hex") { - setValue(newValue.intValue() + (int) change); - } else if (type == "webcolor") { - setValue(newValue.intValue() + (int) change); - } else if (type == "float") { - setValue(newValue.floatValue() + change); - } + public void setCenterX(int mx) { + xLast = xCurrent = xCenter = mx; + } - updateColorBox(); - } - public void setValue(Number value) { - if (type == "int") { - newValue = value.intValue(); - strNewValue = String.format(Locale.US, textFormat, - newValue.intValue()); - } else if (type == "hex") { - newValue = value.intValue(); - strNewValue = String.format(Locale.US, textFormat, - newValue.intValue()); - } else if (type == "webcolor") { - newValue = value.intValue(); - // keep only RGB - int val = (newValue.intValue() & 0xffffff); - strNewValue = String.format(Locale.US, textFormat, val); - } else if (type == "float") { - BigDecimal bd = new BigDecimal(value.floatValue()); - bd = bd.setScale(decimalPlaces, BigDecimal.ROUND_HALF_UP); - newValue = bd.floatValue(); - strNewValue = String.format(Locale.US, textFormat, - newValue.floatValue()); - } + public void setCurrentX(int mx) { + xLast = xCurrent; + xCurrent = mx; - // send new data to the server in the sketch - sendNewValue(); - } + progBar.setPos(xCurrent - xCenter); - public void updateColorBox() { - if (colorBox != null) { - colorBox.colorChanged(); - } - } + updateValue(); + } - private float getChange() { - int pixels = xCurrent - xLast; - return pixels * incValue; - } - public void setPos(int nx, int ny) { - x = nx; - y = ny; - } + public void resetProgress() { + progBar.setPos(0); + } - public void setWidth(int w) { - width = w; - progBar.setWidth(w); - } + public void updateValue() { + float change = getChange(); - public void draw(Graphics2D g2d, boolean hasFocus) { - AffineTransform prevTrans = g2d.getTransform(); - g2d.translate(x, y); + if ("int".equals(type)) { + if (newValue.intValue() + (int) change > Integer.MAX_VALUE || + newValue.intValue() + (int) change < Integer.MIN_VALUE) { + change = 0; + return; + } + setValue(newValue.intValue() + (int) change); + } else if ("hex".equals(type)) { + setValue(newValue.intValue() + (int) change); + } else if ("webcolor".equals(type)) { + setValue(newValue.intValue() + (int) change); + } else if ("float".equals(type)) { + setValue(newValue.floatValue() + change); + } - // draw underline on the number - g2d.setColor(ColorScheme.getInstance().progressFillColor); - g2d.drawLine(0, 0, width, 0); + updateColorBox(); + } - if (hasFocus) { - if (progBar != null) { - g2d.translate(width / 2, 2); - progBar.draw(g2d); - } - } - g2d.setTransform(prevTrans); - } + public void setValue(Number value) { + if ("int".equals(type)) { + newValue = value.intValue(); + strNewValue = String.format(Locale.US, textFormat, newValue.intValue()); - public boolean pick(int mx, int my) { - return pickText(mx, my); - } + } else if ("hex".equals(type)) { + newValue = value.intValue(); + strNewValue = String.format(Locale.US, textFormat, newValue.intValue()); - public boolean pickText(int mx, int my) { - if (mx > x - 2 && mx < x + width + 2 && my > y - height && my < y) { - return true; - } + } else if ("webcolor".equals(type)) { + newValue = value.intValue(); + // keep only RGB + int val = (newValue.intValue() & 0xffffff); + strNewValue = String.format(Locale.US, textFormat, val); - return false; - } + } else if ("float".equals(type)) { + BigDecimal bd = new BigDecimal(value.floatValue()); + bd = bd.setScale(decimalPlaces, BigDecimal.ROUND_HALF_UP); + newValue = bd.floatValue(); + strNewValue = String.format(Locale.US, textFormat, newValue.floatValue()); + } - public boolean valueChanged() { - if (type == "int") { - return (value.intValue() != newValue.intValue()); - } else if (type == "hex") { - return (value.intValue() != newValue.intValue()); - } else if (type == "webcolor") { - return (value.intValue() != newValue.intValue()); - } else { - return (value.floatValue() != newValue.floatValue()); - } - } + // send new data to the server in the sketch + sendNewValue(); + } - public void setColorBox(ColorControlBox box) { - colorBox = box; - } - public void setTweakClient(UDPTweakClient client) { - tweakClient = client; - } + public void updateColorBox() { + if (colorBox != null) { + colorBox.colorChanged(); + } + } - public void sendNewValue() { - int index = varIndex; - try { - if (type == "int") { - tweakClient.sendInt(index, newValue.intValue()); - } else if (type == "hex") { - tweakClient.sendInt(index, newValue.intValue()); - } else if (type == "webcolor") { - tweakClient.sendInt(index, newValue.intValue()); - } else if (type == "float") { - tweakClient.sendFloat(index, newValue.floatValue()); - } - } catch (Exception e) { - System.out.println("error sending new value!"); - } - } - public String toString() { - return type + " " + name + " = " + strValue + " (tab: " + tabIndex - + ", line: " + line + ", start: " + startChar + ", end: " - + endChar + ")"; - } + private float getChange() { + int pixels = xCurrent - xLast; + return pixels * incValue; + } + + + public void setPos(int nx, int ny) { + x = nx; + y = ny; + } + + + public void setWidth(int w) { + width = w; + progBar.setWidth(w); + } + + + public void draw(Graphics2D g2d, boolean hasFocus) { + AffineTransform prevTrans = g2d.getTransform(); + g2d.translate(x, y); + + // draw underline on the number + g2d.setColor(ColorScheme.getInstance().progressFillColor); + g2d.drawLine(0, 0, width, 0); + + if (hasFocus) { + if (progBar != null) { + g2d.translate(width / 2, 2); + progBar.draw(g2d); + } + } + + g2d.setTransform(prevTrans); + } + + + public boolean pick(int mx, int my) { + return pickText(mx, my); + } + + + public boolean pickText(int mx, int my) { + return (mx > x - 2 && mx < x + width + 2 && my > y - height && my < y); + } + + + public boolean valueChanged() { + if ("int".equals(type)) { + return (value.intValue() != newValue.intValue()); + } else if ("hex".equals(type)) { + return (value.intValue() != newValue.intValue()); + } else if ("webcolor".equals(type)) { + return (value.intValue() != newValue.intValue()); + } else { + return (value.floatValue() != newValue.floatValue()); + } + } + + + public void setColorBox(ColorControlBox box) { + colorBox = box; + } + + + public void setTweakClient(UDPTweakClient client) { + tweakClient = client; + } + + + public void sendNewValue() { + int index = varIndex; + try { + if ("int".equals(type)) { + tweakClient.sendInt(index, newValue.intValue()); + } else if ("hex".equals(type)) { + tweakClient.sendInt(index, newValue.intValue()); + } else if ("webcolor".equals(type)) { + tweakClient.sendInt(index, newValue.intValue()); + } else if ("float".equals(type)) { + tweakClient.sendFloat(index, newValue.floatValue()); + } + } catch (Exception e) { + System.out.println("error sending new value!"); + } + } + + + public String toString() { + return type + " " + name + " = " + strValue + " (tab: " + tabIndex + + ", line: " + line + ", start: " + startChar + ", end: " + + endChar + ")"; + } } + /* * Used for sorting the handles by order of occurrence inside each tab */ class HandleComparator implements Comparator { - public int compare(Handle handle1, Handle handle2) { - int tab = handle1.tabIndex - handle2.tabIndex; - if (tab == 0) { - return handle1.startChar - handle2.startChar; - } else { - return tab; - } - } + public int compare(Handle handle1, Handle handle2) { + int tab = handle1.tabIndex - handle2.tabIndex; + if (tab != 0) { + return tab; + } + return handle1.startChar - handle2.startChar; + } } diff --git a/todo.txt b/todo.txt index 89352589a..70cb02da8 100644 --- a/todo.txt +++ b/todo.txt @@ -14,10 +14,13 @@ X Menu mnemonics (alt-f, etc) getting typed into the editor X https://github.com/processing/processing/issues/3057 X Opening and closing preferences window prompts user to save unmodified sketch X https://github.com/processing/processing/issues/3074 +X Pressing PgDn in a code without scrollbar gives Exception +X https://github.com/processing/processing/issues/2990 _ implement line numbers in the editor _ 5px between line number (right-aligned) and the right edge of the gutter _ ie textAlign(RIGHT) / text(lineNum, LEFT_GUTTER - 5, y) +_ https://github.com/processing/processing/issues/3128 _ run button w/ debugger shouldn't require "continue" before actually starting _ https://github.com/processing/processing/issues/3096 @@ -87,6 +90,8 @@ X https://github.com/processing/processing/pull/3069 X Java 8 method replace() used, removed X https://github.com/processing/processing/issues/3168 X https://github.com/processing/processing/pull/3169 +X Closing a few unclosed BufferedReaders and InputStreams +X https://github.com/processing/processing/pull/2961 manindra X Fix for "Probably a ++ should go here" messages