Home | Ajax | BioInformatics | Dojo | EAI | EJB | Hibernate | J2ME | Java | Java Glossary | Java Servlets | JavaScript | Jboss | JDBC | JDO | Jmeter | JSF | JSP | JUnit | Maven | MySQL | Spring Framework | SQL | Struts | Technology | WAP | Web Services | XML


 
  
 
Programming Tutorials: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML
 

 
Facing Programming Problem?
Ask Questions?, Browse Latest Questions, Question-Answer Guidelines
Java
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments

Add RenderingHints to a Graphics

                         

This Java tutorial teaches you about adding the rendering hints to a graphics on the frame. The rendering hints uses the Graphics2D and creates the following image.

Description of program:

This program uses the Graphics2D class for rendering hints and draw or construct the given following image.

Description of code:

Graphics2D():
This is the constructor of Graphics2D class that extends the Graphics class to provide 

KEY_ANTIALIASING:    
This is an antialiasing hint key.

VALUE_ANTIALIAS_ON:
This is a antialiasing hints values and rendered with it.

setRenderingHint():
This method sets the values in Graphics2D object for rendering algorithm.

GradiantPaint(float x1, float y1, Color col1, float x2, float y2, Color col2):
This is the constructor of GradiantPaint class that provides a way for filling the shapes with gradient color pattern. It creates the simple acyclic GradientPaint object. It takes the following arguments:

        x1: This is the x coordinate of first specified point.
        y1: This is the y coordinate of first specified point.
        col1: This is the color of first specified point.
        x2: This is the x coordinate of second specified point.
        y2: This is the y coordinate of second specified point.
        col2: This is the color of second specified point.

Ellipse2D():
This is the constructor of an abstract class Ellipse2D that defines bounding rectangle and constructs an ellipse. 

transform():
This is the constructor of Transform Class. This is an abstract class that transform
a source tree into a tree result.

Here is the code of program:

import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;

public class RanderingHintsGraphics extends Frame{
  public static void main(String[] args) {
    new RanderingHintsGraphics();
  }
  public RanderingHintsGraphics(){
    setTitle("Add RenderingHints to a Graphics");
    setSize(300,200);
    setVisible(true);
    addWindowListener(new WindowAdapter(){
      public void windowClosing(WindowEvent we){
        System.exit(0);
      }
    });
  }
  public void paint(Graphics g){
    Graphics2D d = (Graphics2D)g;
    d.setRenderingHint(
RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON
);
    GradientPaint gpaint = new GradientPaint(
       
5080, Color.gray,50110, Color.lightGray);
        Ellipse2D el = new Ellipse2D.Double(530280160);
        d.setPaint(gpaint);
        d.fill(el);
    double rotation = Math.PI/8;
    d.transform(AffineTransform.getRotateInstance(rotation));
    Font font = new Font("Serif", Font.TRUETYPE_FONT, 50);
        d.setFont(font);
        d.setPaint(Color.white);
    String str = "RoseIndia";
        d.drawString(str,80,60);
  }
}

Download this example.

Output of program:

                         

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Latest Searches:
Filter
Using Design Patterns
validate radio button
netbeans jsp
Struts1.3 tutorials do
ip address programming
Visual Basic Networkin
Javascript Randomizing
Flash Animation Tweeni
jfreechart
Applet
ghdfgsdf
iterator
builb.xml
javascript connect db
file search in directo
Java Chart Designer
Date in JSP
examples with list
how to get the row and
ejp
struts2 checkbox
contact
Oracle forms
request.setAttribute
Java Pass Value
jsp registration form
If tag Struts2
ArrayList
permutation
jsp drop down menu
Create table and inser
checkbox button enable
make programs
DOJO
Inserting data from gu
Java example program t
date month year day
finding max min array
using jacob.jar in jsp
how to read key value
file chooser
panelGrid/
Second-generation aspe
java set methods
java arrays
Java Read File Line by
input values from cmd
text_io.file_type
JMF
.setDocument(new
select a row in jsp
max length 500 chars
Photoshop Christmas Ba
analog
modified
HQL find
Photoshop Textures and
jsf action form
popup in jsp
how to edit a any file
PHP Creating a Mail Fo
jstl basics tomcat
Get average in Array
Date
two date picker diff
excel from java
Add listener to compon
load file
java thread
Eclipse 3.4 EJB
shell
mysql blob
jstl list size
refid in sql select st
how to read xml file i
FileInputStream
hibernate connection p
add a list box in a fo
Logger
Java String toLowerCase Example
Java String toCharArray Example
Java String substring Example
Java String indexOf Example
Java String startsWith Example
Java String hashCode Example
Java String matches Example
Java String length Example
Java String lastIndexOf Example
Java String isEmpty Example
Java String equalsIgnoreCase Example
Java String equals Example
Java String endsWith Example
Java String copyValueOf Example
Java String contentEquals Example
  EAI Articles
  Java Certification
Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.