View Javadoc
1   package test;
2   
3   import java.io.IOException;
4   import java.io.InputStream;
5   import java.util.Iterator;
6   import java.util.List;
7   
8   import net.sourceforge.jsh3modtool.gui.imagetable.ImageModel;
9   import net.sourceforge.jsh3modtool.gui.imagetable.ImagePane;
10  import net.sourceforge.jsh3modtool.mod.GameMod;
11  import net.sourceforge.jsh3modtool.mod.ModScreenShot;
12  
13  /***
14   * @author redsolo
15   */
16  public class ModScreenshotsPanel extends ImagePane 
17  {
18  	private GameMod gameMod;
19  
20  	/***
21  	 * 
22  	 */
23  	public ModScreenshotsPanel() {
24  		super(300, (int) (300*0.75));
25  		getModel().setCellComparator(null);
26  	}
27  	
28  	public void setGameMod(GameMod gamemod)
29  	{
30  		gameMod = gamemod;
31  		updateScreenShots();
32  	}
33  	
34  	public GameMod getGameMod()
35  	{
36  		return gameMod;
37  	}
38  	
39  	private void updateScreenShots()
40  	{
41  		if (gameMod == null)
42  		{
43  			getModel().clear();
44  		} else 
45  		{
46  			List screenshots = gameMod.getScreenshots();
47  			for (Iterator iterator = screenshots.iterator(); iterator.hasNext();) {
48  				getModel().addImageModel(new ModScreenShotImageModel((ModScreenShot) iterator.next()));
49  			}
50  		}
51  	}
52  	
53  	private class ModScreenShotImageModel implements ImageModel
54  	{
55  		ModScreenShot screenshot;
56  
57  		/***
58  		 * @param screenshot
59  		 */
60  		public ModScreenShotImageModel(ModScreenShot screenshot) {
61  			super();
62  			this.screenshot = screenshot;
63  		}
64  
65  		public String getName() {
66  			return screenshot.getName();
67  		}
68  
69  
70  		public String getDescription() {
71  			return screenshot.getDescription();
72  		}
73  
74  		public InputStream getData() throws IOException {
75  			return screenshot.getImageData();
76  		}
77  	}
78  }