Graphical Interface Commands

Slides:



Advertisements
Similar presentations
 2004 Prentice Hall, Inc. All rights reserved. 1 Chapter 30 - Dynamic HTML: Structured Graphics ActiveX Control Outline 30.1Introduction 30.2Shape Primitives.
Advertisements

Laboratory Study II October, Java Programming Assignment  Write a program to calculate and output the distance traveled by a car on a tank of.
Graphics You draw on a Graphics object The Graphics object cannot directly be created by your code, instead one is generated when the method paintComponent.
1 Drawing C Sc 335 Object-Oriented Programming and Design Rick Mercer.
Java Graphics Section 1 - Multi-File Graphics Programs Section 2 - The Coordinate System and Graphics Context g Section 3 - The Java Drawing and Painting.
Building Java Programs Supplement 3G Graphics Copyright (c) Pearson All rights reserved.

Copyright 2008 by Pearson Education Building Java Programs Graphics Reading: Supplement 3G.
1 Chapter 15 l Basic Figures l Colors l Fonts and Other Text Details Graphics Objects.
Copyright 2008 by Pearson Education Building Java Programs Graphics reading: Supplement 3G videos: Ch. 3G #1-2.
1 L38 Graphics and Java 2D™ (3). 2 OBJECTIVES In this chapter you will learn:  To understand graphics contexts and graphics objects.  To understand.
Copyright 2006 by Pearson Education 1 Building Java Programs Supplement 3G: Graphics.
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.
Java Review Structure of a graphics program. Computer Graphics and User Interfaces Java is Object-Oriented A program uses objects to model the solution.
1 Graphical objects We will draw graphics in Java using 3 kinds of objects: DrawingPanel : A window on the screen. Not part of Java; provided by the authors.
CS324e - Elements of Graphics and Visualization Java2D Graphics.
DHTML: Structured Graphics ActiveX Control
Element. The element Used to dynamically draw graphics using javascript. Capable of drawing paths, circles, rectangles, text, and images.
Lecture 15: Intro to Graphics Yoni Fridman 7/25/01 7/25/01.
Chapter 15Java: an Introduction to Computer Science & Programming - Walter Savitch 1 Chapter 15 l Basic Figures l Colors l Fonts and Other Text 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.
Graphics & Java 2D Drawing Two Dimensional Shapes Controlling Fonts Controlling Colors.
Working with Objects. Objectives Create an object Transform an object Arrange and lock an object Step and repeat an object Use Live Distribute Use the.
Graphics Copyright © 2015 by Maria Litvin, Gary Litvin, and Skylight Publishing. All rights reserved. Java Methods Object-Oriented Programming and Data.
Java Graphics. Review 3 kinds of elements in components API? Layout managers Events Extend vs. Implement.
B. RAMAMURTHY Simulating Motion and Implementing Animation.
(C) 2010 Pearson Education, Inc. All rights reserved.  Class Graphics (from package java.awt) provides various methods for drawing text and shapes onto.
Merete S COLLEGEFACULTY OF ENGINEERING & SCIENCE Graphics ikt403 – Object-Oriented Software Development.
1 GUIs, Layout, Drawing Rick Mercer. 2 Event-Driven Programming with Graphical user Interfaces  Most applications have graphical user interfaces (GUIs)
Graphics and Java2D Chapter Java Coordinate System Origin is in _____________ corner –Behind title bar of window X values increase to the ________.
 2000 Deitel & Associates, Inc. All rights reserved. Chapter 19 – Dynamic HTML: Structured Graphics ActiveX Control Outline 19.1Introduction 19.2Shape.
Introduction to Graphics. Graphical objects To draw pictures, we will use three classes of objects: –DrawingPanel : A window on the screen. –Graphics.
1 Drawing C Sc 335 Object-Oriented Programming and Design Rick Mercer.
Introduction to Tool Panel. The tools in the Tools panel let you draw, paint, select, and modify artwork, as well as change the view of the Stage If the.
Copyright 2008 by Pearson Education Building Java Programs Graphics reading: Supplement 3G videos: Ch. 3G #1-2.
Basic Graphics 03/03/16 & 03/07/16 Imagine! Java: Programming Concepts in Context by Frank M. Carrano, (c) Pearson Education - Prentice Hall, 2010.
CS 115 Lecture 6 Graphics Taken from notes by Dr. Neil Moore.
12 Graphics and Java 2D™.
Learn Animations in Fireworks
Flash Interface, Commands and Functions
Building Java Programs
Creating Complex Animations
Building Java Programs
Basic Graphics Chapter 5 3/19/15 Thursday Section Only
Building Java Programs
Building Java Programs
CSc 110, Spring 2017 Lecture 6: Parameters (cont.) and Graphics
Basic Graphics Drawing Shapes 1.
ISC440: Web Programming II Ch14: HTML5 Canvas
4.14 GUI and Graphics Case Study: Creating Simple Drawings (Cont.)
Topic 8 graphics "What makes the situation worse is that the highest level CS course I've ever taken is cs4, and quotes from the graphics group startup.
Building Java Programs
Graphics -- Introduction
“Keep looking up…that’s the secret of life.”
“It is only those who never do anything who never make mistakes.”
Building Java Programs
موضوع بحث: تعریف علم اصول جلسه 43.
اشاره به نتایج قیاس های فقهی گاهی، حکم شرعی است
Building Java Programs
Building Java Programs
Building Java Programs
Building Java Programs
Building Java Programs
Building Java Programs
Building Java Programs
Graphics Reading: Supplement 3G
Building Java Programs
قاعده لا ضرر، تنها در شبهات حکمیه جاری است
Integrated Math One - Module 6 Test Review
1 ج : اشاره بعضی از اصولیون به تعریف ترکیبی آخوند با «یک لفظ»
Presentation transcript:

Graphical Interface Commands By: Amir, Adam, Eduard Green text- good code Red text- bad code 

The Draw Panel J-Panel int workspaceWidth=1440, workspaceHeight=900; Declare the drawpanel at the top of the code to be used MyDrawPanel drawpanel1; < (name of drawpanel can be anything, i.e. BobRossPanel1) Declare the size for the works space immediately underneath: int workspaceWidth=1440, workspaceHeight=900; Add the new Draw Panel to the J-Frame just like any other visible element: this.add (drawpanel1);

g2. line oval arc rectangle polygon draw/fill All the Shapes

Creating The Shapes g2.draw … g2.fill … Shapes and their properties: The outcome will be the desired shape’s outline. (empty inside). g2.fill … The outcome will be the desired shape filled. (filled inside). Shapes and their properties: g2.drawLine(x of start point, y of start point, x of end point, y of end point) g2.drawRect(x of top left corner, y of top left corner, width, height) g2.drawOval(x of top left corner, y of top left corner, width, height) g2.drawArc(x, y, width, height, start angle, end angle)

Polygons are tricky but not really Polygons are extremely useful because most shapes are polygons. When working with a polygon the x and y intercepts must be included in variable arrays above the created polygon. g2.drawPolygon(x-values array name, y-values array name, number of values in array/n) The x and y arrays must be declared as follows: int[]x8={first x value, second x value, third x value…}; int[]y8={first y value, second y value, third y value…}; Do not mess up the order of the x and y because they are coordinates to a point on the grid ad not separate.

Text To Draw To draw phrases or sentences the following code is used: g2.drawString(“text”,x-location,y-location); Declare the font variable and name it: Font Cool = new Font("Haettenschweiler", Font.ITALIC, 40); Furthermore the text can be edited to the preferred size and font: g2.setFont(font variable name);

Color changes and size adaptations When setting the color of the shape/outline you can follow 2 ways: Creating the color as a separate variable to be used repetitive times: Color colorrrr= new Color(r,g,b); Creating the color inside of the set color code that uses it: g2.setColor((new Color(r,g,b))); When setting the color all the shapes under the setColor line are affected, so it is ideal to revert the change so that not all the shapes have the same one.

Transformations in the drawing surface Like math but easier The different changes of the graph positioning include: Rotation: g2.rotate(Math.toRadians(80)); Translation: g2.translate(+ x, + y); When dealing with rotations, the degrees are in radians. The rotation affects all the shapes underneath the line and therefore must be changed back to the original 0 radians to set the graph straight again.

Creating the grid, Cartesian plane To make the calculations easier and to see the points on the drawPanel a grid can be used: How to make a grid is demonstrated on code…

The final touch To make the shapes smoother and the overall image look nicer the following two lines can be used: Graphics2D g2 = (Graphics2D)g; Converts the ordinay graphics object into a Graphics2d object. g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON); This line takes away the jaggedness and smooths out the lines.