source: java/main/src/main/java/com/framsticks/leftovers/f0/NeuroClass.java @ 84

Last change on this file since 84 was 84, checked in by psniegowski, 11 years ago

HIGHLIGHTS:

  • simplification of entities management model
  • cleanup around params (improve hierarchy)
  • migrate from JUnit to TestNG
  • introduce FEST to automatically test GUI
  • improve slider control
  • loosen synchronization between gui tree and backend representation
  • and many other bug fixes

NOTICE:

  • a great many of lines is changed only because of substituting spaces with tabs

CHANGELOG (oldest changes at the bottom):

Some cleaning after fix found.

Fix bug with tree.

More changes with TreeNodes?.

Finally fix issue with tree.

Improve gui tree management.

Decouple update of values from fetch request in gui.

Minor changes.

Minor changes.

Minor change.

Change Path construction wording.

More fixes to SliderControl?.

Fix SliderControl?.

Fix SliderControl?.

Minor improvement.

Several changes.

Make NumberParam? a generic class.

Add robot to the gui test.

Setup common testing logging configuration.

Remove Parameters class.

Remove entityOwner from Parameters.

Move name out from Parameters class.

Move configuration to after the construction.

Simplify observers and endpoints.

Remove superfluous configureEntity overrides.

Add dependency on fest-swing-testng.

Use FEST for final print test.

Use FEST for more concise and readable assertions.

Divide test of F0Parser into multiple methods.

Migrate to TestNG

Minor change.

Change convention from LOGGER to log.

Fix reporting of errors during controls filling.

Bound maximal height of SliderControl?.

Minor improvements.

Improve tooltips for controls.

Also use Delimeted in more places.

Move static control utilities to Gui.

Rename package gui.components to controls.

Some cleaning in controls.

Improve Param classes placing.

Move ValueParam?, PrimitiveParam? and CompositeParam? one package up.

Improve ParamBuilder?.

Move getDef to ValueParam? and PrimitiveParam?.

Move getMax and getDef to ValueParam?.

Move getMin to ValueParam?.

Upgrade to laters apache commons versions.

Use filterInstanceof extensively.

Add instanceof filters.

Make ValueParam? in many places of Param.

Place assertions about ValueParam?.

Add ValueParam?

Rename ValueParam? to PrimitiveParam?

Minor changes.

Several improvements to params types.

Add NumberParam?.

Add TextControl? component.

Add .swp files to .gitignore

Greatly improved slider component.

Some improvements.

Make Param.reassign return also a state.

Add IterableIterator?.

Several changes.

  • Move util classes to better packages.
  • Remove warnings from eclim.

Several improvements.

Fix bug with BooleanParam?.

Some experiments with visualization.

Another fix to panel management.

Improve panel management.

Some refactorization around panels.

Add root class for panel.

File size: 4.6 KB
Line 
1package com.framsticks.leftovers.f0;
2
3import java.util.Arrays;
4
5import com.framsticks.params.FramsClass;
6import com.framsticks.params.Param;
7
8/**
9 * The Class NeuroClass.
10 */
11public 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}
Note: See TracBrowser for help on using the repository browser.