blob: e81a30c099bfbea57d850f46cfb0aa1e9c1238c1 [file] [log] [blame]
/******************************************************************************
* Copyright (c) 2004, 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
****************************************************************************/
package org.eclipse.gmf.runtime.notation.impl;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.gmf.runtime.notation.Bounds;
import org.eclipse.gmf.runtime.notation.NotationPackage;
import org.eclipse.gmf.runtime.notation.Size;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Bounds</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.gmf.runtime.notation.impl.BoundsImpl#getWidth <em>Width</em>}</li>
* <li>{@link org.eclipse.gmf.runtime.notation.impl.BoundsImpl#getHeight <em>Height</em>}</li>
* </ul>
* </p>
*
* @generated
*/
/*
* @canBeSeenBy %partners
*/
public class BoundsImpl extends LocationImpl implements Bounds {
/**
* The default value of the '{@link #getWidth() <em>Width</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getWidth()
* @generated
* @ordered
*/
protected static final int WIDTH_EDEFAULT = -1;
/**
* The cached value of the '{@link #getWidth() <em>Width</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getWidth()
* @generated
* @ordered
*/
protected int width = WIDTH_EDEFAULT;
/**
* The default value of the '{@link #getHeight() <em>Height</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getHeight()
* @generated
* @ordered
*/
protected static final int HEIGHT_EDEFAULT = -1;
/**
* The cached value of the '{@link #getHeight() <em>Height</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getHeight()
* @generated
* @ordered
*/
protected int height = HEIGHT_EDEFAULT;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected BoundsImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected EClass eStaticClass() {
return NotationPackage.Literals.BOUNDS;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public int getWidth() {
return width;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setWidth(int newWidth) {
int oldWidth = width;
width = newWidth;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, NotationPackage.BOUNDS__WIDTH, oldWidth, width));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public int getHeight() {
return height;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setHeight(int newHeight) {
int oldHeight = height;
height = newHeight;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, NotationPackage.BOUNDS__HEIGHT, oldHeight, height));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case NotationPackage.BOUNDS__X:
return new Integer(getX());
case NotationPackage.BOUNDS__Y:
return new Integer(getY());
case NotationPackage.BOUNDS__WIDTH:
return new Integer(getWidth());
case NotationPackage.BOUNDS__HEIGHT:
return new Integer(getHeight());
}
return eDynamicGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case NotationPackage.BOUNDS__X:
setX(((Integer)newValue).intValue());
return;
case NotationPackage.BOUNDS__Y:
setY(((Integer)newValue).intValue());
return;
case NotationPackage.BOUNDS__WIDTH:
setWidth(((Integer)newValue).intValue());
return;
case NotationPackage.BOUNDS__HEIGHT:
setHeight(((Integer)newValue).intValue());
return;
}
eDynamicSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void eUnset(int featureID) {
switch (featureID) {
case NotationPackage.BOUNDS__X:
setX(X_EDEFAULT);
return;
case NotationPackage.BOUNDS__Y:
setY(Y_EDEFAULT);
return;
case NotationPackage.BOUNDS__WIDTH:
setWidth(WIDTH_EDEFAULT);
return;
case NotationPackage.BOUNDS__HEIGHT:
setHeight(HEIGHT_EDEFAULT);
return;
}
eDynamicUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public boolean eIsSet(int featureID) {
switch (featureID) {
case NotationPackage.BOUNDS__X:
return x != X_EDEFAULT;
case NotationPackage.BOUNDS__Y:
return y != Y_EDEFAULT;
case NotationPackage.BOUNDS__WIDTH:
return width != WIDTH_EDEFAULT;
case NotationPackage.BOUNDS__HEIGHT:
return height != HEIGHT_EDEFAULT;
}
return eDynamicIsSet(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public int eBaseStructuralFeatureID(int derivedFeatureID, Class baseClass) {
if (baseClass == Size.class) {
switch (derivedFeatureID) {
case NotationPackage.BOUNDS__WIDTH: return NotationPackage.SIZE__WIDTH;
case NotationPackage.BOUNDS__HEIGHT: return NotationPackage.SIZE__HEIGHT;
default: return -1;
}
}
return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public int eDerivedStructuralFeatureID(int baseFeatureID, Class baseClass) {
if (baseClass == Size.class) {
switch (baseFeatureID) {
case NotationPackage.SIZE__WIDTH: return NotationPackage.BOUNDS__WIDTH;
case NotationPackage.SIZE__HEIGHT: return NotationPackage.BOUNDS__HEIGHT;
default: return -1;
}
}
return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String toString() {
if (eIsProxy()) return super.toString();
StringBuffer result = new StringBuffer(super.toString());
result.append(" (width: "); //$NON-NLS-1$
result.append(width);
result.append(", height: "); //$NON-NLS-1$
result.append(height);
result.append(')');
return result.toString();
}
} //BoundsImpl