Class ChartButton

  • All Implemented Interfaces:
    java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener, java.util.EventListener, ChartPart

    public class ChartButton
    extends java.awt.event.MouseAdapter
    implements ChartPart
    A button that can be used on the chart for whatever function. For example the ChartZoom class uses this to reset the zoom function. When it is clicked it fires its actionPerformed action and whoever is listening to it can react to it.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addActionListener​(java.awt.event.ActionListener l)  
      private void calculatePosition​(java.awt.geom.Rectangle2D textBounds)  
      private void fireActionPerformed()
      Notify listeners that this button was clicked or interacted with in some way
      java.awt.geom.Rectangle2D getBounds()  
      void mouseClicked​(java.awt.event.MouseEvent e)  
      void paint​(java.awt.Graphics2D g)  
      void removeActionListener​(java.awt.event.ActionListener l)  
      (package private) void setText​(java.lang.String text)  
      (package private) void setVisible​(boolean visible)  
      • Methods inherited from class java.awt.event.MouseAdapter

        mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, mouseWheelMoved
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • chart

        private final Chart chart
      • styler

        private final Styler styler
      • bounds

        private java.awt.Rectangle bounds
      • text

        protected java.lang.String text
      • visible

        boolean visible
      • action

        private java.awt.event.ActionEvent action
      • listenerList

        private final javax.swing.event.EventListenerList listenerList
      • xOffset

        protected double xOffset
      • yOffset

        protected double yOffset
      • buttonRect

        private java.awt.Shape buttonRect
    • Constructor Detail

      • ChartButton

        public ChartButton​(XYChart xyChart,
                           XChartPanel<XYChart> xChartPanel,
                           java.lang.String text)
        Constructor
        Parameters:
        xyChart -
        xChartPanel -
        text -
    • Method Detail

      • addActionListener

        public void addActionListener​(java.awt.event.ActionListener l)
      • removeActionListener

        public void removeActionListener​(java.awt.event.ActionListener l)
      • getBounds

        public java.awt.geom.Rectangle2D getBounds()
        Specified by:
        getBounds in interface ChartPart
      • mouseClicked

        public void mouseClicked​(java.awt.event.MouseEvent e)
        Specified by:
        mouseClicked in interface java.awt.event.MouseListener
        Overrides:
        mouseClicked in class java.awt.event.MouseAdapter
      • fireActionPerformed

        private void fireActionPerformed()
        Notify listeners that this button was clicked or interacted with in some way
      • paint

        public void paint​(java.awt.Graphics2D g)
        Specified by:
        paint in interface ChartPart
      • calculatePosition

        private void calculatePosition​(java.awt.geom.Rectangle2D textBounds)
      • setText

        void setText​(java.lang.String text)
      • setVisible

        void setVisible​(boolean visible)