diff --git a/java/src/processing/mode/java/debug/VariableInspector.java b/java/src/processing/mode/java/debug/VariableInspector.java index fa92a7c39..619e4d47b 100644 --- a/java/src/processing/mode/java/debug/VariableInspector.java +++ b/java/src/processing/mode/java/debug/VariableInspector.java @@ -2,7 +2,7 @@ /* Part of the Processing project - http://processing.org - Copyright (c) 2012-15 The Processing Foundation + Copyright (c) 2012-22 The Processing Foundation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 @@ -21,7 +21,6 @@ package processing.mode.java.debug; import java.awt.*; -import java.awt.image.BufferedImage; import java.io.File; import java.util.ArrayList; import java.util.Arrays; @@ -39,7 +38,6 @@ import com.sun.jdi.Value; import processing.app.Language; import processing.app.Messages; -import processing.app.Mode; import processing.app.ui.Toolkit; import processing.mode.java.JavaEditor; @@ -169,10 +167,11 @@ public class VariableInspector extends JDialog { /** * Model for a Outline Row (excluding the tree column). Column 0 is "Value". - * Column 1 is "Type". Handles setting and getting values. TODO: Maybe use a - * TableCellRenderer instead of this to also have a different icon based on - * expanded state. See: - * http://kickjava.com/src/org/netbeans/swing/outline/DefaultOutlineCellRenderer.java.htm + * Column 1 is "Type". Handles setting and getting values. + * + * TODO: Maybe use a TableCellRenderer instead of this to also have a + * different icon based on expanded state, for instance: + * http://kickjava.com/src/org/netbeans/swing/outline/DefaultOutlineCellRenderer.java.htm */ protected class VariableRowModel implements RowModel { final String column0 = Language.text("debugger.value"); @@ -301,77 +300,35 @@ public class VariableInspector extends JDialog { static final int ICON_SIZE = 16; // Indices correspond to VariableNode.TYPE_OBJECT...TYPE_SHORT - static final String[] TYPE_NAMES = { + final String[] TYPE_NAMES = { "object", "array", "integer", "float", "boolean", "char", "string", "long", "double", "byte", "short" }; + final int TYPE_COUNT = TYPE_NAMES.length; - Icon[][] icons; + Icon[] enabledIcons; + Icon[] disabledIcons; OutlineRenderer() { - icons = new Icon[][] { - renderIcons("object"), - renderIcons("array"), - renderIcons("integer"), - renderIcons("float"), - renderIcons("boolean"), - renderIcons("char"), - renderIcons("string"), - renderIcons("long"), - renderIcons("double"), - renderIcons("byte"), - renderIcons("short") - }; - } + enabledIcons = new Icon[TYPE_COUNT]; + disabledIcons = new Icon[TYPE_COUNT]; - - private ImageIcon[] renderIcons(String type) { - File file = editor.getMode().getContentFile("theme/variables/" + type + ".svg"); - return new ImageIcon[] { - Toolkit.renderIcon(file, ENABLED_COLOR, ICON_SIZE), - Toolkit.renderIcon(file, DISABLED_COLOR, ICON_SIZE) - }; - } - - - /** - * Load multiple icons (horizontal) with multiple states (vertical) from - * a single file. - * - * @param fileName file path in the mode folder. - * @return a nested array (first index: icon, second index: state) or - * null if the file wasn't found. - */ - private ImageIcon[][] loadIcons(String fileName) { - Mode mode = editor.getMode(); - File file = mode.getContentFile(fileName); - if (!file.exists()) { - Messages.log(getClass().getName(), "icon file not found: " + file.getAbsolutePath()); - return null; + for (int i = 0; i < TYPE_COUNT; i++) { + String type = TYPE_NAMES[i]; + File file = editor.getMode().getContentFile("theme/variables/" + type + ".svg"); + enabledIcons[i] = Toolkit.renderIcon(file, ENABLED_COLOR, ICON_SIZE); + disabledIcons[i] = Toolkit.renderIcon(file, DISABLED_COLOR, ICON_SIZE); } - Image allIcons = mode.loadImage(fileName); - int cols = allIcons.getWidth(null) / ICON_SIZE; - int rows = allIcons.getHeight(null) / ICON_SIZE; - ImageIcon[][] iconImages = new ImageIcon[cols][rows]; - - for (int i = 0; i < cols; i++) { - for (int j = 0; j < rows; j++) { - Image image = new BufferedImage(ICON_SIZE, ICON_SIZE, BufferedImage.TYPE_INT_ARGB); - Graphics g = image.getGraphics(); - g.drawImage(allIcons, -i * ICON_SIZE, -j * ICON_SIZE, null); - iconImages[i][j] = new ImageIcon(image); - } - } - return iconImages; } protected Icon getIcon(int type, boolean enabled) { + Icon[] icons = enabled ? enabledIcons : disabledIcons; if (type < 0 || type > icons.length - 1) { return null; } - return icons[type][enabled ? 0 : 1]; + return icons[type]; } @@ -459,13 +416,12 @@ public class VariableInspector extends JDialog { // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - // TODO: could probably extend the simpler DefaultTableCellRenderer here /** * Renderer for the value column. Uses an italic font for null values and - * Object values ("instance of ..."). Uses a gray color when tree is not - * enabled. + * Object values ("instance of ..."). Uses a gray color when tree disabled. + * TODO: could probably extend the simpler DefaultTableCellRenderer here */ - protected class ValueCellRenderer extends DefaultOutlineCellRenderer { + static protected class ValueCellRenderer extends DefaultOutlineCellRenderer { public ValueCellRenderer() { super(); @@ -502,7 +458,7 @@ public class VariableInspector extends JDialog { * Editor for the value column. Will show an empty string when editing * String values that are null. */ - protected class ValueCellEditor extends DefaultCellEditor { + static protected class ValueCellEditor extends DefaultCellEditor { public ValueCellEditor() { super(new JTextField()); @@ -590,24 +546,6 @@ public class VariableInspector extends JDialog { // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - // removed in 3.0a9, doesn't seem to be used? -// protected static void run(final VariableInspector vi) { -// EventQueue.invokeLater(new Runnable() { -// @Override -// public void run() { -// vi.setVisible(true); -// } -// }); -// } - - - /* - public DefaultMutableTreeNode getRootNode() { - return rootNode; - } - */ - - /** * Unlock the inspector window. Rebuild after this to avoid ... dots in the * trees labels @@ -729,8 +667,6 @@ public class VariableInspector extends JDialog { path = synthesizePath(path); if (path != null) { tree.expandPath(path); - } else { - //System.out.println("couldn't synthesize path"); } } @@ -804,7 +740,7 @@ public class VariableInspector extends JDialog { public interface VariableNodeFilter { /** Check whether the filter accepts a {@link VariableNode}. */ - public boolean accept(VariableNode var); + boolean accept(VariableNode var); } @@ -812,7 +748,7 @@ public class VariableInspector extends JDialog { * A {@link VariableNodeFilter} that accepts Processing built-in variable * names. */ - public class P5BuiltinsFilter implements VariableNodeFilter { + static public class P5BuiltinsFilter implements VariableNodeFilter { protected String[] p5Builtins = { "focused", @@ -842,7 +778,7 @@ public class VariableInspector extends JDialog { * A {@link VariableNodeFilter} that rejects implicit this references. * (Names starting with "this$") */ - public class ThisFilter implements VariableNodeFilter { + static public class ThisFilter implements VariableNodeFilter { @Override public boolean accept(VariableNode var) { @@ -858,7 +794,7 @@ public class VariableInspector extends JDialog { * A {@link VariableNodeFilter} that either rejects this-fields if hidden by * a local, or prefixes its name with "this." */ - public class LocalHidesThisFilter implements VariableNodeFilter { + static public class LocalHidesThisFilter implements VariableNodeFilter { // Reject a this-field if hidden by a local. public static final int MODE_HIDE = 0; // don't show hidden this fields diff --git a/java/theme/variables-1x.png b/java/theme/variables-1x.png deleted file mode 100644 index b20038b48..000000000 Binary files a/java/theme/variables-1x.png and /dev/null differ diff --git a/java/theme/variables-2x.png b/java/theme/variables-2x.png deleted file mode 100644 index 134701d1e..000000000 Binary files a/java/theme/variables-2x.png and /dev/null differ diff --git a/todo.txt b/todo.txt index 69eb610b9..da11fc1bb 100755 --- a/todo.txt +++ b/todo.txt @@ -72,6 +72,12 @@ X need to check on an actual Linux device, not a VM X this was caused by Nimbus interactions with FlatLaf X command key symbol missing in pop up menus X font for stack trace dialogs is too small (and wrong) +X overall layout/spacing/proportion +X icons for debug toolbar (VariableInspector.java) +X replace variables-1x and -2x with separate SVG files in debug +_ code completion icon updates (class, field, protected, method) +_ these go into CompletionPanel.java + design/selector X updated 4x4 for themes, foundation svg icon tweaks @@ -81,6 +87,8 @@ X add buttons for 'reload theme' and 'how to create themes' to theme fella X remove the 'reload theme' tool X both sets working, loading from folders X fixed up html wiring for styles +X gradients +X add a couple with gradients to the selector box? design/errors X errors table theme @@ -221,7 +229,7 @@ _ can't ship before ui.font and language bits sorted out _ otherwise the override to use Source Sans Pro will hose other languages _ using other JavaFX classes now that they're modules _ https://github.com/processing/processing4-javafx/issues/15 -_ update theme instructions andt +_ update theme instructions _ https://github.com/processing/processing4/wiki/Themes @@ -312,6 +320,7 @@ housekeeping _ replace bug numbers _ http://dev.processing.org/bugs/show_bug.cgi?id=1188 _ with http://processing.org/bugs/bugzilla/1188.html +_ or better yet, https://download.processing.org/bugzilla/1188.html _ also code.google.com URLs with Github URLs (numbers are sorta in sync) @@ -406,15 +415,6 @@ _ add rank for libraries/modes/tools (use unicode chars?) _ probably not sort by default to avoid confusion -design -X gradients -X add a couple with gradients to the selector box? -_ icons for debug toolbar -_ replace variables-1x and -2x with separate SVG files in debug -_ code completion icon updates (class, field, protected, method) -_ overall layout/spacing/proportion - - design/implementation _ updateTheme() in Theme Selector _ theme_selector.combo_box.enabled.bgcolor