Class Netmonitor

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjava.awt.Window
              extended byjava.awt.Frame
                  extended byjavax.swing.JFrame
                      extended byNetmonitor
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, javax.swing.RootPaneContainer, java.io.Serializable, javax.swing.WindowConstants

public class Netmonitor
extends javax.swing.JFrame

Netmonitor is the main class and it is responsible for managing the SQL calls and creating the data objects. It initializes a MapFrame object which acts as Nemo's main GUI window. All classes who needs data from the database calls the respective method in this class, which starts a new thread that performs the SQL query. When the SQL thread finishes, the data is used to build objects that are passed on to other classes.

See Also:
MapFrame, Serialized Form

Nested Class Summary
(package private)  class Netmonitor.AnimationFrame
          Class holding lists of point and line statistics.
(package private)  class Netmonitor.AnimationQueue
          Fifo circular buffer that holds animation frames.
(package private)  class Netmonitor.FrameConsumer
           
(package private)  class Netmonitor.FrameProducer
           
(package private)  class Netmonitor.SQLquery
           
(package private)  class Netmonitor.ThreadCoordinator
           
 
Nested classes inherited from class javax.swing.JFrame
javax.swing.JFrame.AccessibleJFrame
 
Nested classes inherited from class java.awt.Frame
java.awt.Frame.AccessibleAWTFrame
 
Nested classes inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
private  boolean animating
           
private  Netmonitor.AnimationQueue animationQueue
           
private  boolean autoUpdateLoad
           
private  Netmonitor.AnimationFrame currentAnimationFrame
           
private  NetworkElement currentNetwork
           
private  boolean doneFetchingMaps
           
private  boolean doneFetchingStats
           
private static int EQ_STATS
           
private  Netmonitor.FrameConsumer frameConsumer
           
private  Netmonitor.FrameProducer frameProducer
           
private static int LINE_STATS
           
private static int LINES
           
private static int LINEURL
           
private static int LINEVALUE_STATS
           
private  MapFrame mapFrame
           
private static int MAPS
           
private  javax.swing.DefaultListModel networkList
           
private static int NETWORKS
           
private static int POINT_STATS
           
private static int POINTS
           
private static int POINTURL
           
private  java.sql.Connection SQLconnection
           
private static int STATISTICS
           
 
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Fields inherited from class java.awt.Window
 
Fields inherited from class java.awt.Container
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
Netmonitor()
          Creates new form Netmonitor
 
Method Summary
 void addStatistic(StatisticElement statElement)
          Adds a statistic to the list of chosen statistics in the current network.
 void checkAvailableStatistics(int stepSize)
           
 void connectSQLdatabase(java.lang.String databaseURL, java.lang.String username, java.lang.String password)
          Connects to the SQL database given in the databaseURL argument.
 void createEquipmentStatistics(java.sql.ResultSet rs)
           
 void createLineElements(java.sql.ResultSet rs)
           
 void createLineStatistics(java.sql.ResultSet rs)
           
 void createLineURL(java.sql.ResultSet rs)
           
 void createLineValueStatistics(java.sql.ResultSet rs)
           
 void createMapElements(java.sql.ResultSet rs)
           
 void createNetworkElements(java.sql.ResultSet rs)
           
 void createPointElements(java.sql.ResultSet rs)
           
 void createPointStatistics(java.sql.ResultSet rs)
           
 void createPointURL(java.sql.ResultSet rs)
           
 void createStatisticElements(java.sql.ResultSet rs)
           
 boolean getAutoUpdateLoad()
           
 NetworkElement getCurrentNetwork()
          Returns the current network.
 void handleSQLResult(int queryid, java.sql.ResultSet rs)
           
 void init(java.lang.String dbname, java.lang.String username, java.lang.String password, java.lang.String networkString, java.lang.String mapString, java.lang.String lineColourString, java.lang.String lineSizeString, java.lang.String pointColourString, java.lang.String pointSizeString)
          Takes all the command-line parameters as arguments and uses them to select a network, map or statistic.
private  void initComponents()
          This method is called from within the constructor to initialize the form.
static void main(java.lang.String[] args)
          Execution of Nemo starts here.
 java.lang.String parseEquipmentStatQuery(StatisticElement.PointSQLTable table, java.util.Date date, PointElement pointElement, StatisticElement statElement)
           
 java.lang.String parseLineStatQuery(StatisticElement.LineSQLTable table, java.util.Date date, MapElement mapElement, StatisticElement statElement)
           
 java.lang.String parseLineValueStatQuery(StatisticElement.LineSQLTable table, java.util.Date date, LineElement lineElement, StatisticElement statElement)
           
 java.lang.String parsePointStatQuery(StatisticElement.PointSQLTable table, java.util.Date date, MapElement mapElement, StatisticElement statElement)
           
 void retrieveEquipmentStatistics(java.util.Date date, int stepSize, PointElement pointElement)
           
 void retrieveLineURL(LineElement lineElement)
           
 void retrieveLineValueStatistics(java.util.Date date, int stepSize, LineElement lineElement)
           
 void retrieveMap(MapElement mapElement)
          Creates SQLqueries that asks for the image of the map to be retrieved, and all the lines and points belonging to the map.
 void retrieveMapList()
          Creates a new SQLquery thread that asks for all the maps that belongs to the current network.
 void retrievePointURL(PointElement pointElement)
           
 void retrieveStatisticList()
          Creates a new SQLquery thread that asks for all the statistics that belongs to the current network.
 void retrieveStatistics(java.util.Date date, int stepSize)
          Tells the FrameProducer and FrameConsumer objects that a new frame is requested.
 void setCurrentNetwork(NetworkElement network)
          Sets the current network to the networkelement given in the argument.
 void setMaxBufferSize(int size)
           
 void stop()
          Disconnects from sql database.
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Frame
addNotify, finalize, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setIconImage, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, hide, isActive, isFocusableWindow, isFocusCycleRoot, isFocused, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationRelativeTo, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

currentNetwork

private NetworkElement currentNetwork

networkList

private javax.swing.DefaultListModel networkList

mapFrame

private MapFrame mapFrame

autoUpdateLoad

private boolean autoUpdateLoad

doneFetchingMaps

private boolean doneFetchingMaps

doneFetchingStats

private boolean doneFetchingStats

animating

private boolean animating

SQLconnection

private java.sql.Connection SQLconnection

currentAnimationFrame

private Netmonitor.AnimationFrame currentAnimationFrame

animationQueue

private Netmonitor.AnimationQueue animationQueue

frameProducer

private Netmonitor.FrameProducer frameProducer

frameConsumer

private Netmonitor.FrameConsumer frameConsumer

MAPS

private static final int MAPS
See Also:
Constant Field Values

POINTS

private static final int POINTS
See Also:
Constant Field Values

LINES

private static final int LINES
See Also:
Constant Field Values

POINT_STATS

private static final int POINT_STATS
See Also:
Constant Field Values

LINE_STATS

private static final int LINE_STATS
See Also:
Constant Field Values

NETWORKS

private static final int NETWORKS
See Also:
Constant Field Values

STATISTICS

private static final int STATISTICS
See Also:
Constant Field Values

POINTURL

private static final int POINTURL
See Also:
Constant Field Values

LINEURL

private static final int LINEURL
See Also:
Constant Field Values

EQ_STATS

private static final int EQ_STATS
See Also:
Constant Field Values

LINEVALUE_STATS

private static final int LINEVALUE_STATS
See Also:
Constant Field Values
Constructor Detail

Netmonitor

public Netmonitor()
Creates new form Netmonitor

Method Detail

initComponents

private void initComponents()
This method is called from within the constructor to initialize the form. WARNING: Do NOT modify this code. The content of this method is always regenerated by the Form Editor.


init

public void init(java.lang.String dbname,
                 java.lang.String username,
                 java.lang.String password,
                 java.lang.String networkString,
                 java.lang.String mapString,
                 java.lang.String lineColourString,
                 java.lang.String lineSizeString,
                 java.lang.String pointColourString,
                 java.lang.String pointSizeString)
Takes all the command-line parameters as arguments and uses them to select a network, map or statistic.

Parameters:
networkString - name of the network to be selected at startup
mapString - name of the map to be selected at startup
lineColourString - name of the statistic used to represent the linecolour at startup
lineSizeString - name of the statistic used to represent the linesize at startup
pointColourString - name of the statistic used to represent the pointcolour at startup
pointSizeString - name of the statistic used to represent the pointsize at startup

main

public static void main(java.lang.String[] args)
Execution of Nemo starts here. A new Netmonitor object is initialized and the command-line arguments are read in and passed on to the init() method.


connectSQLdatabase

public void connectSQLdatabase(java.lang.String databaseURL,
                               java.lang.String username,
                               java.lang.String password)
Connects to the SQL database given in the databaseURL argument.

Parameters:
databaseURL - the location of the database.
username - the username to log into the database with.
password - the password to log into the database with.

setCurrentNetwork

public void setCurrentNetwork(NetworkElement network)
Sets the current network to the networkelement given in the argument. The maplist and the statisticlist of the network are then retrieved.

Parameters:
network - a NetworkElement that will be used as the current network.

getCurrentNetwork

public NetworkElement getCurrentNetwork()
Returns the current network.

Returns:
the NetworkElement that represents the current network.

addStatistic

public void addStatistic(StatisticElement statElement)
Adds a statistic to the list of chosen statistics in the current network.

Parameters:
statElement - a StatisticElement to be added to the list of chosen statistics.

retrieveMapList

public void retrieveMapList()
Creates a new SQLquery thread that asks for all the maps that belongs to the current network.


retrieveStatisticList

public void retrieveStatisticList()
Creates a new SQLquery thread that asks for all the statistics that belongs to the current network.


retrieveMap

public void retrieveMap(MapElement mapElement)
Creates SQLqueries that asks for the image of the map to be retrieved, and all the lines and points belonging to the map. The points are retrieved first, and we wait until they are in place before we retrieve the lines, since the lines depends on having the points in place in order to connect to them properly. A ThreadCoordinator object makes sure that the map is drawn after both the lines and the mapimage are retrieved.

Parameters:
mapElement - the map to be retrieved.

retrieveStatistics

public void retrieveStatistics(java.util.Date date,
                               int stepSize)
Tells the FrameProducer and FrameConsumer objects that a new frame is requested. A frame is composed lists of statistic objects that contains the colour and size of the lines and points on the map. The frame is eventually fetched, and its contents are drawn on the map.

Parameters:
date - the date the statistic is from.
stepSize - the size of the steps in time between each recorded measure point. E.g. 5 minutes, 1 hour, 1 day.

parsePointStatQuery

public java.lang.String parsePointStatQuery(StatisticElement.PointSQLTable table,
                                            java.util.Date date,
                                            MapElement mapElement,
                                            StatisticElement statElement)

parseLineStatQuery

public java.lang.String parseLineStatQuery(StatisticElement.LineSQLTable table,
                                           java.util.Date date,
                                           MapElement mapElement,
                                           StatisticElement statElement)

retrieveEquipmentStatistics

public void retrieveEquipmentStatistics(java.util.Date date,
                                        int stepSize,
                                        PointElement pointElement)

parseEquipmentStatQuery

public java.lang.String parseEquipmentStatQuery(StatisticElement.PointSQLTable table,
                                                java.util.Date date,
                                                PointElement pointElement,
                                                StatisticElement statElement)

retrievePointURL

public void retrievePointURL(PointElement pointElement)

retrieveLineURL

public void retrieveLineURL(LineElement lineElement)

retrieveLineValueStatistics

public void retrieveLineValueStatistics(java.util.Date date,
                                        int stepSize,
                                        LineElement lineElement)

parseLineValueStatQuery

public java.lang.String parseLineValueStatQuery(StatisticElement.LineSQLTable table,
                                                java.util.Date date,
                                                LineElement lineElement,
                                                StatisticElement statElement)

checkAvailableStatistics

public void checkAvailableStatistics(int stepSize)

handleSQLResult

public void handleSQLResult(int queryid,
                            java.sql.ResultSet rs)

createMapElements

public void createMapElements(java.sql.ResultSet rs)

createPointElements

public void createPointElements(java.sql.ResultSet rs)

createLineElements

public void createLineElements(java.sql.ResultSet rs)

createStatisticElements

public void createStatisticElements(java.sql.ResultSet rs)

createPointStatistics

public void createPointStatistics(java.sql.ResultSet rs)

createLineStatistics

public void createLineStatistics(java.sql.ResultSet rs)

createEquipmentStatistics

public void createEquipmentStatistics(java.sql.ResultSet rs)

createLineValueStatistics

public void createLineValueStatistics(java.sql.ResultSet rs)

createNetworkElements

public void createNetworkElements(java.sql.ResultSet rs)

createPointURL

public void createPointURL(java.sql.ResultSet rs)

createLineURL

public void createLineURL(java.sql.ResultSet rs)

setMaxBufferSize

public void setMaxBufferSize(int size)

stop

public void stop()
Disconnects from sql database.


getAutoUpdateLoad

public boolean getAutoUpdateLoad()