Ignore:
Timestamp:
06/26/13 13:27:31 (11 years ago)
Author:
psniegowski
Message:

HIGHLIGHTS:

  • use java annotations to mark classes and fields to be used when:
    • using java classes with ReflectionAccess? to represent remote objects with FramsClass? description found by "info ..." requests
    • to build up FramsClass? representation of objects not present at remote server
  • allow using primitive types (instead of wraping counterparts) in reflected classes
  • rework FramsClass? creation process (add FramsClassBuilder?)
  • add more tests

CHANGELOG:
Prepare model.World class.

Minor change.

Use primitive types for Genotype and Creature classes.

Use primitive types in model.Neuro* classes.

Use primitive types in model.Joint* classes.

Use primitive types in model.Part* classes.

Fix primitive values.

Extract FramsClassBuilder?.

Add tests of Model classes.

More fixes.

Refactorize out ParamCandidate?.

Several fixes.

Fix all regressions after introducing annotations.

Use annotations throughout the project.

Add exception classes.

Improve creation of FramsClass?.

More changes.

Many changes regarding annotations.

Annotate classes in com.framsticks.model package.

Remove manual FramsClass? constructor.

Construct FramsClass? for Creature. Add test.

Add default values to the ParamAnnotation?.

Add ParamBuilderTest? and ParamAnnotation?.

Add FramsClassAnnotation?.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • java/main/src/main/java/com/framsticks/model/Model.java

    r84 r86  
    11package com.framsticks.model;
    22
     3import com.framsticks.params.annotations.FramsClassAnnotation;
     4import com.framsticks.params.annotations.ParamAnnotation;
    35import com.framsticks.util.lang.Casting;
    46import com.framsticks.util.lang.Containers;
     
    1416 * Author: Piotr Śniegowski
    1517 */
     18@FramsClassAnnotation(id = "m")
    1619public class Model {
    1720
    1821        private final static Logger log = Logger.getLogger(Model.class);
    1922
    20         public Double startingEnergy;
    21         public Double getEnerg0() { return startingEnergy; }
    22         public void setEnerg0(Double energ0) { startingEnergy = energ0; }
     23        @ParamAnnotation(id = "se")
     24        public double startingEnergy;
    2325
    24         public Double getSe() { return startingEnergy; }
    25         public void setSe(Double se) { startingEnergy = se; }
     26        @ParamAnnotation
     27        public double getEnerg0() { return startingEnergy; }
     28        @ParamAnnotation
     29        public void setEnerg0(double energ0) { startingEnergy = energ0; }
    2630
    27         /** Vstyle */
     31
     32        @ParamAnnotation(id = "Vstyle")
    2833        public String visualizationStyle;
    29         public String getVstyle() { return visualizationStyle; }
    30         public void setVstyle(String Vstyle) { visualizationStyle = Vstyle; }
    3134
     35        @ParamAnnotation
    3236        public final List<Part> parts = new ArrayList<Part>();
     37
     38        @ParamAnnotation
    3339        public final List<Joint> joints = new ArrayList<Joint>();
     40
     41        @ParamAnnotation
    3442        public final List<NeuroDef> neurodefs = new ArrayList<NeuroDef>();
    3543
    36         public Double getNumparts() { return (double)parts.size(); }
    37         public Double getNumjoints() { return (double)joints.size(); }
    38         public Double getNumneurons() { return (double)neurodefs.size(); }
     44        //TODO: why those methods returns and accepts doubles?
     45        @ParamAnnotation
     46        public double getNumparts() { return (double)parts.size(); }
     47        @ParamAnnotation
     48        public double getNumjoints() { return (double)joints.size(); }
     49        @ParamAnnotation
     50        public double getNumneurons() { return (double)neurodefs.size(); }
    3951
    4052        //this is impossible to use, because numparts field is marked as readonly
    41         public void setNumparts(Double numparts) { Containers.resizeList(parts, (int) (double) numparts); }
    42         public void setNumjoints(Double numjoints) { Containers.resizeList(joints, (int)(double)numjoints); }
    43         public void setNumneurons(Double numneurons) { Containers.resizeList(neurodefs, (int)(double)numneurons); }
     53        @ParamAnnotation
     54        public void setNumparts(double numparts) { Containers.resizeList(parts, (int) (double) numparts); }
     55        @ParamAnnotation
     56        public void setNumjoints(double numjoints) { Containers.resizeList(joints, (int)(double)numjoints); }
     57        @ParamAnnotation
     58        public void setNumneurons(double numneurons) { Containers.resizeList(neurodefs, (int)(double)numneurons); }
    4459
    4560        public List<Part> getParts() { return parts; }
     
    7893                for (Joint j : f0Genotype.getJoints()) {
    7994                        /** based on c++ Joint::attachToParts*/
    80                         Part p1 = f0Genotype.parts.get(j.getP1());
    81                         Part p2 = f0Genotype.parts.get(j.getP2());
     95                        Part p1 = f0Genotype.parts.get(j.part1);
     96                        Part p2 = f0Genotype.parts.get(j.part2);
    8297                        assert p1 != null && p2 != null;
    8398                        Orientation o = new Orientation().rotate(j.getRotation());
Note: See TracChangeset for help on using the changeset viewer.