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