001: package org.zilonis.tool.ui;
002:
003: import java.awt.BorderLayout;
004: import java.awt.Component;
005: import java.awt.event.KeyEvent;
006: import java.awt.event.KeyListener;
007:
008: import javax.swing.JPanel;
009:
010: import org.jdesktop.animation.timing.Animator;
011: import org.jdesktop.animation.timing.TimingTarget;
012: import org.jdesktop.animation.timing.interpolation.PropertySetter;
013: import org.zilonis.network.Rete;
014: import org.zilonis.tool.ext.aerith.animation.ScreenTransition;
015: import org.zilonis.tool.ext.aerith.animation.TransitionTarget;
016:
017: public class TransitionPanel extends JPanel {
018: private static final int TRANSITION_TIME_IN_MILLIS = 500;
019:
020: private final JPanel content;
021: private final LobbyPanel lobbyPanel;
022: private final ScopesPanel scopesPanel;
023: private final RuleAnalysisPanel rulesPanel;
024: private final WMEPanel wmePanel;
025: private final ShellPanel shellPanel;
026:
027: private enum ScreenType {
028: LOBBY, SCOPES, RULES, WMES, SHELL
029: }
030:
031: private ScreenType currentScreen;
032: private ScreenType oldScreen;
033: private final ScreenTransition screenTransition;
034:
035: TransitionPanel(final NavigationHeader navigationHeader) {
036: super (new BorderLayout());
037: setOpaque(false);
038:
039: content = new JPanel();
040: content.setLayout(new BorderLayout());
041: content.setOpaque(false);
042: Rete rete = new Rete();
043: AnalysisToolParserEventHandler analysisToolParserEventHandler = new AnalysisToolParserEventHandler(
044: rete);
045: lobbyPanel = new LobbyPanel();
046: wmePanel = new WMEPanel();
047: wmePanel.setPanelEventHandler(analysisToolParserEventHandler);
048: analysisToolParserEventHandler.setWMEPanel(wmePanel);
049: rulesPanel = new RuleAnalysisPanel(
050: analysisToolParserEventHandler);
051: scopesPanel = new ScopesPanel(analysisToolParserEventHandler);
052: content.add(lobbyPanel, BorderLayout.CENTER);
053: shellPanel = new ShellPanel(analysisToolParserEventHandler);
054:
055: add(navigationHeader, BorderLayout.NORTH);
056: add(content, BorderLayout.CENTER);
057:
058: currentScreen = ScreenType.LOBBY;
059:
060: screenTransition = new ScreenTransition(content,
061: new ContentTransitionTarget());
062: setFocusable(true);
063: }
064:
065: void setContentVisible(boolean visible) {
066: content.setVisible(visible);
067: }
068:
069: void showLobby() {
070: startTransition(ScreenType.LOBBY);
071: }
072:
073: void showScopesPanel() {
074: startTransition(ScreenType.SCOPES);
075: }
076:
077: void showRulesPanel() {
078: startTransition(ScreenType.RULES);
079: }
080:
081: void showWMEPanel() {
082: startTransition(ScreenType.WMES);
083: }
084:
085: void showShell() {
086: startTransition(ScreenType.SHELL);
087: }
088:
089: private void startTransition(ScreenType newScreen) {
090: if (newScreen != currentScreen) {
091: oldScreen = currentScreen;
092: currentScreen = newScreen;
093: screenTransition.startTransition(TRANSITION_TIME_IN_MILLIS);
094: }
095: }
096:
097: private class ContentTransitionTarget implements TransitionTarget {
098: public void resetCurrentScreen() {
099: content.removeAll();
100: }
101:
102: public void setupNextScreen() {
103: switch (currentScreen) {
104: case LOBBY:
105: content.add(lobbyPanel, BorderLayout.CENTER);
106: break;
107: case RULES:
108: content.add(rulesPanel, BorderLayout.CENTER);
109: break;
110: case SCOPES:
111: content.add(scopesPanel, BorderLayout.CENTER);
112: break;
113: case WMES:
114: content.add(wmePanel, BorderLayout.CENTER);
115: break;
116: case SHELL:
117: content.add(shellPanel, BorderLayout.CENTER);
118: break;
119: default:
120: assert false;
121: break;
122: }
123: }
124:
125: public void transitionComplete() {
126: }
127: }
128:
129: void resetSlideshowPanel() {
130: }
131: }
|