[77] | 1 | package com.framsticks.leftovers.f0; |
---|
| 2 | |
---|
| 3 | import java.util.Arrays; |
---|
| 4 | |
---|
| 5 | import com.framsticks.params.FramsClass; |
---|
[84] | 6 | import com.framsticks.params.Param; |
---|
[77] | 7 | |
---|
| 8 | /** |
---|
| 9 | * The Class NeuroClass. |
---|
| 10 | */ |
---|
| 11 | public class NeuroClass { |
---|
| 12 | /* |
---|
| 13 | public String name, longname, description, code, icon; |
---|
| 14 | public Integer prefinputs, prefoutput, preflocation, vhints; |
---|
| 15 | */ |
---|
| 16 | |
---|
[84] | 17 | /** |
---|
[85] | 18 | * The symbol glyph. |
---|
[84] | 19 | */ |
---|
[85] | 20 | private int[] symbolGlyph; |
---|
[84] | 21 | |
---|
| 22 | /** |
---|
| 23 | * The pref inputs. |
---|
| 24 | */ |
---|
[77] | 25 | private int prefInputs; |
---|
[84] | 26 | |
---|
| 27 | /** |
---|
| 28 | * The pref output. |
---|
| 29 | */ |
---|
[77] | 30 | private int prefOutput; |
---|
[84] | 31 | |
---|
| 32 | /** |
---|
| 33 | * The pref location. |
---|
| 34 | */ |
---|
[77] | 35 | private int prefLocation; |
---|
[84] | 36 | |
---|
| 37 | /** |
---|
| 38 | * The param entry list. |
---|
| 39 | */ |
---|
[77] | 40 | private FramsClass framsClass; |
---|
[84] | 41 | |
---|
| 42 | /** |
---|
| 43 | * The visual hints. |
---|
| 44 | */ |
---|
[77] | 45 | private int visualHints; |
---|
| 46 | |
---|
| 47 | /** |
---|
| 48 | * long description. |
---|
| 49 | * |
---|
| 50 | * @return the description |
---|
| 51 | */ |
---|
| 52 | String getDescription() { |
---|
| 53 | return framsClass.getDescription(); |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | /** |
---|
| 57 | * class getId (short getName). |
---|
| 58 | * |
---|
| 59 | * @return the getId |
---|
| 60 | */ |
---|
| 61 | String getId() { |
---|
| 62 | return framsClass.getId(); |
---|
| 63 | } |
---|
| 64 | |
---|
| 65 | /** |
---|
| 66 | * Instantiates a new neuro class. |
---|
| 67 | * |
---|
[84] | 68 | * @param framsClass the param entry list |
---|
| 69 | * @param prefInputs the pref inputs |
---|
| 70 | * @param prefOutput the pref output |
---|
[77] | 71 | * @param prefLocation the pref location |
---|
[84] | 72 | * @param visualHints the visual hints |
---|
[85] | 73 | * @param symbolGlyph the symbol glymph |
---|
[77] | 74 | */ |
---|
| 75 | public NeuroClass(FramsClass framsClass, int prefInputs, |
---|
[84] | 76 | int prefOutput, int prefLocation, int visualHints, |
---|
[85] | 77 | int[] symbolGlyph) { |
---|
[77] | 78 | this.framsClass = framsClass; |
---|
| 79 | this.prefInputs = prefInputs; |
---|
| 80 | this.prefOutput = prefOutput; |
---|
| 81 | this.prefLocation = prefLocation; |
---|
| 82 | this.visualHints = visualHints; |
---|
[85] | 83 | this.symbolGlyph = (symbolGlyph == null ? null : Arrays.copyOf(symbolGlyph, symbolGlyph.length)); |
---|
[77] | 84 | } |
---|
| 85 | |
---|
| 86 | /** |
---|
| 87 | * human friendly getName, eg. "Neuron","Link","Gyroscope" |
---|
| 88 | * |
---|
| 89 | * @return the getName |
---|
| 90 | */ |
---|
| 91 | String getName() { |
---|
| 92 | return framsClass.getName(); |
---|
| 93 | } |
---|
| 94 | |
---|
| 95 | /** |
---|
| 96 | * NeuroClass specific properties, recognized by all neurons of this class. |
---|
| 97 | * |
---|
| 98 | * @return the param entry list |
---|
| 99 | */ |
---|
| 100 | FramsClass getFramsClass() { |
---|
| 101 | return framsClass; |
---|
| 102 | } |
---|
| 103 | |
---|
| 104 | /** |
---|
| 105 | * Gets the param tab. |
---|
| 106 | * |
---|
| 107 | * @return the param tab |
---|
| 108 | */ |
---|
| 109 | FramsClass getParamTab() { |
---|
| 110 | return framsClass; |
---|
| 111 | } |
---|
| 112 | |
---|
| 113 | /** |
---|
| 114 | * preferred number of inputs, -1 = no preference (any number will go). |
---|
| 115 | * extra inputs may be ignored by the object (depends on the class). |
---|
| 116 | * |
---|
| 117 | * @return the preferred inputs |
---|
| 118 | */ |
---|
| 119 | int getPreferredInputs() { |
---|
| 120 | return prefInputs; |
---|
| 121 | } |
---|
| 122 | |
---|
| 123 | /** |
---|
| 124 | * Gets the preferred location. |
---|
| 125 | * |
---|
| 126 | * @return 0 if the object doesn't need any assignment to the body element. |
---|
[84] | 127 | * 1 = it likes to be attached to the Part ( @see |
---|
| 128 | * Neuro::attachToPart() ) |
---|
| 129 | * 2 = the object prefers to have the Joint ( @see |
---|
| 130 | * Neuro::attachToJoint() ) |
---|
[77] | 131 | */ |
---|
| 132 | int getPreferredLocation() { |
---|
| 133 | return prefLocation; |
---|
| 134 | } |
---|
| 135 | |
---|
| 136 | /** |
---|
| 137 | * Gets the preferred output. |
---|
| 138 | * |
---|
| 139 | * @return 0 if this object doesn't provide useful output signal. |
---|
| 140 | */ |
---|
| 141 | int getPreferredOutput() { |
---|
| 142 | return prefOutput; |
---|
| 143 | } |
---|
| 144 | |
---|
| 145 | /** |
---|
| 146 | * vector drawing to be used in neuro net diagram. interpretation: { LEN = |
---|
| 147 | * datalength (excluding this number) NL = number_of_lines line#1 -> NS = |
---|
| 148 | * number_of_segments, x1,y1, x2,y2, ... xNS-1,yNS-1, ... line#NL -> NS = |
---|
| 149 | * number_of_segments, x1,y1, x2,y2, ... xNS-1,yNS-1, } |
---|
| 150 | * |
---|
| 151 | * @return the symbol glyph |
---|
| 152 | */ |
---|
| 153 | int[] getSymbolGlyph() { |
---|
[85] | 154 | return symbolGlyph; |
---|
[77] | 155 | } |
---|
| 156 | |
---|
| 157 | /** |
---|
| 158 | * vector drawing to be used in neuro net diagram. interpretation: { LEN = |
---|
| 159 | * datalength (excluding this number) NL = number_of_lines line#1 -> NS = |
---|
| 160 | * number_of_segments, x1,y1, x2,y2, ... xNS-1,yNS-1, ... line#NL -> NS = |
---|
| 161 | * number_of_segments, x1,y1, x2,y2, ... xNS-1,yNS-1, } |
---|
| 162 | * |
---|
| 163 | * @param data the new symbol glyph |
---|
| 164 | */ |
---|
| 165 | void setSymbolGlyph(int[] data) { |
---|
[85] | 166 | symbolGlyph = data; |
---|
[77] | 167 | } |
---|
| 168 | |
---|
| 169 | /** |
---|
| 170 | * additional information about how the neuron should be drawn used by |
---|
| 171 | * structure view (and maybe some other components). return value is defined |
---|
| 172 | * by the enum Hint |
---|
| 173 | * |
---|
| 174 | * @return the visual hints |
---|
| 175 | */ |
---|
| 176 | int getVisualHints() { |
---|
| 177 | return visualHints; |
---|
| 178 | } |
---|
| 179 | |
---|
| 180 | |
---|
| 181 | @Override |
---|
| 182 | public String toString() { |
---|
| 183 | StringBuilder sb = new StringBuilder(); |
---|
[84] | 184 | sb.append("NeuroClass [getId=").append(framsClass.getId()) |
---|
[87] | 185 | .append(", name=").append(framsClass.getName()) |
---|
[84] | 186 | .append(", description=").append(framsClass.getDescription()) |
---|
| 187 | .append(", groups#=").append(framsClass.getGroupCount()) |
---|
| 188 | .append(", prefInputs=").append(prefInputs) |
---|
| 189 | .append(", prefOutput=").append(prefOutput) |
---|
| 190 | .append(", prefLocation=").append(prefLocation) |
---|
| 191 | .append(", visualHints=").append(visualHints) |
---|
[85] | 192 | .append(", symbolGlymph=").append(Arrays.toString(symbolGlyph)); |
---|
[84] | 193 | |
---|
| 194 | sb.append(", paramList={"); |
---|
[77] | 195 | for (int i = 0; i < framsClass.getParamCount(); i++) { |
---|
| 196 | sb.append("\n"); |
---|
[84] | 197 | sb.append(framsClass.getParamEntry(i, Param.class).toString()); |
---|
[77] | 198 | } |
---|
| 199 | sb.append("\n}]"); |
---|
| 200 | return sb.toString(); |
---|
| 201 | } |
---|
| 202 | } |
---|