Java Statistical Classes

jsc.swt.plot2d
Class FunctionPlot2D

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--jsc.swt.plot2d.PlotPanel
                                |
                                +--jsc.swt.plot2d.AxesPlot
                                      |
                                      +--jsc.swt.plot2d.FunctionPlot2D
All Implemented Interfaces:
Accessible, Cloneable, ImageObserver, MenuContainer, Serializable
Direct Known Subclasses:
CdfPlot, PdfPlot, ScatterPlot2D, SplinePlot2D

public class FunctionPlot2D
extends AxesPlot

This class represents a plot of functions. Values of the functions y = f(x) are plotted on the vertical Y-axis against the horizontal X-axis.

The addFunction() method adds a function curve for f(x) to the plot. Values of y = f(x) are calculated at n equally spaced x-values using an implementation of the PlotFunction interface, where the getOrdinate() method should return f(x) or Double.NaN if f(x) does not exist at x. The curve is not plotted where f(x) does not exist.

Optionally, the area under the curve can be filled down to y = 0. This is often appropriate in statistical or probability plots, but may be inappropriate in general function plotting where the X-axis may not be at y = 0. Filling may also be inappropriate where f(x) does not exist over some parts of the X-axis.

Version:
1.0
Author:
A. J. Bertie.
See Also:
Serialized Form

Field Summary
 
Fields inherited from class jsc.swt.plot2d.AxesPlot
horizontalAxis, title, verticalAxis
 
Fields inherited from class jsc.swt.plot2d.PlotPanel
componentBounds, hints, objects, SEE_THRU, virtualSpace, vt
 
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
FunctionPlot2D(AxisModel horizontalAxisModel, AxisModel verticalAxisModel, double x, double y, String title)
          Creates the plot with given title and AxisModel objects.
FunctionPlot2D(AxisModel horizontalAxisModel, AxisModel verticalAxisModel, String title)
          Creates the plot with given title and AxisModel objects.
 
Method Summary
 PlotShape addFunction(PlotFunction f, double xMin, double xMax, int n, Color colour)
          Add the curve of a function f(x) to the plot.
 PlotShape addFunction(PlotFunction f, double xMin, double xMax, int n, Color colour, boolean filled)
          Add the curve of a function f(x) to the plot.
 PlotShape addFunction(PlotFunction f, double xMin, double xMax, int n, Color colour, Stroke stroke)
          Add the curve of a function f(x) to the plot.
 PlotShape addFunction(PlotFunction f, double xMin, double xMax, int n, Color colour, Stroke stroke, Paint paint, boolean filled)
          Add the curve of a function f(x) to the plot.
 PlotShape addFunction(PlotFunction f, int n, Color colour)
          Add the curve of a function f(x) to the plot.
 PlotShape addFunction(PlotFunction f, int n, Color colour, Stroke stroke)
          Add the curve of a function f(x) to the plot.
 
Methods inherited from class jsc.swt.plot2d.AxesPlot
addVerticalLine, addVerticalLine, clone, copy, getHorizontalAxis, getTitle, getVerticalAxis, outsideAxes, paintComponent, rescaleHorizontal, rescaleVertical, setClipping, setPaintXaxis, setPaintYaxis, setTitle
 
Methods inherited from class jsc.swt.plot2d.PlotPanel
addComponent, addComponent, addObject, addObjects, addRenderingHint, copyContents, copyPlot, ensureComponentCapacity, ensureObjectCapacity, getBufferedImage, getComponentBounds, getComponentBounds, getObject, getObject, getObjectCount, getObjectIndex, getObjects, getParHeight, getParWidth, getRenderingHints, getVirtualSpace, getVirtualTransform, isAntialiased, isEmpty, isTextAntialiased, merge, paintBackground, pixelToVirtual, pixelToVirtual, removeAll, removeAllComponents, removeAllObjects, removeComponent, removeLastComponent, removeLastObject, removeObject, removeObject, removeRenderingHint, setAntialiasing, setComponentBounds, setComponentBounds, setFocusColour, setObjectComposite, setTextAntialiasing, setVirtualSpace, setZoomable, setZoomBoxColour, setZoomBoxStroke, virtualToPixel, virtualToPixel, virtualToPixelHeight, virtualToPixelWidth, write, write
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, 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, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, 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
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FunctionPlot2D

public FunctionPlot2D(AxisModel horizontalAxisModel,
                      AxisModel verticalAxisModel,
                      String title)
Creates the plot with given title and AxisModel objects. The axes meet at their minimum values.

Parameters:
horizontalAxisModel - the horizontal axis model.
verticalAxisModel - the vertical axis model.
title - the title of the plot.

FunctionPlot2D

public FunctionPlot2D(AxisModel horizontalAxisModel,
                      AxisModel verticalAxisModel,
                      double x,
                      double y,
                      String title)
Creates the plot with given title and AxisModel objects.

Parameters:
horizontalAxisModel - the horizontal axis model.
verticalAxisModel - the vertical axis model.
title - the title of the plot.
Method Detail

addFunction

public PlotShape addFunction(PlotFunction f,
                             int n,
                             Color colour)
Add the curve of a function f(x) to the plot. The curve is drawn over the entire extent of the horizontal X-axis using straight lines connecting n points, and the specified colour. The stroke style is set to the current default of PlotShape. Redraws the plot. Returns the PlotShape that was added to the plot.

Parameters:
f - implements the function f(x) to be plotted.
n - the number of points used to draw the curve.
colour - the colour of the curve.
Returns:
the object added to the plot.

addFunction

public PlotShape addFunction(PlotFunction f,
                             int n,
                             Color colour,
                             Stroke stroke)
Add the curve of a function f(x) to the plot. The curve is drawn over the entire extent of the horizontal X-axis using straight lines connecting n points, and the specified colour and stroke style. Redraws the plot. Returns the PlotShape that was added to the plot.

Parameters:
f - implements the function f(x) to be plotted.
n - the number of points used to draw the curve.
colour - the colour of the curve.
stroke - the stroke style of the curve.
Returns:
the object added to the plot.

addFunction

public PlotShape addFunction(PlotFunction f,
                             double xMin,
                             double xMax,
                             int n,
                             Color colour)
Add the curve of a function f(x) to the plot. The curve is plotted at n values of x from xMin to xMax using straight lines connecting the points, and using the specified colour. The stroke style is set to the current default of PlotShape. Redraws the plot. Returns the PlotShape that was added to the plot.

Parameters:
f - implements the function f(x) to be plotted.
xMin - the minimum x value.
xMax - the maximum x value.
n - the number of points used to draw the curve.
colour - the colour of the curve.
Returns:
the object added to the plot.

addFunction

public PlotShape addFunction(PlotFunction f,
                             double xMin,
                             double xMax,
                             int n,
                             Color colour,
                             Stroke stroke)
Add the curve of a function f(x) to the plot. The curve is plotted at n values of x from xMin to xMax using straight lines connecting the points, and using the specified colour and stroke style. Redraws the plot. Returns the PlotShape that was added to the plot.

Parameters:
f - implements the function f(x) to be plotted.
xMin - the minimum x value.
xMax - the maximum x value.
n - the number of points used to draw the curve.
colour - the colour of the curve.
stroke - the stroke style of the curve.
Returns:
the object added to the plot.

addFunction

public PlotShape addFunction(PlotFunction f,
                             double xMin,
                             double xMax,
                             int n,
                             Color colour,
                             boolean filled)
Add the curve of a function f(x) to the plot. The curve is plotted at n values of x from xMin to xMax using straight lines connecting the points, and using the specified colour. The stroke style is set to the current default of PlotShape. If filled is true, the area under the curve from xMin to xMax is filled using the specified colour. Redraws the plot. Returns the PlotShape that was added to the plot.

Parameters:
f - implements the function f(x) to be plotted.
xMin - the minimum x value.
xMax - the maximum x value.
n - the number of points used to draw the curve.
colour - the colour of the curve.
filled - if true, the area under the curve is filled.
Returns:
the object added to the plot.

addFunction

public PlotShape addFunction(PlotFunction f,
                             double xMin,
                             double xMax,
                             int n,
                             Color colour,
                             Stroke stroke,
                             Paint paint,
                             boolean filled)
Add the curve of a function f(x) to the plot. The curve is plotted at n values of x from xMin to xMax using straight lines connecting the points, and using the specified colour and stroke style. If filled is true, the area under the curve from xMin to xMax is filled using the specified paint style. Redraws the plot. Returns the PlotShape that was added to the plot.

Parameters:
f - implements the function f(x) to be plotted.
xMin - the minimum x value.
xMax - the maximum x value.
n - the number of points used to draw the curve.
colour - the colour of the curve.
stroke - the stroke style of the curve.
paint - the paint style used to fill under the curve.
filled - if true, the area under the curve is filled.
Returns:
the object added to the plot.

Java Statistical Classes

Copyright © Andrew James Bertie, 2005, all rights reserved. Updated 12th Aug 2005