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.Figure
The abstract scale has the common properties for linear(straight) scale and round scale.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AbstractScale.LabelSide
ticks label's position relative to tick marks
-
Field Summary
Fields Modifier and Type Field Description private boolean
autoFormat
private boolean
dateEnabled
protected static java.lang.String
DEFAULT_DATE_FORMAT
protected java.lang.String
default_decimal_format
the default label formatstatic java.lang.String
DEFAULT_ENGINEERING_FORMAT
static double
DEFAULT_LOG_SCALE_MAX
the default maximum value of log scale rangeprivate static double
DEFAULT_LOG_SCALE_MIN
the default minimum value of log scale rangestatic double
DEFAULT_MAX
static double
DEFAULT_MIN
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 paintprotected static int
ENGINEERING_LIMIT
the digits limit to be displayed in engineering formatprivate static java.util.Map<java.lang.String,java.text.Format>
formatCache
private java.lang.String
formatPattern
the format for tick labelsprivate int
formatPatternSize
private boolean
logScaleEnabled
the state if the axis scale is log scaleprivate double
majorGridStep
private int
majorTickMarkStepHint
the pixels hint for major tick mark stepprotected double
max
The maximum value of the scaleprotected double
min
The minimum value of the scaleprivate int
minorTickMarkStepHint
the pixels hint for minor tick mark stepprivate boolean
minorTicksVisible
private Range
range
private boolean
scaleLineVisible
private AbstractScale.LabelSide
tickLabelSide
ticks label positionprivate int
timeUnit
the 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.String
format(java.lang.Object obj)
Formats the given object as a DateFormat if Date is enabled or as a DecimalFormat.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.private java.text.Format
getFormat(java.lang.String pattern, boolean isDateFormat)
java.lang.String
getFormatPattern()
double
getMajorGridStep()
int
getMajorTickMarkStepHint()
int
getMinorTickMarkStepHint()
Range
getRange()
get the scale rangeAbstractScale.LabelSide
getTickLabelSide()
AbstractScale.LabelSide
getTickLablesSide()
Deprecated.use correctly spelled#getTickLabelSide(LabelSide)
int
getTimeUnit()
protected void
internalSetAutoFormat(boolean autoFormat)
Sets ONLY the autoFormat valueprotected void
internalSetFormatPattern(java.lang.String formatPattern)
protected void
internalSetLogScaleEnabled(boolean logScaleEnabled)
protected void
internalSetRange(Range range)
boolean
isAutoFormat()
boolean
isDateEnabled()
boolean
isDirty()
boolean
isLogScaleEnabled()
Gets the state indicating if log scale is enabled.boolean
isMinorTicksVisible()
boolean
isScaleLineVisible()
void
setAutoFormat(boolean autoFormat)
void
setDateEnabled(boolean dateEnabled)
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 paintvoid
setFont(org.eclipse.swt.graphics.Font f)
void
setFormatPattern(java.lang.String formatPattern)
Sets the format pattern for axis tick label.void
setLogScale(boolean enabled)
void
setMajorGridStep(double majorGridStep)
void
setMajorTickMarkStepHint(int majorTickMarkStepHint)
void
setMinorTickMarkStepHint(int minorTickMarkStepHint)
void
setMinorTicksVisible(boolean minorTicksVisible)
void
setRange(double lower, double upper)
set the scale rangevoid
setRange(double t1, double t2, boolean honorOriginDirection)
Set the range with option to honor its original direction.void
setRange(Range range)
set the scale rangevoid
setScaleLineVisible(boolean scaleLineVisible)
void
setTickLabelSide(AbstractScale.LabelSide tickLabelSide)
void
setTickLableSide(AbstractScale.LabelSide tickLabelSide)
Deprecated.use correctly spelledsetTickLabelSide(LabelSide)
void
setTimeUnit(int timeUnit)
Set the time unit for a date enabled scale.abstract void
updateTick()
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. seeFormat
If null is set, default format will be used.
- Parameters:
format
- the format- Throws:
java.lang.NullPointerException
- ifpattern
is 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:
setFont
in interfaceorg.eclipse.draw2d.IFigure
- Overrides:
setFont
in 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
-
-