From 0cfa63839781c046fe4a598966a2c5a65ac2a8b3 Mon Sep 17 00:00:00 2001 From: teddywing Date: Sun, 22 Jun 2014 14:00:48 -0400 Subject: [PATCH 01/15] PdeKeyListener.java: tab key behaves correctly if !editor.tabs.expand If the `editor.tabs.expand` preference setting is set to `false` (tabs are *not* expanded to spaces), insert a tab character when the tab key is pressed. Previously nothing would be inserted. --- app/src/processing/mode/java/PdeKeyListener.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/processing/mode/java/PdeKeyListener.java b/app/src/processing/mode/java/PdeKeyListener.java index e1acd5fad..c1ba6c30d 100644 --- a/app/src/processing/mode/java/PdeKeyListener.java +++ b/app/src/processing/mode/java/PdeKeyListener.java @@ -194,6 +194,9 @@ public class PdeKeyListener { textarea.setSelectedText(spaces(tabSize)); event.consume(); return true; + } else if (!Preferences.getBoolean("editor.tabs.expand")) { + textarea.setSelectedText("\t"); + event.consume(); } break; From 8c225b42826c5a9963b2e4de8bcd3ca595685d39 Mon Sep 17 00:00:00 2001 From: Manindra Moharana Date: Sat, 26 Jul 2014 21:52:20 +0530 Subject: [PATCH 02/15] type safety update.. --- .../processing/mode/experimental/ASTNodeWrapper.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pdex/src/processing/mode/experimental/ASTNodeWrapper.java b/pdex/src/processing/mode/experimental/ASTNodeWrapper.java index 62d84a3ca..e3d26c271 100644 --- a/pdex/src/processing/mode/experimental/ASTNodeWrapper.java +++ b/pdex/src/processing/mode/experimental/ASTNodeWrapper.java @@ -155,9 +155,10 @@ public class ASTNodeWrapper { //nodeOffset = ((VariableDeclarationFragment)(fd.fragments().get(0))).getName().getStartPosition(); } - if(jd == null){ + if (jd == null) { log("Visiting children of node " + getNodeAsString(thisNode)); - Iterator it = thisNode + Iterator it = + (Iterator) thisNode .structuralPropertiesForType().iterator(); boolean flag = true; while (it.hasNext()) { @@ -213,7 +214,7 @@ public class ASTNodeWrapper { * @return */ private int getJavadocOffset(FieldDeclaration fd){ - List list= fd.modifiers(); + List list= (List)fd.modifiers(); SimpleName sn = (SimpleName) getNode(); Type tp = fd.getType(); @@ -247,7 +248,7 @@ public class ASTNodeWrapper { * @return */ private int getJavadocOffset(MethodDeclaration md) { - List list = md.modifiers(); + List list = (List)md.modifiers(); SimpleName sn = (SimpleName) getNode(); int lineNum = getLineNumber(sn); log("SN " + sn + ", " + lineNum); @@ -282,8 +283,7 @@ public class ASTNodeWrapper { */ private int getJavadocOffset(TypeDeclaration td){ // TODO: This isn't perfect yet. Class \n \n \n className still breaks it.. :'( - List list= td.modifiers(); - list = td.modifiers(); + List list= (List)td.modifiers(); SimpleName sn = (SimpleName) getNode(); int lineNum = getLineNumber(sn); From 49f414c6eac40386f0cd2fb7c3df3cafa9a4ac59 Mon Sep 17 00:00:00 2001 From: joelmoniz Date: Sun, 27 Jul 2014 17:17:55 +0400 Subject: [PATCH 03/15] Fixes #2656 --- app/src/processing/app/Editor.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/src/processing/app/Editor.java b/app/src/processing/app/Editor.java index 806771478..fe18ab4a2 100644 --- a/app/src/processing/app/Editor.java +++ b/app/src/processing/app/Editor.java @@ -1232,6 +1232,11 @@ public abstract class Editor extends JFrame implements RunnerListener { public void showReference(String filename) { File file = new File(mode.getReferenceFolder(), filename); + try { + file = file.getCanonicalFile(); + } catch (IOException e) { + e.printStackTrace(); + } // Prepend with file:// and also encode spaces & other characters Base.openURL(file.toURI().toString()); } From 7c5b6b0e23a6f26f512248f4a1b60c5a179bbf00 Mon Sep 17 00:00:00 2001 From: Jakub Valtar Date: Mon, 28 Jul 2014 02:30:57 +0200 Subject: [PATCH 04/15] Implemented elliptical arcs for PShapeSVG Feature request #169 --- core/src/processing/core/PShapeSVG.java | 123 +++++++++++++++++++++++- 1 file changed, 122 insertions(+), 1 deletion(-) diff --git a/core/src/processing/core/PShapeSVG.java b/core/src/processing/core/PShapeSVG.java index 7bac4fb62..aa18b6ed0 100644 --- a/core/src/processing/core/PShapeSVG.java +++ b/core/src/processing/core/PShapeSVG.java @@ -518,7 +518,7 @@ public class PShapeSVG extends PShape { c == 'S' || c == 's' || c == 'Q' || c == 'q' || // quadratic beziers c == 'T' || c == 't' || -// c == 'A' || c == 'a' || // elliptical arc + c == 'A' || c == 'a' || // elliptical arc c == 'Z' || c == 'z' || // closepath c == ',') { separate = true; @@ -816,6 +816,40 @@ public class PShapeSVG extends PShape { } break; + // A - elliptical arc to (absolute) + case 'A': { + float rx = PApplet.parseFloat(pathTokens[i + 1]); + float ry = PApplet.parseFloat(pathTokens[i + 2]); + float angle = PApplet.parseFloat(pathTokens[i + 3]); + boolean fa = PApplet.parseFloat(pathTokens[i + 4]) != 0; + boolean fs = PApplet.parseFloat(pathTokens[i + 5]) != 0; + float endX = PApplet.parseFloat(pathTokens[i + 6]); + float endY = PApplet.parseFloat(pathTokens[i + 7]); + parsePathArcto(cx, cy, rx, ry, angle, fa, fs, endX, endY); + cx = endX; + cy = endY; + i += 8; + prevCurve = true; + } + break; + + // a - elliptical arc to (relative) + case 'a': { + float rx = PApplet.parseFloat(pathTokens[i + 1]); + float ry = PApplet.parseFloat(pathTokens[i + 2]); + float angle = PApplet.parseFloat(pathTokens[i + 3]); + boolean fa = PApplet.parseFloat(pathTokens[i + 4]) != 0; + boolean fs = PApplet.parseFloat(pathTokens[i + 5]) != 0; + float endX = cx + PApplet.parseFloat(pathTokens[i + 6]); + float endY = cy + PApplet.parseFloat(pathTokens[i + 7]); + parsePathArcto(cx, cy, rx, ry, angle, fa, fs, endX, endY); + cx = endX; + cy = endY; + i += 8; + prevCurve = true; + } + break; + case 'Z': case 'z': // since closing the path, the 'current' point needs @@ -924,6 +958,93 @@ public class PShapeSVG extends PShape { } + // Approximates elliptical arc by several bezier segments. + // Meets SVG standard requirements from: + // http://www.w3.org/TR/SVG/paths.html#PathDataEllipticalArcCommands + // http://www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes + // Based on arc to bezier curve equations from: + // http://www.spaceroots.org/documents/ellipse/node22.html + private void parsePathArcto(float x1, float y1, + float rx, float ry, + float angle, + boolean fa, boolean fs, + float x2, float y2) { + if (x1 == x2 && y1 == y2) return; + if (rx == 0 || ry == 0) { parsePathLineto(x2, y2); return; } + + rx = PApplet.abs(rx); ry = PApplet.abs(ry); + + float phi = PApplet.radians(((angle % 360) + 360) % 360); + float cosPhi = PApplet.cos(phi), sinPhi = PApplet.sin(phi); + + float x1r = ( cosPhi * (x1 - x2) + sinPhi * (y1 - y2)) / 2; + float y1r = (-sinPhi * (x1 - x2) + cosPhi * (y1 - y2)) / 2; + + float cxr, cyr; + { + float A = (x1r*x1r) / (rx*rx) + (y1r*y1r) / (ry*ry); + if (A > 1) { + // No solution, scale ellipse up according to SVG standard + float sqrtA = PApplet.sqrt(A); + rx *= sqrtA; cxr = 0; + ry *= sqrtA; cyr = 0; + } else { + float k = ((fa == fs) ? -1f : 1f) * + PApplet.sqrt((rx*rx * ry*ry) / ((rx*rx * y1r*y1r) + (ry*ry * x1r*x1r)) - 1f); + cxr = k * rx * y1r / ry; + cyr = -k * ry * x1r / rx; + } + } + + float cx = cosPhi * cxr - sinPhi * cyr + (x1 + x2) / 2; + float cy = sinPhi * cxr + cosPhi * cyr + (y1 + y2) / 2; + + float phi1, phiDelta; + { + float sx = ( x1r - cxr) / rx, sy = ( y1r - cyr) / ry; + float tx = (-x1r - cxr) / rx, ty = (-y1r - cyr) / ry; + phi1 = PApplet.atan2(sy, sx); + phiDelta = (((PApplet.atan2(ty, tx) - phi1) % TWO_PI) + TWO_PI) % TWO_PI; + if (!fs) phiDelta -= TWO_PI; + } + + // One segment can not cover more that PI, less than PI/2 is + // recommended to avoid visible inaccuracies caused by rounding errors + int segmentCount = PApplet.ceil(PApplet.abs(phiDelta) / TWO_PI * 4); + + float inc = phiDelta / segmentCount; + float a = PApplet.sin(inc) * + (PApplet.sqrt(4 + 3 * PApplet.sq(PApplet.tan(inc / 2))) - 1) / 3; + + float sinPhi1 = PApplet.sin(phi1), cosPhi1 = PApplet.cos(phi1); + + float p1x = x1; + float p1y = y1; + float relq1x = a * (-rx * cosPhi * sinPhi1 - ry * sinPhi * cosPhi1); + float relq1y = a * (-rx * sinPhi * sinPhi1 + ry * cosPhi * cosPhi1); + + for (int i = 0; i < segmentCount; i++) { + float eta = phi1 + (i + 1) * inc; + float sinEta = PApplet.sin(eta), cosEta = PApplet.cos(eta); + + float p2x = cx + rx * cosPhi * cosEta - ry * sinPhi * sinEta; + float p2y = cy + rx * sinPhi * cosEta + ry * cosPhi * sinEta; + float relq2x = a * (-rx * cosPhi * sinEta - ry * sinPhi * cosEta); + float relq2y = a * (-rx * sinPhi * sinEta + ry * cosPhi * cosEta); + + if (i == segmentCount - 1) { p2x = x2; p2y = y2; } + + parsePathCode(BEZIER_VERTEX); + parsePathVertex(p1x + relq1x, p1y + relq1y); + parsePathVertex(p2x - relq2x, p2y - relq2y); + parsePathVertex(p2x, p2y); + + p1x = p2x; relq1x = relq2x; + p1y = p2y; relq1y = relq2y; + } + } + + /** * Parse the specified SVG matrix into a PMatrix2D. Note that PMatrix2D * is rotated relative to the SVG definition, so parameters are rearranged From ac8d8589ea526c7ab38f91524507b7422c5bc866 Mon Sep 17 00:00:00 2001 From: Manindra Moharana Date: Mon, 28 Jul 2014 10:02:59 +0530 Subject: [PATCH 05/15] minor code changes --- .../mode/experimental/ASTGenerator.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/pdex/src/processing/mode/experimental/ASTGenerator.java b/pdex/src/processing/mode/experimental/ASTGenerator.java index f68f8c2c1..3b1740127 100644 --- a/pdex/src/processing/mode/experimental/ASTGenerator.java +++ b/pdex/src/processing/mode/experimental/ASTGenerator.java @@ -895,7 +895,7 @@ public class ASTGenerator { logE("Typed: " + word2 + "|" + " temp Node type: " + testnode.getClass().getSimpleName()); if(testnode instanceof MethodInvocation){ MethodInvocation mi = (MethodInvocation)testnode; - System.out.println(mi.getName() + "," + mi.getExpression() + "," + mi.typeArguments().size()); + log(mi.getName() + "," + mi.getExpression() + "," + mi.typeArguments().size()); } // find nearest ASTNode @@ -1259,8 +1259,7 @@ public class ASTGenerator { // First, see if the classname is a fully qualified name and loads straightaway tehClass = loadClass(className); - // do you mean to check for 'null' here? otherwise, this expression is always true [fry] - if (tehClass instanceof Class) { + if (tehClass != null) { //log(tehClass.getName() + " located straightaway"); return tehClass; } @@ -1282,7 +1281,7 @@ public class ASTGenerator { } } tehClass = loadClass(temp); - if (tehClass instanceof Class) { + if (tehClass != null) { log(tehClass.getName() + " located."); return tehClass; } @@ -1294,7 +1293,7 @@ public class ASTGenerator { PdePreprocessor p = new PdePreprocessor(null); for (String impS : p.getCoreImports()) { tehClass = loadClass(impS.substring(0,impS.length()-1) + className); - if (tehClass instanceof Class) { + if (tehClass != null) { log(tehClass.getName() + " located."); return tehClass; } @@ -1304,7 +1303,7 @@ public class ASTGenerator { for (String impS : p.getDefaultImports()) { if(className.equals(impS) || impS.endsWith(className)){ tehClass = loadClass(impS); - if (tehClass instanceof Class) { + if (tehClass != null) { log(tehClass.getName() + " located."); return tehClass; } @@ -1315,7 +1314,7 @@ public class ASTGenerator { // And finally, the daddy String daddy = "java.lang." + className; tehClass = loadClass(daddy); - if (tehClass instanceof Class) { + if (tehClass != null) { log(tehClass.getName() + " located."); return tehClass; } @@ -1886,7 +1885,6 @@ public class ASTGenerator { + lineElement.getEndOffset()); log("PL " + pdeLine); } catch (BadLocationException e) { - // TODO Auto-generated catch block e.printStackTrace(); } } @@ -3011,7 +3009,7 @@ public class ASTGenerator { /** * A wrapper for java.lang.reflect types. * Will have to see if the usage turns out to be internal only here or not - * and then accordingly decide where to place this class. TODO + * and then accordingly decide where to place this class. * @author quarkninja * */ From 8b380b545978d74c4642a7235661e16898419d7d Mon Sep 17 00:00:00 2001 From: Manindra Moharana Date: Mon, 28 Jul 2014 10:20:51 +0530 Subject: [PATCH 06/15] minor code updates to get rid of warnings.. --- .../processing/mode/experimental/ASTGenerator.java | 8 ++++---- .../processing/mode/experimental/SketchOutline.java | 4 ++-- .../src/processing/mode/experimental/TabOutline.java | 4 ++-- pdex/src/processing/mode/experimental/TextArea.java | 12 ++++++------ 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/pdex/src/processing/mode/experimental/ASTGenerator.java b/pdex/src/processing/mode/experimental/ASTGenerator.java index 3b1740127..dc405da71 100644 --- a/pdex/src/processing/mode/experimental/ASTGenerator.java +++ b/pdex/src/processing/mode/experimental/ASTGenerator.java @@ -268,7 +268,7 @@ public class ASTGenerator { logE("No CU found!"); } visitRecur((ASTNode) compilationUnit.types().get(0), codeTree); - SwingWorker worker = new SwingWorker() { + SwingWorker worker = new SwingWorker() { @Override protected Object doInBackground() throws Exception { @@ -1040,7 +1040,7 @@ public class ASTGenerator { if (sketchOutline.isVisible()) return; Collections.sort(candidates); // CompletionCandidate[][] candi = new CompletionCandidate[candidates.size()][1]; - DefaultListModel defListModel = new DefaultListModel(); + DefaultListModel defListModel = new DefaultListModel(); for (int i = 0; i < candidates.size(); i++) { // candi[i][0] = candidates.get(i); @@ -2261,11 +2261,11 @@ public class ASTGenerator { int endOffset) { // log("dfsLookForASTNode() lookin for " + name + " Offsets: " + startOffset // + "," + endOffset); - Stack stack = new Stack(); + Stack stack = new Stack(); stack.push(root); while (!stack.isEmpty()) { - ASTNode node = (ASTNode) stack.pop(); + ASTNode node = stack.pop(); //log("Popped from stack: " + getNodeAsString(node)); Iterator it = node.structuralPropertiesForType().iterator(); diff --git a/pdex/src/processing/mode/experimental/SketchOutline.java b/pdex/src/processing/mode/experimental/SketchOutline.java index eafda9366..620d8d1b2 100644 --- a/pdex/src/processing/mode/experimental/SketchOutline.java +++ b/pdex/src/processing/mode/experimental/SketchOutline.java @@ -200,7 +200,7 @@ public class SketchOutline { } private void updateSelection(){ - SwingWorker worker = new SwingWorker() { + SwingWorker worker = new SwingWorker() { protected Object doInBackground() throws Exception { String text = searchField.getText().toLowerCase(); tempNode = new DefaultMutableTreeNode(); @@ -252,7 +252,7 @@ public class SketchOutline { } private void scrollToNode(){ - SwingWorker worker = new SwingWorker() { + SwingWorker worker = new SwingWorker() { protected Object doInBackground() throws Exception { return null; diff --git a/pdex/src/processing/mode/experimental/TabOutline.java b/pdex/src/processing/mode/experimental/TabOutline.java index b570a10e0..238671536 100644 --- a/pdex/src/processing/mode/experimental/TabOutline.java +++ b/pdex/src/processing/mode/experimental/TabOutline.java @@ -188,7 +188,7 @@ public class TabOutline { } private void updateSelection() { - SwingWorker worker = new SwingWorker() { + SwingWorker worker = new SwingWorker() { protected Object doInBackground() throws Exception { String text = searchField.getText().toLowerCase(); tempNode = new DefaultMutableTreeNode(); @@ -220,7 +220,7 @@ public class TabOutline { return; } // log(e); - SwingWorker worker = new SwingWorker() { + SwingWorker worker = new SwingWorker() { protected Object doInBackground() throws Exception { return null; diff --git a/pdex/src/processing/mode/experimental/TextArea.java b/pdex/src/processing/mode/experimental/TextArea.java index 82a8e311c..8e28eaf19 100644 --- a/pdex/src/processing/mode/experimental/TextArea.java +++ b/pdex/src/processing/mode/experimental/TextArea.java @@ -53,7 +53,7 @@ public class TextArea extends JEditTextArea { protected DebugEditor editor; // the editor // line properties - protected Map lineColors = new HashMap(); // contains line background colors + protected Map lineColors = new HashMap(); // contains line background colors // left-hand gutter properties protected int gutterPadding = 3; // [px] space added to the left and right of gutter chars @@ -66,9 +66,9 @@ public class TextArea extends JEditTextArea { protected String currentLineMarker = "->"; // the text marker for highlighting the current line in the gutter - protected Map gutterText = new HashMap(); // maps line index to gutter text + protected Map gutterText = new HashMap(); // maps line index to gutter text - protected Map gutterTextColors = new HashMap(); // maps line index to gutter text color + protected Map gutterTextColors = new HashMap(); // maps line index to gutter text color protected TextAreaPainter customPainter; @@ -220,7 +220,7 @@ public class TextArea extends JEditTextArea { if (evt.isAltDown() || evt.isControlDown() || evt.isMetaDown()) { if (ExperimentalMode.ccTriggerEnabled && keyChar == KeyEvent.VK_SPACE && (evt.isControlDown() || evt.isMetaDown())) { - SwingWorker worker = new SwingWorker() { + SwingWorker worker = new SwingWorker() { protected Object doInBackground() throws Exception { // Provide completions only if it's enabled if (ExperimentalMode.codeCompletionsEnabled @@ -240,7 +240,7 @@ public class TextArea extends JEditTextArea { return; } - SwingWorker worker = new SwingWorker() { + SwingWorker worker = new SwingWorker() { protected Object doInBackground() throws Exception { // errorCheckerService.runManualErrorCheck(); // Provide completions only if it's enabled @@ -351,7 +351,7 @@ public class TextArea extends JEditTextArea { // else { //log2(s + " len " + s.length()); - int x = getCaretPosition() - getLineStartOffset(line) - 1, x2 = x + 1, x1 = x - 1; + int x = getCaretPosition() - getLineStartOffset(line) - 1, x1 = x - 1; if(x >= s.length() || x < 0) return null; //TODO: Does this check cause problems? Verify. log2(" x char: " + s.charAt(x)); From 42715c6a0687500ced25f5dbf8e988e794d3e972 Mon Sep 17 00:00:00 2001 From: Manindra Moharana Date: Mon, 28 Jul 2014 10:24:08 +0530 Subject: [PATCH 07/15] removing warnings --- pdex/src/processing/mode/experimental/DebugEditor.java | 10 +++++----- pdex/src/processing/mode/experimental/ErrorBar.java | 8 +++----- .../src/processing/mode/experimental/XQErrorTable.java | 3 +-- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/pdex/src/processing/mode/experimental/DebugEditor.java b/pdex/src/processing/mode/experimental/DebugEditor.java index bc4c449ac..f8d26e266 100755 --- a/pdex/src/processing/mode/experimental/DebugEditor.java +++ b/pdex/src/processing/mode/experimental/DebugEditor.java @@ -99,7 +99,7 @@ public class DebugEditor extends JavaEditor implements ActionListener { protected Color currentLineColor = new Color(255, 255, 150); // the background color for highlighting lines protected Color breakpointMarkerColor = new Color(74, 84, 94); // the color of breakpoint gutter markers protected Color currentLineMarkerColor = new Color(226, 117, 0); // the color of current line gutter markers - protected List breakpointedLines = new ArrayList(); // breakpointed lines + protected List breakpointedLines = new ArrayList(); // breakpointed lines protected LineHighlight currentLine; // line the debugger is currently suspended at protected final String breakpointMarkerComment = " //<>//"; // breakpoint marker comment // menus @@ -837,7 +837,7 @@ public class DebugEditor extends JavaEditor implements ActionListener { * removed from. */ protected List stripBreakpointComments() { - List bps = new ArrayList(); + List bps = new ArrayList(); // iterate over all tabs Sketch sketch = getSketch(); for (int i = 0; i < sketch.getCodeCount(); i++) { @@ -934,7 +934,7 @@ public class DebugEditor extends JavaEditor implements ActionListener { } // note modified tabs - final List modified = new ArrayList(); + final List modified = new ArrayList(); for (int i = 0; i < getSketch().getCodeCount(); i++) { SketchCode tab = getSketch().getCode(i); if (tab.isModified()) { @@ -1586,9 +1586,9 @@ public class DebugEditor extends JavaEditor implements ActionListener { if(type == STATUS_COMPILER_ERR) return; // Clear the message after a delay - SwingWorker s = new SwingWorker() { + SwingWorker s = new SwingWorker() { @Override - protected Void doInBackground() throws Exception { + protected Object doInBackground() throws Exception { try { Thread.sleep(2 * 1000); } catch (InterruptedException e) { diff --git a/pdex/src/processing/mode/experimental/ErrorBar.java b/pdex/src/processing/mode/experimental/ErrorBar.java index 9ab47395b..b858dcdbb 100755 --- a/pdex/src/processing/mode/experimental/ErrorBar.java +++ b/pdex/src/processing/mode/experimental/ErrorBar.java @@ -151,7 +151,7 @@ public class ErrorBar extends JPanel { // Error Marker index in the arraylist is LOCALIZED for current tab. // Also, need to do the update in the UI thread to prevent concurrency issues. final int fheight = this.getHeight(); - SwingWorker worker = new SwingWorker() { + SwingWorker worker = new SwingWorker() { protected Object doInBackground() throws Exception { SketchCode sc = editor.getSketch().getCurrentCode(); @@ -242,10 +242,9 @@ public class ErrorBar extends JPanel { // Find out which error/warning the user has clicked // and then scroll to that - @SuppressWarnings("rawtypes") @Override public void mouseClicked(final MouseEvent e) { - SwingWorker worker = new SwingWorker() { + SwingWorker worker = new SwingWorker() { protected Object doInBackground() throws Exception { for (ErrorMarker eMarker : errorPoints) { @@ -275,11 +274,10 @@ public class ErrorBar extends JPanel { // Tooltip on hover this.addMouseMotionListener(new MouseMotionListener() { - @SuppressWarnings("rawtypes") @Override public void mouseMoved(final MouseEvent evt) { // System.out.println(e); - SwingWorker worker = new SwingWorker() { + SwingWorker worker = new SwingWorker() { protected Object doInBackground() throws Exception { for (ErrorMarker eMarker : errorPoints) { diff --git a/pdex/src/processing/mode/experimental/XQErrorTable.java b/pdex/src/processing/mode/experimental/XQErrorTable.java index e64cf2c4b..2e1c23aa7 100755 --- a/pdex/src/processing/mode/experimental/XQErrorTable.java +++ b/pdex/src/processing/mode/experimental/XQErrorTable.java @@ -117,7 +117,6 @@ public class XQErrorTable extends JTable { * @param tableModel - TableModel * @return boolean - If table data was updated */ - @SuppressWarnings("rawtypes") synchronized public boolean updateTable(final TableModel tableModel) { // If problems list is not visible, no need to update @@ -125,7 +124,7 @@ public class XQErrorTable extends JTable { return false; } - SwingWorker worker = new SwingWorker() { + SwingWorker worker = new SwingWorker() { protected Object doInBackground() throws Exception { return null; From 7bc00af4aff7ae8ffaae3990e2ff8b1f0c0e37c5 Mon Sep 17 00:00:00 2001 From: Manindra Moharana Date: Mon, 28 Jul 2014 10:28:54 +0530 Subject: [PATCH 08/15] more code cleanup --- pdex/src/processing/mode/experimental/AutoSaveUtil.java | 2 +- .../src/processing/mode/experimental/CompilationChecker.java | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/pdex/src/processing/mode/experimental/AutoSaveUtil.java b/pdex/src/processing/mode/experimental/AutoSaveUtil.java index f93b7aa17..f3414ba0c 100644 --- a/pdex/src/processing/mode/experimental/AutoSaveUtil.java +++ b/pdex/src/processing/mode/experimental/AutoSaveUtil.java @@ -31,7 +31,7 @@ import processing.app.Sketch; /** * Autosave utility for saving sketch backups in the background after * certain intervals - * + * NOTE: This was developed as an experiment, but disabled for now. * @author Manindra Moharana * */ diff --git a/pdex/src/processing/mode/experimental/CompilationChecker.java b/pdex/src/processing/mode/experimental/CompilationChecker.java index 3e570bd41..1b5459d06 100644 --- a/pdex/src/processing/mode/experimental/CompilationChecker.java +++ b/pdex/src/processing/mode/experimental/CompilationChecker.java @@ -161,7 +161,7 @@ public class CompilationChecker { } List getResults() { - System.out.println("Calling get results"); + //System.out.println("Calling get results"); return this.classes; } } @@ -268,12 +268,11 @@ public class CompilationChecker { try { urls[i] = jarList.get(i).toURI().toURL(); } catch (MalformedURLException e) { - // TODO Auto-generated catch block e.printStackTrace(); } } urlClassLoader = new URLClassLoader(urls); - System.out.println("URL Classloader ready"); + //System.out.println("URL Classloader ready"); } /** From c9757711319f5dabe3a835cc054f7a77a7a7e5d3 Mon Sep 17 00:00:00 2001 From: Manindra Moharana Date: Mon, 28 Jul 2014 10:32:44 +0530 Subject: [PATCH 09/15] code cleanup --- .../processing/mode/experimental/Debugger.java | 16 ++++++++-------- .../mode/experimental/LineHighlight.java | 2 +- .../src/processing/mode/experimental/LineID.java | 2 +- .../mode/experimental/OffsetMatcher.java | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pdex/src/processing/mode/experimental/Debugger.java b/pdex/src/processing/mode/experimental/Debugger.java index 916745268..7f19d0622 100755 --- a/pdex/src/processing/mode/experimental/Debugger.java +++ b/pdex/src/processing/mode/experimental/Debugger.java @@ -51,13 +51,13 @@ public class Debugger implements VMEventListener { protected ThreadReference currentThread; // thread the last breakpoint or step occured in protected String mainClassName; // name of the main class that's currently being debugged protected ReferenceType mainClass; // the debuggee's main class - protected Set classes = new HashSet(); // holds all loaded classes in the debuggee VM - protected List classLoadListeners = new ArrayList(); // listeners for class load events + protected Set classes = new HashSet(); // holds all loaded classes in the debuggee VM + protected List classLoadListeners = new ArrayList(); // listeners for class load events protected String srcPath; // path to the src folder of the current build - protected List breakpoints = new ArrayList(); // list of current breakpoints + protected List breakpoints = new ArrayList(); // list of current breakpoints protected StepRequest requestedStep; // the step request we are currently in, or null if not in a step - protected Map runtimeLineChanges = new HashMap(); // maps line number changes at runtime (orig -> changed) - protected Set runtimeTabsTracked = new HashSet(); // contains tab filenames which already have been tracked for runtime changes + protected Map runtimeLineChanges = new HashMap(); // maps line number changes at runtime (orig -> changed) + protected Set runtimeTabsTracked = new HashSet(); // contains tab filenames which already have been tracked for runtime changes /** * Construct a Debugger object. @@ -514,7 +514,7 @@ public class Debugger implements VMEventListener { * @return the list of breakpoints in the given tab */ public synchronized List getBreakpoints(String tabFilename) { - List list = new ArrayList(); + List list = new ArrayList(); for (LineBreakpoint bp : breakpoints) { if (bp.lineID().fileName().equals(tabFilename)) { list.add(bp); @@ -1002,7 +1002,7 @@ public class Debugger implements VMEventListener { } catch (IncompatibleThreadStateException ex) { Logger.getLogger(Debugger.class.getName()).log(Level.SEVERE, null, ex); } - return new ArrayList(); + return new ArrayList(); } /** @@ -1081,7 +1081,7 @@ public class Debugger implements VMEventListener { * @return call stack as list of {@link DefaultMutableTreeNode}s */ protected List getStackTrace(ThreadReference t) { - List stack = new ArrayList(); + List stack = new ArrayList(); try { // int i = 0; for (StackFrame f : t.frames()) { diff --git a/pdex/src/processing/mode/experimental/LineHighlight.java b/pdex/src/processing/mode/experimental/LineHighlight.java index c1789cf24..0fd18dfeb 100755 --- a/pdex/src/processing/mode/experimental/LineHighlight.java +++ b/pdex/src/processing/mode/experimental/LineHighlight.java @@ -35,7 +35,7 @@ public class LineHighlight implements LineListener { protected String marker; // protected Color markerColor; protected int priority = 0; - protected static Set allHighlights = new HashSet(); + protected static Set allHighlights = new HashSet(); protected static boolean isHighestPriority(LineHighlight hl) { for (LineHighlight check : allHighlights) { diff --git a/pdex/src/processing/mode/experimental/LineID.java b/pdex/src/processing/mode/experimental/LineID.java index a08d21296..006098567 100755 --- a/pdex/src/processing/mode/experimental/LineID.java +++ b/pdex/src/processing/mode/experimental/LineID.java @@ -42,7 +42,7 @@ public class LineID implements DocumentListener { protected int lineIdx; // the line number, 0-based protected Document doc; // the Document to use for line number tracking protected Position pos; // the Position acquired during line number tracking - protected Set listeners = new HashSet(); // listeners for line number changes + protected Set listeners = new HashSet(); // listeners for line number changes public LineID(String fileName, int lineIdx) { this.fileName = fileName; diff --git a/pdex/src/processing/mode/experimental/OffsetMatcher.java b/pdex/src/processing/mode/experimental/OffsetMatcher.java index 3623e4161..310e596d4 100644 --- a/pdex/src/processing/mode/experimental/OffsetMatcher.java +++ b/pdex/src/processing/mode/experimental/OffsetMatcher.java @@ -187,7 +187,7 @@ public class OffsetMatcher { } private void minDistInGrid(int g[][], int i, int j, int fi, int fj, - char s1[], char s2[], ArrayList set) { + char s1[], char s2[], ArrayList set) { // if(i < s1.length)System.out.print(s1[i] + " <->"); // if(j < s2.length)System.out.print(s2[j]); if (i < s1.length && j < s2.length) { From e3ae98e8ae786f7f19a2dd8f7b6da70b9e7bca8a Mon Sep 17 00:00:00 2001 From: Manindra Moharana Date: Mon, 28 Jul 2014 10:44:20 +0530 Subject: [PATCH 10/15] todo update --- pdex/todo.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pdex/todo.txt b/pdex/todo.txt index b8d2c6d7e..65e7c7116 100644 --- a/pdex/todo.txt +++ b/pdex/todo.txt @@ -20,6 +20,10 @@ Critical Bugs Misc Tasks ---------- +-[ ] New sketchbook layout + +-[ ] Better compatibility java tabs + -[x] Trim CompilationChecker class -[x] Refactoring should support single undo From 75a527f97bac6cc4e427e590b922ffac0a1603f2 Mon Sep 17 00:00:00 2001 From: Manindra Moharana Date: Mon, 28 Jul 2014 10:55:03 +0530 Subject: [PATCH 11/15] some stuff disabled for java tabs --- .../mode/experimental/ASTGenerator.java | 3 +++ .../mode/experimental/DebugEditor.java | 18 ++++++++++++------ .../processing/mode/experimental/TextArea.java | 1 + pdex/todo.txt | 2 +- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/pdex/src/processing/mode/experimental/ASTGenerator.java b/pdex/src/processing/mode/experimental/ASTGenerator.java index dc405da71..5918e8e4b 100644 --- a/pdex/src/processing/mode/experimental/ASTGenerator.java +++ b/pdex/src/processing/mode/experimental/ASTGenerator.java @@ -2066,6 +2066,7 @@ public class ASTGenerator { } public void handleShowUsage(){ + if(editor.hasJavaTabs) return; // show usage disabled if java tabs log("Last clicked word:" + lastClickedWord); if(lastClickedWord == null && editor.ta.getSelectedText() == null){ editor.statusMessage("Highlight the class/function/variable name first" @@ -2319,6 +2320,7 @@ public class ASTGenerator { protected SketchOutline sketchOutline; protected void showSketchOutline(){ + if(editor.hasJavaTabs) return; // sketch outline disabled if java tabs sketchOutline = new SketchOutline(codeTree, errorCheckerService); sketchOutline.show(); } @@ -2403,6 +2405,7 @@ public class ASTGenerator { } public void handleRefactor(){ + if(editor.hasJavaTabs) return; // refactoring disabled if java tabs log("Last clicked word:" + lastClickedWord); if(lastClickedWord == null && editor.ta.getSelectedText() == null){ editor.statusMessage("Highlight the class/function/variable name first", diff --git a/pdex/src/processing/mode/experimental/DebugEditor.java b/pdex/src/processing/mode/experimental/DebugEditor.java index f8d26e266..c278b680c 100755 --- a/pdex/src/processing/mode/experimental/DebugEditor.java +++ b/pdex/src/processing/mode/experimental/DebugEditor.java @@ -189,6 +189,11 @@ public class DebugEditor extends JavaEditor implements ActionListener { */ protected JCheckBoxMenuItem completionsEnabled; + /** + * If sketch contains java tabs, some editor features are disabled + */ + protected boolean hasJavaTabs; + /** * UNUSED. Disbaled for now. */ @@ -1687,19 +1692,20 @@ public class DebugEditor extends JavaEditor implements ActionListener { } /** - * Checks if the sketch contains java tabs. If it does, XQMode ain't built - * for it, yet. Also, user should really start looking at Eclipse. Disable - * compilation check. + * Checks if the sketch contains java tabs. If it does, the editor ain't built + * for it, yet. Also, user should really start looking at more powerful IDEs + * likeEclipse. Disable compilation check and some more features. */ private void checkForJavaTabs() { + hasJavaTabs = false; for (int i = 0; i < this.getSketch().getCodeCount(); i++) { if (this.getSketch().getCode(i).getExtension().equals("java")) { compilationCheckEnabled = false; + hasJavaTabs = true; JOptionPane.showMessageDialog(new Frame(), this .getSketch().getName() - + " contains .java tabs. Live compilation error checking isn't " - + "supported for java tabs. Only " - + "syntax errors will be reported for .pde tabs."); + + " contains .java tabs. Some editor features are not supported " + + "for .java tabs and will be disabled."); break; } } diff --git a/pdex/src/processing/mode/experimental/TextArea.java b/pdex/src/processing/mode/experimental/TextArea.java index 8e28eaf19..1396cd152 100644 --- a/pdex/src/processing/mode/experimental/TextArea.java +++ b/pdex/src/processing/mode/experimental/TextArea.java @@ -207,6 +207,7 @@ public class TextArea extends JEditTextArea { } super.processKeyEvent(evt); + if(editor.hasJavaTabs) return; // code completion disabled if java tabs if (evt.getID() == KeyEvent.KEY_TYPED) { char keyChar = evt.getKeyChar(); diff --git a/pdex/todo.txt b/pdex/todo.txt index 65e7c7116..8b2659193 100644 --- a/pdex/todo.txt +++ b/pdex/todo.txt @@ -22,7 +22,7 @@ Misc Tasks -[ ] New sketchbook layout --[ ] Better compatibility java tabs +-[ ] Better compatibility with java tabs -[x] Trim CompilationChecker class From 1ae3d2c4ad1a230902b1b0c4b9b35fc5bf08b69c Mon Sep 17 00:00:00 2001 From: Manindra Moharana Date: Mon, 28 Jul 2014 11:14:09 +0530 Subject: [PATCH 12/15] more java tab stuff --- pdex/.externalToolBuilders/Ant_Builder.launch | 2 +- pdex/src/processing/mode/experimental/TextArea.java | 4 +++- pdex/src/processing/mode/experimental/TextAreaPainter.java | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pdex/.externalToolBuilders/Ant_Builder.launch b/pdex/.externalToolBuilders/Ant_Builder.launch index 2f93ff37a..9b95f0090 100644 --- a/pdex/.externalToolBuilders/Ant_Builder.launch +++ b/pdex/.externalToolBuilders/Ant_Builder.launch @@ -12,7 +12,7 @@ - + diff --git a/pdex/src/processing/mode/experimental/TextArea.java b/pdex/src/processing/mode/experimental/TextArea.java index 1396cd152..7280b6bbb 100644 --- a/pdex/src/processing/mode/experimental/TextArea.java +++ b/pdex/src/processing/mode/experimental/TextArea.java @@ -652,7 +652,9 @@ public class TextArea extends JEditTextArea { } if (me.getButton() == MouseEvent.BUTTON3) { - fetchPhrase(me); + if(!editor.hasJavaTabs){ // tooltips, etc disabled for java tabs + fetchPhrase(me); + } } // forward to standard listeners diff --git a/pdex/src/processing/mode/experimental/TextAreaPainter.java b/pdex/src/processing/mode/experimental/TextAreaPainter.java index cebe21e84..38f8ddecf 100644 --- a/pdex/src/processing/mode/experimental/TextAreaPainter.java +++ b/pdex/src/processing/mode/experimental/TextAreaPainter.java @@ -87,7 +87,7 @@ public class TextAreaPainter extends processing.app.syntax.TextAreaPainter ta = textArea; addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { -// log( " Meta,Ctrl "+ (evt.getModifiers() & ctrlMask)); + if(ta.editor.hasJavaTabs) return; // Ctrl + Click disabled for java tabs if (evt.getButton() == MouseEvent.BUTTON1) { if (evt.isControlDown() || evt.isMetaDown()) handleCtrlClick(evt); @@ -457,6 +457,7 @@ public class TextAreaPainter extends processing.app.syntax.TextAreaPainter } public String getToolTipText(java.awt.event.MouseEvent evt) { + if(ta.editor.hasJavaTabs) return null; // disabled for java tabs int off = ta.xyToOffset(evt.getX(), evt.getY()); if (off < 0) return null; From 31824905d052e113a6b26f52e1e109a1ab64d6ee Mon Sep 17 00:00:00 2001 From: Manindra Moharana Date: Mon, 28 Jul 2014 11:17:04 +0530 Subject: [PATCH 13/15] fix build.xml for pdex --- pdex/build.xml | 177 +++++++++++++++++++++++++++---------------------- 1 file changed, 97 insertions(+), 80 deletions(-) diff --git a/pdex/build.xml b/pdex/build.xml index 4cfc10aa0..3d4828f8a 100644 --- a/pdex/build.xml +++ b/pdex/build.xml @@ -1,25 +1,55 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + + + - - - - - - - - - - - - - + + + + - - - + + + + + + + + + - - - - - - + + + + + + + + - - - - - - - - - + + + + - - - - - - - - - + + + + - - - - + + + + - - - - + + + + - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - - + + + + + From 6397d941b34c22875d04589088244d453ce99cd7 Mon Sep 17 00:00:00 2001 From: Manindra Moharana Date: Mon, 28 Jul 2014 23:37:14 +0530 Subject: [PATCH 14/15] dialog for new tab and rename. Fixes #2431 --- app/src/processing/app/Sketch.java | 101 ++++++++++++++++++++++++++++- 1 file changed, 98 insertions(+), 3 deletions(-) diff --git a/app/src/processing/app/Sketch.java b/app/src/processing/app/Sketch.java index 013313bad..78d0b1752 100644 --- a/app/src/processing/app/Sketch.java +++ b/app/src/processing/app/Sketch.java @@ -26,6 +26,9 @@ package processing.app; import processing.core.*; import java.awt.*; +import java.awt.event.ActionListener; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; import java.io.*; import javax.swing.*; @@ -286,7 +289,8 @@ public class Sketch { } renamingCode = false; - editor.status.edit("Name for new file:", ""); + // editor.status.edit("Name for new file:", ""); + promptForTabName("Name for new file:", ""); } @@ -326,8 +330,99 @@ public class Sketch { "New name for sketch:" : "New name for file:"; String oldName = (current.isExtension(mode.getDefaultExtension())) ? current.getPrettyName() : current.getFileName(); - editor.status.edit(prompt, oldName); + // editor.status.edit(prompt, oldName); + promptForTabName(prompt, oldName); } + + /** + * Displays a dialog for renaming or creating a new tab + * @param prompt - msg to display + * @param oldName + */ + protected void promptForTabName(String prompt, String oldName) { + final JTextField txtTabName = new JTextField(); + txtTabName.addKeyListener(new KeyAdapter() { + // Forget ESC, the JDialog should handle it. + + // Use keyTyped to catch when the feller is actually + // added to the text field. With keyTyped, as opposed to + // keyPressed, the keyCode will be zero, even if it's + // enter or backspace or whatever, so the keychar should + // be used instead. Grr. + public void keyTyped(KeyEvent event) { + //System.out.println("got event " + event); + char ch = event.getKeyChar(); + if ((ch == '_') || (ch == '.') || // allow.pde and .java + (('A' <= ch) && (ch <= 'Z')) || (('a' <= ch) && (ch <= 'z'))) { + // These events are allowed straight through. + } else if (ch == ' ') { + String t = txtTabName.getText(); + int start = txtTabName.getSelectionStart(); + int end = txtTabName.getSelectionEnd(); + txtTabName.setText(t.substring(0, start) + "_" + t.substring(end)); + txtTabName.setCaretPosition(start + 1); + event.consume(); + } else if ((ch >= '0') && (ch <= '9')) { + // getCaretPosition == 0 means that it's the first char + // and the field is empty. + // getSelectionStart means that it *will be* the first + // char, because the selection is about to be replaced + // with whatever is typed. + if ((txtTabName.getCaretPosition() == 0) + || (txtTabName.getSelectionStart() == 0)) { + // number not allowed as first digit + //System.out.println("bad number bad"); + event.consume(); + } + } else if (ch == KeyEvent.VK_ENTER) { + // Slightly ugly hack that ensures OK button of the dialog + // consumes the Enter key event. Since the text field is the + // default component in the dialog(see below), OK button doesn't + // consume Enter key event, by default. + Container parent = txtTabName.getParent(); + while (!(parent instanceof JOptionPane)) { + parent = parent.getParent(); + } + JOptionPane pane = (JOptionPane) parent; + final JPanel pnlBottom = (JPanel) pane.getComponent(pane + .getComponentCount() - 1); + for (int i = 0; i < pnlBottom.getComponents().length; i++) { + Component component = pnlBottom.getComponents()[i]; + if (component instanceof JButton) { + final JButton okButton = ((JButton) component); + if (okButton.getText().equalsIgnoreCase("OK")) { + ActionListener[] actionListeners = okButton + .getActionListeners(); + if (actionListeners.length > 0) { + actionListeners[0].actionPerformed(null); + event.consume(); + } + } + } + } + } + else { + event.consume(); + } + } + }); + + int userReply = JOptionPane.showOptionDialog(editor, new Object[] { + prompt, txtTabName }, + "Tab Name", + JOptionPane.OK_CANCEL_OPTION, + JOptionPane.PLAIN_MESSAGE, + null, new Object[] { + Preferences.PROMPT_OK, + Preferences.PROMPT_CANCEL }, + txtTabName); + + if (userReply == JOptionPane.OK_OPTION) { + String answer = txtTabName.getText(); + nameCode(answer); + } + } + /** @@ -382,7 +477,7 @@ public class Sketch { if (current == code[0]) { // If this is the main tab, disallow Base.showWarning("Problem with rename", "The first tab cannot be a ." + newExtension + " file.\n" + - "(It may be time for your to graduate to a\n" + + "(It may be time for you to graduate to a\n" + "\"real\" programming environment, hotshot.)"); return; } From 5d09cc74adee98d21f070f22fc8cb89c1f1dfe29 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Mon, 28 Jul 2014 15:16:13 -0400 Subject: [PATCH 15/15] todos and notes for the revisions --- build/shared/revisions.txt | 22 ++++++++++++++++++++++ core/todo.txt | 10 ++++++++-- todo.txt | 12 ++++++++++++ 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/build/shared/revisions.txt b/build/shared/revisions.txt index d4b60796b..30acaafcc 100644 --- a/build/shared/revisions.txt +++ b/build/shared/revisions.txt @@ -1,3 +1,25 @@ +PROCESSING 3.0a2 (REV 0229) - ?? August 2014 + + +[ fixes ] + ++ The Examples and Reference weren't included in 3.0a1. Oops. + https://github.com/processing/processing/issues/2652 + + +[ changes ] + ++ Neglected to mention with the previous release that the video library has + been removed from the default download. This decreases the size of the + Processing download by about 20%. In addition, it was only the video + library for the platform being downloaded, and with the return of cross- + platform application export, that could cause sadness. To use the video + library, use the "Add Library..." menu and select it from the list. + + +. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . + + PROCESSING 3.0a1 (REV 0228) - 26 July 2014 Kicking off the 3.0 release process. The focus for Processing 3 is improving diff --git a/core/todo.txt b/core/todo.txt index a3ff01848..ecf2cc743 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -1,6 +1,14 @@ 0229 core (3.0a2) +pulls +X implement A and a (elliptical arcs) +X https://github.com/processing/processing/issues/169 +X http://code.google.com/p/processing/issues/detail?id=130 +X https://github.com/processing/processing/pull/2659 +X done with an approximation, if re-saving this will destroy data (docs) + + applet removal _ remove Applet as base class _ performance issues on OS X (might be threading due to Applet) @@ -418,8 +426,6 @@ _ for PShape, need to be able to set the origin (flash people) CORE / PShapeSVG -_ implement A and a (elliptical arcs) -_ http://code.google.com/p/processing/issues/detail?id=130 _ implement support for SVG gradients from Inkscape _ http://code.google.com/p/processing/issues/detail?id=1142 _ need to handle