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 EventHTTPPages events.
42: * @author Alexandre Fenyo
43: * @version $Id: HTTPPagesComponent.java,v 1.1 2007/03/08 18:21:31 fenyo Exp $
44: */
45:
46: public class HTTPPagesComponent extends BasicComponent {
47: private static Log log = LogFactory
48: .getLog(HTTPPagesComponent.class);
49:
50: /**
51: * Constructor.
52: * @param target target this graphic component works on.
53: */
54: // GUI thread
55: public HTTPPagesComponent(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 e) {
66: getTarget().unregisterComponent(this , EventHTTPPages.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 , EventHTTPPages.class);
79: final long end = System.currentTimeMillis();
80: final long begin = end
81: - getDelayPerInterval()
82: * (getDimension().width - axis_margin_left - axis_margin_right)
83: / pixels_per_interval;
84: setEvents(getTarget().getEvents(new Date(begin),
85: new Date(end), EventHTTPPages.class));
86: updateVerticalScale();
87: }
88: }
89: }
|