01: package net.xoetrope.samples.travel;
02:
03: import java.awt.Cursor;
04: import java.awt.Point;
05:
06: import net.xoetrope.awt.XImage;
07: import net.xoetrope.awt.XLabel;
08: import net.xoetrope.xui.XPage;
09: import net.xoetrope.xui.XProjectManager;
10:
11: /**
12: * <p>Title: Xui</p>
13: * <p>Description: </p>
14: * <p>Copyright: Copyright (c) Xoetrope Ltd., 1998-2003</p>
15: * <p>Company: Xoetrope Ltd.</p>
16: * @author not attributable
17: * @version 1.0
18: */
19:
20: public class SightSeeingTour extends XPage {
21: XMapViewer mapViewer;
22: XLabel lblMollyMalone, lblDublinCastle;
23: XImage imgNext;
24: XImage imgBack;
25: int currentLocation = 0;
26:
27: public SightSeeingTour() {
28: imgBack = (XImage) componentFactory.addComponent(XPage.IMAGE,
29: 220, 10, 18, 14, "home.gif");
30: mapViewer = (XMapViewer) componentFactory.addComponent(
31: "net.xoetrope.samples.travel.XMapViewer", 0, 0, 250,
32: 300);
33: mapViewer.setMap("DublinMap.gif", 1001, 1091, null);
34: addLocations();
35: setCursors();
36: mapEvents();
37: remove(imgBack);
38: add(imgBack);
39: }
40:
41: public void addLocations() {
42: imgNext = (XImage) mapViewer.addButton("navright.jpg");
43: lblMollyMalone = (XLabel) mapViewer.addLocation(500, 500, " 1");
44: lblDublinCastle = (XLabel) mapViewer
45: .addLocation(224, 515, " 2");
46: mapViewer.centerLocation(lblMollyMalone);
47: mapViewer.setStatus("1: Molly Malone");
48: currentLocation = 1;
49: }
50:
51: public void setCursors() {
52: lblMollyMalone.setCursor(hand);
53: lblDublinCastle.setCursor(hand);
54: }
55:
56: public void showNext() {
57: if (wasMouseClicked()) {
58: switch (++currentLocation) {
59: case 2:
60: mapViewer.centerLocation(lblDublinCastle);
61: mapViewer.setStatus("2: Dublin Castle");
62: mapViewer.addPoint(509, 525);
63: mapViewer.addPoint(new Point(457, 496));
64: mapViewer.addPoint(new Point(457, 473));
65: mapViewer.addPoint(new Point(217, 487));
66: mapViewer.addPoint(new Point(224, 510));
67: mapViewer.repaint();
68: }
69: }
70: }
71:
72: public void mapEvents() {
73: addMouseHandler(imgNext, "showNext");
74: addMouseHandler(lblMollyMalone, "viewMollyMalone");
75: addMouseHandler(lblDublinCastle, "viewDublinCastle");
76: addMouseHandler(imgBack, "goHome");
77: }
78:
79: public void goHome() {
80: if (wasMouseClicked())
81: XProjectManager.getPageManager().showPage("Services");
82: }
83:
84: public void viewMollyMalone() {
85: if (wasMouseClicked())
86: if (((XLabel) getCurrentEvent().getSource()).getText()
87: .trim().compareTo("1") == 0)
88: XProjectManager.getPageManager()
89: .showPage("MollyMalone");
90: }
91:
92: public void viewDublinCastle() {
93: if (wasMouseClicked())
94: XProjectManager.getPageManager().showPage("DublinCastle");
95: }
96:
97: }
|