Source Code Cross Referenced for ISpeedService.java in  » Net » hyperpool-0.4.0 » vicazh » hyperpool » stream » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Net » hyperpool 0.4.0 » vicazh.hyperpool.stream 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package vicazh.hyperpool.stream;
002:
003:        import java.awt.*;
004:        import java.util.logging.*;
005:        import javax.swing.*;
006:        import javax.swing.event.*;
007:        import org.jfree.chart.*;
008:        import org.jfree.chart.plot.*;
009:        import org.jfree.data.time.*;
010:        import vicazh.hyperpool.*;
011:        import vicazh.hyperpool.Start;
012:
013:        /**
014:         * The graphic speed service
015:         * 
016:         * @author Victor Zhigunov
017:         * @version 0.4.0
018:         */
019:        public class ISpeedService extends IService implements 
020:                SpeedServiceMBean, ChangeListener {
021:            private JFreeChart chart;
022:
023:            private XYPlot clientplot;
024:
025:            private XYPlot serverplot;
026:
027:            private JSlider clientslider;
028:
029:            private JSlider serverslider;
030:
031:            private Component component;
032:
033:            /**
034:             * @param name
035:             *            service name
036:             * @param chart
037:             *            chart
038:             * @param clientplot
039:             *            client plot
040:             * @param serverplot
041:             *            server plot
042:             * @param clientslider
043:             *            client slider
044:             * @param serverslider
045:             *            server slider
046:             * @param component
047:             *            component for ui update
048:             */
049:            public ISpeedService(String name, JFreeChart chart,
050:                    XYPlot clientplot, XYPlot serverplot, JSlider clientslider,
051:                    JSlider serverslider, Component component) {
052:                super (SpeedServiceMBean.class, name);
053:                this .chart = chart;
054:                this .clientplot = clientplot;
055:                this .serverplot = serverplot;
056:                this .clientslider = clientslider;
057:                this .serverslider = serverslider;
058:                clientslider.addChangeListener(this );
059:                serverslider.addChangeListener(this );
060:                this .component = component;
061:                updateUI();
062:            }
063:
064:            public void stateChanged(ChangeEvent e) {
065:                JSlider slider = (JSlider) e.getSource();
066:                if (slider.getValueIsAdjusting())
067:                    return;
068:                try {
069:                    if (slider == clientslider)
070:                        setAttribute(SpeedServiceMBean.CLIENT, set(slider,
071:                                clientplot));
072:                    else
073:                        setAttribute(SpeedServiceMBean.SERVER, set(slider,
074:                                serverplot));
075:                } catch (Exception ex) {
076:                    Start.logger.log(Level.SEVERE, ex.getMessage(), ex);
077:                }
078:            }
079:
080:            public static double set(JSlider slider, XYPlot plot) {
081:                double i = (double) slider.getValue() / 10;
082:                double upper = i - i % 10 + 10;
083:                plot.getRangeAxis().setRange(0.0D, upper);
084:                slider.setMaximum((int) upper * 10);
085:                slider.setMinorTickSpacing(slider.getMaximum() / 10);
086:                slider.setMajorTickSpacing(slider.getMaximum() / 2);
087:                return i;
088:            }
089:
090:            private static final String key = "activeCaption";
091:
092:            private static final String keyc = "control";
093:
094:            private static final String keyw = "window";
095:
096:            public void updateUI() {
097:                clientplot.getRenderer().setPaint(UIManager.getColor(key));
098:                serverplot.getRenderer().setPaint(UIManager.getColor(key));
099:                chart.setBackgroundPaint(UIManager.getColor(keyc));
100:                clientplot.setBackgroundPaint(UIManager.getColor(keyw));
101:                serverplot.setBackgroundPaint(UIManager.getColor(keyw));
102:                SwingUtilities.updateComponentTreeUI(component);
103:            }
104:
105:            public static int getValue(double d) {
106:                return (int) (d * 10);
107:            }
108:
109:            protected void otherNotification(String type, Object value) {
110:                if (type.equals(SpeedServiceMBean.CLIENTACTION))
111:                    ((TimeSeriesCollection) clientplot.getDataset()).getSeries(
112:                            0).addOrUpdate(new Millisecond(), (Double) value);
113:                else if (type.equals(SpeedServiceMBean.SERVERACTION))
114:                    ((TimeSeriesCollection) serverplot.getDataset()).getSeries(
115:                            0).addOrUpdate(new Millisecond(), (Double) value);
116:                else if (type.equals(SpeedServiceMBean.CLIENT))
117:                    clientslider.setValue(getValue((Double) value));
118:                else
119:                    serverslider.setValue(getValue((Double) value));
120:            }
121:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.