Académique Documents
Professionnel Documents
Culture Documents
Seminar Project
Submitted by
Md Suhel Azam Roll no#EC200118097
Overview Of Presentation
National Institute of Science & Technology
• What is JGL?
• A set of Java GUI components from Sun
• Included starting with Java 2 SDK1.4.2
• Part of the Java Foundation Classes (JFC)
• The graphics library defines a number of drawing
function, java2d api, java 3d api.
• This graphics class contains two types of subclasses;
those are Debug graphics, Graphics2D.
Graphics Class
National Institute of Science & Technology
• The Graphics class is the abstract base class for all graphics
contexts that allow an application to draw onto components
that are realized on various devices, as well as onto off-screen
images.
• A Graphics object encapsulates state information needed for
the basic rendering operations that Java supports
• This state information includes the following properties:
The Component object on which to draw.
A translation origin for rendering and clipping coordinates.
The current clip.
The current color.
The current font.
The current logical pixel operation function (XOR or Paint).
Graphics library
National Institute of Science & Technology
Constructor Detail
•Graphics
protected Graphics()
Constructs a new Graphics object. This constructor is the
default constructor for a graphics context. Since Graphics is an
abstract class, applications cannot call this constructor directly.
Graphics contexts are obtained from other graphics contexts or
are created by calling getGraphics on a component.
Graphics library
National Institute of Science & Technology
Method Detail
• create
public abstract Graphics create()
translate
public abstract void translate(int x, int y)
• getColor
public abstract Color getColor()
• SetColor
public abstract Color getColor()
• setXORMode
public abstract void setXORMode(Color c1)
• getFont
public abstract Font getFont()
Method Detail
National Institute of Science & Technology
• setFont
public abstract void setFont(Font font)
• clipRect
public abstract void clipRect(int x, int y, int width, int height)
• setClip
public abstract void setClip(int x, int y, int width, int height)
• getClip
public abstract Shape getClip()
• setClip
public abstract void setClip(shape clip)
• drawLine
public abstract void drawLine(int x1, int y1, int x2, int y2)
Method Detail
National Institute of Science & Technology
• fillRect
public abstract void fillRect(int x, int y, int width, int height)
• drawRect
public void drawRect(int x, int y, int width, int height)
• drawOval
public abstract void drawOval(int x, int y, int width, int height)
• drawArc
public abstract void drawArc(int x, int y, int width, int height, int startAngle,
int arcAngle)
• drawPolyline
public abstract void drawPolyline(int[] xPoints, int[] yPoints, int nPoints)
• drawPolygon
public abstract void drawPolygon(int[] xPoints, int[] yPoints, int nPoints)
Md. Suhel Azam
Graphics Library in JAVA
Method Detail
National Institute of Science & Technology
• drawString
public abstract void drawString(String str, int x, int y)
• drawChars
public void drawChars(char[] data, int offset, int length, int x, int y)
• drawImage
public abstract boolean drawImage(Image img, int x, int y,
ImageObserver observer)
• dispose
public abstract void dispose()
• getClipRect
public Rectangle getClipRect()
Graphics2D
National Institute of Science & Technology
Graphics2D
National Institute of Science & Technology
•Rendering Process
The Rendering Process can be broken down into four
phases that are controlled by the Graphics2D rendering attributes.
The three types of rendering operations are:
•Shape operations
•Text operations
•Image Operations
Graphics2D Library
National Institute of Science & Technology
Constructor Detail
• Graphics2D
protected Graphics2D()
Constructs a new Graphics2D object.
Method detail
• draw3DRect
public void draw3DRect(int x,int y,int width,int height,
boolean raised)
• fill3DRect
public void fill3DRect(int x, int y, int width, int height, boolean raised)
• draw
public abstract void draw(Shape s)
• drawString
public abstract void drawString(String str, int x, int y)
Method Detail
National Institute of Science & Technology
• drawRenderedImage
public abstract void drawRenderedImage(RenderImage img,
AffineTransform xform)
• drawGlyphVector
public abstract void drawGlyphVector(GlyphVector g,
float x, float y)
• fill
public abstract void fill(Shape s)
• hit
public abstract boolean hit(Rectangle rect, shape s, boolean onStroke)
• getDeviceConfiguration
public abstract GraphicsConfiguration getDeviceConfiguration()
Method Detail
National Institute of Science & Technology
• setComposite
public abstract void setComposite(Composite comp)
• setPaint
public abstract void setPaint(Paint paint)
• getBackground
public abstract Color getBackground()
• setBackground
public abstract void setBackground(Color color)
• shear
public abstract void shear(double shx, double shy)
• scale
public abstract void scale(double sx, double sy)
Method Detail
National Institute of Science & Technology
• rotate
public abstract void rotate(double theta, double x, double y)
• translate
public abstract void translate(double tx, double ty)
• setPaint
public abstract void setPaint(Paint paint)
• setRenderingHint
public abstract void setRenderingHint(RenderingHints.Key hintKey,
Object hintValue)
• getRenderingHint
public abstract Object getRenderingHint(RenderingHints.Key hintKey)
• addRenderingHints
public abstract void addRenderingHints(Map hints)
Conclusion
National Institute of Science & Technology