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 Colorm_AxisColorthe axis color.protected Stringm_AxisNamethe name of the axis.protected booleanm_AxisNameCenteredwhether the axis name is centered in the axis and not at the border.protected Fontm_AxisNameFontthe font for the axis name.protected intm_AxisWidththe width of the axis (for HORIZONTAL axes, this is the height, of course).protected HashSet<ChangeListener>m_ChangeListenersthe paint listeners.protected Directionm_Directionthe direction of the axis.protected intm_LengthTicksthe length of the ticks.protected AbstractAxisModelm_Modelthe axis model.protected Hashtable<Type,String>m_NumberFormatOverridefor overriding the default number formats.protected Orientationm_Orientationthe orientation of the axis.protected PopupMenuCustomizerm_PopupMenuCustomizeran optional customizer for the right-click popup.protected AxisPanelm_Selfthe panel itself.protected booleanm_ShowGridLineswhether to show the coordinate lines for this axis.protected Typem_Typethe type of axis.protected Visibilitym_Visibilitythe 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 voidaddChangeListener(ChangeListener l)Adds the given listener to the internal list of change listeners.voidaddNumberFormatOverride(Type type, String format)Adds the format override for the specified type.voidassign(AxisPanel other)Obtains all the settings from the other panel.protected voidcalculateDimensions()calculates and sets the preferred size of the axis.booleancanZoom(double min, double max)Checks whether we can still zoom in.voidclearPanning()Clears the panning.voidclearZoom()Removes all zooms.protected voidcopyMargins()Copies the margins to the clipboard.protected voidcopyRange()Copies the range to the clipboard.intcorrectPosition(int pos)"corrects" the position for an origin at bottom-left corner instead of top-left corner, in case of a VERTICAL axis.voiddrawBar(Graphics g)draws the bar.protected voiddrawName(Graphics g)draws the axis name.protected voiddrawTicks(Graphics g)draws the ticks.protected voideditTickGenerator()Allows the user to edit the tick generator.intgetActualAxisWidth()Returns the actual axis width, depending on the visibility.doublegetActualMaximum()Returns the actual maximum on the axis (incl zoom/panning).doublegetActualMaximumNoMargin()Returns the actual maximum on the axis (excl margins).doublegetActualMinimum()Returns the actual minimum on the axis (incl zoom/panning).doublegetActualMinimumNoMargin()Returns the actual minimum on the axis (excl margins).ColorgetAxisColor()Returns the color of the axis.AbstractAxisModelgetAxisModel()Returns the underlying axis model.StringgetAxisName()Returns the name of the axis, null or empty string if none set.FontgetAxisNameFont()Returns the font being used for the axis name.intgetAxisWidth()Returns the current width of the axis.doublegetBottomMargin()Returns the currently set bottom margin factor (>= 0.0).DirectiongetDirection()Returns the direction of the axis.intgetLength()Depending on direction, either returns width (= HORIZONTAL) or height (= VERTICAL).intgetLengthTicks()Returns the length of ticks currently displayed.DoublegetManualBottomMargin()Returns the currently set manual bottom margin factor (>= 0.0 or null).DoublegetManualMaximum()Returns the currently set manual maximum on the axis.DoublegetManualMinimum()Returns the currently set manual minimum on the axis.DoublegetManualTopMargin()Returns the currently set manual top margin factor (>= 0.0 or null).doublegetMaximum()Returns the currently set maximum on the axis.doublegetMinimum()Returns the currently set minimum on the axis.intgetNthValueToShow()Returns the count of ticks a value is shown, i.e., "3" means every third tick: 1, 4, 7, ...StringgetNumberFormat()Returns the pattern used for displaying the numbers on the axis.StringgetNumberFormatOverride(Type type)Returns the format override for the specified type, null if non-existing.OrientationgetOrientation()Returns the orientation of the axis.intgetPixelOffset()Returns the current pixel offset.BasePopupMenugetPopupMenu(MouseEvent e)Returns the popup menu, potentially customized.PopupMenuCustomizergetPopupMenuCustomizer()Returns the current customizer, can be null.BaseIntervalgetRange()Returns the current range of the axis.booleangetShowGridLines()Returns whether the grid lines are displayed.TickGeneratorgetTickGenerator()Returns the current tick generator in use.doublegetTopMargin()Returns the currently set top margin factor (>= 0.0).TypegetType()Returns the type of axis.VisibilitygetVisibility()Returns the visibility of the axis.booleanhasNumberFormatOverride(Type type)Returns whether an override format is available for the specified type.protected booleanhasOverlap(Tick tick1, Tick tick2)Checks whether there is an overlap between the labels of the two Ticks.booleanisAxisNameCentered()Returns whether the axis name is centered in the axis or at the border.protected booleanisFirst(List<Tick> ticks, int i, boolean flipped, int max)Checks whether the tick is the first one.protected booleanisLast(List<Tick> ticks, int i, boolean flipped, int max)Checks whether the tick is the last one.booleanisZoomed()Returns true if the axis is currently zoomed.voidnotifyChangeListeners()Notifies all change listeners.voidpaintComponent(Graphics g)draws the axis.protected voidpasteMargins()Pastes the margins from the clipboard, if possible.protected voidpasteRange()Pastes the range from the clipboard, if possible.voidpopZoom()Removes the latest zoom, if available.doubleposToValue(int pos)Returns the value for the given position according to the settings (min and max).voidpushZoom(double min, double max)Adds the zoom to its internal list and updates the axis.voidremoveChangeListener(ChangeListener l)Removes the given listener from the internal list of change listeners.voidremoveNumberFormatOverride(Type type)Removes the format override for the specified type.voidresetMargins()Resets any manually set margins for the axis.voidresetRange()Resets any manually set range for the axis.voidselectMargins()Pops up a dialog letting the user choose the margins (top/bottom) for the axis.voidselectRange()Pops up a dialog letting the user choose the range (min/max) for the axis.voidsetAxisColor(Color value)Sets the color of the axis.voidsetAxisName(String value)Sets the name of the axis, null or empty string for none.voidsetAxisNameCentered(boolean value)Sets whether the axis name is centered in the axis or at the border.voidsetAxisNameFont(Font value)Sets the font to use for the axis name.voidsetAxisWidth(int value)Sets the width of the axis (this is height for HORIZONTAL axes, of course), at least 5 pixel.voidsetBottomMargin(double value)Sets the bottom margin factor (>= 0.0).voidsetDirection(Direction value)Sets the direction of the axis.voidsetLengthTicks(int value)Sets the length of ticks to display along the axis (at least 4).voidsetManualBottomMargin(Double value)Sets the manual bottom margin factor (>= 0.0 or null).voidsetManualMaximum(Double value)Sets the manual maximum to display on the axis.voidsetManualMinimum(Double value)Sets the manual minimum to display on the axis.voidsetManualTopMargin(Double value)Sets the manual top margin factor (>= 0.0 or null).voidsetMaximum(double value)Sets the maximum to display on the axis.voidsetMinimum(double value)Sets the minimum to display on the axis.voidsetNthValueToShow(int value)Sets the count of ticks a value is shown, i.e., "3" means every third tick: 1, 4, 7, ...voidsetNumberFormat(String value)Sets the pattern used for displaying the numbers on the axis.voidsetOrientation(Orientation value)Sets the orientation of the axis.voidsetPixelOffset(int value)Sets the pixel offset due to panning.voidsetPopupMenuCustomizer(PopupMenuCustomizer value)Sets the class to customize the right-click popup menu.voidsetRange(BaseInterval value)Sets the current range of the axis.voidsetShowGridLines(boolean value)Enables/disables the display of grid lines for this axis.voidsetTickGenerator(TickGenerator value)Sets tick generator to use.voidsetTopMargin(double value)Sets the top margin factor (>= 0.0).voidsetType(Type value)Sets the type of axis.voidsetVisibility(Visibility value)Sets the visibility of the axis.protected booleanskipLabel(List<Tick> ticks, int i)Checks whether the tick is to be skipped.StringtoString()Returns a short description of the axis.StringvalueToDisplay(double value)Transforms the given value into the display (absolute, percentage, log, etc.) format.intvalueToPos(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:
paintComponentin classJComponent- Parameters:
g- the graphics context
-
-