Package wprover
Class JPolygonFlash
- java.lang.Object
-
- wprover.JFlash
-
- wprover.JPolygonFlash
-
- All Implemented Interfaces:
java.awt.event.ActionListener,java.util.EventListener
public class JPolygonFlash extends JFlash implements java.awt.event.ActionListener
JPolygonFlash is a class that extends JFlash and implements ActionListener. It is used to create a flashing polygon effect on a JPanel.
-
-
Constructor Summary
Constructors Constructor Description JPolygonFlash(javax.swing.JPanel p, CPolygon poly1, CPolygon poly2, boolean oc, double xc, double yc, int c1, int c2, int tt)Constructs a new JPolygonFlash with the specified parameters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactionPerformed(java.awt.event.ActionEvent e)Handles the action event for the timer, updating the animation state and repainting the panel.booleandraw(java.awt.Graphics2D g2)Draws the flashing polygon effect based on the current animation state.doublegetCentroidX(java.util.Vector v)Calculates the x-coordinate of the centroid of the given vector of points.doublegetCentroidY(java.util.Vector v)Calculates the y-coordinate of the centroid of the given vector of points.voidrecalculate()Recalculates the flashing effect by reinitializing the animation state.voidstart()Starts the flashing effect and makes the second polygon invisible.voidstop()Stops the flashing effect and makes the second polygon visible.-
Methods inherited from class wprover.JFlash
drawALine3, drawALine3Short, getColor, getRatioColor, getvisibleType, isfinished, isrRunning, isZero, setColor, setDealy, setDrawDash, setDrawDashFb2, updateTimer
-
-
-
-
Constructor Detail
-
JPolygonFlash
public JPolygonFlash(javax.swing.JPanel p, CPolygon poly1, CPolygon poly2, boolean oc, double xc, double yc, int c1, int c2, int tt)Constructs a new JPolygonFlash with the specified parameters.- Parameters:
p- the JPanel to associate with this JPolygonFlashpoly1- the first CPolygon to be used in the flashing effectpoly2- the second CPolygon to be used in the flashing effectoc- a boolean indicating whether to use the specified center coordinatesxc- the x-coordinate of the centeryc- the y-coordinate of the centerc1- the first color index for the flashing effectc2- the second color index for the flashing effecttt- the type of flashing effect
-
-
Method Detail
-
getCentroidX
public double getCentroidX(java.util.Vector v)
Calculates the x-coordinate of the centroid of the given vector of points.- Parameters:
v- the vector of points- Returns:
- the x-coordinate of the centroid
-
getCentroidY
public double getCentroidY(java.util.Vector v)
Calculates the y-coordinate of the centroid of the given vector of points.- Parameters:
v- the vector of points- Returns:
- the y-coordinate of the centroid
-
actionPerformed
public void actionPerformed(java.awt.event.ActionEvent e)
Handles the action event for the timer, updating the animation state and repainting the panel.- Specified by:
actionPerformedin interfacejava.awt.event.ActionListener- Parameters:
e- the action event
-
stop
public void stop()
Stops the flashing effect and makes the second polygon visible.
-
start
public void start()
Starts the flashing effect and makes the second polygon invisible.
-
recalculate
public void recalculate()
Recalculates the flashing effect by reinitializing the animation state.- Overrides:
recalculatein classJFlash
-
draw
public boolean draw(java.awt.Graphics2D g2)
Draws the flashing polygon effect based on the current animation state.This method computes the polygon's vertex positions by either applying a rotation and translation transformation or by linearly interpolating between two sets of points, depending on the current flashing type. It then fills the polygon with an interpolated color and draws its outline.
The method returns false if the animation is not running or has finished.
-
-