Package adams.gui.visualization.core
Class AxisPanel
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- adams.gui.core.BasePanel
-
- adams.gui.visualization.core.AxisPanel
-
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
,Accessible
public class AxisPanel extends BasePanel
Specialized panel for displaying an axis.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- 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 Color
m_AxisColor
the axis color.protected String
m_AxisName
the name of the axis.protected boolean
m_AxisNameCentered
whether the axis name is centered in the axis and not at the border.protected Font
m_AxisNameFont
the font for the axis name.protected int
m_AxisWidth
the width of the axis (for HORIZONTAL axes, this is the height, of course).protected HashSet<ChangeListener>
m_ChangeListeners
the paint listeners.protected Direction
m_Direction
the direction of the axis.protected int
m_LengthTicks
the length of the ticks.protected AbstractAxisModel
m_Model
the axis model.protected Hashtable<Type,String>
m_NumberFormatOverride
for overriding the default number formats.protected Orientation
m_Orientation
the orientation of the axis.protected PopupMenuCustomizer
m_PopupMenuCustomizer
an optional customizer for the right-click popup.protected AxisPanel
m_Self
the panel itself.protected boolean
m_ShowGridLines
whether to show the coordinate lines for this axis.protected Type
m_Type
the type of axis.protected Visibility
m_Visibility
the visibility state of the axis.-
Fields inherited from class adams.gui.core.BasePanel
m_FileChooser
-
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 AxisPanel(Direction direction, Orientation orientation, Type type)
Initializes the axis, with color black and 10 ticks, width 20.AxisPanel(Direction direction, Orientation orientation, Type type, int ticks)
Initializes the axis, with color black, width 20.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addChangeListener(ChangeListener l)
Adds the given listener to the internal list of change listeners.void
addNumberFormatOverride(Type type, String format)
Adds the format override for the specified type.void
assign(AxisPanel other)
Obtains all the settings from the other panel.protected void
calculateDimensions()
calculates and sets the preferred size of the axis.boolean
canZoom(double min, double max)
Checks whether we can still zoom in.void
clearPanning()
Clears the panning.void
clearZoom()
Removes all zooms.protected void
copyMargins()
Copies the margins to the clipboard.protected void
copyRange()
Copies the range to the clipboard.int
correctPosition(int pos)
"corrects" the position for an origin at bottom-left corner instead of top-left corner, in case of a VERTICAL axis.void
drawBar(Graphics g)
draws the bar.protected void
drawName(Graphics g)
draws the axis name.protected void
drawTicks(Graphics g)
draws the ticks.protected void
editTickGenerator()
Allows the user to edit the tick generator.int
getActualAxisWidth()
Returns the actual axis width, depending on the visibility.double
getActualMaximum()
Returns the actual maximum on the axis (incl zoom/panning).double
getActualMaximumNoMargin()
Returns the actual maximum on the axis (excl margins).double
getActualMinimum()
Returns the actual minimum on the axis (incl zoom/panning).double
getActualMinimumNoMargin()
Returns the actual minimum on the axis (excl margins).Color
getAxisColor()
Returns the color of the axis.AbstractAxisModel
getAxisModel()
Returns the underlying axis model.String
getAxisName()
Returns the name of the axis, null or empty string if none set.Font
getAxisNameFont()
Returns the font being used for the axis name.int
getAxisWidth()
Returns the current width of the axis.double
getBottomMargin()
Returns the currently set bottom margin factor (>= 0.0).Direction
getDirection()
Returns the direction of the axis.int
getLength()
Depending on direction, either returns width (= HORIZONTAL) or height (= VERTICAL).int
getLengthTicks()
Returns the length of ticks currently displayed.Double
getManualBottomMargin()
Returns the currently set manual bottom margin factor (>= 0.0 or null).Double
getManualMaximum()
Returns the currently set manual maximum on the axis.Double
getManualMinimum()
Returns the currently set manual minimum on the axis.Double
getManualTopMargin()
Returns the currently set manual top margin factor (>= 0.0 or null).double
getMaximum()
Returns the currently set maximum on the axis.double
getMinimum()
Returns the currently set minimum on the axis.int
getNthValueToShow()
Returns the count of ticks a value is shown, i.e., "3" means every third tick: 1, 4, 7, ...String
getNumberFormat()
Returns the pattern used for displaying the numbers on the axis.String
getNumberFormatOverride(Type type)
Returns the format override for the specified type, null if non-existing.Orientation
getOrientation()
Returns the orientation of the axis.int
getPixelOffset()
Returns the current pixel offset.BasePopupMenu
getPopupMenu(MouseEvent e)
Returns the popup menu, potentially customized.PopupMenuCustomizer
getPopupMenuCustomizer()
Returns the current customizer, can be null.BaseInterval
getRange()
Returns the current range of the axis.boolean
getShowGridLines()
Returns whether the grid lines are displayed.TickGenerator
getTickGenerator()
Returns the current tick generator in use.double
getTopMargin()
Returns the currently set top margin factor (>= 0.0).Type
getType()
Returns the type of axis.Visibility
getVisibility()
Returns the visibility of the axis.boolean
hasNumberFormatOverride(Type type)
Returns whether an override format is available for the specified type.protected boolean
hasOverlap(Tick tick1, Tick tick2)
Checks whether there is an overlap between the labels of the two Ticks.boolean
isAxisNameCentered()
Returns whether the axis name is centered in the axis or at the border.protected boolean
isFirst(List<Tick> ticks, int i, boolean flipped, int max)
Checks whether the tick is the first one.protected boolean
isLast(List<Tick> ticks, int i, boolean flipped, int max)
Checks whether the tick is the last one.boolean
isZoomed()
Returns true if the axis is currently zoomed.void
notifyChangeListeners()
Notifies all change listeners.void
paintComponent(Graphics g)
draws the axis.protected void
pasteMargins()
Pastes the margins from the clipboard, if possible.protected void
pasteRange()
Pastes the range from the clipboard, if possible.void
popZoom()
Removes the latest zoom, if available.double
posToValue(int pos)
Returns the value for the given position according to the settings (min and max).void
pushZoom(double min, double max)
Adds the zoom to its internal list and updates the axis.void
removeChangeListener(ChangeListener l)
Removes the given listener from the internal list of change listeners.void
removeNumberFormatOverride(Type type)
Removes the format override for the specified type.void
resetMargins()
Resets any manually set margins for the axis.void
resetRange()
Resets any manually set range for the axis.void
selectMargins()
Pops up a dialog letting the user choose the margins (top/bottom) for the axis.void
selectRange()
Pops up a dialog letting the user choose the range (min/max) for the axis.void
setAxisColor(Color value)
Sets the color of the axis.void
setAxisName(String value)
Sets the name of the axis, null or empty string for none.void
setAxisNameCentered(boolean value)
Sets whether the axis name is centered in the axis or at the border.void
setAxisNameFont(Font value)
Sets the font to use for the axis name.void
setAxisWidth(int value)
Sets the width of the axis (this is height for HORIZONTAL axes, of course), at least 5 pixel.void
setBottomMargin(double value)
Sets the bottom margin factor (>= 0.0).void
setDirection(Direction value)
Sets the direction of the axis.void
setLengthTicks(int value)
Sets the length of ticks to display along the axis (at least 4).void
setManualBottomMargin(Double value)
Sets the manual bottom margin factor (>= 0.0 or null).void
setManualMaximum(Double value)
Sets the manual maximum to display on the axis.void
setManualMinimum(Double value)
Sets the manual minimum to display on the axis.void
setManualTopMargin(Double value)
Sets the manual top margin factor (>= 0.0 or null).void
setMaximum(double value)
Sets the maximum to display on the axis.void
setMinimum(double value)
Sets the minimum to display on the axis.void
setNthValueToShow(int value)
Sets the count of ticks a value is shown, i.e., "3" means every third tick: 1, 4, 7, ...void
setNumberFormat(String value)
Sets the pattern used for displaying the numbers on the axis.void
setOrientation(Orientation value)
Sets the orientation of the axis.void
setPixelOffset(int value)
Sets the pixel offset due to panning.void
setPopupMenuCustomizer(PopupMenuCustomizer value)
Sets the class to customize the right-click popup menu.void
setRange(BaseInterval value)
Sets the current range of the axis.void
setShowGridLines(boolean value)
Enables/disables the display of grid lines for this axis.void
setTickGenerator(TickGenerator value)
Sets tick generator to use.void
setTopMargin(double value)
Sets the top margin factor (>= 0.0).void
setType(Type value)
Sets the type of axis.void
setVisibility(Visibility value)
Sets the visibility of the axis.protected boolean
skipLabel(List<Tick> ticks, int i)
Checks whether the tick is to be skipped.String
toString()
Returns a short description of the axis.String
valueToDisplay(double value)
Transforms the given value into the display (absolute, percentage, log, etc.) format.int
valueToPos(double value)
Returns the position for the given value according to the settings (min and max).-
Methods inherited from class adams.gui.core.BasePanel
afterHide, afterShow, beforeHide, beforeShow, closeParent, finishInit, getParentChild, getParentDialog, getParentFrame, getParentInternalFrame, getParentTitle, initFileChooser, initGUI, initialize, main, printErrorMessage, printException, saveComponent, setEnabledCascade, setEnabledCascade, setParentTitle, setVisible
-
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, paintChildren, 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, 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, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Field Detail
-
m_Self
protected AxisPanel m_Self
the panel itself.
-
m_Direction
protected Direction m_Direction
the direction of the axis.
-
m_Orientation
protected Orientation m_Orientation
the orientation of the axis.
-
m_Type
protected Type m_Type
the type of axis.
-
m_AxisColor
protected Color m_AxisColor
the axis color.
-
m_AxisWidth
protected int m_AxisWidth
the width of the axis (for HORIZONTAL axes, this is the height, of course).
-
m_AxisName
protected String m_AxisName
the name of the axis.
-
m_AxisNameFont
protected Font m_AxisNameFont
the font for the axis name.
-
m_AxisNameCentered
protected boolean m_AxisNameCentered
whether the axis name is centered in the axis and not at the border.
-
m_LengthTicks
protected int m_LengthTicks
the length of the ticks.
-
m_PopupMenuCustomizer
protected PopupMenuCustomizer m_PopupMenuCustomizer
an optional customizer for the right-click popup.
-
m_ChangeListeners
protected HashSet<ChangeListener> m_ChangeListeners
the paint listeners.
-
m_Model
protected AbstractAxisModel m_Model
the axis model.
-
m_NumberFormatOverride
protected Hashtable<Type,String> m_NumberFormatOverride
for overriding the default number formats.
-
m_ShowGridLines
protected boolean m_ShowGridLines
whether to show the coordinate lines for this axis.
-
m_Visibility
protected Visibility m_Visibility
the visibility state of the axis.
-
-
Constructor Detail
-
AxisPanel
public AxisPanel(Direction direction, Orientation orientation, Type type)
Initializes the axis, with color black and 10 ticks, width 20.- Parameters:
direction
- the direction of the axisorientation
- the orientation of the axistype
- the type of axis
-
AxisPanel
public AxisPanel(Direction direction, Orientation orientation, Type type, int ticks)
Initializes the axis, with color black, width 20.- Parameters:
direction
- the direction of the axisorientation
- the orientation of the axistype
- the type of axisticks
- the number of ticks on the axis
-
-
Method Detail
-
assign
public void assign(AxisPanel other)
Obtains all the settings from the other panel. Does not re-use thePopupMenuCustomizer
.- Parameters:
other
- the panel to get the settings from
-
valueToDisplay
public String valueToDisplay(double value)
Transforms the given value into the display (absolute, percentage, log, etc.) format.- Parameters:
value
- the value to transform- Returns:
- the display value
-
calculateDimensions
protected void calculateDimensions()
calculates and sets the preferred size of the axis.
-
setDirection
public void setDirection(Direction value)
Sets the direction of the axis.- Parameters:
value
- the direction
-
getDirection
public Direction getDirection()
Returns the direction of the axis.- Returns:
- the direction
-
setOrientation
public void setOrientation(Orientation value)
Sets the orientation of the axis.- Parameters:
value
- the orientation
-
getOrientation
public Orientation getOrientation()
Returns the orientation of the axis.- Returns:
- the orientation
-
setType
public void setType(Type value)
Sets the type of axis.- Parameters:
value
- the type
-
getType
public Type getType()
Returns the type of axis.- Returns:
- the type
-
setAxisColor
public void setAxisColor(Color value)
Sets the color of the axis.- Parameters:
value
- the color to use
-
getAxisColor
public Color getAxisColor()
Returns the color of the axis.- Returns:
- the current color
-
setTickGenerator
public void setTickGenerator(TickGenerator value)
Sets tick generator to use.- Parameters:
value
- the tick generator
-
getTickGenerator
public TickGenerator getTickGenerator()
Returns the current tick generator in use.- Returns:
- the tick generator
-
setNthValueToShow
public void setNthValueToShow(int value)
Sets the count of ticks a value is shown, i.e., "3" means every third tick: 1, 4, 7, ...- Parameters:
value
- the count
-
getNthValueToShow
public int getNthValueToShow()
Returns the count of ticks a value is shown, i.e., "3" means every third tick: 1, 4, 7, ...- Returns:
- the count
-
setLengthTicks
public void setLengthTicks(int value)
Sets the length of ticks to display along the axis (at least 4).- Parameters:
value
- the length of ticks
-
getLengthTicks
public int getLengthTicks()
Returns the length of ticks currently displayed.- Returns:
- the legnth of ticks
-
setAxisWidth
public void setAxisWidth(int value)
Sets the width of the axis (this is height for HORIZONTAL axes, of course), at least 5 pixel.- Parameters:
value
- the new width
-
getAxisWidth
public int getAxisWidth()
Returns the current width of the axis.- Returns:
- the width
-
getActualAxisWidth
public int getActualAxisWidth()
Returns the actual axis width, depending on the visibility.- Returns:
- the axis width if visible, otherwise 0
-
setAxisName
public void setAxisName(String value)
Sets the name of the axis, null or empty string for none.- Parameters:
value
- the name of the axis
-
getAxisName
public String getAxisName()
Returns the name of the axis, null or empty string if none set.- Returns:
- the name of the axis or null
-
setAxisNameFont
public void setAxisNameFont(Font value)
Sets the font to use for the axis name.- Parameters:
value
- the font to use
-
getAxisNameFont
public Font getAxisNameFont()
Returns the font being used for the axis name.- Returns:
- the font in use
-
setAxisNameCentered
public void setAxisNameCentered(boolean value)
Sets whether the axis name is centered in the axis or at the border.- Parameters:
value
- if true then the name is centered
-
isAxisNameCentered
public boolean isAxisNameCentered()
Returns whether the axis name is centered in the axis or at the border.- Returns:
- true if centered
-
setMinimum
public void setMinimum(double value)
Sets the minimum to display on the axis.- Parameters:
value
- the minimum value
-
getMinimum
public double getMinimum()
Returns the currently set minimum on the axis.- Returns:
- the minimum value
-
setManualMinimum
public void setManualMinimum(Double value)
Sets the manual minimum to display on the axis.- Parameters:
value
- the minimum value, null to unset
-
getManualMinimum
public Double getManualMinimum()
Returns the currently set manual minimum on the axis.- Returns:
- the minimum value, null if none set
-
getActualMinimum
public double getActualMinimum()
Returns the actual minimum on the axis (incl zoom/panning).- Returns:
- the actual minimum value
-
getActualMinimumNoMargin
public double getActualMinimumNoMargin()
Returns the actual minimum on the axis (excl margins).- Returns:
- the actual minimum value
-
setMaximum
public void setMaximum(double value)
Sets the maximum to display on the axis.- Parameters:
value
- the maximum value
-
getMaximum
public double getMaximum()
Returns the currently set maximum on the axis.- Returns:
- the minimum value
-
setManualMaximum
public void setManualMaximum(Double value)
Sets the manual maximum to display on the axis.- Parameters:
value
- the maximum value, null to unset
-
getManualMaximum
public Double getManualMaximum()
Returns the currently set manual maximum on the axis.- Returns:
- the manual maximum value, null if none set
-
getActualMaximum
public double getActualMaximum()
Returns the actual maximum on the axis (incl zoom/panning).- Returns:
- the actual maximum value
-
getActualMaximumNoMargin
public double getActualMaximumNoMargin()
Returns the actual maximum on the axis (excl margins).- Returns:
- the actual maximum value
-
setTopMargin
public void setTopMargin(double value)
Sets the top margin factor (>= 0.0).- Parameters:
value
- the top margin
-
getTopMargin
public double getTopMargin()
Returns the currently set top margin factor (>= 0.0).- Returns:
- the top margin
-
setBottomMargin
public void setBottomMargin(double value)
Sets the bottom margin factor (>= 0.0).- Parameters:
value
- the bottom margin
-
getBottomMargin
public double getBottomMargin()
Returns the currently set bottom margin factor (>= 0.0).- Returns:
- the bottom margin
-
setManualTopMargin
public void setManualTopMargin(Double value)
Sets the manual top margin factor (>= 0.0 or null).- Parameters:
value
- the top margin
-
getManualTopMargin
public Double getManualTopMargin()
Returns the currently set manual top margin factor (>= 0.0 or null).- Returns:
- the top margin
-
setManualBottomMargin
public void setManualBottomMargin(Double value)
Sets the manual bottom margin factor (>= 0.0 or null).- Parameters:
value
- the bottom margin
-
getManualBottomMargin
public Double getManualBottomMargin()
Returns the currently set manual bottom margin factor (>= 0.0 or null).- Returns:
- the bottom margin
-
clearPanning
public void clearPanning()
Clears the panning.
-
setPixelOffset
public void setPixelOffset(int value)
Sets the pixel offset due to panning.- Parameters:
value
- the offset
-
getPixelOffset
public int getPixelOffset()
Returns the current pixel offset.- Returns:
- the offset
-
setNumberFormat
public void setNumberFormat(String value)
Sets the pattern used for displaying the numbers on the axis.- Parameters:
value
- the value to use- See Also:
DecimalFormat.applyPattern(String)
-
getNumberFormat
public String getNumberFormat()
Returns the pattern used for displaying the numbers on the axis.- Returns:
- the pattern
- See Also:
DecimalFormat.toPattern()
-
setShowGridLines
public void setShowGridLines(boolean value)
Enables/disables the display of grid lines for this axis.- Parameters:
value
- if true then the grid lines will be activated
-
getShowGridLines
public boolean getShowGridLines()
Returns whether the grid lines are displayed.- Returns:
- true if the grid lines are displayed
-
getAxisModel
public AbstractAxisModel getAxisModel()
Returns the underlying axis model.- Returns:
- the model
-
setVisibility
public void setVisibility(Visibility value)
Sets the visibility of the axis.- Parameters:
value
- the visibility
-
getVisibility
public Visibility getVisibility()
Returns the visibility of the axis.- Returns:
- the visibility
-
canZoom
public boolean canZoom(double min, double max)
Checks whether we can still zoom in.- Parameters:
min
- the minimum of the zoommax
- the maximum of the zoom- Returns:
- true if zoom is possible
-
pushZoom
public void pushZoom(double min, double max)
Adds the zoom to its internal list and updates the axis.- Parameters:
min
- the minimum of the zoommax
- the maximum of the zoom
-
popZoom
public void popZoom()
Removes the latest zoom, if available.
-
isZoomed
public boolean isZoomed()
Returns true if the axis is currently zoomed.- Returns:
- true if a zoom is in place
-
clearZoom
public void clearZoom()
Removes all zooms.
-
getLength
public int getLength()
Depending on direction, either returns width (= HORIZONTAL) or height (= VERTICAL).- Returns:
- the length of the axis
-
selectRange
public void selectRange()
Pops up a dialog letting the user choose the range (min/max) for the axis.
-
setRange
public void setRange(BaseInterval value)
Sets the current range of the axis.- Parameters:
value
- the new range
-
getRange
public BaseInterval getRange()
Returns the current range of the axis.- Returns:
- the current range
-
copyRange
protected void copyRange()
Copies the range to the clipboard.
-
pasteRange
protected void pasteRange()
Pastes the range from the clipboard, if possible.
-
resetRange
public void resetRange()
Resets any manually set range for the axis.
-
selectMargins
public void selectMargins()
Pops up a dialog letting the user choose the margins (top/bottom) for the axis.
-
copyMargins
protected void copyMargins()
Copies the margins to the clipboard.
-
pasteMargins
protected void pasteMargins()
Pastes the margins from the clipboard, if possible.
-
resetMargins
public void resetMargins()
Resets any manually set margins for the axis.
-
setPopupMenuCustomizer
public void setPopupMenuCustomizer(PopupMenuCustomizer value)
Sets the class to customize the right-click popup menu.- Parameters:
value
- the customizer
-
getPopupMenuCustomizer
public PopupMenuCustomizer getPopupMenuCustomizer()
Returns the current customizer, can be null.- Returns:
- the customizer
-
getPopupMenu
public BasePopupMenu getPopupMenu(MouseEvent e)
Returns the popup menu, potentially customized.- Parameters:
e
- the mouse event- Returns:
- the popup menu
- See Also:
m_PopupMenuCustomizer
-
editTickGenerator
protected void editTickGenerator()
Allows the user to edit the tick generator.
-
addChangeListener
public void addChangeListener(ChangeListener l)
Adds the given listener to the internal list of change listeners.- Parameters:
l
- the listener to add
-
removeChangeListener
public void removeChangeListener(ChangeListener l)
Removes the given listener from the internal list of change listeners.- Parameters:
l
- the listener to remove
-
notifyChangeListeners
public void notifyChangeListeners()
Notifies all change listeners.
-
addNumberFormatOverride
public void addNumberFormatOverride(Type type, String format)
Adds the format override for the specified type. If the current type is the same type as being set, then the format is automatically updated.- Parameters:
type
- the axis model typeformat
- the override
-
removeNumberFormatOverride
public void removeNumberFormatOverride(Type type)
Removes the format override for the specified type. If the current type is the same type as being removed, then the format is reset to the default one.- Parameters:
type
- the axis model type
-
hasNumberFormatOverride
public boolean hasNumberFormatOverride(Type type)
Returns whether an override format is available for the specified type.- Parameters:
type
- the axis model type- Returns:
- true if an override format exists
-
getNumberFormatOverride
public String getNumberFormatOverride(Type type)
Returns the format override for the specified type, null if non-existing.- Parameters:
type
- the axis model type- Returns:
- the override format, can be null
-
correctPosition
public int correctPosition(int pos)
"corrects" the position for an origin at bottom-left corner instead of top-left corner, in case of a VERTICAL axis.- Parameters:
pos
- the position to correct- Returns:
- the corrected position
-
valueToPos
public int valueToPos(double value)
Returns the position for the given value according to the settings (min and max).- Parameters:
value
- the value to turn into a position- Returns:
- the position
-
posToValue
public double posToValue(int pos)
Returns the value for the given position according to the settings (min and max).- Parameters:
pos
- the position on the panel- Returns:
- the corresponding value
-
drawBar
public void drawBar(Graphics g)
draws the bar.- Parameters:
g
- the graphics context
-
isFirst
protected boolean isFirst(List<Tick> ticks, int i, boolean flipped, int max)
Checks whether the tick is the first one.- Parameters:
ticks
- all the ticksi
- the current tick's indexflipped
- whether the axis is flippedmax
- the width/height of the panel- Returns:
- true if first
-
isLast
protected boolean isLast(List<Tick> ticks, int i, boolean flipped, int max)
Checks whether the tick is the last one.- Parameters:
ticks
- all the ticksi
- the current tick's indexflipped
- whether the axis is flippedmax
- the width/height of the panel- Returns:
- true if last
-
skipLabel
protected boolean skipLabel(List<Tick> ticks, int i)
Checks whether the tick is to be skipped.- Parameters:
ticks
- all the ticksi
- the current tick's index- Returns:
- true if skip
-
hasOverlap
protected boolean hasOverlap(Tick tick1, Tick tick2)
Checks whether there is an overlap between the labels of the two Ticks.- Parameters:
tick1
- the first ticktick2
- the second tick- Returns:
- true if overlapping
-
drawTicks
protected void drawTicks(Graphics g)
draws the ticks.- Parameters:
g
- the graphics context
-
drawName
protected void drawName(Graphics g)
draws the axis name.- Parameters:
g
- the graphics context
-
paintComponent
public void paintComponent(Graphics g)
draws the axis.- Overrides:
paintComponent
in classJComponent
- Parameters:
g
- the graphics context
-
-