001: /*
002: * Rollover.java
003: *
004: * Created on 03 April 2007, 15:10
005: *
006: * To change this template, choose Tools | Template Manager
007: * and open the template in the editor.
008: */
009:
010: package com.xoetrope.svgcomponentswizard;
011:
012: import com.kitfox.svg.SVGRoot;
013: import com.kitfox.svg.animation.AnimationElement;
014: import com.xoetrope.svg.XGrabMap;
015: import com.xoetrope.svg.XInfoFileParser;
016: import com.xoetrope.svg.XPrinterInfo;
017: import com.xoetrope.svg.XRolloverComponent;
018: import com.xoetrope.svg.XSvgImageMap;
019: import com.xoetrope.svg.XViewBoxListener;
020: import com.xoetrope.tools.WardGraph;
021: import java.awt.BorderLayout;
022: import java.awt.event.ActionEvent;
023: import java.awt.event.ActionListener;
024: import javax.swing.JComponent;
025: import net.xoetrope.optional.svg.XSvgButton;
026: import net.xoetrope.swing.XApplet;
027: import net.xoetrope.swing.XPanel;
028: import net.xoetrope.swing.XRadioButton;
029: import net.xoetrope.xui.XPage;
030: import net.xoetrope.xui.XPageManager;
031: import net.xoetrope.xui.XProjectManager;
032:
033: /**
034: *
035: * @author kingsley.elmes
036: */
037: public class Rollover extends XPage {
038: protected XSvgImageMap imageMap;
039: protected JComponent glassPane;
040: protected XRolloverComponent rc1, rc2;
041: protected XRadioButton svgButton, glassButton;
042: protected XGrabMap grabMap;
043:
044: private int mode = 0;
045: public static final int SVG_ROLLOVER = 0;
046: public static final int COMPONENT_ROLLOVER = 1;
047:
048: /** Creates a new instance of Rollover */
049: public Rollover() {
050: }
051:
052: /**
053: * Set-up rollover components and position them on the glass pane.
054: */
055: public void pageCreated() {
056: svgButton = (XRadioButton) findComponent("svgButton");
057: glassButton = (XRadioButton) findComponent("glassButton");
058: svgButton.setFocusable(false);
059: glassButton.setFocusable(false);
060:
061: imageMap = (XSvgImageMap) findComponent("imageMap");
062: imageMap.display();
063: imageMap.loadArrays();
064: imageMap.repaint();
065:
066: glassPane = imageMap.getGlassPane();
067: glassPane.setLayout(null);
068:
069: XInfoFileParser parser = new XInfoFileParser(project,
070: "printers.xml");
071: XPrinterInfo printerInfo = new XPrinterInfo();
072: printerInfo.setSize(162, 92);
073: printerInfo.setFontSize(11);
074:
075: parser.read(0, printerInfo);
076:
077: rc1 = new XRolloverComponent(new JComponent[] { printerInfo });
078: rc1.setBounds(470, 172, 11, 11);
079: glassPane.add(rc1);
080:
081: XPrinterInfo printerInfo2 = new XPrinterInfo();
082: printerInfo2.setSize(162, 92);
083: printerInfo2.setFontSize(11);
084:
085: parser.read(1, printerInfo2);
086:
087: WardGraph graph = new WardGraph();
088: graph.setBounds(-250, -200, 250, 200);
089: glassPane.add(graph);
090:
091: rc2 = new XRolloverComponent(new JComponent[] { graph });
092: rc2.setBounds(388, 277, 11, 11);
093: glassPane.add(rc2);
094:
095: XViewBoxListener listener = new XViewBoxListener(imageMap);
096: listener.registerComponent(rc1);
097: listener.registerComponent(rc2);
098:
099: glassPane.setLayout(new BorderLayout());
100: grabMap = new XGrabMap(imageMap);
101: grabMap.setGlassPane(glassPane);
102: grabMap.hideComponents(true);
103: grabMap.disable();
104: }
105:
106: /**
107: * Hide the glass pane if in svg rollover mode and
108: * set it visible otherwise.
109: */
110: public void pageActivated() {
111: if (mode == SVG_ROLLOVER) {
112: glassPane.setVisible(false);
113: } else {
114: glassPane.setVisible(true);
115: }
116: }
117:
118: /**
119: * Set-up svg rollover mode.
120: */
121: public void svgRollover() {
122: imageMap.setURL(project.findResource("Beaumont_Basic.svg"));
123: imageMap.resetBuffer();
124: imageMap.display();
125: imageMap.loadArrays();
126: imageMap.repaint();
127: imageMap.setRollOverStatus(true);
128:
129: glassPane.setVisible(false);
130: grabMap.disable();
131: mode = 0;
132: }
133:
134: /**
135: * Set-up glass pane rollover mode.
136: */
137: public void glassRollover() {
138: imageMap.setURL(project.findResource("Floor5.svg"));
139: imageMap.resetBuffer();
140: imageMap.display();
141: imageMap.resize();
142: imageMap.repaint();
143: imageMap.setRollOverStatus(false);
144:
145: glassPane.setVisible(true);
146: grabMap.enable();
147: mode = 1;
148: }
149:
150: /**
151: * Show welcome page if back button is pressed.
152: */
153: public void showPage() {
154: glassPane.setVisible(false);
155: XPageManager pageMgr = XProjectManager.getPageManager();
156: pageMgr.showPage("Welcome");
157: }
158: }
|