Package wprover

Class 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 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 JPolygonFlash
        poly1 - the first CPolygon to be used in the flashing effect
        poly2 - the second CPolygon to be used in the flashing effect
        oc - a boolean indicating whether to use the specified center coordinates
        xc - the x-coordinate of the center
        yc - the y-coordinate of the center
        c1 - the first color index for the flashing effect
        c2 - the second color index for the flashing effect
        tt - 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:
        actionPerformed in interface java.awt.event.ActionListener
        Parameters:
        e - the action event
      • stop

        public void stop()
        Stops the flashing effect and makes the second polygon visible.
        Overrides:
        stop in class JFlash
      • start

        public void start()
        Starts the flashing effect and makes the second polygon invisible.
        Overrides:
        start in class JFlash
      • recalculate

        public void recalculate()
        Recalculates the flashing effect by reinitializing the animation state.
        Overrides:
        recalculate in class JFlash
      • 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.

        Specified by:
        draw in class JFlash
        Parameters:
        g2 - the Graphics2D context used for drawing
        Returns:
        true if the polygon is successfully drawn; false otherwise