Class 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.MouseMotionListener
    This 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
    • Nested Class Summary

      • Nested classes/interfaces inherited from class javax.swing.JComponent

        javax.swing.JComponent.AccessibleJComponent
      • Nested classes/interfaces inherited from class java.awt.Container

        java.awt.Container.AccessibleAWTContainer
      • Nested classes/interfaces inherited from class java.awt.Component

        java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
    • 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
      void calculateCustomDomain()  
      void calculateCustomRange()
      Calculates the range and domain (according to min and max y values). and expands range if necessary.
      void calculateDefaultRangeDomain()
      Calculates the default range and domain (according to min and max x and y values).
      void copyFunct​(int index)
      Copies the indicated function's properties, to be pasted later as a new function.
      void deleteFunct​(int index)
      Deletes the indicated function.
      private double distance​(int x1, int y1, int x2, int y2)
      Tests the distance between two points.
      void drawLine​(java.awt.Graphics g, int x1, int y1, int x2, int y2)  
      void drawString​(java.awt.Graphics g, java.lang.String str, int x, int y)  
      java.awt.Color getBackgroundColor()
      Accessor that gets the background color.
      java.awt.Rectangle getBounds()
      Accessor that returns the bounds of the component.
      float getDefaultMaxDomain()
      Returns the default maximum point for the domain (previously calculated).
      float getDefaultMaxRange()
      Returns the default maximum point for the range (previously calculated).
      float getDefaultMinDomain()
      Returns the default minimum point for the domain (previously calculated).
      float getDefaultMinRange()
      Returns the default minimum point for the range (previously calculated).
      boolean getFittedFunctionsVisible()
      Accessor that gets the visible flag.
      ViewJComponentFunct[] getFittedFuncts()
      Accessor that gets the fitted functions for this graph.
      boolean getFunctionsVisible()
      Accessor that gets the visible flag of the functions.
      ViewJComponentFunct[] getFuncts()
      Accessor that gets the functions for this graph.
      java.awt.Rectangle getGraphBounds()  
      boolean getGridlinesVisible()
      Accessor that gets the visible flag.
      boolean getLegendVisible()
      Accessor that gets the visible flag.
      float getMaxDomain()  
      float getMaxRange()
      Returns the current maximum point for the range.
      float getMinDomain()  
      java.awt.Dimension getMinimumSize()
      Accessor that returns the minimum size of this component.
      boolean getMinorTickMarksVisible()
      Accessor that gets the visible flag.
      float getMinRange()
      Returns the current minimum point for the range.
      int getNumberOfXGridLines()
      Accessor that gets the number of gridlines for paint.
      int getNumberOfYGridLines()
      Accessor that gets the number of gridlines for paint.
      int getPointsAndLinesDisplay()
      Accessor that gets the visible flag.
      java.awt.Dimension getPreferredSize()
      Accessor that returns the preferred size of the component.
      java.lang.String getTitle()
      Gets the title for the graph.
      java.util.Vector<java.lang.Double> getX1Vector()  
      java.util.Vector<java.lang.Double> getX2Vector()  
      java.lang.String getXLabel()
      Gets the label for the x axis.
      java.util.Vector<java.lang.Double> getY1Vector()  
      java.util.Vector<java.lang.Double> getY2Vector()  
      java.lang.String getYLabel()
      Gets the label for the y axis.
      private java.lang.String makeString​(float number, int decPts)
      Makes a string of a float with a specific number of decimal points.
      void mouseClicked​(java.awt.event.MouseEvent mouseEvent)
      DOCUMENT ME!
      void mouseDragged​(java.awt.event.MouseEvent mouseEvent)
      ******************* Mouse Motion Events ***************************.********************************************* ***********************
      void mouseEntered​(java.awt.event.MouseEvent mouseEvent)
      ************************ Mouse Events *****************************.********************************************* ***********************
      void mouseExited​(java.awt.event.MouseEvent mouseEvent)
      DOCUMENT ME!
      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.
      void mousePressed​(java.awt.event.MouseEvent mouseEvent)
      DOCUMENT ME!
      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.
      void paintComponent​(java.awt.Graphics g)
      Paints the graph.
      void paintComponentForPrinter​(java.awt.Graphics g)
      Paints the graph for the Printer.
      void pasteFunct()
      Adds the previously copied copied function to the graph.
      void plotGraph​(java.awt.Graphics g)
      Plots the graph by calling PolyLine.
      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.
      private void plotSchwarzChristoffel​(java.awt.Graphics g)  
      void redrawGraph​(java.awt.Rectangle newBounds)
      Redraws the graph based on the new bounds.
      void resetBounds​(java.awt.Rectangle rect)
      Sets the bounds of the component.
      void setAddSchwarzChristoffelLines​(boolean addSchwarzChristoffelLines)  
      void setBackgroundColor​(java.awt.Color color)
      Accessor that sets the background color to paint.
      void setDefaultRangeDomain()
      Sets range and domain to defaults.
      void setDoLogX​(boolean doLogX)  
      void setDoLogY​(boolean doLogY)  
      void setDomain​(float min, float max)
      Sets the domain of the graph according to the min and max parmaters.
      void setFittedFunctionsVisible​(boolean visible)
      Accessor that tells whether to show the gridlines.
      void setFittedFuncts​(ViewJComponentFunct[] functs)
      Accessor that sets the fitted functions for this graph.
      void setFunctionsVisible​(boolean visible)
      Accessor that tells whether to show the functions.
      void setFuncts​(ViewJComponentFunct[] functs)
      Accessor that sets the function for this graph.
      void setGridlinesVisible​(boolean visible)
      Accessor that tells whether to show the gridlines.
      void setLabels​(java.lang.String xStr, java.lang.String yStr)
      Sets the labels for the x and y axis to these strings.
      void setLabelY​(java.lang.String yStr)
      Sets the y axis label to yStr
      void setLegendVisible​(boolean visible)
      Accessor that tells whether to show the legend.
      void setMinorTickMarksVisible​(boolean visible)
      Accessor that tells whether to show the minor tick marks.
      void setNumberOfXGridLines​(int xGrid)
      Accessor that sets the number of gridlines for paint.
      void setNumberOfYGridLines​(int yGrid)
      Accessor that sets the number of gridlines for paint.
      void setPointsAndLinesDisplay​(int showPointsAndLines)
      Accessor that sets whether to display lines only, points and lines, or points only
      void setRange​(float min, float max)
      Sets the range of the graph according to the min and max parmaters.
      void setRangeSymmetric()
      DOCUMENT ME!
      void setTitle​(java.lang.String tStr)
      Sets the title to this string.
      void setUserXGrid​(boolean userXGrid)  
      void setUserYGrid​(boolean userYGrid)  
      void setX1Vector​(java.util.Vector<java.lang.Double> x1Vector)  
      void setX2Vector​(java.util.Vector<java.lang.Double> x2Vector)  
      void setXGridUserPositions​(int[] xGridUserPositions)  
      void setY1Vector​(java.util.Vector<java.lang.Double> y1Vector)  
      void setY2Vector​(java.util.Vector<java.lang.Double> y2Vector)  
      void setYGridUserPositions​(int[] yGridUserPositions)  
      void setYInvert​(int yInvert)  
      void update​(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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • 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!
      • 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!
      • 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!
      • 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!
      • 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!
      • 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 in
        width - initial width for the component
        height - 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:
        getBounds in class java.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:
        getMinimumSize in class javax.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:
        getPreferredSize in class javax.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:
        mouseClicked in interface java.awt.event.MouseListener
        Parameters:
        mouseEvent - DOCUMENT ME!
      • mouseDragged

        public void mouseDragged​(java.awt.event.MouseEvent mouseEvent)
        ******************* Mouse Motion Events ***************************.********************************************* ***********************
        Specified by:
        mouseDragged in interface java.awt.event.MouseMotionListener
        Parameters:
        mouseEvent - DOCUMENT ME!
      • mouseEntered

        public void mouseEntered​(java.awt.event.MouseEvent mouseEvent)
        ************************ Mouse Events *****************************.********************************************* ***********************
        Specified by:
        mouseEntered in interface java.awt.event.MouseListener
        Parameters:
        mouseEvent - DOCUMENT ME!
      • mouseExited

        public void mouseExited​(java.awt.event.MouseEvent mouseEvent)
        DOCUMENT ME!
        Specified by:
        mouseExited in interface java.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:
        mouseMoved in interface java.awt.event.MouseMotionListener
        Parameters:
        mouseEvent - event that triggered this function
      • mousePressed

        public void mousePressed​(java.awt.event.MouseEvent mouseEvent)
        DOCUMENT ME!
        Specified by:
        mousePressed in interface java.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:
        mouseReleased in interface java.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:
        paintComponent in class javax.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 domain
        max - 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 axis
        yStr - 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 range
        max - 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:
        update in class javax.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 point
        y1 - y coordinate of the first point
        x2 - x coordinate of second point
        y2 - 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 string
        decPts - 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)