blob: f564bd1a6d5dc56ca1c8f88a994ef2661e69dd48 [file] [log] [blame]
package org.eclipse.stem.diseasemodels.standard.impl;
/*******************************************************************************
* Copyright (c) 2006 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.stem.core.graph.LabelValue;
import org.eclipse.stem.diseasemodels.standard.SILabelValue;
import org.eclipse.stem.diseasemodels.standard.SIRLabel;
import org.eclipse.stem.diseasemodels.standard.SIRLabelValue;
import org.eclipse.stem.diseasemodels.standard.StandardFactory;
import org.eclipse.stem.diseasemodels.standard.StandardPackage;
/**
* <!-- begin-user-doc --> An implementation of the model object '<em><b>SIR Label</b></em>'.
* <!-- end-user-doc -->
* <p>
* </p>
*
* @generated
*/
public class SIRLabelImpl extends StandardDiseaseModelLabelImpl implements SIRLabel {
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated NOT
*/
protected SIRLabelImpl() {
super();
setCurrentValue(StandardFactory.eINSTANCE.createSIRLabelValue());
setNextValue(StandardFactory.eINSTANCE.createSIRLabelValue());
setTempValue(StandardFactory.eINSTANCE.createSIRLabelValue());
setProbeValue(StandardFactory.eINSTANCE.createSIRLabelValue());
setErrorScale(StandardFactory.eINSTANCE.createSIRLabelValue());
setDeltaValue(StandardFactory.eINSTANCE.createSIRLabelValue());
} // SIRLabelImpl
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return StandardPackage.Literals.SIR_LABEL;
}
/**
* <!-- begin-user-doc -->
*
* @return
*
* <!-- end-user-doc -->
* @generated NOT
*/
public SIRLabelValue getNextSIRValue() {
return (SIRLabelValue) getNextValue();
} // getNextSIRValue
/**
* <!-- begin-user-doc -->
*
* @return
*
* <!-- end-user-doc -->
* @generated NOT
*/
public SIRLabelValue getCurrentSIRValue() {
return (SIRLabelValue) getCurrentValue();
} // getCurrentSIRValue
/**
* @see org.eclipse.stem.diseasemodels.standard.SIRLabel#getR()
*/
public double getR() {
return getCurrentSIRValue().getR();
}
/**
* @see org.eclipse.stem.diseasemodels.standard.SIRLabel#setR(double)
*/
public void setR(double r) {
getCurrentSIRValue().setR(r);
}
/**
* @see org.eclipse.stem.diseasemodels.standard.SIRLabel#getNextR()
*/
public double getNextR() {
return getNextSIRValue().getR();
}
/**
* @see org.eclipse.stem.diseasemodels.standard.SIRLabel#setNextR(double)
*/
public void setNextR(double r) {
getNextSIRValue().setR(r);
} // setNextR
/**
* @return set the number number of infectious population members
*/
public void setNextI(double i) {
((SILabelValue)getNextValue()).setI(i);
}
/**
* @see org.eclipse.stem.diseasemodels.standard.SILabel#getI()
*/
public double getI() {
return getCurrentSIRValue().getI();
} // getI
/**
* @see org.eclipse.stem.diseasemodels.standard.SILabel#setI()
*/
public void setI(double i) {
getCurrentSIRValue().setI(i);
} // getI
/**
* set disease deaths
*/
public void setDiseaseDeaths(double d) {
(((SIRLabelValue)getCurrentValue())).setDiseaseDeaths(d);
} // setDiseaseDeaths
/**
* get disease deaths
*/
public double getDiseaseDeaths() {
return getCurrentSIRValue().getDiseaseDeaths();
} // getDiseaseDeaths
/**
* @see org.eclipse.stem.diseasemodels.standard.SILabel#getNextI()
*/
public double getNextI() {
return getNextSIRValue().getI();
} // getNextI
public String toTooltipString() {
StringBuffer result = new StringBuffer();
double populationCount = getCurrentSIRValue().getPopulationCount();
if(populationCount == 0) populationCount = 1; // Avoid divide by 0, all zeros will be displayed for the compartments
result.append(getPopulationModelLabel() + ": ");
result.append("S:"); //$NON-NLS-1$
result.append(getPercentFormat().format( (getS()) / populationCount) );
result.append(", I:"); //$NON-NLS-1$
result.append(getPercentFormat().format( (getI()) / populationCount) );
result.append(", R:"); //$NON-NLS-1$
result.append(getPercentFormat().format( (getR()) / populationCount) );
result.append(", DD:"); //$NON-NLS-1$
result.append(getPercentFormat().format( (getDiseaseDeaths()) / populationCount) );
return result.toString();
} // toTooltipString
} // SIRLabelImpl