public class Plot3DPane 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 |
---|
Plot3DPane(int width,
int height,
String[] functions,
Color[] surfaceColor,
byte[] lineStrength,
double xmin,
double xmax,
double ymin,
double ymax,
double zmin,
double zmax,
boolean zAuto,
boolean zRatio,
boolean drawTicks,
boolean drawGrid)
Creates a new 3D plot pane.
|
Modifier and Type | Method and Description |
---|---|
void |
axes(Graphics g)
Plots the axes of this graph.
|
void |
drawTicks(Graphics2D g)
Draws ticks on 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 x 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 x-value corresponding to the pixels (px,py).
|
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 |
setTicks(double[] xTicks,
int[] xTicksPixel,
double[] yTicks,
int[] yTicksPixel,
double[] zTicks,
int[] zTicksPixel)
Sets ticks for this plot.
|
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, 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 Plot3DPane(int width, int height, String[] functions, Color[] surfaceColor, byte[] lineStrength, double xmin, double xmax, double ymin, double ymax, double zmin, double zmax, boolean zAuto, boolean zRatio, 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
.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 plottedzAuto
- indicates whether the limits of z-values, given by
z = f (x, y), are calculated automaticallyzRatio
- 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 setTicks(double[] xTicks, int[] xTicksPixel, double[] yTicks, int[] yTicksPixel, double[] zTicks, int[] zTicksPixel)
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 valueszTicks
- array of ticks of the z valueszTicksPixel
- array of ticks of the z pixel valuespublic 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 valuepublic double vy(double x, double y, double z)
x
- the x valuey
- the y valuez
- the z valuepublic 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 drawTicks(Graphics2D g)
g
- the graphics object of this plot