2D API / CATATAN</>↗2D API21 Mei 2012
Arc2D is the abstract superclass for all objects that store a 2D arc defined by a framing rectangle, start angle, angular extent (length of the arc), and a closure type (Arc2D.OPEN, Arc2D.CHORD, or Arc2D.PIE). To constructs a new arc in double values, such as defining the specified location, size, angular extents, and closure type we […]
2D API / CATATAN</>↗2D API21 Mei 2012
The Ellipse2D class define an ellipse that is defined by a framing rectangle. You can create an ellipse using a double or float values. When creating an ellipse using double values use the Ellipse2D.Double class. And for the float values you can use the Ellipse2D.Float class. package org.kodejava.awt.geom; import javax.swing.*; import java.awt.*; import java.awt.geom.Ellipse2D; public […]
2D API / CATATAN</>↗2D API21 Mei 2012
package org.kodejava.awt.geom; import javax.swing.*; import java.awt.*; import java.awt.geom.GeneralPath; public class DrawGeneralPath extends JComponent { public static void main(String[] args) { JFrame frame = new JFrame("Draw GeneralPath Demo"); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.getContentPane().add(new DrawGeneralPath()); frame.pack(); frame.setSize(new Dimension(420, 400)); frame.setVisible(true); } @Override public void paint(Graphics...
2D API / CATATAN</>↗2D API20 Mei 2012
The RoundRectangle2D class defines a rectangle with rounded corners defined by a location (x,y), dimension (w x h), and the width and height of an arc with which to round the corners. The RoundRectangle2D.Double class constructs a RoundRectangle2D from the specified values in double, including the location, width and the arch of the round rectangle. […]
2D API / CATATAN</>↗2D API20 Mei 2012
The code snippet below show you how to use the Graphics2D class the draw a rectangle. You can see the snippet in the paintComponent(Graphics g) method defined in the anonymous JPanel object. To draw a rectangle we use the Rectangle2D.Double static-inner class. The constructor of this class accept the information about the rectangle x, y […]
2D API / CATATAN</>↗2D API20 Mei 2012
The following code snippet show you how to draw a simple line using Graphics2D.draw() method. This method take a parameter that implements the java.awt.Shape interface. To draw a line we can use the Line2D.Double static-inner class. This class constructor takes four integers values that represent the start (x1, y1) and end (x2, y2) coordinate of […]