Update of /var/lib/cvs/congo/monitor
In directory boomer:/tmp/cvs-serv6380/monitor
Added Files:
Chart.java MainFrame.java Monitor.java
Log Message:
The first vestiges of a Java Swing based monitoring program that will
run in realtime, showing registration activity over a series of
specified time intervals. It also shows live counts of subscribed,
registered, badged, and checked-in attendees.
Initial coding and layout is done, XMLRPC hooks are in and sample calls
are working. I've included JFreeChart in the package to allow on the fly
graph generation.
Sample of what it looks like:
http://www.homeport.org/~dbs/screenshots/monitor-6.png (obviously the
graph data is not from CONGO - but it is generated on the fly by
JFreeChart.)
--- /var/lib/cvs/congo/monitor/Chart.java 2005/10/07 04:05:15 NONE
+++ /var/lib/cvs/congo/monitor/Chart.java 2005/10/07 04:05:15 1.1
// ---------------------------------------------------------------------
// $Id: Chart.java,v 1.1 2005/10/07 04:05:15 dbs Exp $
// $Source: /var/lib/cvs/congo/monitor/Chart.java,v $
// ---------------------------------------------------------------------
package com.stonekeep.congo.Monitor ;
// Import the Swing classes
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
// Import the JFreeChart classes
import org.jfree.chart.*;
import org.jfree.chart.plot.*;
import org.jfree.data.*;
import org.jfree.data.general.*;
public class Chart extends JPanel
{
// Holds the data
private DefaultPieDataset dataset = new DefaultPieDataset();
// Create a set of charts
private JFreeChart chart1;
// Create a set of panels that can show charts
private ChartPanel panel1;
public Chart()
{
// Initialize the dataset
dataset.setValue( "California", new Double( 10.0 ) );
dataset.setValue( "Arizona", new Double( 8.0 ) );
dataset.setValue( "New Mexico", new Double( 8.0 ) );
dataset.setValue( "Texas", new Double( 40.0 ) );
dataset.setValue( "Louisiana", new Double( 8.0 ) );
dataset.setValue( "Mississippi", new Double( 4.0 ) );
dataset.setValue( "Alabama", new Double( 2.0 ) );
dataset.setValue( "Florida", new Double( 20.0 ) );
// Create the charts
chart1 = ChartFactory.createPieChart(
"Driving Time Spent Per State (Flat Pie Chart)", // The chart title
dataset, // The dataset for the chart
true, // Is a legend required?
true, // Use tooltips
false // Configure chart to generate URLs?
);
// Create this panel
this.setLayout( new GridLayout( 1, 1 ) );
this.panel1 = new ChartPanel( chart1 );
this.add( panel1 );
}
}
--- /var/lib/cvs/congo/monitor/MainFrame.java 2005/10/07 04:05:15 NONE
+++ /var/lib/cvs/congo/monitor/MainFrame.java 2005/10/07 04:05:15 1.1
// ---------------------------------------------------------------------
// $Id: MainFrame.java,v 1.1 2005/10/07 04:05:15 dbs Exp $
// $Source: /var/lib/cvs/congo/monitor/MainFrame.java,v $
// ---------------------------------------------------------------------
package com.stonekeep.congo.Monitor ;
import javax.swing.* ;
import java.awt.* ;
import org.apache.xmlrpc.*;
import java.util.Vector ;
import java.util.Hashtable ;
class MainFrame extends JFrame {
// Menus...
private JMenuBar mainMenu = new JMenuBar();
private JMenu monitorMenu = new JMenu("Monitor");
private JMenuItem quitItem = new JMenuItem("Quit");
// Panels
private JPanel masterPanel = new JPanel();
private JPanel counterPanel = new JPanel();
private JPanel buttonPanel = new JPanel();
private Chart chart = new Chart();
// Text labels
private JLabel subscribedLabel = new JLabel("Subscribed");
private JLabel registeredLabel = new JLabel("Registered");
private JLabel badgedLabel = new JLabel("Badged");
private JLabel checkedinLabel = new JLabel("Checkedin");
// Fields for counter values
public JTextField subscribedCounter = new JTextField("0");
public JTextField registeredCounter = new JTextField("0");
public JTextField badgedCounter = new JTextField("0");
public JTextField checkedinCounter = new JTextField("0");
// Buttons along the bottom
private JButton scaleToday = new JButton("Today");
private JButton scaleLast3 = new JButton("3 Days");
private JButton scaleWeek = new JButton("Week");
private JButton scaleMonth = new JButton("Month");
private JButton scaleYear = new JButton("Year");
public MainFrame(String myTitle) {
// constructorlicious...
initItems();
setVisible(true);
setTitle(myTitle);
setSize(320,200);
// Start the monitoring thread that will update the counters...
Integer result = 0;
try {
XmlRpcClient xmlrpc = new XmlRpcClient ("http://localhost:8081/RPC2");
Vector params = new Vector ();
params.add(new Integer(17));
result = (Integer) xmlrpc.execute ("reports.numRegistered", params);
}
catch (Exception e) {
System.out.println("Exception thrown : " + e.toString());
}
registeredCounter.setText(result.toString());
}
private void initItems() {
monitorMenu.add(quitItem);
mainMenu.add(monitorMenu);
setJMenuBar(mainMenu);
// Lay out the counterPanel with all the components
GridBagLayout counterLayout = new GridBagLayout();
GridBagConstraints c = new GridBagConstraints();
counterPanel.setLayout(counterLayout);
c.fill = GridBagConstraints.BOTH;
c.weightx = 1.0;
// Add in the labels...
counterLayout.setConstraints(subscribedLabel,c);
counterPanel.add(subscribedLabel,c);
counterLayout.setConstraints(registeredLabel,c);
counterPanel.add(registeredLabel,c);
counterLayout.setConstraints(badgedLabel,c);
counterPanel.add(badgedLabel,c);
c.gridwidth = GridBagConstraints.REMAINDER; //end row
counterLayout.setConstraints(checkedinLabel,c);
counterPanel.add(checkedinLabel,c);
// and the textareas themselves
c.weightx=0;
c.gridwidth = 1;
counterLayout.setConstraints(subscribedCounter,c);
subscribedCounter.setEditable(false);
counterPanel.add(subscribedCounter,c);
c.weightx=1;
counterLayout.setConstraints(registeredCounter,c);
registeredCounter.setEditable(false);
registeredCounter.setBackground(Color.yellow);
counterPanel.add(registeredCounter,c);
counterLayout.setConstraints(badgedCounter,c);
badgedCounter.setEditable(false);
badgedCounter.setBackground(Color.pink);
counterPanel.add(badgedCounter,c);
counterLayout.setConstraints(checkedinCounter,c);
checkedinCounter.setEditable(false);
checkedinCounter.setBackground(Color.green);
counterPanel.add(checkedinCounter,c);
counterPanel.setBorder(BorderFactory.createTitledBorder("Counters"));
counterPanel.setVisible(true);
// The buttonbar panel.
buttonPanel.add(scaleToday);
buttonPanel.add(scaleLast3);
buttonPanel.add(scaleWeek);
buttonPanel.add(scaleMonth);
buttonPanel.add(scaleYear);
// Put it all together.
GridBagLayout masterLayout = new GridBagLayout();
GridBagConstraints gc = new GridBagConstraints();
gc.weighty=1.0;
gc.weightx=1.0;
masterPanel.setLayout(masterLayout);
gc.fill = GridBagConstraints.BOTH;
gc.gridwidth=GridBagConstraints.REMAINDER;
masterPanel.add(counterPanel,gc);
chart.setBorder(BorderFactory.createTitledBorder("Chart"));
chart.setVisible(true);
gc.fill = GridBagConstraints.BOTH;
masterPanel.add(chart,gc);
gc.fill = GridBagConstraints.REMAINDER;
masterPanel.add(buttonPanel);
this.getContentPane().add(masterPanel);
}
}
--- /var/lib/cvs/congo/monitor/Monitor.java 2005/10/07 04:05:15 NONE
+++ /var/lib/cvs/congo/monitor/Monitor.java 2005/10/07 04:05:15 1.1
package com.stonekeep.congo.Monitor ;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
import java.io.*;
/***********************************************************************\
* An Monitor application to display realtime information about what's
* going on inside CONGO.
* $Id: Monitor.java,v 1.1 2005/10/07 04:05:15 dbs Exp $
* (c)2002 Stonekeep Consulting, Inc
* http://www.stonekeep.com
*************************************************************************
* @author Dave Belfer-Shevett - dbs@...
* @version $Id: Monitor.java,v 1.1 2005/10/07 04:05:15 dbs Exp $
************************************************************************/
public class Monitor {
static MainFrame mainFrame ;
static Properties settings ;
static Properties defaults = new Properties();
private static void setDefaults() {
// Sets up the 'defaults' Properties hash
defaults.setProperty("serverhost","http://localhost:8081");
defaults.setProperty("serverpath","/RPC2");
defaults.setProperty("login","congo");
defaults.setProperty("password","congo");
defaults.setProperty("conference","3010");
}
private static void loadProperties() {
settings = new Properties(defaults);
File congorc = new File("Monitor.conf");
if (congorc.exists()) {
System.out.println("Loading Monitor.conf...");
try {
FileInputStream myprefs = new FileInputStream("Monitor.conf");
settings.load(myprefs);
myprefs.close();
}
catch (Exception e) {
System.out.println("*** Exception thrown loading Monitor.conf...");
e.printStackTrace();
}
}
}
public static void main(String s[]) {
mainFrame = new MainFrame("CONGO Monitor");
mainFrame.setSize(800,600);
mainFrame.setVisible(true);
setDefaults();
loadProperties();
}
}