コード例 #1
0
ファイル: Sequencer.java プロジェクト: Ozgay/EclipseTrader
  /**
   * Place a picture in the display area. Places the picture at a random location on screen.
   *
   * @param picture The picture to place on screen.
   * @param add If <code>true</code>, the picture is added to the history.
   */
  protected void place(final Picture picture, final boolean add) {
    Point p;

    if (Picture.ORIGIN == picture.getOrigin()) {
      // never been placed before
      p = random(picture.getURL().toExternalForm(), picture.width, picture.height);
      picture.x = p.x;
      picture.y = p.y;
      picture.setOrigin(p);
    }
    mThumbelina.getPicturePanel().draw(picture, add);
  }
コード例 #2
0
  /**
   * Find a picture with the given URL in the panel. This should really only be used to discover if
   * the picture is still visible. There could be more than one picture with the given URL because
   * it may be partially obscured by another picture, in which case the pieces are each given their
   * own picture object, but all point at the same <code>URL</code> and <code>Image</code>.
   *
   * @param url The url to locate.
   * @return The first picture encountered in the panel, or null if the picture was not found.
   */
  public Picture find(final String url) {
    Enumeration enumeration;
    Picture picture;
    Picture ret;

    ret = null;
    enumeration = mMosaic.getPictures();
    while ((null == ret) && enumeration.hasMoreElements()) {
      picture = (Picture) enumeration.nextElement();
      if (url.equals(picture.getURL().toExternalForm())) ret = picture;
    }

    return (ret);
  }
コード例 #3
0
ファイル: Sequencer.java プロジェクト: Ozgay/EclipseTrader
  /**
   * Add an image to the panel.
   *
   * @param image The image to add.
   * @param url The url the image came from.
   * @param background If <code>true</code>, just add to pending list.
   */
  public void add(final Image image, final URL url, final boolean background) {
    Picture picture;
    int size;

    picture = new Picture();
    picture.setImage(image);
    picture.setURL(url);
    if (background)
      synchronized (mPending) {
        mPending.add(picture);
        size = mPending.size();
        if (mThumbelina.mReadyProgress.getMaximum() < size)
          mThumbelina.mReadyProgress.setMaximum(size);
        mThumbelina.mReadyProgress.setValue(size);
        mPending.notify();
      }
    else place(picture, false);
  }
コード例 #4
0
  /**
   * Paints this component. Runs through the list of tiles and for every one that intersects the
   * clip region performs a <code>drawImage()</code>.
   *
   * @param graphics The graphics context used to paint with.
   */
  public void paint(final Graphics graphics) {
    Rectangle clip;
    Enumeration enumeration;
    HashSet set; // just so we don't draw things twice
    Picture picture;
    Image image;
    Point origin;
    int width;
    int height;

    adjustClipForInsets(graphics);
    clip = graphics.getClipBounds();
    synchronized (mMosaic) {
      if (0 == mMosaic.getSize()) super.paint(graphics);
      else {
        super.paint(graphics);
        enumeration = mMosaic.getPictures();
        set = new HashSet();
        while (enumeration.hasMoreElements()) {
          picture = (Picture) enumeration.nextElement();
          if ((null == clip) || (clip.intersects(picture))) {
            image = picture.getImage();
            if (!set.contains(image)) {
              origin = picture.getOrigin();
              width = image.getWidth(this);
              height = image.getHeight(this);
              graphics.drawImage(
                  picture.getImage(),
                  origin.x,
                  origin.y,
                  origin.x + width,
                  origin.y + height,
                  0,
                  0,
                  width,
                  height,
                  this);
              set.add(image);
            }
          }
        }
      }
    }
  }
コード例 #5
0
  /**
   * Draw an image on screen.
   *
   * @param picture The picture to draw.
   * @param add If <code>true</code>, the picture is added to the history.
   */
  protected void draw(final Picture picture, final boolean add) {
    Component parent;
    boolean dolayout;
    Dimension before;
    Dimension after;

    parent = getParent();
    dolayout = false;
    synchronized (mMosaic) {
      if (parent instanceof JViewport) {
        before = getPreferredSize();
        mMosaic.add(picture);
        after = calculatePreferredSize();
        if (after.width > before.width) dolayout = true;
        else after.width = before.width;
        if (after.height > before.height) dolayout = true;
        else after.height = before.height;
        if (dolayout) mPreferredSize = after;
      } else mMosaic.add(picture);
    }
    if (dolayout) revalidate();
    repaint(picture.x, picture.y, picture.width, picture.height);
    if (add) mThumbelina.addHistory(picture.getURL().toExternalForm());
  }
コード例 #6
0
 /**
  * Move the given picture to the top of the Z order. Adds it, even it if it doesn't exist. Also
  * puts the URL in the url text of the status bar.
  *
  * @param picture The picture being brought forward.
  */
 public void bringToTop(final Picture picture) {
   picture.reset();
   mMosaic.bringToTop(picture);
   repaint(picture.x, picture.y, picture.width, picture.height);
   mThumbelina.mUrlText.setText(picture.getURL().toExternalForm());
 }
コード例 #7
0
ファイル: Picture.java プロジェクト: typetools/javarifier
 /**
  * Construct a picture from the one given.
  *
  * @param picture The picture to copy.
  */
 public Picture(final Picture picture) {
   super(picture);
   setURL(picture.getURL());
   setImage(picture.getImage());
   setOrigin(picture.getOrigin());
 }