Chapter 49 Java 2D.

Slides:



Advertisements
Similar presentations
CHAPTER 20 CREATING SVG GRAPHICS. LEARNING OBJECTIVES How to embed a graphic stored within a.SVG file in an HTML page How to use the and tag pair to specify.
Advertisements

Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 1 Chapter 2 2D Graphics: Basics.
Georgia Institute of Technology Drawing in Java – part 2 Barb Ericson Georgia Institute of Technology September 2005.
CSC1401 Drawing in Java - 2. Reminder from last class How do you save your modified picture? String filename = …; Picture stevePicture = new Picture(filename);
Draw Shapes Introduction to simple graphics. What is a graphics context? An instance of the Graphics class Graphics is ABSTRACT! You can extend Graphics.
More Java Drawing in 2D Animations with Timer. Drawing Review A simple two-dimensional coordinate system exists for each graphics context or drawing surface.
Continuing to very powerful Rendering Model Java2D.
Lecture07 Graphics Programming in Java. Introduction Most of the graphics programming of java is done with: Most of the graphics programming of java is.
1 L38 Graphics and Java 2D™ (3). 2 OBJECTIVES In this chapter you will learn:  To understand graphics contexts and graphics objects.  To understand.
Lecture 7 Graphics under AWT Graphics Attributes Shapes Clips Affine Transformations Strokes, Paints, Colors, Translucency RenderingHints, Anti-aliasing.
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.
Chapter 6 Color Image Processing Chapter 6 Color Image Processing.
Swing Graphics ● Empty Swing containers have no visual appearance except for a background color ● Every JComponent must have a paintComponent method that.
Web Design & Development Lecture 18. Java Graphics.
CS324e - Elements of Graphics and Visualization Java2D Graphics.
Curve Modeling Bézier Curves
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
1 Graphical User Components (II) Outline JTextArea Creating a Customized Subclass of JPanel JPanel Subclass that Handles Its Own Events Windows: Additional.
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.
Java Graphics Swing Graphics
2D Graphics Basics Chapter 2. Bird’s Eye View  Overview of Computer Graphics  2D Graphics: Basics –Basic 2D graphics, rendering pipeline, geometry,
Graphics and Java 2D. 2 Introduction Java’s graphics capabilities –Drawing 2D shapes –Controlling colors –Controlling fonts Java 2D API –More sophisticated.
Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 1 Chapter 3 2D Graphics: Rendering Details.
J McQuillan SE204: 2004/2005: Lecture 4slide 1 The Graphics Class Used when we need to draw to the screen Two graphics classes –Graphics –Graphics2D.
Java Graphics. Review 3 kinds of elements in components API? Layout managers Events Extend vs. Implement.
Big Java by Cay Horstmann Copyright © 2009 by John Wiley & Sons. All rights reserved. In order to display a drawing in a frame, define a class that extends.
Java Graphics Stuart Hansen 11/6/03. What’s Wrong with OpenGL Graphics – not GUI –No real support of text boxes, buttons, etc. Procedural - not OOP –No.
Project 2: Thoughts Problems/Solutions Multiple Vectors vs. One Vector + easy to draw, - z order Shape can draw itself +separation.
1 Chapter 3 2D Graphics: Rendering Details  Color spaces, paints stroke types  Affine transforms including translation, rotation, scaling, shearing,
Creating Your Own Widgets CompSci 230 S Software Construction.
Aim: What is Adobe Illustrator?. Adobe Illustrator is a vector based drawing program.
Java Dynamic Graphics.
Graphics and Java2D Chapter Java Coordinate System Origin is in _____________ corner –Behind title bar of window X values increase to the ________.
Georgia Institute of Technology Drawing in Java – part 3 Barb Ericson Georgia Institute of Technology September 2006.
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.
Advanced Java Screen Update Techniques SD’98 - Session 4406 Ted Faison Faison Computing Inc.
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.
10/20/2005week71 Graphics, mouse and mouse motion events, KeyEvent Agenda Classes in AWT for graphics Example java programs –Graphics –Mouse events –Mouse.
HTML5 Diagramo - Real world example OSCON, Birds of Feather, July 28, 2011.
Advanced AWT Paint. ● Paint is used to fill a shape, its inside is covered with paint. ● Use the setPaint method to set the paint style to an object with.
Barb Ericson Georgia Institute of Technology September 2005
Advanced AWT The Rendering Pipeline
12 Graphics and Java 2D™.
Lecture 5 Basic geometric objects
Creating Your Own Widgets
Java Graphics CS 2511.
Introduction to Geometry – Transformations and Constructions
2D Transformation.
Chapter 34 Advanced JavaFX
Chapter 4 Interface Types and Polymorphism Part 1
JAVA 2 Design and programming of GUI
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.
Chapter 1: Foundations in Geometry
Color Image Processing
Creating Vectors – Part One
Creating Vectors – Part One
Barb Ericson Georgia Institute of Technology September 2005
Presentation transcript:

Chapter 49 Java 2D

Objectives To obtain a Graphics2D object for rendering Java 2D shapes (§49.2). To use geometric models to separate modeling of shapes from rendering (§49.3). To know the hierarchy of shapes (§49.3). To model lines, rectangles, ellipses, arcs using Line2D, Rectangle2D, RoundRectangle2D, Ellipse2D, and Arc2D (§49.4). To perform coordinate transformation using the translate, rotate, and scale methods (§49.5). To specify the attributes of lines using the BasicStroke class (§49.6). To define a varying color using GradientPaint and define an image paint using TexturePaint (§49.7). To model quadratic curves and cubic curves using the QuadCurve2D and CubicCurve2D classes (§49.8). To model an arbitrary geometric path using Path2D and to define interior points using the WIND_EVEN_ODD and WIND_NON_ZERO rules (§49.9). To perform constructive area geometry using the Area class (§49.10).

Obtaining a Graphics2D Object protected void paintComponent(Graphics g) { super.paintComponent(g); // Get a Graphics2D object Graphics2D g2d = (Graphics2D)g; // Use the method in Graphics2D to draw graphics ... }

Geometric Models

The Shape Interface

Rectangle2D, RoundRectangle2D, Arc2D, and Ellipse2D Graphics2DDemo Run

Coordinate Transformations Java 2D provides the classes for modeling geometric objects. It also supports coordinate transformations using translation, rotation, and scaling.

Translations TranslationDemo Run

Rotations RotationDemo Run

Scaling ScalingDemo Run

Strokes BasicStrokeDemo Run

Paint PaintDemo Run

QuadCurve2D and CubicCurve2D CurveDemo Run

Path2D Path2DDemo Run

Winding Rules The WIND_EVEN_ODD rule defines a point as inside a path if a ray from the point towards infinity in an arbitrary direction intersects the path an odd number of times. With the WIND_NON_ZERO rule, the direction of the path is taken into consideration. A point is inside a path if a ray from the point towards infinity in an arbitrary direction intersects the path an unequal number of opposite directions. WindingRuleDemo Run

Constructive Area Geometry AreaDemo Run