animation.tr

Class NetPaint

Implemented Interfaces:
MouseListener, MouseMotionListener

(package private) class NetPaint
extends Canvas
implements MouseMotionListener, MouseListener

class to paint the network and to handle the settings of animation

Field Summary

static Color[]
COLOURS
private static int
MAXSTATIONS
private static int
anz
private Graphics
bg
private Image
buffer
private int
farbnr
int
maxComponentHeight
int
maxComponentWidth
private static String
messageText
Image
monitorNode
Image
normalNode
private PopupMenu
pm
private int
receiveStation
private int
selectmode
private int
sendStation
private boolean
sendmode
(package private) Station[]
st
(package private) TokenRing
sta
(package private) TokenThread
t

Constructor Summary

NetPaint(TokenRing s)
Constructor initializes the first two stations and sets some variables

Method Summary

boolean
addStation()
Puts a new station on the ring and sets the initial values
int
find(int x, int y)
int
getAnz()
int
getMonitor()
void
mouseClicked(MouseEvent e)
void
mouseDragged(MouseEvent e)
void
mouseEntered(MouseEvent e)
void
mouseExited(MouseEvent e)
void
mouseMoved(MouseEvent e)
void
mousePressed(MouseEvent e)
void
mouseReleased(MouseEvent e)
void
paint(Graphics g)
Main paint routine draws all graphics
boolean
removeStation()
Removes a station off the ring
void
sendestop()
Stops putting data frames on the ring
void
sendoff(int sendnr, int recnr)
Erases the frame of sending and receiving station
void
setMessageText(String text)
Prints a red colored message line in the center
void
setSelectMode(int mode)
Sets what a mouse click on a station will produce
void
setsend(boolean sm)
void
startanim(int slt, int ao)
Generates the tokenclass and starts the whole animation
void
stopanim()
Stops the animation and sets the initial values
boolean
token_lives()
void
update(Graphics g)

Field Details

COLOURS

public static final Color[] COLOURS

MAXSTATIONS

private static final int MAXSTATIONS

anz

private static int anz

bg

private Graphics bg

buffer

private Image buffer

farbnr

private int farbnr

maxComponentHeight

public final int maxComponentHeight

maxComponentWidth

public final int maxComponentWidth

messageText

private static String messageText

monitorNode

public final Image monitorNode

normalNode

public final Image normalNode

pm

private PopupMenu pm

receiveStation

private int receiveStation

selectmode

private int selectmode

sendStation

private int sendStation

sendmode

private boolean sendmode

st

(package private)  Station[] st

sta

(package private)  TokenRing sta

t

(package private)  TokenThread t

Constructor Details

NetPaint

public NetPaint(TokenRing s)
Constructor initializes the first two stations and sets some variables

Method Details

addStation

public boolean addStation()
Puts a new station on the ring and sets the initial values

find

public int find(int x,
                int y)
Parameters:
Returns:
>= 0 if cursor is over a station

getAnz

public int getAnz()
Returns:
the amount of stations

getMonitor

public int getMonitor()

mouseClicked

public void mouseClicked(MouseEvent e)

mouseDragged

public void mouseDragged(MouseEvent e)

mouseEntered

public void mouseEntered(MouseEvent e)

mouseExited

public void mouseExited(MouseEvent e)

mouseMoved

public void mouseMoved(MouseEvent e)

mousePressed

public void mousePressed(MouseEvent e)

mouseReleased

public void mouseReleased(MouseEvent e)

paint

public void paint(Graphics g)
Main paint routine draws all graphics

removeStation

public boolean removeStation()
Removes a station off the ring

sendestop

public void sendestop()
Stops putting data frames on the ring

sendoff

public void sendoff(int sendnr,
                    int recnr)
Erases the frame of sending and receiving station
Parameters:
sendnr - number of sending station
recnr - number of receiving station

setMessageText

public void setMessageText(String text)
Prints a red colored message line in the center
Parameters:
text - the message

setSelectMode

public void setSelectMode(int mode)
Sets what a mouse click on a station will produce
Parameters:
mode - the selection mode:
  • 1: sending or receiving station
  • 2: station on or off
  • 3: select monitor

  • setsend

    public void setsend(boolean sm)
    Parameters:
    sm - is true if the animation is started

    startanim

    public void startanim(int slt,
                          int ao)
    Generates the tokenclass and starts the whole animation

    stopanim

    public void stopanim()
    Stops the animation and sets the initial values

    token_lives

    public boolean token_lives()
    Returns:
    true if the whole animation is started

    update

    public void update(Graphics g)