001: /**
002: * <copyright>
003: * </copyright>
004: *
005: * $Id$
006: */package net.refractions.udig.printing.model.impl;
007:
008: import java.text.MessageFormat;
009:
010: import net.refractions.udig.printing.model.Element;
011: import net.refractions.udig.printing.model.ModelPackage;
012: import net.refractions.udig.printing.model.internal.Messages;
013:
014: import org.eclipse.draw2d.geometry.Dimension;
015: import org.eclipse.draw2d.geometry.Point;
016: import org.eclipse.emf.common.notify.Notification;
017: import org.eclipse.emf.ecore.EClass;
018: import org.eclipse.emf.ecore.EStructuralFeature;
019: import org.eclipse.emf.ecore.impl.ENotificationImpl;
020: import org.eclipse.emf.ecore.impl.EObjectImpl;
021:
022: /**
023: * <!-- begin-user-doc -->
024: * An implementation of the model object '<em><b>Element</b></em>'.
025: * <!-- end-user-doc -->
026: * <p>
027: * The following features are implemented:
028: * <ul>
029: * <li>{@link net.refractions.udig.printing.model.impl.ElementImpl#getLocation <em>Location</em>}</li>
030: * <li>{@link net.refractions.udig.printing.model.impl.ElementImpl#getSize <em>Size</em>}</li>
031: * </ul>
032: * </p>
033: *
034: * @generated
035: */
036: public class ElementImpl extends EObjectImpl implements Element {
037: /**
038: * The default value of the '{@link #getLocation() <em>Location</em>}' attribute.
039: * <!-- begin-user-doc -->
040: * <!-- end-user-doc -->
041: * @see #getLocation()
042: * @generated
043: * @ordered
044: */
045: protected static final Point LOCATION_EDEFAULT = null;
046:
047: /**
048: * The cached value of the '{@link #getLocation() <em>Location</em>}' attribute.
049: * <!-- begin-user-doc -->
050: * <!-- end-user-doc -->
051: * @see #getLocation()
052: * @generated
053: * @ordered
054: */
055: protected Point location = LOCATION_EDEFAULT;
056:
057: /**
058: * The default value of the '{@link #getSize() <em>Size</em>}' attribute.
059: * <!-- begin-user-doc -->
060: * <!-- end-user-doc -->
061: * @see #getSize()
062: * @generated
063: * @ordered
064: */
065: protected static final Dimension SIZE_EDEFAULT = null;
066:
067: /**
068: * The cached value of the '{@link #getSize() <em>Size</em>}' attribute.
069: * <!-- begin-user-doc -->
070: * <!-- end-user-doc -->
071: * @see #getSize()
072: * @generated
073: * @ordered
074: */
075: protected Dimension size = SIZE_EDEFAULT;
076:
077: /**
078: * <!-- begin-user-doc -->
079: * <!-- end-user-doc -->
080: * @generated
081: */
082: protected ElementImpl() {
083: super ();
084: }
085:
086: /**
087: * <!-- begin-user-doc -->
088: * <!-- end-user-doc -->
089: * @generated
090: */
091: protected EClass eStaticClass() {
092: return ModelPackage.eINSTANCE.getElement();
093: }
094:
095: /**
096: * <!-- begin-user-doc -->
097: * <!-- end-user-doc -->
098: * @generated
099: */
100: public Point getLocation() {
101: return location;
102: }
103:
104: /**
105: * <!-- begin-user-doc -->
106: * <!-- end-user-doc -->
107: * @generated
108: */
109: public void setLocation(Point newLocation) {
110: Point oldLocation = location;
111: location = newLocation;
112: if (eNotificationRequired())
113: eNotify(new ENotificationImpl(this , Notification.SET,
114: ModelPackage.ELEMENT__LOCATION, oldLocation,
115: location));
116: }
117:
118: /**
119: * <!-- begin-user-doc -->
120: * <!-- end-user-doc -->
121: * @generated
122: */
123: public Dimension getSize() {
124: return size;
125: }
126:
127: /**
128: * <!-- begin-user-doc -->
129: * <!-- end-user-doc -->
130: * @generated
131: */
132: public void setSize(Dimension newSize) {
133: Dimension oldSize = size;
134: size = newSize;
135: if (eNotificationRequired())
136: eNotify(new ENotificationImpl(this , Notification.SET,
137: ModelPackage.ELEMENT__SIZE, oldSize, size));
138: }
139:
140: /**
141: * <!-- begin-user-doc -->
142: * <!-- end-user-doc -->
143: * @generated
144: */
145: public Object eGet(EStructuralFeature eFeature, boolean resolve) {
146: switch (eDerivedStructuralFeatureID(eFeature)) {
147: case ModelPackage.ELEMENT__LOCATION:
148: return getLocation();
149: case ModelPackage.ELEMENT__SIZE:
150: return getSize();
151: }
152: return eDynamicGet(eFeature, resolve);
153: }
154:
155: /**
156: * <!-- begin-user-doc -->
157: * <!-- end-user-doc -->
158: * @generated
159: */
160: public void eSet(EStructuralFeature eFeature, Object newValue) {
161: switch (eDerivedStructuralFeatureID(eFeature)) {
162: case ModelPackage.ELEMENT__LOCATION:
163: setLocation((Point) newValue);
164: return;
165: case ModelPackage.ELEMENT__SIZE:
166: setSize((Dimension) newValue);
167: return;
168: }
169: eDynamicSet(eFeature, newValue);
170: }
171:
172: /**
173: * <!-- begin-user-doc -->
174: * <!-- end-user-doc -->
175: * @generated
176: */
177: public void eUnset(EStructuralFeature eFeature) {
178: switch (eDerivedStructuralFeatureID(eFeature)) {
179: case ModelPackage.ELEMENT__LOCATION:
180: setLocation(LOCATION_EDEFAULT);
181: return;
182: case ModelPackage.ELEMENT__SIZE:
183: setSize(SIZE_EDEFAULT);
184: return;
185: }
186: eDynamicUnset(eFeature);
187: }
188:
189: /**
190: * <!-- begin-user-doc -->
191: * <!-- end-user-doc -->
192: * @generated
193: */
194: public boolean eIsSet(EStructuralFeature eFeature) {
195: switch (eDerivedStructuralFeatureID(eFeature)) {
196: case ModelPackage.ELEMENT__LOCATION:
197: return LOCATION_EDEFAULT == null ? location != null
198: : !LOCATION_EDEFAULT.equals(location);
199: case ModelPackage.ELEMENT__SIZE:
200: return SIZE_EDEFAULT == null ? size != null
201: : !SIZE_EDEFAULT.equals(size);
202: }
203: return eDynamicIsSet(eFeature);
204: }
205:
206: /**
207: * <!-- begin-user-doc -->
208: * <!-- end-user-doc -->
209: * @generated NOT
210: */
211: public String toString() {
212: if (eIsProxy())
213: return super .toString();
214:
215: StringBuffer result = new StringBuffer(super .toString());
216: result.append(MessageFormat.format(Messages.ElementImpl_0
217: + Messages.ElementImpl_toString, new Object[] {
218: location, size }));
219: return result.toString();
220: }
221:
222: } //ElementImpl
|