Hark, An Arc!
When you instanciate a Graphics2D object, you enable yourself to refer
to a bunch of interesting methods having to do with portions of
circles. A portion of a circle is called an arc, and the Graphics2D
object enables to you use arcs in three interesting ways:
* As open arcs, with no connections between their endpoints.
* As chorded arcs, with a chord (a straight line through what would
be the inside of the circle, were it complete) connecting the
arc's endpoints.
* As the basis for a pie (really a pie-slice, most of the time),
which is an arc with line segments connecting its endpoints to
the center of the circle that defines the arc.
Here's a little program illustrating the variations on the arc theme:
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
class Arcs extends Frame {
public static void main(String arg[]) {
new Arcs();
}
Arcs() {
super("Arcs");
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e)
{ System.exit(0); } } );
setSize(350,330);
show();
}
public void paint(Graphics g) {
Graphics2D g2 = (Graphics2D)g;
Arc2D chord = getArcChord();
Arc2D open = getArcOpen();
Arc2D pie = getArcPie();
AffineTransform at = new AffineTransform();
// First row
at.setToTranslation(10.0,30.0);
g2.setTransform(at);
g2.draw(pie);
at.setToTranslation(120.0,30.0);
g2.setTransform(at);
g2.draw(open);
at.setToTranslation(230.0,30.0);
g2.setTransform(at);
g2.draw(chord);
// Second row
at.setToTranslation(10.0,60.0);
g2.setTransform(at);
pie.setAngleExtent(-135.0);
g2.draw(pie);
at.setToTranslation(120.0,60.0);
g2.setTransform(at);
open.setAngleExtent(-135.0);
g2.draw(open);
at.setToTranslation(230.0,60.0);
g2.setTransform(at);
chord.setAngleExtent(-135.0);
g2.draw(chord);
// Third row
at.setToTranslation(10.0,190.0);
g2.setTransform(at);
pie.setAngleStart(45.0);
pie.setAngleExtent(270.0);
g2.draw(pie);
at.setToTranslation(120.0,190.0);
g2.setTransform(at);
open.setAngleStart(45.0);
open.setAngleExtent(270.0);
g2.draw(open);
at.setToTranslation(230.0,190.0);
g2.setTransform(at);
chord.setAngleStart(45.0);
chord.setAngleExtent(270.0);
g2.draw(chord);
}
private Arc2D getArcPie() {
Arc2D.Float arc = new Arc2D.Float(
0.0f,0.0f,
100.0f,100.0f,
0.0f,45.0f,
Arc2D.PIE);
return(arc);
}
private Arc2D getArcChord() {
Arc2D.Float arc = new Arc2D.Float(
0.0f,0.0f,
100.0f,100.0f,
0.0f,45.0f,
Arc2D.CHORD);
return(arc);
}
private Arc2D getArcOpen() {
Arc2D.Float arc = new Arc2D.Float(
0.0f,0.0f,
100.0f,100.0f,
0.0f,45.0f,
Arc2D.OPEN);
return(arc);
}
}
» posted by ITworld staff
ITworld
Symantec Backup Exec 12 and Backup Exec System Recovery 8 deliver industry leading Windows data protection and system recovery. Download this whitepaper to find out the top reasons to upgrade and how to get continuous data protection and complete system recovery.
Data and system loss — from a hard drive failure, malicious attack, natural disaster, or simple human error — can happen anytime. Don’t leave your business vulnerable. Make sure you have a secure recovery strategy in place. Symantec's latest backup and system recovery technology can efficiently restore critical applications, individual emails and documents and even restore your entire system in minutes in the event of a loss.
Businesses face a growing challenge to ensure that the IT environment is properly protected. Backup Exec 12 integrates with other applications in the Symantec family of products, to complement your current data protection strategy, keep your data securely backed up and make it recoverable when you need it most.
Enterprise 2.0 Implementation
By Aaron C. Newman, Jeremy Thomas
Published by McGraw-Hill
Learn more!
Deploying Cisco Wide Area Application Services
By Zach Seils, Joel Christner
Published by Cisco Press
Learn more!








