Class VisStation

java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
com.sanderjurgens.metroplanner.gui.VisStation
All Implemented Interfaces:
MouseListener, ImageObserver, MenuContainer, Serializable, EventListener
Direct Known Subclasses:
VisStationDummy

public class VisStation extends JComponent implements MouseListener
The visual representation of a Station.
Author:
sanderjurgens
See Also:
  • Field Details

    • x

      protected int x
      Position of the component
    • y

      protected int y
      Position of the component
  • Constructor Details

    • VisStation

      public VisStation(Station station, boolean transfer, int x, int y)
      Constructs a new station.
      Parameters:
      station - the station this visual object represents
      transfer - whether is a large transfer station or a small stopping station
      x - the horizontal coordinate of the station
      y - the vertical coordinate of the station
  • Method Details

    • paintComponent

      protected void paintComponent(Graphics graphics)
      Draw a white circle with a black border to represent a station.
      Overrides:
      paintComponent in class JComponent
      Parameters:
      graphics - the Graphics context in which to draw
    • setPosition

      public void setPosition(int x, int y)
      Set the position of the Station by specifying its center.
      Parameters:
      x - the horizontal coordinate of the station's center
      y - the vertical coordinate of the station's center
    • mousePressed

      public void mousePressed(MouseEvent me)
      Mouse handler for when the station is clicked. Delegate this back to the MainFrame with a reference of which station was clicked and whether it was a left or right mouse click.
      Specified by:
      mousePressed in interface MouseListener
      Parameters:
      me - the mouse event
    • mouseClicked

      public void mouseClicked(MouseEvent me)
      Stub.
      Specified by:
      mouseClicked in interface MouseListener
      Parameters:
      me - the mouse event
    • mouseReleased

      public void mouseReleased(MouseEvent me)
      Stub.
      Specified by:
      mouseReleased in interface MouseListener
      Parameters:
      me - the mouse event
    • mouseEntered

      public void mouseEntered(MouseEvent me)
      Stub.
      Specified by:
      mouseEntered in interface MouseListener
      Parameters:
      me - the mouse event
    • mouseExited

      public void mouseExited(MouseEvent me)
      Stub.
      Specified by:
      mouseExited in interface MouseListener
      Parameters:
      me - the mouse event
    • setPosition

      public void setPosition(Point p)
      Give the component a position on the map. It is up to the component how it draws itself around this position. Subclasses must call the setBounds() method to correctly set the size of the component when this method is called.
      Parameters:
      p - the coordinates of the component
    • getPosition

      public Point getPosition()
      Get the position of this component.
      Returns:
      Point(x, y)