transformation

Class AnimatedArrow

Implemented Interfaces:
ActionListener

public class AnimatedArrow
extends java.lang.Object
implements ActionListener

class for drawing animated arrows. Start by placing method drawAnimatedArrow() in the paintComponent() method of JPanel panel. Now every millisecond*speed, Timer t fires an ActionEvent which causes one single arrow to be painted.

Field Summary

static int
FAST
static int
MEDIUM
static int
SLOW
private Font
arrowFont
private int
counter
private boolean
finished
private boolean
firstTime
private double
gradient
private Point
p1
private Point
p2
private int
pace
private JPanel
panel
private int
speed
private Font
stringFont
private Timer
t

Constructor Summary

AnimatedArrow(JPanel p)

Method Summary

void
actionPerformed(ActionEvent e)
handels the ActionEvents that are fired every milli-second by Timer t
void
drawAnimatedArrow(Graphics g, Point p1, Point p2, String s)
starts drawing an animated Arrow from Point p1 to Point p2; is to be placed in the paintComponent method of the calling JPanel
void
drawArrow(Graphics g, Point p, String s)
draws an arrow from point p1 to point p
boolean
finished()
boolean
isRunning()
void
reset()
void
restartTimer()
void
setSpeed(int speed)
void
stopTimer()

Field Details

FAST

public static final int FAST
Field Value:
5

MEDIUM

public static final int MEDIUM
Field Value:
10

SLOW

public static final int SLOW
Field Value:
20

arrowFont

private Font arrowFont

counter

private int counter

finished

private boolean finished

firstTime

private boolean firstTime

gradient

private double gradient

p1

private Point p1

p2

private Point p2

pace

private int pace

panel

private JPanel panel

speed

private int speed

stringFont

private Font stringFont

t

private Timer t

Constructor Details

AnimatedArrow

(package private)  AnimatedArrow(JPanel p)
Parameters:
p - TransformationPanel where to draw on

Method Details

actionPerformed

public void actionPerformed(ActionEvent e)
handels the ActionEvents that are fired every milli-second by Timer t

drawAnimatedArrow

public void drawAnimatedArrow(Graphics g,
                              Point p1,
                              Point p2,
                              String s)
starts drawing an animated Arrow from Point p1 to Point p2; is to be placed in the paintComponent method of the calling JPanel
Parameters:
g - Graphics object of the calling JPanel
p1 - starting Point
p2 - ending Point
s - String which is to be painted in front of the arrowhead

drawArrow

public void drawArrow(Graphics g,
                      Point p,
                      String s)
draws an arrow from point p1 to point p
Parameters:
g - Graphics object of the calling JPanel
p - ending Point of the arrow
s - String which is painted in front of the arrowhead

finished

public boolean finished()

isRunning

public boolean isRunning()

reset

public void reset()

restartTimer

public void restartTimer()

setSpeed

public void setSpeed(int speed)

stopTimer

public void stopTimer()