Package ca.ualberta.stothard.cgview
Class Cgview
java.lang.Object
ca.ualberta.stothard.cgview.Cgview
- All Implemented Interfaces:
CgviewConstants
Represents a circular map of a DNA sequence. Numerous methods are available for controlling the
overall appearance of the map (width, height, background color, etc). The contents of the map are
described in terms of
FeatureSlot
, Feature
, FeatureRange
, Legend
,
and LegendItem
objects.- Author:
- Paul Stothard
-
Field Summary
Fields inherited from interface ca.ualberta.stothard.cgview.CgviewConstants
BASES, BOUNDS_BUTTON, BOUNDS_FEATURE, BOUNDS_RULER, CENTISOMES, DECORATION_CLOCKWISE_ARROW, DECORATION_COUNTERCLOCKWISE_ARROW, DECORATION_HIDDEN, DECORATION_STANDARD, DIRECT_STRAND, INNER_LABELS_AUTO, INNER_LABELS_NO_SHOW, INNER_LABELS_SHOW, LABEL, LABEL_FORCE, LABEL_NONE, LABEL_ZOOMED, LEGEND_DRAW_ZOOMED, LEGEND_ITEM_ALIGN_CENTER, LEGEND_ITEM_ALIGN_LEFT, LEGEND_ITEM_ALIGN_RIGHT, LEGEND_LOWER_CENTER, LEGEND_LOWER_LEFT, LEGEND_LOWER_RIGHT, LEGEND_MIDDLE_CENTER, LEGEND_MIDDLE_LEFT, LEGEND_MIDDLE_LEFT_OF_CENTER, LEGEND_MIDDLE_RIGHT, LEGEND_MIDDLE_RIGHT_OF_CENTER, LEGEND_NO_DRAW_ZOOMED, LEGEND_UPPER_CENTER, LEGEND_UPPER_LEFT, LEGEND_UPPER_RIGHT, POSITIONS_AUTO, POSITIONS_NO_SHOW, POSITIONS_SHOW, REVERSE_STRAND, SWATCH_NO_SHOW, SWATCH_SHOW
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
addInnerLabel
(Label label) Adds an InnerLabel object to this cgview object.protected void
addOuterLabel
(Label label) Adds an outerLabel object to this cgview object.protected double
adjustZoom
(double zoomMultiplier) Checks the zoomMultiplier value and makes adjustments if necessaryprotected boolean
almostInZoomRangeOne
(int base) Returns true if the base is located within the first zoom range, or if it is one base less than the start.protected boolean
baseIsDrawable
(int base) Returns true if the base is located within the visible region of the map.void
draw
(Graphics2D gg) Draws this Cgview map into the specified Graphics2D contextvoid
draw
(Graphics2D gg, boolean keepLastLabels) Draws this Cgview map into the specified Graphics2D contextvoid
drawZoomed
(Graphics2D gg, double zoom, int center) Draws this Cgview map into the specified Graphics2D context.void
drawZoomed
(Graphics2D gg, double zoom, int center, boolean keepLastLabels) Draws this Cgview map into the specified Graphics2D context.double
Returns the length of the arrowheads used for features that are drawn as arrows.Returns the color of the circle that represents the DNA sequence.double
Returns the radius of the circle that represents the DNA sequence.double
Returns the thickness of the line used to draw the circle that represents the DNA sequence.Returns the background color of the map.protected Rectangle2D
Returns a rectangle corresponding to the visible portion of the map.Returns the color of the map border.protected Point2D
Returns a Point2D specifying the center of this cgview.protected double
getDegrees
(int base) Returns a degrees representation of the given base.int
Returns the approximate number of long tick marks to be drawn in the sequence ruler.double
Returns the zoom value stored using the setDesiredZoom() method.int
Returns the zoomCenter value stored using the setDesiredZoomCenter() method.protected boolean
Returns true if the entire plasmid should be drawn.boolean
Returns boolean indicating whether or not legends should be drawn on this map.boolean
Returns true if tick marks are to be drawn.protected ArrayList
Returns an arrayList containing the FeatureSlot objects associated with this Cgview.double
Returns the amount of blank space placed between the concentric feature rings (FeatureSlot
objects).float
Returns the default thickness of the line used to represent sequence features.protected double
Returns the radius of the first (nearest to the backbone) reverse strand FeatureSlot in this Cgview.protected double
Returns the radius of the first (nearest to the backbone) direct strand FeatureSlot in this Cgview.int
Returns the feature position labelling behaviour of this Cgview.int
Returns whether or not feature labels should be shown on this map.Returns the color of all labels, or null if the labels are colored based on the feature they represent.protected Graphics2D
Returns the Graphics2D object for this Cgview.int
Returns the height of the map.float
Returns the opacity of the highlighting added to map items.protected ArrayList
Returns an arrayList of InnerLabel objects associated with this Cgview.boolean
Returns whether or not the map should be drawn with a broken backbone line to indicate a linear molecule.protected boolean
Returns true if the existing labels (those generated by the previous draw operation) are to be drawn.Returns an arrayList of LabelBounds objects associated with this Cgview.Returns the font of the feature labels.double
Returns the length of the line that extends from the feature to the feature label.float
Returns the thickness of the line that extends from features to feature labels.boolean
Returns true if labels are to be randomly shuffled before removing excess labels.int
Returns the maximum number of labels to attempt to arrange for display.protected double
Returns the radius of the last (furthest from the backbone) reverse strand FeatureSlot in this Cgview.protected double
Returns the radius of the last (furthest from the backbone) direct strand FeatureSlot in this Cgview.Returns the default font used for text inLegend
objects added to this Cgview.protected ArrayList
Returns an arrayList of the Legend objects in this Cgview.Returns the default color of the text used forLegend
objects.protected Rectangle2D
Returns a rectangle that covers the length portion of the map title.Returns the text to draw at the sequence start/end boundary if this is a linear molecule.Returns the color of the tick marks in the sequence ruler.double
Returns the minimum feature length to use when drawing sequence features.boolean
Returns whether or not inner labels should be moved from the inside of the backbone circle to the outside of the backbone circle when there is insufficient room on the inside of the backbone circle.double
Returns the number of degrees that the origin is to be moved in the counterclockwise direction from the three o'clock position.protected ArrayList
Returns an arrayList of OuterLabel objects associated with this Cgview.protected double
getRadians
(double base) Returns a radians representation of the given base.protected double
getRadians
(int base) Returns a radians representation of the given base.protected double
Returns a constant that controls label movement along the map backbone.protected double
Returns the distance moved by the labels each time they are moved away from the map backbone during label repositioning.Returns the font of the number labels in the sequence ruler.Returns the color of the text used for the sequence ruler.double
Returns the spacing between the ruler number labels and the tick marks.int
Returns the units to be used for the sequence ruler.int
Returns the length of the sequence to be mapped.float
Returns the proportion of the width of the features to be redrawn for highlighting and shadowing purposes.float
Returns the opacity of the shadowing added to map items.boolean
Returns the alignment behavior of small features when they are drawn.Returns the color of the short tick marks in the sequence ruler.float
Returns the thickness of the short tick marks in the sequence ruler.boolean
Returns whether or not a border should be drawn around the map.boolean
Returns whether or not items on the map should be drawn with shading.boolean
Returns whether or not the message set usingsetWarningText()
should be drawn at the bottom of the figure.int
Returns the width or the height of the map, whichever is smaller.double
Returns the tick density, with 0 being the minimum, 1 being the maximum.float
Returns the length of the tick marks in the sequence ruler.float
Returns the thickness of the tick marks in the sequence ruler.getTitle()
Returns the title of the map.Returns the font of the map title.Returns the color of the text used for the sequence title.protected Rectangle2D
Returns a rectangle that covers the map title.boolean
Returns true if labels are to be drawn with a colored background.int
Returns the inner label behaviour of this Cgview.Returns the font used for any warnings that appear at the bottom of the map.Returns the color of the text used for warnings that appear at the bottom of the figure.Returns a warning message to appear at the bottom of the map.int
getWidth()
Returns the width of the map.Returns the color of the tick mark drawn at the boundary between the end and beginning of the sequence.double
Returns an estimate of the maximum suitable zoom value for this map.protected double
Returns the zoom multiplier for the map, as set using thedrawZoomed()
method.protected int
Returns the number of the first base inside the first zoom range.protected int
Returns the number of the last base inside the first zoom range.protected int
Returns the number of the first base inside the second zoom range.protected int
Returns the number of the last base inside the second zoom range.protected double
Returns the minimum zoom value necessary for labels to be drawn below the backbone.protected boolean
inZoomRange
(double base) Returns true if the base is located within the first zoom range or the second zoom range.protected boolean
inZoomRange
(int base) Returns true if the base is located within the first zoom range or the second zoom range.protected boolean
inZoomRangeOne
(double base) Returns true if the base is located within the first zoom range.protected boolean
inZoomRangeOne
(int base) Returns true if the base is located within the first zoom range.protected boolean
inZoomRangeTwo
(double base) Returns true if the base is located within the second zoom range.protected boolean
inZoomRangeTwo
(int base) Returns true if the base is located within the second zoom range.static void
protected void
Removes labels from this Cgview.protected void
Removes legends from this Cgview.void
setArrowheadLength
(double length) Sets the length of the arrowheads used for features that are drawn as arrows.void
setBackboneColor
(Color color) Sets the color of the circle that represents the DNA sequence.void
setBackboneRadius
(double radius) Sets the radius of the circle that represents the DNA sequence.void
setBackboneThickness
(float thickness) Sets the thickness of the line used to draw the circle that represents the DNA sequence.void
setBackgroundColor
(Color color) Sets the background color of the map.void
setBorderColor
(Color color) Sets the color of the map border.void
setDesiredNumberOfTicks
(int ticks) Sets the approximate number of long tick marks to be drawn in the sequence ruler.void
setDesiredZoom
(double zoom) Can be used to store a zoom value when a Cgview object is read from XML data.void
setDesiredZoomCenter
(int zoomCenter) Can be used to store a zoom center value when a Cgview object is read from XML data.void
setDrawLegends
(boolean drawLegends) Sets whether or not legends should be drawn on this map.void
setDrawTickMarks
(boolean draw) Sets whether or not tick marks are drawn.void
setFeatureSlotSpacing
(double spacing) Sets the amount of blank space placed between the concentric feature rings (FeatureSlot
objects).void
setFeatureThickness
(float thickness) Sets the default thickness of the line used to represent sequence features.void
setGiveFeaturePositions
(int giveFeaturePositions) Specifies under what circumstances feature position information should be added to the label text.void
setGlobalLabel
(int labelType) Sets whether or not feature labels should be shown on this map.void
setGlobalLabelColor
(Color color) By default, feature labels are colored to match the color of the feature they represent.void
setHeight
(int height) Sets the height of the map.void
setHighlightOpacity
(float opacity) Sets the opacity of the highlighting added to map items.void
setIsLinear
(boolean isLinear) Sets whether or not the map should be drawn with a broken backbone line to indicate a linear molecule.void
setLabelFont
(Font font) Sets the default font of the feature labels.void
setLabelLineLength
(double length) Sets the length of the line that extends from the feature to the feature label.void
setLabelLineThickness
(float thickness) Sets the thickness of the line that extends from features to feature labels.void
setLabelPlacementQuality
(int labelPlacementQuality) Specifies how carefully labels placed on the map.void
setLabelShuffle
(boolean shuffle) Sets whether or not labels should be randomly shuffled before removing excess labels.void
setLabelsToKeep
(int number) Sets the maximum number of labels to attempt to arrange for display.void
setLegendFont
(Font font) Sets the default font used for text inLegend
objects added to this Cgview.void
setLegendTextColor
(Color color) Sets the default color of the text used forLegend
objects.void
setLinearBreakText
(String text) Sets the text to draw at the sequence start/end boundary if this is a linear molecule.void
setLongTickColor
(Color color) Sets the color of the tick marks in the sequence ruler.void
setMinimumFeatureLength
(double length) Sets the minimum feature length to use when drawing sequence features.void
setMoveInnerLabelsToOuter
(boolean moveInnerLabelsToOuter) Sets whether or not inner labels should be moved from the inside of the backbone circle to the outside of the backbone circle when there is insufficient room on the inside of the backbone circle.void
setOrigin
(double degrees) Sets the origin of the sequence in relation to the backbone drawing.protected void
setRadiansShiftConstant
(double shiftValue) Controls label movement along the map backbone.void
setRulerFont
(Font font) Sets the font of the number labels in the sequence ruler.void
setRulerFontColor
(Color color) Sets the color of the text used for the sequence ruler.void
setRulerTextPadding
(double padding) Sets the spacing between the ruler number labels and the tick marks.void
setRulerUnits
(int rulerUnits) Sets the units to be used for the sequence ruler.void
setSequenceLength
(int bases) Sets the length of the sequence to be mapped.void
setShadingProportion
(float proportion) Sets the proportion of the width of the features to be redrawn for highlighting and shadowing purposes.void
setShadowOpacity
(float opacity) Sets the opacity of the shadowing added to map items.void
setShiftSmallFeatures
(boolean shift) Sets the alignment behavior of small features when they are drawn.void
setShortTickColor
(Color color) Sets the color of the short tick marks in the sequence ruler.void
setShortTickThickness
(float thickness) Sets the thickness of the short tick marks in the sequence ruler.void
setShowBorder
(boolean showBorder) Sets whether or not a border should be drawn around the map.void
setShowShading
(boolean showShading) Sets whether or not items on the map should be drawn with shading.void
setShowWarning
(boolean showWarning) Sets whether or not the message set usingsetWarningText()
should be drawn at the bottom of the figure.void
setTickDensity
(double density) Adjusts the tick density, with 0 being the minimum, 1 being the maximum.void
setTickLength
(float length) Sets the length of the tick marks in the sequence ruler.void
setTickThickness
(float thickness) Sets the thickness of the tick marks in the sequence ruler.void
Sets the title of of the map.void
setTitleFont
(Font font) Sets the font of the map title.void
setTitleFontColor
(Color color) Sets the color of the text used for the sequence title.void
setUseColoredLabelBackgrounds
(boolean coloredBackground) Sets whether or not labels should be drawn with a colored background.void
setUseInnerLabels
(int useInnerLabels) Specifies under what circumstances labels should be drawn on the inside of the backbone circle.void
setWarningFont
(Font font) Sets the font used for any warnings that appear at the bottom of the map.void
setWarningFontColor
(Color color) Sets the color of the text used for warnings that appear at the bottom of the figure.void
setWarningText
(String message) Specifies a warning message to appear at the bottom of the map.void
setWidth
(int width) Sets the width of the map.void
setZeroTickColor
(Color color) Sets the color of the tick mark drawn at the boundary between the end and beginning of the sequence.protected void
setZoomShift
(double zoom) Sets the minimum zoom value necessary for labels to be drawn below the backbone.protected void
Translates the canvas.protected void
Translates the canvas so that point (0,0) is in the center.protected void
Undoes the canvas translation, so that point(0,0) is in upper left.protected void
Undoes the translation of the canvas that was done to place point (0,0) at the center, so that point(0,0) becomes upper left.
-
Constructor Details
-
Cgview
public Cgview(int sequenceLength) Constructs a new Cgview object.- Parameters:
sequenceLength
- the length of the sequence to be mapped.
-
-
Method Details
-
setSequenceLength
public void setSequenceLength(int bases) Sets the length of the sequence to be mapped.- Parameters:
bases
- the sequence length.
-
getSequenceLength
public int getSequenceLength()Returns the length of the sequence to be mapped.- Returns:
- the length of the sequence.
-
getGraphics
Returns the Graphics2D object for this Cgview.- Returns:
- the Graphics2D object.
-
setHeight
public void setHeight(int height) Sets the height of the map.- Parameters:
height
- the height of the map.
-
getHeight
public int getHeight()Returns the height of the map.- Returns:
- the height of the map.
-
setTickDensity
public void setTickDensity(double density) Adjusts the tick density, with 0 being the minimum, 1 being the maximum.- Parameters:
density
- a double between 0.0 and 1.0.
-
getTickDensity
public double getTickDensity()Returns the tick density, with 0 being the minimum, 1 being the maximum.- Returns:
- a double between 0.0 and 1.0 representing the tick density.
-
setWidth
public void setWidth(int width) Sets the width of the map.- Parameters:
width
- the width of the map.
-
getWidth
public int getWidth()Returns the width of the map.- Returns:
- the width of the map.
-
getSmallestDimension
public int getSmallestDimension()Returns the width or the height of the map, whichever is smaller.- Returns:
- the width or the height of the map, whichever is smaller.
-
setBackgroundColor
Sets the background color of the map.- Parameters:
color
- the background color.
-
getBackgroundColor
Returns the background color of the map.- Returns:
- the background color.
-
setBorderColor
Sets the color of the map border.- Parameters:
color
- the border color.
-
getBorderColor
Returns the color of the map border.- Returns:
- the border color.
-
setBackboneRadius
public void setBackboneRadius(double radius) Sets the radius of the circle that represents the DNA sequence.- Parameters:
radius
- the backbone radius.
-
getBackboneRadius
public double getBackboneRadius()Returns the radius of the circle that represents the DNA sequence.- Returns:
- the backbone radius.
-
setBackboneThickness
public void setBackboneThickness(float thickness) Sets the thickness of the line used to draw the circle that represents the DNA sequence.- Parameters:
thickness
- the thickness of the line.
-
getBackboneThickness
public double getBackboneThickness()Returns the thickness of the line used to draw the circle that represents the DNA sequence.- Returns:
- the thickness of the line.
-
setRulerFontColor
Sets the color of the text used for the sequence ruler.- Parameters:
color
- the font color.
-
getRulerFontColor
Returns the color of the text used for the sequence ruler.- Returns:
- the font color.
-
setTitleFontColor
Sets the color of the text used for the sequence title.- Parameters:
color
- the color of the font.
-
getTitleFontColor
Returns the color of the text used for the sequence title.- Returns:
- the font color.
-
getLegendTextColor
Returns the default color of the text used forLegend
objects.- Returns:
- the font color.
-
setLegendTextColor
Sets the default color of the text used forLegend
objects.- Parameters:
color
- the font color.
-
setWarningFontColor
Sets the color of the text used for warnings that appear at the bottom of the figure.- Parameters:
color
- the font color.
-
getWarningFontColor
Returns the color of the text used for warnings that appear at the bottom of the figure.- Returns:
- the font color.
-
setGlobalLabelColor
By default, feature labels are colored to match the color of the feature they represent. The setGlobalLabelColor() method can be used to specify a single color for all labels.- Parameters:
color
- the color of all labels.
-
getGlobalLabelColor
Returns the color of all labels, or null if the labels are colored based on the feature they represent.- Returns:
- the color of all labels.
-
setShowWarning
public void setShowWarning(boolean showWarning) Sets whether or not the message set usingsetWarningText()
should be drawn at the bottom of the figure.- Parameters:
showWarning
- whether or not the message should be drawn.
-
getShowWarning
public boolean getShowWarning()Returns whether or not the message set usingsetWarningText()
should be drawn at the bottom of the figure.- Returns:
- whether or not the message should be drawn.
-
setIsLinear
public void setIsLinear(boolean isLinear) Sets whether or not the map should be drawn with a broken backbone line to indicate a linear molecule.- Parameters:
isLinear
- whether or not the map should be drawn with a broken backbone line.
-
getIsLinear
public boolean getIsLinear()Returns whether or not the map should be drawn with a broken backbone line to indicate a linear molecule.- Returns:
- whether or not the map should be drawn with a broken backbone.
-
setLinearBreakText
Sets the text to draw at the sequence start/end boundary if this is a linear molecule.- Parameters:
text
- the text to draw at the start/end boundary.
-
getLinearBreakText
Returns the text to draw at the sequence start/end boundary if this is a linear molecule.- Returns:
- the text to draw at the start/end boundary.
-
setShowBorder
public void setShowBorder(boolean showBorder) Sets whether or not a border should be drawn around the map.- Parameters:
showBorder
- whether or not a border should be drawn.
-
getShowBorder
public boolean getShowBorder()Returns whether or not a border should be drawn around the map.- Returns:
- whether or not a border should be drawn.
-
setMoveInnerLabelsToOuter
public void setMoveInnerLabelsToOuter(boolean moveInnerLabelsToOuter) Sets whether or not inner labels should be moved from the inside of the backbone circle to the outside of the backbone circle when there is insufficient room on the inside of the backbone circle.- Parameters:
moveInnerLabelsToOuter
- whether or not labels should be moved from the inside to the outside.
-
getMoveInnerLabelsToOuter
public boolean getMoveInnerLabelsToOuter()Returns whether or not inner labels should be moved from the inside of the backbone circle to the outside of the backbone circle when there is insufficient room on the inside of the backbone circle.- Returns:
- whether or not labels should be moved from the inside to the outside.
-
setShowShading
public void setShowShading(boolean showShading) Sets whether or not items on the map should be drawn with shading. This setting can be overridden by individualFeatureSlot
objects.- Parameters:
showShading
- whether or not items on the map should be drawn with shading.
-
getShowShading
public boolean getShowShading()Returns whether or not items on the map should be drawn with shading.- Returns:
- whether or not items on the map should be drawn with shading.
-
setBackboneColor
Sets the color of the circle that represents the DNA sequence.- Parameters:
color
- the backbone color.
-
getBackboneColor
Returns the color of the circle that represents the DNA sequence.- Returns:
- the backbone color.
-
setFeatureThickness
public void setFeatureThickness(float thickness) Sets the default thickness of the line used to represent sequence features. This value can be changed for individual featureSlots using theFeatureSlot.setFeatureThickness()
method.- Parameters:
thickness
- the default feature thickness.
-
getFeatureThickness
public float getFeatureThickness()Returns the default thickness of the line used to represent sequence features. This value can be changed for individual featureSlots using theFeatureSlot.setFeatureThickness()
method.- Returns:
- the default feature thickness.
-
setMinimumFeatureLength
public void setMinimumFeatureLength(double length) Sets the minimum feature length to use when drawing sequence features. Features smaller than this setting are artificially increased in length, to make them more visible.- Parameters:
length
- the minimum feature length.
-
getMinimumFeatureLength
public double getMinimumFeatureLength()Returns the minimum feature length to use when drawing sequence features. Features smaller than this setting are artificially increased in length, to make them more visible.- Returns:
- the minimum feature length.
-
setFeatureSlotSpacing
public void setFeatureSlotSpacing(double spacing) Sets the amount of blank space placed between the concentric feature rings (FeatureSlot
objects).- Parameters:
spacing
- the spacing between FeatureSlot objects.
-
getFeatureSlotSpacing
public double getFeatureSlotSpacing()Returns the amount of blank space placed between the concentric feature rings (FeatureSlot
objects).- Returns:
- the spacing between FeatureSlot objects.
-
setArrowheadLength
public void setArrowheadLength(double length) Sets the length of the arrowheads used for features that are drawn as arrows.- Parameters:
length
- the arrowhead length.
-
getArrowheadLength
public double getArrowheadLength()Returns the length of the arrowheads used for features that are drawn as arrows.- Returns:
- the arrowhead length.
-
setShiftSmallFeatures
public void setShiftSmallFeatures(boolean shift) Sets the alignment behavior of small features when they are drawn. Small features are those features drawn larger than they actually are, in order to make them visible on the map. Ifshift
is set totrue
, the drawn representation of the feature is shifted so that its center coincides with the true center of the feature. If shift is set to false, the drawing begins at the true beginning of the feature, and extends the length specified using thesetMinimumFeatureLength()
method.- Parameters:
shift
- whether or not to shift small features so that their center coincides with the true center of the feature.- See Also:
-
getShiftSmallFeatures
public boolean getShiftSmallFeatures()Returns the alignment behavior of small features when they are drawn. Small features are those features drawn larger than they actually are, in order to make them visible on the map. Ifshift
is set totrue
, the drawing of the feature is shifted so that its center coincides with the true center of the feature. If shift is set to false, the drawing begins at the true beginning of the feature, and extends the length specified using thesetMinimumFeatureLength()
.- Returns:
- whether or not to shift small features so that their center coincides with the true center of the feature.
-
setShadingProportion
public void setShadingProportion(float proportion) Sets the proportion of the width of the features to be redrawn for highlighting and shadowing purposes.- Parameters:
proportion
- the proportion (between0
and1
).
-
getShadingProportion
public float getShadingProportion()Returns the proportion of the width of the features to be redrawn for highlighting and shadowing purposes.- Returns:
- the proportion (between
0
and1
).
-
setHighlightOpacity
public void setHighlightOpacity(float opacity) Sets the opacity of the highlighting added to map items. The higher the opacity, the more obvious the highlighting.- Parameters:
opacity
- the opacity (between0
and1
).
-
getHighlightOpacity
public float getHighlightOpacity()Returns the opacity of the highlighting added to map items. The higher the opacity, the more obvious the highlighting.- Returns:
- the opacity (between
0
and1
).
-
setShadowOpacity
public void setShadowOpacity(float opacity) Sets the opacity of the shadowing added to map items. The higher the opacity, the more obvious the shadowing.- Parameters:
opacity
- the opacity (between0
and1
).
-
getShadowOpacity
public float getShadowOpacity()Returns the opacity of the shadowing added to map items. The higher the opacity, the more obvious the shadowing.- Returns:
- the opacity (between
0
and1
).
-
setTickThickness
public void setTickThickness(float thickness) Sets the thickness of the tick marks in the sequence ruler.- Parameters:
thickness
- the thickness of the tick marks.
-
getTickThickness
public float getTickThickness()Returns the thickness of the tick marks in the sequence ruler.- Returns:
- the thickness of the tick marks.
-
setTickLength
public void setTickLength(float length) Sets the length of the tick marks in the sequence ruler.- Parameters:
length
- the length of the tick marks.
-
getTickLength
public float getTickLength()Returns the length of the tick marks in the sequence ruler.- Returns:
- the length of the tick marks.
-
setShortTickThickness
public void setShortTickThickness(float thickness) Sets the thickness of the short tick marks in the sequence ruler.- Parameters:
thickness
- the thickness of the short tick marks.
-
getShortTickThickness
public float getShortTickThickness()Returns the thickness of the short tick marks in the sequence ruler.- Returns:
- the thickness of the short tick marks.
-
setLongTickColor
Sets the color of the tick marks in the sequence ruler.- Parameters:
color
- the color of the tick marks.
-
getLongTickColor
Returns the color of the tick marks in the sequence ruler.- Returns:
- the color of the tick marks.
-
setShortTickColor
Sets the color of the short tick marks in the sequence ruler.- Parameters:
color
- the color of the short tick marks.
-
getShortTickColor
Returns the color of the short tick marks in the sequence ruler.- Returns:
- the color of the short tick marks.
-
setZeroTickColor
Sets the color of the tick mark drawn at the boundary between the end and beginning of the sequence.- Parameters:
color
- the color of the tick mark drawn at the boundary between the end and beginning of the sequence.
-
getZeroTickColor
Returns the color of the tick mark drawn at the boundary between the end and beginning of the sequence.- Returns:
- the color of the tick mark drawn at the boundary between the end and beginning of the sequence.
-
setDesiredNumberOfTicks
public void setDesiredNumberOfTicks(int ticks) Sets the approximate number of long tick marks to be drawn in the sequence ruler.- Parameters:
ticks
- the approximate number of tick marks.
-
getDesiredNumberOfTicks
public int getDesiredNumberOfTicks()Returns the approximate number of long tick marks to be drawn in the sequence ruler.- Returns:
- the approximate number of tick marks.
-
setDesiredZoomCenter
public void setDesiredZoomCenter(int zoomCenter) Can be used to store a zoom center value when a Cgview object is read from XML data. This value does not alter drawing directly.- Parameters:
zoomCenter
- a base position to center the map on.
-
getDesiredZoomCenter
public int getDesiredZoomCenter()Returns the zoomCenter value stored using the setDesiredZoomCenter() method.- Returns:
- a base position to center the map on.
-
setDesiredZoom
public void setDesiredZoom(double zoom) Can be used to store a zoom value when a Cgview object is read from XML data. This value does not alter drawing directly.- Parameters:
zoom
- a factor to zoom in by.
-
getDesiredZoom
public double getDesiredZoom()Returns the zoom value stored using the setDesiredZoom() method.- Returns:
- a factor to zoom in by.
-
setRulerFont
Sets the font of the number labels in the sequence ruler.- Parameters:
font
- the font of the number labels.
-
getRulerFont
Returns the font of the number labels in the sequence ruler.- Returns:
- the font of the number labels.
-
setLegendFont
Sets the default font used for text inLegend
objects added to this Cgview.- Parameters:
font
- the fault font for Legend objects.
-
getLegendFont
Returns the default font used for text inLegend
objects added to this Cgview.- Returns:
- the default font for Legend objects.
-
getLegends
Returns an arrayList of the Legend objects in this Cgview.- Returns:
- the Legend objects in this Cgview.
-
setWarningFont
Sets the font used for any warnings that appear at the bottom of the map.- Parameters:
font
- the font used for warning messages.
-
getWarningFont
Returns the font used for any warnings that appear at the bottom of the map.- Returns:
- the font used for warning messages.
-
setWarningText
Specifies a warning message to appear at the bottom of the map.- Parameters:
message
- the contents of the message.
-
getWarningText
Returns a warning message to appear at the bottom of the map.- Returns:
- the warning message.
-
setRulerUnits
public void setRulerUnits(int rulerUnits) Sets the units to be used for the sequence ruler.- Parameters:
rulerUnits
-CgviewConstants.BASES
orCgviewConstants.CENTISOMES
.
-
getRulerUnits
public int getRulerUnits()Returns the units to be used for the sequence ruler.- Returns:
CgviewConstants.BASES
orCgviewConstants.CENTISOMES
.
-
setGlobalLabel
public void setGlobalLabel(int labelType) Sets whether or not feature labels should be shown on this map. This setting is not overridden by Feature and FeatureRange objects.- Parameters:
labelType
-CgviewConstants.LABEL_NONE
,CgviewConstants.LABEL
, orCgviewConstants.LABEL_ZOOMED
.
-
getGlobalLabel
public int getGlobalLabel()Returns whether or not feature labels should be shown on this map. This setting is not overridden by Feature and FeatureRange objects. -
setDrawLegends
public void setDrawLegends(boolean drawLegends) Sets whether or not legends should be drawn on this map.- Parameters:
drawLegends
- whether or not to draw legends.
-
getDrawLegends
public boolean getDrawLegends()Returns boolean indicating whether or not legends should be drawn on this map.- Returns:
- whether or not legends should be drawn on this map.
-
setTitleFont
Sets the font of the map title.- Parameters:
font
- the font of the map title.
-
getTitleFont
Returns the font of the map title.- Returns:
- the font of the map title.
-
setLabelFont
Sets the default font of the feature labels. This font selection will be ignored if a new font is specified in the Feature or FeatureRange objects.- Parameters:
font
- the font of the feature labels.- See Also:
-
getLabelFont
Returns the font of the feature labels. This font selection will be ignored if a font is specified in the Feature or FeatureRange objects.- Returns:
- the font of the feature labels.
-
setRulerTextPadding
public void setRulerTextPadding(double padding) Sets the spacing between the ruler number labels and the tick marks.- Parameters:
padding
- the spacing between the ruler number labels and the tick marks.
-
getRulerTextPadding
public double getRulerTextPadding()Returns the spacing between the ruler number labels and the tick marks.- Returns:
- the spacing between the ruler number labels and the tick marks.
-
setOrigin
public void setOrigin(double degrees) Sets the origin of the sequence in relation to the backbone drawing. By default the sequence begins at the twelve o'clock position.- Parameters:
degrees
- the number of degrees (between-360.0
and360.0d
) to advance the sequence origin in the counterclockwise direction from the three o'clock position.
-
getOrigin
public double getOrigin()Returns the number of degrees that the origin is to be moved in the counterclockwise direction from the three o'clock position.- Returns:
- the number of degrees.
-
setLabelLineThickness
public void setLabelLineThickness(float thickness) Sets the thickness of the line that extends from features to feature labels.- Parameters:
thickness
- the thickness of the line.
-
getLabelLineThickness
public float getLabelLineThickness()Returns the thickness of the line that extends from features to feature labels.- Returns:
- the thickness of the line.
-
setLabelLineLength
public void setLabelLineLength(double length) Sets the length of the line that extends from the feature to the feature label. If feature labels clash with the number labels in the sequence ruler, the length of the label line should be increased using this method.- Parameters:
length
- the length of the label line.
-
getLabelLineLength
public double getLabelLineLength()Returns the length of the line that extends from the feature to the feature label.- Returns:
- the length of the label line.
-
setZoomShift
protected void setZoomShift(double zoom) Sets the minimum zoom value necessary for labels to be drawn below the backbone. When the map is drawn using a zoom value less than the value set using this method, all the labels are drawn on the outside of the backbone circle. When the map is drawn using a zoom value greater than the value set using this method, the labels for features on the reverse strand are drawn on the inside of the backbone circle. Also, when the zoom value is greater than the value set using this method, only the features in the visible portion of the map are drawn.- Parameters:
zoom
- the minimum zoom value necessary for labels to be drawn below the backbone.
-
getZoomShift
protected double getZoomShift()Returns the minimum zoom value necessary for labels to be drawn below the backbone. When the map is drawn using a zoom value less than the value set using this method, all the labels are drawn on the outside of the backbone circle. When the map is drawn using a zoom value greater than the value set using this method, the labels for features on the reverse strand are drawn on the inside of the backbone circle. Also, when the zoom value is greater than the value set using this method, only the features in the visible portion of the map are drawn.- Returns:
- the minimum zoom value necessary for labels to be drawn below the backbone.
-
setLabelsToKeep
public void setLabelsToKeep(int number) Sets the maximum number of labels to attempt to arrange for display. Additional labels are discarded prior to the arrangement process.- Parameters:
number
- the maximum number of labels to attempt to arrange for display.
-
getLabelsToKeep
public int getLabelsToKeep()Returns the maximum number of labels to attempt to arrange for display. Additional labels are discarded prior to the arrangement process.- Returns:
- the maximum number of labels to attempt to arrange for display.
-
setLabelShuffle
public void setLabelShuffle(boolean shuffle) Sets whether or not labels should be randomly shuffled before removing excess labels.- Parameters:
shuffle
- whether or not labels should be randomly shuffled before removing excess labels.
-
getLabelShuffle
public boolean getLabelShuffle()Returns true if labels are to be randomly shuffled before removing excess labels.- Returns:
- whether or not labels should be randomly shuffled before removing excess labels.
-
setUseColoredLabelBackgrounds
public void setUseColoredLabelBackgrounds(boolean coloredBackground) Sets whether or not labels should be drawn with a colored background.- Parameters:
coloredBackground
- whether or not labels should be drawn with a colored background.
-
getUseColoredLabelBackgrounds
public boolean getUseColoredLabelBackgrounds()Returns true if labels are to be drawn with a colored background.- Returns:
- whether or not labels are to be drawn with a colored background.
-
setDrawTickMarks
public void setDrawTickMarks(boolean draw) Sets whether or not tick marks are drawn.- Parameters:
draw
- whether or not tick marks are drawn.
-
getDrawTickMarks
public boolean getDrawTickMarks()Returns true if tick marks are to be drawn.- Returns:
- whether or not tick marks are to be drawn.
-
setTitle
Sets the title of of the map. This title is drawn in the center of the backbone circle when an unzoomed map is drawn.- Parameters:
title
- the title of the map.
-
getTitle
Returns the title of the map. This title is drawn in the center of the backbone circle when an unzoomed map is drawn.- Returns:
- the title of the map.
-
getFeatureSlots
Returns an arrayList containing the FeatureSlot objects associated with this Cgview.- Returns:
- an arrayList of FeatureSlot objects.
-
removeLegends
protected void removeLegends()Removes legends from this Cgview. -
removeLabels
protected void removeLabels()Removes labels from this Cgview. -
getOuterLabels
Returns an arrayList of OuterLabel objects associated with this Cgview.- Returns:
- an arrayList of OuterLabel objects.
-
getInnerLabels
Returns an arrayList of InnerLabel objects associated with this Cgview.- Returns:
- an arrayList of InnerLabel objects.
-
getLabelBounds
Returns an arrayList of LabelBounds objects associated with this Cgview.- Returns:
- an arrayList of LabelBounds objects.
-
getFirstOuterFeatureRadius
protected double getFirstOuterFeatureRadius()Returns the radius of the first (nearest to the backbone) direct strand FeatureSlot in this Cgview.- Returns:
- the radius.
-
getFirstInnerFeatureRadius
protected double getFirstInnerFeatureRadius()Returns the radius of the first (nearest to the backbone) reverse strand FeatureSlot in this Cgview.- Returns:
- the radius.
-
getLastOuterFeatureRadius
protected double getLastOuterFeatureRadius()Returns the radius of the last (furthest from the backbone) direct strand FeatureSlot in this Cgview.- Returns:
- the radius.
-
getLastInnerFeatureRadius
protected double getLastInnerFeatureRadius()Returns the radius of the last (furthest from the backbone) reverse strand FeatureSlot in this Cgview.- Returns:
- the radius.
-
getBackgroundRectangle
Returns a rectangle corresponding to the visible portion of the map.- Returns:
- a rectangle.
-
getTitleRectangle
Returns a rectangle that covers the map title.- Returns:
- a rectangle.
-
getLengthRectangle
Returns a rectangle that covers the length portion of the map title.- Returns:
- a rectangle.
-
getRadians
protected double getRadians(double base) Returns a radians representation of the given base.- Returns:
- a radians representation of the given base.
-
getRadians
protected double getRadians(int base) Returns a radians representation of the given base.- Returns:
- a radians representation of the given base.
-
getCenter
Returns a Point2D specifying the center of this cgview.- Returns:
- the center of this cgview.
-
getDegrees
protected double getDegrees(int base) Returns a degrees representation of the given base. The virtualZoomMultiplier stretches features.- Returns:
- a degrees representation of the given base.
-
setUseInnerLabels
public void setUseInnerLabels(int useInnerLabels) Specifies under what circumstances labels should be drawn on the inside of the backbone circle. When set toCgviewConstants.INNER_LABELS_NO_SHOW
, all the labels are drawn on the outside of the backbone circle. When set toCgviewConstants.INNER_LABELS_AUTO
, all the labels are drawn on the outside of the backbone circle, unless a zoomed map is drawn. When set toCgviewConstants.INNER_LABELS_SHOW
, the labels for features on the reverse strand are drawn on the inside of the backbone circle.- Parameters:
useInnerLabels
-
-
getUseInnerLabels
public int getUseInnerLabels()Returns the inner label behaviour of this Cgview. -
setGiveFeaturePositions
public void setGiveFeaturePositions(int giveFeaturePositions) Specifies under what circumstances feature position information should be added to the label text. When set toCgviewConstants.POSITIONS_NO_SHOW
, position information is not added to the label. When set toCgviewConstants.POSITIONS_AUTO
, position information is added only when a zoomed map is drawn. When set toCgviewConstants.POSITIONS_SHOW
, position information is added to the labels.- Parameters:
giveFeaturePositions
-
-
getGiveFeaturePositions
public int getGiveFeaturePositions()Returns the feature position labelling behaviour of this Cgview. -
getRadiusShiftAmount
protected double getRadiusShiftAmount()Returns the distance moved by the labels each time they are moved away from the map backbone during label repositioning.- Returns:
- the distance moved by the labels.
-
setRadiansShiftConstant
protected void setRadiansShiftConstant(double shiftValue) Controls label movement along the map backbone. When labels are moved along the backbone during label placement, the increment moved by labels is proportional to theshiftValue
constant. If the lines extending to labels are crossing over one another theshiftValue
constant should be set to a smaller value. The default value is0.20
.- Parameters:
shiftValue
- a value that controls label movement along the map backbone.
-
getRadiansShiftConstant
protected double getRadiansShiftConstant()Returns a constant that controls label movement along the map backbone. When labels are moved along the backbone during label placement, the increment moved by labels is proportional to theRADIANS_SHIFT
constant. If the lines extending to labels are crossing over one another theRADIANS_SHIFT
constant should be set to a smaller value. The default value is0.20
.- Returns:
- the
shiftValue
. It controls label movement along the map backbone.
-
setLabelPlacementQuality
public void setLabelPlacementQuality(int labelPlacementQuality) Specifies how carefully labels placed on the map. Higher values lead to more labels being placed without overlaps. Higher values also lead to slower program execution. Hight quality label placement can be used when there are fewer than 100 labels, but when there are more than 100 a low quality setting is recommended.- Parameters:
labelPlacementQuality
- a value between0
and10
specifying how carefully labels are placed on the map. The default value is5
.- See Also:
-
getZoomMultiplier
protected double getZoomMultiplier()Returns the zoom multiplier for the map, as set using thedrawZoomed()
method.- Returns:
- the zoom multiplier.
-
getDrawEntirePlasmid
protected boolean getDrawEntirePlasmid()Returns true if the entire plasmid should be drawn.- Returns:
- true if the entire plasmid should be drawn.
-
getZoomRangeOneStart
protected int getZoomRangeOneStart()Returns the number of the first base inside the first zoom range. When drawing a zoomed map, two ranges are calculated. These ranges contain all the base positions that should be drawn.- Returns:
- the number of the first base inside the first zoom range.
-
getZoomRangeOneStop
protected int getZoomRangeOneStop()Returns the number of the last base inside the first zoom range. When drawing a zoomed map, two ranges are calculated. These ranges contain all the base positions that should be drawn.- Returns:
- the number of the last base inside the first zoom range.
-
getZoomRangeTwoStart
protected int getZoomRangeTwoStart()Returns the number of the first base inside the second zoom range. When drawing a zoomed map, two ranges are calculated. These ranges contain all the base positions that should be drawn.- Returns:
- the number of the first base inside the second zoom range.
-
getZoomRangeTwoStop
protected int getZoomRangeTwoStop()Returns the number of the last base inside the second zoom range. When drawing a zoomed map, two ranges are calculated. These ranges contain all the base positions that should be drawn.- Returns:
- the number of the last base inside the second zoom range.
-
getKeepLastLabels
protected boolean getKeepLastLabels()Returns true if the existing labels (those generated by the previous draw operation) are to be drawn. Returns false if a new set of labels is to be generated and positioned.- Returns:
- whether or not the existing labels are to be drawn.
-
baseIsDrawable
protected boolean baseIsDrawable(int base) Returns true if the base is located within the visible region of the map.- Returns:
- whether or not the base is located within the visible region of the map.
-
inZoomRangeOne
protected boolean inZoomRangeOne(int base) Returns true if the base is located within the first zoom range.- Returns:
- whether or not the base is located within the first zoom range.
-
inZoomRangeOne
protected boolean inZoomRangeOne(double base) Returns true if the base is located within the first zoom range.- Returns:
- whether or not the base is located within the first zoom range.
-
almostInZoomRangeOne
protected boolean almostInZoomRangeOne(int base) Returns true if the base is located within the first zoom range, or if it is one base less than the start.- Returns:
- whether or not the base is located within the first zoom range, or if it is one base less than the start.
-
inZoomRangeTwo
protected boolean inZoomRangeTwo(int base) Returns true if the base is located within the second zoom range.- Returns:
- whether or not the base is located within the first zoom range.
-
inZoomRangeTwo
protected boolean inZoomRangeTwo(double base) Returns true if the base is located within the second zoom range.- Returns:
- whether or not the base is located within the first zoom range.
-
inZoomRange
protected boolean inZoomRange(int base) Returns true if the base is located within the first zoom range or the second zoom range.- Returns:
- whether or not the base is located within the first zoom range.
-
inZoomRange
protected boolean inZoomRange(double base) Returns true if the base is located within the first zoom range or the second zoom range.- Returns:
- whether or not the base is located within the first zoom range.
-
addOuterLabel
Adds an outerLabel object to this cgview object.- Parameters:
label
- an outerLabel object.
-
addInnerLabel
Adds an InnerLabel object to this cgview object.- Parameters:
label
- an innerLabel object.
-
getZoomMax
public double getZoomMax()Returns an estimate of the maximum suitable zoom value for this map.- Returns:
- an estimate of the maximum suitable zoom value for this map.
-
translateCanvas
protected void translateCanvas()Translates the canvas. -
untranslateCanvas
protected void untranslateCanvas()Undoes the canvas translation, so that point(0,0) is in upper left. -
translateZeroCenter
protected void translateZeroCenter()Translates the canvas so that point (0,0) is in the center. -
untranslateZeroCenter
protected void untranslateZeroCenter()Undoes the translation of the canvas that was done to place point (0,0) at the center, so that point(0,0) becomes upper left. -
adjustZoom
protected double adjustZoom(double zoomMultiplier) Checks the zoomMultiplier value and makes adjustments if necessary- Parameters:
zoomMultiplier
- the factor to zoom in by.
-
drawZoomed
Draws this Cgview map into the specified Graphics2D context. The map is drawn such that it is zoomed in by a factor ofzoom
, and centered on the base at positioncenterBase
.- Parameters:
gg
- theGraphics2D
context for rendering.zoom
- the factor to zoom in by.center
- the base position to center the map on.keepLastLabels
-true
if the labels from the last draw operation should be redrawn without repositioning, orfalse
if instead new labels should be generated and then positioned.
-
drawZoomed
Draws this Cgview map into the specified Graphics2D context. The map is drawn such that it is zoomed in by a factor ofzoom
, and centered on the base at positioncenterBase
.- Parameters:
gg
- thegraphics2D
context for rendering.zoom
- the factor to zoom in by.center
- the base position to center the map on.
-
draw
Draws this Cgview map into the specified Graphics2D context- Parameters:
gg
- thegraphics2D
context for rendering.keepLastLabels
-true
if the labels from the last draw operation should be redrawn without repositioning, orfalse
if instead new labels should be generated and then positioned.
-
draw
Draws this Cgview map into the specified Graphics2D context- Parameters:
gg
- the Graphics2D context for rendering.
-
main
-