Class AbstractScale
- java.lang.Object
-
- org.eclipse.draw2d.Figure
-
- org.eclipse.nebula.visualization.xygraph.linearscale.AbstractScale
-
- All Implemented Interfaces:
org.eclipse.draw2d.IFigure
- Direct Known Subclasses:
LinearScale,RoundScale
public abstract class AbstractScale extends org.eclipse.draw2d.FigureThe abstract scale has the common properties for linear(straight) scale and round scale.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAbstractScale.LabelSideticks label's position relative to tick marks
-
Field Summary
Fields Modifier and Type Field Description private booleanautoFormatprivate booleandateEnabledprotected static java.lang.StringDEFAULT_DATE_FORMATprotected java.lang.Stringdefault_decimal_formatthe default label formatstatic java.lang.StringDEFAULT_ENGINEERING_FORMATstatic doubleDEFAULT_LOG_SCALE_MAXthe default maximum value of log scale rangeprivate static doubleDEFAULT_LOG_SCALE_MINthe default minimum value of log scale rangestatic doubleDEFAULT_MAXstatic doubleDEFAULT_MINprotected booleandirtyWhenever any parameter has been changed, the scale should be marked as dirty, so all the inner parameters could be recalculated before the next paintprotected static intENGINEERING_LIMITthe digits limit to be displayed in engineering formatprivate static java.util.Map<java.lang.String,java.text.Format>formatCacheprivate java.lang.StringformatPatternthe format for tick labelsprivate intformatPatternSizeprivate booleanlogScaleEnabledthe state if the axis scale is log scaleprivate doublemajorGridStepprivate intmajorTickMarkStepHintthe pixels hint for major tick mark stepprotected doublemaxThe maximum value of the scaleprotected doubleminThe minimum value of the scaleprivate intminorTickMarkStepHintthe pixels hint for minor tick mark stepprivate booleanminorTicksVisibleprivate Rangerangeprivate booleanscaleLineVisibleprivate AbstractScale.LabelSidetickLabelSideticks label positionprivate inttimeUnitthe time unit for tick step
-
Constructor Summary
Constructors Constructor Description AbstractScale()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description 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, boolean minOrMaxDate)Formats the given object as a DateFormat if Date is enabled or as a DecimalFormat.private java.text.FormatgetFormat(java.lang.String pattern, boolean isDateFormat)java.lang.StringgetFormatPattern()doublegetMajorGridStep()intgetMajorTickMarkStepHint()intgetMinorTickMarkStepHint()RangegetRange()get the scale rangeAbstractScale.LabelSidegetTickLabelSide()AbstractScale.LabelSidegetTickLablesSide()Deprecated.use correctly spelled#getTickLabelSide(LabelSide)intgetTimeUnit()protected voidinternalSetAutoFormat(boolean autoFormat)Sets ONLY the autoFormat valueprotected voidinternalSetFormatPattern(java.lang.String formatPattern)protected voidinternalSetLogScaleEnabled(boolean logScaleEnabled)protected voidinternalSetRange(Range range)booleanisAutoFormat()booleanisDateEnabled()booleanisDirty()booleanisLogScaleEnabled()Gets the state indicating if log scale is enabled.booleanisMinorTicksVisible()booleanisScaleLineVisible()voidsetAutoFormat(boolean autoFormat)voidsetDateEnabled(boolean dateEnabled)protected voidsetDirty(boolean dirty)Whenever any parameter has been changed, the scale should be marked as dirty, so all the inner parameters could be recalculated before the next paintvoidsetFont(org.eclipse.swt.graphics.Font f)voidsetFormatPattern(java.lang.String formatPattern)Sets the format pattern for axis tick label.voidsetLogScale(boolean enabled)voidsetMajorGridStep(double majorGridStep)voidsetMajorTickMarkStepHint(int majorTickMarkStepHint)voidsetMinorTickMarkStepHint(int minorTickMarkStepHint)voidsetMinorTicksVisible(boolean minorTicksVisible)voidsetRange(double lower, double upper)set the scale rangevoidsetRange(double t1, double t2, boolean honorOriginDirection)Set the range with option to honor its original direction.voidsetRange(Range range)set the scale rangevoidsetScaleLineVisible(boolean scaleLineVisible)voidsetTickLabelSide(AbstractScale.LabelSide tickLabelSide)voidsetTickLableSide(AbstractScale.LabelSide tickLabelSide)Deprecated.use correctly spelledsetTickLabelSide(LabelSide)voidsetTimeUnit(int timeUnit)Set the time unit for a date enabled scale.abstract voidupdateTick()Updates the tick, recalculate all inner parameters-
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, 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, layout, paint, paintBorder, paintChildren, paintClientArea, paintFigure, primTranslate, remove, removeAll, removeAncestorListener, removeCoordinateListener, removeFigureListener, removeFocusListener, removeKeyListener, removeLayoutListener, removeListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, revalidate, setBackgroundColor, setBorder, setBounds, setChildrenDirection, setChildrenEnabled, setChildrenOrientation, setClippingStrategy, setConstraint, setCursor, setEnabled, setFlag, setFocusTraversable, setForegroundColor, setLayoutManager, setLocation, setMaximumSize, setMinimumSize, setOpaque, setParent, setPreferredSize, setPreferredSize, setRequestFocusEnabled, setSize, setSize, setToolTip, setValid, setVisible, translate, translateFromParent, translateToAbsolute, translateToParent, translateToRelative, useLocalCoordinates, validate
-
-
-
-
Field Detail
-
DEFAULT_MAX
public static final double DEFAULT_MAX
- See Also:
- Constant Field Values
-
DEFAULT_MIN
public static final double DEFAULT_MIN
- See Also:
- Constant Field Values
-
DEFAULT_ENGINEERING_FORMAT
public static final java.lang.String DEFAULT_ENGINEERING_FORMAT
- See Also:
- Constant Field Values
-
ENGINEERING_LIMIT
protected static final int ENGINEERING_LIMIT
the digits limit to be displayed in engineering format- See Also:
- Constant Field Values
-
DEFAULT_DATE_FORMAT
protected static final java.lang.String DEFAULT_DATE_FORMAT
- See Also:
- Constant Field Values
-
formatCache
private static final java.util.Map<java.lang.String,java.text.Format> formatCache
-
tickLabelSide
private AbstractScale.LabelSide tickLabelSide
ticks label position
-
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
-
DEFAULT_LOG_SCALE_MAX
public static final double DEFAULT_LOG_SCALE_MAX
the default maximum value of log scale range- See Also:
- Constant Field Values
-
default_decimal_format
protected java.lang.String default_decimal_format
the default label format
-
logScaleEnabled
private boolean logScaleEnabled
the state if the axis scale is log scale
-
min
protected double min
The minimum value of the scale
-
max
protected double max
The maximum value of the scale
-
formatPattern
private java.lang.String formatPattern
the format for tick labels
-
timeUnit
private int timeUnit
the time unit for tick step
-
dirty
protected boolean dirty
Whenever any parameter has been changed, the scale should be marked as dirty, so all the inner parameters could be recalculated before the next paint
-
dateEnabled
private boolean dateEnabled
-
scaleLineVisible
private boolean scaleLineVisible
-
majorTickMarkStepHint
private int majorTickMarkStepHint
the pixels hint for major tick mark step
-
minorTickMarkStepHint
private int minorTickMarkStepHint
the pixels hint for minor tick mark step
-
minorTicksVisible
private boolean minorTicksVisible
-
majorGridStep
private double majorGridStep
-
autoFormat
private boolean autoFormat
-
range
private Range range
-
formatPatternSize
private int formatPatternSize
-
-
Method Detail
-
format
public java.lang.String format(java.lang.Object obj)
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.- Parameters:
obj- the object- Returns:
- the formatted string
-
format
public java.lang.String format(java.lang.Object obj, boolean minOrMaxDate)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 objectminOrMaxDate- true if it is the min or max date on the scale.- Returns:
- the formatted string
-
getFormat
private java.text.Format getFormat(java.lang.String pattern, boolean isDateFormat)
-
getMajorTickMarkStepHint
public int getMajorTickMarkStepHint()
- Returns:
- the majorTickMarkStepHint
-
getRange
public Range getRange()
get the scale range
-
getTickLablesSide
@Deprecated public AbstractScale.LabelSide getTickLablesSide()
Deprecated.use correctly spelled#getTickLabelSide(LabelSide)
-
getTickLabelSide
public AbstractScale.LabelSide getTickLabelSide()
- Returns:
- the side of the tick label relative to the tick marks
-
getTimeUnit
public int getTimeUnit()
- Returns:
- the timeUnit
-
isDateEnabled
public boolean isDateEnabled()
- Returns:
- the dateEnabled
-
isDirty
public boolean isDirty()
- Returns:
- the dirty
-
isLogScaleEnabled
public boolean isLogScaleEnabled()
Gets the state indicating if log scale is enabled.- Returns:
- true if log scale is enabled
-
isMinorTicksVisible
public boolean isMinorTicksVisible()
- Returns:
- the minorTicksVisible
-
isScaleLineVisible
public boolean isScaleLineVisible()
- Returns:
- the scaleLineVisible
-
setDateEnabled
public void setDateEnabled(boolean dateEnabled)
- Parameters:
dateEnabled- the dateEnabled to set
-
setDirty
protected void setDirty(boolean dirty)
Whenever any parameter has been changed, the scale should be marked as dirty, so all the inner parameters could be recalculated before the next paint- Parameters:
dirty- the dirty to set
-
setFormatPattern
public void setFormatPattern(java.lang.String formatPattern)
Sets the format pattern for axis tick label. seeFormatIf null is set, default format will be used.
- Parameters:
format- the format- Throws:
java.lang.NullPointerException- ifpatternis nulljava.lang.IllegalArgumentException- if the given pattern is invalid.
-
internalSetFormatPattern
protected void internalSetFormatPattern(java.lang.String formatPattern)
-
getFormatPattern
public java.lang.String getFormatPattern()
- Returns:
- the formatPattern
-
setFont
public void setFont(org.eclipse.swt.graphics.Font f)
- Specified by:
setFontin interfaceorg.eclipse.draw2d.IFigure- Overrides:
setFontin classorg.eclipse.draw2d.Figure
-
setLogScale
public void setLogScale(boolean enabled) throws java.lang.IllegalStateException- Parameters:
enabled- true if enabling log scales- Throws:
java.lang.IllegalStateException
-
internalSetLogScaleEnabled
protected void internalSetLogScaleEnabled(boolean logScaleEnabled)
-
setMajorTickMarkStepHint
public void setMajorTickMarkStepHint(int majorTickMarkStepHint)
- Parameters:
majorTickMarkStepHint- the majorTickMarkStepHint to set, should be less than 1000.
-
setMinorTicksVisible
public void setMinorTicksVisible(boolean minorTicksVisible)
- Parameters:
minorTicksVisible- the minorTicksVisible to set
-
setRange
public void setRange(Range range)
set the scale range
-
setRange
public void setRange(double t1, double t2, boolean honorOriginDirection)Set the range with option to honor its original direction.- Parameters:
t1- value 1 of the ranget2- value 2 of the rangehonorOriginDirection- if true, the start and end value of the range will set according to its original direction.
-
setRange
public void setRange(double lower, double upper)set the scale range- Parameters:
lower- the lower limitupper- the upper limit- Throws:
java.lang.IllegalArgumentException- if lower or upper is Nan of Infinite, or lower >= upper or (upper - lower) is Infinite
-
internalSetRange
protected void internalSetRange(Range range)
-
setScaleLineVisible
public void setScaleLineVisible(boolean scaleLineVisible)
- Parameters:
scaleLineVisible- the scaleLineVisible to set
-
setTickLabelSide
public void setTickLabelSide(AbstractScale.LabelSide tickLabelSide)
- Parameters:
tickLabelSide- the side of the tick label relative to tick mark
-
setTickLableSide
@Deprecated public void setTickLableSide(AbstractScale.LabelSide tickLabelSide)
Deprecated.use correctly spelledsetTickLabelSide(LabelSide)
-
setTimeUnit
public void setTimeUnit(int timeUnit)
Set the time unit for a date enabled scale. The format of the time would be determined by it.- Parameters:
timeUnit- the timeUnit to set. It should be one of: Calendar.MILLISECOND, Calendar.SECOND, Calendar.MINUTE, Calendar.HOUR_OF_DAY, Calendar.DATE, Calendar.MONTH, Calendar.YEAR.- See Also:
Calendar
-
updateTick
public abstract void updateTick()
Updates the tick, recalculate all inner parameters
-
setMajorGridStep
public void setMajorGridStep(double majorGridStep)
- Parameters:
majorGridStep- the majorGridStep to set
-
getMajorGridStep
public double getMajorGridStep()
- Returns:
- the majorGridStep
-
setMinorTickMarkStepHint
public void setMinorTickMarkStepHint(int minorTickMarkStepHint)
- Parameters:
minorTickMarkStepHint- the minorTickMarkStepHint to set
-
getMinorTickMarkStepHint
public int getMinorTickMarkStepHint()
- Returns:
- the minorTickMarkStepHint
-
setAutoFormat
public void setAutoFormat(boolean autoFormat)
- Parameters:
autoFormat- the autoFormat to set
-
internalSetAutoFormat
protected void internalSetAutoFormat(boolean autoFormat)
Sets ONLY the autoFormat value- Parameters:
autoFormat-
-
isAutoFormat
public boolean isAutoFormat()
- Returns:
- the autoFormat
-
-