Class IntensityGraphFigure
- java.lang.Object
-
- org.eclipse.draw2d.Figure
-
- org.eclipse.nebula.visualization.widgets.figures.IntensityGraphFigure
-
- All Implemented Interfaces:
org.eclipse.draw2d.IFigure
,Introspectable
public class IntensityGraphFigure extends org.eclipse.draw2d.Figure implements Introspectable
An intensity graph figure.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
IntensityGraphFigure.ColorDepth
Color depth of the image data in RGB1 mode, since SWT only support 8 bit color depth, it has to convert all data to [0,255].class
IntensityGraphFigure.GraphArea
(package private) class
IntensityGraphFigure.GraphAreaZoomer
static interface
IntensityGraphFigure.ICroppedDataSizeListener
static interface
IntensityGraphFigure.IPixelInfoProvider
static interface
IntensityGraphFigure.IProfileDataChangeLisenter
static interface
IntensityGraphFigure.IROIInfoProvider
Provides info to be displayed on ROI label.static interface
IntensityGraphFigure.IROIListener
ROI listener which will be notified whenever ROI moved.(package private) class
IntensityGraphFigure.SinglePixelProfileCrossHair
class
IntensityGraphFigure.UnsignedPrimitiveArrayWrapper
Wraps an array of raw signed data to emulate an unsigned datatype.
-
Field Summary
Fields Modifier and Type Field Description private boolean
armed
private org.eclipse.swt.graphics.Color
BLACK_COLOR
private org.eclipse.swt.graphics.Image
bufferedImage
private org.eclipse.swt.graphics.ImageData
bufferedImageData
private IntensityGraphFigure.ColorDepth
colorDepth
private ColorMap
colorMap
private ColorMapRamp
colorMapRamp
private int
cropBottom
private int
cropLeft
private IPrimaryArrayWrapper
croppedDataArray
private int
croppedDataHeight
private java.util.List<IntensityGraphFigure.ICroppedDataSizeListener>
croppedDataSizeListeners
private int
croppedDataWidth
private int
cropRight
private int
cropTop
private IPrimaryArrayWrapper
dataArray
private boolean
dataDirty
private int
dataHeight
private int
dataWidth
private org.eclipse.draw2d.geometry.Point
end
private static int
GAP
private IntensityGraphFigure.GraphArea
graphArea
private boolean
inRGBMode
private boolean
isSingleLineProfiling
private double
max
private static int
MAX_ARRAY_SIZE
private double
min
private org.eclipse.draw2d.geometry.Rectangle
originalCrop
private org.eclipse.swt.graphics.PaletteData
palette
private java.util.List<IntensityGraphFigure.IPixelInfoProvider>
pixelInfoProviders
private java.util.List<IntensityGraphFigure.IProfileDataChangeLisenter>
profileListeners
private org.eclipse.swt.graphics.Color
roiColor
private java.util.Map<java.lang.String,ROIFigure>
roiMap
private boolean
runMode
private java.lang.Boolean
savedShowRamp
private org.eclipse.draw2d.geometry.Point
start
private org.eclipse.swt.graphics.Color
TRANSPARENT_COLOR
private int
unsignedBits
private org.eclipse.swt.graphics.Color
WHITE_COLOR
private Axis
xAxis
private Range
xAxisRange
private Axis
yAxis
private Range
yAxisRange
-
Constructor Summary
Constructors Constructor Description IntensityGraphFigure()
IntensityGraphFigure(boolean runMode)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addCroppedDataSizeListener(IntensityGraphFigure.ICroppedDataSizeListener listener)
void
addPixelInfoProvider(IntensityGraphFigure.IPixelInfoProvider pixelInfoProvider)
void
addProfileDataListener(IntensityGraphFigure.IProfileDataChangeLisenter listener)
void
addROI(java.lang.String name, IntensityGraphFigure.IROIListener roiListener, IntensityGraphFigure.IROIInfoProvider roiInfoProvider)
Add a new ROI to the graph.protected int
calcRGBPixel(IPrimaryArrayWrapper dataArray, double max, double min, int index)
private double[]
calculateXProfileData(IPrimaryArrayWrapper data, int dw, int dh)
private double[]
calculateYProfileData(IPrimaryArrayWrapper data, int dw, int dh)
void
dispose()
private org.eclipse.swt.graphics.ImageData
drawRGBImage(IPrimaryArrayWrapper dataArray, int dataWidth, int dataHeight, double max, double min, org.eclipse.swt.graphics.ImageData imageData, boolean shrink)
Calculate the image data from source RGB data array [RGBRGBRGB...].private void
fireProfileDataChanged(IPrimaryArrayWrapper data, int dw, int dh)
java.beans.BeanInfo
getBeanInfo()
IntensityGraphFigure.ColorDepth
getColorDepth()
ColorMap
getColorMap()
int
getCropBottom()
int
getCropLeft()
int
getCropRight()
int
getCropTop()
double[]
getDataArray()
int
getDataHeight()
int
getDataWidth()
IntensityGraphFigure.GraphArea
getGraphArea()
org.eclipse.draw2d.geometry.Dimension
getGraphAreaInsets()
double
getMax()
double
getMin()
java.lang.String
getPixelInfo(int xIndex, int yIndex, double xCoordinate, double yCoordinate, double pixelValue)
ROIFigure
getROI(java.lang.String name)
org.eclipse.swt.graphics.Color
getRoiColor()
int
getUnsignedBits()
Axis
getXAxis()
Axis
getYAxis()
boolean
isInRGBMode()
boolean
isRunMode()
boolean
isShowRamp()
boolean
isSingleLineProfiling()
If it is profiling on single pixel.protected void
layout()
void
removeROI(java.lang.String name)
void
setColorDepth(IntensityGraphFigure.ColorDepth colorDepth)
Set Color depth of the image.void
setColorMap(ColorMap colorMap)
void
setCropBottom(int cropBottom)
void
setCropLeft(int cropLeft)
void
setCropRight(int cropRight)
void
setCropTop(int cropTop)
void
setDataArray(byte[] data)
Set the byte[] data array for the intensity graph.void
setDataArray(double[] data)
Set the double[] data array for the intensity graph.void
setDataArray(float[] data)
Set the float[] data array for the intensity graph.void
setDataArray(int[] data)
Set the int[] data array for the intensity graph.void
setDataArray(long[] data)
Set the long[] data array for the intensity graph.void
setDataArray(short[] data)
Set the short[] data array for the intensity graph.void
setDataArray(IPrimaryArrayWrapper dataWrapper)
Set the data array wrapper for the intensity graph.void
setDataHeight(int dataHeight)
void
setDataWidth(int dataWidth)
void
setFont(org.eclipse.swt.graphics.Font f)
void
setInRGBMode(boolean inRGBMode)
Set if the input data is in RGB mode.void
setMax(double max)
void
setMin(double min)
void
setROIColor(org.eclipse.swt.graphics.Color roiColor)
Set color of ROI figures.void
setROIDataBounds(java.lang.String name, int xIndex, int yIndex, int width, int height)
void
setROIVisible(java.lang.String name, boolean visible)
void
setRunMode(boolean runMode)
void
setShowRamp(boolean show)
void
setSingleLineProfiling(boolean isSingleLineProfiling)
Profile on single pixel.void
setUnsignedBits(int bits)
Sets the unsigned bitsprotected void
updateCroppedDataSize()
private void
zoom()
-
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, 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
-
MAX_ARRAY_SIZE
private static final int MAX_ARRAY_SIZE
- See Also:
- Constant Field Values
-
dataWidth
private int dataWidth
-
dataHeight
private int dataHeight
-
cropLeft
private int cropLeft
-
cropRight
private int cropRight
-
cropTop
private int cropTop
-
cropBottom
private int cropBottom
-
unsignedBits
private int unsignedBits
-
dataArray
private IPrimaryArrayWrapper dataArray
-
croppedDataArray
private IPrimaryArrayWrapper croppedDataArray
-
croppedDataWidth
private int croppedDataWidth
-
croppedDataHeight
private int croppedDataHeight
-
max
private double max
-
min
private double min
-
colorMapRamp
private ColorMapRamp colorMapRamp
-
graphArea
private IntensityGraphFigure.GraphArea graphArea
-
colorMap
private ColorMap colorMap
-
xAxis
private final Axis xAxis
-
yAxis
private final Axis yAxis
-
xAxisRange
private Range xAxisRange
-
yAxisRange
private Range yAxisRange
-
originalCrop
private org.eclipse.draw2d.geometry.Rectangle originalCrop
-
GAP
private static final int GAP
- See Also:
- Constant Field Values
-
start
private org.eclipse.draw2d.geometry.Point start
-
end
private org.eclipse.draw2d.geometry.Point end
-
armed
private boolean armed
-
dataDirty
private boolean dataDirty
-
bufferedImageData
private org.eclipse.swt.graphics.ImageData bufferedImageData
-
bufferedImage
private org.eclipse.swt.graphics.Image bufferedImage
-
profileListeners
private java.util.List<IntensityGraphFigure.IProfileDataChangeLisenter> profileListeners
-
pixelInfoProviders
private java.util.List<IntensityGraphFigure.IPixelInfoProvider> pixelInfoProviders
-
croppedDataSizeListeners
private java.util.List<IntensityGraphFigure.ICroppedDataSizeListener> croppedDataSizeListeners
-
runMode
private boolean runMode
-
roiMap
private java.util.Map<java.lang.String,ROIFigure> roiMap
-
WHITE_COLOR
private final org.eclipse.swt.graphics.Color WHITE_COLOR
-
BLACK_COLOR
private final org.eclipse.swt.graphics.Color BLACK_COLOR
-
TRANSPARENT_COLOR
private final org.eclipse.swt.graphics.Color TRANSPARENT_COLOR
-
inRGBMode
private boolean inRGBMode
-
colorDepth
private IntensityGraphFigure.ColorDepth colorDepth
-
palette
private org.eclipse.swt.graphics.PaletteData palette
-
savedShowRamp
private java.lang.Boolean savedShowRamp
-
isSingleLineProfiling
private boolean isSingleLineProfiling
-
roiColor
private org.eclipse.swt.graphics.Color roiColor
-
-
Method Detail
-
addProfileDataListener
public void addProfileDataListener(IntensityGraphFigure.IProfileDataChangeLisenter listener)
-
addPixelInfoProvider
public void addPixelInfoProvider(IntensityGraphFigure.IPixelInfoProvider pixelInfoProvider)
-
addCroppedDataSizeListener
public void addCroppedDataSizeListener(IntensityGraphFigure.ICroppedDataSizeListener listener)
-
addROI
public void addROI(java.lang.String name, IntensityGraphFigure.IROIListener roiListener, IntensityGraphFigure.IROIInfoProvider roiInfoProvider)
Add a new ROI to the graph.- Parameters:
name
- name of the ROI. It must be unique for this graph.color
- color of the ROI.roiListener
- listener on ROI updates. Can be null.roiInfoProvider
- provides information for the ROI. Can be null.
-
removeROI
public void removeROI(java.lang.String name)
-
setROIVisible
public void setROIVisible(java.lang.String name, boolean visible)
-
calculateXProfileData
private double[] calculateXProfileData(IPrimaryArrayWrapper data, int dw, int dh)
-
calculateYProfileData
private double[] calculateYProfileData(IPrimaryArrayWrapper data, int dw, int dh)
-
dispose
public void dispose()
-
drawRGBImage
private org.eclipse.swt.graphics.ImageData drawRGBImage(IPrimaryArrayWrapper dataArray, int dataWidth, int dataHeight, double max, double min, org.eclipse.swt.graphics.ImageData imageData, boolean shrink)
Calculate the image data from source RGB data array [RGBRGBRGB...].- Parameters:
dataArray
- the source data in RGB mode.dataWidth
- number of columns of dataArray; This will be the width of image data.dataHeight
- number of rows of dataArray; This will be the height of image data.max
- the upper limit of the data in dataArraymin
- the lower limit of the data in dataArrayimageData
- the imageData to be filled. null if a new instance should be created.shrink
- true if area size of image data is smaller than dataWidth*dataHeight. If this is true, it will use the nearest neighbor iamge scaling algorithm as described at http://tech-algorithm.com/articles/nearest-neighbor-image-scaling/.- Returns:
- the image data. null if dataWidth or dataHeight is less than 1 or larger than the data array.
-
calcRGBPixel
protected int calcRGBPixel(IPrimaryArrayWrapper dataArray, double max, double min, int index)
- Parameters:
dataArray
-max
-min
-index
-- Returns:
-
fireProfileDataChanged
private void fireProfileDataChanged(IPrimaryArrayWrapper data, int dw, int dh)
-
getColorMap
public ColorMap getColorMap()
- Returns:
- the colorMap
-
getCropBottom
public int getCropBottom()
- Returns:
- the cropBottom
-
getCropLeft
public int getCropLeft()
- Returns:
- the cropLeft
-
getCropRight
public int getCropRight()
- Returns:
- the cropRigth
-
getCropTop
public int getCropTop()
- Returns:
- the cropTop
-
getDataArray
public double[] getDataArray()
-
getDataHeight
public int getDataHeight()
- Returns:
- the dataHeight
-
getDataWidth
public int getDataWidth()
- Returns:
- the dataWidth
-
getUnsignedBits
public int getUnsignedBits()
- Returns:
- the unsigned bits
-
getGraphArea
public IntensityGraphFigure.GraphArea getGraphArea()
-
getGraphAreaInsets
public org.eclipse.draw2d.geometry.Dimension getGraphAreaInsets()
- Returns:
- the two dimension insets (cropped_width, cropped_height) of graph area
-
getMax
public double getMax()
- Returns:
- the max
-
getMin
public double getMin()
- Returns:
- the min
-
getXAxis
public final Axis getXAxis()
- Returns:
- the xAxis
-
getYAxis
public final Axis getYAxis()
- Returns:
- the yAxis
-
isInRGBMode
public boolean isInRGBMode()
- Returns:
- true if the input data is in RGB mode. For example, the input data is a 1D array of [RGBRGBRGBRGB...]
-
isRunMode
public boolean isRunMode()
- Returns:
- the runMode
-
isShowRamp
public boolean isShowRamp()
-
layout
protected void layout()
- Overrides:
layout
in classorg.eclipse.draw2d.Figure
-
setColorMap
public final void setColorMap(ColorMap colorMap)
- Parameters:
colorMap
- the colorMap to set
-
setCropBottom
public final void setCropBottom(int cropBottom)
- Parameters:
cropBottom
- the cropBottom to set
-
setCropLeft
public final void setCropLeft(int cropLeft)
- Parameters:
cropLeft
- the cropLeft to set
-
setCropRight
public final void setCropRight(int cropRight)
- Parameters:
cropRight
- the cropRigth to set
-
setCropTop
public final void setCropTop(int cropTop)
- Parameters:
cropTop
- the cropTop to set
-
setDataArray
public final void setDataArray(double[] data)
Set the double[] data array for the intensity graph. It must be called in UI thread. Warning: for big image for example 1024*768, it may takes several milliseconds (10-50ms) to paint the image. If this is called too fast that exceeds the painting capability, it may cause memory leaking.- Parameters:
data
- the dataArray to set
-
setDataArray
public final void setDataArray(short[] data)
Set the short[] data array for the intensity graph. It must be called in UI thread. Warning: for big image for example 1024*768, it may takes several milliseconds (10-50ms) to paint the image. If this is called too fast that exceeds the painting capability, it may cause memory leaking.- Parameters:
data
- the dataArray to set
-
setDataArray
public final void setDataArray(byte[] data)
Set the byte[] data array for the intensity graph. It must be called in UI thread. Warning: for big image for example 1024*768, it may takes several milliseconds (10-50ms) to paint the image. If this is called too fast that exceeds the painting capability, it may cause memory leaking.- Parameters:
data
- the dataArray to set
-
setDataArray
public final void setDataArray(int[] data)
Set the int[] data array for the intensity graph. It must be called in UI thread. Warning: for big image for example 1024*768, it may takes several milliseconds (10-50ms) to paint the image. If this is called too fast that exceeds the painting capability, it may cause memory leaking.- Parameters:
data
- the dataArray to set
-
setDataArray
public final void setDataArray(long[] data)
Set the long[] data array for the intensity graph. It must be called in UI thread. Warning: for big image for example 1024*768, it may takes several milliseconds (10-50ms) to paint the image. If this is called too fast that exceeds the painting capability, it may cause memory leaking.- Parameters:
data
- the dataArray to set
-
setDataArray
public final void setDataArray(float[] data)
Set the float[] data array for the intensity graph. It must be called in UI thread. Warning: for big image for example 1024*768, it may takes several milliseconds (10-50ms) to paint the image. If this is called too fast that exceeds the painting capability, it may cause memory leaking.- Parameters:
data
- the dataArray to set
-
setDataArray
public final void setDataArray(IPrimaryArrayWrapper dataWrapper)
Set the data array wrapper for the intensity graph. It must be called in UI thread. Warning: for big image for example 1024*768, it may takes several milliseconds (10-50ms) to paint the image. If this is called too fast that exceeds the painting capability, it may cause memory leaking.- Parameters:
data
- the dataArray to set
-
setDataHeight
public final void setDataHeight(int dataHeight)
- Parameters:
dataHeight
- the dataHeight to set
-
setDataWidth
public final void setDataWidth(int dataWidth)
- Parameters:
dataWidth
- the dataWidth to set
-
setInRGBMode
public void setInRGBMode(boolean inRGBMode)
Set if the input data is in RGB mode. For example, the input data is a 1D array of [RGBRGBRGBRGB...]. If it is true, the color of the pixel will come from the data directly and the color map will be ignored.- Parameters:
inRGBMode
- true if the input data in RGB mode.
-
setMax
public final void setMax(double max)
- Parameters:
max
- the max to set
-
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
-
setMin
public final void setMin(double min)
- Parameters:
min
- the min to set
-
setUnsignedBits
public final void setUnsignedBits(int bits)
Sets the unsigned bits- Parameters:
bits
- the number of bits in the unsigned data, or zero and has to be <= 1023 (limit for IEEE doubles). If bits <= 0, the data is treated as having signed values.
-
setROIColor
public void setROIColor(org.eclipse.swt.graphics.Color roiColor)
Set color of ROI figures.- Parameters:
roiColor
-
-
getRoiColor
public org.eclipse.swt.graphics.Color getRoiColor()
-
setROIDataBounds
public void setROIDataBounds(java.lang.String name, int xIndex, int yIndex, int width, int height)
-
getROI
public ROIFigure getROI(java.lang.String name)
-
setRunMode
public void setRunMode(boolean runMode)
- Parameters:
runMode
- the runMode to set
-
setShowRamp
public void setShowRamp(boolean show)
-
zoom
private void zoom()
-
getBeanInfo
public java.beans.BeanInfo getBeanInfo() throws java.beans.IntrospectionException
- Specified by:
getBeanInfo
in interfaceIntrospectable
- Throws:
java.beans.IntrospectionException
-
getColorDepth
public IntensityGraphFigure.ColorDepth getColorDepth()
- Returns:
- the colorDepth
-
setColorDepth
public void setColorDepth(IntensityGraphFigure.ColorDepth colorDepth)
Set Color depth of the image.- Parameters:
colorDepth
- the colorDepth to set
-
isSingleLineProfiling
public boolean isSingleLineProfiling()
If it is profiling on single pixel.- Returns:
- the isSinglePixelProfiling
-
setSingleLineProfiling
public void setSingleLineProfiling(boolean isSingleLineProfiling)
Profile on single pixel.- Parameters:
isSingleLineProfiling
- the isSinglePixelProfiling to set
-
getPixelInfo
public java.lang.String getPixelInfo(int xIndex, int yIndex, double xCoordinate, double yCoordinate, double pixelValue)
-
updateCroppedDataSize
protected void updateCroppedDataSize()
-
-