| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2562,13 +2562,13 @@ protected void applyPreferences() { | |||
| 2562 | 2562 | UDPTweakClient tweakClient; | |
| 2563 | 2563 | ||
| 2564 | 2564 | ||
| 2565 | - public void startInteractiveMode() { | ||
| 2565 | + protected void startInteractiveMode() { | ||
| 2566 | 2566 | getJavaTextArea().startInteractiveMode(); | |
| 2567 | 2567 | } | |
| 2568 | 2568 | ||
| 2569 | 2569 | ||
| 2570 | 2570 | //public void stopInteractiveMode(ArrayList<Handle> handles[]) { | |
| 2571 | - public void stopInteractiveMode(List<List<Handle>> handles) { | ||
| 2571 | + protected void stopInteractiveMode(List<List<Handle>> handles) { | ||
| 2572 | 2572 | tweakClient.shutdown(); | |
| 2573 | 2573 | getJavaTextArea().stopInteractiveMode(); | |
| 2574 | 2574 | ||
@@ -2639,7 +2639,7 @@ public void stopInteractiveMode(List<List<Handle>> handles) { | |||
| 2639 | 2639 | } | |
| 2640 | 2640 | ||
| 2641 | 2641 | ||
| 2642 | - public void updateInterface(List<List<Handle>> handles, | ||
| 2642 | + protected void updateInterface(List<List<Handle>> handles, | ||
| 2643 | 2643 | List<List<ColorControlBox>> colorBoxes) { | |
| 2644 | 2644 | getJavaTextArea().updateInterface(handles, colorBoxes); | |
| 2645 | 2645 | } | |
@@ -2659,7 +2659,7 @@ static private boolean[] getModifiedTabs(List<List<Handle>> handles) { | |||
| 2659 | 2659 | } | |
| 2660 | 2660 | ||
| 2661 | 2661 | ||
| 2662 | - public void initBaseCode() { | ||
| 2662 | + protected void initBaseCode() { | ||
| 2663 | 2663 | SketchCode[] code = sketch.getCode(); | |
| 2664 | 2664 | ||
| 2665 | 2665 | baseCode = new String[code.length]; | |
@@ -2669,7 +2669,7 @@ public void initBaseCode() { | |||
| 2669 | 2669 | } | |
| 2670 | 2670 | ||
| 2671 | 2671 | ||
| 2672 | - public void initEditorCode(List<List<Handle>> handles, boolean withSpaces) { | ||
| 2672 | + protected void initEditorCode(List<List<Handle>> handles, boolean withSpaces) { | ||
| 2673 | 2673 | SketchCode[] sketchCode = sketch.getCode(); | |
| 2674 | 2674 | for (int tab=0; tab<baseCode.length; tab++) { | |
| 2675 | 2675 | // beautify the numbers | |
@@ -2740,7 +2740,7 @@ private void removeSpacesFromCode() { | |||
| 2740 | 2740 | * these variables and handle update messages. | |
| 2741 | 2741 | */ | |
| 2742 | 2742 | //public boolean automateSketch(Sketch sketch, ArrayList<Handle> handles[]) | |
| 2743 | - public boolean automateSketch(Sketch sketch, List<List<Handle>> handles) { | ||
| 2743 | + protected boolean automateSketch(Sketch sketch, List<List<Handle>> handles) { | ||
| 2744 | 2744 | SketchCode[] code = sketch.getCode(); | |
| 2745 | 2745 | ||
| 2746 | 2746 | if (code.length < 1) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -39,7 +39,7 @@ public class SketchParser { | |||
| 39 | 39 | ||
| 40 | 40 | List<List<Range>> scientificNotations; | |
| 41 | 41 | ||
| 42 | - | ||
| 42 | + | ||
| 43 | 43 | public SketchParser(String[] codeTabs, boolean requiresComment) { | |
| 44 | 44 | this.codeTabs = codeTabs; | |
| 45 | 45 | this.requiresComment = requiresComment; | |
@@ -57,15 +57,13 @@ public SketchParser(String[] codeTabs, boolean requiresComment) { | |||
| 57 | 57 | createColorBoxes(); | |
| 58 | 58 | createColorBoxesForLights(); | |
| 59 | 59 | ||
| 60 | - /* If there is more than one color mode per context, | ||
| 61 | - * allow only hex and webcolors in this context. | ||
| 62 | - * Currently there is no notion of order of execution so we | ||
| 63 | - * cannot know which color mode relate to a color. | ||
| 64 | - */ | ||
| 60 | + // If there is more than one color mode per context, allow only hex and | ||
| 61 | + // webcolors in this context. Currently there is no notion of order of | ||
| 62 | + // execution so we cannot know which color mode relate to a color. | ||
| 65 | 63 | handleMultipleColorModes(); | |
| 66 | 64 | } | |
| 67 | 65 | ||
| 68 | - | ||
| 66 | + | ||
| 69 | 67 | public void addAllNumbers() { | |
| 70 | 68 | //allHandles = new ArrayList[codeTabs.length]; // moved inside addAllDecimalNumbers | |
| 71 | 69 | addAllDecimalNumbers(); | |
@@ -78,7 +76,7 @@ public void addAllNumbers() { | |||
| 78 | 76 | } | |
| 79 | 77 | } | |
| 80 | 78 | ||
| 81 | - | ||
| 79 | + | ||
| 82 | 80 | /** | |
| 83 | 81 | * Get a list of all the numbers in this sketch | |
| 84 | 82 | * @return | |
@@ -89,13 +87,13 @@ private void addAllDecimalNumbers() { | |||
| 89 | 87 | ||
| 90 | 88 | // for every number found: | |
| 91 | 89 | // save its type (int/float), name, value and position in code. | |
| 92 | - | ||
| 90 | + | ||
| 93 | 91 | Pattern p = Pattern.compile("[\\[\\{<>(),\\t\\s\\+\\-\\/\\*^%!|&=?:~]\\d+\\.?\\d*"); | |
| 94 | 92 | for (int i = 0; i < codeTabs.length; i++) { | |
| 95 | 93 | //allHandles[i] = new ArrayList<Handle>(); | |
| 96 | 94 | List<Handle> handles = new ArrayList<Handle>(); | |
| 97 | 95 | allHandles.add(handles); | |
| 98 | - | ||
| 96 | + | ||
| 99 | 97 | String c = codeTabs[i]; | |
| 100 | 98 | Matcher m = p.matcher(c); | |
| 101 | 99 | ||
@@ -157,41 +155,37 @@ private void addAllDecimalNumbers() { | |||
| 157 | 155 | ||
| 158 | 156 | int line = countLines(c.substring(0, start)) - 1; // zero based | |
| 159 | 157 | String value = c.substring(start, end); | |
| 160 | - //value | ||
| 161 | - if (value.contains(".") || forceFloat) { | ||
| 162 | - // consider this as a float | ||
| 163 | - String name = varPrefix + "_float[" + floatVarCount +"]"; | ||
| 164 | - int decimalDigits = getNumDigitsAfterPoint(value); | ||
| 165 | - handles.add(new Handle("float", name, floatVarCount, value, i, line, start, end, decimalDigits)); | ||
| 166 | - floatVarCount++; | ||
| 167 | - } else { | ||
| 168 | - // consider this as an int | ||
| 169 | - String name = varPrefix + "_int[" + intVarCount +"]"; | ||
| 170 | - handles.add(new Handle("int", name, intVarCount, value, i, line, start, end, 0)); | ||
| 171 | - intVarCount++; | ||
| 172 | - } | ||
| 173 | - } | ||
| 174 | - } | ||
| 175 | - } | ||
| 158 | + if (value.contains(".") || forceFloat) { | ||
| 159 | + // consider this as a float | ||
| 160 | + String name = varPrefix + "_float[" + floatVarCount +"]"; | ||
| 161 | + int decimalDigits = getNumDigitsAfterPoint(value); | ||
| 162 | + handles.add(new Handle("float", name, floatVarCount, value, i, line, start, end, decimalDigits)); | ||
| 163 | + floatVarCount++; | ||
| 164 | + } else { | ||
| 165 | + // consider this as an int | ||
| 166 | + String name = varPrefix + "_int[" + intVarCount +"]"; | ||
| 167 | + handles.add(new Handle("int", name, intVarCount, value, i, line, start, end, 0)); | ||
| 168 | + intVarCount++; | ||
| 169 | + } | ||
| 170 | + } | ||
| 171 | + } | ||
| 172 | + } | ||
| 173 | + | ||
| 176 | 174 | ||
| 177 | 175 | /** | |
| 178 | 176 | * Get a list of all the hexadecimal numbers in the code | |
| 179 | 177 | * @return | |
| 180 | 178 | * list of all hexadecimal numbers in the sketch | |
| 181 | 179 | */ | |
| 182 | - private void addAllHexNumbers() | ||
| 183 | - { | ||
| 184 | - /* for every number found: | ||
| 185 | - * save its type (int/float), name, value and position in code. | ||
| 186 | - */ | ||
| 180 | + private void addAllHexNumbers() { | ||
| 181 | + // for every number found: | ||
| 182 | + // save its type (int/float), name, value and position in code. | ||
| 187 | 183 | Pattern p = Pattern.compile("[\\[\\{<>(),\\t\\s\\+\\-\\/\\*^%!|&=?:~]0x[A-Fa-f0-9]+"); | |
| 188 | - for (int i=0; i<codeTabs.length; i++) | ||
| 189 | - { | ||
| 184 | + for (int i = 0; i < codeTabs.length; i++) { | ||
| 190 | 185 | String c = codeTabs[i]; | |
| 191 | 186 | Matcher m = p.matcher(c); | |
| 192 | 187 | ||
| 193 | - while (m.find()) | ||
| 194 | - { | ||
| 188 | + while (m.find()) { | ||
| 195 | 189 | int start = m.start()+1; | |
| 196 | 190 | int end = m.end(); | |
| 197 | 191 | ||
@@ -230,17 +224,16 @@ private void addAllHexNumbers() | |||
| 230 | 224 | } | |
| 231 | 225 | allHandles.get(i).add(handle); | |
| 232 | 226 | intVarCount++; | |
| 233 | - } | ||
| 234 | - } | ||
| 235 | - } | ||
| 227 | + } | ||
| 228 | + } | ||
| 229 | + } | ||
| 230 | + | ||
| 236 | 231 | ||
| 237 | 232 | /** | |
| 238 | 233 | * Get a list of all the webcolors (#) numbers in the code | |
| 239 | - * @return | ||
| 240 | 234 | * list of all hexadecimal numbers in the sketch | |
| 241 | 235 | */ | |
| 242 | - private void addAllWebColorNumbers() | ||
| 243 | - { | ||
| 236 | + private void addAllWebColorNumbers() { | ||
| 244 | 237 | Pattern p = Pattern.compile("#[A-Fa-f0-9]{6}"); | |
| 245 | 238 | for (int i=0; i<codeTabs.length; i++) | |
| 246 | 239 | { | |
@@ -325,17 +318,17 @@ private ArrayList<ColorMode> findAllColorModes() { | |||
| 325 | 318 | return modes; | |
| 326 | 319 | } | |
| 327 | 320 | ||
| 328 | - | ||
| 321 | + | ||
| 329 | 322 | private void createColorBoxes() { | |
| 330 | 323 | colorBoxes = new ArrayList<>(); | |
| 331 | 324 | // search tab for the functions: 'color', 'fill', 'stroke', 'background', 'tint' | |
| 332 | 325 | Pattern p = Pattern.compile("color\\(|color\\s\\(|fill[\\(\\s]|stroke[\\(\\s]|background[\\(\\s]|tint[\\(\\s]"); | |
| 333 | - | ||
| 326 | + | ||
| 334 | 327 | for (int i = 0; i < codeTabs.length; i++) { | |
| 335 | 328 | //colorBoxes[i] = new ArrayList<ColorControlBox>(); | |
| 336 | 329 | List<ColorControlBox> colorBox = new ArrayList<ColorControlBox>(); | |
| 337 | 330 | colorBoxes.add(colorBox); | |
| 338 | - | ||
| 331 | + | ||
| 339 | 332 | String tab = codeTabs[i]; | |
| 340 | 333 | Matcher m = p.matcher(tab); | |
| 341 | 334 | ||
@@ -412,7 +405,7 @@ private void createColorBoxesForLights() { | |||
| 412 | 405 | Pattern p = Pattern.compile("ambientLight[\\(\\s]|directionalLight[\\(\\s]"+ | |
| 413 | 406 | "|pointLight[\\(\\s]|spotLight[\\(\\s]|lightSpecular[\\(\\s]"+ | |
| 414 | 407 | "|specular[\\(\\s]|ambient[\\(\\s]|emissive[\\(\\s]"); | |
| 415 | - | ||
| 408 | + | ||
| 416 | 409 | for (int i=0; i<codeTabs.length; i++) { | |
| 417 | 410 | String tab = codeTabs[i]; | |
| 418 | 411 | Matcher m = p.matcher(tab); | |
@@ -548,7 +541,7 @@ private void handleMultipleColorModes() | |||
| 548 | 541 | } | |
| 549 | 542 | } | |
| 550 | 543 | ||
| 551 | - | ||
| 544 | + | ||
| 552 | 545 | public List<List<Range>> getAllScientificNotations() { | |
| 553 | 546 | //ArrayList<Range> notations[] = new ArrayList[codeTabs.length]; | |
| 554 | 547 | List<List<Range>> notations = new ArrayList<>(); | |
@@ -578,7 +571,7 @@ public static boolean containsTweakComment(String[] codeTabs) { | |||
| 578 | 571 | } | |
| 579 | 572 | return false; | |
| 580 | 573 | } | |
| 581 | - | ||
| 574 | + | ||
| 582 | 575 | ||
| 583 | 576 | static public boolean lineHasTweakComment(int pos, String code) { | |
| 584 | 577 | int lineEnd = getEndOfLine(pos, code); | |
@@ -589,7 +582,7 @@ static public boolean lineHasTweakComment(int pos, String code) { | |||
| 589 | 582 | String line = code.substring(pos, lineEnd); | |
| 590 | 583 | return hasTweakComment(line); | |
| 591 | 584 | } | |
| 592 | - | ||
| 585 | + | ||
| 593 | 586 | ||
| 594 | 587 | static private boolean hasTweakComment(String code) { | |
| 595 | 588 | Pattern p = Pattern.compile("\\/\\/.*tweak", Pattern.CASE_INSENSITIVE); | |
@@ -613,7 +606,7 @@ static private boolean isNegativeSign(int pos, String code) { | |||
| 613 | 606 | return false; | |
| 614 | 607 | } | |
| 615 | 608 | ||
| 616 | - | ||
| 609 | + | ||
| 617 | 610 | static private int getNumDigitsAfterPoint(String number) { | |
| 618 | 611 | Pattern p = Pattern.compile("\\.[0-9]+"); | |
| 619 | 612 | Matcher m = p.matcher(number); | |
@@ -624,13 +617,13 @@ static private int getNumDigitsAfterPoint(String number) { | |||
| 624 | 617 | return 0; | |
| 625 | 618 | } | |
| 626 | 619 | ||
| 627 | - | ||
| 620 | + | ||
| 628 | 621 | static private int countLines(String str) { | |
| 629 | 622 | String[] lines = str.split("\r\n|\n\r|\n|\r"); | |
| 630 | 623 | return lines.length; | |
| 631 | 624 | } | |
| 632 | 625 | ||
| 633 | - | ||
| 626 | + | ||
| 634 | 627 | /** | |
| 635 | 628 | * Are we inside a string? (TODO: ignore comments in the code) | |
| 636 | 629 | * @param pos | |
@@ -721,12 +714,12 @@ static private boolean isInComment(int pos, String code) { | |||
| 721 | 714 | return false; | |
| 722 | 715 | } | |
| 723 | 716 | ||
| 724 | - | ||
| 717 | + | ||
| 725 | 718 | static private int getEndOfLine(int pos, String code) { | |
| 726 | 719 | return code.indexOf("\n", pos); | |
| 727 | 720 | } | |
| 728 | 721 | ||
| 729 | - | ||
| 722 | + | ||
| 730 | 723 | static private int getStartOfLine(int pos, String code) { | |
| 731 | 724 | while (pos >= 0) { | |
| 732 | 725 | if (code.charAt(pos) == '\n') { | |
@@ -738,7 +731,7 @@ static private int getStartOfLine(int pos, String code) { | |||
| 738 | 731 | return 0; | |
| 739 | 732 | } | |
| 740 | 733 | ||
| 741 | - | ||
| 734 | + | ||
| 742 | 735 | /** returns the object of the function starting at 'pos' | |
| 743 | 736 | * | |
| 744 | 737 | * @param pos | |
@@ -769,7 +762,7 @@ else if (readObject) { | |||
| 769 | 762 | return obj; | |
| 770 | 763 | } | |
| 771 | 764 | ||
| 772 | - | ||
| 765 | + | ||
| 773 | 766 | static public int getSetupStart(String code) { | |
| 774 | 767 | Pattern p = Pattern.compile("void[\\s\\t\\r\\n]*setup[\\s\\t]*\\(\\)[\\s\\t\\r\\n]*\\{"); | |
| 775 | 768 | Matcher m = p.matcher(code); | |
@@ -786,7 +779,7 @@ static public int getSetupStart(String code) { | |||
| 786 | 779 | // return str.substring(0, start) + put + str.substring(end, str.length()); | |
| 787 | 780 | // } | |
| 788 | 781 | ||
| 789 | - | ||
| 782 | + | ||
| 790 | 783 | class Range { | |
| 791 | 784 | int start; | |
| 792 | 785 | int end; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments