/**
* 2014 Urs Zeidler
*/
package de.urszeidler.eclipse.shr5.impl;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import de.urszeidler.eclipse.shr5.KiKraft;
import de.urszeidler.eclipse.shr5.QiFokus;
import de.urszeidler.eclipse.shr5.Shr5Package;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Qi Fokus</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link de.urszeidler.eclipse.shr5.impl.QiFokusImpl#getPower <em>Power</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class QiFokusImpl extends AbstraktFokusImpl implements QiFokus {
/**
* The cached value of the '{@link #getPower() <em>Power</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getPower()
* @generated
* @ordered
*/
protected KiKraft power;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected QiFokusImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return Shr5Package.Literals.QI_FOKUS;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public KiKraft getPower() {
return power;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetPower(KiKraft newPower, NotificationChain msgs) {
KiKraft oldPower = power;
power = newPower;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Shr5Package.QI_FOKUS__POWER, oldPower, newPower);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated not
*/
public void setPower(KiKraft newPower) {
if (newPower != power) {
NotificationChain msgs = null;
if (power != null)
msgs = ((InternalEObject)power).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - Shr5Package.QI_FOKUS__POWER, null, msgs);
if (newPower != null)
msgs = ((InternalEObject)newPower).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - Shr5Package.QI_FOKUS__POWER, null, msgs);
msgs = basicSetPower(newPower, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, Shr5Package.QI_FOKUS__POWER, newPower, newPower));
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, Shr5Package.QI_FOKUS__BINDUNGSKOSTEN, 1, 0));
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, Shr5Package.QI_FOKUS__STUFE, 1, 0));
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, Shr5Package.QI_FOKUS__WERT, 1, 0));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case Shr5Package.QI_FOKUS__POWER:
return basicSetPower(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case Shr5Package.QI_FOKUS__POWER:
return getPower();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case Shr5Package.QI_FOKUS__POWER:
setPower((KiKraft)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case Shr5Package.QI_FOKUS__POWER:
setPower((KiKraft)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case Shr5Package.QI_FOKUS__POWER:
return power != null;
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated not
*/
public int getBindungskosten() {
return getStufe() * 2;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated not
*/
public int getStufe() {
if (getPower() != null) {
return (int)Math.ceil((4 * Math.abs(getPower().getKraftpunkte()) / 100D));
}
return stufe;
}
public void setStufe(int newStufe){
super.setStufe(newStufe);
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, Shr5Package.QI_FOKUS__BINDUNGSKOSTEN, 0, 1));
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, Shr5Package.QI_FOKUS__WERT_VALUE, 0, 1));
}
} // QiFokusImpl