/* * Filename: ProteoWizard.java * * Author: Raf Van de Plas * * Contact: * Snail-mail: K.U.Leuven * ESAT-SCD * Kasteelpark Arenberg 10 * B-3001 Leuven-Heverlee * Belgium * Tel: +32 16 327927 * Fax: +32 16 321970 * Gsm: +32 474 243046 * E-mail: raf.vandeplas@esat.kuleuven.ac.be * WWW: http://www.esat.kuleuven.ac.be/~dna/BioI/ * * * Created on: Nov 25, 2003 * * Changed on: Nov 25, 2003 * * Version: 0.1 * * Description: * none * */ import javax.swing.*; //import javax.swing.filechooser.FileFilter; //import javax.swing.text.*; import java.awt.event.*; //import java.awt.color.*; import java.awt.*; //import java.util.*; //import java.io.*; //import java.text.*; import org.jgraph.*; //import org.relaxng.datatype.*; import javax.xml.bind.*; import pd.*; /** * @author rvdplas * * To change the template for this generated type comment go to * Window - Preferences - Java - Code Generation - Code and Comments */ public class ProteoWizard extends JFrame { // Listener for the various buttons, menu options, and controls private ProteoWizardListener proteoWizardListener = null; public ProteoWizard() { // Initializing the parent class (JFrame) super("ProteoWizard"); // Creating & Positioning all GUI controls this.initComponents(); } private void initComponents() { // Setting size of window Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); this.setSize(screenSize); /*this.setSize(640,480); this.setLocation(screenSize.width/2 - (640/2), screenSize.height/2 - (480/2));*/ // Adding a WindowListener to catch the closing of the window this.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); // Initialize the listener for the GUI controls proteoWizardListener = new ProteoWizardListener(this); // Creating the content JPanel contentPanel = new JPanel(); this.getContentPane().add(contentPanel); contentPanel.setLayout(new BorderLayout(10,10)); // // Creating a JGraph component // JGraph jg = new JGraph(); // jg.setBackground(Color.YELLOW); // jg.setGridColor(Color.BLUE); // jg.setGridMode(JGraph.LINE_GRID_MODE); // jg.setGridEnabled(true); // jg.setGridVisible(true); // jg.setEditable(true); // System.out.println(jg.getGraphLayoutCache().getModel().getRootCount()); // contentPanel.add(jg); // //Trying out some state-transition manipulations // System.out.println("**********************************"); // ValidatingJPanel vjp = new ValidatingJPanel(); // State s1 = new State(1220,"First State", vjp); // StateTransitionGraph graph = new StateTransitionGraph(); // graph.addState("State1",vjp); // graph.addState("State2",vjp); // graph.addState("State3",vjp); // graph.addState("State4",vjp); // graph.addState("State5",vjp); // graph.addState("State6",vjp); // // // try{ // graph.addTransitionViaIndex(1, 2, "OK", "next"); // graph.addTransition(graph.getStateAtIndex(1), graph.getStateAtIndex(2), "OK", "back"); // graph.addTransition(graph.getStateAtIndex(1).getId(), graph.getStateAtIndex(2).getId(), "OK", null); // graph.getTransitionsWithControllerMessage(null); // graph.getTransitionsWithControllerMessage("next"); // graph.getTransitionsWithFulfillmentMessage("OK"); // graph.getTransitionsWithSource(graph.getStateAtIndex(1)); // graph.getTransitionsWithTarget(graph.getStateAtIndex(1)); // graph.getTransitionsWithTarget(graph.getStateAtIndex(2)); // graph.removeTransition(graph.getTransition(graph.getStateAtIndex(1),graph.getStateAtIndex(2))); // graph.removeTransitions(graph.getTransitionsWithControllerMessage(null)); // } // catch(StateTransitionGraphException e) // { // System.out.println("An error occured while adding a transition!"); // } // System.out.println("**********************************"); //Trying out the Wizard controllers and panels // System.out.println("**********************************"); // contentPanel.setLayout(new BorderLayout()); // contentPanel.add(new WizardViewerJPanel(), BorderLayout.CENTER); // contentPanel.add(new ControlPanel(), BorderLayout.SOUTH); // System.out.println("**********************************"); System.out.println("****Creating a WizardPanelContainer"); WizardPanelContainer wizPanelContainer = new WizardPanelContainer(); System.out.println("****WizardPanelContainer created."); System.out.println("****Creating the FSM graph"); StateTransitionGraph graph = new StateTransitionGraph(); System.out.println("****FSM graph created."); System.out.println("****Creating the states and their companions"); WizardStatePanel state1Panel = new WizardStatePanel(); state1Panel.add(new JLabel("State 1")); WizardStateCompanion state1Comp = new WizardStateCompanion(wizPanelContainer, state1Panel); graph.addState("State 1", state1Comp); WizardStatePanel state2Panel = new WizardStatePanel(); state2Panel.add(new JLabel("State 2")); WizardStateCompanion state2Comp = new WizardStateCompanion(wizPanelContainer, state2Panel); graph.addState("State 2", state2Comp); WizardStatePanel state3Panel = new WizardStatePanel(); state3Panel.add(new JLabel("State 3")); WizardStateCompanion state3Comp = new WizardStateCompanion(wizPanelContainer, state3Panel); graph.addState("State 3", state3Comp); WizardStatePanel state4Panel = new WizardStatePanel(); state4Panel.add(new JLabel("State 4")); WizardStateCompanion state4Comp = new WizardStateCompanion(wizPanelContainer, state4Panel); graph.addState("State 4", state4Comp); WizardStatePanel state5Panel = new WizardStatePanel(); state5Panel.add(new JLabel("State 5")); WizardStateCompanion state5Comp = new WizardStateCompanion(wizPanelContainer, state5Panel); graph.addState("State 5", state5Comp); graph.setStartState("State 1"); graph.setEndState("State 5"); System.out.println("****States created."); System.out.println("****Creating the transitions"); try{ graph.addTransition("State 1", "State 2", "complete", "next"); graph.addTransition("State 2", "State 3", "complete", "next"); graph.addTransition("State 3", "State 5", "complete", "next"); graph.addTransition("State 2", "State 4", "incomplete", "next"); graph.addTransition("State 4", "State 5", "complete", "next"); } catch(StateTransitionGraphException e) { System.out.println("An error occured while adding a transition!"); } System.out.println("****Transitions created."); System.out.println("****Creating an STGModel"); STGModel stgModel = new STGModel(graph); System.out.println("****STGModel created."); System.out.println("****Creating an STGController"); STGController stgController = new STGController(stgModel); System.out.println("****STGController created."); // Show the window this.setVisible(true); } public static void main(String[] args) { new ProteoWizard(); //Unmarshal: // JAXBContext jc = JAXBContext.newInstance("jaxboutput.pd"); // Unmarshaller u = jc.createUnmarshaller(); // Experiment exper = (Experiment)u.unmarshal(new FileInputStream("exper.xml")); //zie verder hdst 11 p418 //Create Marshall Attempt: // try{ // System.out.println("Marshall TRY:\n"); // // JAXBContext jc = JAXBContext.newInstance("pd"); // ObjectFactory objFactory = new ObjectFactory(); // Experiment exper = objFactory.createExperiment(); // //Some other stuff to create a tree // Marshaller m = jc.createMarshaller(); // m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,Boolean.TRUE); // m.marshal(exper,System.out); // } // catch(JAXBException jaxbe){ // System.out.println("\nJAXBException!"); // } } } class ProteoWizardListener implements ActionListener { ProteoWizard proteoWizard; public ProteoWizardListener(ProteoWizard proteoWizard) { super(); this.proteoWizard = proteoWizard; } public void actionPerformed(ActionEvent e) { // if (e.getActionCommand().equals("open")) // { // //System.out.println("OPEN pressed."); // this.restore.open(); // } // else if (e.getActionCommand().equals("exit")) // { // //System.out.println("EXIT pressed."); // this.restore.exit(); // } // else if (e.getActionCommand().equals("step")) // { // //System.out.println("STEP pressed."); // this.restore.step(); // } // else if (e.getActionCommand().equals("play")) // { // //System.out.println("PLAY pressed."); // this.restore.play(); // } // else if (e.getActionCommand().equals("pause")) // { // //System.out.println("PAUSE pressed."); // this.restore.pause(); // } // else if (e.getActionCommand().equals("stop")) // { // //System.out.println("STOP pressed."); // this.restore.stop(); // } // else if (e.getActionCommand().equals("about")) // { // //System.out.println("ABOUT Pressed."); // this.restore.about(); // } // else if (e.getActionCommand().equals("saveMessages")) // { // //System.out.println("SAVE MESSAGES Pressed."); // this.restore.saveMessageLog(); // } // else if (e.getActionCommand().equals("clearMessages")) // { // //System.out.println("CLEAR MESSAGES Pressed."); // this.restore.clearMessageLog(); // } // else if (e.getActionCommand().equals("fitDisplay")) // { // //System.out.println("FIT DISPLAY Pressed."); // this.restore.fitDisplay(); // } // else if (e.getActionCommand().equals("labelDisplay")) // { // //System.out.println("LABEL DISPLAY Pressed."); // this.restore.labelDisplay(); // } ///* else if (e.getActionCommand().equals("createScene")) // { // this.restore.createScene(); // System.out.println("Create Scene pressed."); // } // else if (e.getActionCommand().equals("createSimilarityMatrices")) // { // this.restore.createSimilarityMatrices(); // System.out.println("Create Similarity Matrices pressed."); // } // else if (e.getActionCommand().equals("createMatchingMatrices")) // { // this.restore.createMatchingMatrices(); // System.out.println("Create Matching Matrices pressed."); // } // else if (e.getActionCommand().equals("getBestFit")) // { // this.restore.getBestFit(); // System.out.println("Get Best Fit pressed."); // }*/ } } class SplashWindow extends JWindow { public SplashWindow(String filename, Frame frame, int waitTime) { super(frame); JLabel label = new JLabel(new ImageIcon(filename)); this.getContentPane().add(label, BorderLayout.CENTER); this.pack(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension labelSize = label.getPreferredSize(); this.setLocation(screenSize.width/2 - (labelSize.width/2), screenSize.height/2 - (labelSize.height/2)); this.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { setVisible(false); dispose(); } }); final int pause = waitTime; final Runnable closerRunner = new Runnable() { public void run() { setVisible(false); dispose(); } }; Runnable waitRunner = new Runnable() { public void run() { try { Thread.sleep(pause); SwingUtilities.invokeAndWait(closerRunner); } catch(Exception e) { e.printStackTrace(); // can catch InvocationTargetException // can catch InterruptedException } } }; this.setVisible(true); Thread splashThread = new Thread(waitRunner, "SplashThread"); splashThread.start(); } }