public class ComplexPlotPane extends JPanel implements Printable
z = f (x, y)
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 |
---|
ComplexPlotPane(int width,
int height,
String[] functions,
Color[] surfaceColor,
byte[] lineStrength,
double xmin,
double xmax,
double ymin,
double ymax,
double zmin,
double zmax,
boolean realPart,
boolean imaginaryPart,
boolean zAuto,
boolean zRatio,
boolean drawAxes,
boolean drawGrid)
Creates a new plot pane.
|
Modifier and Type | Method and Description |
---|---|
void |
axes(Graphics g)
Plots the axes of this graph.
|
void |
computeValues()
Computes all line values regarding the current parameter values.
|
void |
drawAxes(Graphics2D g)
Draws the axes of this plot.
|
void |
line(Graphics g,
double x1,
double y1,
double x2,
double y2)
Draws the line through the specified start and end coordinates projected onto the plot plane.
|
int |
mapX(double x)
Returns the projected value of the specified x value mapped onto this plot.
|
int |
mapY(double y)
Returns the projected value of the specified y value mapped onto this plot.
|
void |
paint(Graphics g1) |
double[] |
pixelToV(int px,
int py)
Returns the projected coordinate values from the pixel values.
|
double |
pixelToX(int px,
int py)
Returns the x-value corresponding to the pixels (px,py).
|
double |
pixelToY(int px,
int py)
Returns the y-value corresponding to the pixels (px,py).
|
int |
print(Graphics g,
PageFormat pf,
int pi) |
void |
rotate(double xAngle,
double yAngle)
Rotates the coordinate axes.
|
void |
setAngles(double angleX,
double angleY)
Sets the rotation angles of this plot.
|
void |
setBackground(Color color) |
void |
setDrawAxes(boolean drawAxes)
Decides whether to draw the coordinate axes of this plot.
|
void |
setImaginaryPart(boolean imaginaryPart)
Decides whether the imaginary part of the function is plotted.
|
void |
setLimits(double xmin,
double xmax,
double ymin,
double ymax,
double zmin,
double zmax)
Sets the limits for the values.
|
void |
setRealPart(boolean realPart)
Decides whether the real part of the function is plotted.
|
void |
setVLimits(int vxmin,
int vxmax,
int vymin,
int vymax)
Sets the limit projected values.
|
void |
startPrinterJob()
Prints this plot.
|
double |
vx(double x,
double y,
double z)
Returns the projected value on the x axis given by the current rotation angles.
|
double |
vy(double x,
double y,
double z)
Returns the projected value on the y axis given by the current rotation angles.
|
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, 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 ComplexPlotPane(int width, int height, String[] functions, Color[] surfaceColor, byte[] lineStrength, double xmin, double xmax, double ymin, double ymax, double zmin, double zmax, boolean realPart, boolean imaginaryPart, boolean zAuto, boolean zRatio, boolean drawAxes, 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
.surfaceColor
- an array of colors for each function
(i.e., surfaceColor.length = functions.length
)lineStrength
- 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 plottedzmin
- the minimum z-value to be plottedzmax
- the maximum z-value to be plottedrealPart
- indicates whether the real part of f is to be plottedimaginaryPart
- indicates whether the imaginary part of f is to be plottedzAuto
- indicates whether the limits of z-values, given by
z = f (x, y), are calculated automaticallyzRatio
- indicates whether the ratio z/x is onedrawAxes
- indicates whether the axes are drawndrawGrid
- indicates whether the plot is marked with a gridpublic void setBackground(Color color)
setBackground
in class JComponent
public void setDrawAxes(boolean drawAxes)
drawAxes
- flag indicating whether to draw the coordinate axespublic void setVLimits(int vxmin, int vxmax, int vymin, int vymax)
vxmin
- minimum projected x-valuevxmax
- maximum projected x-valuevymin
- minimum projected y-valuevymax
- maximum projected y-valuepublic void setAngles(double angleX, double angleY)
angleX
- the rotation angle of the x axisangleY
- the rotation angle of the y axispublic void setLimits(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax)
xmin
- minimum x valuexmax
- maximum x valueymin
- minimum y valueymax
- maximum y valuezmin
- minimum z valuezmax
- maximum z valuepublic void computeValues()
public void rotate(double xAngle, double yAngle)
xAngle
- angle to rotate the x axisyAngle
- angle to rotate the y axispublic void setRealPart(boolean realPart)
realPart
- flag indicating whether the real part of the function is plottedpublic void setImaginaryPart(boolean imaginaryPart)
imaginaryPart
- flag indicating whether the imaginary part of the function is plottedpublic void paint(Graphics g1)
paint
in class JComponent
public int print(Graphics g, PageFormat pf, int pi) throws PrinterException
print
in interface Printable
PrinterException
public void startPrinterJob()
public void axes(Graphics g)
g
- the graphics object of this plotpublic double vx(double x, double y, double z)
x
- the x valuey
- the y valuez
- the z valuesetAngles(double, double)
public double vy(double x, double y, double z)
x
- the x valuey
- the y valuez
- the z valuesetAngles(double, double)
public int mapX(double x)
x
- the x valuepublic int mapY(double y)
y
- the y valuepublic double pixelToX(int px, int py)
(x,y)T = A-1 [(px,py)T - a]
where A is the rotation composed of the rotation withangleX
around the screen x-axis and
angleY
around the screen y-axis,
and a the (pixel) translation.px
- pixels px in x coordinatepy
- pixels py in y coordinatepublic double pixelToY(int px, int py)
px
- pixels px in x coordinatepy
- pixels py in y coordinatepixelToX(int,int)
public double[] pixelToV(int px, int py)
px
- the pixel value of xpy
- the pixel value of ypublic void line(Graphics g, double x1, double y1, double x2, double y2)
g
- the graphics object of this plotx1
- the x coordinate of the starting pointy1
- the y coordinate of the starting pointx2
- the x coordinate of the end pointy2
- the y coordinate of the end pointpublic void drawAxes(Graphics2D g)
g
- the graphics object of this plot