In this section, you will study how to show the clip.
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.
In the example, we have defined buttons to call the action. The FontRenderContext class is used to measure the text. The Font class represents fonts, which are used to render text. We have defined a font 'Monotype Corsiva' for a clip. The class GeneralPath is defined to show the clip in the specified shape. To give the styled character data for the graphics representation, we have used the class TextLayout. The AffineTransform class allows translations, scales, flips, rotations, and shears.
The method getTranslateInstance(0,90) returns a transform representing a translation transformation. The method getOutline() returns the shape.
Following code draw the 90 lines:
| final int LINES = 90; Point2D point1 = new Point2D.Double(2, 2); for (int k = 0; k < LINES; k++) { double x = (2 * getWidth() * k) / LINES; double y = (2 * getHeight() * (LINES - 1 - k)) / LINES; Point2D point2 = new Point2D.Double(x, y); g2.draw(new Line2D.Double(point1, point2)); |
Here is the code of ClipExample.java
import java.awt.*;
|
Output will be displayed as:

After clicking the button show clip, the clip will be shown as:

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Show Clippings View All Comments
Post your Comment