Пример #1
0
  /**
   * invalidates the representation of a resource
   *
   * @param svgHandle a svg handle
   * @param resourceId the id of a resource node
   */
  public void invalidateResourceRepresentation(SVGHandle svgHandle, String resourceId) {

    if (resourceId != null && svgHandle != null) {

      Map<String, ImageRepresentation> idToImageMap = null;

      if (handleToIdToImages.containsKey(svgHandle)) {

        idToImageMap = handleToIdToImages.get(svgHandle);

        if (idToImageMap != null) {

          // removes the id in the map
          synchronized (this) {
            idToImageMap.remove(resourceId);
          }
        }
      }
    }
  }
Пример #2
0
  /**
   * checks if the map associating an id to an image is consistent
   *
   * @param svgHandle a svg handle
   */
  protected void checkResourceRepresentationsConsistency(SVGHandle svgHandle) {

    if (svgHandle != null) {

      Map<String, ImageRepresentation> idToImageMap = null;

      if (handleToIdToImages.containsKey(svgHandle)) {

        idToImageMap = handleToIdToImages.get(svgHandle);

        if (idToImageMap != null) {

          // getting the map associating the id of a resource to the
          // resource node
          LinkedList<String> resourceNames = new LinkedList<String>();
          resourceNames.add("linearGradient");
          resourceNames.add("radialGradient");
          resourceNames.add("pattern");
          resourceNames.add("marker");

          Map<String, Element> resources =
              svgHandle
                  .getSvgResourcesManager()
                  .getResourcesFromDefs(svgHandle.getCanvas().getDocument(), resourceNames);

          for (String id : new LinkedList<String>(idToImageMap.keySet())) {

            if (id != null && !id.equals("") && !resources.containsKey(id)) {

              idToImageMap.remove(id);
            }
          }
        }
      }
    }
  }