/********************************************************************** Tool: Augmented Petrinet for distributed behavioral requirements modelling and simulation Authors: Harini Kalahasti Jayashree Mekala Sangeet Gupta Minqi Li Padma Ravindranathan DanDan Wang. Naveen K Yeddula Last modified on: 5/25/98. ************************************************************************/ // Here this file imports the Abstract Windowing Toolkit from the java library import java.awt.*; import java.applet.*; import java.lang.String; //Harini included import java.util.StringTokenizer ; //import Transition; //SILLY JAVA --rw---------- // petrinet1 class which extends itself as a subclass of the applet in // the graphics class public class petrinet1 extends java.applet.Applet implements Runnable{ /* applet's dimensions */ final static int DIMENSION = 750; /* height of the button control area */ final static int CONTROL_HEIGHT = 500; //*---------Cindy's code-------------*/ Frame frame1; Frame frame2; BaseFrame31 win; GraphCanvas graphcanvas = new GraphCanvas(this); GraphCanvas graphcanvas1 = new GraphCanvas(this, graphcanvas); GraphCanvas graphcanvas2 = new GraphCanvas(this, graphcanvas); Documentation documentation = new Documentation(); Documentation documentation1 = new Documentation(); Documentation documentation2 = new Documentation(); public void init() { petrinet1 g = new petrinet1(); Frame frame1 = new MenuFrame("Petrinet CASE Tool User1",graphcanvas1); Frame frame2 = new MenuFrame("Petrinet CASE Tool User2",graphcanvas2); BaseFrame31 win=new BaseFrame31(" Instrucion Window"); setLayout(new BorderLayout(2, 2)); add("North",new Button("Turbo Power Ranger")); add("Center", graphcanvas); add("South", documentation); frame1.add("Center", graphcanvas1); frame2.add("Center", graphcanvas2); frame1.add("South", documentation1); frame2.add("South", documentation2); frame1.resize(DIMENSION,CONTROL_HEIGHT); frame2.resize(DIMENSION,CONTROL_HEIGHT); win.resize(350, 175); frame1.show(); frame2.show(); win.show(); //-------------------------------------------/ } public Insets insets() { // return new Insets(10, 10, 10, 10); return new Insets(1, 1, 1, 1); } public void lock() { graphcanvas.lock(); //options.lock(); } public void unlock() { graphcanvas.unlock(); //options.unlock(); } public void run(){ } public boolean action(Event evt,Object arg) { if(arg.equals("Turbo Power Ranger")) {BaseFrame31 win=new BaseFrame31(" Instrucion Window"); win.resize(350, 175); win.show(); return true; } else return false; } } // end petrinet1 class MenuFrame extends Frame { // set of options at the top of the screen // from Quan's NFR-Assistant private Menu file_menu, place_menu, transition_menu, token_menu, condition_menu, simulate_menu, edit_menu, help_menu,f; private MenuBar menu_bar; private Display pad; private Panel main_panel; private GridBagLayout gridbag = new GridBagLayout(); public GraphCanvas gc ; public static DialogTest f1; petrinet1 parent; boolean Locked=false; MenuFrame(String title, GraphCanvas graphcanvas) { super(title); gc = graphcanvas ; file_menu = new Menu("File"); file_menu.add (new MenuItem("Clear")); file_menu.add (new MenuItem("Load")); file_menu.add (new MenuItem("Save")); file_menu.add (new MenuItem("Print")); file_menu.add (new MenuItem("Quit")); place_menu = new Menu("Place"); place_menu.add (new MenuItem("Add place")); place_menu.add (new MenuItem("Delete place")); transition_menu = new Menu("Transition"); transition_menu.add (new MenuItem("Add transition")); transition_menu.add (new MenuItem("Delete transition")); transition_menu.add (new MenuItem("Fire transition")); token_menu = new Menu("Token"); token_menu.add (new MenuItem("Add token")); token_menu.add (new MenuItem("Delete token")); condition_menu = new Menu("Condition"); condition_menu.add (new MenuItem("Add Condition")); condition_menu.add (new MenuItem("Delete Condition")); simulate_menu = new Menu("Simulate"); simulate_menu.add (new MenuItem("Arrival interval")); simulate_menu.add (new MenuItem("Firing delay")); simulate_menu.add (new MenuItem("Weight")); /* ------------------- code by Harini & Jayashree--------------------- */ simulate_menu.addSeparator(); // simulate_menu.add(f = new Menu("Options")); f = new Menu("Options"); f.add(new MenuItem("No transition Delay")); f.add(new MenuItem("All transitions - Same Delay")); f.add(new MenuItem("Some transitions - Same Delay")); f.add(new MenuItem("All transitions - Different Delay")); f.add(new MenuItem("Start Cyclic Checking")); simulate_menu.add(f); /* --------------------------------------------------------- */ edit_menu = new Menu("Edit"); edit_menu.add (new MenuItem("Drag")); edit_menu.add (new MenuItem("Move")); edit_menu.add (new MenuItem("Scale")); edit_menu.add (new MenuItem("Font")); edit_menu.add (new MenuItem("Add Link")); edit_menu.add (new MenuItem("Delete Link")); help_menu = new Menu("Help"); help_menu.add (new MenuItem("Glossary")); help_menu.add (new MenuItem("Tutorial")); help_menu.add (new MenuItem("About")); menu_bar = new MenuBar(); menu_bar.add (file_menu); menu_bar.add (place_menu); menu_bar.add (transition_menu); menu_bar.add (token_menu); menu_bar.add (condition_menu); menu_bar.add (simulate_menu); menu_bar.add (edit_menu); menu_bar.add (help_menu); this.setMenuBar (menu_bar); } // end of Display frame constructor //---------------------------------------CJ's Code-----------------// FileDialog openFile = new FileDialog(this,"Open Your Petrinet File",FileDialog.LOAD); FileDialog saveFile = new FileDialog(this,"Save Your Petrinet File As",FileDialog.SAVE); Toolkit toolkit = this.getToolkit( ); public boolean handleEvent(Event event){ if(event.id==Event.WINDOW_DESTROY){ dispose(); return true; } else if(event.id==Event.ACTION_EVENT){ if (event.target instanceof MenuItem){ if("New".equals(event.arg)){ return true; }else if("Load".equals(event.arg)){ openFile.show(); // String inFile=openFile.getFile(); //readFile(inFile); return true; }else if("Save".equals(event.arg)){ saveFile.show(); //String outFile=saveFile.getFile(); //writeFile(outFile); return true; }else if("Print".equals(event.arg)){ PrintJob pjob = toolkit.getPrintJob(this,"Print",null); return true; }else if("Quit".equals(event.arg)){ dispose(); return true; }else if("Tutorial".equals(event.arg)){ BaseFrame31 win=new BaseFrame31(" Instrucion Window"); win.resize(375, 170); win.show(); return true;} } } return false; } //----------------------------------------------------------------------// public void lock() { Locked=true; } public void unlock() { Locked=false; } /* ----------------------- code by Harini Jayashree------------------------ */ public boolean action(Event evt, Object arg) { if(evt.target instanceof MenuItem) { if(arg.equals("No transition Delay")) System.out.println("No transition Delay"); else if(arg.equals("All transitions - Same Delay")) { System.out.println("All transitions - Same Delay"); f1 = new DialogTest("All transitions - Same Delay",1); f1.resize(400,300); f1.show(); } else if(arg.equals("Some transitions - Same Delay")) { System.out.println("Some transitions - Same Delay"); f1 = new DialogTest("Some transitions - Same Delay",2); f1.resize(400,300); f1.show(); } else if(arg.equals("All transitions - Different Delay")) { System.out.println("All transitions - Different Delay"); f1 = new DialogTest("All transitions - Different Delay",3); f1.resize(400,300); f1.show(); } if(arg.equals("Start Cyclic Checking")) { newDialog nd = new newDialog("Enter the number of iterations",gc); nd.resize(400,300); nd.show( ); } return true; } return false; } /* ------------------------------------------------------------ */ } class Documentation extends Panel { // Documentation on top of the screen DocOptions docopt = new DocOptions(this); DocText doctext = new DocText(); Documentation() { setLayout(new BorderLayout(1, 1)); add("West", docopt); add("Center", doctext); } } class DocOptions extends Panel { Choice doc = new Choice(); Documentation parent; DocOptions(Documentation myparent) { // setLayout(new GridLayout(2, 1, 5, 0)); setLayout(new GridLayout(0, 2)); parent = myparent; Label l = new Label ("Instruction:", Label . LEFT); //Label l = new Label ("Instruction:", Label . CENTER); l.setForeground (Color . red); l.setFont (new Font ("Helvetica", Font . BOLD, 10)); add(l); doc.addItem("Add Place"); doc.addItem("Del Place"); doc.addItem("Add Transition"); doc.addItem("Del Transition"); doc.addItem("Add Token"); doc.addItem("Fire Transition"); doc.addItem("Clear"); doc.addItem("run algorithm"); doc.addItem("step through"); doc.addItem("example"); doc.addItem("exit"); doc.addItem("all items"); doc.addItem("Add Condition"); add(doc); } public boolean action(Event evt, Object arg) { if (evt.target instanceof Choice) { String str=new String(doc.getSelectedItem()); parent.doctext.showline(str); } return true; } } class DocText extends TextArea { final String addPlace = new String("Add Place:\n"+ "Draw a place by clicking the mouse.\n\n"); final String delPlace = new String("Delete Place:\n"+ "To delete a place press and click on the place.\n"); final String addTransition = new String("Add Transition:\n"+ "To add a transition click mouse on a place,"+ "and drag it to another place.\n\n"); final String delTransition = new String("Delete Transition:\n"+ "To remove a transition, change its weight to 0.\n\n"); final String fireTransition=new String("Fire Transition:\n"+ "Currently, you can click on the destination place to fire the in-coming" +"transition(s).\n\n"); final String addToken = new String("Add Token\n"+ "To add a token keep the mouse moving on the place\n"+ "with out clicking it on the place, press button\n"); final String startNode = new String("Start Node:\n"+ "The startNode is blue, other places are grey."+ "The first place you draw on the screen will be the startNode.\n"+ "To select another startNode press , click on the startNode, "+ "and drag the mouse to another place.\n"+ "To delete the startNode, first select another startNode, and then"+ "remove the place the usual way.\n"); final String clrReset = new String(" BUTTON: "+ "This Button has to remove the current petrinet from the screen\n"+ "but its current functionality is only removing lines\n"+ "and transitions from the screen\n"); final String runalg = new String(" BUTTON: "+ "Run the algorithm on the graph, there will be a time\n" + "delay of +/- 1 second between steps.\n"+ "To run the algorithm slower, use .\n"); final String step = new String(" BUTTON: " + "An opportunity to step through the algorithm.\n"); final String example = new String(" BUTTON: "+ "Displays a graph on the screen for you.\n"+ "If wanted, the graph can be edited before you "+ " or through the animation of the algorithm.\n"); final String exitbutton = new String(" BUTTON: " + "Only works if applet is run with appletviewer.\n"); final String toclose = new String("ERROR: "+ "This position is too close to another place/transition.\n"); final String done = new String("Algorithm has finished, " + "follow orange transitions from startNode to any place "+ "to get\nthe shortest path to " + "the place. The length of the path is written in the place.\n" + "press to reset the graph, and unlock the screen."); final String some = new String("Algorithm has finished, " + "follow orange transitions from startNode to any place "+ "to get\nthe shortest path to " + "the place. The length of the path is written in the place.\n" + "There are no paths from the startNode to any gray place.\n" + "press to reset the graph, and unlock the screen."); final String none = new String("Algorithm has finished, " + "there are no places reachable from the start place.\n"+ "press to reset the graph, and unlock the screen."); final String maxplaces = new String("ERROR: "+ "Maximum number of places reached!\n\n"); final String info = new String("You can scroll through the documentation or get documentation\n"+ "on a specific "+ "item by selecting the item on the left.\nSelecting "+ "brings you back "+ " to the scrolling text.\n\n"); final String addCondition = new String("Add Condition:\n" + "To add Condition Press and any key. \n\n"); final String locked = new String("ERROR: "+ "Keyboard/mouse locked for this action.\n"+ "Either press or .\n"); final String doc = info; final String docAll = info + addPlace + delPlace + addToken + startNode + addTransition + fireTransition + delTransition + clrReset + runalg + step + example + exitbutton; DocText() { //super(5, 2); //super(3, 2); super(2, 2); setText(doc); setBackground(Color.green); setForeground(Color.red); } public void showline(String str) { if (str.equals("Add Place")) setText(addPlace); else if (str.equals("Del Place")) setText(delPlace); else if (str.equals("Add Transition")) setText(addTransition); else if (str.equals("Del Transition")) setText(delTransition); else if (str.equals("Add Token")) setText(addToken); else if (str.equals("Fire Transition")) setText(fireTransition); else if (str.equals("Start Node")) setText(startNode); else if (str.equals("Clear")) setText(clrReset); else if (str.equals("run algorith")) setText(runalg); else if (str.equals("step throug")) setText(step); else if (str.equals("exampl")) setText(example); else if (str.equals("exit")) setText(exitbutton); else if (str.equals("all items")) setText(docAll); else if (str.equals("toclose")) setText(toclose); else if (str.equals("done")) setText(done); else if (str.equals("locked")) setText(locked); else if (str.equals("maxplaces")) setText(maxplaces); else if (str.equals("none")) setText(none); else if (str.equals("some")) setText(some); else if (str.equals("Add Condition")) setText(addCondition); else setText(str); } } /* ----------------------- Code by Harini & Jayashree ------------------- */ class random_delay { final double MAXINT = 123456; public double delay(double meanvalue) { double d; d = Math.random()/MAXINT ; d = -Math.log(d)/meanvalue ; return(d); } } /* ------------------------------------------------------ */ class fireTransition { double slope; int endX, endY, startX, startY; //a, b, c, d; double distance, dx, dy; double l=20; int step; Canvas canvas; Graphics g; Arc arc; //GraphCanvas graphCanvas = new GraphCanvas(); boolean painting=false; GraphCanvas c; fireTransition(Canvas canvas, int endX, int endY, int startX, int startY, Arc arc, GraphCanvas g) { c =g; this.canvas = canvas; this.endX = endX; this.endY = endY; this.startX = startX; this.startY = startY; this.g = canvas.getGraphics(); this.arc = arc; slope = Math.atan((double)(endY - startY)/(endX - startX)); step=1; distance=Math.sqrt((endY - startY) * (endY - startY) + (endX - startX) * (endX - startX)); this.l = this.distance/10; if (startX < endX && startY > endY) slope = slope + 3.14159; else if (startX < endX && startY < endY) slope = slope - 3.14159; dx = -l * Math.cos(slope); dy = -l * Math.sin(slope); }//end constructor. fireTransition(Canvas canvas, int endX, int endY, int startX, int startY, Arc arc) { this.canvas = canvas; this.endX = endX; this.endY = endY; this.startX = startX; this.startY = startY; this.g = canvas.getGraphics(); this.arc = arc; slope = Math.atan((double)(endY - startY)/(endX - startX)); step=1; distance=Math.sqrt((endY - startY) * (endY - startY) + (endX - startX) * (endX - startX)); this.l = this.distance/10; //calculate the sign of dx and dy if (startX < endX && startY > endY) slope = slope + 3.14159; else if (startX < endX && startY < endY) slope = slope - 3.14159; dx = -l * Math.cos(slope); dy = -l * Math.sin(slope); }//end constructor. //paintings: //public void artist(Canvas canvas)//, int a, int b, int c, int d) public void artist(GraphCanvas canvas,int transno)//, int a, int b, int c, int d) { int xp, yp; //store the previous position int xc, yc; //store the center token position xc = startX + step/21 * (int)dx - Place.radius/10; yc = startY + step/21 * (int)dy - Place.radius/10; {// draw the first token: //**Mei and Pi*** g.setColor(Color.black); g.drawRect(265,35,200,30); //**Mei and Pi*** g.setColor(Color.red); g.fillOval(xc, yc, Place.radius/5, Place.radius/5); g.setColor(Color.white); g.drawOval(xc, yc, Place.radius/5, Place.radius/5); xp = startX; yp = startY; DialogTest d1 = new DialogTest("",0); // for(int i=0;i<20;++i) // System.out.println("~~~"+d1.delay_value[i]); canvas.repaint(); System.out.println("The value of transition"+transno); try { Thread.sleep((long)(d1.delay_value[transno])); } //try { Thread.sleep(40); } //try { Thread.sleep(100); } catch (InterruptedException e) {} step++; } Color bg = canvas.getBackground(); // draw the following circle and hide the previous circle while (step/21 * l < distance) //while (step*l| ---->o" + outPlace.id, 1500);} lock(); inPlace.token=false; Arc arc3= arcList.givenPlaceAndTransition(inPlace, cyclicTransition); fireTransition cyclic1=new fireTransition(this, cyclicTransition.x, cyclicTransition.y,inPlace.x,inPlace.y,arc3); if(tracing){Trace("fireTransition done", 5000);} cyclic1.artist(this,(cyclicTransition.id.charAt(1)-'0')); if(tracing){Trace("artist done", 5000);} Arc arc4=arcList.givenPlaceAndTransition(outPlace, cyclicTransition); fireTransition cyclic2=new fireTransition(this, outPlace.x, outPlace.y, cyclicTransition.x,cyclicTransition.y,arc4); if(tracing){Trace("fireTransition done", 5000);} cyclic2.artist(this,(cyclicTransition.id.charAt(1)-'0')); if(tracing){Trace("artist done", 5000);} outPlace.token=true; PutDot=true; cyclic2.g.setColor(Color.red); cyclic2.g.fillOval(outPlace.x- (Place.radius/10), outPlace.y- (Place.radius/10),Place.radius/5,Place.radius/5); cyclic2.g.setColor(Color.white); cyclic2.g.drawOval(outPlace.x-(Place.radius/10), outPlace.y-(Place.radius/10), Place.radius/5, Place.radius/5); repaint(); child.repaint(); ptrPc2=ptrPc2.getNext(); if(ptrPc2==null) break; outPlace=(Place)ptrPc2.getPlace(); if(tracing) {Trace("outPlace.id=" + outPlace.id, 1500);} unlock(); }//end of while(start.........) }//end of if(condition) ptrT=ptrT.getNext(); //ucondition = CheckUserInput(cyclicTransition.id); System.out.println("The value of ucondition " + ucondition); if(ptrT==null && iterations>0) { ptrT=transitionList.root; iterations--; System.out.println("the value of count = " + iterations); } else if(iterations <= 0) break; cyclicTransition=(Transition)ptrT.getTransition(); ptrC = ptrC.getNext(); if(ptrC == null) ptrC = UI.g.conditionList.root ; C = (Condition)ptrC.getCondition(); System.out.println("TransName2"+ C.transitionname ); if(tracing) {Trace("Transition fired", 1500);} //if (Uppressed) //break; }//end of while(1) } // metho for mouseDown event. public boolean mouseDown(Event evt, int x, int y) { // OLD: // 1 2 3 4 5 6 7 8 // ControlDown T T T T F F F F // shiftDown T T F F T T F F // enclosed T F T F T F T F // ----------------------------------------------------------------------- // ? ? dP ? dToken ? aT aP // aT Place enclosingPlace; sessionStart = true; lastPoint = new Point(x, y); if (tracing) { Trace("mouseDown", 10000); Trace("\n" + String.valueOf(x) + "," + String.valueOf(y) + "," + String.valueOf(Place.radius), 1000); } //if (placeList.root == null) {enclosingPlace = null;} // enclosingPlace = Place.placeList.checkIfInCircle(x, y, Place.radius); //else //{ enclosingPlace = (Place)placeList.checkIfInCircle(x, y, Place.radius); if (tracing) { Trace("\n\n\n enclosingPlace computed", 1000); if (enclosingPlace == null) {Trace("\n NULL PLACE", 1000);} else // if (enclosingPlace != null) {Trace("\n NOT NULL PLACE", 1000);} } if (evt.controlDown()) { if (tracing) {Trace("CONTROL DOWN", 1000);} if (enclosingPlace != null) { if (tracing) {Trace("DEL PLACE", 1000);} DeleteCircle(enclosingPlace); } else {Trace("controlDown & clicking nowhere NOT SUPPORTED", 1000);} } else // (!evt.controlDown) { if (tracing) { Trace("NO CONTROL DOWN", 1000); } if (evt.shiftDown()) // && (!evt.controlDown()) { if (enclosingPlace != null) { if (tracing) {Trace("DEL TOKEN", 1000);} //Place.placeList.DeleteToken(x,y,Place.radius); placeList.DeleteToken(x, y, Place.radius); child.placeList.DeleteToken(x, y, Place.radius); //System.out.println(" Token Deleted"); //Place.placeList.print(); placeList.print(); repaint(); child.repaint(); } else {Trace("shiftDown & clicking nowhere NOT SUPPORTED", 1000);} } else // (!evt.controlDown() && !evt.shiftDown()) { if (tracing) { Trace("\nNEITHER CONTROL NOR SHIFT DOWN", 1000);} if (enclosingPlace != null) { // draw a new transition if (!newEdge) { newEdge = true; newEdgeFromPlace = true; //thisPoint = new Point(x, y); //start= Place.placeList.checkIfInCircle(x, y, Place.radius); start = (Place)placeList.checkIfInCircle(x, y, Place.radius); if (tracing) { Trace("NEW TRAN " + " FROM " + start.id + ", OR A TOKEN", 1000); } } else {Trace("EXCEPTION", 1000);} } else // (!evt.shiftDown() && // !evt.shiftDown() && // (enclosingPlace == null)) { if (tracing) { Trace("\nCOMPUTE TRAN ", 1000); } //Echo echo = new Echo(parent.frame, "echo", "ANY TRANSITION?"); //echo.pack(); //echo.show(); startTransition = transitionList.returnTransitionForXY(x, y); if (tracing) { Trace("\n\nTRAN COMPUTED", 1000); } if (startTransition != null) { if (tracing) { Trace(startTransition.id + " |---->O, OR ANIMATE", 1000);} newEdge = true; newEdgeFromTransition = true; //thisPoint = new Point(x, y); //transition temp = tranList.returnTransitionForXY(x, y); //start = new Place(temp.middle.x, temp.middle.y, false ); //Place.counter--; //Place.cardinality--; //startout = new Point (x,y); } // if (startTransition != null) else // if (startTransition == null) { //if (Place.placeList.withinDistanceFromPlace(x, y, if (placeList.withinDistanceFromPlace(x, y, Place.neighborDistance) == false) { if (tracing) { Trace("ADD NEW PLACE\n", 1000); } DrawCircle = true; if (tracing) {Trace("\n Place.cardinality = " + String.valueOf(Place.cardinality), 1000); } Place PLACE = new Place(x, y, false); placeList.insertAtFront( PLACE ); child.placeList.insertAtFront( PLACE ); //Place.placeList.insertAtFront( PLACE ); placeList.print(); //Place.placeList.print(); repaint(); child.repaint(); if (tracing) {Trace("\nADD NEW PLACE --- DONE", 1000);} //AddPlace(x, y); newEdge = false; newEdgeFromPlace = false; newEdgeFromTransition = false; } // else if else {Trace("EXCEPTION", 1000);} } // end else --- (startTransition == null) } // else // (!evt.shiftDown() && // !evt.shiftDown() && // (enclosingPlace == null)) } // else // (!evt.controlDown() && !evt.shiftDown()) } // else (!(evt.controlDown()) ) return true; } //For every mouse move event this method is accesed public boolean mouseMove(Event evt, int x, int y) { //if (sessionStart) // { // Place enclosingPlace; // // parent.documentation.doctext.showline("mouseMove"); // try { Thread.sleep(1500); } // catch (InterruptedException e) {} // // if (evt.controlDown() ) // { // //enclosingPlace = Place.placeList.checkIfInCircle(x,y,Place.radius); // enclosingPlace = (Place)placeList.checkIfInCircle(x,y,Place.radius); // if (enclosingPlace!=null) // { // parent.documentation.doctext.showline("ADD TOKEN"); // try { Thread.sleep(1500); } // catch (InterruptedException e) {} // // enclosingPlace.token = true; // PutDot = true; // repaint(); // } // } // else { // parent.documentation.doctext.showline("NOT ADD TOKEN"); // try { Thread.sleep(1500); } // catch (InterruptedException e) {} // } // } return true; } //For every mouse drag event this method is accesed public boolean mouseDrag(Event evt, int x, int y) { if (newEdge) { if (tracing) { Trace("mouseDrag", 1000); } thisPoint = new Point(x, y); if (tracing) { Trace("\n " + "thisPoint.x = " + String.valueOf(x) + ", " + "thisPoint.y = " + String.valueOf(y), 500); } sessionStart = true; repaint(); child.repaint(); if (tracing) { Trace("\n\nDRAGGING DONE", 500); } } return true; } //For every mouse up event this method is accesed public boolean mouseUp(Event evt, int x, int y) { if (tracing) { Trace("mouseUp", 1000); } Transition newTransition; if (newEdge) { newEdge = false; //end = Place.placeList.checkIfInCircle(x, y, Place.radius); end = (Place)placeList.checkIfInCircle(x, y, Place.radius); if (end != null) { // end is a place; start is either a place or a transition // O--O // / // / // | if (newEdgeFromPlace) { newEdgeFromPlace = false; if (start != end) // O---------------O { if (tracing) {Trace (start.id + " O------------------O " + end.id + "\n" + String.valueOf(start.x) + ", " + String.valueOf(start.y) + " " + String.valueOf(end.x) + ", " + String.valueOf(end.y) + "\n" + " " + String.valueOf((int)((start.x + end.x)/2)) + ", " + String.valueOf((int)((start.y + end.y)/2)), 2500); } newTransition = new Transition( (int)( (start.x + end.x)/2 ), (int)( (start.y + end.y)/2 ) ); if (tracing) { Trace("NEW TRANSITION:\n" + start.id + " O--------------------O " + end.id + "\n " + " | " + newTransition.id + ": " + "x = " + String.valueOf(newTransition.x) + ", y = " + String.valueOf(newTransition.y), 1500); } transitionList.insertTranAtFront(newTransition); child.transitionList.insertTranAtFront(newTransition); if (tracing) { Trace("tranList added", 1000); } start.outgoingTransition.insertTranAtFront(newTransition); if (tracing) { Trace(start.id + ".outgoingTransition added", 1500); } newTransition.inputPlace.insertAtFront(start); if (tracing) {Trace (newTransition.id + ".inputPlace added", 1500); Trace("\n\n Arc.cardinality = " + String.valueOf(Arc.cardinality), 1000);} Arc arc = new Arc(start, newTransition, Arc.place2Transition); if (tracing) { Trace ("New Arc: O----------| \n" + "place.id = " + arc.place.id + "; transition.id = " + arc.transition.id, 1000);} arcList.insertArcAtFront(arc); child.arcList.insertArcAtFront(arc); if (tracing) {Trace("arcList added", 1000);} //newTransition.oneIncomingArc = arc; newTransition.outputPlace.insertAtFront(end); if (tracing) {Trace(newTransition.id + ".outputPlace added", 3000);} end.incomingTransition.insertTranAtFront(newTransition); if (tracing) {Trace(end.id + ".incomingTransition added", 3000);} arc = new Arc(end, newTransition, Arc.transition2Place); if (tracing) {Trace("New Arc: |------------O \n" + "place.id = " + arc.place.id + "; transition.id = " + arc.transition.id, 3000);} arcList.insertArcAtFront(arc); child.arcList.insertArcAtFront(arc); if (tracing) {Trace("\n arcList added\n" + "arrowHead.x = " + String.valueOf(arc.arrowHead.x) + ", arrowHead.y = " + String.valueOf(arc.arrowHead.y), 1000);} //newTransition.oneOutgoingArc = arc; repaint(); child.repaint(); } else // start == end { if (tracing) {Trace("ADD TOKEN", 1500);} start.token = true; PutDot = true; repaint(); child.repaint(); if (tracing) {Trace("ALLOW A LOOP LATER", 1500);} // Create a transition, tr; // Create an edge from "start" to tr; // Create an edge from tr to "end" //transitionUpdate (start, end, 50, x, y); //repaint(); } // end else } // end if (newEdgeFromPlace) else // if (newEdgeFromTransition) |-------O { if (tracing) {Trace(startTransition.id + " |-----O " + end.id, 1500);} newEdgeFromTransition = false; // Create an edge from "startTransition" to "end" startTransition.outputPlace.insertAtFront(end); if (tracing) {Trace(startTransition.id + ".outputPlace added", 1500);} end.incomingTransition.insertTranAtFront(startTransition); if (tracing) {Trace(endTransition.id + ".incomingTran added", 1500);} Arc arc = new Arc(end, startTransition, Arc.transition2Place); if (tracing) {Trace("new arc with;\n" + "place.id = " + arc.place.id + "; transition.id = " + arc.transition.id, 1500);} arcList.insertArcAtFront(arc); child.arcList.insertArcAtFront(arc); if (tracing) {Trace("arcList added", 1500);} repaint(); child.repaint(); } //end else } // end if (end != null) else // if (end != null) --- i.e., current mouse position is not on a place { // either in the vicinity of a transition, or nowhere // O---| 1. newEdgeFromPlace // \ // \ 2. nowhere: allow for creation of a new transition // // // | 3. mouse down and mouse up: firing transition if (tracing) {Trace("NEW EDGE FROM PLACE, OR ANIMATE", 1500);} endTransition = transitionList.returnTransitionForXY(x, y); if (tracing) {Trace("END TRANSITION COMPUTED", 1000);} if (endTransition != null) // case 1 & 3 - a transition already exists { if (newEdgeFromPlace) // case 1 O----| { newEdgeFromPlace = false; if (tracing) {Trace(start.id + " O------------| " + endTransition.id, 1500);} start.outgoingTransition.insertTranAtFront(endTransition); endTransition.inputPlace.insertAtFront(start); Arc arc = new Arc(start, endTransition, Arc.place2Transition); arcList.insertArcAtFront(arc); child.arcList.insertArcAtFront(arc); repaint(); child.repaint(); } else // if (!newEdgeFromPlace) --- case 3 { boolean fireCondition=checkFireCondition(endTransition); System.out.println("FireCondition called"); System.out.println(fireCondition); if (tracing && fireCondition==true ) {Trace("ANIMATE TRANSITION " + endTransition.id,1500);} newEdgeFromTransition = false; Element ptrP1 = endTransition.inputPlace.root; Place startPlace = (Place)ptrP1.getPlace(); if (tracing) {Trace("startPlace.id = " + startPlace.id, 1500);} Element ptrP2 = endTransition.outputPlace.root; Place endPlace = (Place)ptrP2.getPlace(); int trans_flag =0; if (tracing) {Trace("endPlace.id = " + endPlace.id, 1500);} while (fireCondition && (startPlace != null) && (endPlace != null)) { if (tracing) {Trace("ANIMATE: " + startPlace.id + " O-------->|------->O " + endPlace.id, 1500);} lock(); //Place.placeList.DeleteToken(startPlace.x, //placeList.DeleteToken(startPlace.x, //startPlace.y, Place.radius); startPlace.token = false; // animating the movement of token if (trans_flag == 0) { Arc arc = arcList.givenPlaceAndTransition(startPlace, endTransition); if (tracing) {Trace(arc.place.id + " O--------| " + arc.transition.id, 7000);} //-----------------------------mei-------------------------------/ fireTransition temp = new fireTransition(this, endTransition.x, endTransition.y, startPlace.x, startPlace.y, arc); fireTransition ctemp = new fireTransition(child, endTransition.x, endTransition.y, startPlace.x, startPlace.y, arc); if (tracing) {Trace("fireTransition done", 5000);} System.out.println("temp.artist(this,0)"); temp.artist(this,0); System.out.println("temp.artist(child,0)"); ctemp.artist(child,0); //----------------------------mei------------------------------------/ if (tracing) {Trace("artist done", 5000);} trans_flag = 1; } Arc arc1 = arcList.givenPlaceAndTransition(endPlace, endTransition); //------------------------- mei ----------------------/ fireTransition temp1 = new fireTransition(this, endPlace.x, endPlace.y, endTransition.x, endTransition.y, arc1); fireTransition ctemp1 = new fireTransition(child, endPlace.x, endPlace.y, endTransition.x, endTransition.y, arc1); System.out.println("temp1.artist(this,0)"); temp1.artist(this,0); System.out.println("temp1.artist(child,0)"); ctemp1.artist(child,0); // end of animation //-----------------------------mei ---------------------/ endPlace.token=true; PutDot=true; temp1.g.setColor(Color.red); // temp1.child.setColor(Color.red); temp1.g.fillOval(endPlace.x - (Place.radius)/10, endPlace.y - (Place.radius)/10, Place.radius/5, Place.radius/5); // temp1.child.fillOval(endPlace.x - (Place.radius)/10, // endPlace.y - (Place.radius)/10, // Place.radius/5, Place.radius/5); temp1.g.setColor(Color.white); // temp1.child.setColor(Color.white); temp1.g.drawOval(endPlace.x - (Place.radius)/10, endPlace.y - (Place.radius)/10, Place.radius/5, Place.radius/5); // temp1.child.drawOval(endPlace.x - (Place.radius)/10, // endPlace.y - (Place.radius)/10, // Place.radius/5, Place.radius/5); repaint(); child.repaint(); ptrP2 = ptrP2.getNext(); endPlace = (Place)ptrP2.getPlace(); if (tracing) {Trace("endPlace.id = " + endPlace.id, 1500);} } // end of while (weight[i][endPlace.place_id]>0) unlock(); if (trans_flag == 0) {Trace("ILLEGAL FIRING", 7000);} } // end else } // end if (endTransition != null) else // if (endTransition == null) - case 2 { if (newEdgeFromPlace) // case 2 O // \ // \ { if (tracing) {Trace(start.id + " O------------- (" + String.valueOf(x) + ", " + String.valueOf(y) + ")", 3000); Trace("\n Transition.cardinality = " + String.valueOf(Transition.cardinality), 1000); } newEdgeFromPlace = false; newTransition = new Transition(x, y); if (tracing) {Trace("NEW |: " + newTransition.id, 1000);} transitionList.insertTranAtFront(newTransition); child.transitionList.insertTranAtFront(newTransition); if (tracing) {Trace("transitionList added", 1000);} start.outgoingTransition.insertTranAtFront(newTransition); if (tracing) {Trace(start.id + ".outgoingTransition added", 3000);} newTransition.inputPlace.insertAtFront(start); if (tracing) {Trace(newTransition.id + ".inputPlace added", 3000); Trace("\n Arc.cardinality = " + String.valueOf(Arc.cardinality), 1000);} Arc arc = new Arc(start, newTransition, Arc.place2Transition); if (tracing) {Trace("New Arc:\n" + "place.id = " + arc.place.id + "; transition.id = " + arc.transition.id, 3000);} arcList.insertArcAtFront(arc); child.arcList.insertArcAtFront(arc); if (tracing) {Trace("arcList added", 1000);} //newTransition.oneIncomingArc = arc; } else // if (!newEdgeFromPlace) - a new edge ending nowhere // starting from a transition { if (tracing) {Trace("|--------------\n", 2000);} newEdgeFromTransition = false; if (placeList.withinDistanceFromPlace(x, y, Place.neighborDistance) == false) { if (tracing) {Trace("ADD NEW PLACE\n", 1000);} DrawCircle = true; if (tracing) {Trace("\n Place.cardinality = " + String.valueOf(Place.cardinality), 1000);} end = new Place(x, y, false); placeList.insertAtFront( end ); child.placeList.insertAtFront( end ); //Place.placeList.insertAtFront( end ); //placeList.print(); //Place.placeList.print(); if (tracing) {Trace("\nADD NEW PLACE --- DONE", 1000);} //AddPlace(x, y); startTransition.outputPlace.insertAtFront(end); if (tracing) {Trace(startTransition.id + ".outputPlace added", 3000);} end.incomingTransition.insertTranAtFront(startTransition); if (tracing) {Trace(end.id +".incomingTransition added", 3000);} Arc arc = new Arc(end, startTransition, Arc.transition2Place); if (tracing) {Trace("New Arc:\n" + "place.id = " + arc.place.id + "; transition.id = " + arc.transition.id, 2000);} arcList.insertArcAtFront(arc); child.arcList.insertArcAtFront(arc); if (tracing) {Trace("arcList added: " + "arrowHead.x = " + String.valueOf(arc.arrowHead.x) + ", arrowHead.y = " + String.valueOf(arc.arrowHead.y), 3000);} repaint(); child.repaint(); newEdge = false; newEdgeFromPlace = false; newEdgeFromTransition = false; } // else if } // end else } // end else // if (endTransition == null) - case 2 } // else // if (end != null) - current mouse position is not on a place } // if (newEdge) else // if (newEdge) { if (tracing) {Trace("\n\n\n ALL ELSE", 100);} } // end else //repaint(); return true; } // method for deleting a place void DeleteCircle(Place tempPlace) { //Place.placeList.delete(tempPlace); placeList.delete(tempPlace); child.placeList.delete(tempPlace); Place.cardinality--; DrawCircle = true; //Place.placeList.print(); placeList.print(); repaint(); child.repaint(); System.out.println(" I deleted what you wanted"); } // integer to string conversion to draw the string beside the places public String intToString(int i) { char c=(char)((int)'a'+i); return "P "+i; } public void drawPlace(Graphics g, Place place) { //g.setColor(new Color(10,10,200)); g.setColor( Color.yellow); //g.setColor(new Color(100,100,250)); //g.setColor(new Color(70,70,250)); //LOOKS OK:g.setColor(new Color(50,50,250)); //g.setColor(new Color(10,10,100)); //g.setColor(Color.white); //g.setColor(Color.lightGray); g.fillOval(place.x - (Place.radius)/2, place.y- (Place.radius)/2, Place.radius, Place.radius); if (tracingPlace) { Trace("\n WRITING PLACE ID", 1000);} //draw black circles around places, write their names to the screen g.setColor(Color.black); g.drawOval(place.x - (Place.radius)/2, place.y- (Place.radius)/2, Place.radius, Place.radius); //Write name of the place on the top left side of the circle. g.setColor(Color.blue); g.setFont(new Font("Helvetica", Font.BOLD, 10)); g.drawString(place.id, place.x - 19, place.y - 19); if (tracingPlace) { Trace("**** DRAWING TOKEN *****", 1500);} // Draw the tokens if (PutDot == true) { if (place.token==true) { g.setColor(Color.red); g.fillOval(place.x - (Place.radius)/10, place.y - (Place.radius)/10, Place.radius/5, Place.radius/5); g.setColor(Color.white); g.drawOval(place.x - (Place.radius)/10, place.y - (Place.radius)/10, Place.radius/5, Place.radius/5); } // end if (tempObj.token == true) } // end if (PutDot == true) } /* this method draws the transition line */ public void drawTransition(Graphics g, Transition transition) { // draw transition between place i and place j int x1, x2, x3, y1, y2, y3; float dirx, diry; Point startPt; Point endPt; Point arrowHead; if (tracingTransition) { Trace("drawTransition:" + " id = " + transition.id, 1000);} Arc incomingArc = (Arc)arcList.oneIncomingArc(transition); Arc outgoingArc = (Arc)arcList.oneOutgoingArc(transition); if (incomingArc != null) { if (tracingTransition) { Trace("\n incomingArc.place = " + incomingArc.place.id, 1000); } // find the arc between the first arc in dirx = incomingArc.sin_x; diry = incomingArc.cos_x; startPt = new Point(incomingArc.place.x, incomingArc.place.y); endPt = new Point(transition.x, transition.y); arrowHead = incomingArc.arrowHead; } else // (incomingArc != null) { if (tracingTransition) { Trace("\n outgoingArc.place = " + outgoingArc.place.id, 3000);} // find the arc between the first arc in dirx = outgoingArc.sin_x; diry = outgoingArc.cos_x; startPt = new Point(transition.x, transition.y); endPt = new Point(outgoingArc.place.x, outgoingArc.place.y); arrowHead = outgoingArc.arrowHead; } //x3= (int)(arrowHead.x + 6*dirx); //y3= (int)(arrowHead.y + 6*diry); x3= (int)(transition.x + 6*dirx); y3= (int)(transition.y + 6*diry); g.setColor(Color.magenta); g.drawLine((int)(x3 - 1*dirx + 8*diry), (int)(y3 - 1*diry - 8*dirx), (int)(x3 - 1*dirx - 8*diry), (int)(y3 - 1*diry + 8*dirx)); g.drawLine((int)(x3 - 2*dirx + 8*diry), (int)(y3 - 2*diry - 8*dirx), (int)(x3 - 2*dirx - 8*diry), (int)(y3 - 2*diry + 8*dirx)); // g.drawLine((int)(x3 - 1*dirx + 8*diry), // (int)(y3 - 1*diry - 8*dirx), // (int)(x3 - 1*dirx - 8*diry), // (int)(y3 - 1*diry + 8*dirx)); // g.drawLine((int)(x3 - 2*dirx + 8*diry), // (int)(y3 - 2*diry - 8*dirx), // (int)(x3 - 2*dirx - 8*diry), // (int)(y3 - 2*diry + 8*dirx)); if (tracingTransition) { Trace("\n transition bar drawn", 1000);} int dx = (int)(Math.abs(7*diry)); int dy = (int)(Math.abs(7*dirx)); g.setFont(new Font("Helvetica", Font.BOLD + Font.ITALIC, 10)); if ((startPt.x>endPt.x) && (startPt.y>=endPt.y)) { //g.drawString(transition.id, arrowHead.x + dx, arrowHead.y - dy); g.drawString(transition.id, transition.x + dx, transition.y - dy); } else if ((startPt.x>=endPt.x) && (startPt.yendPt.y)) { g.drawString(transition.id, transition.x + dx, transition.y + fmetrics.getHeight() ); //g.drawString(transition.id, arrowHead.x + dx, //arrowHead.y + fmetrics.getHeight() ); } g.setColor(Color.black); if (tracingTransition) { Trace("\n\n transition id written", 1000);} } public void drawArc(Graphics g, Arc arc) { // draw an arc int x1, x2, x3, y1, y2, y3; Point startPt; Point endPt; if (tracingArc) { Trace("drawArc:\n" + arc.place.id + " O----------| " + arc.transition.id, 2000);} if (arc.direction == Arc.place2Transition) { if (tracingArc) { Trace("from place 2 trans", 1000);} startPt = new Point(arc.place.x, arc.place.y); endPt = new Point(arc.transition.x, arc.transition.y); } else // (arc.direction == Arc.transition2Place) { if (tracingArc) { Trace("from trans 2 place", 1000);} startPt = new Point(arc.transition.x, arc.transition.y); endPt = new Point(arc.place.x, arc.place.y); } if (tracingArc) { Trace("startPt & endPt computed", 1000);} g.setColor( Color.blue); g.drawLine(startPt.x, startPt.y, endPt.x, endPt.y); if (tracingArc) { Trace("Arc line drawn\n" + "(" + startPt.x + ", " + startPt.y + ") ------------- (" + endPt.x + ", " + endPt.y +")", 1000);} // calculate arrowHead float dirx = arc.sin_x; float diry = arc.cos_x; if (tracingArc) { Trace("dirx = " + String.valueOf(dirx) + ", diry = " + String.valueOf(diry), 1000);} // x1= (int)(arc.arrowHead.x - 3*dirx + 6*diry); // x2= (int)(arc.arrowHead.x - 3*dirx - 6*diry); // x3= (int)(arc.arrowHead.x + 6*dirx); // // y1= (int)(arc.arrowHead.y - 3*diry - 6*dirx); // y2= (int)(arc.arrowHead.y - 3*diry + 6*dirx); // y3= (int)(arc.arrowHead.y + 6*diry); // // int transitionHead_x[] = { x1, x2, x3 ,x1}; // int transitionHead_y[] = { y1, y2, y3, y1 }; // New addition to generate arrow head at the target place // calculate transitionHead if (arc.direction == Arc.place2Transition) { x1 = (int)(endPt.x - 3 * dirx + 6*diry); x2 = (int)(endPt.x - 3 * dirx - 6*diry); x3 = (int)(endPt.x + 6 * dirx); y1 = (int)(endPt.y - 3 * diry - 6*dirx); y2 = (int)(endPt.y - 3 * diry + 6*dirx); y3 = (int)(endPt.y + 6*diry); } else { x1 = (int)(endPt.x - 27*dirx + 6*diry); x2 = (int)(endPt.x - 27*dirx - 6*diry); x3 = (int)(endPt.x - 24*dirx + 6*dirx); y1 = (int)(endPt.y - 27*diry - 6*dirx); y2 = (int)(endPt.y - 27*diry + 6*dirx); y3 = (int)(endPt.y - 24*diry + 6*diry); } int transitionHead_x[] = { x1, x2, x3,x1}; int transitionHead_y[] = { y1, y2, y3, y1}; // int transitionHead_x[] = { x1, x2, x3,x1}; // int transitionHead_y[] = { y1, y2, y3, y1}; //// End of New addition to generate arrow head at the target place // // // draw transition // // //g.setColor(Color.black); g.fillPolygon(transitionHead_x, transitionHead_y, 4); if (tracingArc) { Trace("Arc arrow head drawn", 1000);} // g.fillPolygon(transitionHead_x_End, transitionHead_y_End, 4); // // // write weight of transition at an appropriate position // int dx = (int)(Math.abs(7*diry)); // int dy = (int)(Math.abs(7*dirx)); // g.setColor(Color.magenta); // g.drawLine((int)(x3 - 1*dirx + 8*diry), // (int)(y3 - 1*diry - 8*dirx), // (int)(x3 - 1*dirx - 8*diry), // (int)(y3 - 1*diry + 8*dirx)); // g.drawLine((int)(x3 - 2*dirx + 8*diry), // (int)(y3 - 2*diry - 8*dirx), // (int)(x3 - 2*dirx - 8*diry), // (int)(y3 - 2*diry + 8*dirx)); // //g.drawLine(x3+dy, y3+dx, x3-dy, y3-dy); // //g.setColor(Color.black); // // // g.setFont(new Font("Helvetica", Font.BOLD + Font.ITALIC, 10)); // // if ((startPt.x>endPt.x) && (startPt.y>=endPt.y)) // { // g.drawString(current.id, arrowHead.x + dx, arrowHead.y - dy); // } // // // if ((startPt.x>=endPt.x) && (startPt.yendPt.y)) // { // g.drawString(current.id, arrowHead.x + dx, // arrowHead.y + fmetrics.getHeight() ); // } // g.setColor(Color.green); } ////draws the nodes in the tranList //public void drawTransitionNode (Graphics g, Point currentStart, Point currentEnd) { // g.setColor(new Color(100,100,250)); // g.drawLine (currentStart.x, currentStart.y, currentEnd.x, currentEnd.y); //} /*The update function is used to stored the drawn information in the buffer. if this method is not there then previously drawn information will be lost */ public final synchronized void update(Graphics g) { // prepare new image offscreen Dimension d=size(); if ((offScreenImage == null) || (d.width != offScreenSize.width) || (d.height != offScreenSize.height)) { offScreenImage = createImage(d.width, d.height); offScreenSize = d; offScreenGraphics = offScreenImage.getGraphics(); } offScreenGraphics.setColor(Color.cyan); offScreenGraphics.fillRect(0, 0, d.width, d.height); paint(offScreenGraphics); g.drawImage(offScreenImage, 0, 0, null); } /*this method paints the information on to the applet */ public void paint(Graphics g) { if (sessionStart) { if (tracing) {Trace("\n **** PAINT ****", 1000);} if (newEdge) { if (tracing) {Trace("\n ** PAINT: DRAGGING LINE **\n" + "start = " + start.id, 500);} g.setColor(Color.blue); //g.drawLine(start.x, start.y, thisPoint.x, thisPoint.y); g.drawLine(lastPoint.x, lastPoint.y, thisPoint.x, thisPoint.y); if (tracing) {Trace(" DRAGGING DONE", 1500); } } if (tracingArc) {Trace("\n **** start DRAWING ARCS ****", 1000);} Element ptrArc = arcList.root; while ( ptrArc != null) { if (tracingArc) {Trace("\n\n\nAN ARC EXISTS", 1000);} Arc tempObj; tempObj = (Arc)ptrArc.getArc(); ptrArc = ptrArc.next; drawArc(g, tempObj); } if (tracingTransition) {Trace("**** start DRAWING TRANSITIONS****", 1000);} //Element ptr = Transition.transitionList.root; Element ptr = transitionList.root; while ( ptr != null) { if (tracingTransition) { Trace("\n\nA TRANSITION EXISTS ", 1000);} Transition tempObj; tempObj = (Transition)ptr.getTransition(); ptr = ptr.next; drawTransition(g, tempObj); // Element ptrNodeP = tempObj.inputPlace.root; // while ( ptrNodeP != null) // { // Point tempnode; // tempnode = (Point)ptrNodeP.getPoint(); // ptrNodeP = ptrNodeP.next; // drawTransitionNode (g, tempnode, tempObj.middle); // } // Element ptrNode = tempObj.outputPlace.root; // while (ptrNode != null) // { // Point tempnode; // tempnode = (Point)ptrNode.getPoint(); // ptrNode = ptrNode.next; // drawTransitionNode (g, tempObj.middle, tempnode); // } } if (tracingPlace) {Trace("\n\n start DRAWING PLACE ****", 1000);} //Element ptrP = Place.placeList.root; Element ptrP = placeList.root; while (ptrP != null) { if (tracingPlace) { Trace("\n\n\n A PLACE EXISTS", 1000);} Place tempObj; tempObj = (Place)ptrP.getPlace(); ptrP = ptrP.next; if (DrawCircle == true) { if (tracingPlace) {Trace(" DRAWING PLACE\n" + " id = " + tempObj.id + ": " + " x = " + String.valueOf(tempObj.x) + "; " + " y = " + String.valueOf(tempObj.y) + "; \n" + " radius = " + String.valueOf(Place.radius), 1500);} drawPlace(g, tempObj); } } // end while (ptrP != null) //if (tracing) {Trace("\n ARCS, TRANSITIONS & PLACES (TOKENS) PAINTED", 1500);} {Trace("\n ARCS, TRANSITIONS & PLACES (TOKENS) PAINTED", 100);} } //end if (sessionStart) } //end paint } //end class /* --------------------- code by Harini & Jayashree-------------------------- */ class DialogTest extends Frame implements ResultProcessor { double mean_value; String title_name; public static double[] delay_value = new double[20]; int choice ; public DialogTest(String s,int option) { setTitle("Dialog Box for entering the mean value"); choice = option; title_name = s; Panel p = new Panel( ); p.setLayout(new FlowLayout(FlowLayout.LEFT)); p.add(new Button("CLICK HERE")); p.add(new Button("CLOSE")); add("North",p); } public boolean action(Event evt,Object arg) { if(arg.equals("CLICK HERE")) { ConnectInfo in = new ConnectInfo("All","2.34"); ConnectDialog pd = new ConnectDialog(this,title_name,in); pd.show( ); } else if(arg.equals("CLOSE")) dispose(); else return super.action(evt,arg); return true; } public boolean handleEvent(Event evt) { if(evt.id == Event.WINDOW_DESTROY && evt.target == this) System.exit(0); else return super.handleEvent(evt); return true; } public void processResult(Dialog source,Object result) { int[] a = new int[20]; double[] d = new double[20]; int i; if(source instanceof ConnectDialog) { ConnectInfo info = (ConnectInfo) result; System.out.println(info.transitions); System.out.println(info.meanvalue); conversion c = new conversion(); change ch = new change(); tokenGen tg = new tokenGen(); random_delay r = new random_delay(); for(i=0;i<20;++i) delay_value[i] = 0.0 ; if(choice == 1) { double val = c.atod(info.meanvalue); double value = r.delay(val); for(i=0;i<20;++i) delay_value[i] = value; for(i=0;i<20;++i)System.out.println("The value of delay " + delay_value[i]); } if(choice == 2) { for(i=0;i<20;++i) delay_value[i] = Math.random() * 20.0 ; a = ch.stoi(info.transitions); for( i=0;i=0;--i) { result = result + (value.charAt(i)-'0')*power; power = power * 10.0; } power = 10.0 ; for(i=(countl+1);i= '1' && transitions.charAt(i) <= '9') temp[count++] = transitions.charAt(i) - '0' ; else { int tempvalue =0; for(j=0;j