Pertemuan 2 Teknik Animasi 2D dan 3D.

Slides:



Advertisements
Similar presentations
IS Programming Fundamentals 1 (Lec) Date: September 14, Array.
Advertisements

Continuation of chapter 6…. Nested while loop A while loop used within another while loop is called nested while loop. Q. An illustration to generate.
AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
1 Classes and Objects in Java Parameter Passing, Delegation, Visibility Control, and Object Cleanup.
Lecture 4 More on Java® Data Types, Control Structures.
Iterations for loop. Outcome Introduction to for loop The use of for loop instead of while loop Nested for loops.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 3: Flow Control I: For Loops.
Methods and Formatted Output Chapter 4. Overview Breaking down a big program into small methods. Formatting output – using printf – using DecimalFormat.
Input review If review Common Errors in Selection Statement Logical Operators switch Statements Generating Random Numbers practice.
Fun with Swing Chapter 9. Overview Swing vs. AWT Creating windows and panels. Displaying formatted text in panels. Drawing graphics (lines, circles, etc.)
1 public class Newton { public static double sqrt(double c) { double epsilon = 1E-15; if (c < 0) return Double.NaN; double t = c; while (Math.abs(t - c/t)
Introduction to Computer Science Robert Sedgewick and Kevin Wayne Copyright © Recursive GCD Demo public class.
Introduction to Computer Science Robert Sedgewick and Kevin Wayne Recursive Factorial Demo pubic class Factorial {
Modifier in Java Modifier in java Modifier in Java *Suatu akses ke classes, constructors, methods, dan fields. Dapat mengkontrol informasi yang dapat.
Phil Campbell London South Bank University Java 1 First Steps.
Review BP Dari slide pak cahyo pertemuan 7 dan pertemuan 2 dengan sedikit modifikasi.
Loops –Do while Do While Reading for this Lecture, L&L, 5.7.
Picture It Very Basic Game Picture Pepper. Original Game import java.util.Scanner; public class Game { public static void main() { Scanner scan=new Scanner(System.in);
Java POWERED BY: ARVIND DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING RADHA GOVIND GROUP OF INSTITUTIONS,MEERUT.
The Point Class public class Point { public double x; public double y; public Point(double x0, double y0) { x = x0; y = y0; } public double distance(Point.
1 Calling within Static method /* We can call a non static method from a static method but by only through an object of that class. */ class Test1{ public.
Objects contains data and methods Class – type of object Create class first Then object or instance String – defined class String s; // creates instance.
Craps. /* * file : Craps.java * file : Craps.java * author: george j. grevera, ph.d. * author: george j. grevera, ph.d. * desc. : program to simulate.
Interfaces CSC 171 FALL 2004 LECTURE 14. Project 1 review public class Rational { private int numerator, denominator; public Rational(int numerator, int.
Chapter 2 Programming by Example. A Holistic Perspective Three sections separated by blank lines. Program comment File: FileName.java
METHOD OVERRIDING Sub class can override the methods defined by the super class. Overridden Methods in the sub classes should have same name, same signature.
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved.1 Chapter 3 Selections.
Övning 4. Repetition göra egna klasser class Rektangel { private double längd; private double bredd; public Rektangel(double l, double b) { this.längd.
Övning 5. Repetition klasser class Rektangel { private static int antal = 0; private double längd; private double bredd; public Rektangel(double l, double.
Introduction to C# Erick Pranata © Sekolah Tinggi Teknik Surabaya 1.
GUI programming AWT(Abstract Windows Toolkit)-GUI components library when Java was introduced AWT was replaced by Swing components import javax.swing.*;
May 11, 1998CS102-02Lecture 7-1 More Graphics in Java CS Lecture 7-1 A picture's worth a thousand words.
A Simple Applet --- Digital Clock import java.awt.*; import java.util.Calendar; public class DigitalColok extends java.applet.Applet implements Runnable.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 12 GUI Basics.
Random (1) Random class contains a method to generate random numbers of integer and double type Note: before using Random class, you should add following.
Topics AWT Classes Window Fundamentals Working with Frame Windows Creating a Frame Window in an Applet Creating a Windowed Program Displaying Information.
WEB PAGES: CREATING AND MAINTAINING ** Tom Keane & Mayis SeapanInstructors: HTML Tags to format your text.
Web Typography Serif and sans serif fonts  Serifs are the tails on the letters  Serif leads the eye from letter to letter  At large font sizes, the.
Applets CS 3331 Sections 3.3 & 4.7 of [Jia03].
2D Graphics: Rendering Details
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Standard Graphics in Java.
Text and Fonts in CSS. Customizing fonts In CSS, fonts are divided into “font families” Only certain fonts are commonly installed on most computers Therefore.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Creating GUIs in Java Using.
GUI Basics.
Zhang & Liang, Computer Graphics Using Java 2D and 3D (c) 2007 Pearson Education, Inc. All rights reserved. 1 Chapter 3 2D Graphics: Rendering Details.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 12 GUI Basics.
Applets & Graphics. Applets programs that run inside a browser Java platform-independence makes applets possible security restrictions: –cannot read or.
10/24/20151 Java GUI Programming. 10/24/20152 What is a GUI? Java has standard packages for creating custom Graphical User Interfaces Some of the fundamental.
CSc2310 tutoring session, week 8 Fall, 2012 Haidong(Haydon) Xue 5:30pm—8:30pm 11/27/2012 and 11/28/2012 -Class Members vs Instance Members.
1 Operators and Expressions Instructor: Mainak Chaudhuri
Painting (Chapter 12) Java Certification Study Group January 25, 1999 Mark Roth.
CSS FONT STACKS. What are font stacks? Font stacks are about creating a relevant and comprehensive list of fall-back fonts.
Font:  Text of a certain design, available in hundreds of varieties.  Called typeface. Style:  The way a font looks: Bold, Italic, regular Points: 
AWT Java AWT (Abstract Windowing Toolkit) is an API to develop GUI or window-based application in java. Java AWT components are platform-dependent i.e.
Getting Started with GUI Programming Chapter 10 CSCI 1302.
Programming – Lecture 15 Going Beyond the ACM Library.
OPERATOR Dalam Java.
using System; namespace Demo01 { class Program
Chapter 14 GUI Basics.
Maha AlSaif Maryam AlQattan
TO COMPLETE THE FOLLOWING:
Java Lesson 36 Mr. Kalmes.
Recursive GCD Demo public class Euclid {
References and Objects
class PrintOnetoTen { public static void main(String args[]) {
Chapter 17.
A Java Application public class Hello { public static void main(String [] args) { System.out.println("Hello, World!"); } } public class.
A Java Application public class Hello { public static void main(String [] args) { System.out.println("Hello, World!"); } } public class.
Chapter 9.
Chapter 12 GUI Basics.
Presentation transcript:

Pertemuan 2 Teknik Animasi 2D dan 3D

In Java 2D you can use the same logical font names as in Java 1 In Java 2D you can use the same logical font names as in Java 1.1, namely, Serif (e.g., Times), SansSerif (e.g., Helvetica or Arial), Monospaced (e.g., Courier), Dialog, and DialogInput.

However, you can also use arbitrary local fonts installed on the platform if you first look up the entire list, which may take a few seconds.

Look up the fonts with the getAvailableFontFamilyNames or getAllFonts methods of GraphicsEnvironment

GraphicsEnvironment env = GrapicsEnvironment GraphicsEnvironment env = GrapicsEnvironment.getLocalGraphicsEnvironment(); Then, add env.getAvailableFontFamilyNames(); or env.getAllFonts(); // Much slower!

import java. awt. ; /. Lists the names of all available fonts import java.awt.*; /** Lists the names of all available fonts. */ public class ListFonts { public static void main(String[] args) { GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); String[] fontNames = env.getAvailableFontFamilyNames(); System.out.println("Available Fonts:"); for(int i=0; i<fontNames.length; i++) System.out.println(" " + fontNames[i]); }

import java.awt.*; /** An example of using local fonts to perform drawing in * Java 2D */ public class FontExample extends GradientPaintExample { public FontExample() { GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); env.getAvailableFontFamilyNames(); setFont(new Font("Goudy Handtooled BT", Font.PLAIN, 100)); }

protected void drawBigString(Graphics2D g2d) { g2d. setPaint(Color protected void drawBigString(Graphics2D g2d) { g2d.setPaint(Color.black); g2d.drawString("Java 2D", 25, 215); } public void paintComponent(Graphics g) { clear(g); Graphics2D g2d = (Graphics2D)g; drawGradientCircle(g2d); drawBigString(g2d);

public static void main(String[] args) { WindowUtilities public static void main(String[] args) { WindowUtilities.openInJFrame(new FontExample(), 380, 400); }

Join Styles JOIN_MITER JOIN_BEVEL JOIN_ROUND

Cap Styles CAP_SQUARE CAP_BUTT CAP_ROUND