当前位置: 首页>>代码示例>>Java>>正文


Java UnitDefinition.getUnitCount方法代码示例

本文整理汇总了Java中org.sbml.jsbml.UnitDefinition.getUnitCount方法的典型用法代码示例。如果您正苦于以下问题:Java UnitDefinition.getUnitCount方法的具体用法?Java UnitDefinition.getUnitCount怎么用?Java UnitDefinition.getUnitCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.sbml.jsbml.UnitDefinition的用法示例。


在下文中一共展示了UnitDefinition.getUnitCount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createUnitsChoices

import org.sbml.jsbml.UnitDefinition; //导入方法依赖的package包/类
public static JComboBox createUnitsChoices(BioModel bioModel) {
	JComboBox specUnits = new JComboBox();
	specUnits.addItem("( none )");
	for (int i = 0; i < bioModel.getSBMLDocument().getModel().getUnitDefinitionCount(); i++) {
		UnitDefinition unit = bioModel.getSBMLDocument().getModel().getUnitDefinition(i);
		if ((unit.getUnitCount() == 1)
				&& (unit.getUnit(0).isMole() || unit.getUnit(0).isItem() || unit.getUnit(0).isGram() || unit.getUnit(0).isKilogram())
				&& (unit.getUnit(0).getExponent() == 1)) {
			if (!(bioModel.getSBMLDocument().getLevel() < 3 && unit.getId().equals("substance"))) {
				specUnits.addItem(unit.getId());
			}
		}
	}
	if (bioModel.getSBMLDocument().getLevel() < 3) {
		specUnits.addItem("substance");
	}
	String[] unitIds = { "dimensionless", "gram", "item", "kilogram", "mole" };
	for (int i = 0; i < unitIds.length; i++) {
		specUnits.addItem(unitIds[i]);
	}
	return specUnits;
}
 
开发者ID:MyersResearchGroup,项目名称:iBioSim,代码行数:23,代码来源:MySpecies.java

示例2: definitionToXml

import org.sbml.jsbml.UnitDefinition; //导入方法依赖的package包/类
private static String definitionToXml(UnitDefinition definition) {
	if (definition.getUnitCount() == 0) {
		return NO_UNIT;
	}

	SBMLDocument doc = new SBMLDocument(LEVEL, VERSION);
	Model model = doc.createModel("ID");

	model.addUnitDefinition(definition.clone());

	ByteArrayOutputStream out = new ByteArrayOutputStream();

	try {
		SBMLWriter.write(doc, out, "test", "1.0", ' ', (short) 0);

		String xml = out.toString(StandardCharsets.UTF_8.name());
		String from = "<listOfUnitDefinitions>";
		String to = "</listOfUnitDefinitions>";

		return xml.substring(xml.indexOf(from) + from.length(), xml.indexOf(to)).replace("\n", "");
	} catch (SBMLException | XMLStreamException | UnsupportedEncodingException e) {
		e.printStackTrace();
		return null;
	}
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:26,代码来源:PmmUnit.java

示例3: checkUnitsInRateRule

import org.sbml.jsbml.UnitDefinition; //导入方法依赖的package包/类
public static boolean checkUnitsInRateRule(SBMLDocument document, Rule rule)
{
	UnitDefinition unitDef = rule.getDerivedUnitDefinition();
	UnitDefinition unitDefVar;
	Species species = document.getModel().getSpecies(getVariable(rule));
	Compartment compartment = document.getModel().getCompartment(getVariable(rule));
	Parameter parameter = document.getModel().getParameter(getVariable(rule));
	if (species != null)
	{
		unitDefVar = species.getDerivedUnitDefinition();
	}
	else if (compartment != null)
	{
		unitDefVar = compartment.getDerivedUnitDefinition();
	}
	else
	{
		unitDefVar = parameter.getDerivedUnitDefinition();
	}
	if (document.getModel().getUnitDefinition("time") != null)
	{
		UnitDefinition timeUnitDef = document.getModel().getUnitDefinition("time");
		for (int i = 0; i < timeUnitDef.getUnitCount(); i++)
		{
			Unit timeUnit = timeUnitDef.getUnit(i);
			Unit recTimeUnit = unitDefVar.createUnit();
			recTimeUnit.setKind(timeUnit.getKind());
			if (document.getLevel() < 3)
			{
				recTimeUnit.setExponent(timeUnit.getExponent() * (-1));
			}
			else
			{
				recTimeUnit.setExponent(timeUnit.getExponent() * (-1));
			}
			recTimeUnit.setScale(timeUnit.getScale());
			recTimeUnit.setMultiplier(timeUnit.getMultiplier());
		}
	}
	else
	{
		Unit unit = unitDefVar.createUnit();
		unit.setKind(Unit.Kind.valueOf("second".toUpperCase()));
		unit.setExponent(-1.0);
		unit.setScale(0);
		unit.setMultiplier(1.0);
	}
	if (!UnitDefinition.areEquivalent(unitDef, unitDefVar))
	{
		return true;
	}
	return false;
}
 
开发者ID:MyersResearchGroup,项目名称:iBioSim,代码行数:54,代码来源:SBMLutilities.java


注:本文中的org.sbml.jsbml.UnitDefinition.getUnitCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。