Package wprover
Class JFlash
- java.lang.Object
-
- wprover.JFlash
-
- Direct Known Subclasses:
JAngleFlash,JAreaFlash,JArrowFlash,JCgFlash,JCirFlash,JLineFlash,JObjectFlash,JPointEnlargeFlash,JPolygonFlash,JRedoStepFlash,JSegmentMovingFlash,JTLineFlash,JTriFlash
public abstract class JFlash extends java.lang.ObjectJFlash is an abstract class that provides methods for creating and managing graphical flash effects in a JPanel. It includes methods for drawing angles, setting colors, and managing timers.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.awt.Colorcolorstatic java.awt.BasicStrokeDashstatic java.awt.BasicStrokeDASH1protected booleanfbprotected booleanfinishedprotected intnprotected javax.swing.JPanelpanelprotected intTIME_INTERVALprotected javax.swing.Timertimerprotected booleanvTypeprotected static doubleZERO
-
Constructor Summary
Constructors Constructor Description JFlash(javax.swing.JPanel p)Constructs a new JFlash with the specified JPanel.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract booleandraw(java.awt.Graphics2D g2)Draws the flash effect on the specified Graphics2D context.static voiddrawALine3(CPoint p1, CPoint p2, double x, double y, boolean ln, java.awt.Graphics2D g2)Draws a line segment between a point and the closer of two other points, with optional line drawing.static voiddrawALine3Short(CPoint p1, CPoint p2, double x, double y, java.awt.Graphics2D g2)Draws a line segment between a point and the closer of two other points.java.awt.ColorgetColor()Gets the color of the flash.protected static java.awt.ColorgetRatioColor(int c1, int c2, double ra)Gets a color that is a blend of two colors based on a ratio.booleangetvisibleType()Gets the visibility type of the flash.booleanisfinished()Checks if the flash effect is finished.booleanisrRunning()Checks if the timer is running.booleanisZero(double d)Checks if the given value is approximately zero.voidrecalculate()Recalculates the flash effect.voidsetColor(java.awt.Color c)Sets the color of the flash.voidsetDealy(int n)Sets the delay for the timer.voidsetDrawDash(java.awt.Graphics2D g2)Sets the drawing stroke to a dashed line with a red color.voidsetDrawDashFb2(java.awt.Graphics2D g2)Sets the drawing stroke to either a bold or dashed line with a red color based on the fb flag.voidstart()Starts the flash effect.voidstop()Stops the flash effect.voidupdateTimer()Updates the timer delay to the flash interval defined in CMisc.
-
-
-
Field Detail
-
timer
protected javax.swing.Timer timer
-
panel
protected javax.swing.JPanel panel
-
n
protected int n
-
ZERO
protected static double ZERO
-
Dash
public static final java.awt.BasicStroke Dash
-
DASH1
public static final java.awt.BasicStroke DASH1
-
color
protected java.awt.Color color
-
finished
protected boolean finished
-
vType
protected boolean vType
-
fb
protected boolean fb
-
TIME_INTERVAL
protected int TIME_INTERVAL
-
-
Method Detail
-
updateTimer
public void updateTimer()
Updates the timer delay to the flash interval defined in CMisc.
-
setDealy
public void setDealy(int n)
Sets the delay for the timer.- Parameters:
n- the delay in milliseconds
-
getvisibleType
public boolean getvisibleType()
Gets the visibility type of the flash.- Returns:
- true if the flash is visible, false otherwise
-
setColor
public void setColor(java.awt.Color c)
Sets the color of the flash.- Parameters:
c- the color to set
-
getColor
public java.awt.Color getColor()
Gets the color of the flash.- Returns:
- the color of the flash
-
draw
public abstract boolean draw(java.awt.Graphics2D g2)
Draws the flash effect on the specified Graphics2D context.- Parameters:
g2- the Graphics2D context to draw on- Returns:
- true if the drawing was successful, false otherwise
-
recalculate
public void recalculate()
Recalculates the flash effect. This method is intended to be overridden by subclasses.
-
start
public void start()
Starts the flash effect.
-
stop
public void stop()
Stops the flash effect.
-
isfinished
public boolean isfinished()
Checks if the flash effect is finished.- Returns:
- true if the flash effect is finished, false otherwise
-
isrRunning
public boolean isrRunning()
Checks if the timer is running.- Returns:
- true if the timer is running, false otherwise
-
setDrawDash
public final void setDrawDash(java.awt.Graphics2D g2)
Sets the drawing stroke to a dashed line with a red color.- Parameters:
g2- the Graphics2D context to set the stroke on
-
setDrawDashFb2
public final void setDrawDashFb2(java.awt.Graphics2D g2)
Sets the drawing stroke to either a bold or dashed line with a red color based on the fb flag.- Parameters:
g2- the Graphics2D context to set the stroke on
-
isZero
public final boolean isZero(double d)
Checks if the given value is approximately zero.- Parameters:
d- the value to check- Returns:
- true if the value is approximately zero, false otherwise
-
drawALine3Short
public static void drawALine3Short(CPoint p1, CPoint p2, double x, double y, java.awt.Graphics2D g2)
Draws a line segment between a point and the closer of two other points.- Parameters:
p1- the first pointp2- the second pointx- the x-coordinate of the third pointy- the y-coordinate of the third pointg2- the Graphics2D context to draw on
-
drawALine3
public static void drawALine3(CPoint p1, CPoint p2, double x, double y, boolean ln, java.awt.Graphics2D g2)
Draws a line segment between a point and the closer of two other points, with optional line drawing.- Parameters:
p1- the first pointp2- the second pointx- the x-coordinate of the third pointy- the y-coordinate of the third pointln- whether to draw the line segment between p1 and p2g2- the Graphics2D context to draw on
-
getRatioColor
protected static java.awt.Color getRatioColor(int c1, int c2, double ra)Gets a color that is a blend of two colors based on a ratio.- Parameters:
c1- the first color indexc2- the second color indexra- the ratio for blending the colors- Returns:
- the blended color
-
-