Prog1Tools
Class FunctionPlotter

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Frame
                  extended by javax.swing.JFrame
                      extended by Prog1Tools.Screen
                          extended by Prog1Tools.GraphicScreen
                              extended by Prog1Tools.FunctionPlotter
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants, FunctionPlotterSpec, GraphicScreenSpec, ScreenSpec

public class FunctionPlotter
extends GraphicScreen
implements FunctionPlotterSpec

Plotter auf Basis der Klasse GraphicScreen zur Darstellung von Funktionsgraphen.

Version:
1.0
Author:
hagen.buchwald@kit.edu
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JFrame
javax.swing.JFrame.AccessibleJFrame
 
Nested classes/interfaces inherited from class java.awt.Frame
java.awt.Frame.AccessibleAWTFrame
 
Nested classes/interfaces inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
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
 
Field Summary
 
Fields inherited from class Prog1Tools.GraphicScreen
HEIGHT, ITEMS, ORIGIN_X, ORIGIN_Y, WIDTH
 
Fields inherited from class Prog1Tools.Screen
choosenColor, choosenFile, debug, fileChooser, fileFilter, fontName, fontSize, fontStyle, keyListener, mouseListener, player, selectedKeyChar, selectedKeyCode, selectedMouseButton, selectedOption, selectedSource, seq, track
 
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface Prog1Tools.FunctionPlotterSpec
MARGIN, X_OFFSET, Y_OFFSET
 
Fields inherited from interface Prog1Tools.ScreenSpec
APPROVE_FILE, BLACK, BLACK_B, BLACK_G, BLACK_R, BLUE, BLUE_B, BLUE_G, BLUE_R, BLUE2, BLUE2_B, BLUE2_G, BLUE2_R, BLUE3, BLUE3_B, BLUE3_G, BLUE3_R, BROWN, BROWN_B, BROWN_G, BROWN_R, BROWN2, BROWN2_B, BROWN2_G, BROWN2_R, CANCEL_FILE, CANCEL_OPTION, CLOSED_OPTION, COLUMNS, DELIMITER, FONT_NAME, FONT_SIZE, FONT_STYLE, GREEN, GREEN_B, GREEN_G, GREEN_R, GREEN2, GREEN2_B, GREEN2_G, GREEN2_R, GREY, GREY_B, GREY_G, GREY_R, GREY2, GREY2_B, GREY2_G, GREY2_R, KEYCHAR_RESET_VALUE, KEYCODE_RESET_VALUE, MAX_X, MAX_Y, MOUSEBUTTON_RESET_VALUE, NO_OPTION, OK_OPTION, ORANGE, ORANGE_B, ORANGE_G, ORANGE_R, PURPLE, PURPLE_B, PURPLE_G, PURPLE_R, RED, RED_B, RED_G, RED_R, ROWS, WHITE, WHITE_B, WHITE_G, WHITE_R, YES_OPTION
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, PROPERTIES, SOMEBITS
 
Constructor Summary
FunctionPlotter(int width, int height)
          Konstruktor.
 
Method Summary
 void drawAbscissae()
          Kommando zum Zeichnen der x-Achse (Abszisse).
 void drawCoordinateSystem()
          Kommando zum Zeichnen des Koordinaten-Systems.
 void drawGraph(double[] xValues, double[] yValues, boolean isFilled)
          Kommando zum Zeichnen eines Funktionsgraphen im Wertebereich anhand einer Wertetabelle.
 void drawGraph(FunctionSpec function, boolean isFilled)
          Kommando zum Zeichnen des Graphen der uebergebenen Funktion f(x) im Wertebereich.
 void drawOrdinate()
          Kommando zum Zeichnen der y-Achse (Ordinate).
static FunctionPlotter getInstance()
          Statische Methode zur einfachen Erzeugung eines Funktions-Plotters.
static FunctionPlotter getInstance(int width, int height)
          Statische Methode zur einfachen Erzeugung eines Funktions-Plotters.
 double getLeftX()
          Abfrage des linken Rands des Wertebereichs, der von der x-Achse abgedeckt wird.
 double getLowerY()
          Abfrage des unteren Rands des Wertebereichs, der von der y-Achse abgedeckt wird.
 double getRightX()
          Abfrage des rechten Rands des Wertebereichs, der von der x-Achse abgedeckt wird.
 double getUpperY()
          Abfrage des oberen Rands des Wertebereichs, der von der y-Achse abgedeckt wird.
 double ratio()
           
 int rel2absX(double xRelative)
           
 int rel2absY(double yRelative)
           
 void setXRange(double leftX, double rightX)
          Kommando zum Setzen des Wertebereichs, der von der x-Achse abgedeckt werden soll.
 void setYRange(double lowerY, double upperY)
          Kommando zum Setzen des Wertebereichs, der von der y-Achse abgedeckt werden soll.
 
Methods inherited from class Prog1Tools.GraphicScreen
clearScreen, drawArc, drawCircle, drawLine, drawOrigin, drawOval, drawPolygon, drawPolyline, drawRectangle, drawRectangle3D, drawRectangleRounded, drawText, getColor, getItem, getMaxNumberOfItems, getMaxX, getMaxY, getNumberOfItems, getOrigin, paint, setColor, setOrigin
 
Methods inherited from class Prog1Tools.Screen
clearScreen, getChoosenColor, getChoosenFile, getSelectedKeyChar, getSelectedKeyCode, getSelectedMouseButton, getSelectedOption, pause, playSound, readBoolean, readByte, readChar, readDouble, readFloat, readInt, readLine, readLong, readShort, resetFont, resetKeyEvent, resetMouseEvent, setDebug, setFont, setResizable, showColorChooserDialog, showConfirmDialog, showFileOpenDialog, showFileSaveDialog, showInputDialogComboBox, showMessageDialog, showOptionDialogAbbruchOK, showOptionDialogJaNein
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
 
Methods inherited from class java.awt.Frame
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setState, setTitle, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOwnedWindows, getOwner, getOwnerlessWindows, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setVisible, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, setBackground, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface Prog1Tools.GraphicScreenSpec
clearScreen, repaint
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Constructor Detail

FunctionPlotter

public FunctionPlotter(int width,
                       int height)
Konstruktor.

Parameters:
width - Breite des FunctionPlotter-Fensters.
height - Hoehe des FunctionPlotter-Fensters.
Method Detail

getInstance

public static FunctionPlotter getInstance()
Statische Methode zur einfachen Erzeugung eines Funktions-Plotters. Wiederholte Aufrufe dieser Methode liefern stets die gleiche Instanz (Singleton-Pattern).

Returns:
singulaere Instanz der Klasse FunctionPlotter

getInstance

public static FunctionPlotter getInstance(int width,
                                          int height)
Statische Methode zur einfachen Erzeugung eines Funktions-Plotters. Wiederholte Aufrufe dieser Methode liefern stets die gleiche Instanz (Singleton-Pattern).

Parameters:
width - Breite des FunctionPlotter-Bildschirms in Pixel
height - Hoehe des FunctionPlotter-Bildschirms in Pixel
Returns:
singulaere Instanz der Klasse FunctionPlotter

setXRange

public void setXRange(double leftX,
                      double rightX)
Description copied from interface: FunctionPlotterSpec
Kommando zum Setzen des Wertebereichs, der von der x-Achse abgedeckt werden soll.

Specified by:
setXRange in interface FunctionPlotterSpec
rightX - rechter Rand des Wertebereichs

setYRange

public void setYRange(double lowerY,
                      double upperY)
Description copied from interface: FunctionPlotterSpec
Kommando zum Setzen des Wertebereichs, der von der y-Achse abgedeckt werden soll.

Specified by:
setYRange in interface FunctionPlotterSpec
Parameters:
lowerY - unterer Rand des Wertebereichs
upperY - oberer Rand des Wertebereichs

getLeftX

public double getLeftX()
Description copied from interface: FunctionPlotterSpec
Abfrage des linken Rands des Wertebereichs, der von der x-Achse abgedeckt wird.

Specified by:
getLeftX in interface FunctionPlotterSpec

getRightX

public double getRightX()
Description copied from interface: FunctionPlotterSpec
Abfrage des rechten Rands des Wertebereichs, der von der x-Achse abgedeckt wird.

Specified by:
getRightX in interface FunctionPlotterSpec

getLowerY

public double getLowerY()
Description copied from interface: FunctionPlotterSpec
Abfrage des unteren Rands des Wertebereichs, der von der y-Achse abgedeckt wird.

Specified by:
getLowerY in interface FunctionPlotterSpec

getUpperY

public double getUpperY()
Description copied from interface: FunctionPlotterSpec
Abfrage des oberen Rands des Wertebereichs, der von der y-Achse abgedeckt wird.

Specified by:
getUpperY in interface FunctionPlotterSpec

drawAbscissae

public void drawAbscissae()
Description copied from interface: FunctionPlotterSpec
Kommando zum Zeichnen der x-Achse (Abszisse). Der Wert x = 0 liegt genau im Ursprung.

Specified by:
drawAbscissae in interface FunctionPlotterSpec

drawOrdinate

public void drawOrdinate()
Description copied from interface: FunctionPlotterSpec
Kommando zum Zeichnen der y-Achse (Ordinate). Der Wert y = 0 liegt genau im Ursprung.

Specified by:
drawOrdinate in interface FunctionPlotterSpec

drawCoordinateSystem

public void drawCoordinateSystem()
Description copied from interface: FunctionPlotterSpec
Kommando zum Zeichnen des Koordinaten-Systems. Der Nullpunkt des Koordinatensystems liegt im Ursprung des Screens.

Specified by:
drawCoordinateSystem in interface FunctionPlotterSpec

drawGraph

public void drawGraph(double[] xValues,
                      double[] yValues,
                      boolean isFilled)
Description copied from interface: FunctionPlotterSpec
Kommando zum Zeichnen eines Funktionsgraphen im Wertebereich anhand einer Wertetabelle.

Specified by:
drawGraph in interface FunctionPlotterSpec
Parameters:
xValues - x-Werte der Wertetabelle
isFilled - bei false wird nur die Linie des Graphen in der aktuellen Farbe gezeichnet; bei true wird zusaetzlich der Bereich zwischen x-Achse und Graph mit der aktuellen Zeichenfarbe gefüllt.

drawGraph

public void drawGraph(FunctionSpec function,
                      boolean isFilled)
Description copied from interface: FunctionPlotterSpec
Kommando zum Zeichnen des Graphen der uebergebenen Funktion f(x) im Wertebereich.

Specified by:
drawGraph in interface FunctionPlotterSpec
Parameters:
function - Funktion f(x)
isFilled - bei false wird nur die Linie des Graphen in der aktuellen Farbe gezeichnet; bei true wird zusaetzlich der Bereich zwischen x-Achse und Graph mit der aktuellen Zeichenfarbe gefüllt.

rel2absX

public int rel2absX(double xRelative)

rel2absY

public int rel2absY(double yRelative)

ratio

public double ratio()