public class PlotPane extends JPanel implements Printable
y = f (x)
JPanel.AccessibleJPanel
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
NO_SUCH_PAGE, PAGE_EXISTS
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
PlotPane(int width,
int height)
Creates an empty plot pane.
|
PlotPane(int width,
int height,
String[] functions,
Color[] lineColor,
byte[] linewidth,
double xmin,
double xmax,
double ymin,
double ymax,
boolean yAuto,
boolean yRatio,
boolean drawTicks,
boolean drawGrid)
Creates a new plot pane.
|
Modifier and Type | Method and Description |
---|---|
void |
computePixels()
Computes all pixel values of the current function values.
|
void |
paint(Graphics g) |
int |
print(Graphics g,
PageFormat pf,
int pi) |
void |
setDrawGrid(boolean drawGrid)
Decides whether a coordinate grid is plotted.
|
void |
setDrawTicks(boolean drawTicks)
Decides whether coordinate ticks are plotted.
|
void |
setFPixels(int[][] fPixels)
Sets the function pixel values of this plot.
|
void |
setOrigin(int ox,
int oy)
Sets the origin of this plot pane.
|
void |
setTicks(double[] xTicks,
int[] xTicksPixel,
double[] yTicks,
int[] yTicksPixel)
Sets ticks for this plot.
|
void |
startPrinterJob()
Prints this plot.
|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
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, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, 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
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, transferFocusDownCycle, validate, validateTree
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, 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, transferFocusBackward, transferFocusUpCycle
public PlotPane(int width, int height)
width
- the width of this plot paneheight
- the width of this plot panepublic PlotPane(int width, int height, String[] functions, Color[] lineColor, byte[] linewidth, double xmin, double xmax, double ymin, double ymax, boolean yAuto, boolean yRatio, boolean drawTicks, boolean drawGrid)
width
- the width of this plot paneheight
- the width of this plot panefunctions
- an array of all functions to be plotted,
given by strings parseable by FunctionParser
.lineColor
- an array of colors for each function
(i.e., surfaceColor.length = functions.length
)linewidth
- an array of line strengths in pixels for each function
(i.e., lineStrength.length = functions.length
);
usually, the strength is a small positive integerxmin
- the minimum x-value to be plottedxmax
- the maximum x-value to be plottedymin
- the minimum y-value to be plottedymax
- the maximum y-value to be plottedyAuto
- indicates whether the limits of y-values, given by
y = f (x), are calculated automaticallyyRatio
- indicates whether the ratio z/x is onedrawTicks
- indicates whether the axes are marked with ticksdrawGrid
- indicates whether the plot is marked with a gridpublic void setDrawGrid(boolean drawGrid)
drawGrid
- flag deciding whether to plot a coordinate gridpublic void setDrawTicks(boolean drawTicks)
drawTicks
- flag deciding whether to plot coordinate tickspublic void setFPixels(int[][] fPixels)
fPixels
- function pixel valuespublic void computePixels()
public void setOrigin(int ox, int oy)
ox
- the x value of the originoy
- the y value of the originpublic void setTicks(double[] xTicks, int[] xTicksPixel, double[] yTicks, int[] yTicksPixel)
xTicks
- array of ticks of the x valuesxTicksPixel
- array of ticks of the x pixel valuesyTicks
- array of ticks of the y valuesyTicksPixel
- array of ticks of the y pixel valuespublic void paint(Graphics g)
paint
in class JComponent
public int print(Graphics g, PageFormat pf, int pi) throws PrinterException
print
in interface Printable
PrinterException
public void startPrinterJob()