001 package atlantis;
002
003 import java.awt.Rectangle;
004 import java.awt.Toolkit;
005 import java.io.File;
006 import java.io.InputStream;
007
008 import javax.swing.UIManager;
009 import javax.xml.parsers.DocumentBuilder;
010 import javax.xml.parsers.DocumentBuilderFactory;
011
012 import org.w3c.dom.Node;
013 import org.apache.commons.cli.Option;
014 import org.apache.commons.cli.OptionBuilder;
015 import org.apache.commons.cli.OptionGroup;
016 import org.apache.commons.cli.Options;
017 import org.apache.commons.cli.HelpFormatter;
018 import org.apache.commons.cli.CommandLine;
019 import org.apache.commons.cli.CommandLineParser;
020 import org.apache.commons.cli.GnuParser;
021 import org.apache.commons.cli.ParseException;
022
023 import atlantis.canvas.ACanvas;
024 import atlantis.config.ADefaultValues;
025 import atlantis.config.AConfigUpdater;
026 import atlantis.event.AEventManager;
027 import atlantis.event.AEventSource.InvalidEventSourceException;
028 import atlantis.event.AEventSource.NoMoreEventsException;
029 import atlantis.event.AEventSource.ReadEventException;
030 import atlantis.event.AEventSourceException;
031 import atlantis.geometry.AAtlasDetector;
032 import atlantis.geometry.ADetectorSystem;
033 import atlantis.gui.AColorMap;
034 import atlantis.gui.ADemoDialog;
035 import atlantis.gui.AEventQueue;
036 import atlantis.gui.AExceptionHandler;
037 import atlantis.gui.AGUI;
038 import atlantis.gui.ACursorFactory;
039 import atlantis.gui.AStartupWindow;
040 import atlantis.gui.AReadEventFromServerDialog;
041 import atlantis.list.AListManager;
042 import atlantis.parameters.APar;
043 import atlantis.projection.AProjectionsManager;
044 import atlantis.utils.AAtlantisException;
045 import atlantis.utils.AUtilities;
046 import atlantis.utils.AMath;
047 import atlantis.utils.xml.AXMLErrorHandler;
048 import atlantis.utils.xml.AXMLUtils;
049 import atlantis.event.AEventHistory;
050 import atlantis.utils.ALogger;
051 import javax.swing.JOptionPane;
052
053
054
055 public class Atlantis
056 {
057
058
059
060 private static ALogger logger = null;
061
062
063 public static String versionAtlantisJava = "$Name: AtlantisJava-09-11-11 $";
064
065 public static final String fileSep = System.getProperty("file.separator");
066 public static final String lineSep = System.getProperty("line.separator");
067 public static final String userHome = System.getProperty("user.home");
068
069
070 public static boolean SHOW_HLTAUTOKEY = false;
071
072 public static int MAX_WIDTH = 0;
073
074 public static boolean inDemo = false;
075
076
077
078 private static final AEventManager eventManager = new AEventManager();
079 private static final ACursorFactory cursors = new ACursorFactory();
080
081 private static ADetectorSystem detector;
082 private static ACanvas canvas;
083 private static AGUI gui;
084
085 private static final String JDK_VERSION_ERROR_MSG =
086 "Atlantis requires Java (JDK or JRE) version 1.5 or newer.\n" +
087 "Please visit: http://java.sun.com/j2se/1.5/ and download Java 1.5";
088
089 private static final String INIT_ERROR_MSG =
090 "Error during Atlantis initialization.\n" +
091 "(configuration file related issues might be\n" +
092 "corrected by running with -x (updating customised configuration)).\n" +
093 "See console output for more information.";
094
095 public static final String LIVE_POINT_1_EVENTS_URL =
096 "http://pcatdwww.cern.ch/atlas-point1/EventDisplayFiles";
097
098
099 private static boolean updateConfig = false;
100
101 private static String configCommandLine = null;
102
103 private static String colormapCommandLine = null;
104
105 private static String serverName = null;
106
107 private static Integer serverPort = 48965;
108
109 private static String archiveName = null;
110
111 private static boolean accessOrder = ADemoDialog.SEQUENTIAL;
112
113 private static boolean demoMode = ADemoDialog.SINGLE_WINDOW_MODE;
114
115 private static String selectedProjections = null;
116
117 private static Integer loopInterval = null;
118
119 private static String defaultEventFile = null;
120
121 private static AEventHistory eventHistory = null;
122
123 public static final boolean atlantisWithOpenGL = false;
124
125
126
127
128
129
130 private static String getServerName()
131 {
132 return serverName;
133 }
134
135
136
137
138
139 private static Integer getServerPort()
140 {
141 return serverPort;
142 }
143
144
145
146
147
148
149 private static Integer getLoopInterval()
150 {
151 return loopInterval;
152 }
153
154
155
156
157
158
159 public static AEventHistory getEventHistory() {
160 return eventHistory;
161 }
162
163
164
165
166
167 private static void checkJDKVersion()
168 {
169 try
170 {
171 UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
172 }
173 catch(Exception e)
174 {
175 AExceptionHandler.processException("Error During Setting Look and Feel", e);
176 }
177
178 String version = System.getProperty("java.version");
179 if(version == null || version.compareTo("1.5") < 0)
180 {
181 AExceptionHandler.processException("fatal", JDK_VERSION_ERROR_MSG);
182 }
183
184 }
185
186
187 private static void updateStartupWindow(AStartupWindow win, String msg)
188 {
189 win.updateText(msg);
190
191 }
192
193
194
195 private static void initAtlantis() {
196 AStartupWindow startupWin = null;
197
198 try {
199
200 System.setProperty("sun.awt.exception.handler",
201 "AAWTExceptionHandler");
202 Toolkit.getDefaultToolkit().getSystemEventQueue().push(new AEventQueue());
203
204 startupWin = AStartupWindow.getInstance();
205 updateStartupWindow(startupWin, "Atlantis initialisation");
206
207 logger.info("Atlantis home: " + Atlantis.getHomeDirectory());
208
209
210 logger.info("Reading Atlantis runtime configuration");
211 ADefaultValues.readRuntimeValues();
212
213
214 updateStartupWindow(startupWin, "Reading Atlantis configuration");
215 logger.info("Reading the configuration...");
216
217 String fileNameDist = getHomeDirectory() + "configuration" +
218 fileSep + "config.xml";
219 String fileNameUser = userHome + fileSep + ".Atlantis-config.xml";
220
221
222 String fileNameChk = userHome + fileSep + ".Atlantis-config.chk";
223
224
225
226 if ((new File(fileNameChk).exists() &&
227 !AConfigUpdater.compareChecksums(fileNameDist, fileNameChk)) ||
228 !new File(fileNameChk).exists()) {
229 AConfigUpdater.createChecksumFile(fileNameDist, fileNameChk);
230 Atlantis.updateConfig = true;
231 logger.info("Updating customised configuration forced.");
232 }
233
234
235
236
237 if (Atlantis.configCommandLine != null) {
238 logger.info("Configuration file specified on command line: " +
239 Atlantis.configCommandLine);
240 fileNameUser = Atlantis.configCommandLine;
241 }
242
243
244 InputStream isConfig = null;
245
246 try {
247 logger.info("Using configuration file: " + fileNameUser);
248 if (Atlantis.updateConfig) {
249 updateStartupWindow(startupWin, "Updating user's configuration");
250 logger.info("Updating user's customised configuration file ...");
251 AConfigUpdater.updateConfigurationFile(fileNameDist, fileNameUser);
252 } else {
253 logger.info("User's configuration file is up-to-date.");
254 }
255
256 isConfig = AUtilities.getFileAsStream(fileNameUser);
257 } catch (AAtlantisException aae) {
258
259 logger.error("Could not read " + fileNameUser + " reason: " +
260 aae.getMessage());
261 logger.info("Using configuration file: " + fileNameDist);
262 isConfig = AUtilities.getFileAsStream(fileNameDist);
263 }
264
265
266 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
267 factory.setValidating(true);
268 DocumentBuilder parser = factory.newDocumentBuilder();
269 parser.setErrorHandler(new AXMLErrorHandler());
270
271
272 Node rootNode = parser.parse(isConfig).getDocumentElement();
273
274
275 Node initializationNode = AXMLUtils.getChild(rootNode, "Initialization");
276
277
278 logger.info("Reading the colour map...");
279 updateStartupWindow(startupWin, "Reading Atlantis colour map");
280 AColorMap.readColorMap(Atlantis.colormapCommandLine);
281
282
283 logger.info("Building Canvas, Projections...");
284 updateStartupWindow(startupWin, "Building Atlantis Canvas, Projections");
285 Node canvasNode = AXMLUtils.getChild(initializationNode, "Canvas");
286 canvas = new ACanvas(canvasNode);
287
288
289
290 logger.info("Building Parameters...");
291 new APar(AXMLUtils.getChild(rootNode, "Parameters")).update(
292 AXMLUtils.getChild(rootNode, "ParameterDifferences"));
293
294 Node interactionsNode =
295 AXMLUtils.getChild(initializationNode, "Interactions");
296 AProjectionsManager.initialise(interactionsNode);
297
298
299 logger.info("Reading the geometry...");
300 updateStartupWindow(startupWin, "Reading Atlantis geometry");
301 String geomPrefix = Atlantis.getHomeDirectory() + "geometry" +
302 Atlantis.fileSep;
303 String geomName = ADefaultValues.get("GeometryName");
304 if (!"".equals(geomName)) {
305
306 geomName = "_" + geomName;
307
308
309 String geomNameFull1 = geomPrefix + "AGeometry" + geomName + ".xml";
310 String geomNameFull2 = geomPrefix + "AMuonGeometry" + geomName + ".xml";
311 try {
312
313 InputStream i = AUtilities.getFileAsStream(geomNameFull1);
314 i = AUtilities.getFileAsStream(geomNameFull2);
315 i = null;
316 } catch (AAtlantisException ae) {
317 geomName = "";
318 }
319 }
320 String geomIdCalo = geomPrefix + "AGeometry" + geomName + ".xml";
321 String geomMuon = geomPrefix + "AMuonGeometry" + geomName + ".xml";
322 detector = new AAtlasDetector(geomIdCalo, geomMuon);
323
324 canvas.finalizeConstruction();
325 canvas.readCorners(AXMLUtils.getChild(rootNode, "WindowCorners"));
326
327 canvas.setCurrentWindow(canvas.getCurrentWindowName());
328
329 getEventManager().addNewEventListener(canvas);
330
331
332
333 updateStartupWindow(startupWin, "Reading event file");
334
335 if (Atlantis.archiveName == null && Atlantis.serverName == null) {
336
337 getDefaultEvent();
338 }
339
340 logger.info("Atlantis Ready...");
341 updateStartupWindow(startupWin, "Atlantis Ready");
342
343
344 logger.info("Displaying GUI, Canvas...");
345 updateStartupWindow(startupWin, "Displaying Atlantis GUI and Canvas");
346
347 AColorMap.setColorMap(APar.get("Prefs", "ColorMap").getI());
348
349
350
351 canvas.setVisible(true);
352
353
354
355
356 canvas.correctAspectRatios();
357
358
359
360
361 Rectangle screenSize = canvas.getGraphicsConfiguration().getBounds();
362
363 int useWidth = screenSize.width;
364 if (MAX_WIDTH > 0 && useWidth > MAX_WIDTH) {
365 useWidth = MAX_WIDTH;
366 }
367 int guiHeight = canvas.getBounds().height;
368 gui = new AGUI(guiHeight);
369 if (canvas.getCurrentLayout().getName().equals("FULL SCREEN")) {
370 int guiWidth = useWidth / 4;
371 gui.setBounds(useWidth * 3 / 4, 0, guiWidth, guiHeight);
372 } else {
373 int guiWidth = useWidth - canvas.getBounds().width - canvas.getBounds().x;
374 gui.setBounds(canvas.getBounds().x + canvas.getBounds().width,
375 canvas.getBounds().y, guiWidth, guiHeight);
376 }
377 gui.setVisible(true);
378
379 if (Atlantis.serverName != null) {
380 if (Atlantis.loopInterval != null) {
381
382
383 AReadEventFromServerDialog dialog = AReadEventFromServerDialog.getInstance();
384
385 dialog.setServerName(getServerName());
386 dialog.setPortNumber(getServerPort());
387 dialog.setUpdateInterval(getLoopInterval());
388 dialog.showDialog();
389 dialog.startEventLoop();
390 } else {
391
392
393 String sourceName = "xmlrpc://" + getServerName() + ":" + getServerPort();
394
395 try {
396 Atlantis.getEventManager().setEventSource(sourceName);
397 Atlantis.getEventManager().nextEvent();
398 } catch (AEventSourceException aes) {
399 JOptionPane.showMessageDialog(AGUI.getGUI(), "Cannot read event from server - " +
400 "reading default event instead", "Bad Event Source", JOptionPane.ERROR_MESSAGE);
401
402 logger.error("Unable to read event from server:");
403 logger.error(aes.getCauseMessges());
404
405 logger.info("Reading default event instead");
406 getDefaultEvent();
407 }
408 }
409 }
410
411 if (Atlantis.archiveName != null)
412 {
413
414
415 ADemoDialog.getInstance().setSelectedFile(Atlantis.archiveName);
416 ADemoDialog.getInstance().setMode(Atlantis.demoMode);
417 ADemoDialog.getInstance().setAccessOrder(Atlantis.accessOrder);
418 if (getLoopInterval() != null)
419 ADemoDialog.getInstance().setTimerInterval(getLoopInterval());
420
421 if (Atlantis.selectedProjections != null) {
422 ADemoDialog.getInstance().clearProjSelection();
423 if (selectedProjections.indexOf("1") >= 0) {
424 ADemoDialog.getInstance().setProjStatus("YX", true);
425 }
426 if (selectedProjections.indexOf("2") >= 0) {
427 ADemoDialog.getInstance().setProjStatus("VP", true);
428 }
429 if (selectedProjections.indexOf("3") >= 0) {
430 ADemoDialog.getInstance().setProjStatus("EG", true);
431 }
432 if (selectedProjections.indexOf("4") >= 0) {
433 ADemoDialog.getInstance().setProjStatus("RZ", true);
434 }
435 if (selectedProjections.indexOf("5") >= 0) {
436 ADemoDialog.getInstance().setProjStatus("FR", true);
437 }
438 if (selectedProjections.indexOf("6") >= 0) {
439 ADemoDialog.getInstance().setProjStatus("FZ", true);
440 }
441 if (selectedProjections.indexOf("7") >= 0) {
442 ADemoDialog.getInstance().setProjStatus("XZ", true);
443 }
444 if (selectedProjections.indexOf("8") >= 0) {
445 ADemoDialog.getInstance().setProjStatus("YZ", true);
446 }
447 if (selectedProjections.indexOf("9") >= 0) {
448 ADemoDialog.getInstance().setProjStatus("LegoPlot", true);
449 }
450 if (!ADemoDialog.getInstance().checkProjSelection()) {
451 ADemoDialog.getInstance().setDefaultProjSelection();
452 }
453 }
454 String order = (Atlantis.accessOrder) ? "random" : "sequential";
455 logger.info("Reading event from " + Atlantis.archiveName + " in " + order + " access order");
456 ADemoDialog.getInstance().setVisible(true);
457 ADemoDialog.getInstance().startDemo();
458 }
459
460
461 if (eventHistory != null)
462 getEventManager().addNewEventListener(eventHistory);
463
464 } catch (Exception e) {
465 logger.fatal(INIT_ERROR_MSG);
466 logger.fatal(e.getMessage(), e);
467 AExceptionHandler.processException(INIT_ERROR_MSG, e);
468 } finally {
469 if (startupWin != null) {
470 startupWin.dispose();
471 }
472 }
473
474 }
475
476
477
478
479
480 public static AEventManager getEventManager()
481 {
482 return eventManager;
483 }
484
485
486
487
488 public static ADetectorSystem getDetector()
489 {
490 return detector;
491
492 }
493
494
495
496
497
498
499 public static void setDetector(ADetectorSystem currentDetector)
500 {
501 Atlantis.detector = currentDetector;
502
503 }
504
505
506
507
508
509 public static void restoreDefaults()
510 {
511
512 APar.restoreDefaults();
513
514 if (getEventManager().getCurrentEvent() != null) {
515 getEventManager().getCurrentEvent().setPrimaryVertex();
516 }
517
518 AListManager.getInstance().reset();
519
520 AGUI.refresh();
521 ACanvas.getCanvas().restoreDefaults();
522
523 }
524
525
526 public static String getHomeDirectory()
527 {
528
529 String temp = Atlantis.class.getResource("Atlantis.class").getFile();
530
531 temp = temp.substring(5);
532 if(temp.indexOf("!") > -1)
533 {
534
535 temp = temp.substring(0, temp.indexOf("!"));
536 temp = temp.replaceAll("%20", " ");
537 return temp.substring(0, temp.lastIndexOf('/') + 1);
538 }
539
540 return System.getProperty("user.dir") + fileSep;
541
542 }
543
544 private static void processCommandLineParameters(String args[])
545 {
546 HelpFormatter formatter = new HelpFormatter();
547
548 Options o = new Options();
549 Option hltautokey = new Option("a", false, "show HLTAutoKey tracks");
550 o.addOption(hltautokey);
551
552 System.out.print("Command line arguments:\n ");
553 for(int i = 0; i < args.length; i++)
554 {
555 System.out.print(args[i] + " ");
556 }
557 System.out.println("\n");
558
559 Option config = OptionBuilder.withArgName("file")
560 .hasArg()
561 .withDescription("read configuration from specified file")
562 .withLongOpt("config")
563 .create("c");
564 o.addOption(config);
565
566
567 String debugDescr = "log debug messages of severity level to " +
568 "stdout, if destination (filename) is set " +
569 "then also to a file. severity levels are " +
570 ALogger.getStringLevels() + " (INFO is default)";
571 Option debug = OptionBuilder.hasArgs(2)
572 .withArgName("severity destination")
573 .withDescription(debugDescr)
574 .withLongOpt("debug").create('d');
575 o.addOption(debug);
576
577
578 Option defaultEvent = OptionBuilder.withArgName("file")
579 .hasArg()
580 .withDescription("set default event file at startup")
581 .withLongOpt("default")
582 .create("f");
583 o.addOption(defaultEvent);
584
585
586 Option configMode = new Option("g", false, "use configuration demo mode with -l (single window mode by default)");
587 Option help = new Option("h", "help", false, "display this help message");
588 Option projection = OptionBuilder.withArgName("number")
589 .hasArg()
590 .withDescription("set projections used in single window demo mode with -l (e.g. -j 123)"
591 + "\n 1 --- YX"
592 + "\n 2 --- " + AMath.PHI + AMath.ETA
593 + "\n 3 --- " + AMath.PHI + AMath.LAMBDA
594 + "\n 4 --- " + AMath.RHO + "Z"
595 + "\n 5 --- " + AMath.PHI + AMath.RHO
596 + "\n 6 --- " + AMath.PHI + "Z"
597 + "\n 7 --- X'Z"
598 + "\n 8 --- Y'Z"
599 + "\n 9 --- LegoPlot")
600 .withLongOpt("projection")
601 .create("j");
602 Option loop = OptionBuilder.withArgName("file")
603 .hasArg()
604 .withDescription("loop through all events in specified file (.zip archive)")
605 .withLongOpt("loop")
606 .create("l");
607 Option colormap = OptionBuilder.withArgName("file")
608 .hasArg()
609 .withDescription("read colourmap from specified file")
610 .withLongOpt("colormap")
611 .create("m");
612 Option pause = OptionBuilder.withArgName("seconds")
613 .hasArg()
614 .withDescription("set timer interval for -s or -l options")
615 .withLongOpt("pause")
616 .create("p");
617 Option random = new Option("r", "random", false, "use random access order with -l (sequential by default)");
618 Option server = OptionBuilder.withArgName("hostname[:port]")
619 .hasArg()
620 .withDescription("read event from specified remote server")
621 .withLongOpt("server")
622 .create("s");
623 Option updateConfig = new Option("x", "updateconfig", false, "update user's configuration file");
624 Option maxWidth = OptionBuilder.withArgName("maxwidth")
625 .hasArg()
626 .withDescription("maximum screen width used by Atlantis")
627 .withLongOpt("maxwidth")
628 .create("w");
629
630
631
632
633
634 String overviewDescr = "save history overview when reading files from " +
635 "JiveXML server: save PNG and XML " +
636 "files into directory dir every n events and " +
637 " keep m events in total";
638 Option monitOverview = OptionBuilder.hasArgs(3)
639 .withArgName("dir n m")
640 .withDescription(overviewDescr).
641 withLongOpt("overview").create('o');
642 o.addOption(monitOverview);
643
644
645 o.addOption(help);
646 OptionGroup group1 = new OptionGroup();
647 group1.addOption(loop);
648 group1.addOption(server);
649 o.addOptionGroup(group1);
650 OptionGroup group2 = new OptionGroup();
651 group2.addOption(configMode);
652 group2.addOption(projection);
653 o.addOptionGroup(group2);
654 o.addOption(colormap);
655 o.addOption(pause);
656 o.addOption(random);
657 o.addOption(updateConfig);
658 o.addOption(maxWidth);
659
660 CommandLineParser parser = new GnuParser();
661 String headerMsg = "\nMandatory arguments to long options are " +
662 "mandatory for short options too.\n";
663 String footerMsg = "\n-l and -s are mutually exclusive\n";
664 footerMsg += "-g and -j are mutually exclusive\n";
665 footerMsg += "\nAtlFast objects were supported up to " +
666 "AtlantisJava-09-05-28 via \"Fast\" option.\n";
667 footerMsg += "Beginner simplified GUI was supported up to " +
668 "AtlantisJava-09-05-28 via \"Beginner\" option.\n";
669 footerMsg += "CTB 2004 geometry was supported up to " +
670 "AtlantisJava-09-07-42 via -t, --testbeam option.\n";
671
672 try
673 {
674 CommandLine l = parser.parse(o, args);
675
676
677 if(l.hasOption('a'))
678 {
679 Atlantis.SHOW_HLTAUTOKEY = true;
680 }
681 if(l.hasOption('c'))
682 {
683 Atlantis.configCommandLine = l.getOptionValue('c', null);
684 }
685 if(l.hasOption('d'))
686 {
687 String[] vals = l.getOptionValues('d');
688
689
690 try
691 {
692 ALogger.initialize(vals);
693 }
694 catch(Exception aa)
695 {
696
697 throw new ParseException(debug.getLongOpt() +
698 " settings incorrect: " + aa.getMessage());
699 }
700 }
701 if(l.hasOption('f'))
702 {
703 Atlantis.defaultEventFile = l.getOptionValue('f', null);
704 }
705 if(l.hasOption('h'))
706 {
707 formatter.printHelp("Atlantis", headerMsg, o, footerMsg);
708 System.exit(0);
709 }
710 if(l.hasOption('l'))
711 {
712 Atlantis.archiveName = l.getOptionValue('l', null);
713 if(l.hasOption('g'))
714 {
715 Atlantis.demoMode = ADemoDialog.CONFIGURATION_MODE;
716 }
717 else
718 {
719
720 if(l.hasOption('j'))
721 {
722 Atlantis.selectedProjections = l.getOptionValue('j', null);
723 }
724 }
725 if(l.hasOption('r'))
726 {
727 Atlantis.accessOrder = ADemoDialog.RANDOM;
728 }
729 }
730 if(l.hasOption('m'))
731 {
732
733 Atlantis.colormapCommandLine = l.getOptionValue('m', null);
734 }
735 if (l.hasOption('s')) {
736
737 String[] serverPortName = l.getOptionValue('s', null).split(":");
738 if ((serverPortName.length < 1) || (serverPortName.length > 2))
739 throw new ParseException("Server option needs argument in the format 'hostname:port'");
740
741
742 if (!((serverPortName[0]).equals("")))
743 Atlantis.serverName = serverPortName[0];
744
745
746 if (serverPortName.length == 2) {
747 if (!(serverPortName[1]).equals("")) {
748 try {
749
750 Atlantis.serverPort = Integer.parseInt(serverPortName[1]);
751 } catch (NumberFormatException nfe) {
752 throw new ParseException("Port number " + serverPortName[1] + " is not valid for -s option");
753 }
754 }
755 }
756 }
757
758
759
760 if (l.hasOption('p')) {
761 String s = l.getOptionValue('p', null);
762
763 try {
764 loopInterval = Integer.parseInt(s);
765 } catch (NumberFormatException nfe) {
766 throw new ParseException(s + " is not integer for -p option");
767 }
768 }
769
770 if(l.hasOption('w'))
771 {
772 try
773 {
774 Atlantis.MAX_WIDTH = Integer.parseInt(l.getOptionValue('w', null));
775 }
776 catch (NumberFormatException e)
777 {
778 Atlantis.MAX_WIDTH = 0;
779 }
780 }
781 if(l.hasOption('x'))
782 {
783 Atlantis.updateConfig = true;
784 }
785 if(l.hasOption('o'))
786 {
787 String[] vals = l.getOptionValues('o');
788 if(vals.length != monitOverview.getArgs())
789 {
790 throw new ParseException(monitOverview.getLongOpt() +
791 " options takes exactly 3 arguments");
792 }
793
794
795
796 try
797 {
798 String dir = vals[0];
799 short n = Short.parseShort(vals[1]);
800 short m = Short.parseShort(vals[2]);
801 Atlantis.eventHistory = new AEventHistory(dir,n,m);
802 } catch (NumberFormatException nfe){
803 throw new ParseException("Invalid parameters to option -o");
804 } catch(Exception aa){
805 throw new ParseException(aa.getMessage());
806 }
807 }
808 }
809 catch(ParseException ex)
810 {
811 System.err.println("\n" + ex.getMessage() + "\n");
812 formatter.printHelp("Atlantis", headerMsg, o, footerMsg);
813 System.exit(1);
814 }
815
816 }
817
818
819
820
821
822 public static void getDefaultEvent()
823 {
824
825 String eventPath;
826
827
828 if(Atlantis.defaultEventFile != null) {
829 eventPath = Atlantis.defaultEventFile;
830 } else {
831
832 eventPath = Atlantis.getHomeDirectory() + "events" + Atlantis.fileSep +
833 "test_events.zip";
834 }
835
836
837 logger.info("Reading the default event: " + eventPath);
838
839 try {
840 getEventManager().setEventSource(eventPath);
841 getEventManager().nextEvent();
842 } catch (InvalidEventSourceException ies){
843
844 String msg = "Can not access "+eventPath+": "+ies.getMessage();
845 logger.error(msg);
846
847 JOptionPane.showMessageDialog(ACanvas.getCanvas(), msg,
848 "Invalid Event Source",JOptionPane.ERROR_MESSAGE);
849 } catch (NoMoreEventsException nme){
850 String msg = "No events in "+eventPath+": "+nme.getMessage();
851 logger.error(msg);
852
853 JOptionPane.showMessageDialog(ACanvas.getCanvas(), msg,
854 "No Events found",JOptionPane.ERROR_MESSAGE);
855 } catch (ReadEventException rex){
856 String msg = "Can not read events from "+eventPath+": "+rex.getMessage();
857 logger.error(msg);
858
859 JOptionPane.showMessageDialog(ACanvas.getCanvas(), msg,
860 "Can not read event",JOptionPane.ERROR_MESSAGE);
861 }
862 }
863
864
865 private static void setCVSTagInfo()
866 {
867
868 String s = Atlantis.versionAtlantisJava;
869 s = Atlantis.versionAtlantisJava.replaceAll("Name", "");
870 s = s.replaceAll("\\$", "").replaceAll(":", "").trim();
871 if("".compareTo(s) == 0)
872 {
873 s = "AtlantisJava (CVS tag n/a)";
874 }
875 Atlantis.versionAtlantisJava = s;
876
877 }
878
879
880
881 public static void main(String[] args)
882 {
883 processCommandLineParameters(args);
884
885
886 logger = ALogger.getLogger(Atlantis.class);
887
888 checkJDKVersion();
889
890 setCVSTagInfo();
891 String msg = "Running AtlantisJava version (CVS tag): " +
892 Atlantis.versionAtlantisJava;
893 logger.info(msg);
894
895 if (Atlantis.atlantisWithOpenGL) {
896 logger.info("Testing for OpenGL");
897 logger.info(AOpenGLTools.isOpenGLAvailable() ? "Open GL Available" : "Open GL Unavailable");
898 }
899
900 initAtlantis();
901
902 }
903
904
905 }
906
Due to the LXR bug, the updates fail sometimes to remove references to deleted files. The Saturday's full rebuilds fix these problems |
This page was automatically generated by the
LXR engine.
|
|