Package barsuift.simLife

Examples of barsuift.simLife.PercentState


    }

    public void testCreateSunState() {
        SunStateFactory factory = new SunStateFactory();
        SunState sunState = factory.createSunState();
        PercentState luminosity = sunState.getLuminosity();
        assertEquals(1.00, luminosity.getValue().doubleValue());
        PercentState riseAngle = sunState.getRiseAngle();
        assertEquals(0.25, riseAngle.getValue().doubleValue());
        PercentState zenithAngle = sunState.getZenithAngle();
        assertEquals(0.50, zenithAngle.getValue().doubleValue());
    }
View Full Code Here


        assertEquals(new BigDecimal(0), leaf.collectFreeEnergy());
        assertEquals(16, leaf.getAge());
    }

    public void testSpendTime2() {
        leafState.setEfficiency(new PercentState(new BigDecimal("0.999999")));
        leaf = new BasicTreeLeaf(universe, leafState);
        observerHelper.addObserver(leaf);

        assertEquals(0, observerHelper.nbUpdated());
View Full Code Here

        assertEquals(new BigDecimal(0), leaf.collectFreeEnergy());
        assertEquals(16, leaf.getAge());
    }

    public void testSpendTime3() {
        leafState.setEfficiency(new PercentState(new BigDecimal("0.991")));
        leaf = new BasicTreeLeaf(universe, leafState);
        observerHelper.addObserver(leaf);

        assertEquals(0, observerHelper.nbUpdated());
View Full Code Here

     * <li>riseAngle = 25%</li>
     * <li>zenithAngle = 50%</li>
     * </ul>
     */
    public SunState createSunState() {
        PercentState luminosity = new PercentState(new BigDecimal("1.00"));
        PercentState riseAngle = new PercentState(new BigDecimal("0.25"));
        PercentState zenithAngle = new PercentState(new BigDecimal("0.50"));
        return new SunState(luminosity, riseAngle, zenithAngle);
    }
View Full Code Here

    private void age() {
        state.setAge(state.getAge() + 1);
        setChanged();
        notifyObservers(LeafUpdateCode.age);
        BigDecimal newEfficiency = getEfficiency().getValue().multiply(AGING_EFFICIENCY_DECREASE.getValue());
        state.setEfficiency(new PercentState(newEfficiency));
        setChanged();
        notifyObservers(LeafUpdateCode.efficiency);
    }
View Full Code Here

    private void improveEfficiency() {
        BigDecimal maxEfficiencyToAdd = new BigDecimal(1).subtract(getEfficiency().getValue());
        // use all the energy, up to the max efficiency that can be added to get 100
        BigDecimal efficiencyToAdd = maxEfficiencyToAdd.min(getEnergy().movePointLeft(2));
        state.setEfficiency(new PercentState(getEfficiency().getValue().add(efficiencyToAdd).setScale(10,
                RoundingMode.HALF_DOWN)));
        setChanged();
        notifyObservers(LeafUpdateCode.efficiency);
        state.setEnergy(getEnergy().subtract(efficiencyToAdd.movePointRight(2)).setScale(10, RoundingMode.HALF_DOWN));
        setChanged();
View Full Code Here

     * <li>age between 0 and 100</li>
     * <li>random 3D state</li>
     * </ul>
     */
    public TreeLeafState createRandomTreeLeafState(Point3d leafAttachPoint) {
        PercentState efficiency = new PercentState(PercentHelper.getDecimalValue(Randomizer.randomBetween(90, 100)));
        int age = Randomizer.randomBetween(0, 100);
        BigDecimal energy = new BigDecimal(Randomizer.randomBetween(0, 100));
        BigDecimal freeEnergy = new BigDecimal(Randomizer.randomBetween(0, 50));
        TreeLeaf3DStateFactory leaf3DStateFactory = new TreeLeaf3DStateFactory();
        TreeLeaf3DState leaf3dState = leaf3DStateFactory.createRandomTreeLeaf3DState(leafAttachPoint);
View Full Code Here

     * <li>age = 0</li>
     * <li>new 3D state</li>
     * </ul>
     */
    public TreeLeafState createNewTreeLeafState(Point3d leafAttachPoint, BigDecimal energy) {
        PercentState efficiency = new PercentState(PercentHelper.getDecimalValue(Randomizer.randomBetween(90, 100)));
        int age = 0;
        BigDecimal freeEnergy = new BigDecimal(0);
        TreeLeaf3DStateFactory leaf3DStateFactory = new TreeLeaf3DStateFactory();
        TreeLeaf3DState leaf3dState = leaf3DStateFactory.createNewTreeLeaf3DState(leafAttachPoint);
        return new TreeLeafState(LEAF_COUNT++, age, energy, freeEnergy, efficiency, leaf3dState);
View Full Code Here

    private PercentState zenithAngle;

    public SunState() {
        super();
        this.luminosity = new PercentState();
        this.riseAngle = new PercentState();
        this.zenithAngle = new PercentState();
    }
View Full Code Here

        this.zenithAngle = zenithAngle;
    }

    public SunState(SunState copy) {
        super();
        this.luminosity = new PercentState(copy.getLuminosity());
        this.riseAngle = new PercentState(copy.getRiseAngle());
        this.zenithAngle = new PercentState(copy.getZenithAngle());
    }
View Full Code Here

TOP

Related Classes of barsuift.simLife.PercentState

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.