Package moa.gui.visualization
Class AbstractGraphCanvas
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- moa.gui.visualization.AbstractGraphCanvas
-
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
,Accessible
- Direct Known Subclasses:
ParamGraphCanvas
,ProcessGraphCanvas
public abstract class AbstractGraphCanvas extends JPanel
AbstractGraphCanvas is an abstract class offering scaling functionality and the structure of the underlying Axes and Plot classes. The functionality of the scaling is as following: the size of the canvas is determined by two sizes: the size itself and the preferredSize, which is used by the parental viewport to set its size. If the window is rescaled (e.g. by dragging the window) the preferred size does not change, which results in setting the size to the viewport size. If the y axis is zoomed, the baseHeight determines the new size and preferred size. This class is partially based on GraphCanvas.- Version:
- $Revision: 1 $
- Author:
- Tim Sabsch (tim.sabsch@ovgu.de)
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
-
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
-
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
-
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
-
Field Summary
Fields Modifier and Type Field Description protected AbstractGraphAxes
axesPanel
protected double
baseHeight
protected double
baseWidth
protected double
max_x_value
protected double
max_y_value
protected MeasureCollection[]
measures
protected int
measureSelected
protected MeasureCollection[]
measureStds
protected double
min_x_value
protected AbstractGraphPlot
plotPanel
protected static int
X_OFFSET_LEFT
protected static int
X_OFFSET_RIGHT
protected double
x_resolution
protected static int
Y_OFFSET_BOTTOM
protected static int
Y_OFFSET_TOP
protected double
y_resolution
-
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
-
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
-
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
-
Constructor Summary
Constructors Constructor Description AbstractGraphCanvas(AbstractGraphAxes ax, AbstractGraphPlot g)
Initialises an AbstractGraphCanvas by constructing its AbstractGraphAxes, AbstractGraphPlot as well as setting initial sizes.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract double
getMaxXValue()
Returns the maximum value for the x-axis.abstract double
getMinXValue()
Returns the minimum value for the x-axis.protected void
paintChildren(Graphics g)
void
scaleXResolution(double factor)
Scales the resolution on the x-axis by the given factor and updates the canvas.void
scaleYResolution(double factor)
Scales the resolution on the y-axis by the given factor and updates the canvas.void
setMeasureSelected(int selected)
Sets the currently selected measure index.abstract void
setPreferredSize()
Sets the preferred canvas size.abstract void
setSize()
Sets the canvas size.void
setStandardDeviationPainted(boolean b)
Sets the value of the plotPlanel for isStandardDeviationPainted.void
updateCanvas(boolean force)
Updates the canvas: if values have changed or it is forced, the canvas and preferred sizes are updated and the canvas is repainted.-
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
-
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, 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, paint, paintBorder, 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
-
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, 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, 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
-
measures
protected MeasureCollection[] measures
-
measureStds
protected MeasureCollection[] measureStds
-
measureSelected
protected int measureSelected
-
axesPanel
protected AbstractGraphAxes axesPanel
-
plotPanel
protected AbstractGraphPlot plotPanel
-
X_OFFSET_LEFT
protected static final int X_OFFSET_LEFT
- See Also:
- Constant Field Values
-
X_OFFSET_RIGHT
protected static final int X_OFFSET_RIGHT
- See Also:
- Constant Field Values
-
Y_OFFSET_BOTTOM
protected static final int Y_OFFSET_BOTTOM
- See Also:
- Constant Field Values
-
Y_OFFSET_TOP
protected static final int Y_OFFSET_TOP
- See Also:
- Constant Field Values
-
min_x_value
protected double min_x_value
-
max_x_value
protected double max_x_value
-
max_y_value
protected double max_y_value
-
x_resolution
protected double x_resolution
-
y_resolution
protected double y_resolution
-
baseWidth
protected double baseWidth
-
baseHeight
protected double baseHeight
-
-
Constructor Detail
-
AbstractGraphCanvas
public AbstractGraphCanvas(AbstractGraphAxes ax, AbstractGraphPlot g)
Initialises an AbstractGraphCanvas by constructing its AbstractGraphAxes, AbstractGraphPlot as well as setting initial sizes.
-
-
Method Detail
-
setStandardDeviationPainted
public void setStandardDeviationPainted(boolean b)
Sets the value of the plotPlanel for isStandardDeviationPainted.- Parameters:
b
- new setting for isStandardDeviationPainted in the plotPanel
-
scaleXResolution
public void scaleXResolution(double factor)
Scales the resolution on the x-axis by the given factor and updates the canvas.- Parameters:
factor
- factor the x_resolution will be scaled by
-
scaleYResolution
public void scaleYResolution(double factor)
Scales the resolution on the y-axis by the given factor and updates the canvas. The y-resolution must not be lower than 1.- Parameters:
factor
- factor the y_resolution will be scaled by
-
setMeasureSelected
public void setMeasureSelected(int selected)
Sets the currently selected measure index.- Parameters:
selected
- new selected measure
-
updateCanvas
public void updateCanvas(boolean force)
Updates the canvas: if values have changed or it is forced, the canvas and preferred sizes are updated and the canvas is repainted. Size and preferred size are determined by the subclass extending AbstractGraphCanvas.- Parameters:
force
- enforce repainting
-
setSize
public abstract void setSize()
Sets the canvas size.
-
setPreferredSize
public abstract void setPreferredSize()
Sets the preferred canvas size.
-
getMinXValue
public abstract double getMinXValue()
Returns the minimum value for the x-axis.
-
getMaxXValue
public abstract double getMaxXValue()
Returns the maximum value for the x-axis.
-
paintChildren
protected void paintChildren(Graphics g)
- Overrides:
paintChildren
in classJComponent
-
-