@Override @Deprecated public void setUnits(Kind unitKind) { setUnits(new Unit(1d, 0, unitKind, 1d, getLevel(), getVersion())); }
/** * Sets the unitsID to 'unitsID'. * * @param unitsID * A valid identifier of a {@link UnitDefinition} in the * {@link Model} or the name of one of the {@link Unit.Kind} base * types. * @deprecated This is a requirement for Level 1 Version 1 and Version 2, * but can only be used in conjunction with {@link Parameter}s. * In this case this {@link AssignmentRule} represents the SBML * element ParameterRule. * @throws PropertyNotAvailableException if Level is not 1. */ @Override @Deprecated public void setUnits(String unitsID) { if (getLevel() != 1) { throw new PropertyNotAvailableException(TreeNodeChangeEvent.units, this); } if (isSetVariable() && !isParameter()) { throw new IllegalArgumentException(MessageFormat.format( "Cannot set unit {0} for a variable other than parameter", unitsID)); } String oldUnitsID = this.unitsID; this.unitsID = unitsID; firePropertyChange(TreeNodeChangeEvent.units, oldUnitsID, unitsID); }
@Override public void setVariable(Variable variable) { if (variable != null) { if (variable.isConstant()) { throw new IllegalArgumentException(MessageFormat.format( resourceBundle.getString("Assignment.ILLEGAL_CONSTANT_VARIABLE_MSG"), variable.getId(), getElementName())); } if (isSetUnits() && !(variable instanceof Parameter)) { throw new IllegalArgumentException(MessageFormat.format( "Variable expected to be an instance of Parameter because a Unit attribute is set already, but given is an instance of {0}.", variable.getElementName())); } if ((getLevel() < 3) && (variable instanceof SpeciesReference)) { throw new IllegalArgumentException(MessageFormat.format( resourceBundle.getString("Assignment.ILLEGAL_VARIABLE_EXCEPTION_MSG"), variable.getId(), getElementName())); } if (variable.isSetId()) { String oldVariable = variableID; variableID = variable.getId(); firePropertyChange(TreeNodeChangeEvent.variable, oldVariable, variableID); } else { unsetVariable(); } } else { unsetVariable(); } }
@Override @Deprecated public void setUnits(Unit unit) { UnitDefinition ud = new UnitDefinition(unit.getKind().toString(), getLevel(), getVersion()); ud.addUnit(unit); if ((unit.getExponent() != 1) || (unit.getScale() != 0) || (unit.getMultiplier() != 1d) || (unit.getOffset() != 0d)) { StringBuilder sb = new StringBuilder(); sb.append(unit.getMultiplier()); sb.append('_'); sb.append(unit.getScale()); sb.append('_'); sb.append(unit.getKind().toString()); sb.append('_'); sb.append(unit.getExponent()); ud.setId(sb.toString()); Model m = getModel(); if (m != null) { m.addUnitDefinition(ud); } } setUnits(ud); }