source: java/main/src/main/java/com/framsticks/params/PrimitiveParam.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: 2.0 KB
Line 
1package com.framsticks.params;
2
3
4/**
5 * @author Piotr Sniegowski
6 */
7public abstract class PrimitiveParam extends ValueParam {
8
9        /** The minimum allowed value of parameter. */
10        protected Object min;
11
12        /** The maximum allowed value of parameter. */
13        protected Object max;
14
15        /** The default value of parameter. */
16        protected Object def;
17
18        public void save(SinkInterface sink, Object value) {
19                sink.print(value);
20        }
21
22        protected <T> T tryCastAndReturn(Object value, Class<T> type) {
23                if (value == null)
24                        return null;
25                try {
26                        return type.cast(value);
27                } catch (ClassCastException e) {
28                        throw new ClassCastException("property \"" + name
29                                        + "\" type is \"" + value.getClass().getName()
30                                        + "\", not \"" + type.getName() + "\"");
31                }
32        }
33
34        /**
35         * Gets the minimum value of parameter.
36         *
37         * @param <T> the generic getType which must be correctly specified by user
38         * @param type the getType of variable, can be checked by
39         * @return the minimum allowed value of parameter
40         * @throws ClassCastException the class cast exception, thrown when given getType is incorrect
41         */
42        public <T> T getMin(Class<T> type) {
43                return tryCastAndReturn(min, type);
44        }
45
46        /**
47         * Gets the maximum value of parameter.
48         *
49         * @param <T> the generic getType which must be correctly specified by user
50         * @param type the getType of variable, can be checked by {@link #getStorageType()}
51         * @return the maximum allowed value of parameter
52         * @throws ClassCastException the class cast exception, thrown when given getType is incorrect
53         */
54        public <T> T getMax(Class<T> type) {
55                return tryCastAndReturn(max, type);
56        }
57
58        /**
59         * Gets the default value of parameter.
60         *
61         * @param <T> the generic getType which must be correctly specified by user
62         * @param type the getType of variable, can be checked by {@link #getStorageType()}
63         * @return the default value of parameter
64         * @throws ClassCastException the class cast exception, thrown when given getType is incorrect
65         */
66        public <T> T getDef(Class<T> type) throws ClassCastException {
67                return tryCastAndReturn(def, type);
68        }
69}
Note: See TracBrowser for help on using the repository browser.