Ignore:
Timestamp:
07/14/13 23:20:04 (11 years ago)
Author:
psniegowski
Message:

HIGHLIGHTS:

  • improve tree side notes
  • improve GUI layout
  • add foldable list of occured events to EventControl?
  • improve automatic type conversion in proxy listeners
  • implement several Access functionalities as algorithms independent of Access type
  • introduce draft base classes for distributed experiments
  • automatically register dependant Java classes to FramsClass? registry
  • add testing prime experiment and configuration
  • simplify and improve task dispatching

CHANGELOG:
Improve task dispatching in RemoteTree?.

GUI no longer hangs on connection problems.

Make all dispatchers joinables.

Refactorize Thread dispatcher.

Remove Task and PeriodicTask?.

Use Java utilities in those situations.

Reworking tasks dispatching.

Fix bug in EventControl? listener dispatching.

Minor improvements.

Add testing configuration for ExternalProcess? in GUI.

More improvement to prime.

Support for USERREADONLY in GUI.

Add that flag to various params in Java classes.

Remove redundant register clauses from several FramsClassAnnotations?.

Automatically gather and register dependant classes.

Add configuration for prime.

Improve Simulator class.

Add prime.xml configuration.

Introduce draft Experiment and Simulator classes.

Add prime experiment tests.

Enclose typical map with listeners into SimpleUniqueList?.

Needfile works in GUI.

Improve needfile handling in Browser.

More improvement with NeedFile?.

Implementing needfile.

Update test.

Rename ChangeEvent? to TestChangeEvent?.

Automatic argument type search in RemoteTree? listeners.

MultiParamLoader? uses AccessProvider?. By default old implementation
enclosed in AccessStash? or Registry.

Minor changes.

Rename SourceInterface? to Source.

Also improve toString of File and ListSource?.

Remove unused SimpleSource? class.

Add clearing in HistoryControl?.

Show entries in table at EventControl?.

Improve EventControl?.

Add listeners registration to EventControl?.

Add foldable table to HistoryControl?.

Add control row to Procedure and Event controls.

Improve layout of controls.

Another minor change to gui layout.

Minor improvement in the SliderControl?.

Minor changes.

Move ReflectionAccess?.Backend to separate file.

It was to cluttered.

Cleanup in ReflectionAccess?.

Move setMin, setMax, setDef to AccessOperations?.

Extract loading operation into AccessOperations?.

Append Framsticks to name of UnsupportedOperationException?.

The java.lang.UnsupportedOperationException? was shadowing this class.

Rename params.Util to params.ParamsUtil?.

Several improvements.

Minor changes.

Implement revert functionality.

Improve local changes management.

Minor improvement.

Remove methods rendered superfluous after SideNoteKey? improvement.

Improve SideNoteKey?.

It is now generic type, so explicit type specification at
call site is no more needed.

Introduce SideNoteKey? interface.

Only Objects implementing that key may be used as side note keys.

Minor improvements.

Use strings instead of ValueControls? in several gui mappings.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • java/main/src/main/java/com/framsticks/params/SimpleAbstractAccess.java

    r100 r101  
    44import static com.framsticks.util.lang.Containers.filterInstanceof;
    55
    6 import org.apache.logging.log4j.Logger;
    7 import org.apache.logging.log4j.LogManager;
    86
    97import com.framsticks.params.types.ObjectParam;
    108import com.framsticks.util.FramsticksException;
    11 import static com.framsticks.params.SetStateFlags.*;
    129
    1310/**
     
    2320 * @author Piotr Sniegowski
    2421 */
    25 public abstract class SimpleAbstractAccess implements Access {
    26 
    27         private final static Logger log = LogManager.getLogger(SimpleAbstractAccess.class.getName());
     22public abstract class SimpleAbstractAccess implements ObjectAccess {
    2823
    2924        protected final FramsClass framsClass;
     
    4035                return framsClass;
    4136        }
    42 
    43         /**
    44          * Simple String key, value class.
    45          */
    46         public static class Entry {
    47 
    48                 public final String key;
    49                 public final String value;
    50 
    51                 public Entry(String key, String value) {
    52                         this.key = key;
    53                         this.value = value;
    54                 }
    55 
    56                 @Override
    57                 public String toString() {
    58                         return key + " = " + value;
    59                 }
    60         }
    61 
    6237
    6338        @Override
     
    129104
    130105        @Override
    131         public void setDefault(boolean numericOnly) {
    132                 for (int i = 0; i < framsClass.getParamCount(); i++) {
    133                         setDefault(i, numericOnly);
    134                 }
    135         }
    136 
    137         @Override
    138         public void setDefault(int i, boolean numericOnly) {
    139                 ValueParam entry = framsClass.getParamEntry(i, ValueParam.class);
    140                 if ((entry != null)     && (!numericOnly || entry.isNumeric())) {
    141                         set(i, entry.getDef(entry.getStorageType()));
    142                 }
    143         }
    144 
    145         @Override
    146         public void setMin() {
    147                 for (int i = 0; i < framsClass.getParamCount(); i++) {
    148                         setMin(i);
    149                 }
    150         }
    151 
    152         @Override
    153         public void setMin(int i) {
    154                 PrimitiveParam<?> entry = framsClass.getParamEntry(i, PrimitiveParam.class);
    155                 Object min = entry.getMin(entry.getStorageType());
    156                 if (min != null) {
    157                         set(i, min);
    158                 }
    159         }
    160 
    161         @Override
    162         public void setMax() {
    163                 for (int i = 0; i < framsClass.getParamCount(); i++) {
    164                         setMax(i);
    165                 }
    166         }
    167 
    168         @Override
    169         public void setMax(int i) {
    170                 PrimitiveParam<?> entry = framsClass.getParamEntry(i, PrimitiveParam.class);
    171                 Object max = entry.getMax(entry.getStorageType());
    172                 if (max != null) {
    173                         set(i, max);
    174                 }
    175         }
    176 
    177         @Override
    178106        public void save(SinkInterface sink) {
    179107                assert framsClass != null;
     
    189117                }
    190118                sink.breakLine();
    191         }
    192 
    193         private static Entry readEntry(SourceInterface source) {
    194 
    195                 String line;
    196                 String key = null;
    197                 StringBuilder value = null;
    198                 while ((line = source.readLine()) != null) {
    199                         if (key == null) {
    200                                 int colonIndex = line.indexOf(':');
    201                                 if (colonIndex == -1) {
    202                                         return null;
    203                                 }
    204                                 key = line.substring(0, colonIndex);
    205                                 String inlineValue = line.substring(colonIndex + 1);
    206 
    207 
    208                                 if (!inlineValue.startsWith("~")) {
    209                                         return new Entry(key, inlineValue);
    210                                 }
    211                                 value = new StringBuilder();
    212                                 value.append(inlineValue.substring(1));
    213                                 continue;
    214                         }
    215                         if (value.length() != 0) {
    216                                 value.append(System.getProperty("line.separator"));
    217                         }
    218                         if (line.endsWith("~") && !line.endsWith("\\~")) {
    219                                 value.append(line.substring(0, line.length() - 1));
    220                                 return new Entry(key, value.toString().replaceAll("\\\\~", "~"));
    221                         }
    222                         value.append(line);
    223                 }
    224                 return null;
    225         }
    226 
    227         @Override
    228         public void load(SourceInterface source) {
    229                 //TODO not clearing values, because get from manager gives only fields, not children
    230                 //this.clearValues();
    231 
    232                 Entry entry;
    233                 while ((entry = readEntry(source)) != null) {
    234                         Param param = getParam(entry.key);
    235                         if (param == null) {
    236                                 throw new FramsticksException().msg("param not found in access").arg("name", entry.key).arg("access", this);
    237                         }
    238                         if (!(param instanceof ValueParam)) {
    239                                 throw new FramsticksException().msg("param is not a value param").arg("param", param).arg("access", this);
    240                         }
    241                         if ((param.getFlags() & ParamFlags.DONTLOAD) == 0) {
    242                                 int retFlags = this.set((ValueParam) param, entry.value);
    243                                 if ((retFlags & (PSET_HITMIN | PSET_HITMAX)) != 0) {
    244                                         String which = ((retFlags & PSET_HITMIN) != 0) ? "small" : "big";
    245                                         log.warn("value of key '{}' was too {}, adjusted", entry.key, which);
    246                                 }
    247                         }
    248                 }
    249119        }
    250120
     
    266136        }
    267137
    268         /*
    269         protected <T extends Comparable<T>> int setAndCut(Param param, Object value, Class<T> type) {
    270                 int flags = 0;
    271                 T val = type.cast(value);
    272                 T min = param.getMin(type);
    273                 T max = param.getMax(type);
    274                 if (min != null && val.compareTo(min) < 0) {
    275                         val = min;
    276                         flags |= Flags.PSET_HITMIN;
    277                 }
    278                 if (max != null && val.compareTo(max) > 0) {
    279                         val = max;
    280                         flags |= Flags.PSET_HITMAX;
    281                 }
    282                 internalSet(param, val);
    283                 return flags;
    284         }*/
    285 
    286 
    287138        @Override
    288139        public ParamBuilder buildParam(ParamBuilder builder) {
Note: See TracChangeset for help on using the changeset viewer.