KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > fenyo > gnetwatch > GUI > FloodComponent


1
2 /*
3  * GNetWatch
4  * Copyright 2006, 2007 Alexandre Fenyo
5  * gnetwatch@fenyo.net
6  *
7  * This file is part of GNetWatch.
8  *
9  * GNetWatch is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * GNetWatch is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with GNetWatch; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22  */

23 package net.fenyo.gnetwatch.GUI;
24
25 import java.io.*;
26 import java.util.Date JavaDoc;
27 import java.awt.*;
28 import java.awt.event.WindowEvent JavaDoc;
29 import java.awt.font.*;
30 import java.awt.geom.*;
31 import java.awt.image.*;
32 import javax.swing.*;
33 import javax.imageio.*;
34
35 import net.fenyo.gnetwatch.data.*;
36 import net.fenyo.gnetwatch.targets.*;
37
38 import org.apache.commons.logging.Log;
39 import org.apache.commons.logging.LogFactory;
40
41 /**
42  * This class implements a component that can display EventFlood events.
43  * @author Alexandre Fenyo
44  * @version $Id: FloodComponent.java,v 1.7 2007/03/08 18:21:32 fenyo Exp $
45  */

46
47 public class FloodComponent extends BasicComponent {
48   private static Log log = LogFactory.getLog(FloodComponent.class);
49
50   /**
51    * Constructor.
52    * @param target target this graphic component works on.
53    */

54   // GUI thread
55
public FloodComponent(final Target target) {
56     super(target);
57   }
58
59   /**
60    * Called when the window is closing.
61    * @param e event.
62    * @return void.
63    */

64   // AWT thread
65
public void windowClosing(final WindowEvent JavaDoc e) {
66     getTarget().unregisterComponent(this, EventFlood.class);
67   }
68
69   /**
70    * Fetches events that can be displayed.
71    * @param none.
72    * @return void.
73    */

74   // AWT thread
75
// AWT thread << sync_value_per_vinterval << sync_update << registered_components
76
protected void updateValues() {
77     synchronized (getSyncUpdate()) {
78       getTarget().registerComponent(this, EventFlood.class);
79       final long end = System.currentTimeMillis();
80       final long begin = end - getDelayPerInterval() *
81       (getDimension().width - axis_margin_left - axis_margin_right) / pixels_per_interval;
82       setEvents(getTarget().getEvents(new Date JavaDoc(begin), new Date JavaDoc(end), EventFlood.class));
83       updateVerticalScale();
84     }
85   }
86 }
87
Popular Tags