Exemplo n.º 1
0
    /** refreshes the representation */
    protected void refreshRepresentation() { // TODO

      ImageRepresentation imageRepresentation = getResourceImage(svgHandle, resourceId);

      if (imageRepresentation != null) {

        if (useSmallImage && imageRepresentation.getSmallImage() != null) {

          synchronized (this) {
            resourceImage = new ImageIcon(imageRepresentation.getSmallImage()).getImage();
          }

        } else if (imageRepresentation.getLargeImage() != null) {

          synchronized (this) {
            resourceImage = new ImageIcon(imageRepresentation.getLargeImage()).getImage();
          }
        }

        if (resourceImage != null) {

          refreshParents();
        }
      }
    }
Exemplo n.º 2
0
  /**
   * getting the image representing a resource given the id of a resource
   *
   * @param svgHandle a svg handle
   * @param resourceId the id of the resource from which the image has been created
   * @param useSmallImage whether the returned image should be small or large
   * @return the image representing the resource
   */
  public Image getImage(SVGHandle svgHandle, String resourceId, boolean useSmallImage) {

    Image image = null;

    if (svgHandle != null && resourceId != null && !resourceId.equals("")) {

      Map<String, ImageRepresentation> idToImageMap = null;

      if (handleToIdToImages.containsKey(svgHandle)) {

        idToImageMap = handleToIdToImages.get(svgHandle);

        if (idToImageMap.containsKey(resourceId)) {

          ImageRepresentation imageRepresentation = idToImageMap.get(resourceId);

          if (imageRepresentation != null) {

            if (useSmallImage) {

              image = imageRepresentation.getSmallImage();

            } else {

              image = imageRepresentation.getLargeImage();
            }
          }
        }
      }
    }

    return image;
  }
Exemplo n.º 3
0
    /**
     * the constructor of the class
     *
     * @param svgHandle a svg handle
     * @param resourceId the id of a resource
     * @param useSmallImage whether this resource representation should display a large or a small
     *     image
     * @param componentToRefresh the component to refresh
     */
    protected ResourceRepresentation(
        SVGHandle svgHandle,
        String resourceId,
        boolean useSmallImage,
        Component componentToRefresh) {

      this.svgHandle = svgHandle;
      this.resourceId = resourceId;
      this.useSmallImage = useSmallImage;
      this.componentToRefresh = componentToRefresh;

      setBackground(Color.white);
      setLayout(null);

      if (useSmallImage) {

        setPreferredSize(new Dimension(smallImageSize.width + 2, smallImageSize.height + 2));

      } else {

        setPreferredSize(new Dimension(imageSize.width + 2, imageSize.height + 2));
      }

      ImageRepresentation imageRepresentation = getResourceImage(svgHandle, resourceId);
      Image image = null;

      if (imageRepresentation != null) {

        if (useSmallImage) {

          image = new ImageIcon(imageRepresentation.getSmallImage()).getImage();

        } else {

          image = new ImageIcon(imageRepresentation.getLargeImage()).getImage();
        }
      }

      if (image == null) {

        resourceRepresentationList.add(this);

      } else {

        synchronized (this) {
          resourceImage = image;
        }
      }
    }