public class XYPlot extends java.lang.Object implements IXYGraphLibAdapter, IXYPlot, IXYPlotEvent
IXYPlotEvent.KeyEvent
Modifier and Type | Field and Description |
---|---|
static int |
CMD_LAST_DATA |
static int |
CMD_MOVE_LEFT |
static int |
CMD_MOVE_RIGHT |
static int |
CMD_NEXT_DATA |
static int |
CMD_SHOW_ALL |
static int |
CMD_ZOOM_IN |
static int |
CMD_ZOOM_OUT |
static boolean |
SUPPORT_PARTIAL_DRAW |
Modifier | Constructor and Description |
---|---|
protected |
XYPlot(IXYGraphLib graphLib) |
Modifier and Type | Method and Description |
---|---|
boolean |
addDataHandler(XYPlotData dh)
Add an already existing data set
|
static XYPlotData |
createDataHandler(int max,
IXYGraphLib.RGB color)
Create a new data set to be displayed in the XY plot.
|
static IXYPlot |
createXYPlot(IXYGraphLib graphLib)
Static method to create an XYPlot instance
|
boolean |
evalKey(int key)
Method to be called by the owner of the plot to inform about a key stroke.
|
boolean |
evalMouseEvent(IXYGraphLib.MouseEvent event,
int x,
int y)
Method to be called by the owner of the plot to inform about mouse click
events.
|
java.util.ArrayList<XYPlotData> |
getDataHandlers()
Get list of used data handlers
|
long |
getDelayRepaint()
Get the delay of the repaint operation (see
setUpdateDelay(long) |
IXYGraphLib.Rect |
getRedrawArea()
Get the area which needs to be redrawn.
|
java.lang.String |
getXAxisText()
Get the text for the X axis
|
double |
getXMax()
Get the maximum X value
|
double |
getXMin()
Get the minimum X value
|
java.lang.String |
getXUnitText()
Get the text for the X axis unit
|
int |
getZoomBoxLacyUpdateDelay()
Returns the current value of the zoom box delay.
|
int |
height()
Get height of plot are
|
void |
initXRange(double xmin,
double xmax)
Same as setXRange but is always executed independent of the graphs current
paused state.
|
boolean |
isAllowPauseOnDataClick()
Returns the current state of the flag.
|
boolean |
isLegendExpanded()
Status, expanded (true) ore collapsed (false), of the legend box
|
boolean |
isOutdated()
Returns true if the graph needs to be repainted.
|
boolean |
moveByPixels(int pixelNum)
Move visible data to the right
|
void |
moveLeft()
Move visible data to the left
|
void |
moveRight()
Move visible data to the right
|
void |
onEvent(IXYPlotEvent.KeyEvent event)
This is the default handler for button events send from the plot to its
owner.
|
void |
paintCursor()
Paint the cursor into the plot
|
void |
paintGraph()
Paint the plot to the internal image
|
void |
registerEventHandler(IXYPlotEvent h)
Register a handler to receive clicks on the start/stop, pause keys.
|
boolean |
removeDataHandler(XYPlotData dh)
Remove data set
|
void |
removeDataHandlers()
Remove all data sets
|
void |
setAllowPauseOnDataClick(boolean allowPauseOnDataClick)
Allow that a click into the graph switches the state to pause mode.
|
void |
setAxisColor(int r,
int g,
int b)
Set color of axis
|
void |
setAxisLabels(boolean value)
Turn on/off of axis labels and legend.
|
void |
setBgColor(int r,
int g,
int b)
Set color of global background
|
void |
setBounds(IXYGraphLib.Rect bounds)
Set the boundaries of the component in absolute coordinates of the canvas
|
void |
setClearButtonVisible(boolean value)
Set the delete plot button to visible or invisible.
|
void |
setCursorBgColor(int r,
int g,
int b)
Set color of cursor box background
|
void |
setCursorColor(int r,
int g,
int b)
Set color of cursor
|
void |
setDataHandlers(XYPlotData[] dhs)
Add a set of data handlers to the graph.
|
void |
setDrawAreaBgColor(int r,
int g,
int b)
Set color of curve draw area background
|
void |
setFontSize(int labelFontSize,
int titleFontSize)
Set size of font for labels and title
|
void |
setFontSize(java.lang.String fontName,
int labelFontSize,
int titleFontSize)
Set name and size of font for labels and title
|
void |
setLegendBgColor(int r,
int g,
int b)
Set background color of the legend area.
|
void |
setLegendExpanded(boolean value)
Expand (true) ore collapse (false) the legend box
|
void |
setLegendSelectBgColor(int r,
int g,
int b)
Set background color of selected data in legend.
|
void |
setLegendVisible(boolean value)
Set the legend box to visible.
|
protected void |
setNeedsRedraw()
Set redraw flag
|
void |
setOptimizedLineDrawing(boolean optimizedDraw)
Large data sets consume a lot of time for drawing the lines.
|
void |
setPaused(boolean paused)
Set graph in paused mode.
|
void |
setSaveButtonVisible(boolean value)
Set the save button to visible or invisible.
|
void |
setSmoothScroll(boolean smoothScroll)
Set smooth scrolling.
|
void |
setStartButtonVisible(boolean value)
Set the run/pause button to visible or invisible.
|
void |
setUpdateDelay(long delay)
Set the delay of the repaint operation.
|
void |
setXAxisText(java.lang.String s)
Set the text for the X axis unit
|
void |
setXRange(double xmin,
double xmax)
Set the range for the X axis.
|
void |
setXUnitText(java.lang.String s)
Set the text for the X axis unit
|
void |
setYRange(XYPlotData data,
double ymin,
double ymax)
Set the range for the Y axis.
|
void |
setZoomBoxLacyUpdateDelay(int zoomBoxLacyUpdateDelay)
This value in [ms] is used to delay the update of the zoom box when changing
the size.
|
boolean |
showsCursor()
Check status of cursor
|
int |
width()
Get width of plot are
|
boolean |
zoomAt(int position,
double factor)
Zoom x-Axis at given position by a factor
|
void |
zoomIn()
Zoom x-Axis around cursor position
|
public static final int CMD_MOVE_LEFT
public static final int CMD_MOVE_RIGHT
public static final int CMD_LAST_DATA
public static final int CMD_NEXT_DATA
public static final int CMD_ZOOM_IN
public static final int CMD_ZOOM_OUT
public static final int CMD_SHOW_ALL
public static final boolean SUPPORT_PARTIAL_DRAW
protected XYPlot(IXYGraphLib graphLib)
public static IXYPlot createXYPlot(IXYGraphLib graphLib)
graphLib
- Interface to the graphic librarypublic void registerEventHandler(IXYPlotEvent h)
registerEventHandler
in interface IXYPlot
h
- Receiver object for the eventspublic static XYPlotData createDataHandler(int max, IXYGraphLib.RGB color)
max
- Maximum number of XY values to be stored in the setcolor
- Color of the data to be displayed in the plotpublic java.util.ArrayList<XYPlotData> getDataHandlers()
IXYPlot
getDataHandlers
in interface IXYPlot
public void setDataHandlers(XYPlotData[] dhs)
IXYPlot
setDataHandlers
in interface IXYPlot
public boolean addDataHandler(XYPlotData dh)
IXYPlot
addDataHandler
in interface IXYPlot
public boolean removeDataHandler(XYPlotData dh)
IXYPlot
removeDataHandler
in interface IXYPlot
public void removeDataHandlers()
IXYPlot
removeDataHandlers
in interface IXYPlot
public void onEvent(IXYPlotEvent.KeyEvent event)
onEvent
in interface IXYPlotEvent
public boolean showsCursor()
showsCursor
in interface IXYGraphLibAdapter
protected void setNeedsRedraw()
public boolean isOutdated()
isOutdated
in interface IXYPlot
public long getDelayRepaint()
setUpdateDelay(long)
public void setUpdateDelay(long delay)
IXYPlot
setUpdateDelay
in interface IXYPlot
delay
- Value in [ms]public void setBgColor(int r, int g, int b)
IXYPlot
setBgColor
in interface IXYPlot
r
- R value of RGBg
- G value of RGBb
- B value of RGBpublic void setDrawAreaBgColor(int r, int g, int b)
IXYPlot
setDrawAreaBgColor
in interface IXYPlot
r
- R value of RGBg
- G value of RGBb
- B value of RGBpublic void setAxisColor(int r, int g, int b)
IXYPlot
setAxisColor
in interface IXYPlot
r
- R value of RGBg
- G value of RGBb
- B value of RGBpublic void setCursorColor(int r, int g, int b)
IXYPlot
setCursorColor
in interface IXYPlot
r
- R value of RGBg
- G value of RGBb
- B value of RGBpublic void setLegendBgColor(int r, int g, int b)
IXYPlot
setLegendBgColor
in interface IXYPlot
r
- R value of RGBg
- G value of RGBb
- B value of RGBpublic void setLegendSelectBgColor(int r, int g, int b)
IXYPlot
setLegendSelectBgColor
in interface IXYPlot
r
- R value of RGBg
- G value of RGBb
- B value of RGBpublic void setCursorBgColor(int r, int g, int b)
IXYPlot
setCursorBgColor
in interface IXYPlot
r
- R value of RGBg
- G value of RGBb
- B value of RGBpublic void setFontSize(int labelFontSize, int titleFontSize)
IXYPlot
setFontSize
in interface IXYPlot
public void setFontSize(java.lang.String fontName, int labelFontSize, int titleFontSize)
IXYPlot
setFontSize
in interface IXYPlot
public void setOptimizedLineDrawing(boolean optimizedDraw)
IXYPlot
setOptimizedLineDrawing
in interface IXYPlot
optimizedDraw
- True to optimize drawingpublic boolean evalKey(int key)
public boolean evalMouseEvent(IXYGraphLib.MouseEvent event, int x, int y)
evalMouseEvent
in interface IXYPlot
x
- x coordinate of the mouse down clicky
- y coordinate of the mouse down clickpublic void moveLeft()
IXYPlot
public void moveRight()
IXYPlot
public boolean moveByPixels(int pixelNum)
IXYPlot
moveByPixels
in interface IXYPlot
public void zoomIn()
IXYPlot
public boolean zoomAt(int position, double factor)
IXYPlot
public java.lang.String getXUnitText()
IXYPlot
getXUnitText
in interface IXYPlot
public void setXUnitText(java.lang.String s)
IXYPlot
setXUnitText
in interface IXYPlot
s
- Unit text i.e. "s" for seconds. Do not add brackets [] herepublic java.lang.String getXAxisText()
IXYPlot
getXAxisText
in interface IXYPlot
public void setXAxisText(java.lang.String s)
IXYPlot
setXAxisText
in interface IXYPlot
s
- Unit text i.e. "s" for seconds. Do not use brackets [] here, they
are added automaticallypublic void setBounds(IXYGraphLib.Rect bounds)
setBounds
in interface IXYGraphLibAdapter
setBounds
in interface IXYPlot
bounds
- Outer rectangle defining the plotting arepublic IXYGraphLib.Rect getRedrawArea()
getRedrawArea
in interface IXYPlot
public int width()
public int height()
public void setYRange(XYPlotData data, double ymin, double ymax)
ymin
- Minimum y value to be displayedymax
- Maximum y value to be displayedpublic void setXRange(double xmin, double xmax)
IXYPlot
public void initXRange(double xmin, double xmax)
IXYPlot
initXRange
in interface IXYPlot
xmin
- Minimum x value to be displayedxmax
- Maximum x value to be displayedpublic double getXMin()
IXYPlot
public double getXMax()
IXYPlot
public void paintGraph()
paintGraph
in interface IXYGraphLibAdapter
public void paintCursor()
paintCursor
in interface IXYGraphLibAdapter
public int getZoomBoxLacyUpdateDelay()
getZoomBoxLacyUpdateDelay
in interface IXYPlot
public void setZoomBoxLacyUpdateDelay(int zoomBoxLacyUpdateDelay)
setZoomBoxLacyUpdateDelay
in interface IXYPlot
zoomBoxLacyUpdateDelay
- New value for update delaypublic boolean isAllowPauseOnDataClick()
isAllowPauseOnDataClick
in interface IXYPlot
public void setAllowPauseOnDataClick(boolean allowPauseOnDataClick)
setAllowPauseOnDataClick
in interface IXYPlot
allowPauseOnDataClick
- True to pause graph if clickedpublic void setLegendExpanded(boolean value)
setLegendExpanded
in interface IXYPlot
value
- New value for legend expand statepublic boolean isLegendExpanded()
isLegendExpanded
in interface IXYPlot
public void setSmoothScroll(boolean smoothScroll)
IXYPlot
setSmoothScroll
in interface IXYPlot
smoothScroll
- True to scroll smoothlypublic void setSaveButtonVisible(boolean value)
IXYPlot
setSaveButtonVisible
in interface IXYPlot
value
- true/falsepublic void setStartButtonVisible(boolean value)
IXYPlot
setStartButtonVisible
in interface IXYPlot
value
- true/falsepublic void setClearButtonVisible(boolean value)
IXYPlot
setClearButtonVisible
in interface IXYPlot
value
- true/falsepublic void setLegendVisible(boolean value)
setLegendVisible
in interface IXYPlot
value
- New value for visible statepublic void setPaused(boolean paused)
public void setAxisLabels(boolean value)
IXYPlot
setAxisLabels
in interface IXYPlot
value
- true (default) or false