2
* @(#)QuaquaIconFactory.java 3.2 2007-01-05
4
* Copyright (c) 2005-2006 Werner Randelshofer
5
* Staldenmattweg 2, Immensee, CH-6405, Switzerland.
8
* This software is the confidential and proprietary information of
9
* Werner Randelshofer. ("Confidential Information"). You shall not
10
* disclose such Confidential Information and shall use it only in
11
* accordance with the terms of the license agreement you entered into
12
* with Werner Randelshofer.
15
package org.pushingpixels.substance.internal.contrib.randelshofer.quaqua;
19
import java.awt.image.*;
21
import javax.swing.plaf.*;
23
import org.pushingpixels.substance.internal.contrib.randelshofer.quaqua.util.*;
25
//import javax.imageio.*;
26
//import javax.imageio.stream.*;
33
* @author Werner Randelshofer, Christopher Atlan
34
* @version 3.2 2007-01-05 Issue #1: Changed LazyOptionPaneIcon to load image
35
* asynchronously before paintIcon is invoked.
36
* <br>3.1 2006-12-24 by Karl von Randow: Use Images class to create artwork.
37
* <br>3.0.2 2006-11-01 Use Graphics2D.drawImage() to scale application
38
* image icon instead of using Image.getScaledInstance().
39
* <br>3.0.1 2006-05-14 Application icon was unnecessarily created multiple
41
* <br>3.0 2006-05-12 Added support for file icon images. Renamed some
43
* <br>2.1 2006-02-14 Added method createFrameButtonStateIcon.
44
* <br>2.0 2006-02-12 Added methods createApplicationIcon, compose,
45
* createOptionPaneIcon. These methods were contributed by Christopher Atlan.
46
* <br>1.0 December 4, 2005 Created.
48
public class QuaquaIconFactory {
49
private static BufferedImage applicationImage;
53
* Prevent instance creation.
55
private QuaquaIconFactory() {
58
public static URL getResource(String location) {
59
URL url = QuaquaIconFactory.class.getResource(location);
61
throw new InternalError("image resource missing: "+location);
66
public static Image createImage(String location) {
67
return createImage(QuaquaIconFactory.class, location);
69
public static Image createImage(Class baseClass, String location) {
70
return Images.createImage(baseClass.getResource(location));
72
public static Image createBufferedImage(String location) {
73
return Images.toBufferedImage(createImage(location));
76
public static Icon[] createIcons(String location, int count, boolean horizontal) {
77
Icon[] icons = new Icon[count];
79
BufferedImage[] images = Images.split(
80
(Image) createImage(location),
84
for (int i=0; i < count; i++) {
85
icons[i] = new IconUIResource(new ImageIcon(images[i]));
90
public static Icon createIcon(String location, int count, boolean horizontal, int index) {
91
return createIcons(location, count, horizontal)[index];
95
public static Icon createButtonStateIcon(String location, int states) {
96
return new ButtonStateIcon(
97
(Image) createImage(location),
101
public static Icon createButtonStateIcon(String location, int states, Point shift) {
102
return new ShiftedIcon(
104
(Image) createImage(location),
110
public static Icon createButtonStateIcon(String location, int states, Rectangle shift) {
111
return new ShiftedIcon(
113
(Image) createImage(location),
120
public static Icon createIcon(Class baseClass, String location) {
121
return new ImageIcon(createImage(baseClass, location));
123
public static Icon createIcon(Class baseClass, String location, Point shift) {
124
return new ShiftedIcon(
125
new ImageIcon(createImage(baseClass, location)),
129
public static Icon createIcon(Class baseClass, String location, Rectangle shiftAndSize) {
130
return new ShiftedIcon(
131
new ImageIcon(createImage(baseClass, location)),