Appendix G Navigation and Collision Detection for Web-Based 3D Experiment
|
|
- Amos Kelly
- 6 years ago
- Views:
Transcription
1 Appendix G Appendix G Navigation and Collision Detection for Web-Based 3D Experiment G.1 ImportInG libraries import javax.media.j3d.*; import javax.vecmath.*; import java.awt.event.*; import java.awt.awtevent; import java.util.enumeration; import javax.swing.event.*; import javax.swing.*; G.2 defining class for navigation and collision detection public class NavigatorBehavior extends Behavior implements MouseListener, MouseMotionListener, ActionListener, ItemListener, ChangeListener private TransformGroup viewtrans; private TransformGroup bodytrans; private TransformGroup outsidetrans; private Matrix3f commat = new Matrix3f(); private Shape3D bodyshape; private int direction; private WakeupCriterion eventscondition[] = new WakeupCriterion[3];
2 Ko & Cheng private WakeupOr allevents; private String buttonvalue = new String(); private boolean poststop = false; private float turningangle = 0.0f; private float pitchangle = 0.0f; private Point3f viewposi = new Point3f(); private Point3f firstviewposi = new Point3f(); private Point3f outsideposi = new Point3f(); private boolean ticked = false; private int delay = 20; private JSlider FrameDelay; private Animation animator; //for animating thread; private boolean animating = false; private BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 0.1); private static final float PAI = f; private static final float ANGLEPAI = 2.0f*PAI/360.0f; private static final float SPAN = 0.02f; private static final float ANGLESTEP = 0.01f; private static final float Outsidescale = 0.4f; private static final int VIEWMOTION = 5001; private static final int DOOROPEN = 401; private static final int DOORCLOSE = 402; private static final int ANIMATION = 501; private static final int INTERACTION = 502; private static final int Forward = KeyEvent.VK_UP; private static final int Backward = KeyEvent.VK_DOWN; private static final int LEFT = KeyEvent.VK_LEFT; private static final int RIGHT = KeyEvent.VK_RIGHT; private static final int SHIFTRIGHT = KeyEvent.VK_R; private static final int SHIFTLEFT = KeyEvent.VK_L; private static final int Up = KeyEvent.VK_U; private static final int Down = KeyEvent.VK_D; G.3 constructor of navigation and collision detection function NavigatorBehavior(TransformGroup viewtrans, TransformGroup bodytrans, Shape3D bodyshape) this.bodyshape = bodyshape; this.viewtrans = viewtrans; this.bodytrans = bodytrans;
3 Appendix G G.4 view platform position InItIalIZatIon public void initposition(point3f initposi) this.viewposi = new Point3f(initposi); firstviewposi = new Point3f(initposi); init(); G.5 setting reference for outside scene public void setoutside(transformgroup outsidetrans, Point3f outsideposi) this.outsidetrans = outsidetrans; this.outsideposi = new Point3f(outsideposi); G.6 setting reference for speed control slider for navigation public void setobject(jslider FrameDelay) this.framedelay = FrameDelay; G.7 parameter InItIalIZatIon private void init() commat.m00 = 1.0f; commat.m01 = 0.0f; commat.m02 = 0.0f; commat.m10 = 0.0f; commat.m11 = 1.0f; commat.m12 = 0.0f; commat.m20 = 0.0f; commat.m21 = 0.0f; commat.m22 = 1.0f;
4 Ko & Cheng G.8 function for calculation of rotation matrix from rotation angle private Matrix3f comatrix(int mode, float angle) Matrix3f tempmat = new Matrix3f(); switch (mode) case 1: tempmat.m00 = (float)(math.cos(angle)); tempmat.m01 = 0.0f; tempmat.m02 = (float)(math.sin(angle)); tempmat.m10 = 0.0f; tempmat.m11 = 1.0f; tempmat.m12 = 0.0f; tempmat.m20 = (float)(-math.sin(angle)); tempmat.m21 = 0.0f; tempmat.m22 = (float)(math.cos(angle)); case 2: tempmat.m00 = 1.0f; tempmat.m01 = 0.0f; tempmat.m02 = 0.0f; tempmat.m10 = 0.0f; tempmat.m11 = (float)(math.cos(angle)); tempmat.m12 = (float)(math.sin(angle)); tempmat.m20 = 0.0f; tempmat.m21 = (float)(-math.sin(angle)); tempmat.m22 = (float)(math.cos(angle)); case 3: tempmat.m00 = (float)(math.cos(angle)); tempmat.m01 = (float)(-math.sin(angle)); tempmat.m02 = 0.0f; tempmat.m10 = (float)(math.sin(angle)); tempmat.m11 = (float)(math.cos(angle)); tempmat.m12 = 0.0f; tempmat.m20 = 0.0f; tempmat.m21 = 0.0f; tempmat.m22 = 1.0f; default: return tempmat; G.9 function for ImplementatIon of rotation for view platform
5 Appendix G private void setrotation(transformgroup Trans, float angle, Matrix3f rotmat, int mode) Transform3D rt3d = new Transform3D(); Trans.getTransform(rt3d); rotmat.transpose(); rotmat.invert(); rotmat.mul(rotmat, comatrix(mode, angle)); rt3d.setrotation(rotmat); Trans.setTransform(rt3d); G.10 function for ImplementatIon of translation for view platform private Point3f settranslation(matrix3f rotmat, Point3f posi) Point3f tempposi = new Point3f(); tempposi.x = rotmat.m00*posi.x + rotmat.m01*posi.y + rotmat.m02*(posi.z+0.01f); tempposi.y = rotmat.m10*posi.x + rotmat.m11*posi.y + rotmat.m12*(posi.z+0.01f); tempposi.z = rotmat.m20*posi.x + rotmat.m21*posi.y + rotmat.m22*(posi.z+0.01f); return tempposi; G.11 function for ImplementatIon of translation and rotation for transform Group private void setposition(transformgroup Trans, Point3f point) Transform3D t3d = new Transform3D(); Trans.getTransform(t3d); t3d.settranslation(new Vector3d(point)); Trans.setTransform(t3d); G.12 event InItIalIZatIon function public void initialize() eventscondition[0] = new WakeupOnAWTEvent(KeyEvent.KEY_PRESSED); eventscondition[1] = new WakeupOnCollisionEntry(bodyshape); eventscondition[2] = new WakeupOnBehaviorPost(null, VIEWMOTION); allevents = new WakeupOr(eventsCondition); wakeupon(allevents);
6 0 Ko & Cheng G.13 key events response function for keyboard navigation private void processkeyevent(keyevent e) int key = e.getkeycode(); direction = key; switch(key) case Forward: direction = Forward; viewposi.x = viewposi.x-2.0f*span*(float)math.sin(turningangle); viewposi.z = viewposi.z-2.0f*span*(float)math.cos(turningangle); case Backward: direction = Backward; viewposi.x = viewposi.x+2.0f*span*(float)math.sin(turningangle); viewposi.z = viewposi.z+2.0f*span*(float)math.cos(turningangle); case LEFT: if (pitchangle!=0) setrotation(viewtrans, -pitchangle, commat, 2); pitchangle = 0.0f; setrotation(viewtrans, ANGLESTEP, commat, 1); turningangle += ANGLESTEP; case RIGHT: if (pitchangle!=0) setrotation(viewtrans, -pitchangle, commat, 2); pitchangle = 0.0f; setrotation(viewtrans, -ANGLESTEP, commat, 1); turningangle -= ANGLESTEP; case Up: if (viewposi.y<1.7f)
7 Appendix G viewposi.y = viewposi.y+span/2.0f; case Down: if (viewposi.y>1.0f) viewposi.y = viewposi.y-span/2.0f; case SHIFTLEFT: direction = SHIFTLEFT; viewposi.x = viewposi.x-span*(float)math.sin(turningangle+math.pi/2.0); viewposi.z = viewposi.z-span*(float)math.cos(turningangle+math.pi/2.0); case SHIFTRIGHT: direction = SHIFTRIGHT; viewposi.x = viewposi.x+span*(float)math.sin(turningangle+math.pi/2.0); viewposi.z = viewposi.z+span*(float)math.cos(turningangle+math.pi/2.0); default: G.14 main events response function for navigating and collision detection public void processstimulus(enumeration criteria) WakeupCriterion wakeup; AWTEvent[] event; int eventid; if (!animating) while (criteria.hasmoreelements())
8 Ko & Cheng wakeup = (WakeupCriterion) criteria.nextelement(); if (wakeup instanceof WakeupOnAWTEvent) event = ((WakeupOnAWTEvent)wakeup).getAWTEvent(); for (int i=0; i<event.length; i++) processkeyevent((keyevent) event[i]); if (wakeup instanceof WakeupOnBehaviorPost) try Thread.sleep(delay); catch (Exception ie) System.out.println( Interrupted Exception! ); if (buttonvalue.indexof( Forward )!= -1) direction = Forward; viewposi.x = viewposi.x-2.0f*span*(float)math.sin(turningangle); viewposi.z = viewposi.z-2.0f*span*(float)math.cos(turningangle); else if (buttonvalue.indexof( Backward )!= -1) direction = Backward; viewposi.x = viewposi.x+2.0f*span*(float)math.sin(turningangle); viewposi.z = viewposi.z+2.0f*span*(float)math.cos(turningangle); else if (buttonvalue.indexof( Turnleft )!= -1) if (pitchangle!=0) setrotation(viewtrans, -pitchangle, commat, 2); pitchangle = 0.0f; setrotation(viewtrans, ANGLESTEP, commat, 1); turningangle += ANGLESTEP; else if (buttonvalue.indexof( Turnright )!= -1) if (pitchangle!=0) setrotation(viewtrans, -pitchangle, commat, 2); pitchangle = 0.0f;
9 Appendix G setrotation(viewtrans, -ANGLESTEP, commat, 1); turningangle -= ANGLESTEP; else if (buttonvalue.indexof( Pitchup )!= -1) if (pitchangle>-10.0f*anglepai) setrotation(viewtrans, -ANGLESTEP, commat, 2); pitchangle -= ANGLESTEP; else if (buttonvalue.indexof( Pitchdown )!= -1) if (pitchangle<10.0f*anglepai) setrotation(viewtrans, ANGLESTEP, commat, 2); pitchangle += ANGLESTEP; else if (buttonvalue.indexof( Yawleft )!= -1) else if (buttonvalue.indexof( Yawright )!= -1) else if (buttonvalue.indexof( Horizontal )!= -1) if (pitchangle!=0) setrotation(viewtrans, -pitchangle, commat, 2); pitchangle = 0.0f; else if (buttonvalue.indexof( Original )!= -1) viewposi = new Point3f(firstviewposi); if (pitchangle!=0) setrotation(viewtrans, -pitchangle, commat, 2); pitchangle = 0.0f; if (turningangle!=0) setrotation(viewtrans, -turningangle, commat, 1); turningangle = 0.0f;
10 Ko & Cheng else if (buttonvalue.indexof( Up )!= -1) if (viewposi.y<1.7f) viewposi.y = viewposi.y+span/2.0f; else if (buttonvalue.indexof( Down )!= -1) if (viewposi.y>1.0f) viewposi.y = viewposi.y-span/2.0f; else if (buttonvalue.indexof( Shiftleft )!= -1) direction = SHIFTLEFT; viewposi.x = viewposi.x-span*(float)math.sin(turningangle+math.pi/2.0); viewposi.z = viewposi.z-span*(float)math.cos(turningangle+math.pi/2.0); else if (buttonvalue.indexof( Shiftright )!= -1) direction = SHIFTRIGHT; viewposi.x = viewposi.x+span*(float)math.sin(turningangle+math.pi/2.0); viewposi.z = viewposi.z+span*(float)math.cos(turningangle+math.pi/2.0); if (poststop) postid(viewmotion); if (wakeup instanceof WakeupOnCollisionEntry) // The implememtation of the collision function, go back two step when // the collision occurs in order to obtain the next collision ability switch (direction) case Forward: viewposi.x = viewposi.x+4.0f*span*(float)math.sin(turningangle); viewposi.z = viewposi.z+4.0f*span*(float)math.cos(turningangle);
11 Appendix G case Backward: viewposi.x = viewposi.x-4.0f*span*(float)math.sin(turningangle); viewposi.z = viewposi.z-4.0f*span*(float)math.cos(turningangle); case SHIFTLEFT: viewposi.x = viewposi.x+2.0f*span*(float)math.sin(turningangle+math.pi/2.0); viewposi.z = viewposi.z+2.0f*span*(float)math.cos(turningangle+math.pi/2.0); case SHIFTRIGHT: viewposi.x = viewposi.x-2.0f*span*(float)math.sin(turningangle+math.pi/2.0); viewposi.z = viewposi.z-2.0f*span*(float)math.cos(turningangle+math.pi/2.0); default: this.wakeupon(allevents); G.15 events function for navigation control panel public void actionperformed(actionevent e) String radiobutton = e.getactioncommand(); if (radiobutton.indexof( Animation )!=-1) animating = true; viewposi = new Point3f(firstviewposi); if (pitchangle!=0) setrotation(viewtrans, -pitchangle, commat, 2); pitchangle = 0.0f;
12 Ko & Cheng if (turningangle!=0) setrotation(viewtrans, -turningangle, commat, 1); turningangle = 0.0f; setposition(outsidetrans, new Point3f(Outsidescale*viewposi.x, outsideposi.y, outsideposi.z)); postid(dooropen); if (animator == null) animator = new Animation(); animator.running = true; else if (!animator.running) animator.running = true; else if (radiobutton.indexof( Interaction )!=-1) animating = false; viewposi = new Point3f(firstviewposi); if (pitchangle!=0) setrotation(viewtrans, -pitchangle, commat, 2); pitchangle = 0.0f; if (turningangle!=0) setrotation(viewtrans, -turningangle, commat, 1); turningangle = 0.0f; postid(doorclose); if (animator!= null) if (animator.animationthread.isalive()) animator.running = false; //quit the measuring loop animator = null;
13 Appendix G G.16 mouse release events function public void mousereleased(mouseevent e) poststop = false; G.17 function for mouse pressed events for IdentIfyInG Icons on navigating panel public void mousepressed(mouseevent e) buttonvalue = null; int positionx = e.getx(); int positiony = e.gety(); if(positionx>722 && positionx<734 && positiony>58 && positiony<71) buttonvalue = Shiftleft ; else if(positionx>826 && positionx<839 && positiony>55 && positiony<69) buttonvalue = Shiftright ; else if(positionx>772 && positionx<788 && positiony>7 && positiony<21) buttonvalue = Up ; else if(positionx>772 && positionx<788 && positiony>102 && positiony<114) buttonvalue = Down ; else if(positionx>785 && positionx<798 && positiony>40 && positiony<52) buttonvalue = Forward ; else if(positionx>758 && positionx<771 && positiony>74 && positiony<86) buttonvalue = Backward ; else if(positionx>767 && positionx<791 && positiony>52 && positiony<64) buttonvalue = Original ; else if(positionx>883 && positionx<896 && positiony>53 && positiony<73) buttonvalue = Turnleft ; else if(positionx>974 && positionx<985 && positiony>52 && positiony<75)
14 Ko & Cheng buttonvalue = Turnright ; else if(positionx>922 && positionx<944 && positiony>14 && positiony<22) buttonvalue = Pitchup ; else if(positionx>922 && positionx<942 && positiony>100 && positiony<113) buttonvalue = Pitchdown ; else if(positionx>925 && positionx<942 && positiony>57 && positiony<77) buttonvalue = Horizontal ; if (buttonvalue!= null) poststop = true; postid(viewmotion); G.18 function for mouse exit event public void mouseexited(mouseevent e) G.19 function for mouse entry event public void mouseentered(mouseevent e) G.20 function for mouse click event public void mouseclicked(mouseevent e)
15 Appendix G G.21 function for mouse move event public void mousemoved(mouseevent e) G.22 function for mouse drag event public void mousedragged(mouseevent e) G.23 function for dragging of speed control slider panel public void statechanged(changeevent e) if (e.getsource().tostring().indexof( majortickspacing=2 )!=-1) delay = (10-FrameDelay.getValue())*15; G.24 function for clicking mode buttons on navigation panel public void itemstatechanged(itemevent e) if (e.getsource().tostring().indexof( Keyboard )!=-1) if (e.getstatechange() == ItemEvent.DESELECTED) ticked = false; else ticked = true;
16 0 Ko & Cheng G.25 animation thread class for continuous movement WhIle navigating Icons Is held or animation mode button Is clicked class Animation implements Runnable boolean running = false; Thread AnimationThread; public Animation() AnimationThread = new Thread(this); AnimationThread.start(); //call function run() to begin to measure public void run() try AnimationThread.sleep(1000); catch (Exception ie) System.out.println( Interrupted Exception! ); while (running) if (viewposi.z>-2.0f) viewposi.z = viewposi.z - 2.0f*SPAN; setposition(outsidetrans, new Point3f(Outsidescale*viewposi.x, outsideposi.y, outsideposi.z)); else viewposi.z=-2.0f; setrotation(viewtrans, ANGLESTEP, commat, 1); turningangle += ANGLESTEP; try AnimationThread.sleep(80); catch (Exception ie) System.out.println( Interrupted Exception! ); AnimationThread.interrupt(); //stop measuring // end of class NavigatorBehavior
Interaction and Animation in Java 3D
Computer Game Technologies Interaction and Animation in Java 3D Computer Game Technologies, 2017 1 Interaction and Animation in Java 3D Interaction is a change in the scene in response to user action Key
More informationProgramming Languages and Techniques (CIS120)
Programming Languages and Techniques (CIS120) Lecture 36 November 30, 2018 Mushroom of Doom Model / View / Controller Chapter 31 Announcements Game Project Complete Code Due: Monday, December 10th NO LATE
More informationProgramming Languages and Techniques (CIS120)
Programming Languages and Techniques (CIS120) Lecture 34 April 13, 2017 Model / View / Controller Chapter 31 How is the Game Project going so far? 1. not started 2. got an idea 3. submitted design proposal
More informationJava Mouse Actions. C&G criteria: 5.2.1, 5.4.1, 5.4.2,
Java Mouse Actions C&G criteria: 5.2.1, 5.4.1, 5.4.2, 5.6.2. The events so far have depended on creating Objects and detecting when they receive the event. The position of the mouse on the screen can also
More informationGUI Event Handlers (Part II)
GUI Event Handlers (Part II) 188230 Advanced Computer Programming Asst. Prof. Dr. Kanda Runapongsa Saikaew (krunapon@kku.ac.th) Department of Computer Engineering Khon Kaen University 1 Agenda Listener
More informationComputer Science 210: Data Structures. Intro to Java Graphics
Computer Science 210: Data Structures Intro to Java Graphics Summary Today GUIs in Java using Swing in-class: a Scribbler program READING: browse Java online Docs, Swing tutorials GUIs in Java Java comes
More informationGraphical User Interfaces 2
Graphical User Interfaces 2 CSCI 136: Fundamentals CSCI 136: Fundamentals of Computer of Science Computer II Science Keith II Vertanen Keith Vertanen Copyright 2011 Extending JFrame Dialog boxes Overview
More informationThe AWT Event Model 9
The AWT Event Model 9 Course Map This module covers the event-based GUI user input mechanism. Getting Started The Java Programming Language Basics Identifiers, Keywords, and Types Expressions and Flow
More informationG51PGP Programming Paradigms. Lecture 008 Inner classes, anonymous classes, Swing worker thread
G51PGP Programming Paradigms Lecture 008 Inner classes, anonymous classes, Swing worker thread 1 Reminder subtype polymorphism public class TestAnimals public static void main(string[] args) Animal[] animals
More informationGUI in Java TalentHome Solutions
GUI in Java TalentHome Solutions AWT Stands for Abstract Window Toolkit API to develop GUI in java Has some predefined components Platform Dependent Heavy weight To use AWT, import java.awt.* Calculator
More informationGUI DYNAMICS Lecture July 26 CS2110 Summer 2011
GUI DYNAMICS Lecture July 26 CS2110 Summer 2011 GUI Statics and GUI Dynamics 2 Statics: what s drawn on the screen Components buttons, labels, lists, sliders, menus,... Containers: components that contain
More informationGraphical User Interfaces 2
Graphical User Interfaces 2 CSCI 136: Fundamentals of Computer Science II Keith Vertanen Copyright 2014 2011 Extending JFrame Dialog boxes Overview Ge
More informationMethod Of Key Event Key Listener must implement three methods, keypressed(), keyreleased() & keytyped(). 1) keypressed() : will run whenever a key is
INDEX Event Handling. Key Event. Methods Of Key Event. Example Of Key Event. Mouse Event. Method Of Mouse Event. Mouse Motion Listener. Example of Mouse Event. Event Handling One of the key concept in
More informationAppendix D Main Applet for Web-Based 3D Experiment
0 Ko & Cheng Appendix D Main Applet for Web-Based 3D Experiment d.1 ImportInG libraries import java.awt.borderlayout; import java.applet.applet; import java.awt.event.*; import com.sun.j3d.utils.applet.mainframe;
More informationGraphical User Interfaces 2
Graphical User Interfaces 2 CSCI 136: Fundamentals of Computer Science II Keith Vertanen Copyright 2011 Extending JFrame Dialog boxes Ge?ng user input Overview Displaying message or error Listening for
More informationTHE UNIVERSITY OF AUCKLAND
CompSci 101 with answers THE UNIVERSITY OF AUCKLAND FIRST SEMESTER, 2012 Campus: City COMPUTER SCIENCE Principles of Programming (Time Allowed: TWO hours) NOTE: You must answer all questions in this test.
More informationProgramming Languages and Techniques (CIS120)
Programming Languages and Techniques (CIS120) Lecture 35 April 21, 2014 Swing III: Paint demo, Mouse InteracFon HW 10 has a HARD deadline Announcements You must submit by midnight, April 30 th Demo your
More informationCSIS 10A Assignment 14 SOLUTIONS
CSIS 10A Assignment 14 SOLUTIONS Read: Chapter 14 Choose and complete any 10 points from the problems below, which are all included in the download file on the website. Use BlueJ to complete the assignment,
More informationECE 462 Object-Oriented Programming using C++ and Java. Key Inputs in Java Games
ECE 462 Object-Oriented Programming g using C++ and Java Key Inputs in Java Games Yung-Hsiang Lu yunglu@purdue.edu d YHL Java Key Input 1 Handle Key Events have the focus of the keyboard inputs by calling
More informationProgramming Languages and Techniques (CIS120)
Programming Languages and Techniques (CIS120) Lecture 35 April 15, 2013 Swing III: OO Design, Mouse InteracGon Announcements HW10: Game Project is out, due Tuesday, April 23 rd at midnight If you want
More informationJava for Interfaces and Networks (DT3010, HT10)
Java for Interfaces and Networks (DT3010, HT10) Mouse Events, Timers, Serialization Federico Pecora School of Science and Technology Örebro University federico.pecora@oru.se Federico Pecora Java for Interfaces
More informationDesign Patterns: Prototype, State, Composite, Memento
Design Patterns: Prototype, State, Composite, Memento Let s start by considering the CanvasEditor as we had it at the end of the last class. Recall that when a button was clicked, the button s custom ActionListener
More informationHandling Mouse and Keyboard Events
Handling Mouse and Keyboard Events 605.481 1 Java Event Delegation Model EventListener handleevent(eventobject handleevent(eventobject e); e); EventListenerObject source.addlistener(this);
More informationUNIT-3 : MULTI THREADED PROGRAMMING, EVENT HANDLING. A Multithreaded program contains two or more parts that can run concurrently.
UNIT-3 : MULTI THREADED PROGRAMMING, EVENT HANDLING 1. What are Threads? A thread is a single path of execution of code in a program. A Multithreaded program contains two or more parts that can run concurrently.
More informationCOMP 102: Test 2 Model Solutions
Family Name:.......................... Other Names:.......................... ID Number:............................ Instructions Time allowed: 45 minutes There are 45 marks in total. Answer all the questions.
More informationCSIS 10A Practice Final Exam Solutions
CSIS 10A Practice Final Exam Solutions 1) (5 points) What would be the output when the following code block executes? int a=3, b=8, c=2; if (a < b && b < c) b = b + 2; if ( b > 5 a < 3) a = a 1; if ( c!=
More informationPESIT Bangalore South Campus
INTERNAL ASSESSMENT TEST II Date : 20-09-2016 Max Marks: 50 Subject & Code: JAVA & J2EE (10IS752) Section : A & B Name of faculty: Sreenath M V Time : 8.30-10.00 AM Note: Answer all five questions 1) a)
More informationProgrammierpraktikum
Programmierpraktikum Claudius Gros, SS2012 Institut für theoretische Physik Goethe-University Frankfurt a.m. 1 of 18 17/01/13 11:46 Java Applets 2 of 18 17/01/13 11:46 Java applets embedding Java applications
More informationProgramming Languages and Techniques (CIS120)
Programming Languages and Techniques (CIS120) Lecture 35 November 30 th 2015 Design PaBerns Model / View / Controller Chapter 31 Game project grading Game Design Proposal Milestone Due: (12 points) Tuesday
More informationHW#1: Pencil Me In Status!? How was Homework #1? Reminder: Handouts. Homework #2: Java Draw Demo. 3 Handout for today! Lecture-Homework mapping.
HW#1: Pencil Me In Status!? CS193J: Programming in Java Summer Quarter 2003 Lecture 6 Inner Classes, Listeners, Repaint Manu Kumar sneaker@stanford.edu How was Homework #1? Comments please? SITN students
More information(listener)... MouseListener, ActionLister. (adapter)... MouseAdapter, ActionAdapter. java.awt AWT Abstract Window Toolkit GUI
51 6!! GUI(Graphical User Interface) java.awt javax.swing (component) GUI... (container) (listener)... MouseListener, ActionLister (adapter)... MouseAdapter, ActionAdapter 6.1 GUI(Graphics User Interface
More informationH212 Introduction to Software Systems Honors
Introduction to Software Systems Honors Lecture #19: November 4, 2015 1/14 Third Exam The third, Checkpoint Exam, will be on: Wednesday, November 11, 2:30 to 3:45 pm You will have 3 questions, out of 9,
More informationLecture 28. Exceptions and Inner Classes. Goals. We are going to talk in more detail about two advanced Java features:
Lecture 28 Exceptions and Inner Classes Goals We are going to talk in more detail about two advanced Java features: Exceptions supply Java s error handling mechanism. Inner classes ease the overhead of
More informationJ.73 J.74 THE I/O PACKAGE. Java I/O is defined in terms of streams. Streams are ordered sequences of data that have a source and a destination.
THE I/O PACKAGE Java I/O is defined in terms of streams. J.73 import java.io.*; class Translate { public static void main(string[] args) { InputStream in = System.in; OutputStream out = System.out; J.74
More informationjavax.swing Swing Timer
27 javax.swing Swing SwingUtilities SwingConstants Timer TooltipManager JToolTip 649 650 Swing CellRendererPane Renderer GrayFilter EventListenerList KeyStroke MouseInputAdapter Swing- PropertyChangeSupport
More informationChapter 1 GUI Applications
Chapter 1 GUI Applications 1. GUI Applications So far we've seen GUI programs only in the context of Applets. But we can have GUI applications too. A GUI application will not have any of the security limitations
More informationCS 106A, Lecture 14 Events and Instance Variables
CS 106A, Lecture 14 Events and Instance Variables Reading: Art & Science of Java, Ch. 10.1-10.4 This document is copyright (C) Stanford Computer Science and Marty Stepp, licensed under Creative Commons
More informationclass BankFilter implements Filter { public boolean accept(object x) { BankAccount ba = (BankAccount) x; return ba.getbalance() > 1000; } }
9.12) public interface Filter boolean accept(object x); Describes any class whose objects can measure other objects. public interface Measurer double measure(object anobject); This program tests the use
More informationComponent-Based Behavioural Modelling with High-Level Petri Nets
Component-Based Behavioural Modelling with High-Level Petri Nets Rémi Bastide, Eric Barboni LIIHS IRIT, University of Toulouse, France {bastide, barboni}@irit.fr Software Components Active domain for industry,
More informationWindows and Events. created originally by Brian Bailey
Windows and Events created originally by Brian Bailey Announcements Review next time Midterm next Friday UI Architecture Applications UI Builders and Runtimes Frameworks Toolkits Windowing System Operating
More informationNORTHWEST NAZARENE UNIVERSITY. Cyclops An Open Source Educational Tool for Modeling Digital Logic
NORTHWEST NAZARENE UNIVERSITY Cyclops An Open Source Educational Tool for Modeling Digital Logic THESIS Submitted to the Department of Mathematics and Computer Science in partial fulfillment of the requirements
More informationCS2110. GUIS: Listening to Events
CS2110. GUIS: Listening to Events Also anonymous classes Download the demo zip file from course website and look at the demos of GUI things: sliders, scroll bars, combobox listener, etc 1 mainbox boardbox
More informationCS 106A, Lecture 14 Events and Instance Variables
CS 106A, Lecture 14 Events and Instance Variables Reading: Art & Science of Java, Ch. 10.1-10.4 This document is copyright (C) Stanford Computer Science and Marty Stepp, licensed under Creative Commons
More informationpublic void mouseexited (MouseEvent e) setminute(getminute()+increment); 11.2 public void mouseclicked (MouseEvent e) int x = e.getx(), y = e.gety();
11 The Jav aawt Part I: Mouse Events 11.1 public void mouseentered (MouseEvent e) setminute(getminute()+increment); 53 public void mouseexited (MouseEvent e) setminute(getminute()+increment); 11.2 public
More informationUser interfaces and Swing
User interfaces and Swing Overview, applets, drawing, action listening, layout managers. APIs: java.awt.*, javax.swing.*, classes names start with a J. Java Lectures 1 2 Applets public class Simple extends
More informationChapter 10. 3D Sprites
Chapter 10. 3D Sprites In this chapter, we develop a Sprite3D class, very similar in nature to the 2D sprite class of chapter??. Subclasses of Sprite3D are used to create different kinds of sprites, which
More informationAdvanced Java Programming (17625) Event Handling. 20 Marks
Advanced Java Programming (17625) Event Handling 20 Marks Specific Objectives To write event driven programs using the delegation event model. To write programs using adapter classes & the inner classes.
More informationAnimation in Java 3D
Computer Game Technologies Animation in Java 3D Computer Game Technologies, 2017 1 Animation in Java 3D Animation is a change without any direct user action Time-based animation Interpolators Alpha objects
More informationEvents Chris Piech CS106A, Stanford University. Piech, CS106A, Stanford University
Events Chris Piech CS106A, Stanford University Catch Me If You Can We ve Gotten Ahead of Ourselves Source: The Hobbit Start at the Beginning Source: The Hobbit Learning Goals 1. Write a program that can
More informationProgram 20: //Design an Applet program to handle Mouse Events. import java.awt.*; import java.applet.*; import java.awt.event.*;
Program 20: //Design an Applet program to handle Mouse Events. import java.awt.*; import java.applet.*; import java.awt.event.*; /* */ public
More informationBASICS OF GRAPHICAL APPS
CSC 2014 Java Bootcamp Lecture 7 GUI Design BASICS OF GRAPHICAL APPS 2 Graphical Applications So far we ve focused on command-line applications, which interact with the user using simple text prompts In
More informationCIS 120 Final Exam 16 December Name (printed): Pennkey (login id):
CIS 120 Final Exam 16 December 2015 Name (printed): Pennkey (login id): My signature below certifies that I have complied with the University of Pennsylvania s Code of Academic Integrity in completing
More informationEVENTS, EVENT SOURCES AND LISTENERS
Java Programming EVENT HANDLING Arash Habibi Lashkari Ph.D. Candidate of UTM University Kuala Lumpur, Malaysia All Rights Reserved 2010, www.ahlashkari.com EVENTS, EVENT SOURCES AND LISTENERS Important
More informationPESIT Bangalore South Campus Hosur road, 1km before Electronic City, Bengaluru -100 Department of Information Science and Engineering
INTERNAL ASSESSMENT TEST 2 Date : 28-09-15 Max Marks :50 Subject & Code : JAVA&J2EE(10IS753) Section: VII A&B Name of faculty : Mr.Sreenath M V Time : 11.30-1.00 PM Note: Answer any five questions 1) a)
More informationFile: GFace.java /* * File: GFace.java * This class implements a face as a GCompound. */
Steve Cooper Handout #22 CS 106A April 24, 2013 Graphics and Events Examples File: GFace.java * File: GFace.java * This class implements a face as a GCompound. // Note: only need acm.graphics since this
More informationMULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.
CSIS 10A PRACTICE FINAL EXAM SOLUTIONS Closed Book Closed Computer 3 Sheets of Notes Allowed MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) What
More informationCSIS 10A PRACTICE FINAL EXAM Name Closed Book Closed Computer 3 Sheets of Notes Allowed
CSIS 10A PRACTICE FINAL EXAM Name Closed Book Closed Computer 3 Sheets of Notes Allowed MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) What would
More informationCSEN401 Computer Programming Lab. Topics: Graphical User Interface Window Interfaces using Swing
CSEN401 Computer Programming Lab Topics: Graphical User Interface Window Interfaces using Swing Prof. Dr. Slim Abdennadher 22.3.2015 c S. Abdennadher 1 Swing c S. Abdennadher 2 AWT versus Swing Two basic
More informationEXAMINATIONS 2010 END-OF-YEAR COMP 102 INTRODUCTION TO COMPUTER PROGRAM DESIGN
T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW V I C T O R I A UNIVERSITY OF WELLINGTON Student ID:....................... EXAMINATIONS 2010 END-OF-YEAR COMP 102 INTRODUCTION TO
More informationL4,5: Java Overview II
L4,5: Java Overview II 1. METHODS Methods are defined within classes. Every method has an associated class; in other words, methods are defined only within classes, not standalone. Methods are usually
More informationCheng, CSE870. More Frameworks. Overview. Recap on OOP. Acknowledgements:
More Frameworks Acknowledgements: K. Stirewalt. Johnson, B. Foote Johnson, Fayad, Schmidt Overview eview of object-oriented programming (OOP) principles. Intro to OO frameworks: o Key characteristics.
More informationGUI 4.1 GUI GUI MouseTest.java import javax.swing.*; import java.awt.*; import java.awt.event.*; /* 1 */
25 4 GUI GUI GUI 4.1 4.1.1 MouseTest.java /* 1 */ public class MouseTest extends JApplet implements MouseListener /* 2 */ { int x=50, y=20; addmouselistener(this); /* 3 */ super.paint(g); /* 4 */ g.drawstring("hello
More informationQuick Reference. There are several already named colors which you can use, but you must import the appropriate Java library.
Quick Reference This appendix contain information on many of the useful objects and methods related to this book. Some are used in the book, others are just extras you may want to explore to add extra
More informationOutline. Topic 9: Swing. GUIs Up to now: line-by-line programs: computer displays text user types text AWT. A. Basics
Topic 9: Swing Outline Swing = Java's GUI library Swing is a BIG library Goal: cover basics give you concepts & tools for learning more Assignment 7: Expand moving shapes from Assignment 4 into game. "Programming
More informationG51PRG: Introduction to Programming Second semester Applets and graphics
G51PRG: Introduction to Programming Second semester Applets and graphics Natasha Alechina School of Computer Science & IT nza@cs.nott.ac.uk Previous two lectures AWT and Swing Creating components and putting
More informationBM214E Object Oriented Programming Lecture 13
BM214E Object Oriented Programming Lecture 13 Events To understand how events work in Java, we have to look closely at how we use GUIs. When you interact with a GUI, there are many events taking place
More informationAP Computer Science Unit 13. Still More Graphics and Animation.
AP Computer Science Unit 13. Still More Graphics and Animation. In this unit you ll learn about the following: Mouse Motion Listener Suggestions for designing better graphical programs Simple game with
More informationIndex. Symbols. aural environment 269
0 Index Index Symbols 2D image 129 2D mouse 194 3D computer graphics, interactive 1 3D graphic, full-immersive 5 3D graphic, non-immersive 5 3D graphic, semi-immersive 5 3D graphics 5 3D graphics API 11
More informationPoints Missed on Page page 1 of 8
Midterm II - CSE11 Fall 2013 CLOSED BOOK, CLOSED NOTES 50 minutes, 100 points Total. Name: ID: Problem #1 (8 points) Rewrite the following code segment using a for loop instead of a while loop (that is
More informationEINFÜHRUNG IN DIE PROGRAMMIERUNG
EINFÜHRUNG IN DIE PROGRAMMIERUNG GRAFIK- UND NETZWERKPROGRAMMIERUNG Tobias Witt 28.03.2014 SWING FENSTER public class Main extends JFrame { public Main() { add(new Board()); settitle("wurm"); setdefaultcloseoperation(exit_on_close);
More informationCOURSE: Introduction to JAVA Programming GRADE(S): UNIT 1: Introduction to Applets NATIONAL STANDARDS: ALL STUDENTS
UNIT 1: Introduction to Applets 1.1 Use graphics objects to generate output on screen 1.2 1.3 1.4 Write and run applets Accepting input and manipulating numbers Write and run applets using graphics to
More informationInteractors. Brahm Capoor.
Interactors Brahm Capoor brahm@stanfordedu Learning goals for today To learn how to use interactors in our programs Learning goals for today To learn how to use interactors in our programs To go under
More informationBreakout YEAH hours. Brahm Capoor & Jared Wolens
Breakout YEAH hours Brahm Capoor & Jared Wolens Road Map YEAH hour schedule Deadline: Due Wednesday, February 8th Lecture Review Using the debugger Assignment Overview Q&A! YEAH hours this quarter Assignment
More informationAdvanced Java Unit 6: Review of Graphics and Events
Advanced Java Unit 6: Review of Graphics and Events This is a review of the basics of writing a java program that has a graphical interface. To keep things simple, all of the graphics programs will follow
More informationAdvanced Java Programming
Advanced Java Programming Shmulik London Lecture #5 GUI Programming Part I AWT & Basics Advanced Java Programming / Shmulik London 2006 Interdisciplinary Center Herzeliza Israel 1 Agenda AWT & Swing AWT
More informationApplet which displays a simulated trackball in the upper half of its window.
Example: Applet which displays a simulated trackball in the upper half of its window. By dragging the trackball using the mouse, you change its state, given by its x-y position relative to the window boundaries,
More informationNITI NITI I PRIORITET
NITI public class ThreadsTest { public static void main(string args[]) { BytePrinter bp1 = new BytePrinter(); BytePrinter bp2 = new BytePrinter(); BytePrinter bp3 = new BytePrinter(); bp1.start(); bp2.start();
More informationCS2110. GUIS: Listening to Events Also anonymous classes versus Java 8 functions. Anonymous functions. Anonymous functions. Anonymous functions
CS2110. GUIS: Listening to Events Also anonymous classes versus Java 8 functions Lunch with instructors: Visit Piazza pinned post to reserve a place Download demo zip file from course website, look at
More informationEE219 Object Oriented Programming I (2005/2006) SEMESTER 1 SOLUTIONS
Q1(a) Corrected code is: EE219 Object Oriented Programming I (2005/2006) SEMESTER 1 SOLUTIONS 01 #include 02 using namespace std; 03 04 class Question1 05 06 int a,b,*p; 07 08 public: 09 Question1(int
More informationQuestion 1. Show the steps that are involved in sorting the string SORTME using the quicksort algorithm given below.
Name: 1.124 Quiz 2 Thursday November 9, 2000 Time: 1 hour 20 minutes Answer all questions. All questions carry equal marks. Question 1. Show the steps that are involved in sorting the string SORTME using
More informationChapter 10. Further Abstraction Techniques
Chapter 10 Further Abstraction Techniques In the previous chapter, we saw how Java checks the usage of methods. We also saw that if the method is not defined in the superclass, the compiler will not work.
More informationJava Foundations John Lewis Peter DePasquale Joe Chase Third Edition
Java Foundations John Lewis Peter DePasquale Joe Chase Third Edition Pearson Education Limited Edinburgh Gate Harlow Essex CM20 2JE England and Associated Companies throughout the world Visit us on the
More informationCS 335 Graphics and Multimedia. Image Manipulation
CS 335 Graphics and Multimedia Image Manipulation Image Manipulation Independent pixels: image subtraction image averaging grey level mapping thresholding Neighborhoods of pixels: filtering, convolution,
More informationCS11 Java. Fall Lecture 4
CS11 Java Fall 2006-2007 Lecture 4 Today s Topics Interfaces The Swing API Event Handlers Inner Classes Arrays Java Interfaces Classes can only have one parent class No multiple inheritance in Java! By
More informationUCLA PIC 20A Java Programming
UCLA PIC 20A Java Programming Instructor: Ivo Dinov, Asst. Prof. In Statistics, Neurology and Program in Computing Teaching Assistant: Yon Seo Kim, PIC University of California, Los Angeles, Summer 2002
More informationBehaviours. Capabilities and Scheduling Bounds
Behaviours Java 3D uses the Behavior class to facilitate interaction and animation This class, and its descendants, are links to user code which can change the graphics and sounds of the virtual universe
More informationDartmouth College Computer Science 10, Fall 2015 Midterm Exam
Dartmouth College Computer Science 10, Fall 2015 Midterm Exam 6.00-9.00pm, Monday, October 19, 2015 105 Dartmouth Hall Professor Prasad Jayanti Print your name: Print your section leader name: If you need
More informationUnit 7: Event driven programming
Faculty of Computer Science Programming Language 2 Object oriented design using JAVA Dr. Ayman Ezzat Email: ayman@fcih.net Web: www.fcih.net/ayman Unit 7: Event driven programming 1 1. Introduction 2.
More informationCS2110. GUIS: Listening to Events. Anonymous functions. Anonymous functions. Anonymous functions. Checkers.java. mainbox
CS2110. GUIS: Listening to Events Lunch with instructors: Visit pinned Piazza post. A4 due tonight. Consider taking course S/U (if allowed) to relieve stress. Need a letter grade of C- or better to get
More informationCS2110. GUIS: Listening to Events
CS2110. GUIS: Listening to Events Lunch with instructors: Visit pinned Piazza post. A4 due tonight. Consider taking course S/U (if allowed) to relieve stress. Need a letter grade of C- or better to get
More informationChapter 6 Game Programming I
Chapter 6 Game Programming I To this point we've learned to create simple objects such as UFOs on screen and move them around in a controlled manner. Now we'll take a look at the components of basic game
More informationUML and OOD. Some terms related to OOD. Dependency. Coupling. Interfaces. Multiple Interfaces
UML and OOD Some terms related to OOD What are good systems like? Most real systems are too big for a single developer to understand everything about the system modules. How do we break a system into modules/components/classes?
More informationLab. Lecture 26: Concurrency & Responsiveness. Assignment. Maze Program
Lab Lecture 26: Concurrency & Responsiveness CS 62 Fall 2016 Kim Bruce & Peter Mawhorter Using parallelism to speed up sorting using Threads and ForkJoinFramework Review relevant material. Some slides
More informationSession 6. Microsoft and The DigiPen Institute of Technology Webcast Series
Session 6 Microsoft and The DigiPen Institute of Technology Webcast Series HOW TO USE THIS DOCUMENT This e-textbook has been distributed electronically using the Adobe Portable Document Format (PDF) format.
More informationFirstSwingFrame.java Page 1 of 1
FirstSwingFrame.java Page 1 of 1 2: * A first example of using Swing. A JFrame is created with 3: * a label and buttons (which don t yet respond to events). 4: * 5: * @author Andrew Vardy 6: */ 7: import
More informationCS 2113 Software Engineering
CS 2113 Software Engineering Java 5 - GUIs Import the code to intellij https://github.com/cs2113f18/template-j-5.git Professor Tim Wood - The George Washington University Class Hierarchies Abstract Classes
More informationAP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS
AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS PAUL L. BAILEY Abstract. This documents amalgamates various descriptions found on the internet, mostly from Oracle or Wikipedia. Very little of this
More informationAdapted from slides by Brahm Capoor. Breakout YEAH hours. Michael (Chung Troute)
Adapted from slides by Brahm Capoor Breakout YEAH hours Michael (Chung Troute) Road Map Lecture Review Graphics Animation Events Using the debugger Assignment Overview Q&A! Graphics GRect rect = new GRect(50,
More informationQueens College, CUNY Department of Computer Science. CS 212 Object-Oriented Programming in Java Practice Exam 2. CS 212 Exam 2 Study Guide
Topics for Exam 2: Queens College, CUNY Department of Computer Science CS 212 Object-Oriented Programming in Java Practice Exam 2 CS 212 Exam 2 Study Guide Linked Lists define a list node define a singly-linked
More informationjavax.swing.jbutton upbutton = new javax.swing.jbutton("up"); upbutton.addactionlistener(new UpListener(_drawing)); row.
package beginninggraphics; public class App { private containers.column _column; private Drawing _drawing; public App() { javax.swing.jframe frame = new javax.swing.jframe(); _column = new containers.column();
More information