Class SquarePusher

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable

public class SquarePusher extends JComponent
Interactive component that allows you to drag a little rectangle round inside a big rectangle. It is used as part of the UI for legend positioning.
Since:
13 Mar 2013
Author:
Mark Taylor
See Also:
  • Constructor Details

    • SquarePusher

      public SquarePusher()
      Constructor.
  • Method Details

    • addActionListener

      public void addActionListener(ActionListener listener)
      Adds a listener to be notified when the position changes.
      Parameters:
      listener - listener
    • removeActionListener

      public void removeActionListener(ActionListener listener)
      Removes a listener previously added.
      Parameters:
      listener - listener
    • getXPosition

      public float getXPosition()
      Returns the selected fractional horizontal position.
      Returns:
      X position in the range 0..1
    • getYPosition

      public float getYPosition()
      Returns the selected fractional vertical position.
      Returns:
      Y position in the range 0..1
    • setPosition

      public void setPosition(float xpos, float ypos)
      Sets the fractional position.
      Parameters:
      xpos - new X position in the range 0..1
      ypos - new Y position in the range 0..1
    • paintComponent

      protected void paintComponent(Graphics g)
      Overrides:
      paintComponent in class JComponent
    • setEnabled

      public void setEnabled(boolean isEnabled)
      Overrides:
      setEnabled in class JComponent
    • main

      public static void main(String[] args)
      Test.