486 super.propertyChange(evt);
487 }
488 }
489
490 /**
491 * A versatile Icon implementation which can take an array of Icon
492 * instances (typically <code>ImageIcon</code>s) and choose one that gives the best
493 * quality for a given Graphics2D scale factor when painting.
494 * <p>
495 * The class is public so it can be instantiated by UIDefaults.ProxyLazyValue.
496 * <p>
497 * Note: We assume here that icons are square.
498 */
499 public static class ScalableIconUIResource implements Icon, UIResource {
500 // We can use an arbitrary size here because we scale to it in paintIcon()
501 private static final int SIZE = 16;
502
503 private Icon[] icons;
504
505 /**
506 * @params objects an array of Icon or UIDefaults.LazyValue
507 * <p>
508 * The constructor is public so it can be called by UIDefaults.ProxyLazyValue.
509 */
510 public ScalableIconUIResource(Object[] objects) {
511 this.icons = new Icon[objects.length];
512
513 for (int i = 0; i < objects.length; i++) {
514 if (objects[i] instanceof UIDefaults.LazyValue) {
515 icons[i] = (Icon)((UIDefaults.LazyValue)objects[i]).createValue(null);
516 } else {
517 icons[i] = (Icon)objects[i];
518 }
519 }
520 }
521
522 /**
523 * @return the <code>Icon</code> closest to the requested size
524 */
525 protected Icon getBestIcon(int size) {
526 if (icons != null && icons.length > 0) {
|
486 super.propertyChange(evt);
487 }
488 }
489
490 /**
491 * A versatile Icon implementation which can take an array of Icon
492 * instances (typically <code>ImageIcon</code>s) and choose one that gives the best
493 * quality for a given Graphics2D scale factor when painting.
494 * <p>
495 * The class is public so it can be instantiated by UIDefaults.ProxyLazyValue.
496 * <p>
497 * Note: We assume here that icons are square.
498 */
499 public static class ScalableIconUIResource implements Icon, UIResource {
500 // We can use an arbitrary size here because we scale to it in paintIcon()
501 private static final int SIZE = 16;
502
503 private Icon[] icons;
504
505 /**
506 * @param objects an array of Icon or UIDefaults.LazyValue
507 * <p>
508 * The constructor is public so it can be called by UIDefaults.ProxyLazyValue.
509 */
510 public ScalableIconUIResource(Object[] objects) {
511 this.icons = new Icon[objects.length];
512
513 for (int i = 0; i < objects.length; i++) {
514 if (objects[i] instanceof UIDefaults.LazyValue) {
515 icons[i] = (Icon)((UIDefaults.LazyValue)objects[i]).createValue(null);
516 } else {
517 icons[i] = (Icon)objects[i];
518 }
519 }
520 }
521
522 /**
523 * @return the <code>Icon</code> closest to the requested size
524 */
525 protected Icon getBestIcon(int size) {
526 if (icons != null && icons.length > 0) {
|