Java Design Targets To comprehend Representation connections and articles To have the capacity to control hues and textu.


88 views
Uploaded on:
Category: Product / Service
Description
Java Design Goals To comprehend Representation settings and items To have the capacity to control hues and textual styles To have the capacity to comprehend and utilize the Illustrations techniques The Co-ordinate Framework (0,0) X pivot (x,y) Y hub Design Connections and Design Objects
Transcripts
Slide 1

Java Graphics Objectives To comprehend Graphics connections and articles To have the capacity to control hues and text styles To have the capacity to comprehend and utilize the Graphics strategies

Slide 2

The Co-ordinate System (0,0) X pivot (x,y) Y hub

Slide 3

Graphics Contexts and Graphics Objects A Java Graphics Context empowers drawing on the screen. A Graphics item deals with a controlling so as to set how data is drawn. Consider the accompanying system found in Applets: open void paint(Graphics g) g speaks to a reference to the Graphics article dealing with the applets graphics setting. The paint strategies is not regularly utilized straightforwardly by the software engineer.

Slide 4

Should a software engineer need to constrain paint , a call to the repaint strategy may be made. repaint() ; This makes a call to the component’s redesign technique which will call paint straightforwardly Color Control Colors are characterized and controlled in Java through class Color . Consistent shading qualities are characterized in this class. New hues may be defined utilizing RGB qualities: Color c = new Color(128, 128, 128) ;//Gray

Slide 5

Displaying Colors in an Applet import java.awt.*; import javax.swing.*; open class ShowColours augments JApplet { open void paint(Graphics g) {/set new shading utilizing whole numbers g.setColor( new Color(255, 0 , 0) ) ; g.fillRect(25, 25, 100, 20) ; g.drawString( "Current RGB: "+g.getColor(), 130, 40) ;/set new drawing shading utilizing static shading items g.setColor(Color.blue) ; g.fillRect(25, 50, 100, 20) ; g.drawString( "Current RGB: "+g.getColor(), 130, 65) ; }

Slide 6

Font Control import javax.swing.*; import java.awt.*; open class FontTest broadens JApplet { open void paint(Graphics g) {/set textual style to Serif (Times), striking, 12pt g.setFont( new Font("Serif", Font.BOLD, 12) ) ; g.drawString( "Serif 12 point bold.", 20, 50) ;/set text style to monspaced (dispatch), italic, 24pt g.setFont( new Font("Monospaced",Font.ITALIC,24)); g.drawString( "Monospaced 24 point italic.",20,70);/set text style to Serif, bold+italic, 24pt g.setFont( new Font("Serif", Font.BOLD+Font.ITALIC, 24) ) ; g.drawString( "Serif 24 point intense and italic.", 20, 90) ; }

Slide 7

Font Metrics Class FontMetrics characterizes strategies which give estimation information around a textual style. Text style f = …… FontMetrics fm = f.getFontMetrics() ; int a = fm.getAscent() ; int d = fm.getDescent() ; int h = fm.getHeight() ; driving Xy1㔠tallness rising plummet

Slide 8

Lines, Rectangles and Ovals open void drawLine(int x1, int y1, int x2, int y2) g.drawLine(10,10,20,20) ; open void drawRect(int x, int y, int width, int stature) g.drawRect(10,10,20,20) ; open void fillRect(int x, int y, int width, int tallness) g.fillRect(10,10,20,20) ; open void drawRoundRect(int x, int y, int w, int h, int aw, int ah) g.drawRoundRect(10,10,20,20,5,5) ;

Slide 9

import javax.swing.*; import java.awt.*; open class GraphicsTest develops JApplet { open void paint(Graphics g) { g.drawLine(10,10,20,20) ; g.drawRect(10,40,20,20) ; g.fillRect(10,70,20,20) ; g.drawRoundRect(10,100,20,20,5,5) ; g.drawRoundRect(10,130,100,100,20,20) ; g.drawOval(10,210,20,20) ; g.fillOval(10,240,20,20) ; }

Slide 11

.:

Recommended
View more...