Source Code Cross Referenced for LX200ControlPanel.java in  » Science » JSci » JSci » astro » telescope » 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 » Science » JSci » JSci.astro.telescope 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package JSci.astro.telescope;
002:
003:        import java.awt.*;
004:        import java.awt.event.*;
005:        import java.io.*;
006:        import java.rmi.*;
007:
008:        public final class LX200ControlPanel extends Panel implements  Runnable {
009:            private LX200Remote lx200;
010:            private Thread statusThr = null;
011:            private TextField raField = new TextField(8);
012:            private TextField decField = new TextField(8);
013:            private Button gotoButton = new Button("Goto");
014:            private Button syncButton = new Button("Sync");
015:            private Label raLabel = new Label();
016:            private Label decLabel = new Label();
017:            private Button inButton = new Button("+");
018:            private Button outButton = new Button("-");
019:            private Choice focusRateCombo = new Choice();
020:            private Button northButton = new Button("N");
021:            private Button eastButton = new Button("E");
022:            private Button southButton = new Button("S");
023:            private Button westButton = new Button("W");
024:            private Choice slewRateCombo = new Choice();
025:
026:            public static void main(String arg[]) {
027:                if (arg.length != 1) {
028:                    System.out
029:                            .println("Usage: LX200ControlPanel rmi://<host>[:port]/<remote name>");
030:                    return;
031:                }
032:                Frame app = new Frame("LX200 Control Panel");
033:                app.addWindowListener(new WindowAdapter() {
034:                    public void windowClosing(WindowEvent evt) {
035:                        System.exit(0);
036:                    }
037:                });
038:                app.add(new LX200ControlPanel(arg[0]));
039:                app.setSize(100, 400);
040:                app.setVisible(true);
041:            }
042:
043:            public LX200ControlPanel(String url) {
044:                try {
045:                    lx200 = (LX200Remote) Naming.lookup(url);
046:                } catch (Exception e) {
047:                    e.printStackTrace();
048:                }
049:                gotoButton.addActionListener(new GotoActionListener());
050:                syncButton.addActionListener(new SyncActionListener());
051:                inButton.addActionListener(new FocusActionListener(
052:                        LX200.FOCUS_IN));
053:                outButton.addActionListener(new FocusActionListener(
054:                        LX200.FOCUS_OUT));
055:                focusRateCombo.add("Fast");
056:                focusRateCombo.add("Slow");
057:                focusRateCombo.addItemListener(new FocusRateItemListener());
058:                northButton.addActionListener(new SlewActionListener(
059:                        LX200.SLEW_NORTH));
060:                eastButton.addActionListener(new SlewActionListener(
061:                        LX200.SLEW_EAST));
062:                southButton.addActionListener(new SlewActionListener(
063:                        LX200.SLEW_SOUTH));
064:                westButton.addActionListener(new SlewActionListener(
065:                        LX200.SLEW_WEST));
066:                slewRateCombo.add("Slew");
067:                slewRateCombo.add("Find");
068:                slewRateCombo.add("Center");
069:                slewRateCombo.add("Guide");
070:                slewRateCombo.addItemListener(new SlewRateItemListener());
071:                Panel radecPanel = new Panel();
072:                radecPanel.add(raLabel);
073:                radecPanel.add(decLabel);
074:                radecPanel.add(raField);
075:                radecPanel.add(decField);
076:                radecPanel.add(gotoButton);
077:                radecPanel.add(syncButton);
078:                Panel focusPanel = new Panel();
079:                focusPanel.setLayout(new GridLayout(3, 1));
080:                focusPanel.add(inButton);
081:                focusPanel.add(outButton);
082:                focusPanel.add(focusRateCombo);
083:                Panel slewPanel = new Panel();
084:                GridBagConstraints gbc = new GridBagConstraints();
085:                GridBagLayout gridbag = new GridBagLayout();
086:                slewPanel.setLayout(gridbag);
087:                gbc.fill = GridBagConstraints.BOTH;
088:                gbc.gridx = 1;
089:                gbc.gridy = 0;
090:                gridbag.setConstraints(northButton, gbc);
091:                slewPanel.add(northButton);
092:                gbc.gridx = 0;
093:                gbc.gridy = 1;
094:                gridbag.setConstraints(westButton, gbc);
095:                slewPanel.add(westButton);
096:                gbc.gridx = 2;
097:                gbc.gridy = 1;
098:                gridbag.setConstraints(eastButton, gbc);
099:                slewPanel.add(eastButton);
100:                gbc.gridx = 1;
101:                gbc.gridy = 2;
102:                gridbag.setConstraints(southButton, gbc);
103:                slewPanel.add(southButton);
104:                gbc.gridx = 0;
105:                gbc.gridy = 3;
106:                gbc.gridwidth = GridBagConstraints.REMAINDER;
107:                gridbag.setConstraints(slewRateCombo, gbc);
108:                slewPanel.add(slewRateCombo);
109:                add(radecPanel);
110:                add(focusPanel);
111:                add(slewPanel);
112:                statusThr = new Thread(this );
113:                statusThr.start();
114:            }
115:
116:            private class GotoActionListener implements  ActionListener {
117:                public void actionPerformed(ActionEvent evt) {
118:                    try {
119:                        lx200.setObjectCoords(raField.getText(), decField
120:                                .getText());
121:                        lx200.slewToObject();
122:                    } catch (IOException e) {
123:                    }
124:                }
125:            }
126:
127:            private class SyncActionListener implements  ActionListener {
128:                public void actionPerformed(ActionEvent evt) {
129:                    try {
130:                        lx200.setObjectCoords(raField.getText(), decField
131:                                .getText());
132:                        lx200.syncCoords();
133:                    } catch (IOException e) {
134:                    }
135:                }
136:            }
137:
138:            private class FocusActionListener implements  ActionListener {
139:                private final int direction;
140:                private boolean focusing = false;
141:
142:                public FocusActionListener(int dir) {
143:                    direction = dir;
144:                }
145:
146:                public void actionPerformed(ActionEvent evt) {
147:                    if (focusing) {
148:                        try {
149:                            lx200.stopFocus();
150:                        } catch (IOException e) {
151:                        }
152:                        focusing = false;
153:                    } else {
154:                        try {
155:                            lx200.startFocus(direction);
156:                        } catch (IOException e) {
157:                        }
158:                        focusing = true;
159:                    }
160:                }
161:            }
162:
163:            private class FocusRateItemListener implements  ItemListener {
164:                public void itemStateChanged(ItemEvent evt) {
165:                    try {
166:                        lx200
167:                                .setFocusRate(focusRateCombo.getSelectedIndex() + 1);
168:                    } catch (IOException e) {
169:                    }
170:                }
171:            }
172:
173:            private class SlewActionListener implements  ActionListener {
174:                private final int direction;
175:                private boolean slewing = false;
176:
177:                public SlewActionListener(int dir) {
178:                    direction = dir;
179:                }
180:
181:                public void actionPerformed(ActionEvent evt) {
182:                    if (slewing) {
183:                        try {
184:                            lx200.stopSlew(direction);
185:                        } catch (IOException e) {
186:                        }
187:                        slewing = false;
188:                    } else {
189:                        try {
190:                            lx200.startSlew(direction);
191:                        } catch (IOException e) {
192:                        }
193:                        slewing = true;
194:                    }
195:                }
196:            }
197:
198:            private class SlewRateItemListener implements  ItemListener {
199:                public void itemStateChanged(ItemEvent evt) {
200:                    try {
201:                        lx200.setSlewRate(slewRateCombo.getSelectedIndex() + 1);
202:                    } catch (IOException e) {
203:                    }
204:                }
205:            }
206:
207:            public void run() {
208:                while (statusThr == Thread.currentThread()) {
209:                    try {
210:                        raLabel.setText("RA: " + lx200.getRA());
211:                        decLabel.setText("Dec: " + lx200.getDec());
212:                    } catch (IOException e) {
213:                    }
214:                    try {
215:                        Thread.sleep(2000);
216:                    } catch (InterruptedException e) {
217:                    }
218:                }
219:            }
220:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.