Report problems to ATLAS LXR Team (with time and IP address indicated)

The LXR Cross Referencer

source navigation ]
diff markup ]
identifier search ]
general search ]
 
 
Architecture: linux ]
Version: head ] [ nightly ] [ GaudiDev ]
  Links to LXR source navigation pages for stable releases [ 12.*.* ]   [ 13.*.* ]   [ 14.*.* ] 

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     // the attribute gets initialized after command line options
058     // are processed. all other classes will just do 
059     // logger = ALogger.getLogger(Class.class) in their attribute definitions
060     private static ALogger logger = null;
061 
062     // expands into CVS tag
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     // flag for displaying HLTAutoKey data
070     public static boolean SHOW_HLTAUTOKEY = false;
071     // limit the total width of Atlantis to this number of pixels (0 = screen width)
072     public static int MAX_WIDTH = 0;
073     
074     public static boolean inDemo = false;
075 
076     // main Atlantis components
077     // static final declaration ensures these objects are always there
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     // force Atlantis to update the personal configuration file
099     private static boolean updateConfig = false;
100     // configuration file specified as command line argument
101     private static String configCommandLine = null;
102     // colormap file specified as command line argument
103     private static String colormapCommandLine = null;
104     // server name specified as command line argument for reading event remotely
105     private static String serverName = null;
106     // server port specified as command line argument for reading event remotely
107     private static Integer serverPort = 48965;
108     // archive name specified as command line argument for looping
109     private static String archiveName = null;
110     // access order when using -l to loop through an archive
111     private static boolean accessOrder = ADemoDialog.SEQUENTIAL;
112     // demo mode when using -l to loop through an archive
113     private static boolean demoMode = ADemoDialog.SINGLE_WINDOW_MODE;
114     // selected projections specified as command line argument for looping
115     private static String selectedProjections = null;
116     // timer delay for reading events from server automatically
117     private static Integer loopInterval = null;
118     // default event file specified from command line
119     private static String defaultEventFile = null;
120     // Object for saving event history in a directory
121     private static AEventHistory eventHistory = null;
122     
123     public static final boolean atlantisWithOpenGL = false;
124 
125     
126     /**
127      * Returns the name of the server specified as a command line option or null
128      * @return the server name
129      */
130     private static String getServerName()
131     {
132         return serverName;
133     }  
134    
135     /**
136      * Returns the port number of the server specified as a command line option or null
137      * @return the port number of the server
138      */
139     private static Integer getServerPort()
140     {
141         return serverPort;
142     }
143   
144     /**
145      * Returns the delay for timer for automatic event reading from server
146      * when this option was specified as command line argument 
147      * @return the delay in seconds
148      */
149     private static Integer getLoopInterval()
150     {
151         return loopInterval;
152     }
153  
154     /**
155      * Return the eventHistory object, which saves raw event data, images and
156      * thumbnails into files, keeping a maximum number of files
157      * @return the AEventHistoryObject
158      */
159     public static AEventHistory getEventHistory() {
160       return eventHistory;
161     }
162  
163  
164     /**
165      * Checks the version of user's Java Runtime Environment
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     } // checkJDKVersion() --------------------------------------------------
185 
186 
187     private static void updateStartupWindow(AStartupWindow win, String msg)
188     {
189         win.updateText(msg);
190         
191     } // updateStartupWindow() ----------------------------------------------
192 
193 
194     
195     private static void initAtlantis() {
196     AStartupWindow startupWin = null;
197 
198     try {
199       // replace event queue by AEventQueue ---------------------------
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       // reading Atlantis runtime configuration
210       logger.info("Reading Atlantis runtime configuration");
211       ADefaultValues.readRuntimeValues();
212 
213       // read the configuration xml files -------------------------
214       updateStartupWindow(startupWin, "Reading Atlantis configuration");
215       logger.info("Reading the configuration...");
216       // configuration file from the Atlantis distributon
217       String fileNameDist = getHomeDirectory() + "configuration" +
218               fileSep + "config.xml";
219       String fileNameUser = userHome + fileSep + ".Atlantis-config.xml";
220       // this is checksum of the distribution's configuration file
221       // if it doesn't match, Atlantis tries to update user's configuration
222       String fileNameChk = userHome + fileSep + ".Atlantis-config.chk";
223 
224       // check if the checksum file (.chk) is up-to-date,
225       // create one if not exist or not is not up-to-date
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       // if configuration file is specified as command line argument
235       // take it rather than configuration in user's home directory
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       //check if we can read the user configuration file
244       InputStream isConfig = null; // configuration file input stream
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         // read the configuration file from user's home directory
256         isConfig = AUtilities.getFileAsStream(fileNameUser);
257       } catch (AAtlantisException aae) {
258         // read the configuration file from atlantis distribution
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       //Get document parser instance
266       DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
267       factory.setValidating(true);
268       DocumentBuilder parser = factory.newDocumentBuilder();
269       parser.setErrorHandler(new AXMLErrorHandler());
270 
271       //Get the root node
272       Node rootNode = parser.parse(isConfig).getDocumentElement();
273 
274       // read the XML initialization node, and performs initialization
275       Node initializationNode = AXMLUtils.getChild(rootNode, "Initialization");
276 
277       // read colour map (colormap.xml) configuration -----------------
278       logger.info("Reading the colour map...");
279       updateStartupWindow(startupWin, "Reading Atlantis colour map");
280       AColorMap.readColorMap(Atlantis.colormapCommandLine);
281 
282       // creating canvas ----------------------------------------------
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       // reading parameters ------------------------------------------
290       logger.info("Building Parameters...");
291       new APar(AXMLUtils.getChild(rootNode, "Parameters")).update(
292               AXMLUtils.getChild(rootNode, "ParameterDifferences"));
293       // creating the Projections Manager (reading the projections)
294       Node interactionsNode =
295               AXMLUtils.getChild(initializationNode, "Interactions");
296       AProjectionsManager.initialise(interactionsNode);
297 
298       // reading  the geometry ----------------------------------------
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         // name of the geometry considered after underscore
306         geomName = "_" + geomName;
307 
308         // do the geometry files exist - just try loading the files
309         String geomNameFull1 = geomPrefix + "AGeometry" + geomName + ".xml";
310         String geomNameFull2 = geomPrefix + "AMuonGeometry" + geomName + ".xml";
311         try {
312           // just accessibility test
313           InputStream i = AUtilities.getFileAsStream(geomNameFull1);
314           i = AUtilities.getFileAsStream(geomNameFull2);
315           i = null;
316         } catch (AAtlantisException ae) {
317           geomName = ""; // will fall back to default geometry
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       // This is needed here, design should be changed to remove this problem
327       canvas.setCurrentWindow(canvas.getCurrentWindowName());
328       //Add the canvas as a NewEvent event listener
329       getEventManager().addNewEventListener(canvas);
330 
331       // reading the event --------------------------------------------
332 
333       updateStartupWindow(startupWin, "Reading event file");
334 
335       if (Atlantis.archiveName == null && Atlantis.serverName == null) {
336         // read default event from local file system
337         getDefaultEvent();
338       }
339 
340       logger.info("Atlantis Ready...");
341       updateStartupWindow(startupWin, "Atlantis Ready");
342 
343       // displaying GUI, Canvas ---------------------------------------
344       logger.info("Displaying GUI, Canvas...");
345       updateStartupWindow(startupWin, "Displaying Atlantis GUI and Canvas");
346       // update colors to those selected in the config file
347       AColorMap.setColorMap(APar.get("Prefs", "ColorMap").getI());
348       // NB: must calculate the size of GUI after calling
349       // canvas.setVisible(true), in which the real final size of Canvas
350       // will be calculated
351       canvas.setVisible(true);
352 
353       // Now the canvas is on the screen and have a size, check if we need
354       // to rework the aspect ratio on YX projections at all as is the case
355       // when going to control room projectors for example - AD
356       canvas.correctAspectRatios();
357       
358       //Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
359       //This will stretch the GUI over multiple displays
360       //Rather use the canvases graphics config
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           // both server name (-s) and timer delay (-p) were specified
382           // so create a server dialog
383           AReadEventFromServerDialog dialog =  AReadEventFromServerDialog.getInstance();
384           //set all properties
385           dialog.setServerName(getServerName());
386           dialog.setPortNumber(getServerPort());
387           dialog.setUpdateInterval(getLoopInterval());
388           dialog.showDialog();
389           dialog.startEventLoop();
390         } else {
391           // read a single event from the server
392           //Assemble the xmlrpc source string
393           String sourceName = "xmlrpc://" + getServerName() + ":" + getServerPort();
394           //set new event source and read first event
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             //be a bit verbose
402             logger.error("Unable to read event from server:");
403             logger.error(aes.getCauseMessges());
404             //If we fail, read default event instead
405             logger.info("Reading default event instead");
406             getDefaultEvent();
407           }
408         }
409       }
410 
411       if (Atlantis.archiveName != null) // loop an archive in demo mode
412       {
413         // NB: ADemoDialog need GUI to be present to initialize
414         // properly, so put here after GUI's construction
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       //If we have a history saver, add it now as new event listener
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   } // initAtlantis() -----------------------------------------------------
475 
476 
477     /**
478      * @return the event manager object
479      */
480     public static AEventManager getEventManager()
481     {
482         return eventManager;
483     }
484 
485     /**
486      * @return the detector system object
487      */
488     public static ADetectorSystem getDetector()
489     {
490         return detector;
491 
492     }
493 
494     /**
495      * Call from AReadGeometryChooser where the Atlantis geometry is changed
496      * on-the-fly
497      * @param currentDetector the dectector
498      */
499     public static void setDetector(ADetectorSystem currentDetector)
500     {
501         Atlantis.detector = currentDetector;
502 
503     } // setDetector() ------------------------------------------------------
504 
505 
506     /**
507      * Restore all the default configuration
508      */
509     public static void restoreDefaults()
510     {
511       //restore default parameters
512       APar.restoreDefaults();
513       //reset primary vertex in current event if there is one
514       if (getEventManager().getCurrentEvent() != null) {
515          getEventManager().getCurrentEvent().setPrimaryVertex();
516       }
517       //reset all list
518       AListManager.getInstance().reset();
519       //Finally refresh GUI and canvas
520       AGUI.refresh();
521       ACanvas.getCanvas().restoreDefaults();
522 
523     } // restoreDefaults() --------------------------------------------------
524 
525 
526     public static String getHomeDirectory()
527     {
528         // where was this class loaded from
529         String temp = Atlantis.class.getResource("Atlantis.class").getFile();
530         // remove "file:"
531         temp = temp.substring(5);
532         if(temp.indexOf("!") > -1)
533         {
534             // atlantis is in a .jar file
535             temp = temp.substring(0, temp.indexOf("!"));
536             temp = temp.replaceAll("%20", " ");
537             return temp.substring(0, temp.lastIndexOf('/') + 1);
538         }
539         // must be the current working directory of the user
540         return System.getProperty("user.dir") + fileSep;
541 
542     } // getHomeDirectory() -------------------------------------------------
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         // -o --overview - used for monitoring in the ACR - when reading xml
631         // from JiveXML server, save png canvas plot and xml event event
632         // date every N events into specified directory where history of 
633         // M length files is kept
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             // retrieve the argument for options
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                 // vals[0] - severity level
689                 // vals[1] - destination to write logs to
690                 try
691                 {
692                     ALogger.initialize(vals); // need to check vals
693                 }
694                 catch(Exception aa)
695                 {
696                     //aa.printStackTrace();
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                     // only valid with one window demo mode
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                 // retrieve the argument for options or assign default value
733                 Atlantis.colormapCommandLine = l.getOptionValue('m', null);
734             }
735             if (l.hasOption('s')) {
736               //Get the combined server name:port string
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               //Set server name if given
742               if (!((serverPortName[0]).equals("")))
743                 Atlantis.serverName = serverPortName[0];
744 
745               //Check if port number is given
746               if (serverPortName.length == 2) {
747                 if (!(serverPortName[1]).equals("")) {
748                   try {
749                     //Check wether this was an integer
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              * Loop intervall - currently only when reading from server
759              */
760             if (l.hasOption('p')) {
761               String s = l.getOptionValue('p', null);
762               // just check whether integer was supplied
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                 // vals[0] - directory to store events and png into
794                 // vals[1] - n - save every n events
795                 // vals[2] - m - keep m files in the directory
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         } // try
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     } // processCommandLineParameters() -------------------------------------
817 
818 
819     /**
820      * Read in the default event shipped with Atlantis
821      */
822     public static void getDefaultEvent()
823     {
824         //Get the file where the default event is stored
825         String eventPath;
826         
827         //Check if default event is set in command line options
828         if(Atlantis.defaultEventFile != null) {
829             eventPath = Atlantis.defaultEventFile;
830         } else {
831           //Otherwise set it to the current home
832           eventPath = Atlantis.getHomeDirectory() + "events" + Atlantis.fileSep +
833             "test_events.zip";
834         }
835         
836         //be verbose
837         logger.info("Reading the default event: " + eventPath);
838         //set the event source and read an event
839         try {
840           getEventManager().setEventSource(eventPath);
841           getEventManager().nextEvent();
842         } catch (InvalidEventSourceException ies){
843           //Write error message
844           String msg = "Can not access "+eventPath+": "+ies.getMessage();
845           logger.error(msg);
846           //Show error dialog
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           //Show error dialog
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           //Show error dialog
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         // CVS expands into $Name: AtlantisJava-09-11-11 $, we only want the tag name
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     }  // setCVSTagInfo() ---------------------------------------------------
878 
879 
880 
881     public static void main(String[] args)
882     {
883         processCommandLineParameters(args);
884         
885         // logger should be initialized from processCommandLineParameters()
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     } // main() -------------------------------------------------------------
903 
904 
905 } // Atlantis class =========================================================
906 

source navigation ] diff markup ] identifier search ] general search ]

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. Valid HTML 4.01!