예제 #1
0
 /**
  * Forwards the <code>DocumentEvent</code> to the give child view. This simply messages the view
  * with a call to <code>insertUpdate</code>, <code>removeUpdate</code>, or <code>changedUpdate
  * </code> depending upon the type of the event. This is called by <a
  * href="#forwardUpdate">forwardUpdate</a> to forward the event to children that need it.
  *
  * @param v the child view to forward the event to
  * @param e the change information from the associated document
  * @param a the current allocation of the view
  * @param f the factory to use to rebuild if the view has children
  * @see #forwardUpdate
  * @since 1.3
  */
 protected void forwardUpdateToView(View v, DocumentEvent e, Shape a, ViewFactory f) {
   DocumentEvent.EventType type = e.getType();
   if (type == DocumentEvent.EventType.INSERT) {
     v.insertUpdate(e, a, f);
   } else if (type == DocumentEvent.EventType.REMOVE) {
     v.removeUpdate(e, a, f);
   } else {
     v.changedUpdate(e, a, f);
   }
 }
  /** Invoked when the Elements attributes have changed. Recreates the image. */
  @Override
  public void changedUpdate(DocumentEvent e, Shape a, ViewFactory f) {
    super.changedUpdate(e, a, f);

    synchronized (this) {
      state |= RELOAD_FLAG | RELOAD_IMAGE_FLAG;
    }

    // Assume the worst.
    preferenceChanged(null, true, true);
  }
  /** My attributes may have changed. */
  public void changedUpdate(DocumentEvent e, Shape a, ViewFactory f) {
    if (DEBUG) System.out.println("ImageView: changedUpdate begin...");
    super.changedUpdate(e, a, f);
    float align = getVerticalAlignment();

    int height = fHeight;
    int width = fWidth;

    initialize(getElement());

    boolean hChanged = fHeight != height;
    boolean wChanged = fWidth != width;
    if (hChanged || wChanged || getVerticalAlignment() != align) {
      if (DEBUG) System.out.println("ImageView: calling preferenceChanged");
      getParent().preferenceChanged(this, hChanged, wChanged);
    }
    if (DEBUG) System.out.println("ImageView: changedUpdate end; valign=" + getVerticalAlignment());
  }