Package gov.nih.mipav.view
Class ViewJComponentGraph
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- gov.nih.mipav.view.ViewJComponentGraph
-
- All Implemented Interfaces:
java.awt.event.MouseListener,java.awt.event.MouseMotionListener,java.awt.image.ImageObserver,java.awt.MenuContainer,java.io.Serializable,java.util.EventListener
public class ViewJComponentGraph extends javax.swing.JComponent implements java.awt.event.MouseListener, java.awt.event.MouseMotionListenerThis is a custom made Swing component. It is a graph that takes a panel in the constructor and then draws itself. The graph has the option of labels for the x and y axis, which are set with an accessor. Gridlines can also be turned on and off. The function calling ViewJComponentGraph may specify a number of gridlines to have on the graph. The number of gridlines is the same as the number of tick marks. Points are plotted in the graph by calling an accessor with an array of x coordinates and an array of y coordinates. The number of coordinates in each array must be equal.- Version:
- 0.1 Aug 1, 1998
- Author:
- Neva Cherniavsky (primary), Harman Singh
- See Also:
ViewJFrameGraph,ViewJComponentFunct, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private booleanaddSchwarzChristoffelLinesprivate java.awt.ColorbackgroundColorDOCUMENT ME!private java.awt.RectangleboundsDOCUMENT ME!private static ViewJComponentFunctcopiedFunctDOCUMENT ME!private static java.lang.StringcopiedNameDOCUMENT ME!private static float[]copiedXsDOCUMENT ME!private static float[]copiedYsDOCUMENT ME!private java.awt.CursorcrosshairCursorDOCUMENT ME!private java.awt.CursordefaultCursorDOCUMENT ME!private floatdefaultMaxDomainDOCUMENT ME!private floatdefaultMaxRangeDOCUMENT ME!private floatdefaultMinDomainDOCUMENT ME!private floatdefaultMinRangeDOCUMENT ME!private booleandoLogXprivate booleandoLogYprivate ViewJComponentFunct[]fittedFunctionsDOCUMENT ME!private java.awt.Fontfont10DOCUMENT ME!private java.awt.Fontfont12DOCUMENT ME!private java.awt.Fontfont12BDOCUMENT ME!private javax.swing.ImageIconfun2IconDOCUMENT ME!private javax.swing.ImageIconfun2PrintIconDOCUMENT ME!private javax.swing.ImageIconfun3IconDOCUMENT ME!private javax.swing.ImageIconfun3PrintIconDOCUMENT ME!private javax.swing.ImageIconfun4IconDOCUMENT ME!private javax.swing.ImageIconfun4PrintIconDOCUMENT ME!private javax.swing.ImageIconfun5IconDOCUMENT ME!private javax.swing.ImageIconfun5PrintIconDOCUMENT ME!private ViewJComponentFunct[]functionsDOCUMENT ME!private java.awt.RectanglegraphBoundsDOCUMENT ME!static intMAX_NUM_FUNCTSMaximum number of functions that the graph may display.private floatmaxDomainDOCUMENT ME!private floatmaxRangeDOCUMENT ME!private floatminDomainDOCUMENT ME!private floatminRangeDOCUMENT ME!private int[]newXDOCUMENT ME!private int[]newYDOCUMENT ME!private java.awt.RectangleoldRubberbandDOCUMENT ME!private javax.swing.JFrameparentFrameDOCUMENT ME!private RubberbandRectanglerubberbandRectDOCUMENT ME!private static longserialVersionUIDUse serialVersionUID for interoperability.static intSHOW_LINES_ONLYstatic intSHOW_POINTS_AND_LINESstatic intSHOW_POINTS_ONLYprivate booleanshowFittedFunctionsDOCUMENT ME!private booleanshowFunctionsDOCUMENT ME!private booleanshowGridLinesDOCUMENT ME!private booleanshowLegendDOCUMENT ME!private booleanshowMinorTickMarksDOCUMENT ME!private intshowPointsAndLinesDOCUMENT ME!private java.lang.StringtitleDOCUMENT ME!private booleanuserXGridprivate booleanuserYGridprivate java.util.Vector<java.lang.Double>x1Vectorprivate java.util.Vector<java.lang.Double>x2Vectorprivate intxGridLinesDOCUMENT ME!private int[]xGridUserPositionsprivate java.lang.StringxLabelDOCUMENT ME!private doublexScaleDOCUMENT ME!private doublexTickDOCUMENT ME!private java.util.Vector<java.lang.Double>y1Vectorprivate java.util.Vector<java.lang.Double>y2Vectorprivate intyGridLinesDOCUMENT ME!private int[]yGridUserPositionsprivate intyInvertprivate java.lang.StringyLabelDOCUMENT ME!private doubleyScaleDOCUMENT ME!private doubleyTickDOCUMENT ME!private booleanzeroXMinprivate booleanzeroYMin-
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
-
Constructor Summary
Constructors Constructor Description ViewJComponentGraph(javax.swing.JFrame frame, int width, int height)Constructor - creates graph within the JPanel using graphics.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcalculateCustomDomain()voidcalculateCustomRange()Calculates the range and domain (according to min and max y values). and expands range if necessary.voidcalculateDefaultRangeDomain()Calculates the default range and domain (according to min and max x and y values).voidcopyFunct(int index)Copies the indicated function's properties, to be pasted later as a new function.voiddeleteFunct(int index)Deletes the indicated function.private doubledistance(int x1, int y1, int x2, int y2)Tests the distance between two points.voiddrawLine(java.awt.Graphics g, int x1, int y1, int x2, int y2)voiddrawString(java.awt.Graphics g, java.lang.String str, int x, int y)java.awt.ColorgetBackgroundColor()Accessor that gets the background color.java.awt.RectanglegetBounds()Accessor that returns the bounds of the component.floatgetDefaultMaxDomain()Returns the default maximum point for the domain (previously calculated).floatgetDefaultMaxRange()Returns the default maximum point for the range (previously calculated).floatgetDefaultMinDomain()Returns the default minimum point for the domain (previously calculated).floatgetDefaultMinRange()Returns the default minimum point for the range (previously calculated).booleangetFittedFunctionsVisible()Accessor that gets the visible flag.ViewJComponentFunct[]getFittedFuncts()Accessor that gets the fitted functions for this graph.booleangetFunctionsVisible()Accessor that gets the visible flag of the functions.ViewJComponentFunct[]getFuncts()Accessor that gets the functions for this graph.java.awt.RectanglegetGraphBounds()booleangetGridlinesVisible()Accessor that gets the visible flag.booleangetLegendVisible()Accessor that gets the visible flag.floatgetMaxDomain()floatgetMaxRange()Returns the current maximum point for the range.floatgetMinDomain()java.awt.DimensiongetMinimumSize()Accessor that returns the minimum size of this component.booleangetMinorTickMarksVisible()Accessor that gets the visible flag.floatgetMinRange()Returns the current minimum point for the range.intgetNumberOfXGridLines()Accessor that gets the number of gridlines for paint.intgetNumberOfYGridLines()Accessor that gets the number of gridlines for paint.intgetPointsAndLinesDisplay()Accessor that gets the visible flag.java.awt.DimensiongetPreferredSize()Accessor that returns the preferred size of the component.java.lang.StringgetTitle()Gets the title for the graph.java.util.Vector<java.lang.Double>getX1Vector()java.util.Vector<java.lang.Double>getX2Vector()java.lang.StringgetXLabel()Gets the label for the x axis.java.util.Vector<java.lang.Double>getY1Vector()java.util.Vector<java.lang.Double>getY2Vector()java.lang.StringgetYLabel()Gets the label for the y axis.private java.lang.StringmakeString(float number, int decPts)Makes a string of a float with a specific number of decimal points.voidmouseClicked(java.awt.event.MouseEvent mouseEvent)DOCUMENT ME!voidmouseDragged(java.awt.event.MouseEvent mouseEvent)******************* Mouse Motion Events ***************************.********************************************* ***********************voidmouseEntered(java.awt.event.MouseEvent mouseEvent)************************ Mouse Events *****************************.********************************************* ***********************voidmouseExited(java.awt.event.MouseEvent mouseEvent)DOCUMENT ME!voidmouseMoved(java.awt.event.MouseEvent mouseEvent)Changes the cursor to crosshair and enables the zoom box rubberband if the cursor is in the graph; also sees if cursor is near a valid point and prints it out.voidmousePressed(java.awt.event.MouseEvent mouseEvent)DOCUMENT ME!voidmouseReleased(java.awt.event.MouseEvent mouseEvent)Checks to see that the zoom box is valid, then redraws the graph using the zoom box as bounds.voidpaintComponent(java.awt.Graphics g)Paints the graph.voidpaintComponentForPrinter(java.awt.Graphics g)Paints the graph for the Printer.voidpasteFunct()Adds the previously copied copied function to the graph.voidplotGraph(java.awt.Graphics g)Plots the graph by calling PolyLine.private voidplotGraphForPrinter(java.awt.Graphics g)Same as the plotGraph method, except the points used in this method are readable when sent to the printer.private voidplotSchwarzChristoffel(java.awt.Graphics g)voidredrawGraph(java.awt.Rectangle newBounds)Redraws the graph based on the new bounds.voidresetBounds(java.awt.Rectangle rect)Sets the bounds of the component.voidsetAddSchwarzChristoffelLines(boolean addSchwarzChristoffelLines)voidsetBackgroundColor(java.awt.Color color)Accessor that sets the background color to paint.voidsetDefaultRangeDomain()Sets range and domain to defaults.voidsetDoLogX(boolean doLogX)voidsetDoLogY(boolean doLogY)voidsetDomain(float min, float max)Sets the domain of the graph according to the min and max parmaters.voidsetFittedFunctionsVisible(boolean visible)Accessor that tells whether to show the gridlines.voidsetFittedFuncts(ViewJComponentFunct[] functs)Accessor that sets the fitted functions for this graph.voidsetFunctionsVisible(boolean visible)Accessor that tells whether to show the functions.voidsetFuncts(ViewJComponentFunct[] functs)Accessor that sets the function for this graph.voidsetGridlinesVisible(boolean visible)Accessor that tells whether to show the gridlines.voidsetLabels(java.lang.String xStr, java.lang.String yStr)Sets the labels for the x and y axis to these strings.voidsetLabelY(java.lang.String yStr)Sets the y axis label to yStrvoidsetLegendVisible(boolean visible)Accessor that tells whether to show the legend.voidsetMinorTickMarksVisible(boolean visible)Accessor that tells whether to show the minor tick marks.voidsetNumberOfXGridLines(int xGrid)Accessor that sets the number of gridlines for paint.voidsetNumberOfYGridLines(int yGrid)Accessor that sets the number of gridlines for paint.voidsetPointsAndLinesDisplay(int showPointsAndLines)Accessor that sets whether to display lines only, points and lines, or points onlyvoidsetRange(float min, float max)Sets the range of the graph according to the min and max parmaters.voidsetRangeSymmetric()DOCUMENT ME!voidsetTitle(java.lang.String tStr)Sets the title to this string.voidsetUserXGrid(boolean userXGrid)voidsetUserYGrid(boolean userYGrid)voidsetX1Vector(java.util.Vector<java.lang.Double> x1Vector)voidsetX2Vector(java.util.Vector<java.lang.Double> x2Vector)voidsetXGridUserPositions(int[] xGridUserPositions)voidsetY1Vector(java.util.Vector<java.lang.Double> y1Vector)voidsetY2Vector(java.util.Vector<java.lang.Double> y2Vector)voidsetYGridUserPositions(int[] yGridUserPositions)voidsetYInvert(int yInvert)voidupdate(java.awt.Graphics g)Calls paint.-
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, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUI, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, 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, updateUI
-
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, 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, getAccessibleContext, getBackground, 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, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
Use serialVersionUID for interoperability.- See Also:
- Constant Field Values
-
MAX_NUM_FUNCTS
public static final int MAX_NUM_FUNCTS
Maximum number of functions that the graph may display.- See Also:
- Constant Field Values
-
copiedXs
private static float[] copiedXs
DOCUMENT ME!
-
copiedYs
private static float[] copiedYs
DOCUMENT ME!
-
copiedName
private static java.lang.String copiedName
DOCUMENT ME!
-
copiedFunct
private static ViewJComponentFunct copiedFunct
DOCUMENT ME!
-
backgroundColor
private java.awt.Color backgroundColor
DOCUMENT ME!
-
bounds
private java.awt.Rectangle bounds
DOCUMENT ME!
-
crosshairCursor
private java.awt.Cursor crosshairCursor
DOCUMENT ME!
-
defaultCursor
private java.awt.Cursor defaultCursor
DOCUMENT ME!
-
defaultMaxDomain
private float defaultMaxDomain
DOCUMENT ME!
-
defaultMaxRange
private float defaultMaxRange
DOCUMENT ME!
-
defaultMinDomain
private float defaultMinDomain
DOCUMENT ME!
-
defaultMinRange
private float defaultMinRange
DOCUMENT ME!
-
fittedFunctions
private ViewJComponentFunct[] fittedFunctions
DOCUMENT ME!
-
font10
private java.awt.Font font10
DOCUMENT ME!
-
font12
private java.awt.Font font12
DOCUMENT ME!
-
font12B
private java.awt.Font font12B
DOCUMENT ME!
-
fun2Icon
private javax.swing.ImageIcon fun2Icon
DOCUMENT ME!
-
fun2PrintIcon
private javax.swing.ImageIcon fun2PrintIcon
DOCUMENT ME!
-
fun3Icon
private javax.swing.ImageIcon fun3Icon
DOCUMENT ME!
-
fun3PrintIcon
private javax.swing.ImageIcon fun3PrintIcon
DOCUMENT ME!
-
fun4Icon
private javax.swing.ImageIcon fun4Icon
DOCUMENT ME!
-
fun4PrintIcon
private javax.swing.ImageIcon fun4PrintIcon
DOCUMENT ME!
-
fun5Icon
private javax.swing.ImageIcon fun5Icon
DOCUMENT ME!
-
fun5PrintIcon
private javax.swing.ImageIcon fun5PrintIcon
DOCUMENT ME!
-
functions
private ViewJComponentFunct[] functions
DOCUMENT ME!
-
graphBounds
private java.awt.Rectangle graphBounds
DOCUMENT ME!
-
maxDomain
private float maxDomain
DOCUMENT ME!
-
maxRange
private float maxRange
DOCUMENT ME!
-
minDomain
private float minDomain
DOCUMENT ME!
-
minRange
private float minRange
DOCUMENT ME!
-
newX
private int[] newX
DOCUMENT ME!
-
newY
private int[] newY
DOCUMENT ME!
-
oldRubberband
private java.awt.Rectangle oldRubberband
DOCUMENT ME!
-
parentFrame
private javax.swing.JFrame parentFrame
DOCUMENT ME!
-
rubberbandRect
private RubberbandRectangle rubberbandRect
DOCUMENT ME!
-
showFittedFunctions
private boolean showFittedFunctions
DOCUMENT ME!
-
showFunctions
private boolean showFunctions
DOCUMENT ME!
-
showGridLines
private boolean showGridLines
DOCUMENT ME!
-
showLegend
private boolean showLegend
DOCUMENT ME!
-
showMinorTickMarks
private boolean showMinorTickMarks
DOCUMENT ME!
-
SHOW_LINES_ONLY
public static final int SHOW_LINES_ONLY
- See Also:
- Constant Field Values
-
SHOW_POINTS_AND_LINES
public static final int SHOW_POINTS_AND_LINES
- See Also:
- Constant Field Values
-
SHOW_POINTS_ONLY
public static final int SHOW_POINTS_ONLY
- See Also:
- Constant Field Values
-
showPointsAndLines
private int showPointsAndLines
DOCUMENT ME!
-
title
private java.lang.String title
DOCUMENT ME!
-
xGridLines
private int xGridLines
DOCUMENT ME!
-
xLabel
private java.lang.String xLabel
DOCUMENT ME!
-
xScale
private double xScale
DOCUMENT ME!
-
xTick
private double xTick
DOCUMENT ME!
-
yGridLines
private int yGridLines
DOCUMENT ME!
-
yLabel
private java.lang.String yLabel
DOCUMENT ME!
-
yScale
private double yScale
DOCUMENT ME!
-
yTick
private double yTick
DOCUMENT ME!
-
userXGrid
private boolean userXGrid
-
userYGrid
private boolean userYGrid
-
xGridUserPositions
private int[] xGridUserPositions
-
yGridUserPositions
private int[] yGridUserPositions
-
doLogX
private boolean doLogX
-
doLogY
private boolean doLogY
-
zeroXMin
private boolean zeroXMin
-
zeroYMin
private boolean zeroYMin
-
x1Vector
private java.util.Vector<java.lang.Double> x1Vector
-
y1Vector
private java.util.Vector<java.lang.Double> y1Vector
-
x2Vector
private java.util.Vector<java.lang.Double> x2Vector
-
y2Vector
private java.util.Vector<java.lang.Double> y2Vector
-
addSchwarzChristoffelLines
private boolean addSchwarzChristoffelLines
-
yInvert
private int yInvert
-
-
Constructor Detail
-
ViewJComponentGraph
public ViewJComponentGraph(javax.swing.JFrame frame, int width, int height)Constructor - creates graph within the JPanel using graphics.- Parameters:
frame- frame that this component is inwidth- initial width for the componentheight- initial height for the component
-
-
Method Detail
-
calculateCustomDomain
public void calculateCustomDomain()
-
calculateCustomRange
public void calculateCustomRange()
Calculates the range and domain (according to min and max y values). and expands range if necessary. (does not shrink range)
-
calculateDefaultRangeDomain
public void calculateDefaultRangeDomain()
Calculates the default range and domain (according to min and max x and y values). Modifies minRange, maxRange, minDomain, maxDomain accordingly.
-
copyFunct
public void copyFunct(int index)
Copies the indicated function's properties, to be pasted later as a new function.- Parameters:
index- - index of the function to be copied
-
deleteFunct
public void deleteFunct(int index)
Deletes the indicated function.- Parameters:
index- - index of the function to be deleted
-
getBackgroundColor
public java.awt.Color getBackgroundColor()
Accessor that gets the background color.- Returns:
- DOCUMENT ME!
-
getBounds
public java.awt.Rectangle getBounds()
Accessor that returns the bounds of the component.- Overrides:
getBoundsin classjava.awt.Component- Returns:
- rectangle bounds of the component
-
getMaxDomain
public float getMaxDomain()
-
getMinDomain
public float getMinDomain()
-
getDefaultMaxDomain
public float getDefaultMaxDomain()
Returns the default maximum point for the domain (previously calculated).- Returns:
- DOCUMENT ME!
-
getDefaultMinDomain
public float getDefaultMinDomain()
Returns the default minimum point for the domain (previously calculated).- Returns:
- DOCUMENT ME!
-
getDefaultMaxRange
public float getDefaultMaxRange()
Returns the default maximum point for the range (previously calculated).- Returns:
- DOCUMENT ME!
-
getDefaultMinRange
public float getDefaultMinRange()
Returns the default minimum point for the range (previously calculated).- Returns:
- DOCUMENT ME!
-
getFittedFunctionsVisible
public boolean getFittedFunctionsVisible()
Accessor that gets the visible flag.- Returns:
- the boolean visible flag
-
getFittedFuncts
public ViewJComponentFunct[] getFittedFuncts()
Accessor that gets the fitted functions for this graph.- Returns:
- an array of functions for this graph
-
getFunctionsVisible
public boolean getFunctionsVisible()
Accessor that gets the visible flag of the functions.- Returns:
- the boolean visible flag
-
getFuncts
public ViewJComponentFunct[] getFuncts()
Accessor that gets the functions for this graph.- Returns:
- an array of functions for this graph
-
getGridlinesVisible
public boolean getGridlinesVisible()
Accessor that gets the visible flag.- Returns:
- the boolean visible flag
-
getLegendVisible
public boolean getLegendVisible()
Accessor that gets the visible flag.- Returns:
- the boolean visible flag
-
getMaxRange
public float getMaxRange()
Returns the current maximum point for the range.- Returns:
- DOCUMENT ME!
-
getMinimumSize
public java.awt.Dimension getMinimumSize()
Accessor that returns the minimum size of this component.- Overrides:
getMinimumSizein classjavax.swing.JComponent- Returns:
- the minimum size
-
getMinorTickMarksVisible
public boolean getMinorTickMarksVisible()
Accessor that gets the visible flag.- Returns:
- the boolean visible flag
-
getMinRange
public float getMinRange()
Returns the current minimum point for the range.- Returns:
- DOCUMENT ME!
-
getNumberOfXGridLines
public int getNumberOfXGridLines()
Accessor that gets the number of gridlines for paint.- Returns:
- the number of gridlines on the x axis
-
getNumberOfYGridLines
public int getNumberOfYGridLines()
Accessor that gets the number of gridlines for paint.- Returns:
- the number of gridlines on the y axis
-
getPointsAndLinesDisplay
public int getPointsAndLinesDisplay()
Accessor that gets the visible flag.- Returns:
- the integer visible flag
-
getPreferredSize
public java.awt.Dimension getPreferredSize()
Accessor that returns the preferred size of the component.- Overrides:
getPreferredSizein classjavax.swing.JComponent- Returns:
- the preferred size
-
getTitle
public java.lang.String getTitle()
Gets the title for the graph.- Returns:
- title for the graph
-
getXLabel
public java.lang.String getXLabel()
Gets the label for the x axis.- Returns:
- label for the x axis
-
getYLabel
public java.lang.String getYLabel()
Gets the label for the y axis.- Returns:
- label for the y axis
-
mouseClicked
public void mouseClicked(java.awt.event.MouseEvent mouseEvent)
DOCUMENT ME!- Specified by:
mouseClickedin interfacejava.awt.event.MouseListener- Parameters:
mouseEvent- DOCUMENT ME!
-
mouseDragged
public void mouseDragged(java.awt.event.MouseEvent mouseEvent)
******************* Mouse Motion Events ***************************.********************************************* ***********************- Specified by:
mouseDraggedin interfacejava.awt.event.MouseMotionListener- Parameters:
mouseEvent- DOCUMENT ME!
-
mouseEntered
public void mouseEntered(java.awt.event.MouseEvent mouseEvent)
************************ Mouse Events *****************************.********************************************* ***********************- Specified by:
mouseEnteredin interfacejava.awt.event.MouseListener- Parameters:
mouseEvent- DOCUMENT ME!
-
mouseExited
public void mouseExited(java.awt.event.MouseEvent mouseEvent)
DOCUMENT ME!- Specified by:
mouseExitedin interfacejava.awt.event.MouseListener- Parameters:
mouseEvent- DOCUMENT ME!
-
mouseMoved
public void mouseMoved(java.awt.event.MouseEvent mouseEvent)
Changes the cursor to crosshair and enables the zoom box rubberband if the cursor is in the graph; also sees if cursor is near a valid point and prints it out.- Specified by:
mouseMovedin interfacejava.awt.event.MouseMotionListener- Parameters:
mouseEvent- event that triggered this function
-
mousePressed
public void mousePressed(java.awt.event.MouseEvent mouseEvent)
DOCUMENT ME!- Specified by:
mousePressedin interfacejava.awt.event.MouseListener- Parameters:
mouseEvent- DOCUMENT ME!
-
mouseReleased
public void mouseReleased(java.awt.event.MouseEvent mouseEvent)
Checks to see that the zoom box is valid, then redraws the graph using the zoom box as bounds.- Specified by:
mouseReleasedin interfacejava.awt.event.MouseListener- Parameters:
mouseEvent- event that triggered this function
-
paintComponent
public void paintComponent(java.awt.Graphics g)
Paints the graph. Checks if the labels are defined and draws them, checks if the gridlines should be shown and draws them, then calls PolyLine with the points.- Overrides:
paintComponentin classjavax.swing.JComponent- Parameters:
g- Graphics to paint in
-
paintComponentForPrinter
public void paintComponentForPrinter(java.awt.Graphics g)
Paints the graph for the Printer. Certain things such as background color and graph dimensions and location differ from the regular paint method- Parameters:
g- Graphics to paint in
-
pasteFunct
public void pasteFunct()
Adds the previously copied copied function to the graph.
-
redrawGraph
public void redrawGraph(java.awt.Rectangle newBounds)
Redraws the graph based on the new bounds. Used for zooming in on portions of the graph.- Parameters:
newBounds- the new bounds of the graph
-
resetBounds
public void resetBounds(java.awt.Rectangle rect)
Sets the bounds of the component.- Parameters:
rect- the new bounds for the component
-
setBackgroundColor
public void setBackgroundColor(java.awt.Color color)
Accessor that sets the background color to paint.- Parameters:
color- the new background color
-
setDefaultRangeDomain
public void setDefaultRangeDomain()
Sets range and domain to defaults.
-
setDoLogX
public void setDoLogX(boolean doLogX)
- Parameters:
doLogX-
-
setDoLogY
public void setDoLogY(boolean doLogY)
- Parameters:
doLogY-
-
setDomain
public void setDomain(float min, float max)Sets the domain of the graph according to the min and max parmaters.- Parameters:
min- minimum domainmax- maximum domain
-
setFittedFunctionsVisible
public void setFittedFunctionsVisible(boolean visible)
Accessor that tells whether to show the gridlines.- Parameters:
visible- boolean to set it to
-
setFittedFuncts
public void setFittedFuncts(ViewJComponentFunct[] functs)
Accessor that sets the fitted functions for this graph.- Parameters:
functs- function to set the graph to
-
setFunctionsVisible
public void setFunctionsVisible(boolean visible)
Accessor that tells whether to show the functions.- Parameters:
visible- boolean to set it to
-
setFuncts
public void setFuncts(ViewJComponentFunct[] functs)
Accessor that sets the function for this graph.- Parameters:
functs- function to set the graph to
-
setGridlinesVisible
public void setGridlinesVisible(boolean visible)
Accessor that tells whether to show the gridlines.- Parameters:
visible- boolean to set it to
-
setLabels
public void setLabels(java.lang.String xStr, java.lang.String yStr)Sets the labels for the x and y axis to these strings.- Parameters:
xStr- label for the x axisyStr- label for the y axis
-
setLabelY
public void setLabelY(java.lang.String yStr)
Sets the y axis label to yStr- Parameters:
yStr-
-
setLegendVisible
public void setLegendVisible(boolean visible)
Accessor that tells whether to show the legend.- Parameters:
visible- boolean to set it to
-
setMinorTickMarksVisible
public void setMinorTickMarksVisible(boolean visible)
Accessor that tells whether to show the minor tick marks.- Parameters:
visible- boolean to set it to
-
setNumberOfXGridLines
public void setNumberOfXGridLines(int xGrid)
Accessor that sets the number of gridlines for paint.- Parameters:
xGrid- the number of gridlines on the x axis
-
setNumberOfYGridLines
public void setNumberOfYGridLines(int yGrid)
Accessor that sets the number of gridlines for paint.- Parameters:
yGrid- the number of gridlines on the y axis
-
setPointsAndLinesDisplay
public void setPointsAndLinesDisplay(int showPointsAndLines)
Accessor that sets whether to display lines only, points and lines, or points only- Parameters:
visible- integer to set it to
-
setRange
public void setRange(float min, float max)Sets the range of the graph according to the min and max parmaters.- Parameters:
min- minimum rangemax- maximum range
-
setRangeSymmetric
public void setRangeSymmetric()
DOCUMENT ME!
-
setTitle
public void setTitle(java.lang.String tStr)
Sets the title to this string.- Parameters:
tStr- title for the graph
-
update
public void update(java.awt.Graphics g)
Calls paint.- Overrides:
updatein classjavax.swing.JComponent- Parameters:
g- Graphics to paint in
-
distance
private double distance(int x1, int y1, int x2, int y2)Tests the distance between two points.- Parameters:
x1- x coordinate of the first pointy1- y coordinate of the first pointx2- x coordinate of second pointy2- y coordinate of second point- Returns:
- returns the distance
-
makeString
private java.lang.String makeString(float number, int decPts)Makes a string of a float with a specific number of decimal points.- Parameters:
number- number to be converted to a stringdecPts- the number of decimal points- Returns:
- string representation of the number
-
plotGraph
public void plotGraph(java.awt.Graphics g)
Plots the graph by calling PolyLine. Makes new arrays for the x and y, scaling them to the graphics x and y. Also writes the tick mark labels.- Parameters:
g- graphics to draw in
-
plotSchwarzChristoffel
private void plotSchwarzChristoffel(java.awt.Graphics g)
-
plotGraphForPrinter
private void plotGraphForPrinter(java.awt.Graphics g)
Same as the plotGraph method, except the points used in this method are readable when sent to the printer.- Parameters:
g- graphics to draw in
-
getGraphBounds
public java.awt.Rectangle getGraphBounds()
-
drawString
public void drawString(java.awt.Graphics g, java.lang.String str, int x, int y)
-
drawLine
public void drawLine(java.awt.Graphics g, int x1, int y1, int x2, int y2)
-
setUserXGrid
public void setUserXGrid(boolean userXGrid)
-
setXGridUserPositions
public void setXGridUserPositions(int[] xGridUserPositions)
-
setUserYGrid
public void setUserYGrid(boolean userYGrid)
-
setYGridUserPositions
public void setYGridUserPositions(int[] yGridUserPositions)
-
setX1Vector
public void setX1Vector(java.util.Vector<java.lang.Double> x1Vector)
-
getX1Vector
public java.util.Vector<java.lang.Double> getX1Vector()
-
setX2Vector
public void setX2Vector(java.util.Vector<java.lang.Double> x2Vector)
-
getX2Vector
public java.util.Vector<java.lang.Double> getX2Vector()
-
setY1Vector
public void setY1Vector(java.util.Vector<java.lang.Double> y1Vector)
-
getY1Vector
public java.util.Vector<java.lang.Double> getY1Vector()
-
setY2Vector
public void setY2Vector(java.util.Vector<java.lang.Double> y2Vector)
-
getY2Vector
public java.util.Vector<java.lang.Double> getY2Vector()
-
setAddSchwarzChristoffelLines
public void setAddSchwarzChristoffelLines(boolean addSchwarzChristoffelLines)
-
setYInvert
public void setYInvert(int yInvert)
-
-