Created an icon manager for loading icons from tilesets using a
configuration file to map icon set identifiers to tileset images and metrics. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@924 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
#
|
||||
# $Id: iconmgr.properties,v 1.1 2002/02/03 22:43:54 mdb Exp $
|
||||
#
|
||||
# Test properties for the icon manager
|
||||
|
||||
test.path = /media/miso/tiles/node-icons.png
|
||||
test.metrics = 8, 16, 16
|
||||
@@ -0,0 +1,46 @@
|
||||
//
|
||||
// $Id: TestIconManager.java,v 1.1 2002/02/03 22:43:54 mdb Exp $
|
||||
|
||||
package com.threerings.media;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import javax.swing.*;
|
||||
|
||||
import com.samskivert.swing.HGroupLayout;
|
||||
import com.samskivert.swing.util.SwingUtil;
|
||||
|
||||
import com.threerings.resource.ResourceManager;
|
||||
import com.threerings.media.tile.TileManager;
|
||||
|
||||
/**
|
||||
* Does something extraordinary.
|
||||
*/
|
||||
public class TestIconManager
|
||||
{
|
||||
public static void main (String[] args)
|
||||
{
|
||||
try {
|
||||
JFrame frame = new JFrame("TestIconManager");
|
||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
ResourceManager rmgr = new ResourceManager("rsrc", null, null);
|
||||
ImageManager imgr = new ImageManager(rmgr, frame);
|
||||
TileManager tmgr = new TileManager(imgr);
|
||||
IconManager iconmgr = new IconManager(
|
||||
tmgr, "rsrc/config/media/iconmgr.properties");
|
||||
|
||||
JPanel panel = new JPanel(new HGroupLayout());
|
||||
for (int i = 0; i < 8; i++) {
|
||||
panel.add(new JButton(iconmgr.getIcon("test", i)));
|
||||
}
|
||||
|
||||
frame.getContentPane().add(panel, BorderLayout.CENTER);
|
||||
frame.pack();
|
||||
SwingUtil.centerWindow(frame);
|
||||
frame.show();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace(System.err);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user