@jbrowse/plugin-linear-comparative-view 2.6.1 → 2.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (209) hide show
  1. package/dist/LGVSyntenyDisplay/configSchemaF.d.ts +1 -3
  2. package/dist/LGVSyntenyDisplay/configSchemaF.js +0 -1
  3. package/dist/LGVSyntenyDisplay/index.js +0 -1
  4. package/dist/LGVSyntenyDisplay/model.d.ts +17 -76
  5. package/dist/LGVSyntenyDisplay/model.js +22 -4
  6. package/dist/LaunchLinearSyntenyView.js +0 -1
  7. package/dist/LinearComparativeDisplay/configSchemaF.js +0 -1
  8. package/dist/LinearComparativeDisplay/index.js +0 -1
  9. package/dist/LinearComparativeDisplay/stateModelFactory.js +0 -1
  10. package/dist/LinearComparativeView/components/Header.js +11 -2
  11. package/dist/LinearComparativeView/components/LinearComparativeView.js +0 -1
  12. package/dist/LinearComparativeView/components/Rubberband.js +11 -33
  13. package/dist/LinearComparativeView/components/VerticalGuide.d.ts +8 -0
  14. package/dist/LinearComparativeView/components/VerticalGuide.js +33 -0
  15. package/dist/LinearComparativeView/index.js +0 -1
  16. package/dist/LinearComparativeView/model.d.ts +9 -15
  17. package/dist/LinearComparativeView/model.js +0 -1
  18. package/dist/LinearReadVsRef/LinearReadVsRef.js +0 -1
  19. package/dist/LinearReadVsRef/index.js +0 -1
  20. package/dist/LinearSyntenyDisplay/afterAttach.js +0 -1
  21. package/dist/LinearSyntenyDisplay/components/Component.js +0 -1
  22. package/dist/LinearSyntenyDisplay/components/LinearSyntenyRendering.js +0 -1
  23. package/dist/LinearSyntenyDisplay/components/SyntenyTooltip.js +0 -1
  24. package/dist/LinearSyntenyDisplay/components/util.js +0 -1
  25. package/dist/LinearSyntenyDisplay/configSchemaF.js +0 -1
  26. package/dist/LinearSyntenyDisplay/drawSynteny.js +0 -1
  27. package/dist/LinearSyntenyDisplay/index.js +0 -1
  28. package/dist/LinearSyntenyDisplay/model.js +0 -1
  29. package/dist/LinearSyntenyView/components/ExportSvgDialog.js +0 -1
  30. package/dist/LinearSyntenyView/components/Icons.js +0 -1
  31. package/dist/LinearSyntenyView/components/ImportCustomTrack.js +0 -1
  32. package/dist/LinearSyntenyView/components/ImportForm.js +0 -1
  33. package/dist/LinearSyntenyView/components/ImportSyntenyTrackSelector.js +0 -1
  34. package/dist/LinearSyntenyView/components/LinearSyntenyView.js +0 -1
  35. package/dist/LinearSyntenyView/index.js +0 -1
  36. package/dist/LinearSyntenyView/model.d.ts +9 -9
  37. package/dist/LinearSyntenyView/model.js +0 -1
  38. package/dist/LinearSyntenyView/svgcomponents/SVGBackground.js +2 -2
  39. package/dist/LinearSyntenyView/svgcomponents/SVGLinearSyntenyView.js +0 -1
  40. package/dist/SyntenyFeatureDetail/SyntenyFeatureDetail.js +0 -1
  41. package/dist/SyntenyFeatureDetail/index.js +0 -1
  42. package/dist/SyntenyTrack/configSchema.js +0 -1
  43. package/dist/SyntenyTrack/index.js +0 -1
  44. package/dist/index.js +0 -1
  45. package/dist/util.js +0 -1
  46. package/esm/LGVSyntenyDisplay/configSchemaF.d.ts +1 -3
  47. package/esm/LGVSyntenyDisplay/configSchemaF.js +0 -1
  48. package/esm/LGVSyntenyDisplay/index.js +0 -1
  49. package/esm/LGVSyntenyDisplay/model.d.ts +17 -76
  50. package/esm/LGVSyntenyDisplay/model.js +23 -5
  51. package/esm/LaunchLinearSyntenyView.js +0 -1
  52. package/esm/LinearComparativeDisplay/configSchemaF.js +0 -1
  53. package/esm/LinearComparativeDisplay/index.js +0 -1
  54. package/esm/LinearComparativeDisplay/stateModelFactory.js +0 -1
  55. package/esm/LinearComparativeView/components/Header.js +11 -2
  56. package/esm/LinearComparativeView/components/LinearComparativeView.js +0 -1
  57. package/esm/LinearComparativeView/components/Rubberband.js +8 -33
  58. package/esm/LinearComparativeView/components/VerticalGuide.d.ts +8 -0
  59. package/esm/LinearComparativeView/components/VerticalGuide.js +28 -0
  60. package/esm/LinearComparativeView/index.js +0 -1
  61. package/esm/LinearComparativeView/model.d.ts +9 -15
  62. package/esm/LinearComparativeView/model.js +0 -1
  63. package/esm/LinearReadVsRef/LinearReadVsRef.js +0 -1
  64. package/esm/LinearReadVsRef/index.js +0 -1
  65. package/esm/LinearSyntenyDisplay/afterAttach.js +0 -1
  66. package/esm/LinearSyntenyDisplay/components/Component.js +0 -1
  67. package/esm/LinearSyntenyDisplay/components/LinearSyntenyRendering.js +0 -1
  68. package/esm/LinearSyntenyDisplay/components/SyntenyTooltip.js +0 -1
  69. package/esm/LinearSyntenyDisplay/components/util.js +0 -1
  70. package/esm/LinearSyntenyDisplay/configSchemaF.js +0 -1
  71. package/esm/LinearSyntenyDisplay/drawSynteny.js +0 -1
  72. package/esm/LinearSyntenyDisplay/index.js +0 -1
  73. package/esm/LinearSyntenyDisplay/model.js +0 -1
  74. package/esm/LinearSyntenyView/components/ExportSvgDialog.js +0 -1
  75. package/esm/LinearSyntenyView/components/Icons.js +0 -1
  76. package/esm/LinearSyntenyView/components/ImportCustomTrack.js +0 -1
  77. package/esm/LinearSyntenyView/components/ImportForm.js +0 -1
  78. package/esm/LinearSyntenyView/components/ImportSyntenyTrackSelector.js +0 -1
  79. package/esm/LinearSyntenyView/components/LinearSyntenyView.js +0 -1
  80. package/esm/LinearSyntenyView/index.js +0 -1
  81. package/esm/LinearSyntenyView/model.d.ts +9 -9
  82. package/esm/LinearSyntenyView/model.js +0 -1
  83. package/esm/LinearSyntenyView/svgcomponents/SVGBackground.js +2 -2
  84. package/esm/LinearSyntenyView/svgcomponents/SVGLinearSyntenyView.js +0 -1
  85. package/esm/SyntenyFeatureDetail/SyntenyFeatureDetail.js +0 -1
  86. package/esm/SyntenyFeatureDetail/index.js +0 -1
  87. package/esm/SyntenyTrack/configSchema.js +0 -1
  88. package/esm/SyntenyTrack/index.js +0 -1
  89. package/esm/index.js +0 -1
  90. package/esm/util.js +0 -1
  91. package/package.json +4 -4
  92. package/dist/LGVSyntenyDisplay/configSchemaF.js.map +0 -1
  93. package/dist/LGVSyntenyDisplay/index.js.map +0 -1
  94. package/dist/LGVSyntenyDisplay/model.js.map +0 -1
  95. package/dist/LaunchLinearSyntenyView.js.map +0 -1
  96. package/dist/LinearComparativeDisplay/configSchemaF.js.map +0 -1
  97. package/dist/LinearComparativeDisplay/index.js.map +0 -1
  98. package/dist/LinearComparativeDisplay/stateModelFactory.js.map +0 -1
  99. package/dist/LinearComparativeView/components/Header.js.map +0 -1
  100. package/dist/LinearComparativeView/components/LinearComparativeView.js.map +0 -1
  101. package/dist/LinearComparativeView/components/Rubberband.js.map +0 -1
  102. package/dist/LinearComparativeView/index.js.map +0 -1
  103. package/dist/LinearComparativeView/model.js.map +0 -1
  104. package/dist/LinearReadVsRef/LinearReadVsRef.js.map +0 -1
  105. package/dist/LinearReadVsRef/index.js.map +0 -1
  106. package/dist/LinearSyntenyDisplay/afterAttach.js.map +0 -1
  107. package/dist/LinearSyntenyDisplay/components/Component.js.map +0 -1
  108. package/dist/LinearSyntenyDisplay/components/LinearSyntenyRendering.js.map +0 -1
  109. package/dist/LinearSyntenyDisplay/components/SyntenyTooltip.js.map +0 -1
  110. package/dist/LinearSyntenyDisplay/components/util.js.map +0 -1
  111. package/dist/LinearSyntenyDisplay/configSchemaF.js.map +0 -1
  112. package/dist/LinearSyntenyDisplay/drawSynteny.js.map +0 -1
  113. package/dist/LinearSyntenyDisplay/index.js.map +0 -1
  114. package/dist/LinearSyntenyDisplay/model.js.map +0 -1
  115. package/dist/LinearSyntenyView/components/ExportSvgDialog.js.map +0 -1
  116. package/dist/LinearSyntenyView/components/Icons.js.map +0 -1
  117. package/dist/LinearSyntenyView/components/ImportCustomTrack.js.map +0 -1
  118. package/dist/LinearSyntenyView/components/ImportForm.js.map +0 -1
  119. package/dist/LinearSyntenyView/components/ImportSyntenyTrackSelector.js.map +0 -1
  120. package/dist/LinearSyntenyView/components/LinearSyntenyView.js.map +0 -1
  121. package/dist/LinearSyntenyView/index.js.map +0 -1
  122. package/dist/LinearSyntenyView/model.js.map +0 -1
  123. package/dist/LinearSyntenyView/svgcomponents/SVGBackground.js.map +0 -1
  124. package/dist/LinearSyntenyView/svgcomponents/SVGLinearSyntenyView.js.map +0 -1
  125. package/dist/SyntenyFeatureDetail/SyntenyFeatureDetail.js.map +0 -1
  126. package/dist/SyntenyFeatureDetail/index.js.map +0 -1
  127. package/dist/SyntenyTrack/configSchema.js.map +0 -1
  128. package/dist/SyntenyTrack/index.js.map +0 -1
  129. package/dist/index.js.map +0 -1
  130. package/dist/util.js.map +0 -1
  131. package/esm/LGVSyntenyDisplay/configSchemaF.js.map +0 -1
  132. package/esm/LGVSyntenyDisplay/index.js.map +0 -1
  133. package/esm/LGVSyntenyDisplay/model.js.map +0 -1
  134. package/esm/LaunchLinearSyntenyView.js.map +0 -1
  135. package/esm/LinearComparativeDisplay/configSchemaF.js.map +0 -1
  136. package/esm/LinearComparativeDisplay/index.js.map +0 -1
  137. package/esm/LinearComparativeDisplay/stateModelFactory.js.map +0 -1
  138. package/esm/LinearComparativeView/components/Header.js.map +0 -1
  139. package/esm/LinearComparativeView/components/LinearComparativeView.js.map +0 -1
  140. package/esm/LinearComparativeView/components/Rubberband.js.map +0 -1
  141. package/esm/LinearComparativeView/index.js.map +0 -1
  142. package/esm/LinearComparativeView/model.js.map +0 -1
  143. package/esm/LinearReadVsRef/LinearReadVsRef.js.map +0 -1
  144. package/esm/LinearReadVsRef/index.js.map +0 -1
  145. package/esm/LinearSyntenyDisplay/afterAttach.js.map +0 -1
  146. package/esm/LinearSyntenyDisplay/components/Component.js.map +0 -1
  147. package/esm/LinearSyntenyDisplay/components/LinearSyntenyRendering.js.map +0 -1
  148. package/esm/LinearSyntenyDisplay/components/SyntenyTooltip.js.map +0 -1
  149. package/esm/LinearSyntenyDisplay/components/util.js.map +0 -1
  150. package/esm/LinearSyntenyDisplay/configSchemaF.js.map +0 -1
  151. package/esm/LinearSyntenyDisplay/drawSynteny.js.map +0 -1
  152. package/esm/LinearSyntenyDisplay/index.js.map +0 -1
  153. package/esm/LinearSyntenyDisplay/model.js.map +0 -1
  154. package/esm/LinearSyntenyView/components/ExportSvgDialog.js.map +0 -1
  155. package/esm/LinearSyntenyView/components/Icons.js.map +0 -1
  156. package/esm/LinearSyntenyView/components/ImportCustomTrack.js.map +0 -1
  157. package/esm/LinearSyntenyView/components/ImportForm.js.map +0 -1
  158. package/esm/LinearSyntenyView/components/ImportSyntenyTrackSelector.js.map +0 -1
  159. package/esm/LinearSyntenyView/components/LinearSyntenyView.js.map +0 -1
  160. package/esm/LinearSyntenyView/index.js.map +0 -1
  161. package/esm/LinearSyntenyView/model.js.map +0 -1
  162. package/esm/LinearSyntenyView/svgcomponents/SVGBackground.js.map +0 -1
  163. package/esm/LinearSyntenyView/svgcomponents/SVGLinearSyntenyView.js.map +0 -1
  164. package/esm/SyntenyFeatureDetail/SyntenyFeatureDetail.js.map +0 -1
  165. package/esm/SyntenyFeatureDetail/index.js.map +0 -1
  166. package/esm/SyntenyTrack/configSchema.js.map +0 -1
  167. package/esm/SyntenyTrack/index.js.map +0 -1
  168. package/esm/index.js.map +0 -1
  169. package/esm/util.js.map +0 -1
  170. package/src/LGVSyntenyDisplay/configSchemaF.ts +0 -22
  171. package/src/LGVSyntenyDisplay/index.ts +0 -20
  172. package/src/LGVSyntenyDisplay/model.ts +0 -177
  173. package/src/LaunchLinearSyntenyView.ts +0 -86
  174. package/src/LinearComparativeDisplay/configSchemaF.ts +0 -22
  175. package/src/LinearComparativeDisplay/index.ts +0 -21
  176. package/src/LinearComparativeDisplay/stateModelFactory.ts +0 -212
  177. package/src/LinearComparativeView/components/Header.tsx +0 -103
  178. package/src/LinearComparativeView/components/LinearComparativeView.tsx +0 -152
  179. package/src/LinearComparativeView/components/Rubberband.tsx +0 -329
  180. package/src/LinearComparativeView/index.ts +0 -15
  181. package/src/LinearComparativeView/model.ts +0 -395
  182. package/src/LinearReadVsRef/LinearReadVsRef.tsx +0 -360
  183. package/src/LinearReadVsRef/index.ts +0 -58
  184. package/src/LinearSyntenyDisplay/afterAttach.ts +0 -149
  185. package/src/LinearSyntenyDisplay/components/Component.tsx +0 -75
  186. package/src/LinearSyntenyDisplay/components/LinearSyntenyRendering.tsx +0 -200
  187. package/src/LinearSyntenyDisplay/components/SyntenyTooltip.tsx +0 -82
  188. package/src/LinearSyntenyDisplay/components/util.ts +0 -142
  189. package/src/LinearSyntenyDisplay/configSchemaF.ts +0 -38
  190. package/src/LinearSyntenyDisplay/drawSynteny.ts +0 -266
  191. package/src/LinearSyntenyDisplay/index.ts +0 -21
  192. package/src/LinearSyntenyDisplay/model.ts +0 -187
  193. package/src/LinearSyntenyView/components/ExportSvgDialog.tsx +0 -148
  194. package/src/LinearSyntenyView/components/Icons.tsx +0 -24
  195. package/src/LinearSyntenyView/components/ImportCustomTrack.tsx +0 -262
  196. package/src/LinearSyntenyView/components/ImportForm.tsx +0 -221
  197. package/src/LinearSyntenyView/components/ImportSyntenyTrackSelector.tsx +0 -82
  198. package/src/LinearSyntenyView/components/LinearSyntenyView.tsx +0 -20
  199. package/src/LinearSyntenyView/index.ts +0 -15
  200. package/src/LinearSyntenyView/model.test.ts +0 -1605
  201. package/src/LinearSyntenyView/model.ts +0 -169
  202. package/src/LinearSyntenyView/svgcomponents/SVGBackground.tsx +0 -21
  203. package/src/LinearSyntenyView/svgcomponents/SVGLinearSyntenyView.tsx +0 -176
  204. package/src/SyntenyFeatureDetail/SyntenyFeatureDetail.tsx +0 -64
  205. package/src/SyntenyFeatureDetail/index.ts +0 -36
  206. package/src/SyntenyTrack/configSchema.ts +0 -23
  207. package/src/SyntenyTrack/index.tsx +0 -15
  208. package/src/index.tsx +0 -42
  209. package/src/util.ts +0 -124
@@ -1,200 +0,0 @@
1
- import React, { useState, useCallback } from 'react'
2
- import { observer } from 'mobx-react'
3
- import {
4
- assembleLocString,
5
- getContainingView,
6
- getSession,
7
- isSessionModelWithWidgets,
8
- } from '@jbrowse/core/util'
9
-
10
- // locals
11
- import SyntenyTooltip from './SyntenyTooltip'
12
- import { LinearSyntenyDisplayModel } from '../model'
13
- import { getId, MAX_COLOR_RANGE } from '../drawSynteny'
14
-
15
- export default observer(function LinearSyntenyRendering({
16
- model,
17
- }: {
18
- model: LinearSyntenyDisplayModel
19
- }) {
20
- const highResolutionScaling = 1
21
- const view = getContainingView(model)
22
- const height = view.middleComparativeHeight
23
- const width = view.width
24
-
25
- const [tooltip, setTooltip] = useState('')
26
- const [currX, setCurrX] = useState<number>()
27
- const [currY, setCurrY] = useState<number>()
28
-
29
- // these useCallbacks avoid new refs from being created on any mouseover, etc.
30
- const k1 = useCallback(
31
- (ref: HTMLCanvasElement) => model.setMouseoverCanvasRef(ref),
32
- // eslint-disable-next-line react-hooks/exhaustive-deps
33
- [model, height, width],
34
- )
35
- const k2 = useCallback(
36
- (ref: HTMLCanvasElement) => model.setMainCanvasRef(ref),
37
- // eslint-disable-next-line react-hooks/exhaustive-deps
38
- [model, height, width],
39
- )
40
- const k3 = useCallback(
41
- (ref: HTMLCanvasElement) => model.setClickMapCanvasRef(ref),
42
- // eslint-disable-next-line react-hooks/exhaustive-deps
43
- [model, height, width],
44
- )
45
- const k4 = useCallback(
46
- (ref: HTMLCanvasElement) => model.setCigarClickMapCanvasRef(ref),
47
- // eslint-disable-next-line react-hooks/exhaustive-deps
48
- [model, height, width],
49
- )
50
-
51
- return (
52
- <div style={{ position: 'relative' }}>
53
- <canvas
54
- ref={k1}
55
- width={width}
56
- height={height}
57
- style={{ width, height, position: 'absolute', pointerEvents: 'none' }}
58
- />
59
- <canvas
60
- ref={k2}
61
- onMouseMove={event => {
62
- const ref1 = model.clickMapCanvas
63
- const ref2 = model.cigarClickMapCanvas
64
- if (!ref1 || !ref2) {
65
- return
66
- }
67
- const rect = ref1.getBoundingClientRect()
68
- const ctx1 = ref1.getContext('2d')
69
- const ctx2 = ref2.getContext('2d')
70
- if (!ctx1 || !ctx2) {
71
- return
72
- }
73
- const { clientX, clientY } = event
74
- const x = clientX - rect.left
75
- const y = clientY - rect.top
76
- setCurrX(clientX)
77
- setCurrY(clientY)
78
- const [r1, g1, b1] = ctx1.getImageData(x, y, 1, 1).data
79
- const [r2, g2, b2] = ctx2.getImageData(x, y, 1, 1).data
80
- const unitMultiplier = Math.floor(MAX_COLOR_RANGE / model.numFeats)
81
- const id = getId(r1, g1, b1, unitMultiplier)
82
- model.setMouseoverId(model.featPositions[id]?.f.id())
83
- if (id === -1) {
84
- setTooltip('')
85
- } else if (model.featPositions[id]) {
86
- const { f, cigar } = model.featPositions[id]
87
- // @ts-expect-error
88
- const f1 = f.toJSON() as {
89
- refName: string
90
- start: number
91
- end: number
92
- strand?: number
93
- assemblyName: string
94
- identity?: number
95
- name?: string
96
- mate: {
97
- start: number
98
- end: number
99
- refName: string
100
- name: string
101
- }
102
- }
103
- const f2 = f1.mate
104
- const unitMultiplier2 = Math.floor(MAX_COLOR_RANGE / cigar.length)
105
- const cigarIdx = getId(r2, g2, b2, unitMultiplier2)
106
- const l1 = f1.end - f1.start
107
- const l2 = f2.end - f2.start
108
- const identity = f1.identity
109
- const n1 = f1.name
110
- const n2 = f2.name
111
- const tooltip = [
112
- `Loc1: ${assembleLocString(f1)}`,
113
- `Loc2: ${assembleLocString(f2)}`,
114
- `Inverted: ${f1.strand === -1}`,
115
- `Query len: ${l1}`,
116
- `Target len: ${l2}`,
117
- ]
118
- if (identity) {
119
- tooltip.push(`Identity: ${identity}`)
120
- }
121
-
122
- if (cigar[cigarIdx]) {
123
- tooltip.push(
124
- `CIGAR operator: ${cigar[cigarIdx]}${cigar[cigarIdx + 1]}`,
125
- )
126
- }
127
- if (n1 && n2) {
128
- tooltip.push(`Name 1: ${n1}`, `Name 2: ${n2}`)
129
- }
130
- setTooltip(tooltip.join('<br/>'))
131
- }
132
- }}
133
- onMouseLeave={() => model.setMouseoverId(undefined)}
134
- onClick={event => {
135
- const ref1 = model.clickMapCanvas
136
- const ref2 = model.cigarClickMapCanvas
137
- if (!ref1 || !ref2) {
138
- return
139
- }
140
- const rect = ref1.getBoundingClientRect()
141
- const ctx1 = ref1.getContext('2d')
142
- const ctx2 = ref2.getContext('2d')
143
- if (!ctx1 || !ctx2) {
144
- return
145
- }
146
- const x = event.clientX - rect.left
147
- const y = event.clientY - rect.top
148
- const [r1, g1, b1] = ctx1.getImageData(x, y, 1, 1).data
149
- const unitMultiplier = Math.floor(MAX_COLOR_RANGE / model.numFeats)
150
- const id = getId(r1, g1, b1, unitMultiplier)
151
- const f = model.featPositions[id]
152
- if (!f) {
153
- return
154
- }
155
- model.setClickId(f.f.id())
156
- const session = getSession(model)
157
- if (isSessionModelWithWidgets(session)) {
158
- session.showWidget(
159
- session.addWidget('SyntenyFeatureWidget', 'syntenyFeature', {
160
- featureData: {
161
- feature1: f.f.toJSON(),
162
- feature2: f.f.get('mate'),
163
- },
164
- }),
165
- )
166
- }
167
- }}
168
- data-testid="synteny_canvas"
169
- style={{ width, height, position: 'absolute' }}
170
- width={width * highResolutionScaling}
171
- height={height * highResolutionScaling}
172
- />
173
- <canvas
174
- ref={k3}
175
- style={{
176
- imageRendering: 'pixelated',
177
- pointerEvents: 'none',
178
- visibility: 'hidden',
179
- position: 'absolute',
180
- }}
181
- width={width}
182
- height={height}
183
- />
184
- <canvas
185
- ref={k4}
186
- style={{
187
- imageRendering: 'pixelated',
188
- pointerEvents: 'none',
189
- visibility: 'hidden',
190
- position: 'absolute',
191
- }}
192
- width={width}
193
- height={height}
194
- />
195
- {model.mouseoverId && tooltip && currX && currY ? (
196
- <SyntenyTooltip x={currX} y={currY} title={tooltip} />
197
- ) : null}
198
- </div>
199
- )
200
- })
@@ -1,82 +0,0 @@
1
- import React, { useMemo, useState } from 'react'
2
- import { observer } from 'mobx-react'
3
- import { Portal, alpha } from '@mui/material'
4
- import { makeStyles } from 'tss-react/mui'
5
- import { usePopper } from 'react-popper'
6
- import { SanitizedHTML } from '@jbrowse/core/ui'
7
-
8
- function round(value: number) {
9
- return Math.round(value * 1e5) / 1e5
10
- }
11
-
12
- const useStyles = makeStyles()(theme => ({
13
- // these styles come from
14
- // https://github.com/mui-org/material-ui/blob/master/packages/material-ui/src/Tooltip/Tooltip.js
15
- tooltip: {
16
- position: 'absolute',
17
- pointerEvents: 'none',
18
- backgroundColor: alpha(theme.palette.grey[700], 0.9),
19
- borderRadius: theme.shape.borderRadius,
20
- color: theme.palette.common.white,
21
- fontFamily: theme.typography.fontFamily,
22
- padding: '4px 8px',
23
- fontSize: theme.typography.pxToRem(12),
24
- lineHeight: `${round(14 / 10)}em`,
25
- maxWidth: 300,
26
- wordWrap: 'break-word',
27
- },
28
- }))
29
-
30
- const SyntenyTooltip = observer(function ({
31
- x,
32
- y,
33
- title,
34
- }: {
35
- x: number
36
- y: number
37
- title: string
38
- }) {
39
- const [width, setWidth] = useState(0)
40
- const [anchorEl, setAnchorEl] = useState<HTMLDivElement | null>(null)
41
- const { classes } = useStyles()
42
-
43
- // must be memoized a la https://github.com/popperjs/react-popper/issues/391
44
- const virtElement = useMemo(
45
- () => ({
46
- getBoundingClientRect: () => {
47
- return {
48
- top: y,
49
- left: x + width / 2,
50
- bottom: y,
51
- right: x,
52
- width: 0,
53
- height: 0,
54
- x,
55
- y,
56
- toJSON() {},
57
- }
58
- },
59
- }),
60
- [x, y, width],
61
- )
62
- const { styles, attributes } = usePopper(virtElement, anchorEl)
63
-
64
- return title ? (
65
- <Portal>
66
- <div
67
- ref={ref => {
68
- setWidth(ref?.getBoundingClientRect().width || 0)
69
- setAnchorEl(ref)
70
- }}
71
- className={classes.tooltip}
72
- // zIndex needed to go over widget drawer
73
- style={{ ...styles.popper, zIndex: 100000 }}
74
- {...attributes.popper}
75
- >
76
- <SanitizedHTML html={title} />
77
- </div>
78
- </Portal>
79
- ) : null
80
- })
81
-
82
- export default SyntenyTooltip
@@ -1,142 +0,0 @@
1
- import { doesIntersect2, Feature } from '@jbrowse/core/util'
2
-
3
- interface Pos {
4
- offsetPx: number
5
- }
6
-
7
- interface FeatPos {
8
- p11: Pos
9
- p12: Pos
10
- p21: Pos
11
- p22: Pos
12
- f: Feature
13
- cigar: string[]
14
- }
15
-
16
- export function drawMatchSimple({
17
- feature,
18
- ctx,
19
- offsets,
20
- cb,
21
- height,
22
- drawCurves,
23
- oobLimit,
24
- viewWidth,
25
- hideTiny,
26
- }: {
27
- feature: FeatPos
28
- ctx: CanvasRenderingContext2D
29
- offsets: number[]
30
- oobLimit: number
31
- viewWidth: number
32
- cb: (ctx: CanvasRenderingContext2D) => void
33
- height: number
34
- drawCurves?: boolean
35
- hideTiny?: boolean
36
- }) {
37
- const { p11, p12, p21, p22 } = feature
38
-
39
- const x11 = p11.offsetPx - offsets[0]
40
- const x12 = p12.offsetPx - offsets[0]
41
- const x21 = p21.offsetPx - offsets[1]
42
- const x22 = p22.offsetPx - offsets[1]
43
-
44
- const l1 = Math.abs(x12 - x11)
45
- const l2 = Math.abs(x22 - x21)
46
- const y1 = 0
47
- const y2 = height
48
- const mid = (y2 - y1) / 2
49
- const minX = Math.min(x21, x22)
50
- const maxX = Math.max(x21, x22)
51
-
52
- if (!doesIntersect2(minX, maxX, -oobLimit, viewWidth + oobLimit)) {
53
- return
54
- }
55
-
56
- // drawing a line if the results are thin: drawing a line results in much
57
- // less pixellation than filling in a thin polygon
58
- if (l1 <= 1 && l2 <= 1) {
59
- // hideTiny can be used to avoid drawing mouseover for thin lines in this
60
- // case
61
- if (!hideTiny) {
62
- ctx.beginPath()
63
- ctx.moveTo(x11, y1)
64
- if (drawCurves) {
65
- ctx.bezierCurveTo(x11, mid, x21, mid, x21, y2)
66
- } else {
67
- ctx.lineTo(x21, y2)
68
- }
69
- ctx.stroke()
70
- }
71
- } else {
72
- draw(ctx, x11, x12, y1, x22, x21, y2, mid, drawCurves)
73
- cb(ctx)
74
- }
75
- }
76
-
77
- export function draw(
78
- ctx: CanvasRenderingContext2D,
79
- x1: number,
80
- x2: number,
81
- y1: number,
82
- x3: number,
83
- x4: number,
84
- y2: number,
85
- mid: number,
86
- drawCurves?: boolean,
87
- ) {
88
- if (drawCurves) {
89
- drawBezierBox(ctx, x1, x2, y1, x3, x4, y2, mid)
90
- } else {
91
- drawBox(ctx, x1, x2, y1, x3, x4, y2)
92
- }
93
- }
94
-
95
- export function drawBox(
96
- ctx: CanvasRenderingContext2D,
97
- x1: number,
98
- x2: number,
99
- y1: number,
100
- x3: number,
101
- x4: number,
102
- y2: number,
103
- ) {
104
- ctx.beginPath()
105
- ctx.moveTo(x1, y1)
106
- ctx.lineTo(x2, y1)
107
- ctx.lineTo(x3, y2)
108
- ctx.lineTo(x4, y2)
109
- ctx.closePath()
110
- ctx.fill()
111
- }
112
-
113
- export function drawBezierBox(
114
- ctx: CanvasRenderingContext2D,
115
- x1: number,
116
- x2: number,
117
- y1: number,
118
- x3: number,
119
- x4: number,
120
- y2: number,
121
- mid: number,
122
- ) {
123
- const len1 = Math.abs(x1 - x2)
124
- const len2 = Math.abs(x1 - x2)
125
-
126
- // heuristic to not draw hourglass inversions with bezier curves when they
127
- // are thin and far apart because it results in areas that are not drawn well
128
- // demo https://codesandbox.io/s/fast-glitter-q3b1or?file=/src/index.js
129
- if (len1 < 5 && len2 < 5 && x2 < x1 && Math.abs(x1 - x3) > 100) {
130
- const tmp = x1
131
- x1 = x2
132
- x2 = tmp
133
- }
134
- ctx.beginPath()
135
- ctx.moveTo(x1, y1)
136
- ctx.lineTo(x2, y1)
137
- ctx.bezierCurveTo(x2, mid, x3, mid, x3, y2)
138
- ctx.lineTo(x4, y2)
139
- ctx.bezierCurveTo(x4, mid, x1, mid, x1, y1)
140
- ctx.closePath()
141
- ctx.fill()
142
- }
@@ -1,38 +0,0 @@
1
- import { ConfigurationSchema } from '@jbrowse/core/configuration'
2
- import PluginManager from '@jbrowse/core/PluginManager'
3
- import baseConfigFactory from '../LinearComparativeDisplay/configSchemaF'
4
-
5
- /**
6
- * #config LinearSyntenyDisplay
7
- */
8
- function configSchemaFactory(pluginManager: PluginManager) {
9
- return ConfigurationSchema(
10
- 'LinearSyntenyDisplay',
11
- {
12
- /**
13
- * #slot
14
- * currently unused
15
- */
16
- trackIds: {
17
- type: 'stringArray',
18
- defaultValue: [],
19
- },
20
-
21
- /**
22
- * #slot
23
- * currently unused
24
- */
25
- middle: { type: 'boolean', defaultValue: true },
26
- },
27
- {
28
- /**
29
- * #baseConfiguration
30
- * this refers to the LinearComparativeDisplay
31
- */
32
- baseConfiguration: baseConfigFactory(pluginManager),
33
- explicitlyTyped: true,
34
- },
35
- )
36
- }
37
-
38
- export default configSchemaFactory