• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java UnitDefinition类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: completeUnitDefinitions

import org.sbml.jsbml.UnitDefinition; //导入依赖的package包/类
/**
 * Complete unit definitions.
 *
 * @param unitDefinitions
 *        the unit definitions
 * @return ListOf<UnitDefinition>
 *         TODO
 */
public static ListOf<UnitDefinition> completeUnitDefinitions(
  ListOf<UnitDefinition> unitDefinitions) {
  for (UnitDefinition ud : unitDefinitions) {
    ListOf<Unit> units = ud.getListOfUnits();
    for (Unit u : units) {
      if (!u.isSetExponent()) {
        u.setExponent(1d);
      }
      if (!u.isSetMultiplier()) {
        u.setMultiplier(1d);
      }
      if (!u.isSetKind()) {
        u.setKind(Kind.INVALID);
      }
      if (!u.isSetScale()) {
        u.setScale(0);
      }
    }
  }
  return unitDefinitions;
}
 
开发者ID:funasoul,项目名称:celldesigner-parser,代码行数:30,代码来源:SBMLModelCompleter.java


示例2: checkUnitsInAssignmentRule

import org.sbml.jsbml.UnitDefinition; //导入依赖的package包/类
public static boolean checkUnitsInAssignmentRule(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 (!UnitDefinition.areEquivalent(unitDef, unitDefVar))
	{
		return true;
	}
	return false;
}
 
开发者ID:MyersResearchGroup,项目名称:iBioSim,代码行数:26,代码来源:SBMLutilities.java


示例3: checkUnitsInInitialAssignment

import org.sbml.jsbml.UnitDefinition; //导入依赖的package包/类
public static boolean checkUnitsInInitialAssignment(SBMLDocument document, InitialAssignment init)
{
	UnitDefinition unitDef = init.getDerivedUnitDefinition();
	UnitDefinition unitDefVar;
	Species species = document.getModel().getSpecies(init.getVariable());
	Compartment compartment = document.getModel().getCompartment(init.getVariable());
	Parameter parameter = document.getModel().getParameter(init.getVariable());
	if (species != null)
	{
		unitDefVar = species.getDerivedUnitDefinition();
	}
	else if (compartment != null)
	{
		unitDefVar = compartment.getDerivedUnitDefinition();
	}
	else
	{
		unitDefVar = parameter.getDerivedUnitDefinition();
	}
	if (!UnitDefinition.areEquivalent(unitDef, unitDefVar))
	{
		return true;
	}
	return false;
}
 
开发者ID:MyersResearchGroup,项目名称:iBioSim,代码行数:26,代码来源:SBMLutilities.java


示例4: checkUnitsInEventAssignment

import org.sbml.jsbml.UnitDefinition; //导入依赖的package包/类
public static boolean checkUnitsInEventAssignment(SBMLDocument document, EventAssignment assign)
{
	UnitDefinition unitDef = assign.getDerivedUnitDefinition();
	UnitDefinition unitDefVar;
	Species species = document.getModel().getSpecies(assign.getVariable());
	Compartment compartment = document.getModel().getCompartment(assign.getVariable());
	Parameter parameter = document.getModel().getParameter(assign.getVariable());
	if (species != null)
	{
		unitDefVar = species.getDerivedUnitDefinition();
	}
	else if (compartment != null)
	{
		unitDefVar = compartment.getDerivedUnitDefinition();
	}
	else
	{
		unitDefVar = parameter.getDerivedUnitDefinition();
	}
	if (unitDef != null && unitDefVar != null && !UnitDefinition.areEquivalent(unitDef, unitDefVar))
	{
		return true;
	}
	return false;
}
 
开发者ID:MyersResearchGroup,项目名称:iBioSim,代码行数:26,代码来源:SBMLutilities.java


示例5: 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


示例6: addUnitDefinition

import org.sbml.jsbml.UnitDefinition; //导入依赖的package包/类
private void addUnitDefinition(String strLB_Unit) {
	if (!strLB_Unit.equals("dimensionless")) {
		boolean bFound = false;

		for (String strUnitDef : _ListOfUnitDefinitions) {
			if (strUnitDef.equals(strLB_Unit.trim())) {
				bFound = true;
				break;
			}
		}

		if (!bFound) {
			UnitDefinition _unit = model.createUnitDefinition();
			_unit.setId(strLB_Unit);
			_ListOfUnitDefinitions.add(strLB_Unit);
		}
	}
}
 
开发者ID:ibalaur,项目名称:MetabolicFramework,代码行数:19,代码来源:JSON2SBMLParser.java


示例7: 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


示例8: UnitDefinitionTable

import org.sbml.jsbml.UnitDefinition; //导入依赖的package包/类
/**
 * Instantiates a new unit definition table.
 *
 * @param loud the loud
 */
UnitDefinitionTable(ListOf<UnitDefinition> loud){
	this.model = loud.getModel();
	list = loud;
	setUnitDefinitionToList(loud);
	MyTableModel tm = getTableModelWithUnitDefinitions(loud);
	table = new JTable(tm);
	setTableProperties(table);
	pane = setTableToScroll("unit",table);
}
 
开发者ID:spatialsimulator,项目名称:XitoSBML,代码行数:15,代码来源:UnitDefinitionTable.java


示例9: setUnitDefinitionToList

import org.sbml.jsbml.UnitDefinition; //导入依赖的package包/类
/**
 * Sets the unit definition to list.
 *
 * @param loud the new unit definition to list
 */
private void setUnitDefinitionToList(ListOf<UnitDefinition> loud){
	long max = loud.size();
	for(int i = 0; i < max; i++){
		UnitDefinition ud = loud.get(i);
		memberList.add(ud.clone());
	}
}
 
开发者ID:spatialsimulator,项目名称:XitoSBML,代码行数:13,代码来源:UnitDefinitionTable.java


示例10: getTableModelWithUnitDefinitions

import org.sbml.jsbml.UnitDefinition; //导入依赖的package包/类
/**
 * Gets the table model with unit definitions.
 *
 * @param loud the loud
 * @return the table model with unit definitions
 */
private MyTableModel getTableModelWithUnitDefinitions(ListOf<UnitDefinition> loud){
	int max = memberList.size();
	Object[][] data  = new Object[max][header.length];
	for(int i = 0; i < max; i++){
		UnitDefinition ud = (UnitDefinition) memberList.get(i);
		data[i][0] = ud.getId();
		data[i][1] = unitsToString(ud.getListOfUnits());
	}
	
	MyTableModel tm = new MyTableModel(data, header) {
		private static final long serialVersionUID = 1L;

		@Override
		public Class<?> getColumnClass(int Column) {
			switch (Column) {
			case 0: // id
			case 1: // units
				return String.class;
			default:
				return String.class;
			}
		}
	};
	
	tm.setColumnIdentifiers(header);
		
	return tm;
}
 
开发者ID:spatialsimulator,项目名称:XitoSBML,代码行数:35,代码来源:UnitDefinitionTable.java


示例11: unitDefinitionToVector

import org.sbml.jsbml.UnitDefinition; //导入依赖的package包/类
/**
	 * Unit definition to vector.
	 *
	 * @param ud the ud
	 * @return the vector
	 */
	private Vector<Object> unitDefinitionToVector(UnitDefinition ud){
		Vector<Object> v = new Vector<Object>();
		v.add(ud.getId());
//		v.add(p.getValue());
//		v.add(p.getUnits());
//		v.add(p.getConstant());
//		
		return v;
	}
 
开发者ID:spatialsimulator,项目名称:XitoSBML,代码行数:16,代码来源:UnitDefinitionTable.java


示例12: addUnits

import org.sbml.jsbml.UnitDefinition; //导入依赖的package包/类
/**
 * Adds the units.
 */
public void addUnits(){
	if(unit == null) 
		return; 
	UnitDefinition ud = model.createUnitDefinition();
	ud.setId("length");
	Unit u = ud.createUnit();
	u.setKind(Kind.METRE);
	u.setExponent(1d);
	u.setScale(0);
	u.setMultiplier(getUnitMultiplier(unit));

	ud = model.createUnitDefinition();
	ud.setId("area");
	u = ud.createUnit();
	u.setKind(Kind.METRE);
	u.setExponent(2d);
	u.setScale(0);
	u.setMultiplier(getUnitMultiplier(unit));
	
	ud = model.createUnitDefinition();
	ud.setId("volume");
	u = ud.createUnit();
	u.setKind(Kind.METRE);
	u.setExponent(3d);
	u.setScale(0);
	u.setMultiplier(getUnitMultiplier(unit));
}
 
开发者ID:spatialsimulator,项目名称:XitoSBML,代码行数:31,代码来源:SpatialSBMLExporter.java


示例13: getUnits

import org.sbml.jsbml.UnitDefinition; //导入依赖的package包/类
public ArrayList<String> getUnits() {
	ArrayList<String> unitSet = new ArrayList<String>();
	if (sbml!=null) {
		for (int i = 0; i < sbml.getModel().getUnitDefinitionCount(); i++) {
			UnitDefinition unit = sbml.getModel().getUnitDefinition(i);
			unitSet.add(unit.getId());
		}
	}
	return unitSet;
}
 
开发者ID:MyersResearchGroup,项目名称:iBioSim,代码行数:11,代码来源:BioModel.java


示例14: checkUnitsInEventDelay

import org.sbml.jsbml.UnitDefinition; //导入依赖的package包/类
public static boolean checkUnitsInEventDelay(Delay delay)
{
	UnitDefinition unitDef = delay.getDerivedUnitDefinition();
	if (unitDef != null && !(unitDef.isVariantOfTime()))
	{
		return true;
	}
	return false;
}
 
开发者ID:MyersResearchGroup,项目名称:iBioSim,代码行数:10,代码来源:SBMLutilities.java


示例15: Units

import org.sbml.jsbml.UnitDefinition; //导入依赖的package包/类
public Units(BioModel gcm, ModelEditor modelEditor) {
	super(new BorderLayout());
	this.bioModel = gcm;
	this.modelEditor = modelEditor;
	Model model = gcm.getSBMLDocument().getModel();
	addUnit = new JButton("Add Unit");
	removeUnit = new JButton("Remove Unit");
	editUnit = new JButton("Edit Unit");
	unitDefs = new JList();
	ListOf<UnitDefinition> listOfUnits = model.getListOfUnitDefinitions();
	String[] units = new String[model.getUnitDefinitionCount()];
	for (int i = 0; i < model.getUnitDefinitionCount(); i++) {
		UnitDefinition unit = listOfUnits.get(i);
		units[i] = unit.getId();
		// GET OTHER THINGS
	}
	JPanel addRem = new JPanel();
	addRem.add(addUnit);
	addRem.add(removeUnit);
	addRem.add(editUnit);
	addUnit.addActionListener(this);
	removeUnit.addActionListener(this);
	editUnit.addActionListener(this);
	JLabel panelLabel = new JLabel("List of Units:");
	JScrollPane scroll = new JScrollPane();
	scroll.setMinimumSize(new Dimension(260, 220));
	scroll.setPreferredSize(new Dimension(276, 152));
	scroll.setViewportView(unitDefs);
	edu.utah.ece.async.ibiosim.dataModels.biomodel.util.Utility.sort(units);
	unitDefs.setListData(units);
	unitDefs.setSelectedIndex(0);
	unitDefs.addMouseListener(this);
	this.add(panelLabel, "North");
	this.add(scroll, "Center");
	this.add(addRem, "South");
}
 
开发者ID:MyersResearchGroup,项目名称:iBioSim,代码行数:37,代码来源:Units.java


示例16: refreshUnitsPanel

import org.sbml.jsbml.UnitDefinition; //导入依赖的package包/类
/**
 * Refresh units panel
 */
public void refreshUnitsPanel() {
	Model model = bioModel.getSBMLDocument().getModel();
	ListOf<UnitDefinition> listOfUnits = model.getListOfUnitDefinitions();
	String[] units = new String[model.getUnitDefinitionCount()];
	for (int i = 0; i < model.getUnitDefinitionCount(); i++) {
		UnitDefinition unit = listOfUnits.get(i);
		units[i] = unit.getId();
		// GET OTHER THINGS
	}
	edu.utah.ece.async.ibiosim.dataModels.biomodel.util.Utility.sort(units);
	unitDefs.setListData(units);
	unitDefs.setSelectedIndex(0);
}
 
开发者ID:MyersResearchGroup,项目名称:iBioSim,代码行数:17,代码来源:Units.java


示例17: removeUnit

import org.sbml.jsbml.UnitDefinition; //导入依赖的package包/类
/**
 * Remove a unit
 */
private void removeUnit() {
	int index = unitDefs.getSelectedIndex();
	if (index != -1) {
		if (!unitsInUse(((String) unitDefs.getSelectedValue()).split(" ")[0])) {
			UnitDefinition tempUnit = bioModel.getSBMLDocument().getModel().getUnitDefinition(((String) unitDefs.getSelectedValue()).split(" ")[0]);
			ListOf<UnitDefinition> u = bioModel.getSBMLDocument().getModel().getListOfUnitDefinitions();
			for (int i = 0; i < bioModel.getSBMLDocument().getModel().getUnitDefinitionCount(); i++) {
				if (u.get(i).getId().equals(tempUnit.getId())) {
					u.remove(i);
				}
			}
			for (int i = 0; i < bioModel.getSBMLCompModel().getListOfPorts().size(); i++) {
				Port port = bioModel.getSBMLCompModel().getListOfPorts().get(i);
				if (port.isSetIdRef() && port.getIdRef().equals(tempUnit.getId())) {
					bioModel.getSBMLCompModel().getListOfPorts().remove(i);
					break;
				}
			}
			unitDefs.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
			Utility.remove(unitDefs);
			unitDefs.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
			if (index < unitDefs.getModel().getSize()) {
				unitDefs.setSelectedIndex(index);
			}
			else {
				unitDefs.setSelectedIndex(index - 1);
			}
			modelEditor.setDirty(true);
			modelEditor.makeUndoPoint();
		}
	}
}
 
开发者ID:MyersResearchGroup,项目名称:iBioSim,代码行数:36,代码来源:Units.java


示例18: convertUnits

import org.sbml.jsbml.UnitDefinition; //导入依赖的package包/类
public Map<String, Unit<?>> convertUnits(ListOf<UnitDefinition> sbmlUnits) {
    Map<String, Unit<?>> units = new HashMap<>();
    for (UnitDefinition unitDefinition : sbmlUnits) {
        units.put(unitDefinition.getId(), convertUnit(unitDefinition));
    }
    return units;
}
 
开发者ID:cleberecht,项目名称:singa,代码行数:8,代码来源:SBMLUnitConverter.java


示例19: convertUnit

import org.sbml.jsbml.UnitDefinition; //导入依赖的package包/类
public Unit<?> convertUnit(UnitDefinition unitDefinition) {
    Unit<?> resultUnit = new ProductUnit();
    for (org.sbml.jsbml.Unit sbmlUnit : unitDefinition.getListOfUnits()) {
        Unit unitComponent = getUnitForKind(sbmlUnit.getKind());
        unitComponent = unitComponent.transform(
                UnitPrefixes.getUnitPrefixFromScale(sbmlUnit.getScale()).getCorrespondingConverter());
        unitComponent = unitComponent.pow((int) sbmlUnit.getExponent());
        unitComponent = unitComponent.multiply(sbmlUnit.getMultiplier());
        resultUnit = resultUnit.multiply(unitComponent);
    }
    logger.debug("Parsed unit {},", resultUnit.toString());
    return resultUnit;
}
 
开发者ID:cleberecht,项目名称:singa,代码行数:14,代码来源:SBMLUnitConverter.java


示例20: getConversionFactor

import org.sbml.jsbml.UnitDefinition; //导入依赖的package包/类
private static double getConversionFactor(String fromXml, String toXml) {
	Double result = factors.getIfPresent(new Pair<>(fromXml, toXml));

	if (result != null) {
		return result;
	}

	double factor = Double.NaN;

	if (fromXml.equals(toXml)) {
		factor = 1.0;
	} else {
		UnitDefinition from = definitionFromXml(fromXml);
		UnitDefinition to = definitionFromXml(toXml);

		if (UnitDefinition.areIdentical(from, to)) {
			factor = 1.0;
		} else {
			UnitDefinition div = from.divideBy(to).simplify();

			if (div.getNumUnits() == 1 && div.getUnit(0).isDimensionless() && div.getUnit(0).getExponent() == 1.0) {
				factor = div.getUnit(0).getMultiplier() * Math.pow(10, div.getUnit(0).getScale());
			}
		}
	}

	factors.put(new Pair<>(fromXml, toXml), factor);

	return factor;
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:31,代码来源:PmmUnit.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ServicePortBuilder类代码示例发布时间:2022-05-22
下一篇:
Java JsonNotification类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap