Class: Layout

Layout

Layout controls how everything is draw on the map. It also determines the best size for the tracks so they fit on the map. See Map Scales for details on circular and linear layouts.

new Layout()

Create a the Layout

Members

backboneBackbone

Get the Backbone

bbInsideOffsetNumber

Get the distance from the backbone to the inner/bottom edge of the map.

bbOutsideOffsetNumber

Get the distance from the backbone to the outer/top edge of the map.

canvasCanvas

Get the Canvas

centerInsideOffsetNumber

Get the distance from the center of the map to the inner/bottom edge of the map.

centerOutsideOffsetNumber

Get the distance from the center of the map to the outer/top edge of the map.

heightNumber

Get the canvas height

initialMapThicknessProportion

Get or set the initial map thickness as a proportion of a viewer dimension (height for linear maps, minimum dimension for circular maps). The initial map thickness is at a zoomFactor of 1.

maxMapThicknessProportion

Get or set the maximum map thickness as a proportion of a viewer dimension (height for linear maps, minimum dimension for circular maps).

maxSlotThickness

Get or set the max slot thickness.

minSlotThickness

Get or set the min slot thickness.

scaleObject

Return an object that contains the 3 D3 Continuous Scales used by CGView. See Map Scales for details.

Scale Description
x Convert between the canvas x position (0 is left side of canvas) and map x position (center of map).
y Convert between the canvas y position (0 is top side of canvas) and map y position (center of map).
bp - circular Convert between bp and radians (Top of map is 1 bp and -π/2).
bp - linear Convert between bp and distance on x-axis

sequenceSequence

Get the Sequence

typeCanvas

Get or set the layout type: linear or circular.

viewerViewer

Get the Viewer

widthNumber

Get the canvas width

Methods

adjustedBackboneCenterOffset(centerOffset){Number}

Return an the backbone center offset adjusted for the zoom level.

Name Type Description
centerOffset Number

The backbone initial centerOffset.

Returns:
Type Description
Number adjustedCenterOffset

bpForPoint(point){Number}

Returns the basepair corresponding to the given point on the canvas.

Name Type Description
point Point

Point on the canvas.

Returns:
Type Description
Number
  • The basepair.

centerOffsetForPoint(point){Number}

Returns the Center Offset for the given point on the canvas. Center offset is the distance from the center of the map. For a circular map, this is the radius, while for a linear map, it's the distance from the backbone.

Name Type Description
point Point

Point on the canvas.

Returns:
Type Description
Number
  • Center Offset

clockPositionForBp(bp, invers){Number}

Returns the clock position (1-12) for the supplied bp. For example, the top of the map would be 12, the bottom would be 6 and the right side of a circular map will be 3.

Name Type Description
bp Number

Basepair position on the map.

invers Boolean

When true, give the opposite clock position (e.g. 6 instead of 12).

Returns:
Type Description
Number
  • An integer between 1 and 12.

domainsFor(bp, zoomFactor){Array}

Returns the X and Y scale domains for the given bp and zoomFactor.

Name Type Default Description
bp Number

Basepair

zoomFactor Number Current viewer zoom factor optional

The zoom factor used to calculate the domains

Returns:
Type Description
Array
  • The X and Y scale domains in the form of [[X1, X2], [Y1, Y2]].

path(layer, centerOffset, startBp, stopBp, anticlockwise, startType)

Adds a lineTo path to the given layer. Path does not draw. It only adds lineTo and optionally moveTo commands to the context for the given layer.

Name Type Default Description
layer String

The name of the canvas layer to add the path.

centerOffset Number

This distance from the center of the Map.

startBp Number

The start position in basepairs.

stopBp Number

The stop position in basepairs.

anticlockwise Boolean false optional

For circular maps the default direction is clockwise. Set this to true to draw arcs, anticlockwise.

startType String 'moveTo' optional

How the path should be started. Allowed values:

  • moveTo: moveTo start; lineTo stop
  • lineTo: lineTo start; lineTo stop
  • noMoveTo: ingore start; lineTo stop

pixelsPerBp(centerOffset){Number}

The number of pixels per basepair along the given centerOffset.

Name Type Default Description
centerOffset Number Backbone.adjustedCenterOffset optional

Distance from the center of the map. For a circular map, this is the radius, while for a linear map, it's the distance from the backbone.

Returns:
Type Description
Number
  • Pixels per basepair.

pointForBp(bp, centerOffset){Point}

Returns the point on the canvas for the given bp and centerOffset.

Name Type Default Description
bp Number

Basepair

centerOffset Number Backbone.adjustedCenterOffset optional

Distance from the center of the map. For a circular map, this is the radius, while for a linear map, it's the distance from the backbone.

Returns:
Type Description
Point
  • The point on the canvas.

visibleRangeForCenterOffset(centerOffset, margin){CGRange}

Return the CGRange for the sequence visisible at the given centerOffset. The margin is a distance in pixels added on to the Canvas size when calculating the CGRange.

Name Type Description
centerOffset Number

The distance from the center of them map.

margin Number

An amount (in pixels) added to the Canvas in all dimensions.

Returns:
Type Description
CGRange
  • the visible range.