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

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

HIGHLIGHTS:

  • upgrade to Java 7
    • use try-multi-catch clauses
    • use try-with-resources were appropriate
  • configure FindBugs? (use mvn site and then navigate in browser to the report)
    • remove most bugs found
  • parametrize Dispatching environment (Dispatcher, RunAt?) to enforce more control on the place of closures actual call

CHANGELOG:
Rework FavouritesXMLFactory.

FindBugs?. Thread start.

FindBugs?. Minor change.

FindBugs?. Iterate over entrySet.

FindBugs?. Various.

FindBug?.

FindBug?. Encoding.

FindBug?. Final fields.

FindBug?.

Remove synchronization bug in ClientConnection?.

Experiments with findbugs.

Finish parametrization.

Make RunAt? an abstract class.

More changes in parametrization.

More changes in parametrizing dispatching.

Several changes to parametrize tasks.

Rename Runnable to RunAt?.

Add specific framsticks Runnable.

Add JSR305 (annotations).

Add findbugs reporting.

More improvements to ParamBuilder? wording.

Make FramsClass? accept also ParamBuilder?.

Change wording of ParamBuilder?.

Change wording of Request creation.

Use Java 7 exception catch syntax.

Add ScopeEnd? class.

Upgrade to Java 7.

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 glyph.
19         */
20        private int[] symbolGlyph;
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 symbolGlyph the symbol glymph
74         */
75        public NeuroClass(FramsClass framsClass, int prefInputs,
76                                          int prefOutput, int prefLocation, int visualHints,
77                                          int[] symbolGlyph) {
78                this.framsClass = framsClass;
79                this.prefInputs = prefInputs;
80                this.prefOutput = prefOutput;
81                this.prefLocation = prefLocation;
82                this.visualHints = visualHints;
83                this.symbolGlyph = (symbolGlyph == null ? null : Arrays.copyOf(symbolGlyph, symbolGlyph.length));
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.
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() )
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() {
154                return symbolGlyph;
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) {
166                symbolGlyph = data;
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();
184                sb.append("NeuroClass [getId=").append(framsClass.getId())
185                                .append(", getName=").append(framsClass.getName())
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)
192                                .append(", symbolGlymph=").append(Arrays.toString(symbolGlyph));
193
194                sb.append(", paramList={");
195                for (int i = 0; i < framsClass.getParamCount(); i++) {
196                        sb.append("\n");
197                        sb.append(framsClass.getParamEntry(i, Param.class).toString());
198                }
199                sb.append("\n}]");
200                return sb.toString();
201        }
202}
Note: See TracBrowser for help on using the repository browser.