001: /*
002: * Images.java
003: *
004: * Created on 16 March 2007, 15:06
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.xoetrope.svg.XSvgImageMap;
013: import com.xoetrope.svg.XSvgMagnifyingWindow;
014: import java.awt.BorderLayout;
015: import java.awt.Color;
016: import java.awt.Point;
017: import java.awt.event.MouseEvent;
018: import java.awt.event.MouseListener;
019: import javax.swing.BorderFactory;
020: import javax.swing.JComponent;
021: import javax.swing.JFrame;
022: import javax.swing.JPanel;
023: import net.xoetrope.swing.XApplet;
024: import net.xoetrope.swing.XPanel;
025: import net.xoetrope.xui.XPage;
026: import net.xoetrope.xui.XPageManager;
027: import net.xoetrope.xui.XProjectManager;
028:
029: /**
030: *
031: * @author kingsley.elmes
032: */
033: public class Images extends XPage implements MouseListener {
034: protected XSvgImageMap imageMap1, imageMap2, imageMap3, imageMap4,
035: imageMap5, imageMap6, imageMap7, imageMap8, imageMap9,
036: imageMap10, imageMap11, imageMap12, largeMap;
037: protected XPanel mainPanel;
038: protected JComponent glassPane;
039: protected XSvgMagnifyingWindow magWindow;
040: protected JPanel mapPanel;
041:
042: /** Creates a new instance of Images */
043: public Images() {
044: }
045:
046: /**
047: * Display svg images and add mouse listener to each one.
048: */
049: public void pageCreated() {
050: glassPane = (JComponent) findComponent("glassPane");
051:
052: imageMap1 = (XSvgImageMap) findComponent("imageMap1");
053: imageMap2 = (XSvgImageMap) findComponent("imageMap2");
054: imageMap3 = (XSvgImageMap) findComponent("imageMap3");
055: imageMap4 = (XSvgImageMap) findComponent("imageMap4");
056: imageMap5 = (XSvgImageMap) findComponent("imageMap5");
057: imageMap6 = (XSvgImageMap) findComponent("imageMap6");
058: imageMap7 = (XSvgImageMap) findComponent("imageMap7");
059: imageMap8 = (XSvgImageMap) findComponent("imageMap8");
060: imageMap9 = (XSvgImageMap) findComponent("imageMap9");
061: imageMap10 = (XSvgImageMap) findComponent("imageMap10");
062: imageMap11 = (XSvgImageMap) findComponent("imageMap11");
063: imageMap12 = (XSvgImageMap) findComponent("imageMap12");
064:
065: imageMap1.addMouseListener(this );
066: imageMap2.addMouseListener(this );
067: imageMap3.addMouseListener(this );
068: imageMap4.addMouseListener(this );
069: imageMap5.addMouseListener(this );
070: imageMap6.addMouseListener(this );
071: imageMap7.addMouseListener(this );
072: imageMap8.addMouseListener(this );
073: imageMap9.addMouseListener(this );
074: imageMap10.addMouseListener(this );
075: imageMap11.addMouseListener(this );
076: imageMap12.addMouseListener(this );
077:
078: mapPanel = new JPanel();
079: mapPanel.setBorder(BorderFactory.createLineBorder(Color.black));
080: mapPanel.setLayout(new BorderLayout());
081: mapPanel.setOpaque(true);
082: }
083:
084: public void pageActivated() {
085: }
086:
087: /**
088: * Displays the welcome page if the back button is pressed.
089: */
090: public void showPage() {
091: XPageManager pageMgr = XProjectManager.getPageManager();
092: pageMgr.showPage("Welcome");
093: }
094:
095: /**
096: * Displays an enlarged image when a rollover occurs on one of the svg images.
097: * @param e the passed <CODE>MouseEvent</CODE>.
098: */
099: public void mouseEntered(MouseEvent e) {
100: largeMap = new XSvgImageMap();
101:
102: XSvgImageMap m = (XSvgImageMap) e.getSource();
103: Point loc = m.getLocation();
104: Point mouse = e.getPoint();
105:
106: if ((loc.x < getWidth() / 2) && (loc.y < getHeight() / 2)) { // 1
107: mapPanel.setBounds(m.getX() + m.getWidth(), m.getY(), 300,
108: 300);
109: } else if ((loc.x > getWidth() / 2)
110: && (loc.y < getHeight() / 2)) { // 2
111: mapPanel.setBounds(m.getX() - mapPanel.getWidth(),
112: m.getY(), 300, 300);
113: } else if ((loc.x < getWidth() / 2)
114: && (loc.y > getHeight() / 2)) { // 3
115: mapPanel.setBounds(m.getX() + m.getWidth(), m.getY()
116: - (mapPanel.getHeight() - m.getHeight()), 300, 300);
117: } else if ((loc.x > getWidth() / 2)
118: && (loc.y > getHeight() / 2)) { // 4
119: mapPanel.setBounds(m.getX() - mapPanel.getWidth(), m.getY()
120: - (mapPanel.getHeight() - m.getHeight()), 300, 300);
121: }
122:
123: largeMap.setURL(m.getURL());
124: largeMap.display();
125: mapPanel.removeAll();
126: mapPanel.add(largeMap);
127:
128: glassPane.add(mapPanel);
129:
130: glassPane.setVisible(true);
131: glassPane.repaint();
132: }
133:
134: /**
135: * Hide glass pane when a mouse exited event occurs.
136: * @param e the passed <CODE>MouseEvent</CODE>.
137: */
138: public void mouseExited(MouseEvent e) {
139: glassPane.setVisible(false);
140: }
141:
142: public void mouseClicked(MouseEvent e) {
143: }
144:
145: public void mousePressed(MouseEvent e) {
146: }
147:
148: public void mouseReleased(MouseEvent e) {
149: }
150: }
|