Source Code Cross Referenced for ServerPanel.java in  » Testing » jakarta-jmeter » org » apache » jmeter » visualizers » 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 » Testing » jakarta jmeter » org.apache.jmeter.visualizers 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         *
009:         *   http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.apache.jmeter.visualizers;
018:
019:        import java.awt.Dimension;
020:        import java.awt.FlowLayout;
021:
022:        import javax.swing.ImageIcon;
023:        import javax.swing.JPanel;
024:        import javax.swing.JLabel;
025:        import org.apache.jmeter.util.JMeterUtils;
026:        import org.apache.jmeter.monitor.util.Stats;
027:
028:        /**
029:         * The purpose of ServerPanel is to display an unique server and its current
030:         * status. The server label consist of the protocol, host and port. For example,
031:         * a system with multiple Tomcat's running on different ports would be different
032:         * ServerPanel.
033:         */
034:        public class ServerPanel extends JPanel implements  MonitorGuiListener {
035:
036:            private JLabel serverField;
037:
038:            private JLabel timestampField;
039:
040:            /**
041:             * Preference size for the health icon
042:             */
043:            private Dimension prefsize = new Dimension(25, 75);
044:
045:            private JLabel healthIcon;
046:
047:            private JLabel loadIcon;
048:
049:            /**
050:             * Health Icons
051:             */
052:            public static final ImageIcon HEALTHY = JMeterUtils
053:                    .getImage("monitor-healthy.gif");
054:
055:            public static final ImageIcon ACTIVE = JMeterUtils
056:                    .getImage("monitor-active.gif");
057:
058:            public static final ImageIcon WARNING = JMeterUtils
059:                    .getImage("monitor-warning.gif");
060:
061:            public static final ImageIcon DEAD = JMeterUtils
062:                    .getImage("monitor-dead.gif");
063:
064:            /**
065:             * Load Icons
066:             */
067:            public static final ImageIcon LOAD_1 = JMeterUtils
068:                    .getImage("monitor-load-1.gif");
069:
070:            public static final ImageIcon LOAD_2 = JMeterUtils
071:                    .getImage("monitor-load-2.gif");
072:
073:            public static final ImageIcon LOAD_3 = JMeterUtils
074:                    .getImage("monitor-load-3.gif");
075:
076:            public static final ImageIcon LOAD_4 = JMeterUtils
077:                    .getImage("monitor-load-4.gif");
078:
079:            public static final ImageIcon LOAD_5 = JMeterUtils
080:                    .getImage("monitor-load-5.gif");
081:
082:            public static final ImageIcon LOAD_6 = JMeterUtils
083:                    .getImage("monitor-load-6.gif");
084:
085:            public static final ImageIcon LOAD_7 = JMeterUtils
086:                    .getImage("monitor-load-7.gif");
087:
088:            public static final ImageIcon LOAD_8 = JMeterUtils
089:                    .getImage("monitor-load-8.gif");
090:
091:            public static final ImageIcon LOAD_9 = JMeterUtils
092:                    .getImage("monitor-load-9.gif");
093:
094:            public static final ImageIcon LOAD_10 = JMeterUtils
095:                    .getImage("monitor-load-10.gif");
096:
097:            // private MonitorModel DATA;
098:
099:            /**
100:             * 
101:             */
102:            public ServerPanel(MonitorModel model) {
103:                super ();
104:                // DATA = model;
105:                init(model);
106:            }
107:
108:            /**
109:             * 
110:             * @deprecated Only for use in unit testing
111:             */
112:            public ServerPanel() {
113:                // log.warn("Only for use in unit testing");
114:            }
115:
116:            /**
117:             * Init will create the JLabel widgets for the host, health, load and
118:             * timestamp.
119:             * 
120:             * @param model
121:             */
122:            private void init(MonitorModel model) {
123:                this .setLayout(new FlowLayout());
124:                serverField = new JLabel(model.getURL());
125:                this .add(serverField);
126:                healthIcon = new JLabel(getHealthyImageIcon(model.getHealth()));
127:                healthIcon.setPreferredSize(prefsize);
128:                this .add(healthIcon);
129:                loadIcon = new JLabel(getLoadImageIcon(model.getLoad()));
130:                this .add(loadIcon);
131:                timestampField = new JLabel(model.getTimestampString());
132:                this .add(timestampField);
133:            }
134:
135:            /**
136:             * Static method for getting the right ImageIcon for the health.
137:             * 
138:             * @param health
139:             * @return image for the status
140:             */
141:            public static ImageIcon getHealthyImageIcon(int health) {
142:                ImageIcon i = null;
143:                switch (health) {
144:                case Stats.HEALTHY:
145:                    i = HEALTHY;
146:                    break;
147:                case Stats.ACTIVE:
148:                    i = ACTIVE;
149:                    break;
150:                case Stats.WARNING:
151:                    i = WARNING;
152:                    break;
153:                case Stats.DEAD:
154:                    i = DEAD;
155:                    break;
156:                }
157:                return i;
158:            }
159:
160:            /**
161:             * Static method looks up the right ImageIcon from the load value.
162:             * 
163:             * @param load
164:             * @return image for the load
165:             */
166:            public static ImageIcon getLoadImageIcon(int load) {
167:                if (load <= 10) {
168:                    return LOAD_1;
169:                } else if (load > 10 && load <= 20) {
170:                    return LOAD_2;
171:                } else if (load > 20 && load <= 30) {
172:                    return LOAD_3;
173:                } else if (load > 30 && load <= 40) {
174:                    return LOAD_4;
175:                } else if (load > 40 && load <= 50) {
176:                    return LOAD_5;
177:                } else if (load > 50 && load <= 60) {
178:                    return LOAD_6;
179:                } else if (load > 60 && load <= 70) {
180:                    return LOAD_7;
181:                } else if (load > 70 && load <= 80) {
182:                    return LOAD_8;
183:                } else if (load > 80 && load <= 90) {
184:                    return LOAD_9;
185:                } else {
186:                    return LOAD_10;
187:                }
188:            }
189:
190:            /**
191:             * Method will update the ServerPanel's health, load, and timestamp. For
192:             * efficiency, it uses the static method to lookup the images.
193:             */
194:            public void updateGui(MonitorModel stat) {
195:                // this.DATA = null;
196:                // this.DATA = stat;
197:                loadIcon.setIcon(getLoadImageIcon(stat.getLoad()));
198:                healthIcon.setIcon(getHealthyImageIcon(stat.getHealth()));
199:                timestampField.setText(stat.getTimestampString());
200:                this .updateGui();
201:            }
202:
203:            /**
204:             * update the gui
205:             */
206:            public void updateGui() {
207:                this.repaint();
208:            }
209:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.