Class DAxis
- java.lang.Object
-
- org.eclipse.draw2d.Figure
-
- org.eclipse.nebula.visualization.xygraph.linearscale.AbstractScale
-
- org.eclipse.nebula.visualization.xygraph.linearscale.LinearScale
-
- org.eclipse.nebula.visualization.xygraph.figures.Axis
-
- org.eclipse.nebula.visualization.xygraph.figures.DAxis
-
- All Implemented Interfaces:
org.eclipse.draw2d.IFigure,IScaleProvider
public class DAxis extends Axis
The Diamond Light Source implementation of the axis figure.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.eclipse.nebula.visualization.xygraph.figures.Axis
Axis.AxisMouseListener
-
Nested classes/interfaces inherited from class org.eclipse.nebula.visualization.xygraph.linearscale.LinearScale
LinearScale.Orientation
-
Nested classes/interfaces inherited from class org.eclipse.nebula.visualization.xygraph.linearscale.AbstractScale
AbstractScale.LabelSide
-
-
Field Summary
Fields Modifier and Type Field Description private booleanaxisAutoscaleTightprivate java.util.Map<java.lang.Integer,java.text.Format>cachedFormatsprivate static doubleDEFAULT_LOG_SCALE_MINthe default minimum value of log scale rangeprivate booleanticksAtEndsprivate booleanticksIndexBasedif true, then ticks are based on axis dataset indexesprotected booleanuserDefinedFormatthe user formatprivate static doubleZERO_RANGE_LOWEST_FRACTION-
Fields inherited from class org.eclipse.nebula.visualization.xygraph.figures.Axis
listeners, ZOOM_RATIO, ZOOM_SPEED
-
Fields inherited from class org.eclipse.nebula.visualization.xygraph.linearscale.LinearScale
SPACE_BTW_MARK_LABEL
-
Fields inherited from class org.eclipse.nebula.visualization.xygraph.linearscale.AbstractScale
DEFAULT_DATE_FORMAT, default_decimal_format, DEFAULT_ENGINEERING_FORMAT, DEFAULT_LOG_SCALE_MAX, DEFAULT_MAX, DEFAULT_MIN, dirty, ENGINEERING_LIMIT, max, min
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcalculateSpan(java.lang.Object obj)Calculate span of a textual form of object in scale's orientationvoidclear()protected LinearScaleTickLabelscreateLinearScaleTickLabels()Creates the linearScaleTickLabel.protected LinearScaleTickMarkscreateLinearScaleTickMarks()Creates the LinearScaleTickMarks.java.lang.Stringformat(java.lang.Object obj)Formats the given object as a DateFormat if Date is enabled or as a DecimalFormat.java.lang.Stringformat(java.lang.Object obj, int extraDP)Formats the given object as a DateFormat if Date is enabled or as a DecimalFormat.protected java.lang.StringgetAutoFormat(double min, double max)intgetMargin()Margin is half of the label's length(Horizontal Scale) or height(Vertical scale), so that the label can be displayed correctly.doublegetScaling()Get scaling for axis in terms of pixels/unitbooleanhasTicksAtEnds()Returns true if ticks at end of axis are shownbooleanhasUserDefinedFormat()private voidinternalSetRange(double lower, double upper, boolean ticksAtEnd)booleanisAxisAutoscaleTight()booleanisTicksIndexBased()protected voidlayout()protected voidlayoutTicks()booleanperformAutoScale(boolean force)Perform an auto-scale: Axis limits are set to the value range of the traces on this axis.private booleanrangeIsUnchanged(double dataMin, double dataMax, double axisMin, double axisMax)Determines if upper or lower data has changed from current axis limitsvoidsetAutoFormat(boolean autoFormat)voidsetAxisAutoscaleTight(boolean axisTight)voidsetDateEnabled(boolean dateEnabled)private voidsetFormat(java.lang.String formatPattern)voidsetFormatPattern(java.lang.String formatPattern)Sets the format pattern for axis tick label.voidsetHasUserDefinedFormat(boolean hasUserDefinedFormat)Sets whether there is a user defined format or notvoidsetLogScale(boolean enabled)voidsetRange(double lower, double upper)set the scale rangevoidsetTicksAtEnds(boolean ticksAtEnds)Sets whether ticks at ends of axis are shownvoidsetTicksIndexBased(boolean isTicksIndexBased)voidupdateTick()Updates the tick, recalculate all parameters, such as margin, length...-
Methods inherited from class org.eclipse.nebula.visualization.xygraph.figures.Axis
addListener, addTrace, dataChanged, fireAxisRangeChanged, fireRevalidated, getAutoScale, getAutoScaleThreshold, getForegroundColorRGB, getGrid, getMajorGridColor, getMajorGridColorRGB, getMinorGridColor, getPreferredSize, getScaleFontData, getTitle, getTitleFont, getTitleFontData, getTraceDataRange, getTraceList, getXYGraph, isAutoScale, isDashGridLine, isInverted, isOnPrimarySide, isShowMajorGrid, isShowMinorGrid, isYAxis, paintClientArea, pan, panChecked, removeListener, removeTrace, setAutoScale, setAutoScaleThreshold, setBackgroundColor, setDashGridLine, setFont, setForegroundColor, setGrid, setInverted, setMajorGridColor, setMinorGridColor, setMinorTicksVisible, setPrimarySide, setShowMajorGrid, setShowMinorGrid, setTitle, setTitleFont, setVisible, setXYGraph, setYAxis, setZoomType, toString, zoomInOut
-
Methods inherited from class org.eclipse.nebula.visualization.xygraph.linearscale.LinearScale
figureLayout, getDimension, getLabel, getLength, getLocalRange, getMargin, getOrientation, getPositionValue, getPositionValue, getScaleRange, getScaleTickLabels, getScaleTickMarks, getTickLength, getTicksProvider, getValuePosition, getValuePrecisePosition, isHorizontal, isLabelCustomised, isPrimary, isShowMaxLabel, isShowMinLabel, setBounds, setLength, setLocalRange, setMargin, setOrientation, setShowMaxLabel, setShowMinLabel, useLocalCoordinates
-
Methods inherited from class org.eclipse.nebula.visualization.xygraph.linearscale.AbstractScale
format, getFormatPattern, getMajorGridStep, getMajorTickMarkStepHint, getMinorTickMarkStepHint, getRange, getTickLabelSide, getTickLablesSide, getTimeUnit, internalSetAutoFormat, internalSetFormatPattern, internalSetLogScaleEnabled, internalSetRange, isAutoFormat, isDateEnabled, isDirty, isLogScaleEnabled, isMinorTicksVisible, isScaleLineVisible, setDirty, setMajorGridStep, setMajorTickMarkStepHint, setMinorTickMarkStepHint, setRange, setRange, setScaleLineVisible, setTickLabelSide, setTickLableSide, setTimeUnit
-
Methods inherited from class org.eclipse.draw2d.Figure
add, add, add, add, addAncestorListener, addCoordinateListener, addFigureListener, addFocusListener, addKeyListener, addLayoutListener, addListener, addMouseListener, addMouseMotionListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, containsPoint, containsPoint, erase, findDescendantAtExcluding, findFigureAt, findFigureAt, findFigureAt, findFigureAtExcluding, findMouseEventTargetAt, findMouseEventTargetInDescendantsAt, fireCoordinateSystemChanged, fireFigureMoved, fireMoved, firePropertyChange, firePropertyChange, firePropertyChange, getBackgroundColor, getBorder, getBounds, getChildren, getClientArea, getClientArea, getClippingStrategy, getCursor, getFlag, getFont, getForegroundColor, getInsets, getLayoutManager, getListeners, getLocalBackgroundColor, getLocalFont, getLocalForegroundColor, getLocation, getMaximumSize, getMinimumSize, getMinimumSize, getParent, getPreferredSize, getSize, getToolTip, getUpdateManager, handleFocusGained, handleFocusLost, handleKeyPressed, handleKeyReleased, handleMouseDoubleClicked, handleMouseDragged, handleMouseEntered, handleMouseExited, handleMouseHover, handleMouseMoved, handleMousePressed, handleMouseReleased, hasFocus, internalGetEventDispatcher, intersects, invalidate, invalidateTree, isCoordinateSystem, isEnabled, isFocusTraversable, isMirrored, isMouseEventTarget, isOpaque, isRequestFocusEnabled, isShowing, isValid, isValidationRoot, isVisible, paint, paintBorder, paintChildren, paintFigure, primTranslate, remove, removeAll, removeAncestorListener, removeCoordinateListener, removeFigureListener, removeFocusListener, removeKeyListener, removeLayoutListener, removeListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, revalidate, setBorder, setChildrenDirection, setChildrenEnabled, setChildrenOrientation, setClippingStrategy, setConstraint, setCursor, setEnabled, setFlag, setFocusTraversable, setLayoutManager, setLocation, setMaximumSize, setMinimumSize, setOpaque, setParent, setPreferredSize, setPreferredSize, setRequestFocusEnabled, setSize, setSize, setToolTip, setValid, translate, translateFromParent, translateToAbsolute, translateToParent, translateToRelative, validate
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.nebula.visualization.xygraph.linearscale.IScaleProvider
format, getFont, getForegroundColor, getFormatPattern, getMajorGridStep, getMajorTickMarkStepHint, getMinorTickMarkStepHint, getTimeUnit, isAutoFormat, isDateEnabled, isLogScaleEnabled
-
-
-
-
Field Detail
-
ticksIndexBased
private boolean ticksIndexBased
if true, then ticks are based on axis dataset indexes
-
cachedFormats
private java.util.Map<java.lang.Integer,java.text.Format> cachedFormats
-
ticksAtEnds
private boolean ticksAtEnds
-
userDefinedFormat
protected boolean userDefinedFormat
the user format
-
axisAutoscaleTight
private boolean axisAutoscaleTight
-
DEFAULT_LOG_SCALE_MIN
private static final double DEFAULT_LOG_SCALE_MIN
the default minimum value of log scale range- See Also:
- Constant Field Values
-
ZERO_RANGE_LOWEST_FRACTION
private static final double ZERO_RANGE_LOWEST_FRACTION
-
-
Method Detail
-
createLinearScaleTickLabels
protected LinearScaleTickLabels createLinearScaleTickLabels()
Description copied from class:LinearScaleCreates the linearScaleTickLabel. To be overridden if necessary if another Axis implementation is used.- Overrides:
createLinearScaleTickLabelsin classLinearScale
-
createLinearScaleTickMarks
protected LinearScaleTickMarks createLinearScaleTickMarks()
Description copied from class:LinearScaleCreates the LinearScaleTickMarks. To be overridden if necessary if another Axis implementation is used.- Overrides:
createLinearScaleTickMarksin classLinearScale
-
calculateSpan
public int calculateSpan(java.lang.Object obj)
Calculate span of a textual form of object in scale's orientation- Parameters:
obj- object- Returns:
- span in pixel
-
getMargin
public int getMargin()
Description copied from class:LinearScaleMargin is half of the label's length(Horizontal Scale) or height(Vertical scale), so that the label can be displayed correctly. So the range and format pattern must be set correctly before you can get the correct margin.- Specified by:
getMarginin interfaceIScaleProvider- Overrides:
getMarginin classLinearScale- Returns:
- the margin
-
getScaling
public double getScaling()
Get scaling for axis in terms of pixels/unit- Returns:
- scaling
-
layoutTicks
protected void layoutTicks()
-
setTicksIndexBased
public void setTicksIndexBased(boolean isTicksIndexBased)
- Parameters:
isTicksIndexBased- if true, make ticks based on axis dataset indexes
-
isTicksIndexBased
public boolean isTicksIndexBased()
- Returns:
- True if ticks are index based
-
format
public java.lang.String format(java.lang.Object obj)
Description copied from class:AbstractScaleFormats the given object as a DateFormat if Date is enabled or as a DecimalFormat. This is based on an internal format pattern given the object in parameter.- Specified by:
formatin interfaceIScaleProvider- Overrides:
formatin classAbstractScale- Parameters:
obj- the object- Returns:
- the formatted string
-
updateTick
public void updateTick()
Description copied from class:LinearScaleUpdates the tick, recalculate all parameters, such as margin, length...- Overrides:
updateTickin classLinearScale
-
format
public java.lang.String format(java.lang.Object obj, int extraDP)Formats the given object as a DateFormat if Date is enabled or as a DecimalFormat. This is based on an internal format pattern given the object in parameter. When formatting a date, if minOrMaxDate is true as well as autoFormat, then the SimpleDateFormat us used to format the object.- Parameters:
obj- the objectextraDP- must be non-negative- Returns:
- the formatted string
-
getAutoFormat
protected java.lang.String getAutoFormat(double min, double max)
-
setDateEnabled
public void setDateEnabled(boolean dateEnabled)
- Overrides:
setDateEnabledin classAbstractScale- Parameters:
dateEnabled- the dateEnabled to set
-
setFormatPattern
public void setFormatPattern(java.lang.String formatPattern)
Description copied from class:AbstractScaleSets the format pattern for axis tick label. seeFormatIf null is set, default format will be used.
- Overrides:
setFormatPatternin classAbstractScale
-
setFormat
private void setFormat(java.lang.String formatPattern)
-
setRange
public void setRange(double lower, double upper)Description copied from class:AbstractScaleset the scale range
-
internalSetRange
private void internalSetRange(double lower, double upper, boolean ticksAtEnd)
-
setAutoFormat
public void setAutoFormat(boolean autoFormat)
- Specified by:
setAutoFormatin interfaceIScaleProvider- Overrides:
setAutoFormatin classAbstractScale- Parameters:
autoFormat- the autoFormat to set
-
setLogScale
public void setLogScale(boolean enabled) throws java.lang.IllegalStateException- Overrides:
setLogScalein classAxis- Parameters:
enabled- true if enabling log scales- Throws:
java.lang.IllegalStateException
-
performAutoScale
public boolean performAutoScale(boolean force)
Description copied from class:AxisPerform an auto-scale: Axis limits are set to the value range of the traces on this axis. Includes some optimization: Axis range is set a little wider than exact trace data range. When auto-scale would only perform a minor axis adjustment, axis is left unchanged.- Overrides:
performAutoScalein classAxis- Parameters:
force- If true, the axis will be auto-scaled by force regardless the autoScale field. Otherwise, it will use the autoScale field to judge whether an auto-scale will be performed.- Returns:
- true if the axis is repainted due to range change.
- See Also:
Axis.autoScaleThreshold
-
rangeIsUnchanged
private boolean rangeIsUnchanged(double dataMin, double dataMax, double axisMin, double axisMax)Determines if upper or lower data has changed from current axis limits- Parameters:
dataMin- - min of data in bufferdataMax- - max of data in bufferaxisMin- - current axis minaxisMax- - current axis max- Returns:
- TRUE if data and axis max and min values are equal
-
clear
public void clear()
-
setAxisAutoscaleTight
public void setAxisAutoscaleTight(boolean axisTight)
- Parameters:
axisTight- set whether autoscale sets axis range tight to the data or the end of axis is set to the nearest tickmark
-
isAxisAutoscaleTight
public boolean isAxisAutoscaleTight()
- Returns:
- true if autoscaling axis is tight to displayed data
-
setTicksAtEnds
public void setTicksAtEnds(boolean ticksAtEnds)
Sets whether ticks at ends of axis are shown- Parameters:
ticksAtEnds-
-
hasTicksAtEnds
public boolean hasTicksAtEnds()
Returns true if ticks at end of axis are shown- Specified by:
hasTicksAtEndsin interfaceIScaleProvider- Overrides:
hasTicksAtEndsin classLinearScale- Returns:
- true if ticks at end of axis are shown
-
setHasUserDefinedFormat
public void setHasUserDefinedFormat(boolean hasUserDefinedFormat)
Sets whether there is a user defined format or not- Parameters:
hasUserDefinedFormat-
-
hasUserDefinedFormat
public boolean hasUserDefinedFormat()
- Returns:
- true if user format is defined
-
-