Related Tutorials


 
 

Share on Google+Share on Google+

Graphics 2D

Advertisement
Clip is an art which can be an image, graphics, picture, photograph, video or any illustration.

Graphics 2D

        

  1. Show Clippings
    Clip is an art which can be an image, graphics, picture, photograph, video or any illustration. We are providing you an example where we will show you the clippings.
      
  2. Clip Area
    In the given example, we have defined two buttons clip1 and clip2 to perform two actions. On clicking clip1, a Rectangle2D class shows the clip of  rectangular area and on clicking clip2,  Rectangle class (subclass of Rectangle2D) shows a rectangle inside the rectangular area.
      
  3. Noise Image in Graphics
    This Java Tutorial is all about creating Images with the use of graphics in Java. For this we have to import awt and swing package in our Java code.
      
  4. Event Dispatcher Thread
    In the tutorial Java Event Dispatcher thread in Graphics, we'll illustrate you how to handle events in graphics using Java.
      
  5. How to create Animation
    This section illustrates you how to create Animation. We are proving you an example defining a static variable DELAY of integer type. The object of Insets class is provides the representation of the borders i.e.
     
  6. Color Composite Example
    Composition is the process of combining two images. We are providing you an example. The Ellipse2D.Float  class provides an ellipse defining values of float type.
      
  7. Bouncing Thread Example
    In this section, we are going to develop a small Java Graphics application that creates a ball which bounce with the help of thread in Graphics.
      
  8. Use Alpha values to draw in Layers
    An alpha object produces the alpha value which changes with time specified by the parameters of the alpha object. The alpha value is the graphics state parameter that is used to composite objects to the existing page.
      
  9. Show Alpha Value and Alpha Rules
    To give blending and transparency effects with graphics and images and the alpha values, the class AlphaComposite is used. An alpha value of 0.0f makes the source disappear and 1.0f make it completely opaque.
      
  10. Show Addition, Subtraction, Intersection, Exclusive OR on one frame
    In this section, we are providing you an example which performs all the functions on one frame. Two classes Rectangle2D and Ellipse2D are used which provides rectangle and circle.
     
  11. Gradient Color Example
    Gradient Color is a tool bar which consists of different shades of color. We are providing you an example which shows the Gradient Color.
      
  12. How to show Rainbow Colors
    The Rainbow consists of seven colors known as VIBGYOR i.e. violet, indigo, blue, green, yellow, orange and red color. We are providing you an example which shows all the seven colors of rainbow.
     
  13. Show XOR Mode
    XOR or Exclusive Or returns true only if both its operands have different values. The XOR shows the uncommon part. We are providing you an example which shows the XOR mode.
      
  14. Simple Basic Stroke Example
    The stylistic representation of the outline for the specified shape has been given by the interface Stroke. To outline the specified shape rendered with an object of Graphics2D, we have used the BasicStroke class.
     
  15. Draw Dashed Oval
    To give the stylistic and impressive representation of the outline, we have used the class BasicStroke. This class has been given by the interface Stroke.
      
  16. Show Stroke with Effect
    The interface Stroke gives the stylish way of representing the outlines. To show the effect, class GradientPaint is used which fills the specified figure in a color gradient pattern.
      
  17. Outlining the font
    By outlining the font , we make the characters more stylish and impressive. We are providing you an example which outlines the text.
      
  18. Move Curve Control Point
    The Control points are the points on a curve which are used to change the shape and angle of the curve. On stretching and rotating the control point, the shape of the curve and the angle of a curve manipulates.
      
  19. Simple Font Paint Example
    A font is a specific style of displaying characters. It describes the design, size, appearance, weight, and spacing of a character. It is the combination of pitch and spacing.
     
  20. Draw different curves with QuadCurve2D
    In the given example, we have used Vector class to implement an array of objects. The components of this class can be accessed using an index.
     
  21. Clip of image
    To show the image clip, we have used Ellipse2D class to show the oval shape in an image. To give the path with straight line, we have used the class GeneralPath. The AffineTransform class allows translation, shearing, scaling, rotation etc.
      
  22. Show Oval Icons
    An icon is an image that shows some concept or specific entity with meaning for the user. To show Oval Icons, we have used the class Container.
     
  23. Display the Shadow of the string
    To display the shadow, we have used the class GradientPaint to draw a box. The g.setStroke(new BasicStroke(15)) draw the wide lines.
     
  24. Simple Gradient Paint Example
    A gradient refers to a colored strip with two defined endpoints. Both the end points are defined with different color.
     
  25. Round gradient Paint Example
    The radial gradient defines a color at a point, and blends into another color. We are providing you an example which displays the radial gradient.
     
  26. Another Example of Gradient Paint
    This section shows you the gradient Paint on rounded corner rectangle. A gradient is like a colored strip. It is created by specifying a color at one point and another color at another point.
      
  27. Show Text effect
    Text effect gives the stylistic way to design headings. To rotate the text, we have used AffineTransform class that defines different properties like rotation, translation, scaling and shearing etc.
      
  28. Text Texture Example
    Texture refers to the roughness of the smoothness of a work of art. The way in which you paint involves texture. A texture is a bitmap image applied to the surface in computer graphics.
     
  29. Show Graphics on full Screen
    To display the graphics, we have used the class DisplayMode which provides the bit depth, height, width, and refresh rate of a GraphicsDevice.
      
  30. Show String in Oval
    To show a string in oval, we are providing you an example. A font 'Book Antiqua' is defined to display the string 'WELCOME'. To render the particular font on the screen, we have used the class FontMetrics.
     
  31. Display Different Fonts
    A font is a specific style of displaying characters. It describes the design, size, appearance, weight, and spacing of a character. It is the combination of  pitch and spacing.
     
  32. How to display the font in center
    To display the font in center, the method paint() is defined. The Font class defines the font 'Monotype 'Corsiva'. The class FontRenderContext measures the text.
     
  33. Font Derivation
    Font derivation refers to the different styles provided by the font. The method deriveFont() provides different styles to the characters.
     
  34. Draw a Mandelbrot
    A Mandelbrot is a collection of points in the plane whose boundary forms a fractal. It is having a complicated structure, which does not simplify at any given magnification.
      
  35. Show Icon Displayer  
    An icon  is an image, picture, or representation. To display the icon, we have defined an image. The class ImageIcon is responsible to paint the icons from Images. The MediaTracker preloads the images that are created from a URL, filename or byte array.
      
  36. Show Calendar Icon
    An icon is a pictorial image used in a graphical user interface to represent a program, a command, a link to a Web page, etc. To show calendar icon, we have used the class Calendar.
      
  37. Icon showing Color Gradient
    A color gradient consisting of two or more colors blending together. To display the icon, we have defined the height and width of an image.
     
  38. Icon Changes at runtime
    To create an icon, we have defined Icon class which provides three methods getIconWidth(),  getIconHeight() and paintIcon(). We have defined two sliders using JSlider class to show the changes related to height and width of the icon.
      
  39. Crop Image
    To crop an image, an image is defined inside the class folder. The class ImageIcon calls its method getImage() which returns the specified image.
      
  40. Generate Image Files 
    This section illustrates you how to generate image files. For this, we have used the class ImageIO which provides methods for locating ImageReaders and ImageWriters. 
     
  41. Show Image Scale
    To show scales of Image, an image is defined inside the class folder and calls the ImageIcon class to return the image. The Insets class shows the border of a container which specifies the space leave at each of its edges.
     
  42. Display Image using Toolkit.getImage()
    To display the image, put an image into the folder where the class is specified. Class URL defines the resource. A resource can be a file or a directory.
     
  43. How to flip image
    To reverse the image, an image is put into the folder where class is specified. The getDefaultToolkit() method of ToolKit class provides the default toolkit. The method getImage() of class ToolKit returns an image.
      
  44. Show Image Effect
    To show Image effects, we have defined three matrix: RED_MATRIX, GREEN_MATRIX, BLUE_MATRIX  which shows colors.
      
  45. Show Other Image Effects
    To show image effects like sharpen, blur, show edge, reset ,etc, we have create radio buttons on which the action will be performed by calling ActionListener class.
     
  46. Affine Transform Example
    The sequences of translations, scales, flips, rotations, and shears are provided by the class AffineTransform. To show shearing, we are providing you an example.
      
  47. Use of Image I/O library
    The ImageIO class provides the method to read and write image. We are providing you an example which copies the specified input file into the output file.
      
  48. TextHitInfo Example
    In this section, we are providing you an example based on class TextHitInfo. In the given example, when you click the element of the string, TextHitInfo class will displayed the position of character on the console.
     
  49. Break a Line for text layout
    In this section, we are providing you an example to break a line. To break down the text into lines, the class LineBreakMeasurer is used. The class Hashtable maps keys to values.
     
  50. Show Image Reader and Image Writer by MIME Type
    To show the image reader and image writer by MIME Type, we have used ImageIO class of the package javax.imageio.*. The ImageIO class provides the methods for locating ImageReaders and ImageWriters.
      
  51. Show Image Reader and Image Writer by image format
    To show the image reader and image writer, we have used ImageIO class of the package javax.imageio.*. The ImageIO class provides methods for locating ImageReaders and ImageWriters.
     
  52. Show Transparent Text
    To draw the text, Font class is used. To show transparency over the specified text, the class AlphaComposite is used which shows the transparency effects with graphics.
     
  53. Draw text like a curve
    To draw the text, we have used the Font class which represents the font to render the text. The method getFontRenderContext() of class Graphics2D get the rendering context of the font specified.
     
  54. Show Textured Paint
    Texture refers to the roughness of the smoothness of a work of art. The way in which you paint involves texture. We are providing you an example that will show the textured paint.
      
  55. Show Different Strokes
    To give the the impressive and stylistic outline, class BasicStroke is used. The value passed in the constructor of the class BasicStroke shows the thickness of outline.
     
  56. Show General Path
    This section illustrates you how to create GeneralPath. We have used the class GeneralPath to create three different shapes. For this, we have create three objects of class GeneralPath i.e, path1, path2, path3.
      
  57. Mouse Drag and Drop
    To draw a figure using drag and drop, we have used Rectangle2D class to draw a rectangle. This rectangle has been shown on the frame. When you drag the rectangle and move, a number of figures will be drawn connected to each other.
      
  58. Draw Polygon in Graphics
    A polygon is a closed path or circuit which is made by joining line segments. In polygon, each line segment intersects exactly two others line segments. To draw a polygon, we have used the Polygon class.
      
  59. Draw An Arc in Graphics
    An arc of a circle is a segment of the circumference of the circle. To draw an arc, class Arc2D is used. To give the stylistic and impressive way to the outline of arc, we have used BasicStroke class.
     
  60. Draw Ellipse in Rectangle
    To draw an Ellipse inside the rectangle, we have defined two classes Rectangle2D and Ellipse2D of package java.awt.geom.*. These classes provides a rectangle and a circle respectively.
      
  61. Draw a Triangle using a Line2D
    To draw a triangle, we are using Line2D class of package java.awt.geom.*. This class provides a line segment in (x, y) coordinate space. We have draw three line segments using the class Line2D to create a triangle. 
     
  62. Show Color Components
    To show color components, we have used the class DirectColorModel. The DirectColorModel class shows pixel values that represent RGB color and alpha information and pack into a single int, short, or byte quantity.
     
  63. Draw Grids
    To draw the grids, we have defined rows and columns. The method g.drawLine(0, k * heightOfRow, width, k * heightOfRow) draws the number of rows.
      
  64. Different Line Styles
    To show different styles of line, we have used BasicStroke class. The class BasicStroke provides several line drawing attributes: the line width, the dash pattern, the end cap style for the line, and the join style for the line. 
      
  65. Change Color and Font of text
    This section illustrates you how to change color and font of text using TextAttributes class. A string is defined and the class AttributedString holds the string.
     
  66. Layout text along a line using LineMetrics
    This section illustrates you how to layout text along a line. For this, class LineMetrics is used which layouts the text along a line. The Font class represents the font.
     
  67. Show Coordinates
    In this section, we are going to display a frame where we have draw the grid. As the user move or click the cursor with the mouse over the grid, a label displays the location of cursor,  i.e., shows coordinates with respect to x-axis and y-axis.
      
  68. Show Translation property of class AffineTransform
    To show translation, we have used Ellipse2D class to draw the oval. The method getTranslateInstance() returns the translation transformation.
     
  69. Show Rotation property of class AffineTransform
    To show rotation, we have used Ellipse2D class to draw the shape oval. The method getTranslateInstance() returns the translation transformation.
     
  70. Show Scaling property of class AffineTransform
    To show the scaling, we have used Ellipse2D class to draw the oval. The method getTranslateInstance() returns the translation transformation.
      
  71. Show Shearing property of class AffineTransform
    To show the shearing, we have used Ellipse2D class to draw the oval. The method getTranslateInstance() returns the translation transformation.
Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: December 14, 2008

Related Tutorials

Discuss: Graphics 2D  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:1
pradeep
January 19, 2012
GOOD

GOOD
DMCA.com