01: /*
02: * GNetWatch
03: * Copyright 2006, 2007 Alexandre Fenyo
04: * gnetwatch@fenyo.net
05: *
06: * This file is part of GNetWatch.
07: *
08: * GNetWatch is free software; you can redistribute it and/or modify
09: * it under the terms of the GNU General Public License as published by
10: * the Free Software Foundation; either version 2 of the License, or
11: * (at your option) any later version.
12: *
13: * GNetWatch is distributed in the hope that it will be useful,
14: * but WITHOUT ANY WARRANTY; without even the implied warranty of
15: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16: * GNU General Public License for more details.
17: *
18: * You should have received a copy of the GNU General Public License
19: * along with GNetWatch; if not, write to the Free Software
20: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21: */
22: package net.fenyo.gnetwatch.GUI;
23:
24: import java.io.*;
25: import java.util.Date;
26: import java.awt.*;
27: import java.awt.event.WindowEvent;
28: import java.awt.font.*;
29: import java.awt.geom.*;
30: import java.awt.image.*;
31: import javax.swing.*;
32: import javax.imageio.*;
33:
34: import net.fenyo.gnetwatch.data.*;
35: import net.fenyo.gnetwatch.targets.*;
36:
37: import org.apache.commons.logging.Log;
38: import org.apache.commons.logging.LogFactory;
39:
40: /**
41: * This class implements a component that can display EventFlood events.
42: * @author Alexandre Fenyo
43: * @version $Id: FloodComponent.java,v 1.7 2007/03/08 18:21:32 fenyo Exp $
44: */
45:
46: public class FloodComponent extends BasicComponent {
47: private static Log log = LogFactory.getLog(FloodComponent.class);
48:
49: /**
50: * Constructor.
51: * @param target target this graphic component works on.
52: */
53: // GUI thread
54: public FloodComponent(final Target target) {
55: super (target);
56: }
57:
58: /**
59: * Called when the window is closing.
60: * @param e event.
61: * @return void.
62: */
63: // AWT thread
64: public void windowClosing(final WindowEvent e) {
65: getTarget().unregisterComponent(this , EventFlood.class);
66: }
67:
68: /**
69: * Fetches events that can be displayed.
70: * @param none.
71: * @return void.
72: */
73: // AWT thread
74: // AWT thread << sync_value_per_vinterval << sync_update << registered_components
75: protected void updateValues() {
76: synchronized (getSyncUpdate()) {
77: getTarget().registerComponent(this , EventFlood.class);
78: final long end = System.currentTimeMillis();
79: final long begin = end
80: - getDelayPerInterval()
81: * (getDimension().width - axis_margin_left - axis_margin_right)
82: / pixels_per_interval;
83: setEvents(getTarget().getEvents(new Date(begin),
84: new Date(end), EventFlood.class));
85: updateVerticalScale();
86: }
87: }
88: }
|