Skip to content

Commit

Permalink
Fix comment
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Jan 9, 2023
1 parent 6f479c9 commit 0ed6975
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export function drawMatchSimple({
drawCurves,
oobLimit,
viewWidth,
hideTiny,
}: {
feature: FeatPos
ctx: CanvasRenderingContext2D
Expand All @@ -31,6 +32,7 @@ export function drawMatchSimple({
cb: (ctx: CanvasRenderingContext2D) => void
height: number
drawCurves?: boolean
hideTiny?: boolean
}) {
const { p11, p12, p21, p22 } = feature

Expand All @@ -53,15 +55,19 @@ export function drawMatchSimple({

// drawing a line if the results are thin: drawing a line results in much
// less pixellation than filling in a thin polygon
if (l1 < 1 || l2 < 1) {
ctx.beginPath()
ctx.moveTo(x11, y1)
if (drawCurves) {
ctx.bezierCurveTo(x11, mid, x21, mid, x21, y2)
} else {
ctx.lineTo(x21, y2)
if (l1 <= 1 && l2 <= 1) {
// hideTiny can be used to avoid drawing mouseover for thin lines in this
// case
if (!hideTiny) {
ctx.beginPath()
ctx.moveTo(x11, y1)
if (drawCurves) {
ctx.bezierCurveTo(x11, mid, x21, mid, x21, y2)
} else {
ctx.lineTo(x21, y2)
}
ctx.stroke()
}
ctx.stroke()
} else {
draw(ctx, x11, x12, y1, x22, x21, y2, mid, drawCurves)
cb(ctx)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ export function drawRef(model: LinearSyntenyDisplayModel) {
// this loop is optimized to draw thousands/millions of thin lines as a polyline,
// the polyline calls ctx.stroke once is much more efficient than calling stroke()
// many times
ctx1.fillStyle = colorMap.M
ctx1.strokeStyle = colorMap.M
for (let i = 0; i < featPos.length; i++) {
const { p11, p12, p21, p22 } = featPos[i]
ctx1.fillStyle = colorMap.M
ctx1.strokeStyle = colorMap.M

const x11 = p11.offsetPx - offsets[0]
const x12 = p12.offsetPx - offsets[0]
Expand Down Expand Up @@ -91,10 +91,10 @@ export function drawRef(model: LinearSyntenyDisplayModel) {

// this loop only draws small lines as a polyline, the polyline calls
// ctx.stroke once is much more efficient than calling stroke() many times
ctx1.fillStyle = colorMap.M
ctx1.strokeStyle = colorMap.M
for (let i = 0; i < featPos.length; i++) {
const { p11, p12, p21, p22, f, cigar } = featPos[i]
ctx1.fillStyle = colorMap.M
ctx1.strokeStyle = colorMap.M

const x11 = p11.offsetPx - offsets[0]
const x12 = p12.offsetPx - offsets[0]
Expand Down Expand Up @@ -219,6 +219,7 @@ export function drawRef(model: LinearSyntenyDisplayModel) {
offsets,
oobLimit,
viewWidth: view.width,
hideTiny: true,
height,
})
}
Expand All @@ -240,7 +241,7 @@ export function drawMouseoverSynteny(model: LinearSyntenyDisplayModel) {
ctx.resetTransform()
ctx.scale(highResolutionScaling, highResolutionScaling)
ctx.clearRect(0, 0, width, height)
if (mouseoverId !== -1 && model.features) {
if (mouseoverId !== -1 && model.features && model.features[mouseoverId]) {
const feature = model.featPositions[mouseoverId]
ctx.fillStyle = 'rgb(0,0,0,0.1)'
drawMatchSimple({
Expand All @@ -255,7 +256,7 @@ export function drawMouseoverSynteny(model: LinearSyntenyDisplayModel) {
})
}

if (clickId !== -1 && model.features) {
if (clickId !== -1 && model.features && model.featPositions[clickId]) {
const feature = model.featPositions[clickId]
ctx.strokeStyle = 'rgb(0, 0, 0, 0.9)'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ import { bpToPx } from '@jbrowse/core/util/Base1DUtils'
import { MismatchParser } from '@jbrowse/plugin-alignments'
import { reaction, autorun } from 'mobx'

// locas
// locals
import baseModelFactory from '../LinearComparativeDisplay/stateModelFactory'
import { LinearSyntenyViewModel } from '../LinearSyntenyView/model'

// locals
import { drawMouseoverSynteny, drawRef } from './drawSynteny'

interface Pos {
Expand Down

0 comments on commit 0ed6975

Please sign in to comment.