001: /*
002: * Welcome.java
003: *
004: * Created on 16 March 2007, 09:37
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.tools.XCircularBackground;
013: import java.awt.Component;
014: import java.awt.Font;
015: import java.awt.event.MouseEvent;
016: import java.awt.event.MouseListener;
017: import javax.swing.SwingUtilities;
018: import net.xoetrope.swing.XImageButton;
019: import net.xoetrope.swing.XPanel;
020: import net.xoetrope.swing.dnd.XTransferHandlerFactory;
021: import net.xoetrope.xui.XPage;
022: import net.xoetrope.xui.XPageManager;
023: import net.xoetrope.xui.XProjectManager;
024:
025: /**
026: *
027: * @author kingsley.elmes
028: */
029: public class Welcome extends XPage implements MouseListener {
030: protected XImageButton imagesButton, magButton, catalogButton,
031: rolloverButton, rockerButton, guageButton;
032: protected XPanel imagesPanel, magPanel, catalogPanel,
033: rolloverPanel, descriptionPanel, listenerPanel;
034: protected XTransferHandlerFactory factory;
035: protected XCircularBackground background;
036:
037: /** Creates a new instance of Welcome */
038: public Welcome() {
039: factory = XTransferHandlerFactory.getInstance(project);
040: }
041:
042: /**
043: * Add mouse listener to each button and set-up circular background panel.
044: */
045: public void pageCreated() {
046: imagesButton = (XImageButton) findComponent("imagesBtn");
047: magButton = (XImageButton) findComponent("magBtn");
048: catalogButton = (XImageButton) findComponent("catalogBtn");
049: rolloverButton = (XImageButton) findComponent("rolloverBtn");
050: rockerButton = (XImageButton) findComponent("rockerBtn");
051: guageButton = (XImageButton) findComponent("guageBtn");
052:
053: descriptionPanel = (XPanel) findComponent("descriptionPanel");
054: listenerPanel = (XPanel) findComponent("listenerPanel");
055:
056: imagesButton.addMouseListener(this );
057: magButton.addMouseListener(this );
058: catalogButton.addMouseListener(this );
059: rolloverButton.addMouseListener(this );
060: rockerButton.addMouseListener(this );
061: guageButton.addMouseListener(this );
062: listenerPanel.addMouseListener(this );
063:
064: background = new XCircularBackground();
065: background.setCircleRotation(0.0);
066: background
067: .setRotatedText(" SVG Components Wizard SVG Components Wizard SVG Components Wizard");
068: // background.setAlignTopLeft( false );
069:
070: descriptionPanel.setPainter(background);
071: }
072:
073: /**
074: * Set the text to be displayed in the circular background panel component and set it visible.
075: */
076: public void pageActivated() {
077: background.setFont(new Font("Arial", Font.BOLD, 14));
078: background
079: .setCenterText("The SVG Components Wizard gives the user an overview of how the various SVG "
080: + "components provided by Carousel can be used for mapping, facilities management, "
081: + "drawing and visualization. The wizard provides options to filter SVG images for "
082: + "certain types and view them, magnify svg images with the aid of the magnifying "
083: + "window and magnifying glass components, view a catalog of products with a shopping "
084: + "cart to drag and drop products too and a details panel displaying details about each product "
085: + "and lastly, a demo of the component rollover and svg rollover features is shown.");
086: descriptionPanel.setVisible(true);
087: }
088:
089: public void mouseEntered(final MouseEvent e) {
090: SwingUtilities.invokeLater(new Runnable() {
091: public void run() {
092: togglePanels(e.getSource());
093: }
094: });
095: }
096:
097: public void mouseExited(MouseEvent e) {
098: }
099:
100: /**
101: * Toggle the current display status of the background panel based on the
102: * object that fired the mouse event.
103: * @param source <CODE>Object</CODE> that fired the smouse event.
104: */
105: private void togglePanels(Object source) {
106: if (source == imagesButton) {
107: background.setCircleRotation(45.0);
108: background
109: .setCenterText("View a set of SVG images with automatic enlargement and preview of the images as the mouse rolls over the components. The preview is useful for both highlighting important information and for selection purposes.");
110: } else if (source == magButton) {
111: background.setCircleRotation(37.0);
112: background
113: .setCenterText("Magnify SVG images using a magnifying glass or an airplane view. The magnifier saves some space over the airplane view as it does not need a window of its own. The magnifier rotates so that the enlarged view is always visible within the client area of the image.");
114: } else if (source == catalogButton) {
115: background.setCircleRotation(22.0);
116: background
117: .setCenterText("Display a catalog of items with stats and information. The catalog integrates SVG components and normal Swing components using painters and other such mechanisms. Using this catalog SVG images are display in a shopping cart and can be dragged and dropped.");
118: } else if (source == rolloverButton) {
119: background.setCircleRotation(15.0);
120: background
121: .setCenterText("Mouse over certain parts of the svg images to display rollover components. Again rollovers are used to highlight a area of an SVG, in this case the rollover is an expanded version of the item under the cursor.");
122: } else if (source == rockerButton) {
123: background.setCircleRotation(8.0);
124: background
125: .setCenterText("View an SVG rocker component that can be used for panning images left, right, up and down. This example displays a layered SVG image, where the layers are turned on or off to give rollover and mouse pressed effects.");
126: } else if (source == guageButton) {
127: background.setCircleRotation(1.0);
128: background
129: .setCenterText("View an SVG guage component in which the needle can be rotated using mouse clicks. Animation is used to show some of the capabilities of SVG and add greater interactivity. Click on the needle while holding or releasing the CTRL key to move the guage's needle.");
130: }
131: descriptionPanel.repaint();
132: }
133:
134: /**
135: * Show page method which is called to display one of the wizard's pages.
136: */
137: public void showPage() {
138: XPageManager pageMgr = XProjectManager.getPageManager();
139: String page = ((Component) getCurrentEvent().getSource())
140: .getName();
141: String destination = ((String) getAttribute("dest", page));
142:
143: if (destination.equals("Images"))
144: background.setCircleRotation(45.0);
145: else if (destination.equals("Magnification"))
146: background.setCircleRotation(37.0);
147: else if (destination.equals("Catalog"))
148: background.setCircleRotation(22.0);
149: else if (destination.equals("Rollover"))
150: background.setCircleRotation(15.0);
151: else if (destination.equals("SvgRocker"))
152: background.setCircleRotation(8.0);
153: else if (destination.equals("SvgGuage"))
154: background.setCircleRotation(8.0);
155:
156: pageMgr.showPage(destination);
157: }
158:
159: public void mouseClicked(MouseEvent e) {
160: }
161:
162: public void mousePressed(MouseEvent e) {
163: }
164:
165: public void mouseReleased(MouseEvent e) {
166: }
167: }
|