- Timestamp:
- 01/10/14 16:04:39 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/gui/Help.java
r678 r680 17 17 18 18 // modifiers 19 public static final int none = 0, control = 1, shift = 2, drag = 4 ; // TODO: add mod for click+hold ???19 public static final int none = 0, control = 1, shift = 2, drag = 4, hold = 8; 20 20 private static final String[] modifiers = { "", "^", "+", "^+", "d", "d^", "d+", "d^+" }; 21 21 … … 27 27 28 28 /** 29 * 30 * @param array 31 * @param max 32 * @return int[] containing all positive values NOT in array, below max 29 * Set each index of $array to reference $value 33 30 */ 34 private static final int[] invert(int[] array, int max) { 35 int c = 0; 36 // count the values within the range from the array 37 for(int i : array) { 38 if(i < max && i >= 0) { 39 c++; 40 } 31 private static final void fill(String[] array, String value) { 32 for(int i = 0; i < array.length; i++) { 33 array[i] = value; 41 34 } 42 // make a new array of the correct size43 int[] ret = new int[max - c];44 int p = 0;45 // populate the array46 for(int i = 0; i < max; i++) {47 boolean add = true;48 for(int j = 0; j < array.length; j++) {49 if(i == array[j]) {50 add = false;51 break;52 }53 }54 if(add) {55 ret[p++] = i;56 }57 }58 return ret;59 35 } 60 36 61 private static final void fill(String[] array, String value) { 62 for(int i = 0; i < array.length; i++) { 63 array[i] = value; 64 } 65 } 66 37 /** 38 * Set each index of $array to reference an array filled with $value 39 */ 67 40 private static final void fill(String[][] array, String value) { 68 array[0] = Arrays.copyOf(array[0], array[0].length);41 array[0] = new String[array[0].length]; 69 42 fill(array[0], value); 70 43 for(int i = 1; i < array.length; i++) { … … 73 46 } 74 47 75 private static final void fill(String[] array, int[] indices, String value, boolean invert) { 76 if(invert) { 77 indices = invert(indices, array.length); 78 } 79 for(int i = 0; i < indices.length; i++) { 80 array[indices[i]] = value; 48 /** 49 * Set the indices of $array that have $indexBit set (or not set if $invert) to reference $value 50 */ 51 private static final void fill(String[] array, int indexBit, String value, boolean invert, boolean lazy) { 52 for(int i = 0; i < array.length; i++) { 53 if((!lazy && ((i & indexBit) == indexBit && !invert) || ((i & indexBit) == 0 && invert)) || 54 (lazy && ((i & indexBit) != 0 && !invert) || ((i & indexBit) != indexBit && invert))){ 55 array[i] = value; 56 } 81 57 } 82 58 } 83 59 84 private static final void fill(String[] array, int indexBit, String value, boolean invert) { 60 /** 61 * Calls fill(array, indexBit, value, false, false) 62 */ 63 private static final void fill(String[] array, int indexBit, String value) { 64 fill(array, indexBit, value, false, false); 65 } 66 67 /** 68 * Set the indices of $array that have $indexBit set (or not set if $invert) to reference an array filled with $value 69 */ 70 private static final void fill(String[][] array, int indexBit, String value, boolean invert, boolean lazy) { 85 71 for(int i = 0; i < array.length; i++) { 86 72 if((!lazy && ((i & indexBit) == indexBit && !invert) || ((i & indexBit) == 0 && invert)) || 73 (lazy && ((i & indexBit) != 0 && !invert) || ((i & indexBit) != indexBit && invert))){ 74 fill(array[i] = Arrays.copyOf(array[i], array[i].length), value); 75 } 87 76 } 88 77 } 89 78 90 private static final void fill(String[][] array, int[] indices, String value, boolean invert) { 91 if(invert) { 92 indices = invert(indices, array.length); 93 } 94 array[indices[0]] = Arrays.copyOf(array[indices[0]], array[indices[0]].length); 95 fill(array[indices[0]], value); 96 for(int i = 1; i < indices.length; i++) { 97 array[indices[i]] = array[indices[0]]; 79 /** 80 * Calls fill(array, indexBit, value, false, false) 81 */ 82 private static final void fill(String[][] array, int indexBit, String value) { 83 fill(array, indexBit, value, false, false); 84 } 85 86 /** 87 * For each array at the indices of $array that have $indexBit set (or not set if $invert), 88 * set each index that has $indexBit2 set (or not set if $invert) to reference $value 89 */ 90 private static final void fill(String[][] array, int indexBit, int indexBit2, String value, boolean invert, boolean invert2, boolean lazy, boolean lazy2) { 91 for(int i = 0; i < array.length; i++) { 92 if((!lazy && ((i & indexBit) == indexBit && !invert) || ((i & indexBit) == 0 && invert)) || 93 (lazy && ((i & indexBit) != 0 && !invert) || ((i & indexBit) != indexBit && invert))) { 94 fill(array[i] = Arrays.copyOf(array[i], array[i].length), indexBit2, value, invert2, lazy2); 95 } 98 96 } 99 97 } 100 98 101 private static final void fill(String[][] array, int[] indices, int[] indices2, String value, boolean invert, boolean invert2) { 102 if(indices != null) { 103 if(invert) { 104 indices = invert(indices, array.length); 105 } 106 // fill the correct indices 107 array[indices[0]] = Arrays.copyOf(array[indices[0]], array[indices[0]].length); 108 fill(array[indices[0]], indices2, value, invert2); 109 for(int i = 1; i < indices.length; i++) { 110 array[indices[i]] = array[indices[0]]; 111 } 112 } else { 113 // fill all indices 114 array[0] = Arrays.copyOf(array[0], array[0].length); 115 fill(array[0], indices2, value, invert2); 116 for(int i = 1; i < array.length; i++) { 117 array[i] = array[0]; 118 } 119 } 99 /** 100 * Calls fill(array, indexBit, indexBit2, value, false, false, false, false) 101 */ 102 private static final void fill(String[][] array, int indexBit, int indexBit2, String value) { 103 fill(array, indexBit, indexBit2, value, false, false, false, false); 120 104 } 121 105 … … 124 108 static { 125 109 fill(statusText[background][left], "Go back"); 126 fill(statusText[background][left], new int[] { control, control | shift, shift }, "Go forward", false);127 fill(statusText[background][left], new int[] { drag, control | drag, shift | drag, control | shift | drag }, null, false); // no action for dragging unless shift down128 fill(statusText[background][left], new int[] { control | shift | drag, shift | drag }, new int[] { panning, panning | action }, "Drag to pan", false, false);110 fill(statusText[background][left], control | shift, "Go forward", false, true); 111 fill(statusText[background][left], drag, null); // no action for dragging unless shift down 112 fill(statusText[background][left], shift | drag, panning, "Drag to pan"); 129 113 fill(statusText[background][middle], "Create arrow"); 130 fill(statusText[background][middle], new int[] { drag, control | drag, shift | drag, control | shift | drag }, null, false); // no action for dragging114 fill(statusText[background][middle], drag, null); // no action for dragging 131 115 fill(statusText[background][right], "Create rectangle"); 132 fill(statusText[background][right], new int[] { drag, control | drag, shift | drag, control | shift | drag }, null, false); // no action for dragging133 fill(statusText[background][left | middle], null); 116 fill(statusText[background][right], drag, null); // no action for dragging 117 fill(statusText[background][left | middle], null); // no action for left + middle 134 118 fill(statusText[background][left | right], "Auto format"); 135 119 fill(statusText[background][middle | right], "Undo"); 136 120 137 121 fill(statusText[item][left], "Follow link"); 138 fill(statusText[item][left], new int[] { control, control | shift }, new int[] { action, panning | action }, "Run action", true, false);139 fill(statusText[item][left], new int[] { drag, control | drag, shift | drag, control | shift | drag }, null, false); // no action for dragging122 fill(statusText[item][left], control, action, "Run action", true, false, false, false); 123 fill(statusText[item][left], drag, null); // no action for dragging 140 124 fill(statusText[item][middle], "Pickup"); 141 fill(statusText[item][middle], new int[] { drag, control | drag, shift | drag, control | shift | drag }, null, false); // no action for dragging125 fill(statusText[item][middle], drag, null); // no action for dragging 142 126 fill(statusText[item][right], "Copy"); 143 fill(statusText[item][right], new int[] { drag, control | drag, shift | drag, control | shift | drag }, null, false); // no action for dragging127 fill(statusText[item][right], drag, null); // no action for dragging 144 128 fill(statusText[item][left | middle], null); // no action for left + middle 145 129 fill(statusText[item][left | right], "Extract attributes");
Note:
See TracChangeset
for help on using the changeset viewer.