Package wprover

Class JTriFlash

  • All Implemented Interfaces:
    java.awt.event.ActionListener, java.util.EventListener

    public class JTriFlash
    extends JFlash
    implements java.awt.event.ActionListener
    JTriFlash is a class that extends JFlash and implements ActionListener. It is used to create a triangular flashing effect on a JPanel.
    • Method Detail

      • start

        public void start()
        Description copied from class: JFlash
        Starts the flash effect.
        Overrides:
        start in class JFlash
      • actionPerformed

        public void actionPerformed​(java.awt.event.ActionEvent e)
        Handles the action event by updating the animation state and repainting the panel.
        Specified by:
        actionPerformed in interface java.awt.event.ActionListener
        Parameters:
        e - the action event triggering the update
      • recalculate

        public void recalculate()
        Recalculates the flash animation by reinitializing its state based on the current direction.
        Overrides:
        recalculate in class JFlash
      • draw

        public boolean draw​(java.awt.Graphics2D g2)
        Draws the triangular flash effect onto the provided graphics context.
        Specified by:
        draw in class JFlash
        Parameters:
        g2 - the graphics context to draw the flash effect on
        Returns:
        true if drawing was successful; false otherwise
      • drawFirstTriangle

        public void drawFirstTriangle​(java.awt.Graphics2D g2)
        Draws the first triangle of the flash animation using the initial set of coordinates.
        Parameters:
        g2 - the graphics context to draw the triangle on
      • drawColoredTriangle

        public void drawColoredTriangle​(int[] p1,
                                        int[] p2,
                                        java.awt.Graphics2D g2)
        Draws an outline of the triangle using the specified vertex coordinates.
        Parameters:
        p1 - an array containing the x-coordinates of the triangle's vertices
        p2 - an array containing the y-coordinates of the triangle's vertices
        g2 - the graphics context for drawing the triangle outline
      • drawLastTriangle

        public void drawLastTriangle​(java.awt.Graphics2D g2)
        Draws the final triangle of the flash effect using the last computed set of coordinates.
        Parameters:
        g2 - the graphics context on which to draw the triangle
      • drawTiangle

        public void drawTiangle​(java.awt.Graphics2D g2,
                                int index)
        Draws a triangle at the specified index from the precomputed coordinate arrays.
        Parameters:
        g2 - the graphics context used for drawing the triangle
        index - the index of the coordinate arrays to use for drawing