Source Code Cross Referenced for guiRenderingSetting.java in  » Net » JCGrid » org » homedns » dade » jcgrid » cmd » mandel » 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 » JCGrid » org.homedns.dade.jcgrid.cmd.mandel 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         Copyright (C) 2004 David Bucciarelli (davibu@interfree.it)
003:
004:         This program is free software; you can redistribute it and/or
005:         modify it under the terms of the GNU General Public License
006:         as published by the Free Software Foundation; either version 2
007:         of the License, or (at your option) any later version.
008:
009:         This program is distributed in the hope that it will be useful,
010:         but WITHOUT ANY WARRANTY; without even the implied warranty of
011:         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012:         GNU General Public License for more details.
013:
014:         You should have received a copy of the GNU General Public License
015:         along with this program; if not, write to the Free Software
016:         Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
017:         */
018:
019:        package org.homedns.dade.jcgrid.cmd.mandel;
020:
021:        import java.io.*;
022:        import java.text.*;
023:        import java.util.*;
024:        import java.awt.*;
025:        import javax.swing.*;
026:        import javax.swing.text.*;
027:
028:        import org.apache.log4j.*;
029:
030:        import org.homedns.dade.jcgrid.*;
031:        import org.homedns.dade.jcgrid.client.*;
032:        import org.homedns.dade.jcgrid.message.*;
033:        import org.homedns.dade.jcgrid.worker.impl.mandel.*;
034:        import org.homedns.dade.jcgrid.server.*;
035:
036:        public class guiRenderingSetting extends javax.swing.JDialog {
037:            private final static String className = guiRenderingSetting.class
038:                    .getName();
039:            private static Logger log = Logger.getLogger(className);
040:            private static Logger logDetail = Logger.getLogger("DETAIL."
041:                    + className);
042:
043:            private static final long serialVersionUID = 1L;
044:
045:            //--------------------------------------------------------------------------
046:
047:            private class RenderingThreadFeedback implements 
048:                    MandelRenderingClientFeedback {
049:                public RenderingThreadFeedback() {
050:                }
051:
052:                public void error(String msg, Exception ex) {
053:                    log.warn(msg, ex);
054:
055:                    JOptionPane.showMessageDialog(guiRenderingSetting.this ,
056:                            msg, "Rendering error", JOptionPane.ERROR_MESSAGE);
057:                }
058:
059:                public void receivedFragmentResult(MandelWorkRequest req,
060:                        MandelWorkResult res, MandelRenderingFrame frame) {
061:                    pPic.updateImage(frame);
062:                }
063:
064:                public void renderingBegin() {
065:                    pbStatus.setValue(pbStatus.getMinimum());
066:                }
067:
068:                public void renderingEnd() {
069:                    rendThread = null;
070:                    bStartStop.setText("Start rendering");
071:                }
072:
073:                public void sendingFrgamentRequest(MandelWorkRequest req) {
074:                }
075:
076:                public void setProgressMaximum(int max) {
077:                    pbStatus.setMaximum(max);
078:                }
079:
080:                public void setProgressMinimum(int min) {
081:                    pbStatus.setMinimum(min);
082:                }
083:
084:                public void setProgressValue(int val) {
085:                    pbStatus.setValue(val);
086:                }
087:
088:                public void setRenderingTime(MandelWorkRequest req, long msdt) {
089:                    double dt = msdt / 1000.0;
090:                    double pixsec = req.getXStep() * req.getYStep() / dt;
091:
092:                    DecimalFormat df = new DecimalFormat("0.00");
093:
094:                    if (dt > 0)
095:                        lRenderTime.setText(df.format(dt / 60.0) + " min ("
096:                                + df.format(pixsec) + "pixel/sec)");
097:                    else
098:                        lRenderTime.setText("N/A");
099:                }
100:
101:                public void completeFrame(int idx, MandelRenderingFrame frame) {
102:                    pPic.updateImage(frame);
103:                }
104:            }
105:
106:            //--------------------------------------------------------------------------
107:
108:            private GridNodeClientConfig clientConfig;
109:
110:            private guiMandelRenderingPannel pPic;
111:
112:            private short maxIteration;
113:            private double zoomFactor;
114:            private double xOrigin;
115:            private double yOrigin;
116:            private int imgWidth;
117:            private int imgHeight;
118:
119:            private MandelRenderingClient rendThread;
120:            private MandelWorkRequest lastRequest;
121:
122:            /** Creates new form guiRenderingSetting */
123:            public guiRenderingSetting(GridNodeClientConfig cfg,
124:                    java.awt.Frame parent, boolean modal,
125:                    guiMandelRenderingPannel rendPannel) {
126:                super (parent, modal);
127:
128:                clientConfig = cfg;
129:                pPic = rendPannel;
130:                rendThread = null;
131:                lastRequest = null;
132:
133:                initComponents();
134:
135:                this .resetView(false);
136:            }
137:
138:            public void resetView(boolean doRendering) {
139:                maxIteration = 512;
140:                sMaxIteration.setValue(maxIteration);
141:                lMaxIteration.setText(Short.toString(maxIteration));
142:                zoomFactor = 1.0;
143:                lZoomFactor.setText(Double.toString(zoomFactor));
144:                xOrigin = 0.0;
145:                lXOrig.setText(Double.toString(xOrigin));
146:                yOrigin = 0.0;
147:                lYOrig.setText(Double.toString(yOrigin));
148:
149:                if (doRendering)
150:                    this .startRendering();
151:            }
152:
153:            public void startRendering() {
154:                pPic.initImage();
155:
156:                int colorType = MandelRenderingFrame.COLOR_TABLE_TYPE_RED;
157:                if (cColors.getSelectedIndex() == MandelRenderingFrame.COLOR_TABLE_TYPE_MISC)
158:                    colorType = MandelRenderingFrame.COLOR_TABLE_TYPE_MISC;
159:
160:                short mi = maxIteration;
161:                double zf = zoomFactor;
162:                double xo = xOrigin;
163:                double yo = yOrigin;
164:                int w = pPic.getWidth();
165:                int h = pPic.getHeight();
166:
167:                if ((w <= 0) || (h <= 0))
168:                    return;
169:
170:                lImgWidth.setText(Integer.toString(w));
171:                lImgHeight.setText(Integer.toString(h));
172:                float ratio = h / (float) w;
173:
174:                // Check if there is a rendering already running
175:
176:                if (rendThread != null) {
177:                    try {
178:                        rendThread.interrupt();
179:                        rendThread.join();
180:                    } catch (Exception ex) {
181:                        log.warn("Error stopping the rendering", ex);
182:
183:                        JOptionPane.showMessageDialog(this ,
184:                                "Error stopping the rendering.",
185:                                "Rendering error", JOptionPane.ERROR_MESSAGE);
186:
187:                        rendThread = null;
188:                    }
189:                }
190:
191:                // Setup JCGrid Client
192:
193:                GridClient gc = new GridClient();
194:                gc.setNodeConfig(clientConfig);
195:                GridNodeClientConfig config = (GridNodeClientConfig) gc
196:                        .getNodeConfig();
197:
198:                try {
199:                    // Creating work request
200:
201:                    lastRequest = new MandelWorkRequest(
202:                            config.getSessionName(), 0, (short) mi, xo - 2.0
203:                                    * zf, yo - 2.0 * zf * ratio, 4.0 * zf / w,
204:                            4.0 * zf * ratio / h, w, h);
205:
206:                    rendThread = new MandelRenderingClient(config,
207:                            new RenderingThreadFeedback(), lastRequest);
208:                    rendThread.getFrame().setColorTableType(colorType);
209:                    rendThread.getFrame().setMaxIter(mi);
210:
211:                    rendThread.start();
212:                } catch (Exception ex) {
213:                    log.warn("Error starting the rendering", ex);
214:
215:                    JOptionPane.showMessageDialog(this ,
216:                            "Error starting the rendering.", "Rendering error",
217:                            JOptionPane.ERROR_MESSAGE);
218:
219:                    rendThread = null;
220:                }
221:            }
222:
223:            /** This method is called from within the constructor to
224:             * initialize the form.
225:             * WARNING: Do NOT modify this code. The content of this method is
226:             * always regenerated by the Form Editor.
227:             */
228:            private void initComponents() {//GEN-BEGIN:initComponents
229:                java.awt.GridBagConstraints gridBagConstraints;
230:
231:                pCfg = new javax.swing.JPanel();
232:                jLabel4 = new javax.swing.JLabel();
233:                lMaxIteration = new javax.swing.JLabel();
234:                sMaxIteration = new javax.swing.JSlider();
235:                jLabel5 = new javax.swing.JLabel();
236:                lZoomFactor = new javax.swing.JLabel();
237:                bZoomIn = new javax.swing.JButton();
238:                bZoomOut = new javax.swing.JButton();
239:                jLabel6 = new javax.swing.JLabel();
240:                lXOrig = new javax.swing.JLabel();
241:                lLeft = new javax.swing.JButton();
242:                lRight = new javax.swing.JButton();
243:                jLabel7 = new javax.swing.JLabel();
244:                lYOrig = new javax.swing.JLabel();
245:                lUp = new javax.swing.JButton();
246:                lDown = new javax.swing.JButton();
247:                bCursor = new javax.swing.JButton();
248:                jLabel9 = new javax.swing.JLabel();
249:                lImgWidth = new javax.swing.JLabel();
250:                jLabel8 = new javax.swing.JLabel();
251:                lImgHeight = new javax.swing.JLabel();
252:                jLabel10 = new javax.swing.JLabel();
253:                cColors = new javax.swing.JComboBox();
254:                pRendering = new javax.swing.JPanel();
255:                bStartStop = new javax.swing.JButton();
256:                pbStatus = new javax.swing.JProgressBar();
257:                jLabel13 = new javax.swing.JLabel();
258:                lRenderTime = new javax.swing.JLabel();
259:
260:                getContentPane().setLayout(new java.awt.GridBagLayout());
261:
262:                setTitle("Rendering settings");
263:                setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
264:                setName("dSetting");
265:                pCfg.setLayout(new java.awt.GridBagLayout());
266:
267:                pCfg.setBorder(new javax.swing.border.TitledBorder(
268:                        "Configuration"));
269:                jLabel4.setText("Max. iterations:");
270:                gridBagConstraints = new java.awt.GridBagConstraints();
271:                gridBagConstraints.gridx = 0;
272:                gridBagConstraints.gridy = 0;
273:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
274:                gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
275:                gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
276:                pCfg.add(jLabel4, gridBagConstraints);
277:
278:                lMaxIteration.setText("...");
279:                lMaxIteration.setForeground(java.awt.Color.blue);
280:                gridBagConstraints = new java.awt.GridBagConstraints();
281:                gridBagConstraints.gridx = 1;
282:                gridBagConstraints.gridy = 0;
283:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
284:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
285:                gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
286:                pCfg.add(lMaxIteration, gridBagConstraints);
287:
288:                sMaxIteration.setMinimum(512);
289:                sMaxIteration.setMaximum(30000);
290:                sMaxIteration.setSnapToTicks(true);
291:                sMaxIteration
292:                        .addChangeListener(new javax.swing.event.ChangeListener() {
293:                            public void stateChanged(
294:                                    javax.swing.event.ChangeEvent evt) {
295:                                sMaxIterationStateChanged(evt);
296:                            }
297:                        });
298:
299:                gridBagConstraints = new java.awt.GridBagConstraints();
300:                gridBagConstraints.gridx = 2;
301:                gridBagConstraints.gridy = 0;
302:                gridBagConstraints.gridwidth = 3;
303:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
304:                gridBagConstraints.weightx = 1.0;
305:                gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
306:                pCfg.add(sMaxIteration, gridBagConstraints);
307:
308:                jLabel5.setText("Zoom factor:");
309:                gridBagConstraints = new java.awt.GridBagConstraints();
310:                gridBagConstraints.gridx = 0;
311:                gridBagConstraints.gridy = 1;
312:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
313:                gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
314:                gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
315:                pCfg.add(jLabel5, gridBagConstraints);
316:
317:                lZoomFactor.setText("...");
318:                lZoomFactor.setForeground(java.awt.Color.blue);
319:                gridBagConstraints = new java.awt.GridBagConstraints();
320:                gridBagConstraints.gridx = 1;
321:                gridBagConstraints.gridy = 1;
322:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
323:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
324:                gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
325:                pCfg.add(lZoomFactor, gridBagConstraints);
326:
327:                bZoomIn.setText("Zoom In");
328:                bZoomIn.addActionListener(new java.awt.event.ActionListener() {
329:                    public void actionPerformed(java.awt.event.ActionEvent evt) {
330:                        bZoomInActionPerformed(evt);
331:                    }
332:                });
333:
334:                gridBagConstraints = new java.awt.GridBagConstraints();
335:                gridBagConstraints.gridx = 2;
336:                gridBagConstraints.gridy = 1;
337:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
338:                gridBagConstraints.weightx = 1.0;
339:                gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
340:                pCfg.add(bZoomIn, gridBagConstraints);
341:
342:                bZoomOut.setText("Zoom Out");
343:                bZoomOut.addActionListener(new java.awt.event.ActionListener() {
344:                    public void actionPerformed(java.awt.event.ActionEvent evt) {
345:                        bZoomOutActionPerformed(evt);
346:                    }
347:                });
348:
349:                gridBagConstraints = new java.awt.GridBagConstraints();
350:                gridBagConstraints.gridx = 3;
351:                gridBagConstraints.gridy = 1;
352:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
353:                gridBagConstraints.weightx = 1.0;
354:                gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
355:                pCfg.add(bZoomOut, gridBagConstraints);
356:
357:                jLabel6.setText("X origin:");
358:                gridBagConstraints = new java.awt.GridBagConstraints();
359:                gridBagConstraints.gridx = 0;
360:                gridBagConstraints.gridy = 5;
361:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
362:                gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
363:                gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
364:                pCfg.add(jLabel6, gridBagConstraints);
365:
366:                lXOrig.setText("...");
367:                lXOrig.setForeground(java.awt.Color.blue);
368:                gridBagConstraints = new java.awt.GridBagConstraints();
369:                gridBagConstraints.gridx = 1;
370:                gridBagConstraints.gridy = 5;
371:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
372:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
373:                gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
374:                pCfg.add(lXOrig, gridBagConstraints);
375:
376:                lLeft.setText("Move left");
377:                lLeft.addActionListener(new java.awt.event.ActionListener() {
378:                    public void actionPerformed(java.awt.event.ActionEvent evt) {
379:                        lLeftActionPerformed(evt);
380:                    }
381:                });
382:
383:                gridBagConstraints = new java.awt.GridBagConstraints();
384:                gridBagConstraints.gridx = 2;
385:                gridBagConstraints.gridy = 5;
386:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
387:                gridBagConstraints.weightx = 1.0;
388:                gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
389:                pCfg.add(lLeft, gridBagConstraints);
390:
391:                lRight.setText("Move right");
392:                lRight.addActionListener(new java.awt.event.ActionListener() {
393:                    public void actionPerformed(java.awt.event.ActionEvent evt) {
394:                        lRightActionPerformed(evt);
395:                    }
396:                });
397:
398:                gridBagConstraints = new java.awt.GridBagConstraints();
399:                gridBagConstraints.gridx = 3;
400:                gridBagConstraints.gridy = 5;
401:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
402:                gridBagConstraints.weightx = 1.0;
403:                gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
404:                pCfg.add(lRight, gridBagConstraints);
405:
406:                jLabel7.setText("Y origin:");
407:                gridBagConstraints = new java.awt.GridBagConstraints();
408:                gridBagConstraints.gridx = 0;
409:                gridBagConstraints.gridy = 6;
410:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
411:                gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
412:                gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
413:                pCfg.add(jLabel7, gridBagConstraints);
414:
415:                lYOrig.setText("...");
416:                lYOrig.setForeground(java.awt.Color.blue);
417:                gridBagConstraints = new java.awt.GridBagConstraints();
418:                gridBagConstraints.gridx = 1;
419:                gridBagConstraints.gridy = 6;
420:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
421:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
422:                gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
423:                pCfg.add(lYOrig, gridBagConstraints);
424:
425:                lUp.setText("Move up");
426:                lUp.addActionListener(new java.awt.event.ActionListener() {
427:                    public void actionPerformed(java.awt.event.ActionEvent evt) {
428:                        lUpActionPerformed(evt);
429:                    }
430:                });
431:
432:                gridBagConstraints = new java.awt.GridBagConstraints();
433:                gridBagConstraints.gridx = 2;
434:                gridBagConstraints.gridy = 6;
435:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
436:                gridBagConstraints.weightx = 1.0;
437:                gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
438:                pCfg.add(lUp, gridBagConstraints);
439:
440:                lDown.setText("Move down");
441:                lDown.addActionListener(new java.awt.event.ActionListener() {
442:                    public void actionPerformed(java.awt.event.ActionEvent evt) {
443:                        lDownActionPerformed(evt);
444:                    }
445:                });
446:
447:                gridBagConstraints = new java.awt.GridBagConstraints();
448:                gridBagConstraints.gridx = 3;
449:                gridBagConstraints.gridy = 6;
450:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
451:                gridBagConstraints.weightx = 1.0;
452:                gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
453:                pCfg.add(lDown, gridBagConstraints);
454:
455:                bCursor.setText("Move to cursor");
456:                bCursor.addActionListener(new java.awt.event.ActionListener() {
457:                    public void actionPerformed(java.awt.event.ActionEvent evt) {
458:                        bCursorActionPerformed(evt);
459:                    }
460:                });
461:
462:                gridBagConstraints = new java.awt.GridBagConstraints();
463:                gridBagConstraints.gridx = 4;
464:                gridBagConstraints.gridy = 5;
465:                gridBagConstraints.gridheight = 2;
466:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
467:                gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
468:                pCfg.add(bCursor, gridBagConstraints);
469:
470:                jLabel9.setText("Image width:");
471:                gridBagConstraints = new java.awt.GridBagConstraints();
472:                gridBagConstraints.gridx = 0;
473:                gridBagConstraints.gridy = 10;
474:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
475:                gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
476:                gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
477:                pCfg.add(jLabel9, gridBagConstraints);
478:
479:                lImgWidth.setText("...");
480:                lImgWidth.setForeground(java.awt.Color.blue);
481:                gridBagConstraints = new java.awt.GridBagConstraints();
482:                gridBagConstraints.gridx = 1;
483:                gridBagConstraints.gridy = 10;
484:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
485:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
486:                gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
487:                pCfg.add(lImgWidth, gridBagConstraints);
488:
489:                jLabel8.setText("Image height:");
490:                gridBagConstraints = new java.awt.GridBagConstraints();
491:                gridBagConstraints.gridx = 0;
492:                gridBagConstraints.gridy = 11;
493:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
494:                gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
495:                gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
496:                pCfg.add(jLabel8, gridBagConstraints);
497:
498:                lImgHeight.setText("...");
499:                lImgHeight.setForeground(java.awt.Color.blue);
500:                gridBagConstraints = new java.awt.GridBagConstraints();
501:                gridBagConstraints.gridx = 1;
502:                gridBagConstraints.gridy = 11;
503:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
504:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
505:                gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
506:                pCfg.add(lImgHeight, gridBagConstraints);
507:
508:                jLabel10.setText("Image colors:");
509:                gridBagConstraints = new java.awt.GridBagConstraints();
510:                gridBagConstraints.gridx = 0;
511:                gridBagConstraints.gridy = 12;
512:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
513:                gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
514:                gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
515:                pCfg.add(jLabel10, gridBagConstraints);
516:
517:                cColors.setModel(new javax.swing.DefaultComboBoxModel(
518:                        new String[] { "Red", "Misc" }));
519:                gridBagConstraints = new java.awt.GridBagConstraints();
520:                gridBagConstraints.gridx = 1;
521:                gridBagConstraints.gridy = 12;
522:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
523:                gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
524:                pCfg.add(cColors, gridBagConstraints);
525:
526:                gridBagConstraints = new java.awt.GridBagConstraints();
527:                gridBagConstraints.gridx = 0;
528:                gridBagConstraints.gridy = 0;
529:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
530:                gridBagConstraints.weightx = 1.0;
531:                gridBagConstraints.weighty = 1.0;
532:                getContentPane().add(pCfg, gridBagConstraints);
533:
534:                pRendering.setLayout(new java.awt.GridBagLayout());
535:
536:                pRendering.setBorder(new javax.swing.border.TitledBorder(
537:                        "Rendering"));
538:                bStartStop.setText("Start rendering");
539:                bStartStop
540:                        .addActionListener(new java.awt.event.ActionListener() {
541:                            public void actionPerformed(
542:                                    java.awt.event.ActionEvent evt) {
543:                                bStartStopActionPerformed(evt);
544:                            }
545:                        });
546:
547:                gridBagConstraints = new java.awt.GridBagConstraints();
548:                gridBagConstraints.gridx = 0;
549:                gridBagConstraints.gridy = 0;
550:                gridBagConstraints.gridwidth = 2;
551:                gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
552:                pRendering.add(bStartStop, gridBagConstraints);
553:
554:                pbStatus.setStringPainted(true);
555:                gridBagConstraints = new java.awt.GridBagConstraints();
556:                gridBagConstraints.gridx = 0;
557:                gridBagConstraints.gridy = 1;
558:                gridBagConstraints.gridwidth = 2;
559:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
560:                gridBagConstraints.weightx = 1.0;
561:                gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
562:                pRendering.add(pbStatus, gridBagConstraints);
563:
564:                jLabel13
565:                        .setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
566:                jLabel13.setText("Last rendering time:");
567:                gridBagConstraints = new java.awt.GridBagConstraints();
568:                gridBagConstraints.gridx = 0;
569:                gridBagConstraints.gridy = 2;
570:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
571:                gridBagConstraints.weightx = 0.5;
572:                gridBagConstraints.weighty = 1.0;
573:                gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
574:                pRendering.add(jLabel13, gridBagConstraints);
575:
576:                lRenderTime
577:                        .setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
578:                lRenderTime.setForeground(java.awt.SystemColor.activeCaption);
579:                gridBagConstraints = new java.awt.GridBagConstraints();
580:                gridBagConstraints.gridx = 1;
581:                gridBagConstraints.gridy = 2;
582:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
583:                gridBagConstraints.weightx = 0.5;
584:                gridBagConstraints.weighty = 1.0;
585:                gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
586:                pRendering.add(lRenderTime, gridBagConstraints);
587:
588:                gridBagConstraints = new java.awt.GridBagConstraints();
589:                gridBagConstraints.gridx = 0;
590:                gridBagConstraints.gridy = 3;
591:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
592:                gridBagConstraints.weightx = 1.0;
593:                gridBagConstraints.weighty = 1.0;
594:                getContentPane().add(pRendering, gridBagConstraints);
595:
596:                setBounds(50, 50, 600, 320);
597:            }//GEN-END:initComponents
598:
599:            private void bCursorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bCursorActionPerformed
600:                if (lastRequest != null) {
601:                    xOrigin = lastRequest.getXOrig() + pPic.getCursorX()
602:                            * lastRequest.getDX() * lastRequest.getXStep();
603:                    lXOrig.setText(Double.toString(xOrigin));
604:
605:                    yOrigin = lastRequest.getYOrig() + pPic.getCursorY()
606:                            * lastRequest.getDY() * lastRequest.getYStep();
607:                    lYOrig.setText(Double.toString(yOrigin));
608:                }
609:            }//GEN-LAST:event_bCursorActionPerformed
610:
611:            private void lDownActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lDownActionPerformed
612:                yOrigin -= 0.1 * zoomFactor;
613:                lYOrig.setText(Double.toString(yOrigin));
614:            }//GEN-LAST:event_lDownActionPerformed
615:
616:            private void lUpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lUpActionPerformed
617:                yOrigin += 0.1 * zoomFactor;
618:                lYOrig.setText(Double.toString(yOrigin));
619:            }//GEN-LAST:event_lUpActionPerformed
620:
621:            private void lRightActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lRightActionPerformed
622:                xOrigin += 0.1 * zoomFactor;
623:                lXOrig.setText(Double.toString(xOrigin));
624:            }//GEN-LAST:event_lRightActionPerformed
625:
626:            private void lLeftActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lLeftActionPerformed
627:                xOrigin -= 0.1 * zoomFactor;
628:                lXOrig.setText(Double.toString(xOrigin));
629:            }//GEN-LAST:event_lLeftActionPerformed
630:
631:            private void bZoomOutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bZoomOutActionPerformed
632:                zoomFactor *= 1.0 / 0.925;
633:                lZoomFactor.setText(Double.toString(zoomFactor));
634:            }//GEN-LAST:event_bZoomOutActionPerformed
635:
636:            private void bZoomInActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bZoomInActionPerformed
637:                zoomFactor *= 0.925;
638:                lZoomFactor.setText(Double.toString(zoomFactor));
639:            }//GEN-LAST:event_bZoomInActionPerformed
640:
641:            private void sMaxIterationStateChanged(
642:                    javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_sMaxIterationStateChanged
643:                maxIteration = (short) sMaxIteration.getValue();
644:                lMaxIteration.setText(Short.toString(maxIteration));
645:            }//GEN-LAST:event_sMaxIterationStateChanged
646:
647:            private void bStartStopActionPerformed(
648:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bStartStopActionPerformed
649:                if (rendThread == null)
650:                    this .startRendering();
651:                else {
652:                    try {
653:                        rendThread.interrupt();
654:                        rendThread.join();
655:                    } catch (Exception ex) {
656:                        log.warn("Error stopping the rendering", ex);
657:
658:                        JOptionPane.showMessageDialog(this ,
659:                                "Error stopping the rendering.",
660:                                "Rendering error", JOptionPane.ERROR_MESSAGE);
661:
662:                        rendThread = null;
663:                    }
664:                }
665:
666:                if (rendThread == null)
667:                    bStartStop.setText("Start rendering");
668:                else
669:                    bStartStop.setText("Stop rendering");
670:            }//GEN-LAST:event_bStartStopActionPerformed
671:
672:            // Variables declaration - do not modify//GEN-BEGIN:variables
673:            private javax.swing.JButton bCursor;
674:            private javax.swing.JButton bStartStop;
675:            private javax.swing.JButton bZoomIn;
676:            private javax.swing.JButton bZoomOut;
677:            private javax.swing.JComboBox cColors;
678:            private javax.swing.JLabel jLabel10;
679:            private javax.swing.JLabel jLabel13;
680:            private javax.swing.JLabel jLabel4;
681:            private javax.swing.JLabel jLabel5;
682:            private javax.swing.JLabel jLabel6;
683:            private javax.swing.JLabel jLabel7;
684:            private javax.swing.JLabel jLabel8;
685:            private javax.swing.JLabel jLabel9;
686:            private javax.swing.JButton lDown;
687:            private javax.swing.JLabel lImgHeight;
688:            private javax.swing.JLabel lImgWidth;
689:            private javax.swing.JButton lLeft;
690:            private javax.swing.JLabel lMaxIteration;
691:            private javax.swing.JLabel lRenderTime;
692:            private javax.swing.JButton lRight;
693:            private javax.swing.JButton lUp;
694:            private javax.swing.JLabel lXOrig;
695:            private javax.swing.JLabel lYOrig;
696:            private javax.swing.JLabel lZoomFactor;
697:            private javax.swing.JPanel pCfg;
698:            private javax.swing.JPanel pRendering;
699:            private javax.swing.JProgressBar pbStatus;
700:            private javax.swing.JSlider sMaxIteration;
701:            // End of variables declaration//GEN-END:variables
702:
703:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.