Search in sources :

Example 1 with ConcUnitSystem

use of org.vcell.model.bngl.BngUnitSystem.ConcUnitSystem in project vcell by virtualcell.

the class BNGLUnitsPanel method getUnits.

public BngUnitSystem getUnits() {
    if (getSelectedButtonText(buttonGroup) == null) {
        // better to return a default than null
        return new BngUnitSystem(BngUnitOrigin.DEFAULT);
    }
    if (getSelectedButtonText(buttonGroup).equals(concentrations)) {
        double volume = Double.parseDouble(cVolumeSize.getText());
        ConcUnitSystem cus = ConcUnitSystem.values()[0];
        for (ConcUnitSystem s : ConcUnitSystem.values()) {
            if (s.description.equals(concentrationUnitsCombo.getSelectedItem().toString())) {
                cus = s;
                break;
            }
        }
        TimeUnitSystem tus = TimeUnitSystem.values()[0];
        for (TimeUnitSystem s : TimeUnitSystem.values()) {
            if (s.description.equals(cTimeUnitsCombo.getSelectedItem().toString())) {
                tus = s;
                break;
            }
        }
        return BngUnitSystem.createAsConcentration(BngUnitOrigin.USER, volume, cus, tus);
    } else {
        // molecules
        // we know for sure it's valid double
        double volume = Double.parseDouble(mVolumeSize.getText());
        VolumeUnitSystem vus = VolumeUnitSystem.values()[0];
        for (VolumeUnitSystem s : VolumeUnitSystem.values()) {
            if (s.description.equals(mVolumeUnitsCombo.getSelectedItem().toString())) {
                vus = s;
                break;
            }
        }
        TimeUnitSystem tus = TimeUnitSystem.values()[0];
        for (TimeUnitSystem s : TimeUnitSystem.values()) {
            if (s.description.equals(mTimeUnitsCombo.getSelectedItem().toString())) {
                tus = s;
                break;
            }
        }
        return BngUnitSystem.createAsMolecules(BngUnitOrigin.USER, volume, vus, tus);
    }
}
Also used : VolumeUnitSystem(org.vcell.model.bngl.BngUnitSystem.VolumeUnitSystem) BngUnitSystem(org.vcell.model.bngl.BngUnitSystem) TimeUnitSystem(org.vcell.model.bngl.BngUnitSystem.TimeUnitSystem) ConcUnitSystem(org.vcell.model.bngl.BngUnitSystem.ConcUnitSystem)

Aggregations

BngUnitSystem (org.vcell.model.bngl.BngUnitSystem)1 ConcUnitSystem (org.vcell.model.bngl.BngUnitSystem.ConcUnitSystem)1 TimeUnitSystem (org.vcell.model.bngl.BngUnitSystem.TimeUnitSystem)1 VolumeUnitSystem (org.vcell.model.bngl.BngUnitSystem.VolumeUnitSystem)1