View Javadoc

1   /*
2    * VAST - VOTech/Astrogrid Siap Tool.
3    * An ACR-based client for searching SIAP servers.
4    * The joke is that is should actually be quite small.
5    * John Taylor, ROE/VOTech/AstroGrid jdt AT roe.ac.uk
6    * 15-Feb-2006
7    */
8   package org.votech.ds6.imageutils;
9   
10  import java.awt.Image;
11  import java.net.URL;
12  
13  
14  
15  /**
16   * @author jdt
17   *
18   */
19  public class ResizableImageIcon extends javax.swing.ImageIcon {
20  
21  	/**
22  	 * 
23  	 */
24  	private static final long serialVersionUID = 1L;
25  
26  
27  	public ResizableImageIcon() {
28  		super();
29  	}
30  
31  	public ResizableImageIcon(byte[] arg0, String arg1) {
32  		super(arg0, arg1);
33  	}
34  
35  	public ResizableImageIcon(byte[] arg0) {
36  		super(arg0);
37  	}
38  
39  	public ResizableImageIcon(Image arg0, String arg1) {
40  		super(arg0, arg1);
41  	}
42  
43  	public ResizableImageIcon(Image arg0) {
44  		super(arg0);
45  	}
46  
47  	public ResizableImageIcon(String arg0, String arg1) {
48  		super(arg0, arg1);
49  	}
50  
51  	public ResizableImageIcon(String arg0) {
52  		super(arg0);
53  	}
54  
55  	public ResizableImageIcon(URL arg0, String arg1) {
56  		super(arg0, arg1);
57  	}
58  
59  	public ResizableImageIcon(URL arg0) {
60  		super(arg0);
61  	}
62  
63  	private Image original;
64  
65  	
66  	public void resize(int x, int y) {
67          if (x==curr_x && y==curr_y) {
68              //do nothing
69              return;
70          }
71  		if (original==null) {
72  			//First time we've resized
73  			original = super.getImage();
74  		}
75  		Image resized = original.getScaledInstance(x,y,Image.SCALE_DEFAULT);
76  		super.setImage(resized);
77          curr_x=x;
78          curr_y=y;
79  	}
80      
81      int curr_x = -10, curr_y=-10;
82  
83  
84  
85  
86  }