/*
* Title: japlot.jaxodraw
* Description: Graphical user interface for drawing Feynman diagrams
* @author Daniele Binosi
* @author Lukas Theussl
* @author Sergei Chekanov
Copyright (C) 2003-2006, Daniele Binosi and Lukas Theussl
See the file LICENSE in the source distribution home directory
for a full copy of the GPL (GNU General Public License).
This file is part of japlot.jaxodraw.
japlot.jaxodraw is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
japlot.jaxodraw is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package japlot.jaxodraw;
import japlot.Global;
import java.util.ArrayList;
import java.awt.*;
import jhplot.jadraw.JaAxes;
import jhplot.jadraw.JaObject;
/** The main class of the japlot.jaxodraw program. */
public class JaxoDraw {
private static java.util.ResourceBundle language;
private ArrayList list;
private JaxoMainPanel feyn;
// this version of japlot.jaxodraw
/** The version number of this release of japlot.jaxodraw. */
public static final String VERSION_NUMBER = "1.0";
/** The current version of japlot.jaxodraw. */
public static final String VERSION = "japlot.jaxodraw-" + VERSION_NUMBER;
/** The japlot.jaxodraw web site. */
public static final String WEB_SITE = "http://jaxodraw.sourceforge.net";
// System properties
/** The current user. */
public static final String USER_NAME = System.getProperty("user.name");
/** The current user's home directory. */
public static final String USER_HOME = System.getProperty("user.home");
/** The name of the current operating system. */
public static final String OS_NAME = System.getProperty("os.name");
/** The architecture of the current operating system. */
public static final String OS_ARCH = System.getProperty("os.arch");
/** The version of the current operating system. */
public static final String OS_VERSION = System.getProperty("os.version");
/** The current Java version. */
public static final String JAVA_VERSION =
System.getProperty("java.version");
/** The current Java runtime version. */
public static final String JAVA_RUNTIME_VERSION =
System.getProperty("java.runtime.version");
/** The directory where Java is installed on the current machine. */
public static final String JAVA_HOME = System.getProperty("java.home");
/** The current Java class path. */
public static final String JAVA_CLASSPATH =
System.getProperty("java.class.path");
/** The file where user-selected preferences will be stored. */
public static final String PREFS_FILENAME = ".Jaxorc";
/** The current directory. */
private static String curDIR = "";
protected int N1final; // final
protected int N2final;
// main class to call
public JaxoDraw(String inputFile ) {
/*
language =
java.util.ResourceBundle.getBundle(JaxoPrefs.getPref(
JaxoPrefs.PREF_LANGUAGE));
getUserDir();
// Preferences are read first so that command line arguments
getPreferences();
// this is the main program
Global.init();
list = new ArrayList();
feyn = new JaxoMainPanel();
// draw axes first
JaAxes axes = new JaAxes(0,0);
axes.setLocation(0.1,0.1,"NDC");
axes.setRelWH(0.85,0.85,"NDC");
axes.setColor(Color.black);
axes.setFillColor(Color.white);
axes.setStroke(2.0f);
this.add(axes);
JaxoGraph firstGraph = new JaxoGraph(list);
feyn.init(inputFile,firstGraph);
feyn.setTitle(VERSION);
feyn.pack();
feyn.setDefaultCloseOperation(javax.swing.JFrame.DO_NOTHING_ON_CLOSE);
feyn.setVisible(true);
Global.sizeX=feyn.getSizeX();
Global.sizeY=feyn.getSizeY();
if (!JaxoPrefs.getBooleanPref(JaxoPrefs.PREF_GRIDONOFF)) {
feyn.gridOn(false);
}
*/
}
public JaxoDraw() {
this(null);
}
public void add(JaObject ob) {
ob.updateCoor();
list.add(ob);
}
public void clear() {
list.clear();
JaxoGraph firstGraph = new JaxoGraph(list);
feyn.setGraph(firstGraph);
}
public void update() {
JaxoGraph firstGraph = new JaxoGraph(list);
feyn.setGraph(firstGraph);
feyn.repaintCanvas();
}
/////////////////////////
/** The main method of japlot.jaxodraw: determines system properties,
* preferences and command line arguments,
* before bringing up the graphical user interface.
* @param args The array of command line arguments.
*/
public static void main(String[] args) {
String inputFile = getCommandLineArgs(args);
// System.out.println(inputFile);
JaxoDraw jd = new JaxoDraw(inputFile);
/*
JaFLine temp= new JaFLine();
temp.setLocation(0.2, 0.3);
temp.setColor(Color.red);
temp.setRelWH(0.3,0.4);
temp.setStroke(2.0f);
jd.add(temp);
jd.update();
*/
// System.out.println(jd.getSizeX());
// System.out.println(jd.getSizeY());
}
/** Checks whether preferences have been saved from an earlier session
* and if yes, imports them.
*/
public static void getPreferences() {
String prefFileName =
USER_HOME + java.io.File.separator + PREFS_FILENAME;
java.io.File prefFile = new java.io.File(prefFileName);
if (prefFile.exists()) {
JaxoPrefs.importPrefs(prefFileName);
}
}
/** get X size */
public int getSizeX() {
return feyn.getSizeX();
}
/** get Y size */
public int getSizeY() {
return feyn.getSizeY();
}
/** Processes the command line arguments.
* @param args The array of command line parameters
* as passed from the main method.
* @return The file name of an input file to be opened.
*/
private static String getCommandLineArgs(String[] args) {
String inputFile = "";
int nofJax = 0;
if (args.length > 0) {
if (args[0].startsWith("--")) {
if (args[0].equals("--version")) {
System.out.println(VERSION);
} else if (args[0].equals("--info")) {
info();
} else if (args[0].equals("--help")) {
help();
} else {
System.out.println(language.getString("Unknown_option:")
+ args[0]);
}
shutdown(0);
} else {
for (int i = 0; i < args.length; i++) {
if (args[i].endsWith(".xml")) {
System.out.println(language.getString("Reading_file")
+ args[i]);
inputFile = args[i];
if (nofJax > 0) {
System.out.println(language.getString(
"Warning:_You_can_only_read_one_input_file!"));
}
nofJax++;
} else if (args[i].equals("-verbose")) {
JaxoPrefs.setVerbose(true);
} else if (args[i].equals("-quiet")) {
JaxoPrefs.setVerbose(false);
} else {
System.out.println(language.getString(
"Unknown_option:") + args[i]);
}
}
}
}
return inputFile;
}
/** Returns the current working directory.
* @return The current working directory.
*/
public static String getCurDir() {
return curDIR;
}
/** Sets the current working directory.
* @param newDir The new working directory.
*/
public static void setCurDir(String newDir) {
curDIR = newDir;
}
/** Calls System.exit(status).
* @param status The exit status code.
*/
public static void shutdown(int status) {
System.exit(status);
}
/** Determines the user's home directory from system properties. */
private static void getUserDir() {
try {
curDIR = System.getProperty("user.dir");
} catch (SecurityException aSecurityException) {
javax.swing.JOptionPane.showMessageDialog(null,
language.getString(
"SecurityException:_Cannot_get_system_properties!"));
System.err.println(aSecurityException);
}
}
/** Help message. */
private static void help() {
System.out.println(language.getString("Start_the_program_with:")
+ language.getString("jaxodraw_[options]")
+ language.getString("and_check_the_User_Guide_in_the_Help_menu.")
+ language.getString("Command_line_options:")
+ language.getString(
"--version__prints_out_the_version_number_of_JaxoDraw")
+ language.getString("--help_____prints_out_this_help")
+ language.getString(
"--info_____prints_out_some_information_about_your_system")
+ language.getString(
"_-verbose__turns_on_verbose_error_messaging_(default_in_the_current_version)")
+ language.getString(
"_-quiet____turns_off_verbose_error_messaging"));
}
/** Info message. */
private static void info() {
System.out.println(language.getString("OS_name:") + OS_NAME + "\n"
+ language.getString("OS_architecture:") + OS_ARCH + "\n"
+ language.getString("OS_version:") + OS_VERSION + "\n"
+ language.getString("Java_version:") + JAVA_VERSION + "\n"
+ language.getString("Java_runtime_version:")
+ JAVA_RUNTIME_VERSION + "\n"
+ language.getString("Java_home_directory:") + JAVA_HOME + "\n"
+ language.getString("Java_class_path:") + JAVA_CLASSPATH);
}
public void setRangeX(double min, double max) {
// TODO Auto-generated method stub
}
public void setRangeY(double min, double max) {
// TODO Auto-generated method stub
}
}
Ads help maintain this website.