protected Object updateFromReference(String childName, Object refChild, EObject eChildParntObj) {
   Object child = ((IChartObject) refChild).copyInstance();
   ChartElementUtil.setEObjectAttribute(eChildParntObj, childName, child, false);
   return child;
 }
  /**
   * Updates chart element object.
   *
   * @param expected class of expected chart element.
   * @param name chart element name
   * @param eParentObj container of chart element object.
   * @param eObj chart element object.
   * @param eRef reference chart object to be used to update chart object's values.
   * @param eDef default chart object to be used to update chart object's values.
   */
  public void update(
      EClass expected, String name, EObject eParentObj, EObject eObj, EObject eRef, EObject eDef) {
    if (eObj == null) {
      if (eRef != null) {
        if (eRef instanceof IChartObject) {
          eObj = ((IChartObject) eRef).copyInstance();
          ChartElementUtil.setEObjectAttribute(eParentObj, name, eObj, false);
        }
      } else if (eDef != null) {
        if (eDef instanceof IChartObject) {
          eObj = ((IChartObject) eDef).copyInstance();
          ChartElementUtil.setEObjectAttribute(eParentObj, name, eObj, false);
          return;
        }
      }
    }
    if (eObj == null || (eRef == null && eDef == null)) {
      return;
    }

    // Process visible case.
    if (contanisVisibleElement(eObj.eClass())) {
      if (eObj.eIsSet(eObj.eClass().getEStructuralFeature("visible"))) // $NON-NLS-1$
      {
        if (eObj.eGet(eObj.eClass().getEStructuralFeature("visible"))
            != Boolean.TRUE) // $NON-NLS-1$
        {
          // If the visible attribute is set to false, directly return, no need
          // to update other attributes.
          return;
        }
      } else {
        // If eObj isn't set visible and the visible attribute of
        // reference object is set to false, directly return, no need to
        // update other attributes.
        if (eRef != null
            && eRef.eIsSet(eRef.eClass().getEStructuralFeature("visible"))) // $NON-NLS-1$
        {
          if (eRef.eGet(eRef.eClass().getEStructuralFeature("visible"))
              != Boolean.TRUE) // $NON-NLS-1$
          {
            eObj.eSet(eRef.eClass().getEStructuralFeature("visible"), Boolean.FALSE); // $NON-NLS-1$
            return;
          }
        } else if (eDef != null
            && eDef.eIsSet(eDef.eClass().getEStructuralFeature("visible"))) // $NON-NLS-1$
        {
          if (eDef.eGet(eDef.eClass().getEStructuralFeature("visible"))
              != Boolean.TRUE) // $NON-NLS-1$
          {
            eObj.eSet(eDef.eClass().getEStructuralFeature("visible"), Boolean.FALSE); // $NON-NLS-1$
            return;
          }
        }
      }
    }

    EClass eClass = eObj.eClass();

    // attributes
    updateAttrs(eClass, eParentObj, eObj, eRef, eDef);

    // list attributes

    // references
    for (EReference ref : eClass.getEAllReferences()) {
      String childName = ref.getName();
      Object child = eObj.eGet(ref);
      Object refChild = eRef != null ? eRef.eGet(ref) : null;
      Object defChild = eDef != null ? eDef.eGet(ref) : null;
      EObject eChildParntObj = eObj;
      if (child == null) {
        if (refChild != null) {
          if (refChild instanceof IChartObject) {
            child = updateFromReference(childName, refChild, eChildParntObj);
          }
        } else if (defChild != null) {
          if (defChild instanceof IChartObject) {
            child = ((IChartObject) defChild).copyInstance();
            ChartElementUtil.setEObjectAttribute(eChildParntObj, childName, child, false);
            continue;
          }
        }
      }

      if (child != null) {
        if (ref.isMany()) {
          int size = ((List<?>) child).size();
          for (int i = 0; i < size; i++) {
            Object item = ((List<?>) child).get(i);
            Object refItem =
                (refChild == null || (i >= ((List<?>) refChild).size()))
                    ? null
                    : ((List<?>) refChild).get(i);
            Object defItem =
                (defChild == null || (i >= ((List<?>) defChild).size()))
                    ? null
                    : ((List<?>) defChild).get(i);
            update(ref, eObj, (EObject) item, (EObject) refItem, (EObject) defItem);
          }
        } else {
          update(ref, eObj, (EObject) child, (EObject) refChild, (EObject) defChild);
        }
      }
    }
  }