01: package net.xoetrope.xui.test;
02:
03: import java.awt.Frame;
04: import java.awt.event.MouseEvent;
05:
06: import net.xoetrope.awt.XHotspotImage;
07: import net.xoetrope.awt.XLabel;
08: import net.xoetrope.xui.XPage;
09: import net.xoetrope.xui.XResourceManager;
10: import net.xoetrope.xui.XTextRenderer;
11:
12: /**
13: * <p>Title: Xui</p>
14: * <p>Description: </p>
15: * <p>Copyright: Copyright (c) Xoetrope Ltd., 1998-2003</p>
16: * <p>Company: Xoetrope Ltd.</p>
17: * @author not attributable
18: * @version 1.0
19: */
20:
21: public class HotspotFrame extends XPage {
22: protected static final int OUTSIDE_AIR = 6;
23: XHotspotImage roomImage;
24: Frame frame;
25: XLabel lblTest;
26:
27: public HotspotFrame() {
28: frame = new Frame("XImageHotspot Test");
29: frame.setLayout(null);
30: frame.setSize(640, 480);
31: this .setBounds(frame.getBounds());
32: roomImage = (XHotspotImage) componentFactory.addComponent(
33: XPage.HOTSPOTIMAGE, 50, 10, 585, 253, "roomdata.jpg");
34:
35: componentFactory.addComponent(XPage.IMAGE, 10, 350, 134, 28,
36: "SingleRoomOn.gif");
37: lblTest = (XLabel) componentFactory.addComponent(XPage.LABEL,
38: 150, 350, 134, 35,
39: "This is the test wrapping label ® °C");
40: lblTest.setAlignment(XTextRenderer.RIGHT);
41: frame.setVisible(true);
42: frame.show();
43: frame.add(this );
44: addMouseHandler(roomImage, "handleHotspotsClicks");
45: setupHotspots();
46: }
47:
48: public void setupHotspots() {
49: try {
50: roomImage.read(XResourceManager.getBufferedReader(
51: "Hotspots.xml", null));
52: } catch (Exception ex) {
53: ex.printStackTrace();
54: }
55: }
56:
57: public void handleHotspotsClicks() {
58: if (wasMouseClicked()) {
59: switch (roomImage
60: .checkHotspot(((MouseEvent) getCurrentEvent())
61: .getPoint())) {
62: case OUTSIDE_AIR:
63: showMessage("Input error", "This is a test message");
64: break;
65: }
66: }
67: }
68:
69: }
|