Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

org.objectweb.cjdbc.console.monitoring.MonitoringGraph Class Reference

List of all members.

Public Member Functions

 MonitoringGraph (AbstractDataCollector collector, DataCollectorMBean jmxClient)
void display ()
void addData (long newValue)
void saveAs () throws IOException
void run ()
AbstractDataCollector getCollector ()
void setCollector (AbstractDataCollector collector)
JFrame getFrame ()
void setFrame (JFrame frame)
boolean getFramed ()
void setFramed (boolean framed)
long getFrequency ()
void setFrequency (long frequency)
long getRepeat ()
void setRepeat (long repeat)
boolean getStop ()
void setStop (boolean stop)
int getTimeFrame ()
void setTimeFrame (int timeFrame)
JFreeChart getChart ()
ChartPanel getPanel ()
long getTimeStarted ()
boolean getDisplay ()
void setDisplay (boolean display)
int getFrameHeight ()
void setFrameHeight (int frameHeight)
int getFrameWidth ()
void setFrameWidth (int frameWidth)
boolean getSaveOnFinish ()
void setSaveOnFinish (boolean saveOnFinish)
String getText ()
void setText (String text)
long getPoolingSpeed ()
void setPoolingSpeed (long poolingSpeed)
long getDisplayFrequency ()
void setDisplayFrequency (long displayFrequency)

Detailed Description

Encapsulate the JFreeChart classes and methods to provide easiness of configuration for a monitoring graph. This MonitoringGraph also contains the thread that retrieves the information at the moment. TODO: Should take out this Thread so that it connects to a monitoring repository.

Author:
Nicolas Modrzyk

Definition at line 54 of file MonitoringGraph.java.


Constructor & Destructor Documentation

org.objectweb.cjdbc.console.monitoring.MonitoringGraph.MonitoringGraph AbstractDataCollector  collector,
DataCollectorMBean  jmxClient
 

Creates a new MonitoringGraph object

Parameters:
collector An AbstractDataCollector object
jmxClient a DataCollectorJmxClient object

Definition at line 94 of file MonitoringGraph.java.

References org.objectweb.cjdbc.console.monitoring.MonitoringGraph.display().

00096   {
00097     this.collector = collector;
00098     this.jmxClient = jmxClient;
00099 
00100     buffer = new XYSeries("Buffer");
00101 
00102     series = new XYSeries(collector.getTargetName());
00103     series.setMaximumItemCount(timeFrame);
00104     dataset = new XYSeriesCollection(series);
00105     chart = ChartFactory.createXYLineChart(collector.getDescription(),
00106         "Time (Started at:"
00107             + new SimpleDateFormat("HH:mm:ss").format(new Date()) + ")", "",
00108         dataset, PlotOrientation.VERTICAL, true, false, false);
00109     panel = new ChartPanel(chart);
00110     panel.setSize(frameWidth, frameHeight);
00111 
00112     if (display)
00113       display();
00114   }


Member Function Documentation

void org.objectweb.cjdbc.console.monitoring.MonitoringGraph.addData long  newValue  ) 
 

Add a data entry to the current serie. Bufferize given the buffer series size

Parameters:
newValue new data to add

Definition at line 140 of file MonitoringGraph.java.

Referenced by org.objectweb.cjdbc.console.monitoring.MonitoringGraph.run().

00141   {
00142     long now = (System.currentTimeMillis() / 1000) - timeStarted;
00143     if (displayFrequency == 0)
00144     {
00145       series.add(now, newValue);
00146     }
00147     else if (displayFrequencyCount < displayFrequency)
00148     {
00149       displayFrequencyCount++;
00150       buffer.add(now, newValue);
00151     }
00152     else
00153     {
00154       int count = buffer.getItemCount();
00155       for (int i = 0; i < count; i++)
00156       {
00157         series.add(buffer.getDataItem(i));
00158       }
00159       buffer = new XYSeries("buffer");
00160       displayFrequencyCount = 0;
00161     }
00162   }

void org.objectweb.cjdbc.console.monitoring.MonitoringGraph.display  ) 
 

Display the graph on screen

Definition at line 119 of file MonitoringGraph.java.

Referenced by org.objectweb.cjdbc.console.monitoring.MonitoringGraph.MonitoringGraph().

00120   {
00121     chart.setBorderVisible(false);
00122     panel.setVisible(true);
00123     if (framed)
00124     {
00125       frame = new JFrame(collector.getDescription());
00126       frame.getContentPane().add(panel);
00127       frame.setSize(new java.awt.Dimension(frameWidth, frameHeight));
00128       RefineryUtilities.centerFrameOnScreen(frame);
00129       frame.setVisible(true);
00130       frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
00131     }
00132   }

JFreeChart org.objectweb.cjdbc.console.monitoring.MonitoringGraph.getChart  ) 
 

Returns:
Returns the chart.

Definition at line 339 of file MonitoringGraph.java.

00340   {
00341     return chart;
00342   }

AbstractDataCollector org.objectweb.cjdbc.console.monitoring.MonitoringGraph.getCollector  ) 
 

Returns:
Returns the collector.

Definition at line 226 of file MonitoringGraph.java.

00227   {
00228     return collector;
00229   }

boolean org.objectweb.cjdbc.console.monitoring.MonitoringGraph.getDisplay  ) 
 

Returns:
Returns the display.

Definition at line 363 of file MonitoringGraph.java.

00364   {
00365     return display;
00366   }

long org.objectweb.cjdbc.console.monitoring.MonitoringGraph.getDisplayFrequency  ) 
 

Returns:
Returns the displayFrequency.

Definition at line 459 of file MonitoringGraph.java.

00460   {
00461     return displayFrequency;
00462   }

JFrame org.objectweb.cjdbc.console.monitoring.MonitoringGraph.getFrame  ) 
 

Returns:
Returns the frame.

Definition at line 242 of file MonitoringGraph.java.

Referenced by org.objectweb.cjdbc.console.monitoring.MonitoringConsole.graph().

00243   {
00244     return frame;
00245   }

boolean org.objectweb.cjdbc.console.monitoring.MonitoringGraph.getFramed  ) 
 

Returns:
Returns the framed.

Definition at line 258 of file MonitoringGraph.java.

00259   {
00260     return framed;
00261   }

int org.objectweb.cjdbc.console.monitoring.MonitoringGraph.getFrameHeight  ) 
 

Returns:
Returns the frameHeight.

Definition at line 379 of file MonitoringGraph.java.

00380   {
00381     return frameHeight;
00382   }

int org.objectweb.cjdbc.console.monitoring.MonitoringGraph.getFrameWidth  ) 
 

Returns:
Returns the frameWidth.

Definition at line 395 of file MonitoringGraph.java.

00396   {
00397     return frameWidth;
00398   }

long org.objectweb.cjdbc.console.monitoring.MonitoringGraph.getFrequency  ) 
 

Returns:
Returns the frequency.

Definition at line 274 of file MonitoringGraph.java.

00275   {
00276     return frequency;
00277   }

ChartPanel org.objectweb.cjdbc.console.monitoring.MonitoringGraph.getPanel  ) 
 

Returns:
Returns the panel.

Definition at line 347 of file MonitoringGraph.java.

00348   {
00349     return panel;
00350   }

long org.objectweb.cjdbc.console.monitoring.MonitoringGraph.getPoolingSpeed  ) 
 

Returns:
Returns the poolingSpeed.

Definition at line 443 of file MonitoringGraph.java.

00444   {
00445     return poolingSpeed;
00446   }

long org.objectweb.cjdbc.console.monitoring.MonitoringGraph.getRepeat  ) 
 

Returns:
Returns the repeat.

Definition at line 290 of file MonitoringGraph.java.

00291   {
00292     return repeat;
00293   }

boolean org.objectweb.cjdbc.console.monitoring.MonitoringGraph.getSaveOnFinish  ) 
 

Returns:
Returns the saveOnFinish.

Definition at line 411 of file MonitoringGraph.java.

00412   {
00413     return saveOnFinish;
00414   }

boolean org.objectweb.cjdbc.console.monitoring.MonitoringGraph.getStop  ) 
 

Returns:
Returns the stop.

Definition at line 306 of file MonitoringGraph.java.

00307   {
00308     return stop;
00309   }

String org.objectweb.cjdbc.console.monitoring.MonitoringGraph.getText  ) 
 

Returns:
Returns the text.

Definition at line 427 of file MonitoringGraph.java.

00428   {
00429     return text;
00430   }

int org.objectweb.cjdbc.console.monitoring.MonitoringGraph.getTimeFrame  ) 
 

Returns:
Returns the timeFrame.

Definition at line 322 of file MonitoringGraph.java.

00323   {
00324     return timeFrame;
00325   }

long org.objectweb.cjdbc.console.monitoring.MonitoringGraph.getTimeStarted  ) 
 

Returns:
Returns the timeStarted.

Definition at line 355 of file MonitoringGraph.java.

00356   {
00357     return timeStarted;
00358   }

void org.objectweb.cjdbc.console.monitoring.MonitoringGraph.run  ) 
 

See also:
java.lang.Runnable#run()

Definition at line 180 of file MonitoringGraph.java.

References org.objectweb.cjdbc.console.monitoring.MonitoringGraph.addData(), and org.objectweb.cjdbc.console.monitoring.MonitoringGraph.saveAs().

00181   {
00182     timeStarted = System.currentTimeMillis() / 1000;
00183     int count = 0;
00184     while (repeat == -1 || count < repeat)
00185     {
00186       count++;
00187       synchronized (this)
00188       {
00189         try
00190         {
00191           addData(jmxClient.retrieveData(collector));
00192           wait(frequency);
00193           if (stop)
00194             break;
00195 
00196           if (display == true && panel.isShowing() == false)
00197           {
00198             if (panel.getParent().isShowing() == false)
00199               stop = true;
00200           }
00201 
00202         }
00203         catch (Exception e)
00204         {
00205           stop = true;
00206           throw new RuntimeException(e.getMessage());
00207         }
00208       }
00209     }
00210     if (saveOnFinish)
00211     {
00212       try
00213       {
00214         saveAs();
00215       }
00216       catch (Exception e)
00217       {
00218         //ignore
00219       }
00220     }
00221   }

void org.objectweb.cjdbc.console.monitoring.MonitoringGraph.saveAs  )  throws IOException
 

Save the graph into a file

Exceptions:
IOException if an error occurs

Definition at line 169 of file MonitoringGraph.java.

Referenced by org.objectweb.cjdbc.console.monitoring.MonitoringGraph.run().

00170   {
00171     String fileName = collector.getTargetName() + "-"
00172         + new SimpleDateFormat().format(new Date());
00173     ChartUtilities.saveChartAsJPEG(new File(fileName), this.chart, frameWidth,
00174         frameHeight);
00175   }

void org.objectweb.cjdbc.console.monitoring.MonitoringGraph.setCollector AbstractDataCollector  collector  ) 
 

Parameters:
collector The collector to set.

Definition at line 234 of file MonitoringGraph.java.

00235   {
00236     this.collector = collector;
00237   }

void org.objectweb.cjdbc.console.monitoring.MonitoringGraph.setDisplay boolean  display  ) 
 

Parameters:
display The display to set.

Definition at line 371 of file MonitoringGraph.java.

00372   {
00373     this.display = display;
00374   }

void org.objectweb.cjdbc.console.monitoring.MonitoringGraph.setDisplayFrequency long  displayFrequency  ) 
 

Parameters:
displayFrequency The displayFrequency to set.

Definition at line 467 of file MonitoringGraph.java.

Referenced by org.objectweb.cjdbc.console.monitoring.MonitoringConsole.graph().

00468   {
00469     this.displayFrequency = displayFrequency;
00470   }

void org.objectweb.cjdbc.console.monitoring.MonitoringGraph.setFrame JFrame  frame  ) 
 

Parameters:
frame The frame to set.

Definition at line 250 of file MonitoringGraph.java.

00251   {
00252     this.frame = frame;
00253   }

void org.objectweb.cjdbc.console.monitoring.MonitoringGraph.setFramed boolean  framed  ) 
 

Parameters:
framed The framed to set.

Definition at line 266 of file MonitoringGraph.java.

00267   {
00268     this.framed = framed;
00269   }

void org.objectweb.cjdbc.console.monitoring.MonitoringGraph.setFrameHeight int  frameHeight  ) 
 

Parameters:
frameHeight The frameHeight to set.

Definition at line 387 of file MonitoringGraph.java.

00388   {
00389     this.frameHeight = frameHeight;
00390   }

void org.objectweb.cjdbc.console.monitoring.MonitoringGraph.setFrameWidth int  frameWidth  ) 
 

Parameters:
frameWidth The frameWidth to set.

Definition at line 403 of file MonitoringGraph.java.

00404   {
00405     this.frameWidth = frameWidth;
00406   }

void org.objectweb.cjdbc.console.monitoring.MonitoringGraph.setFrequency long  frequency  ) 
 

Parameters:
frequency The frequency to set.

Definition at line 282 of file MonitoringGraph.java.

Referenced by org.objectweb.cjdbc.console.monitoring.MonitoringConsole.graph().

00283   {
00284     this.frequency = frequency;
00285   }

void org.objectweb.cjdbc.console.monitoring.MonitoringGraph.setPoolingSpeed long  poolingSpeed  ) 
 

Parameters:
poolingSpeed The poolingSpeed to set.

Definition at line 451 of file MonitoringGraph.java.

00452   {
00453     this.poolingSpeed = poolingSpeed;
00454   }

void org.objectweb.cjdbc.console.monitoring.MonitoringGraph.setRepeat long  repeat  ) 
 

Parameters:
repeat The repeat to set.

Definition at line 298 of file MonitoringGraph.java.

Referenced by org.objectweb.cjdbc.console.monitoring.MonitoringConsole.graph().

00299   {
00300     this.repeat = repeat;
00301   }

void org.objectweb.cjdbc.console.monitoring.MonitoringGraph.setSaveOnFinish boolean  saveOnFinish  ) 
 

Parameters:
saveOnFinish The saveOnFinish to set.

Definition at line 419 of file MonitoringGraph.java.

00420   {
00421     this.saveOnFinish = saveOnFinish;
00422   }

void org.objectweb.cjdbc.console.monitoring.MonitoringGraph.setStop boolean  stop  ) 
 

Parameters:
stop The stop to set.

Definition at line 314 of file MonitoringGraph.java.

00315   {
00316     this.stop = stop;
00317   }

void org.objectweb.cjdbc.console.monitoring.MonitoringGraph.setText String  text  ) 
 

Parameters:
text The text to set.

Definition at line 435 of file MonitoringGraph.java.

Referenced by org.objectweb.cjdbc.console.monitoring.MonitoringConsole.graph().

00436   {
00437     this.text = text;
00438   }

void org.objectweb.cjdbc.console.monitoring.MonitoringGraph.setTimeFrame int  timeFrame  ) 
 

Parameters:
timeFrame The timeFrame to set.

Definition at line 330 of file MonitoringGraph.java.

Referenced by org.objectweb.cjdbc.console.monitoring.MonitoringConsole.graph().

00331   {
00332     this.timeFrame = timeFrame;
00333     series.setMaximumItemCount(timeFrame);
00334   }


The documentation for this class was generated from the following file:
Generated on Mon Apr 11 22:02:40 2005 for C-JDBC by  doxygen 1.3.9.1