Package barsuift.simLife

Examples of barsuift.simLife.Percent


     */
    public BasicSun(SunState state) throws IllegalArgumentException {
        if (state == null) {
            throw new IllegalArgumentException("Null sun state");
        }
        luminosity = new Percent(state.getLuminosity());
        riseAngle = new Percent(state.getRiseAngle());
        zenithAngle = new Percent(state.getZenithAngle());
        sun3D = new BasicSun3D(this);
    }
View Full Code Here


     * <code>collectedEnergy= sunLuminosity * leafEfficiency * 10</code>
     *
     * @return the collected energy
     */
    private void collectSolarEnergy() {
        Percent lightRate = universe.getEnvironment().getSun().getLuminosity();
        BigDecimal solarEnergyRateCollected = getEfficiency().getValue().multiply(lightRate.getValue());
        BigDecimal energyCollected = solarEnergyRateCollected.multiply(MAX_ENERGY_TO_COLLECT).multiply(
                new BigDecimal(leaf3D.getArea()));
        BigDecimal energyCollectedForLeaf = energyCollected.multiply(ENERGY_RATIO_TO_KEEP.getValue());
        BigDecimal freeEnergyCollected = energyCollected.subtract(energyCollectedForLeaf);
        state.setEnergy(state.getEnergy().add(energyCollectedForLeaf));
View Full Code Here

        mockSun = null;
        display = null;
    }

    public void testInit() {
        assertEquals(mockSun.getWhiteFactor(), new Percent(display.getSlider().getValue()));
        mockSun.setWhiteFactor(new Percent(90));
        display = new SunColorPanel(mockSun);
        assertEquals(mockSun.getWhiteFactor(), new Percent(display.getSlider().getValue()));
        mockSun.setWhiteFactor(new Percent(80));
        display = new SunColorPanel(mockSun);
        assertEquals(mockSun.getWhiteFactor(), new Percent(display.getSlider().getValue()));
        mockSun.setWhiteFactor(new Percent(100));
        display = new SunColorPanel(mockSun);
        assertEquals(mockSun.getWhiteFactor(), new Percent(display.getSlider().getValue()));
    }
View Full Code Here

        display = new SunColorPanel(mockSun);
        assertEquals(mockSun.getWhiteFactor(), new Percent(display.getSlider().getValue()));
    }

    public void testUpdate() {
        assertEquals(mockSun.getWhiteFactor(), new Percent(display.getSlider().getValue()));
        mockSun.setWhiteFactor(new Percent(90));
        display.update(mockSun, SunUpdateCode.color);
        assertEquals(mockSun.getWhiteFactor(), new Percent(display.getSlider().getValue()));
        mockSun.setWhiteFactor(new Percent(90));
        display.update(mockSun, SunUpdateCode.color);
        assertEquals(mockSun.getWhiteFactor(), new Percent(display.getSlider().getValue()));
        mockSun.setWhiteFactor(new Percent(100));
        display.update(mockSun, SunUpdateCode.color);
        assertEquals(mockSun.getWhiteFactor(), new Percent(display.getSlider().getValue()));
    }
View Full Code Here

        mockSun = null;
        display = null;
    }

    public void testInit() {
        assertEquals(mockSun.getZenithAngle(), new Percent(display.getSlider().getValue()));
        mockSun.setZenithAngle(new Percent(90));
        display = new SunZenithPanel(mockSun);
        assertEquals(mockSun.getZenithAngle(), new Percent(display.getSlider().getValue()));
        mockSun.setZenithAngle(new Percent(80));
        display = new SunZenithPanel(mockSun);
        assertEquals(mockSun.getZenithAngle(), new Percent(display.getSlider().getValue()));
        mockSun.setZenithAngle(new Percent(100));
        display = new SunZenithPanel(mockSun);
        assertEquals(mockSun.getZenithAngle(), new Percent(display.getSlider().getValue()));
    }
View Full Code Here

        sun = null;
        display = null;
    }

    public void testInit() {
        assertEquals(sun.getRiseAngle(), new Percent(display.getSlider().getValue()));
        sun.setRiseAngle(new Percent(90));
        display = new SunRisePanel(sun);
        assertEquals(sun.getRiseAngle(), new Percent(display.getSlider().getValue()));
        sun.setRiseAngle(new Percent(80));
        display = new SunRisePanel(sun);
        assertEquals(sun.getRiseAngle(), new Percent(display.getSlider().getValue()));
        sun.setRiseAngle(new Percent(100));
        display = new SunRisePanel(sun);
        assertEquals(sun.getRiseAngle(), new Percent(display.getSlider().getValue()));
    }
View Full Code Here

        mockSun = null;
        display = null;
    }

    public void testInit() {
        assertEquals(mockSun.getLuminosity(), new Percent(display.getSlider().getValue()));
        mockSun.setLuminosity(new Percent(90));
        display = new SunLuminosityPanel(mockSun);
        assertEquals(mockSun.getLuminosity(), new Percent(display.getSlider().getValue()));
        mockSun.setLuminosity(new Percent(80));
        display = new SunLuminosityPanel(mockSun);
        assertEquals(mockSun.getLuminosity(), new Percent(display.getSlider().getValue()));
        mockSun.setLuminosity(new Percent(100));
        display = new SunLuminosityPanel(mockSun);
        assertEquals(mockSun.getLuminosity(), new Percent(display.getSlider().getValue()));
    }
View Full Code Here

        assertEquals(mockSun.getLuminosity(), new Percent(display.getSlider().getValue()));
    }

    public void testUpdate() {
        assertEquals("Sun luminosity (100.00%)", display.getLabel().getText());
        assertEquals(mockSun.getLuminosity(), new Percent(display.getSlider().getValue()));
        mockSun.setLuminosity(new Percent(90));
        display.update(mockSun, SunUpdateCode.luminosity);
        assertEquals("Sun luminosity (90.00%)", display.getLabel().getText());
        assertEquals(mockSun.getLuminosity(), new Percent(display.getSlider().getValue()));
        mockSun.setLuminosity(new Percent(90));
        display.update(mockSun, SunUpdateCode.luminosity);
        assertEquals("Sun luminosity (90.00%)", display.getLabel().getText());
        assertEquals(mockSun.getLuminosity(), new Percent(display.getSlider().getValue()));
        mockSun.setLuminosity(new Percent(100));
        display.update(mockSun, SunUpdateCode.luminosity);
        assertEquals("Sun luminosity (100.00%)", display.getLabel().getText());
        assertEquals(mockSun.getLuminosity(), new Percent(display.getSlider().getValue()));
    }
View Full Code Here

        BasicTreeLeaf3D leaf3D = new BasicTreeLeaf3D(mockUniverse3D, leaf3DState, mockLeaf);
        assertEquals(leaf3DState, leaf3D.getState());
    }

    public void testObservers() {
        mockLeaf.setEfficiency(new Percent(80));
        BasicTreeLeaf3D leaf3D = new BasicTreeLeaf3D(mockUniverse3D, leaf3DState, mockLeaf);
        assertEquals(1, mockLeaf.countObservers());
        // check the observer is the leaf3D
        mockLeaf.deleteObserver(leaf3D);
        assertEquals(0, mockLeaf.countObservers());
View Full Code Here

        mockLeaf.deleteObserver(leaf3D);
        assertEquals(0, mockLeaf.countObservers());
    }

    public void testAppearance() {
        mockLeaf.setEfficiency(new Percent(80));
        BasicTreeLeaf3D leaf3D = new BasicTreeLeaf3D(mockUniverse3D, leaf3DState, mockLeaf);
        CompilerHelper.compile(leaf3D.getBranchGroup());
        Shape3D leafShape3D = (Shape3D) leaf3D.getBranchGroup().getChild(0);

        Color3f expectedColor = new Color3f(ColorConstants.brownYellow);
        expectedColor.interpolate(ColorConstants.green, 0.8f);
        ColorTestHelper.testColorFromMaterial(leafShape3D.getAppearance(), expectedColor, new Color3f(0.05f, 0.05f,
                0.05f), new Color3f(0.15f, 0.15f, 0.15f));

        // check the leaves are not culled (transparent) when seen from behind
        assertEquals(PolygonAttributes.CULL_NONE, leafShape3D.getAppearance().getPolygonAttributes().getCullFace());

        mockLeaf.setEfficiency(new Percent(75));
        leaf3D.update(mockLeaf, LeafUpdateCode.efficiency);

        // check that the color has changed as expected
        expectedColor = new Color3f(ColorConstants.brownYellow);
        expectedColor.interpolate(ColorConstants.green, 0.75f);
        ColorTestHelper.testColorFromMaterial(leafShape3D.getAppearance(), expectedColor, new Color3f(0.05f, 0.05f,
                0.05f), new Color3f(0.15f, 0.15f, 0.15f));


        mockLeaf.setEfficiency(new Percent(60));
        leaf3D.update(mockLeaf, null);

        // check that the color has NOT changed as expected, because the update code is not the appropriate one
        expectedColor = new Color3f(ColorConstants.brownYellow);
        expectedColor.interpolate(ColorConstants.green, 0.75f); // 75%, not 60%
View Full Code Here

TOP

Related Classes of barsuift.simLife.Percent

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.