001 package org.LiveGraph.gui.msg;
002
003 import java.awt.Dimension;
004 import java.awt.Toolkit;
005
006 import javax.swing.WindowConstants;
007
008 import org.LiveGraph.LiveGraph;
009 import org.LiveGraph.events.Event;
010 import org.LiveGraph.gui.GUIEvent;
011 import org.LiveGraph.gui.LiveGraphFrame;
012
013 import java.awt.event.WindowAdapter;
014 import java.awt.event.WindowEvent;
015
016 /**
017 * This is the application's message window.
018 *
019 * <p style="font-size:smaller;">This product includes software developed by the
020 * <strong>LiveGraph</strong> project and its contributors.<br />
021 * (<a href="http://www.live-graph.org" target="_blank">http://www.live-graph.org</a>)<br />
022 * Copyright (c) 2007-2008 G. Paperin.<br />
023 * All rights reserved.
024 * </p>
025 * <p style="font-size:smaller;">File: MessageWindow.java</p>
026 * <p style="font-size:smaller;">Redistribution and use in source and binary forms, with or
027 * without modification, are permitted provided that the following terms and conditions are met:
028 * </p>
029 * <p style="font-size:smaller;">1. Redistributions of source code must retain the above
030 * acknowledgement of the LiveGraph project and its web-site, the above copyright notice,
031 * this list of conditions and the following disclaimer.<br />
032 * 2. Redistributions in binary form must reproduce the above acknowledgement of the
033 * LiveGraph project and its web-site, the above copyright notice, this list of conditions
034 * and the following disclaimer in the documentation and/or other materials provided with
035 * the distribution.<br />
036 * 3. All advertising materials mentioning features or use of this software or any derived
037 * software must display the following acknowledgement:<br />
038 * <em>This product includes software developed by the LiveGraph project and its
039 * contributors.<br />(http://www.live-graph.org)</em><br />
040 * 4. All advertising materials distributed in form of HTML pages or any other technology
041 * permitting active hyper-links that mention features or use of this software or any
042 * derived software must display the acknowledgment specified in condition 3 of this
043 * agreement, and in addition, include a visible and working hyper-link to the LiveGraph
044 * homepage (http://www.live-graph.org).
045 * </p>
046 * <p style="font-size:smaller;">THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY
047 * OF ANY KIND, EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
048 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
049 * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
050 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
051 * IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
052 * </p>
053 *
054 * @author Greg Paperin (<a href="http://www.paperin.org" target="_blank">http://www.paperin.org</a>)
055 * @version {@value org.LiveGraph.LiveGraph#version}
056 */
057 public class MessageWindow extends LiveGraphFrame {
058
059
060 /**
061 * This is the default constructor.
062 */
063 public MessageWindow() {
064 super();
065 initialize();
066 }
067
068
069 /**
070 * This method initializes the main window.
071 */
072 private void initialize() {
073
074 // Main window size and position:
075 final int WIN_WIDTH = 600;
076 final int WIN_HEIGHT = 200;
077 Dimension scr = Toolkit.getDefaultToolkit().getScreenSize();
078 this.setBounds((scr.width - WIN_WIDTH) / 2, (scr.height - WIN_HEIGHT) / 2, WIN_WIDTH, WIN_HEIGHT);
079
080 // Other main settings:
081 this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
082 this.setTitle("Messages (LiveGraph)");
083
084 // Closing handler:
085 this.addWindowListener(new WindowAdapter() {
086 @Override public void windowClosing(WindowEvent e) {
087 LiveGraph.application().guiManager().setDisplayMessageWindows(false);
088 }
089 });
090
091 } // private void initialize()
092
093 /**
094 * Updates local view on GUI events.
095 *
096 * @param event A GUI event.
097 */
098 @Override
099 protected void processGUIEvent(Event<GUIEvent> event) {
100
101 super.processGUIEvent(event);
102 if (GUIEvent.GUI_MessagesDisplayStateChanged == event.getType()) {
103 setVisible(event.getInfoBoolean());
104 }
105 }
106
107 } // public class MessageWindow