Package ca.ualberta.stothard.cgview
Class FeatureSlot
java.lang.Object
ca.ualberta.stothard.cgview.FeatureSlot
- All Implemented Interfaces:
CgviewConstants
Represents a slot of space on the Cgview map. When the map is drawn, the FeatureSlot objects form
concentric rings around the backbone circle. Individual features, which are described using
Feature
objects, are drawn in the FeatureSlot objects. FeatureSlot objects are allocated
space in the order that they are added to the Cgview object, such that those added first receive
space closest to the backbone circle.- Author:
- Paul Stothard
-
Nested Class Summary
-
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
ConstructorDescriptionFeatureSlot
(int strand) Constructs a newFeatureSlot
object.FeatureSlot
(int strand, boolean showShading) Constructs a newFeatureSlot
object.FeatureSlot
(Cgview cgview, int strand) Constructs a new FeatureSlot object. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addFeature
(Feature feature) Adds a Feature object to this FeatureSlot.protected void
draw()
Draws the contents of this FeatureSlot.double
getBasesPerMinFeature
(double zoom) Returns the minimum feature length in bases that can be drawn accurately in this FeatureSlot, at the given zoom value.float
Returns the thickness of the arc used to represent sequence features in this FeatureSlot.double
Returns the minimum feature length to use when drawing sequence features.boolean
Returns whether or not items in this FeatureSlot should be drawn with shading.int
Returns the strand of this FeatureSlot.boolean
Returns a boolean specifying whether or not the supplied Feature object can fit in this FeatureSlot without overlapping with Feature objects already present in this FeatureSlot.void
Adds this FeatureSlot to a Cgview object.void
setFeatureThickness
(float featureThickness) Sets the thickness of the arc used to represent sequence features in this FeatureSlot.void
setMinimumFeatureLength
(double length) Sets the minimum feature length to use when drawing sequence features.protected void
Sets the radius of this FeatureSlot.void
setShowShading
(boolean showShading) Sets whether or not items in this FeatureSlot should be drawn with shading.void
Sorts the features in this FeatureSlot by start base.
-
Constructor Details
-
FeatureSlot
Constructs a new FeatureSlot object.- Parameters:
cgview
- the Cgview object to contain this FeatureSlot.strand
- the strand of this FeatureSlot,CgviewConstants.DIRECT_STRAND
orCgviewConstants.REVERSE_STRAND
. If strand is set to DIRECT_STRAND this FeatureSlot is placed on the outside of the backbone circle. If strand is set to REVERSE_STRAND this FeatureSlot is placed on the inside of the backbone circle.
-
FeatureSlot
public FeatureSlot(int strand) Constructs a newFeatureSlot
object. It can be added to a Cgview object using the setCgview() method.- Parameters:
strand
- the strand of this FeatureSlot,CgviewConstants.DIRECT_STRAND
orCgviewConstants.REVERSE_STRAND
. If strand is set to DIRECT_STRAND this FeatureSlot is placed on the outside of the backbone circle. If strand is set to REVERSE_STRAND this FeatureSlot is placed on the inside of the backbone circle.
-
FeatureSlot
public FeatureSlot(int strand, boolean showShading) Constructs a newFeatureSlot
object. It can be added to a cgview object using the setCgview() method.- Parameters:
strand
- the strand of this featureSlot,CgviewConstants.DIRECT_STRAND
orCgviewConstants.REVERSE_STRAND
. If strand is set to DIRECT_STRAND this FeatureSlot is placed on the outside of the backbone circle. If strand is set to REVERSE_STRAND this FeatureSlot is placed on the inside of the backbone circle.showShading
- whether or not items this FeatureSlot should be drawn with shading.
-
-
Method Details
-
setCgview
Adds this FeatureSlot to a Cgview object.- Parameters:
cgview
- the Cgview object to contain this FeatureSlot.
-
addFeature
Adds a Feature object to this FeatureSlot.- Parameters:
feature
- the Feature to add to this FeatureSlot.
-
getStrand
public int getStrand()Returns the strand of this FeatureSlot.- Returns:
- an
int
representing the strand of this FeatureSlot.
-
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.
-
setFeatureThickness
public void setFeatureThickness(float featureThickness) Sets the thickness of the arc used to represent sequence features in this FeatureSlot.- Parameters:
featureThickness
- the feature thickness.
-
getFeatureThickness
public float getFeatureThickness()Returns the thickness of the arc used to represent sequence features in this FeatureSlot.- Returns:
- the feature thickness.
-
setShowShading
public void setShowShading(boolean showShading) Sets whether or not items in this FeatureSlot should be drawn with shading.- Parameters:
showShading
- whether or not items this FeatureSlot should be drawn with shading.
-
getShowShading
public boolean getShowShading()Returns whether or not items in this FeatureSlot should be drawn with shading.- Returns:
- whether or not items in this featureSlot should be drawn with shading.
-
setRadius
protected void setRadius()Sets the radius of this FeatureSlot. -
getBasesPerMinFeature
public double getBasesPerMinFeature(double zoom) Returns the minimum feature length in bases that can be drawn accurately in this FeatureSlot, at the given zoom value. Feature lengths smaller than this length are automatically drawn larger so that they are visible. This method should be used when deciding on the appropriate window size (length of bases) to use when calculating a value to present on the map. For example, if you plan to display percent GC content on the map, and this method returns98.0003
, you should choose a window size of 99 or greater when calculating percent GC. In other words, you would create a Feature object containing a FeatureRange object spanning bases 1 to 99, a second FeatureRange spanning bases 100 to 199, and so on. Each FeatureRange would be decorated in some way to convey the %GC value calculated for the segment of bases it contains (usingFeatureRange.setProportionOfThickness(float)
for example).- Parameters:
zoom
- the zoom value to be used when drawing the Cgview map.
-
draw
protected void draw()Draws the contents of this FeatureSlot. -
isRoom
Returns a boolean specifying whether or not the supplied Feature object can fit in this FeatureSlot without overlapping with Feature objects already present in this FeatureSlot.- Parameters:
feature
- the Feature to check.- Returns:
- whether or not the Feature object can fit without overlapping with other Feature objects.
-
sortFeaturesByStart
public void sortFeaturesByStart()Sorts the features in this FeatureSlot by start base. If this is a DIRECT_STRAND slot the features are sorted in ascending order. If this is a REVERSE_STRAND slot the features are sorted in descending order. This sorting produces a more visually pleasing feature appearance when arrows are used.
-