marytts.signalproc.display
Class FunctionGraphCustom

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by marytts.signalproc.display.FunctionGraph
                      extended by marytts.signalproc.display.FunctionGraphCustom
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, marytts.signalproc.display.CursorListener, marytts.signalproc.display.CursorSource
Direct Known Subclasses:
SpectrogramCustom

public class FunctionGraphCustom
extends marytts.signalproc.display.FunctionGraph

See Also:
Serialized Form

Nested Class Summary
 class FunctionGraphCustom.DoublePoint
           
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  boolean autoYMinMax
           
protected  Color axisColor
           
protected  Color backgroundColor
           
protected  List cursorListeners
           
protected  List<double[]> dataseries
           
static int DEFAULT_HEIGHT
           
static int DEFAULT_WIDTH
           
static int DOT_EMPTYCIRCLE
           
static int DOT_EMPTYDIAMOND
           
static int DOT_EMPTYSQUARE
           
static int DOT_FULLCIRCLE
           
static int DOT_FULLDIAMOND
           
static int DOT_FULLSQUARE
           
protected  int dotSize
           
protected  List<Integer> dotStyle
           
static int DRAW_DOTS
           
static int DRAW_HISTOGRAM
           
static int DRAW_LINE
           
static int DRAW_LINEWITHDOTS
           
protected  List<Color> graphColor
           
protected  BufferedImage graphImage
           
protected  List<Integer> graphStyle
           
protected  Color histogramBorderColor
           
protected  int histogramWidth
           
protected  int paddingBottom
           
protected  int paddingLeft
           
protected  int paddingRight
           
protected  int paddingTop
           
protected  FunctionGraphCustom.DoublePoint positionCursor
           
protected  FunctionGraphCustom.DoublePoint rangeCursor
           
protected  boolean showXAxis
           
protected  boolean showYAxis
           
protected  double x0
           
protected  double xStep
           
protected  double ymax
           
protected  double ymin
           
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
protected FunctionGraphCustom()
          Display a 2d graph showing y(x), with labelled scales.
  FunctionGraphCustom(double x0, double xStep, double[] y)
          Display a 2d graph showing y(x), with labelled scales.
  FunctionGraphCustom(int width, int height, double x0, double xStep, double[] y)
          Display a 2d graph showing y(x), with labelled scales.
 
Method Summary
 void addCursorListener(marytts.signalproc.display.CursorListener l)
           
 void addDataSeries(double[] data, Color newGraphColor, int newGraphStyle, int newDotStyle)
          Add a secondary data series to this graph.
protected  void createGraphImage()
           
protected  void drawData(Graphics2D g, int image_fromX, int image_toX, int image_refX, int image_refY, int startY, int image_height, double[] data, Color currentGraphColor, int currentGraphStyle, int currentDotStyle)
          While painting the graph, draw the actual function data.
protected  void drawDot(Graphics2D g, int x, int y, int currentDotStyle)
           
protected  void drawXAxis(Graphics2D g, double width, int startX, int startY, int image_y_origin)
           
protected  void drawYAxis(Graphics2D g, double height, int startX, int startY, int image_x_origin)
           
protected  JPanel getControls()
          Subclasses may provide specific controls here.
 marytts.signalproc.display.CursorListener[] getCursorListeners()
           
protected  String getLabel(double x, double y)
           
 marytts.signalproc.display.CursorDisplayer.CursorLine getPositionCursor()
           
 marytts.signalproc.display.CursorDisplayer.CursorLine getRangeCursor()
           
 marytts.signalproc.display.CursorDisplayer.Label getValueLabel()
           
protected  double getXRange()
           
protected  double getYRange()
           
 double getZoomX()
           
protected  int imageX2indexX(int imageX)
           
protected  double imageX2X(int imageX)
           
protected  double imageY2Y(int imageY)
           
protected  int indexX2imageX(int indexX)
           
 void initialise(int width, int height, double newX0, double newXStep, double[] data)
           
protected  void notifyCursorListeners()
           
 void paintComponent(Graphics gr)
           
 boolean removeCursorListener(marytts.signalproc.display.CursorListener l)
           
 void setPrimaryDataSeriesStyle(Color newGraphColor, int newGraphStyle, int newDotStyle)
           
 void setYMinMax(double theYMin, double theYMax)
          Manually set the min and max values for the y axis.
 void setZoomX(double factor)
          Set the zoom of the X
 JFrame showInJFrame(String title, boolean allowZoom, boolean exitOnClose)
           
 JFrame showInJFrame(String title, boolean allowZoom, boolean showControls, boolean exitOnClose)
           
 JFrame showInJFrame(String title, int width, int height, boolean allowZoom, boolean exitOnClose)
           
 JFrame showInJFrame(String title, int width, int height, boolean allowZoom, boolean showControls, boolean exitOnClose)
           
 void updateCursorPosition(marytts.signalproc.display.CursorEvent e)
          Used when keeping several FunctionGraphs' cursor positions in synchrony.
 void updateData(double newX0, double newXStep, double[] data)
          Replace the previous data with the given new data.
protected  int X2imageX(double x)
           
protected  int X2indexX(double x)
           
protected  int y2imageY(double y)
           
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_WIDTH

public static final int DEFAULT_WIDTH
See Also:
Constant Field Values

DEFAULT_HEIGHT

public static final int DEFAULT_HEIGHT
See Also:
Constant Field Values

DRAW_LINE

public static final int DRAW_LINE
See Also:
Constant Field Values

DRAW_DOTS

public static final int DRAW_DOTS
See Also:
Constant Field Values

DRAW_LINEWITHDOTS

public static final int DRAW_LINEWITHDOTS
See Also:
Constant Field Values

DRAW_HISTOGRAM

public static final int DRAW_HISTOGRAM
See Also:
Constant Field Values

DOT_FULLCIRCLE

public static final int DOT_FULLCIRCLE
See Also:
Constant Field Values

DOT_FULLSQUARE

public static final int DOT_FULLSQUARE
See Also:
Constant Field Values

DOT_FULLDIAMOND

public static final int DOT_FULLDIAMOND
See Also:
Constant Field Values

DOT_EMPTYCIRCLE

public static final int DOT_EMPTYCIRCLE
See Also:
Constant Field Values

DOT_EMPTYSQUARE

public static final int DOT_EMPTYSQUARE
See Also:
Constant Field Values

DOT_EMPTYDIAMOND

public static final int DOT_EMPTYDIAMOND
See Also:
Constant Field Values

paddingLeft

protected int paddingLeft

paddingRight

protected int paddingRight

paddingTop

protected int paddingTop

paddingBottom

protected int paddingBottom

x0

protected double x0

xStep

protected double xStep

dataseries

protected List<double[]> dataseries

ymin

protected double ymin

ymax

protected double ymax

showXAxis

protected boolean showXAxis

showYAxis

protected boolean showYAxis

graphImage

protected BufferedImage graphImage

backgroundColor

protected Color backgroundColor

axisColor

protected Color axisColor

graphColor

protected List<Color> graphColor

histogramBorderColor

protected Color histogramBorderColor

graphStyle

protected List<Integer> graphStyle

dotStyle

protected List<Integer> dotStyle

dotSize

protected int dotSize

histogramWidth

protected int histogramWidth

autoYMinMax

protected boolean autoYMinMax

positionCursor

protected FunctionGraphCustom.DoublePoint positionCursor

rangeCursor

protected FunctionGraphCustom.DoublePoint rangeCursor

cursorListeners

protected List cursorListeners
Constructor Detail

FunctionGraphCustom

protected FunctionGraphCustom()
Display a 2d graph showing y(x), with labelled scales. This constructor is for subclasses only, which may need to perform some operations before calling initialise().


FunctionGraphCustom

public FunctionGraphCustom(double x0,
                           double xStep,
                           double[] y)
Display a 2d graph showing y(x), with labelled scales.


FunctionGraphCustom

public FunctionGraphCustom(int width,
                           int height,
                           double x0,
                           double xStep,
                           double[] y)
Display a 2d graph showing y(x), with labelled scales.

Method Detail

initialise

public void initialise(int width,
                       int height,
                       double newX0,
                       double newXStep,
                       double[] data)
Overrides:
initialise in class marytts.signalproc.display.FunctionGraph

updateData

public void updateData(double newX0,
                       double newXStep,
                       double[] data)
Replace the previous data with the given new data. Any secondary data series added using {addDataSeries(double[], Color, int, int) are removed.

Overrides:
updateData in class marytts.signalproc.display.FunctionGraph
Parameters:
newX0 - x position of first data point
newXStep - distance between data points on X axis
data - all data points

setPrimaryDataSeriesStyle

public void setPrimaryDataSeriesStyle(Color newGraphColor,
                                      int newGraphStyle,
                                      int newDotStyle)
Overrides:
setPrimaryDataSeriesStyle in class marytts.signalproc.display.FunctionGraph

setYMinMax

public void setYMinMax(double theYMin,
                       double theYMax)
Manually set the min and max values for the y axis.

Overrides:
setYMinMax in class marytts.signalproc.display.FunctionGraph
Parameters:
theYMin -
theYMax -

addDataSeries

public void addDataSeries(double[] data,
                          Color newGraphColor,
                          int newGraphStyle,
                          int newDotStyle)
Add a secondary data series to this graph.

Overrides:
addDataSeries in class marytts.signalproc.display.FunctionGraph
Parameters:
data - the function data, which must be of same length as the original data. updateData(double, double, double[])
newGraphColor - a colour
newGraphStyle - the style for painting this data series. One of DRAW_LINE, DRAW_DOTS, 3, DRAW_HISTOGRAM.
newDotStyle - the shape of any dots to use (meaningful only with newGraphStyle == DRAW_DOTS or DRAW_LINEWITHDOTS). One of DOT_EMPTYCIRCLE, DOT_EMPTYDIAMOND, DOT_EMPTYSQUARE, DOT_FULLCIRCLE, DOT_FULLDIAMOND, DOT_FULLSQUARE. For other graph styles, this is ignored, and it is recommended to set it to -1 for clarity.

getZoomX

public double getZoomX()
Overrides:
getZoomX in class marytts.signalproc.display.FunctionGraph

setZoomX

public void setZoomX(double factor)
Set the zoom of the X

Overrides:
setZoomX in class marytts.signalproc.display.FunctionGraph
Parameters:
factor - the zoom factor for X; 1 means that each data point corresponds to one pixel; 0.5 means that 2 data points are mapped onto one pixel; etc.

createGraphImage

protected void createGraphImage()
Overrides:
createGraphImage in class marytts.signalproc.display.FunctionGraph

drawData

protected void drawData(Graphics2D g,
                        int image_fromX,
                        int image_toX,
                        int image_refX,
                        int image_refY,
                        int startY,
                        int image_height,
                        double[] data,
                        Color currentGraphColor,
                        int currentGraphStyle,
                        int currentDotStyle)
While painting the graph, draw the actual function data.

Overrides:
drawData in class marytts.signalproc.display.FunctionGraph
Parameters:
g - the graphics2d object to paint in
image_fromX - first visible X coordinate of the Graph display area (= after subtracting space reserved for Y axis)
image_toX - last visible X coordinate of the Graph display area (= after subtracting space reserved for Y axis)
image_refX - X coordinate of the origin, in the display area
image_refY - Y coordinate of the origin, in the display area
xScaleFactor - conversion factor between data space and image space, image_x = xScaleFactor * data_x
yScaleFactor - conversion factor between data space and image space, image_y = yScaleFactor * data_y
startY - the start position on the Y axis (= the lower bound of the drawing area)
image_height - the height of the drawable region for the y values

drawDot

protected void drawDot(Graphics2D g,
                       int x,
                       int y,
                       int currentDotStyle)
Overrides:
drawDot in class marytts.signalproc.display.FunctionGraph

drawYAxis

protected void drawYAxis(Graphics2D g,
                         double height,
                         int startX,
                         int startY,
                         int image_x_origin)
Overrides:
drawYAxis in class marytts.signalproc.display.FunctionGraph

drawXAxis

protected void drawXAxis(Graphics2D g,
                         double width,
                         int startX,
                         int startY,
                         int image_y_origin)
Overrides:
drawXAxis in class marytts.signalproc.display.FunctionGraph

paintComponent

public void paintComponent(Graphics gr)
Overrides:
paintComponent in class marytts.signalproc.display.FunctionGraph

imageX2indexX

protected int imageX2indexX(int imageX)
Overrides:
imageX2indexX in class marytts.signalproc.display.FunctionGraph

imageX2X

protected double imageX2X(int imageX)
Overrides:
imageX2X in class marytts.signalproc.display.FunctionGraph

indexX2imageX

protected int indexX2imageX(int indexX)
Overrides:
indexX2imageX in class marytts.signalproc.display.FunctionGraph

X2imageX

protected int X2imageX(double x)
Overrides:
X2imageX in class marytts.signalproc.display.FunctionGraph

X2indexX

protected int X2indexX(double x)
Overrides:
X2indexX in class marytts.signalproc.display.FunctionGraph

imageY2Y

protected double imageY2Y(int imageY)
Overrides:
imageY2Y in class marytts.signalproc.display.FunctionGraph

y2imageY

protected int y2imageY(double y)
Overrides:
y2imageY in class marytts.signalproc.display.FunctionGraph

getYRange

protected double getYRange()
Overrides:
getYRange in class marytts.signalproc.display.FunctionGraph

getXRange

protected double getXRange()
Overrides:
getXRange in class marytts.signalproc.display.FunctionGraph

getPositionCursor

public marytts.signalproc.display.CursorDisplayer.CursorLine getPositionCursor()
Specified by:
getPositionCursor in interface marytts.signalproc.display.CursorSource
Overrides:
getPositionCursor in class marytts.signalproc.display.FunctionGraph

getRangeCursor

public marytts.signalproc.display.CursorDisplayer.CursorLine getRangeCursor()
Specified by:
getRangeCursor in interface marytts.signalproc.display.CursorSource
Overrides:
getRangeCursor in class marytts.signalproc.display.FunctionGraph

getValueLabel

public marytts.signalproc.display.CursorDisplayer.Label getValueLabel()
Specified by:
getValueLabel in interface marytts.signalproc.display.CursorSource
Overrides:
getValueLabel in class marytts.signalproc.display.FunctionGraph

addCursorListener

public void addCursorListener(marytts.signalproc.display.CursorListener l)
Overrides:
addCursorListener in class marytts.signalproc.display.FunctionGraph

getCursorListeners

public marytts.signalproc.display.CursorListener[] getCursorListeners()
Overrides:
getCursorListeners in class marytts.signalproc.display.FunctionGraph

removeCursorListener

public boolean removeCursorListener(marytts.signalproc.display.CursorListener l)
Overrides:
removeCursorListener in class marytts.signalproc.display.FunctionGraph

notifyCursorListeners

protected void notifyCursorListeners()
Overrides:
notifyCursorListeners in class marytts.signalproc.display.FunctionGraph

updateCursorPosition

public void updateCursorPosition(marytts.signalproc.display.CursorEvent e)
Used when keeping several FunctionGraphs' cursor positions in synchrony. Register each other as cursor listeners before the glass pane; whichever gets clicked causes the others to be updated. Make sure to add any peers _before_ any displaying cursor listeners, to make sure all are in line before being displayed.

Specified by:
updateCursorPosition in interface marytts.signalproc.display.CursorListener
Overrides:
updateCursorPosition in class marytts.signalproc.display.FunctionGraph

showInJFrame

public JFrame showInJFrame(String title,
                           boolean allowZoom,
                           boolean exitOnClose)
Overrides:
showInJFrame in class marytts.signalproc.display.FunctionGraph

showInJFrame

public JFrame showInJFrame(String title,
                           boolean allowZoom,
                           boolean showControls,
                           boolean exitOnClose)
Overrides:
showInJFrame in class marytts.signalproc.display.FunctionGraph

showInJFrame

public JFrame showInJFrame(String title,
                           int width,
                           int height,
                           boolean allowZoom,
                           boolean exitOnClose)
Overrides:
showInJFrame in class marytts.signalproc.display.FunctionGraph

showInJFrame

public JFrame showInJFrame(String title,
                           int width,
                           int height,
                           boolean allowZoom,
                           boolean showControls,
                           boolean exitOnClose)
Overrides:
showInJFrame in class marytts.signalproc.display.FunctionGraph

getControls

protected JPanel getControls()
Subclasses may provide specific controls here.

Overrides:
getControls in class marytts.signalproc.display.FunctionGraph
Returns:
a JPanel filled with the controls, or null if none are to be provided.

getLabel

protected String getLabel(double x,
                          double y)
Overrides:
getLabel in class marytts.signalproc.display.FunctionGraph


Copyright © 2013. All Rights Reserved.