Java2D Graphics Summary Images,. Full-Screen Exclusive Mode -Full-screen exclusive mode is a powerful feature of J2SE TM version 1.4 that allows the programmer.

Slides:



Advertisements
Similar presentations
Introduction to Java 2 Programming
Advertisements

Multi-threaded applications SE SE-2811 Dr. Mark L. Hornick 2 What SE1011 students are told… When the main() method is called, the instructions.
Chapter 6 Photoshop and ImageReady: Part II The Web Warrior Guide to Web Design Technologies.
COSC 4126 images - D Goforth Images, Buffering and Animation controlling full screen graphics.
Object Oriented Programming with Java (150704).   Applet  AWT (Abstract Window Toolkit)  Japplet  Swing Types of Applet.
1 Frameworks. 2 Framework Set of cooperating classes/interfaces –Structure essential mechanisms of a problem domain –Programmer can extend framework classes,
Slides prepared by Rose Williams, Binghamton University Chapter 17 Swing I.
Applets. The Applet Class public class MyApplet extends java.applet.Applet {... /** The no-arg constructor is called by the browser when the Web page.
Review of Java Applets Vijayan Sugumaran Decision and Information Sciences Oakland University.
Graphics Programming. In this class, we will cover: The difference between AWT and Swing Creating a frame Frame positioning Displaying information in.
Lecture 15 Graphical User Interfaces (GUI’s). Objectives Provide a general set of concepts for GUI’s Layout manager GUI components GUI Design Guidelines.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 16 Applets.
Game Design and Programming. Objectives Classify the games How games are design How games are implemented What are the main components of a game engine.
18-Jun-15 Applets. 2 An applet is a program that is typically embedded in a Web page and can be run from a browser You need special HTML in the Web page.
Advanced Java Class GUI – part 1. Intro to GUI GUI = Graphical User Interface -- “Gooey” Just because it’s “gooey” does not mean you may write messy code.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 14 Applets, Images,
28-Jun-15 Applets. 2 An applet is a program that is typically embedded in a Web page and can be run from a browser You need special HTML in the Web page.
Applets. What is an Applet?  According to Sun “An applet is a small program that is intended not to be run on its own, but rather to be embedded inside.
© The McGraw-Hill Companies, 2006 Chapter 10 Graphics and event- driven programs.
Java Review Structure of a graphics program. Computer Graphics and User Interfaces Java is Object-Oriented A program uses objects to model the solution.
Lecture20 Java Game Programming III – Rate Control, Simple Animation and Display Mode.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L05 (Chapter 16) Applets.
Introduction to Java GUI Creating Graphical User Interfaces © copyright Bobby Hoggard / material may not be redistributed without permission.
Applets Java API.
20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 16: Java Applets & AWT Fundamentals of Web Programming.
Draw Shapes Introduction to simple graphics. What is a Component? A class that resides in the java.awt package Examples include: –Button, java.awt.Button.
Intro to GUIs (Graphical User Interfaces) Section 2.5Intro. to GUIs: a GUI Greeter Section 3.7Graphical/Internet Java: Einstein's Equation.
JAPPLET.
Learn about the types of Graphics that are available Develop a basic Graphics applet Develop a basic Graphics application Review the Java API and use.
3461A Readings from the Swing Tutorial. 3461A Overview  The follow is the Table of Contents from the trail “Creating a GUI with JFC/Swing” in the “The.
Object Oriented Programming Lecture 4: Refactoring, An Applet Example, Idiom - Animation applets, Introduction to the Laboratorial exercise www2.hh.se/staff/jebe/oop2005/
Java Programming: Advanced Topics 1 Common Elements of Graphical User Interfaces Chapter 6.
Omer Boyaci. Resources  
Week 11 Creating Framed Layouts Objectives Understand the benefits and drawbacks of frames Understand and use frame syntax Customize frame characteristics.
Java Threads. What is a Thread? A thread can be loosely defined as a separate stream of execution that takes place simultaneously with and independently.
Chapter 8 HTML Frames. 2 Principles of Web Design Chapter 8 Objectives Understand the benefits and drawbacks of frames Understand and use frames syntax.
Slides prepared by Rose Williams, Binghamton University ICS201 Lecture 13 : Swing I King Fahd University of Petroleum & Minerals College of Computer Science.
Session 27 Swing vs. AWT. AWT (Abstract Window ToolKit) It is a portable GUI library for stand-alone applications and/or applets. The Abstract Window.
1 CSC111H Graphical User Interfaces (GUIs) Introduction GUIs in Java Understanding Events A Simple Application The Containment Hierarchy Layout Managers.
Pravin Yannawar, DOCS, NMU Jalgaon Basic Java : Applets 2 Objectives of This Session Identify the need for Applets Distinguish between Applets and Applications.
CSE S. Tanimoto Java Introduction 1 Java A Programming Language for Web-based Computing with Graphics.
High Performance Java Swing Animation David Wallace Croft Presented to the Plano Java Users Group Plano, TX Copyright 2004 David Wallace Croft.
CSE S. Tanimoto Java Introduction 1 Java A Programming Language for Web-based Computing with Graphics.
Applets Yong Choi School of Business CSU, Bakersfield.
Creating Windows. How can we use Java to create programs that use windows (GUI applications)? How can we use Java to create programs that use windows.
Chapter 14 Applets and Advanced GUI  The Applet Class  The HTML Tag F Passing Parameters to Applets F Conversions Between Applications and Applets F.
Intro to Applets. Applet Applets run within the Web browser environment Applets bring dynamic interaction and live animation to an otherwise static HTML.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
GUIs Graphical User Interfaces. Everything coming together Known: – Inheritance – Interfaces – Abstract classes – Polymorphism – Exceptions New: – Events.
Java Dynamic Graphics.
CIS Intro to JAVA Lecture Notes Set 8 9-June-05.
Copyright © Curt Hill Applets A different type of program.
Java Swing One of the most important features of Java is its ability to draw graphics.
Project 5: Using Pop-Up Windows Essentials for Design JavaScript Level One Michael Brooks.
GAM666 – Introduction To Game Programming ● DirectDraw, the 2D component of DirectX, uses the term “surface” to mean an area of memory in which pixel data.
Java Applets Adding Animation. Import Files You still need to include the same files: –import java.applet.*; –import java.awt.*;
Java Threads 1 1 Threading and Concurrent Programming in Java Threads and Swing D.W. Denbo.
1 Applets Programming. Introduction Java programs are divided into two main categories, applets and applications. An application is an ordinary Java program.
CSE S. Tanimoto Java Introduction 1 Java A Programming Language for Web-based Computing.
Event Loops and GUI Intro2CS – weeks
Lecture 27 Creating Custom GUIs
Lecture 28 Concurrent, Responsive GUIs
Ellen Walker Hiram College
Advanced Menuing, Introduction to Picking
A Programming Language for
Steps to Creating a GUI Interface
Java Programming COMP-417 Applet
A Programming Language for
TA: Nouf Al-Harbi NoufNaief.net :::
TA: Nouf Al-Harbi NoufNaief.net :::
Presentation transcript:

Java2D Graphics Summary Images,

Full-Screen Exclusive Mode -Full-screen exclusive mode is a powerful feature of J2SE TM version 1.4 that allows the programmer to suspend the windowing system so that drawing can be done directly to the screen. -Full-screen exclusive mode is handled through a java.awt.GraphicsDevice object. -For a list of all available screen graphics devices (in single or multi-monitor systems), you can call the method getScreenDevices on the local java.awt.GraphicsEnvironment; for the default (primary) screen (the only screen on a single- monitor system), you can call the method getDefaultScreenDevice

Full-Screen Exclusive Mode In a full-screen exclusive application, the program can control the bit depth and size (display mode) of the screen. Finally, many more advanced techniques, such as page flipping and stereo buffering (utilizing systems which use a separate set of frames for each eye) require, on some platforms, that an application first be in full-screen exclusive mode.

Hardware-Accelerated Image Basics Once you have the graphics device, you can call one of the following methods: public boolean isFullScreenSupported() This method returns whether or not full-screen exclusive mode is available. On systems where full-screen exclusive mode is not available, it is probably better to run an application in windowed mode with a fixed size rather than setting a full-screen window. public void setFullScreenWindow(Window w) Given a window, this method enters full-screen exclusive mode using that window. If full-screen exclusive mode is not available, the window is positioned at (0,0) and resized to fit the screen. Use this method with a null parameter to exit full-screen exclusive mode.

Summary: Programming Full Screen Exclusive Mode GraphicsDevice myDevice; Window myWindow; try { myDevice.setFullScreenWindow(myWindow);... } finally { myDevice.setFullScreenWindow(null); }

Summary: Programming Full Screen Exclusive Mode Most full-screen exclusive applications are better suited to use undecorated windows. (Turn off decorations in a frame or dialog using the setUndecorated method—scroll bar, titles, etc). frame.setUndecorated(false); Full-screen exclusive applications should not be resizable, since resizing a full-screen application can cause unpredictable (or possibly dangerous) behavior. frame.setResizable(false); For security reasons, the user must grant fullScreenExclusive permission when using full-screen exclusive mode in an applet.

Programming: Changing the Display Mode The display mode is in (java.awt.DisplayMode) The method getDisplayMode gets current display mode. The method getDisplayModes get ALL possible display modes. GraphicsDevice myDevice; Window myWindow; DisplayMode newDisplayMode; DisplayMode oldDisplayMode = myDevice.getDisplayMode(); try { myDevice.setFullScreenWindow(myWindow); myDevice.setDisplayMode(newDisplayMode);... } finally { myDevice.setDisplayMode(oldDisplayMode); myDevice.setFullScreenWindow(null); }

Passive vs Active Rendering // Traditional GUI Application paint method: // This can be called at any time, usually from the event dispatch thread public void paint(Graphics g) { // Use g to draw my Component } This is sometimes referred to as passive rendering. As you can imagine, such a system incurs a lot of overhead, much to the annoyance of many performance-sensitive AWT and Swing programmers.

Active Rendering Instead of relying on the paint method in full-screen exclusive mode, drawing code is usually more appropriately done in a rendering loop: public void myRenderingLoop() { while (!done) { Graphics myGraphics = getPaintGraphics(); // Draw as appropriate using myGraphics myGraphics.dispose(); }

BufferStrategy class – Double Buffering -Suppose you had to draw an entire picture on the screen, pixel by pixel or line by line. -If you were to draw such a thing directly to the screen (using, say, Graphics.drawLine), you would probably notice with much disappointment that it takes a bit of time. -You will probably even notice visible artifacts of how your picture is drawn. Rather than watching things being drawn in this fashion and at this pace, most programmers use a technique called double-buffering. - The traditional notion of double-buffering in Java applications is fairly straightforward: create an offscreen image, draw to that image using the image's graphics object, then, in one step, call drawImage using the target window's graphics object and the offscreen image. You may have already noticed that Swing uses this technique in many of its components, usually enabled by default, using the setDoubleBuffered method.

JFrame window = new JFrame(); DisplayMode displayMode = new DisplayMode(800, 600, 16, 75); // get the GraphicsDevice GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice device = environment.getDefaultScreenDevice(); // use the JFrame as the full screen window device.setFullScreenWindow(window); // change the display mode device.setDisplayMode(displayMode); // After you are finished change the graphics mode back // by setting the full screen window to null device.setFillScreenWindow(null);