You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.7 KiB
Java
59 lines
1.7 KiB
Java
4 years ago
|
// FailedTransmission.java
|
||
|
|
||
|
package simulator;
|
||
|
|
||
|
import java.awt.*;
|
||
|
import support.ProtocolEvent;
|
||
|
|
||
|
/**
|
||
|
This is the class for a failed transmission arrow.
|
||
|
|
||
|
@author Kenneth J. Turner
|
||
|
@version 1.0 (1st September 1999, IAR): initial version <br/>
|
||
|
<br/> 1.5 (22nd July 2010, KJT): minor tidying
|
||
|
*/
|
||
|
public class FailedTransmission extends TransmissionSymbol {
|
||
|
|
||
|
private final static int crossSize = 10;
|
||
|
|
||
|
/**
|
||
|
Constructor for a traverse transmission arrow.
|
||
|
|
||
|
@param event protocol event
|
||
|
@param lToR true = left-to-right
|
||
|
@param column column
|
||
|
@param top top of service primitive
|
||
|
@param height height of successful transmission
|
||
|
*/
|
||
|
public FailedTransmission(
|
||
|
ProtocolEvent event, boolean lToR, int column, int top, int height) {
|
||
|
super(event, lToR, column, top, height);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
Draw a dashed line with cutoff representing failed transmission through
|
||
|
medium.
|
||
|
|
||
|
@param g graphics object
|
||
|
*/
|
||
|
public void draw(Graphics g) {
|
||
|
int leftX = inset + col * columnWidth + arrowWidth / 2;
|
||
|
int rightX = leftX + columnWidth - arrowWidth;
|
||
|
int midX = (leftX + rightX) / 2;
|
||
|
int midY = top + height / 2;
|
||
|
g.setColor(Color.blue);
|
||
|
if (lToR)
|
||
|
drawDashedLine(g, leftX, top, midX, midY, dashLength);
|
||
|
else
|
||
|
drawDashedLine(g, rightX, top, midX, midY, dashLength);
|
||
|
// draw a cross to indicate loss of signal
|
||
|
g.drawLine(midX - crossSize / 2, midY - crossSize / 2,
|
||
|
midX + crossSize / 2, midY + crossSize / 2);
|
||
|
g.drawLine(midX + crossSize / 2, midY - crossSize / 2,
|
||
|
midX - crossSize / 2, midY + crossSize / 2);
|
||
|
g.setColor(Color.black);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|