⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 run.java

📁 petrinets小程序
💻 JAVA
字号:
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;


public class run extends JFrame{

//	public static pn PNet;
    public static Editor Ed;
    public static visOfReachabilityTree visTree;
    public static visOfReachabilityGraph visGraph;
//    public jpn IPN;
//  vis Vis;
    int StepCount;
    int mode;
    int vismode;
    int delay;
    boolean demo;
    boolean selected;
    boolean single;
    transition selectedTransition;

    static final int PARMAN = 0;
    static final int PARRAN = 1;
    static final int SEQMAN = 2;
    static final int SEQRAN = 3;
    static final int CODE = 99;
	
    private JTextField StatusLine, StatusMode, StatusDiv, StatusCount;
	
	private JPanel buttonPanel, showPanel;
	private JPanel panelOfDraw, buttonPanelOfDraw, panelOfDrawL, panelOfDrawR, panelOfDrawLabel;
	private JPanel panelOfReachabilityTree, panelOfReachabilityTreeB, panelOfReachabilityTreeR, panelOfReachabilityTreeLabel;
	private JPanel panelOfReachabilityGraph, panelOfReachabilityGraphB, panelOfReachabilityGraphR, panelOfReachabilityGraphLabel;
	private JButton updateReachabilityTree, updateReachabilityGraph;
	private JButton editInReachabilityTree, editInReachabilityGraph;
	
	private JButton drawButton, reachabilityTreeButton, reachabilityGraphButton;
	private JButton EditPnGraph, structureInReachabilityTree, structureInReachabilityGraph;
	

	
	public run(){
		
		super("Petri Net.iSco");
//		PNet = new pn();
		Ed = new Editor("The Petri - Net - Simulator.iSco", null);
		Dimension dimvis = new Dimension(1000,1000);
//		if(!PNet.equal(Ed.PNet, PNet))
//			PNet = new pn(Ed.PNet);
		Container container = getContentPane();
		container.setLayout( new BorderLayout() );
// big frame
		ButtonHandle handle = new ButtonHandle();
		drawButton = new JButton( "Structure" );
		drawButton.addActionListener(handle);
		reachabilityTreeButton = new JButton( "ShowReachabilityTree" );
		reachabilityTreeButton.addActionListener(handle);
		reachabilityGraphButton = new JButton( "ShowReachabilityGraph" );
		reachabilityGraphButton.addActionListener(handle);
		buttonPanel = new JPanel();
		buttonPanel.setLayout( new GridLayout( 1, 0 ) );
		buttonPanel.add(drawButton);
		buttonPanel.add(reachabilityTreeButton);
		buttonPanel.add(reachabilityGraphButton);
		container.add( buttonPanel, BorderLayout.NORTH );
		showPanel = new JPanel();
		showPanel.setLayout( new BorderLayout() );
		container.add(showPanel, BorderLayout.CENTER);
		
//
		StatusLine = new JTextField("Status", 10);
		StatusLine.setEditable(false);
		StatusMode = new JTextField("SeqRan", 10);
		StatusMode.setEditable(false);
		StatusDiv = new JTextField("Color", 10);
		StatusDiv.setEditable(false);
		StatusCount = new JTextField("StatusCount", 10);
		StatusCount.setEditable(false);
		
// draw pn frame
		panelOfDraw = new JPanel();
		panelOfDraw.setLayout(new BorderLayout());
		panelOfDraw.setVisible(true);
		buttonPanelOfDraw = new JPanel();
		buttonPanelOfDraw.setLayout( new BorderLayout() );
		EditPnGraph = new JButton( "Edit PN Graph" );
		EditPnGraph.addActionListener(new PnButtonHandle());
		panelOfDraw.add(EditPnGraph, BorderLayout.SOUTH);
		panelOfDrawR = new JPanel();
		panelOfDrawR.add(new visOfStructure());
		panelOfDrawLabel = new JPanel();
		panelOfDrawLabel.setLayout(new GridLayout(1,0));
		panelOfDrawLabel.add(new JLabel("  Structure"));
		panelOfDrawLabel.add(StatusLine);
		panelOfDrawLabel.add(StatusMode);
		panelOfDrawLabel.add(StatusDiv);
		panelOfDrawLabel.add(StatusCount);
		panelOfDraw.add(panelOfDrawR, BorderLayout.CENTER);
		panelOfDraw.add(panelOfDrawLabel, BorderLayout.NORTH);
		showPanel.add(panelOfDraw, BorderLayout.WEST);
				
// draw reachabilityTree frame
		visTree = new visOfReachabilityTree(this.Ed.PNet, dimvis);
		panelOfReachabilityTree = new JPanel();
		panelOfReachabilityTree.setLayout(new BorderLayout());
		panelOfReachabilityTree.setVisible(false);
		panelOfReachabilityTreeR = new JPanel();
		panelOfReachabilityTreeR.add(new JScrollPane(visTree));
		panelOfReachabilityTreeLabel = new JPanel();
		panelOfReachabilityTreeLabel.setLayout(new GridLayout(1,0));
		panelOfReachabilityTreeLabel.add(new JLabel("  ReachabilityTree"));
		panelOfReachabilityTree.add(panelOfReachabilityTreeR, BorderLayout.CENTER);
		panelOfReachabilityTree.add(panelOfReachabilityTreeLabel, BorderLayout.NORTH);
		showPanel.add(panelOfReachabilityTree, BorderLayout.CENTER);
		structureInReachabilityTree = new JButton("Structure");
		structureInReachabilityTree.addActionListener(new StButtonHandle());
		editInReachabilityTree = new JButton("Edit PN Graph");
		editInReachabilityTree.addActionListener(new PnButtonHandle());
		updateReachabilityTree = new JButton("updateReachabilityTree");
		updateReachabilityTree.addActionListener(new updateRTButtonHandle());
		
		panelOfReachabilityTreeB = new JPanel();
		panelOfReachabilityTreeB.setLayout(new GridLayout(0,3));
		panelOfReachabilityTreeB.add(structureInReachabilityTree);
		panelOfReachabilityTreeB.add(editInReachabilityTree);
		panelOfReachabilityTreeB.add(updateReachabilityTree);
		panelOfReachabilityTree.add(panelOfReachabilityTreeB, BorderLayout.SOUTH);
		
// draw reachabilityGraph frame		
		visGraph = new visOfReachabilityGraph(dimvis);
		panelOfReachabilityGraph = new JPanel();
		panelOfReachabilityGraph.setLayout(new BorderLayout());
		panelOfReachabilityGraph.setVisible(false);
		panelOfReachabilityGraphR = new JPanel();
		panelOfReachabilityGraphR.add(visGraph);
		panelOfReachabilityGraphLabel = new JPanel();
		panelOfReachabilityGraphLabel.setLayout(new BorderLayout());
		panelOfReachabilityGraphLabel.add(new JLabel("ReachabilityGraph  ", JLabel.LEFT), BorderLayout.EAST);
		panelOfReachabilityGraph.add(panelOfReachabilityGraphR, BorderLayout.CENTER);
		panelOfReachabilityGraph.add(panelOfReachabilityGraphLabel, BorderLayout.NORTH);
		showPanel.add(panelOfReachabilityGraph, BorderLayout.EAST);
		structureInReachabilityGraph = new JButton("Structure");
		structureInReachabilityGraph.addActionListener(new StButtonHandle());
		editInReachabilityGraph = new JButton("Edit PN Graph");
		editInReachabilityGraph.addActionListener(new PnButtonHandle());
		updateReachabilityGraph = new JButton("updateReachabilityGraph");
		updateReachabilityGraph.addActionListener(new updateRGButtonHandle());
		
		panelOfReachabilityGraphB = new JPanel();
		panelOfReachabilityGraphB.setLayout(new GridLayout(0,3));
		panelOfReachabilityGraphB.add(structureInReachabilityGraph);
		panelOfReachabilityGraphB.add(editInReachabilityGraph);
		panelOfReachabilityGraphB.add(updateReachabilityGraph);
		panelOfReachabilityGraph.add(panelOfReachabilityGraphB, BorderLayout.SOUTH);
		
		
		
		this.setSize(800, 600);
		this.setVisible( true );
		
	}
	
	public static void main(String[] args) {
		
		run application = new run();
		application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
		
	}
	
//
//
//
//
//
	
// Big frame buttons handle	
	public class ButtonHandle implements ActionListener{

		public void actionPerformed(ActionEvent event) {
			

			if( event.getActionCommand() == "Structure" ){
				panelOfDraw.setVisible(true);
				panelOfReachabilityTree.setVisible(false);
				panelOfReachabilityGraph.setVisible(false);
			}
			else if( event.getActionCommand() == "ShowReachabilityTree" ){
				panelOfDraw.setVisible(false);
				panelOfReachabilityTree.setVisible(true);
				panelOfReachabilityGraph.setVisible(false);
			}
			else if( event.getActionCommand() == "ShowReachabilityGraph" ){
				panelOfDraw.setVisible(false);
				panelOfReachabilityTree.setVisible(false);
				panelOfReachabilityGraph.setVisible(true);
			}
		}
	}
	
	public class PnButtonHandle implements ActionListener{

		public void actionPerformed(ActionEvent event) {
//			Ed = new Editor("jPNS - The Petri - Net - Simulator", null);
	        Ed.resize(800, 600);
	        Ed.show();
		}

	}
	
	public class StButtonHandle implements ActionListener{
		public void actionPerformed(ActionEvent event){
//			PNet = new pn(Ed.returnPNet());
			ShowStructure s = new ShowStructure(Ed);
			s.resize(800, 600);
			s.show();
		}
	}
	
	public class updateRTButtonHandle implements ActionListener{
		public void actionPerformed(ActionEvent event){
			Dimension dimvis = new Dimension(1000, 1000);
//			visTree = new visOfReachabilityTree(run.Ed.PNet, dimvis);
//			visTree.updateRT(Ed.PNet);
			visTree.runVictualRun = true;
			visTree.update(visTree.getGraphics());
//			ShowReachabilityTree s = new ShowReachabilityTree(Ed);
//			s.resize(800, 600);
//			s.show();
		}
	}
	
	public class updateRGButtonHandle implements ActionListener{
		public void actionPerformed(ActionEvent event){
			ShowReachabilityGraph s = new ShowReachabilityGraph(Ed);
			s.resize(800, 600);
			s.show();
		}
	}
	
	
	
	

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -