Class ChartButton
- java.lang.Object
-
- java.awt.event.MouseAdapter
-
- org.knowm.xchart.internal.chartpart.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.
-
-
Field Summary
Fields Modifier and Type Field Description private java.awt.event.ActionEventactionprivate java.awt.Rectangleboundsprivate java.awt.ShapebuttonRectprivate Chartchartprivate javax.swing.event.EventListenerListlistenerListprivate Stylerstylerprotected java.lang.Stringtext(package private) booleanvisibleprotected doublexOffsetprotected doubleyOffset-
Fields inherited from interface org.knowm.xchart.internal.chartpart.ChartPart
SOLID_STROKE
-
-
Constructor Summary
Constructors Constructor Description ChartButton(XYChart xyChart, XChartPanel<XYChart> xChartPanel, java.lang.String text)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddActionListener(java.awt.event.ActionListener l)private voidcalculatePosition(java.awt.geom.Rectangle2D textBounds)private voidfireActionPerformed()Notify listeners that this button was clicked or interacted with in some wayjava.awt.geom.Rectangle2DgetBounds()voidmouseClicked(java.awt.event.MouseEvent e)voidpaint(java.awt.Graphics2D g)voidremoveActionListener(java.awt.event.ActionListener l)(package private) voidsetText(java.lang.String text)(package private) voidsetVisible(boolean visible)
-
-
-
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()
-
mouseClicked
public void mouseClicked(java.awt.event.MouseEvent e)
- Specified by:
mouseClickedin interfacejava.awt.event.MouseListener- Overrides:
mouseClickedin classjava.awt.event.MouseAdapter
-
fireActionPerformed
private void fireActionPerformed()
Notify listeners that this button was clicked or interacted with in some way
-
calculatePosition
private void calculatePosition(java.awt.geom.Rectangle2D textBounds)
-
setText
void setText(java.lang.String text)
-
setVisible
void setVisible(boolean visible)
-
-