/**
   * Return the default draw2D dimension according to the specified DNode.
   *
   * @return the default draw2D dimension according to the specified DNode.
   */
  public Dimension getDefaultDimension() {
    final Dimension result = DEFAULT_NODE_DIMENSION.getCopy();

    if (node.getStyle() instanceof WorkspaceImage) {
      final WorkspaceImage workspaceImage = (WorkspaceImage) node.getStyle();
      final String path = workspaceImage.getWorkspacePath();
      final Image image;
      image = WorkspaceImageFigure.getImageInstanceFromPath(path);
      if (image != null) {
        // Use default image size
        if (node.getWidth() == null || Integer.valueOf(node.getWidth()) == -1) {
          result.width = image.getBounds().width;
          result.height = image.getBounds().height;
        } else {
          // width is already defined, adapt height thanks to
          // image ratio
          final double ratio = (double) image.getBounds().width / image.getBounds().height;
          double newHeight = node.getWidth().intValue() / ratio;

          // Adapt to draw2D
          result.width = node.getWidth().intValue() * LayoutUtils.SCALE;
          result.height = (int) (newHeight * LayoutUtils.SCALE);
        }
      }
    } else {
      if (node.getWidth() != null) {
        result.width = node.getWidth().intValue();
      }
      if (node.getHeight() != null) {
        result.height = node.getHeight().intValue();
      }

      // Adapt to draw2D
      result.width = result.width * LayoutUtils.SCALE;
      result.height = result.height * LayoutUtils.SCALE;
    }

    return result;
  }
 /**
  * Clear cache if necessary and return true if a refresh of figure of opened editors must be done,
  * false otherwise.
  *
  * @param delta , resource delta
  * @return boolean
  */
 private boolean needClearCache(IResource resource) {
   boolean cacheUpdated = false;
   String resourceExtension = resource.getFileExtension();
   if (WorkspaceImageFigure.isSvgImage(resourceExtension)) {
     String svgUri = resource.getFullPath().toString();
     Option<String> removed = SVGWorkspaceImageFigure.removeFromCache(svgUri);
     if (removed.some()) {
       cacheUpdated = true;
     }
   } else {
     URL url;
     try {
       url =
           new File(
                   ResourcesPlugin.getWorkspace()
                       .getRoot()
                       .getLocation()
                       .append(resource.getFullPath())
                       .toOSString())
               .toURI()
               .toURL();
     } catch (MalformedURLException e) {
       DiagramPlugin.getDefault().logError("Invalid uri : " + e.getMessage());
       return false;
     }
     ImageDescriptor bundledImageDescriptor = ImageDescriptor.createFromURL(url);
     boolean removed = DiagramUIPlugin.getPlugin().removeCacheImage(bundledImageDescriptor);
     // If a removed cache action is do, a refresh opened editors
     // is
     // required
     if (removed) {
       cacheUpdated = true;
     }
   }
   return cacheUpdated;
 }