Advanced Java Screen Update Techniques SD’98 - Session 4406 Ted Faison Faison Computing Inc.

Slides:



Advertisements
Similar presentations
Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 1 Chapter 2 2D Graphics: Basics.
Advertisements

Georgia Institute of Technology Drawing in Java – part 2 Barb Ericson Georgia Institute of Technology September 2005.
Java Two Dimensional Graphics with Affine Transforms
CSC1401 Drawing in Java - 2. Reminder from last class How do you save your modified picture? String filename = …; Picture stevePicture = new Picture(filename);
More Java Drawing in 2D Animations with Timer. Drawing Review A simple two-dimensional coordinate system exists for each graphics context or drawing surface.
User Interface Programming in C#: Graphics
Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 1 Chapter 4 2D Graphics: Advanced Topics.
Graphics Programming UQC117S2 Semester /4. Session 3 1 Drawing in Java 2D Graphics API.
1 L38 Graphics and Java 2D™ (3). 2 OBJECTIVES In this chapter you will learn:  To understand graphics contexts and graphics objects.  To understand.
IAT 3551 Computer Graphics Overview Color Displays Drawing Pipeline.
Lecture 7 Graphics under AWT Graphics Attributes Shapes Clips Affine Transformations Strokes, Paints, Colors, Translucency RenderingHints, Anti-aliasing.
Graphics in Java Part I. Lecture Objectives Understand the basic concepts of Computer Graphics Learn about Computer Graphics Applications Learn about.
Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 1 Chapter 2 2D Graphics: Basics F The architecture.
Swing Graphics ● Empty Swing containers have no visual appearance except for a background color ● Every JComponent must have a paintComponent method that.
Introduction to 3D Graphics John E. Laird. Basic Issues u Given a internal model of a 3D world, with textures and light sources how do you project it.
User Interface Programming in C#: Direct Manipulation Chris North CS 3724: HCI.
Graphics ~ Tools To Edit Clip Art MsBrewer Fall 2012.
CS324e - Elements of Graphics and Visualization Java2D Graphics.
Vector Graphics Making custom images. Raster vs. Vector Graphics In computer graphics, a raster graphics image, or bitmap, is a dot matrix data structure.
1 Review of COMPSCI 221  Chapters 1-11 in text  User Interfaces will be addressed as a take- home question.
Java ME & Blackberry APIs for Game Dev Week III. Overview Java 2D API Java 3D API SVG Blackberry APIs
BY Kamran Yousaf Computer Graphics & Animation. BY Kamran Yousaf Contents Introduction Usage, Application & Advantages Video Display Devices Output Devices.
1 CMT Fundamentals of Computer Graphics Revision Dr. Xiaohong Gao BG---Room 2C23 Week 11.
1 Graphical User Components (II) Outline JTextArea Creating a Customized Subclass of JPanel JPanel Subclass that Handles Its Own Events Windows: Additional.
1.00 Lecture 18 Geometric Transformations in the 2D API.
2D Graphics: Rendering Details
Chapter 15 Graphics and Java 2D™ Java How to Program, 8/e (C) 2010 Pearson Education, Inc. All rights reserved.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 28 - Java Graphics and Java2D Outline 28.1Introduction.
Chapter 28 - Java Graphics and Java2D Outline 28.1Introduction 28.2Graphics Contexts and Graphics Objects 28.3Color Control 28.4Font Control 28.5Drawing.
Default Fill & Stroke D Swap Fill & Stroke Shift X None / Gradient > Color < Stroke X Fill (Click to activate) X More about Fill and Stroke:
 Pearson Education, Inc. All rights reserved. 1 Ch 12 Graphics and Java 2D In this chapter you will learn:  To understand graphics contexts.
(C) 2010 Pearson Education, Inc. All rights reserved. Omer Boyaci.
Advanced User Interfaces with Java SD’98 - Session 3206 Ted Faison Faison Computing Inc.
Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 1 Chapter 3 2D Graphics: Rendering Details.
Java Graphics. Review 3 kinds of elements in components API? Layout managers Events Extend vs. Implement.
1 Chapter 3 2D Graphics: Rendering Details  Color spaces, paints stroke types  Affine transforms including translation, rotation, scaling, shearing,
User Interface Programming in C#: Direct Manipulation Chris North CS 3724: HCI.
2D Graphics: Advanced Topics Chapter 4. Bird’s Eye View  Overview of Computer Graphics  2D Graphics: Basics  2D Graphics: Rendering Details  2D Graphics:
Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive.
1 Perception and VR MONT 104S, Fall 2008 Lecture 21 More Graphics for VR.
Java Direct Manipulation Chris North cs3724: HCI.
Aim: What is Adobe Illustrator?. Adobe Illustrator is a vector based drawing program.
Java Dynamic Graphics.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Image Panel & Image Navigator. Review Graphics2D class for drawing shapes in a component – paintComponent(Graphics g) – Graphics2D g2 = (Graphics2D)g;
Graphics and Java2D Chapter Java Coordinate System Origin is in _____________ corner –Behind title bar of window X values increase to the ________.
CS COMPUTER GRAPHICS LABORATORY. LIST OF EXPERIMENTS 1.Implementation of Bresenhams Algorithm – Line, Circle, Ellipse. 2.Implementation of Line,
CISC 110 Day 3 Introduction to Computer Graphics.
Java Graphics Opening Discussion zWhat did we talk about last class? zDo you have any questions about the assignment? zOffset between class.
Creating Vectors – Part One 2.02 Understand Digital Vector Graphics.
Image Panel & Image Navigator. Review Graphics2D class for drawing shapes in a component – paintComponent(Graphics g) – Graphics2D g2 = (Graphics2D)g;
Java Graphics Chris North cs3724: HCI. Presentations peter hou Vote: UI Hall of Fame/Shame?
Computer Graphics I, Fall 2010 Transformations.
1 Teaching Innovation - Entrepreneurial - Global The Centre for Technology enabled Teaching & Learning, N Y S S, India DTEL DTEL (Department for Technology.
Projects: not limited to spec Error checking File filters Create multiple file formats Polygons Filled shapes Etc.
IS502:M ULTIMEDIA D ESIGN FOR I NFORMATION S YSTEM D IGITAL S TILL I MAGES Presenter Name: Mahmood A.Moneim Supervised By: Prof. Hesham A.Hefny Winter.
Georgia Institute of Technology Drawing in Java – part 2 Dr Usman Saeed Assistant Professor Faculty of Computing and Information Technology North Jeddah.
Main characteristics of Vector graphics  Vector graphics provide an elegant way of constructing digital images (diagrams, technical illustration and.
Advanced AWT The Rendering Pipeline
12 Graphics and Java 2D™.
Computer Graphics Overview
Rendering Pipeline Fall, 2015.
3D Geometric Transformations
Graphics Fundamentals
Java Graphics The basic rendering mechanism is the drawing system that controls when and how programs can draw on a graphics component. When a component.
2.02 Understand Digital Vector Graphics
Chapter 49 Java 2D.
Creating Vectors – Part One
Creating Vectors – Part One
Translation in Homogeneous Coordinates
Presentation transcript:

Advanced Java Screen Update Techniques SD’98 - Session 4406 Ted Faison Faison Computing Inc.

Painting with the 2D API –Everything is just a Shape The Shape interface and its main methods –boolean contains(Point2D) –Rectangle getBounds() –PathIterator getPathIterator(AffineTransform) –boolean Intersects(Rectangle2D) GeneralPath, Bezier Curves Rectangles, Polygons, Ellipses, Arcs Text

2D Drawing Examples –Drawing a geometric shape DrawingRectangles.java –Filling a shape FillingRectangles.java –Drawing the outline of a shape TextOutline.java

Flicker and repaint ( ) –What repaint() does Erases component background Sets graphics context color Calls paint() –Flicker is produced by the background erasure –Example RectWithFlicker.java

Minimizing Flicker Tips –Call paint() directly, instead of repaint(), if the component has no transparent areas –Don't erase areas you're going to paint over

Moving components on the screen SetLocation causes the AWT to erase the old image and draw the new one. Can cause flicker, since no optimizations are applied Use a silhouette a lightweight outline XORed to the screen Extremely fast Example: UsingSilhouettes.java

Double Buffering An example –OffScreenImage.java Using BufferedImage –gives control over transparency and blending –examples –OffScreenBufferedImage.java –OffScreenBufferedImageWithTransparency.java

Shaping the area painted: Clipping Regions Using Graphics.setClip –JDK 1.1 supported only rect Graphics.setClip(int, int, int, int); –JDK 1.2 also supports arbitrary shapes Graphics2D.setClip(Shape)

Improving Screen Update Speed with Clipping –Use rectangular clipping areas only –Examples Rectangles: RectMovingWithClipping.java Images: ImageMovingWithClipping.java Shapes: ShapeMovingWithClipping.java –uses coordinate transformations to move shape

Coordinate Transformations Functions that map a point in one space to a point in another space Represented using a 3x3 matrix Transformations require multiplying each pixel by the transformation matrix Positive angles rotate the X+ axis towards the Y+ axis Can be used to invert axes, bend images, distort space arbitrarily

Coordinate Transformations a 11 a 12 a 13 a 21 a 22 a xy1xy1 a 11 x a 12 y a 13 a 21 x a 22 y a x’ y’ 1 ==

Affine Transforms Maintain straightness and parallelism Translation setToTranslation(double dx, double, dy); used to support graphics scrolling User Space Device Space

Affine Transforms Rotation –Rotating about the origin setToRotation(double theta); User Space Device Space

Affine Transforms –Rotation about an arbitrary point SetToRotation(theta, x, y); User Space Device Space (x, y)

Affine Transforms Shearing setToShear(double sh, double sy) User Space Device Space

Affine Transforms Scaling setToScale(double sx, double sy) anisotropic vs isotropic scaling User Space Device Space

Affine Transforms Handling transformed images with offscreen buffers –Examples OffScreenTransformedImage.java ScalingImages.java RotatingImages.java ShearingImages.java

Batch Painting A technique to speed up rendering Used internally by the Graphics2D context Batch: a block of contiguous pixels with the same Paint object

Drawing Patterns Patterns require BufferedImage and TexturePaint objects –Example PatternedBackgrounds.java Filling Shapes with Patterns –Example: FillingShapeWithPattern.java –Example: FillingTextWithPattern.java

Conclusion Use Double Buffering to minimize flicker Use Coordinate Transformations to scroll and zoom Everything is a Shape, with support for stroking, gradient filling and pattern filling Batch painting internally increases screen update speed