Class ChromatogramGraphic
java.lang.Object
org.biojava.bio.chromatogram.graphic.ChromatogramGraphic
- All Implemented Interfaces:
Cloneable
Encapsulates a configurable method for drawing a
Chromatogram
into a graphics context.- Since:
- 1.3
- Author:
- Rhett Sutphin (UI CBCB), Matthew Pocock
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA typesafe enumeration of the options available for configuring the behavior of aChromatogramGraphicinstance. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanFlag for call boxes.protected MapThe map containing the colors for drawing traces.protected booleanFlag for drawable call boxes.protected MapThe map containing the fill colors for callboxes.protected MapThe map containing theChromatogramGraphic.Options and values for this instance.protected booleanFlag for subpaths. -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor with no Chromatogram.Creates a newChromatogramGraphic, initially displaying the given chromatogram. -
Method Summary
Modifier and TypeMethodDescriptionclone()Performs a partial deep copy and invalidates regenerable structures.voiddrawTo(Graphics2D g2) Draws the chromatogram onto the provided graphics context.protected voidPrecomputes theRectangle2Ds that are the in-memory representation of the callboxes.protected voidgenerateDrawableCallboxes(AffineTransform shapeTx) Precomputes the callboxes in screen coordinates.protected voidPrecomputes theGeneralPaths used to draw the traces.Returns the color that will be used to draw the trace for the given DNA symbol.Returns the color that will be used to fill in the callboxes for calls with the given symbol.getCallboxBounds(int index) Returns the screen-coordinate bounds of the callbox for a given call.getCallboxBounds(int index, boolean boundsOnScreen) Returns the bounds of the callbox for a given call.intReturns the number of callboxes, regenerating them if necessary.intgetCallContaining(float x) Synonym forgetCallContaining(float, boolean)withpointOnScreen=true.intgetCallContaining(float x, boolean xOnScreen) Same asgetCallContaining(Point2D, boolean), except that only the x-coordinate of the point is specified.intgetCallContaining(Point2D point) Synonym forgetCallContaining(Point2D, boolean)withpointOnScreen=true.intgetCallContaining(Point2D point, boolean pointOnScreen) Returns the 0-based index of the call containing a given point.Accessor for the in-use chromatogram.floatHelper method for converting aNumber-valued option into afloatprimitive.intReturns the height of the whole graphic (in pixels).floatReturns the in-use horizontal scale factor.intHelper method for converting aNumber-valued option into anintprimitive.Returns a new AffineTransform describing the transformation from output space to chromatogram space.Returns the current value for the specified option.intReturns the width of the graphic as it will be rendered.intgetRenderedWidth(float horizontalScale) Returns the width of the graphic as it would be rendered with the specified horizontal scale.Returns a new AffineTransform describing the transformation from chromatogram coordinates to output coordinates.voidgetTransformAndConcat(AffineTransform target) Concatenates the chromatogram-to-output transform to the provided given AffineTransform.floatReturns the in use vertical scale factor.intgetWidth()Returns the width of the whole graphic (in pixels).booleanHelper method for converting aBoolean-valued option into abooleanprimitive.voidsetBaseColor(Symbol b, Color c) Maps a color to a DNA symbol.voidSets the chromatogram to draw.voidsetHeight(int h) Sets the height (in pixels).voidsetHorizontalScale(float hs) Sets the horizontal scale (proportional).voidsetOption(ChromatogramGraphic.Option opt, Object value) Sets a new value for the specified option.voidsetVerticalScale(float vs) Sets the vertical scale (proportional).voidsetWidth(int w) Sets the width of the whole graphic (in pixels).
-
Field Details
-
subpathsValid
Flag for subpaths. -
callboxesValid
Flag for call boxes. -
drawableCallboxesValid
Flag for drawable call boxes. -
options
The map containing theChromatogramGraphic.Options and values for this instance. -
colors
The map containing the colors for drawing traces. Keys are DNA Symbols. -
fillColors
The map containing the fill colors for callboxes. Keys are DNA Symbols.
-
-
Constructor Details
-
ChromatogramGraphic
public ChromatogramGraphic()Default constructor with no Chromatogram. -
ChromatogramGraphic
Creates a newChromatogramGraphic, initially displaying the given chromatogram.- Parameters:
c- the Chromomatogram to display
-
-
Method Details
-
generateSubpaths
Precomputes theGeneralPaths used to draw the traces. -
generateCallboxes
Precomputes theRectangle2Ds that are the in-memory representation of the callboxes. These rectangles are used for drawing (via generateDrawableCallboxes) as well as queries (e.g.,getCallContaining(java.awt.geom.Point2D, boolean)). -
generateDrawableCallboxes
Precomputes the callboxes in screen coordinates.- Parameters:
shapeTx- the transform to apply to the callboxes to move them into screen space.
-
getChromatogram
Accessor for the in-use chromatogram.- Returns:
- the chromatogram that a call to
drawTo(java.awt.Graphics2D)will draw
-
setChromatogram
Sets the chromatogram to draw.- Parameters:
c- the new chromatogram- See Also:
-
getWidth
Returns the width of the whole graphic (in pixels).- Returns:
- the width
-
getHeight
Returns the height of the whole graphic (in pixels).- Returns:
- the height
-
getHorizontalScale
Returns the in-use horizontal scale factor. The "units" of this value are (trace samples) / pixel. For example, a horizontal scale of 1.0 means that there will be one pixel horizontally for each trace sample.- Returns:
- the horizontal scale
-
getVerticalScale
Returns the in use vertical scale factor. The "units" of this value are (trace value bins) / pixel. For example, a vertical scale of 1.0 means that there will be one pixel vertically for each value in the range [0,getChromatogram().getMax()].- Returns:
- the vertical scale
-
getRenderedWidth
Returns the width of the graphic as it will be rendered. This means that theChromatogramGraphic.Option.FROM_TRACE_SAMPLEandChromatogramGraphic.Option.TO_TRACE_SAMPLEbounds are taken into account.- Returns:
- the rendered width
-
getRenderedWidth
Returns the width of the graphic as it would be rendered with the specified horizontal scale. TheChromatogramGraphic.Option.FROM_TRACE_SAMPLEandChromatogramGraphic.Option.TO_TRACE_SAMPLEbounds are taken into account.- Parameters:
horizontalScale- the horizontal scale- Returns:
- the rendered width at that scale
-
setHeight
Sets the height (in pixels). This will also change the vertical scale.- Parameters:
h- the desired height in pixels- See Also:
-
setVerticalScale
Sets the vertical scale (proportional). This will also change the height.- Parameters:
vs- the desired vertical scale. SeegetVerticalScale()for semantics.- See Also:
-
setWidth
Sets the width of the whole graphic (in pixels). This will also change the horizontal scale.- Parameters:
w- the desired width in pixels- See Also:
-
setHorizontalScale
Sets the horizontal scale (proportional). This will also change the width.- Parameters:
hs- the desired vertical scale. SeegetHorizontalScale()for semantics.- See Also:
-
getBaseColor
Returns the color that will be used to draw the trace for the given DNA symbol.- Parameters:
b- the symbol- Returns:
- the color, or null if none is set
-
getBaseFillColor
Returns the color that will be used to fill in the callboxes for calls with the given symbol.- Parameters:
b- the symbol- Returns:
- the color, or null if none is set
-
setBaseColor
Maps a color to a DNA symbol. The color as specified will be used for to draw the trace for the symbol (if any). The fill color for calls to the symbol will be derived from the trace color.- Parameters:
b- the symbolc- the color
-
getCallboxCount
Returns the number of callboxes, regenerating them if necessary. This should almost always equalgetChromatogram().getSequenceLength()- Returns:
- the number of callboxes
-
getCallboxBounds
Returns the screen-coordinate bounds of the callbox for a given call.- Parameters:
index- the callbox for which to get the bounds 0-based- Returns:
- a Rectangle2D giving the bounds of the call box
-
getCallboxBounds
Returns the bounds of the callbox for a given call.- Parameters:
index- the callbox for which to get the bounds 0-based.boundsOnScreen- determines the coordinate system of the returned bounds- Returns:
- the bounds of the callbox in screen coordinates if
boundsOnScreenis true, otherwise the bounds of the callbox in chromatogram coordinates
-
getCallContaining
Returns the 0-based index of the call containing a given point. The point may be either in screen space or chromatogram space, scale-wise. If the point is in screen space, the caller must translate the point such that if it is, for instance, from a mouse click, a click on the upper-left corner of the graphic would be (0,0).- Parameters:
point- the point to search forpointOnScreen- if true, the point will be treated as though it is in screen space. Otherwise, it will be considered to be in chromatogram space.- Returns:
- the 0-based index of the callbox which contains the point
-
getCallContaining
Synonym forgetCallContaining(Point2D, boolean)withpointOnScreen=true.- Parameters:
point- the Point2D to search with- Returns:
- the call containing this point
-
getCallContaining
Same asgetCallContaining(Point2D, boolean), except that only the x-coordinate of the point is specified.- Parameters:
x- the x-coordinate to search forxOnScreen- whether the coordinate in screen space or chromatogram space- Returns:
- the index of the call containing the position x
-
getCallContaining
Synonym forgetCallContaining(float, boolean)withpointOnScreen=true.- Parameters:
x- the x-coordinate to search for- Returns:
- the index of the call containing the position x
-
getTransform
Returns a new AffineTransform describing the transformation from chromatogram coordinates to output coordinates. -
getTransformAndConcat
Concatenates the chromatogram-to-output transform to the provided given AffineTransform. -
getInvTransform
Returns a new AffineTransform describing the transformation from output space to chromatogram space. Should be much more efficient thangetTransform().createInverse() -
drawTo
Draws the chromatogram onto the provided graphics context.- Parameters:
g2- the Graphics2D to draw to
-
setOption
Sets a new value for the specified option. Be sure that the value is appropriate per the documentation, or you'll induce a ClassCastException somewhere else.- Parameters:
opt- Option to setvalue- new value for the option- See Also:
-
getOption
Returns the current value for the specified option.- See Also:
-
optionIsTrue
Helper method for converting aBoolean-valued option into abooleanprimitive.- Parameters:
opt- theChromatogramGraphic.Optionto convert- Returns:
- true if the option is enabled
- Throws:
ClassCastException- when the option isn'tBoolean-valued
-
getFloatOption
Helper method for converting aNumber-valued option into afloatprimitive.- Parameters:
opt- theChromatogramGraphic.Optionto convert- Throws:
ClassCastException- when the option isn'tNumber-valued
-
getIntOption
Helper method for converting aNumber-valued option into anintprimitive.- Parameters:
opt- theChromatogramGraphic.Optionto convert- Throws:
ClassCastException- when the option isn'tNumber-valued
-
clone
Performs a partial deep copy and invalidates regenerable structures.
-