@jbrowse/plugin-dotplot-view 2.6.1

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 (263) hide show
  1. package/LICENSE +201 -0
  2. package/dist/ComparativeRenderer/index.d.ts +27 -0
  3. package/dist/ComparativeRenderer/index.js +59 -0
  4. package/dist/ComparativeRenderer/index.js.map +1 -0
  5. package/dist/DotplotDisplay/components/DotplotDisplay.d.ts +8 -0
  6. package/dist/DotplotDisplay/components/DotplotDisplay.js +24 -0
  7. package/dist/DotplotDisplay/components/DotplotDisplay.js.map +1 -0
  8. package/dist/DotplotDisplay/index.d.ts +12 -0
  9. package/dist/DotplotDisplay/index.js +48 -0
  10. package/dist/DotplotDisplay/index.js.map +1 -0
  11. package/dist/DotplotDisplay/renderDotplotBlock.d.ts +11 -0
  12. package/dist/DotplotDisplay/renderDotplotBlock.js +57 -0
  13. package/dist/DotplotDisplay/renderDotplotBlock.js.map +1 -0
  14. package/dist/DotplotDisplay/stateModelFactory.d.ts +138 -0
  15. package/dist/DotplotDisplay/stateModelFactory.js +165 -0
  16. package/dist/DotplotDisplay/stateModelFactory.js.map +1 -0
  17. package/dist/DotplotReadVsRef/DotplotReadVsRef.d.ts +3 -0
  18. package/dist/DotplotReadVsRef/DotplotReadVsRef.js +102 -0
  19. package/dist/DotplotReadVsRef/DotplotReadVsRef.js.map +1 -0
  20. package/dist/DotplotReadVsRef/index.d.ts +2 -0
  21. package/dist/DotplotReadVsRef/index.js +42 -0
  22. package/dist/DotplotReadVsRef/index.js.map +1 -0
  23. package/dist/DotplotRenderer/ComparativeRenderRpc.d.ts +27 -0
  24. package/dist/DotplotRenderer/ComparativeRenderRpc.js +59 -0
  25. package/dist/DotplotRenderer/ComparativeRenderRpc.js.map +1 -0
  26. package/dist/DotplotRenderer/DotplotRenderer.d.ts +69 -0
  27. package/dist/DotplotRenderer/DotplotRenderer.js +274 -0
  28. package/dist/DotplotRenderer/DotplotRenderer.js.map +1 -0
  29. package/dist/DotplotRenderer/components/DotplotRendering.d.ts +5 -0
  30. package/dist/DotplotRenderer/components/DotplotRendering.js +13 -0
  31. package/dist/DotplotRenderer/components/DotplotRendering.js.map +1 -0
  32. package/dist/DotplotRenderer/configSchema.d.ts +61 -0
  33. package/dist/DotplotRenderer/configSchema.js +83 -0
  34. package/dist/DotplotRenderer/configSchema.js.map +1 -0
  35. package/dist/DotplotRenderer/index.d.ts +3 -0
  36. package/dist/DotplotRenderer/index.js +17 -0
  37. package/dist/DotplotRenderer/index.js.map +1 -0
  38. package/dist/DotplotView/1dview.d.ts +307 -0
  39. package/dist/DotplotView/1dview.js +95 -0
  40. package/dist/DotplotView/1dview.js.map +1 -0
  41. package/dist/DotplotView/blockTypes.d.ts +61 -0
  42. package/dist/DotplotView/blockTypes.js +117 -0
  43. package/dist/DotplotView/blockTypes.js.map +1 -0
  44. package/dist/DotplotView/components/Axes.d.ts +14 -0
  45. package/dist/DotplotView/components/Axes.js +127 -0
  46. package/dist/DotplotView/components/Axes.js.map +1 -0
  47. package/dist/DotplotView/components/CursorIcon.d.ts +4 -0
  48. package/dist/DotplotView/components/CursorIcon.js +19 -0
  49. package/dist/DotplotView/components/CursorIcon.js.map +1 -0
  50. package/dist/DotplotView/components/DotplotTooltip.d.ts +19 -0
  51. package/dist/DotplotView/components/DotplotTooltip.js +128 -0
  52. package/dist/DotplotView/components/DotplotTooltip.js.map +1 -0
  53. package/dist/DotplotView/components/DotplotView.d.ts +6 -0
  54. package/dist/DotplotView/components/DotplotView.js +272 -0
  55. package/dist/DotplotView/components/DotplotView.js.map +1 -0
  56. package/dist/DotplotView/components/DotplotWarnings.d.ts +6 -0
  57. package/dist/DotplotView/components/DotplotWarnings.js +40 -0
  58. package/dist/DotplotView/components/DotplotWarnings.js.map +1 -0
  59. package/dist/DotplotView/components/ExportSvgDialog.d.ts +8 -0
  60. package/dist/DotplotView/components/ExportSvgDialog.js +76 -0
  61. package/dist/DotplotView/components/ExportSvgDialog.js.map +1 -0
  62. package/dist/DotplotView/components/Grid.d.ts +10 -0
  63. package/dist/DotplotView/components/Grid.js +60 -0
  64. package/dist/DotplotView/components/Grid.js.map +1 -0
  65. package/dist/DotplotView/components/Header.d.ts +10 -0
  66. package/dist/DotplotView/components/Header.js +168 -0
  67. package/dist/DotplotView/components/Header.js.map +1 -0
  68. package/dist/DotplotView/components/ImportCustomTrack.d.ts +11 -0
  69. package/dist/DotplotView/components/ImportCustomTrack.js +180 -0
  70. package/dist/DotplotView/components/ImportCustomTrack.js.map +1 -0
  71. package/dist/DotplotView/components/ImportForm.d.ts +6 -0
  72. package/dist/DotplotView/components/ImportForm.js +121 -0
  73. package/dist/DotplotView/components/ImportForm.js.map +1 -0
  74. package/dist/DotplotView/components/ImportSyntenyTrackSelector.d.ts +9 -0
  75. package/dist/DotplotView/components/ImportSyntenyTrackSelector.js +69 -0
  76. package/dist/DotplotView/components/ImportSyntenyTrackSelector.js.map +1 -0
  77. package/dist/DotplotView/components/PanButtons.d.ts +6 -0
  78. package/dist/DotplotView/components/PanButtons.js +60 -0
  79. package/dist/DotplotView/components/PanButtons.js.map +1 -0
  80. package/dist/DotplotView/components/WarningDialog.d.ts +16 -0
  81. package/dist/DotplotView/components/WarningDialog.js +41 -0
  82. package/dist/DotplotView/components/WarningDialog.js.map +1 -0
  83. package/dist/DotplotView/components/util.d.ts +19 -0
  84. package/dist/DotplotView/components/util.js +90 -0
  85. package/dist/DotplotView/components/util.js.map +1 -0
  86. package/dist/DotplotView/index.d.ts +2 -0
  87. package/dist/DotplotView/index.js +44 -0
  88. package/dist/DotplotView/index.js.map +1 -0
  89. package/dist/DotplotView/model.d.ts +616 -0
  90. package/dist/DotplotView/model.js +647 -0
  91. package/dist/DotplotView/model.js.map +1 -0
  92. package/dist/DotplotView/svgcomponents/SVGBackground.d.ts +5 -0
  93. package/dist/DotplotView/svgcomponents/SVGBackground.js +13 -0
  94. package/dist/DotplotView/svgcomponents/SVGBackground.js.map +1 -0
  95. package/dist/DotplotView/svgcomponents/SVGDotplotView.d.ts +2 -0
  96. package/dist/DotplotView/svgcomponents/SVGDotplotView.js +47 -0
  97. package/dist/DotplotView/svgcomponents/SVGDotplotView.js.map +1 -0
  98. package/dist/LaunchDotplotView.d.ts +2 -0
  99. package/dist/LaunchDotplotView.js +45 -0
  100. package/dist/LaunchDotplotView.js.map +1 -0
  101. package/dist/ServerSideRenderedBlockContent.d.ts +12 -0
  102. package/dist/ServerSideRenderedBlockContent.js +87 -0
  103. package/dist/ServerSideRenderedBlockContent.js.map +1 -0
  104. package/dist/ServerSideSyntenyRendering.d.ts +23 -0
  105. package/dist/ServerSideSyntenyRendering.js +54 -0
  106. package/dist/ServerSideSyntenyRendering.js.map +1 -0
  107. package/dist/index.d.ts +7 -0
  108. package/dist/index.js +44 -0
  109. package/dist/index.js.map +1 -0
  110. package/dist/util.d.ts +9 -0
  111. package/dist/util.js +9 -0
  112. package/dist/util.js.map +1 -0
  113. package/esm/ComparativeRenderer/index.d.ts +27 -0
  114. package/esm/ComparativeRenderer/index.js +53 -0
  115. package/esm/ComparativeRenderer/index.js.map +1 -0
  116. package/esm/DotplotDisplay/components/DotplotDisplay.d.ts +8 -0
  117. package/esm/DotplotDisplay/components/DotplotDisplay.js +19 -0
  118. package/esm/DotplotDisplay/components/DotplotDisplay.js.map +1 -0
  119. package/esm/DotplotDisplay/index.d.ts +12 -0
  120. package/esm/DotplotDisplay/index.js +41 -0
  121. package/esm/DotplotDisplay/index.js.map +1 -0
  122. package/esm/DotplotDisplay/renderDotplotBlock.d.ts +11 -0
  123. package/esm/DotplotDisplay/renderDotplotBlock.js +49 -0
  124. package/esm/DotplotDisplay/renderDotplotBlock.js.map +1 -0
  125. package/esm/DotplotDisplay/stateModelFactory.d.ts +138 -0
  126. package/esm/DotplotDisplay/stateModelFactory.js +158 -0
  127. package/esm/DotplotDisplay/stateModelFactory.js.map +1 -0
  128. package/esm/DotplotReadVsRef/DotplotReadVsRef.d.ts +3 -0
  129. package/esm/DotplotReadVsRef/DotplotReadVsRef.js +98 -0
  130. package/esm/DotplotReadVsRef/DotplotReadVsRef.js.map +1 -0
  131. package/esm/DotplotReadVsRef/index.d.ts +2 -0
  132. package/esm/DotplotReadVsRef/index.js +36 -0
  133. package/esm/DotplotReadVsRef/index.js.map +1 -0
  134. package/esm/DotplotRenderer/ComparativeRenderRpc.d.ts +27 -0
  135. package/esm/DotplotRenderer/ComparativeRenderRpc.js +53 -0
  136. package/esm/DotplotRenderer/ComparativeRenderRpc.js.map +1 -0
  137. package/esm/DotplotRenderer/DotplotRenderer.d.ts +69 -0
  138. package/esm/DotplotRenderer/DotplotRenderer.js +268 -0
  139. package/esm/DotplotRenderer/DotplotRenderer.js.map +1 -0
  140. package/esm/DotplotRenderer/components/DotplotRendering.d.ts +5 -0
  141. package/esm/DotplotRenderer/components/DotplotRendering.js +8 -0
  142. package/esm/DotplotRenderer/components/DotplotRendering.js.map +1 -0
  143. package/esm/DotplotRenderer/configSchema.d.ts +61 -0
  144. package/esm/DotplotRenderer/configSchema.js +81 -0
  145. package/esm/DotplotRenderer/configSchema.js.map +1 -0
  146. package/esm/DotplotRenderer/index.d.ts +3 -0
  147. package/esm/DotplotRenderer/index.js +12 -0
  148. package/esm/DotplotRenderer/index.js.map +1 -0
  149. package/esm/DotplotView/1dview.d.ts +307 -0
  150. package/esm/DotplotView/1dview.js +87 -0
  151. package/esm/DotplotView/1dview.js.map +1 -0
  152. package/esm/DotplotView/blockTypes.d.ts +61 -0
  153. package/esm/DotplotView/blockTypes.js +109 -0
  154. package/esm/DotplotView/blockTypes.js.map +1 -0
  155. package/esm/DotplotView/components/Axes.d.ts +14 -0
  156. package/esm/DotplotView/components/Axes.js +121 -0
  157. package/esm/DotplotView/components/Axes.js.map +1 -0
  158. package/esm/DotplotView/components/CursorIcon.d.ts +4 -0
  159. package/esm/DotplotView/components/CursorIcon.js +11 -0
  160. package/esm/DotplotView/components/CursorIcon.js.map +1 -0
  161. package/esm/DotplotView/components/DotplotTooltip.d.ts +19 -0
  162. package/esm/DotplotView/components/DotplotTooltip.js +101 -0
  163. package/esm/DotplotView/components/DotplotTooltip.js.map +1 -0
  164. package/esm/DotplotView/components/DotplotView.d.ts +6 -0
  165. package/esm/DotplotView/components/DotplotView.js +244 -0
  166. package/esm/DotplotView/components/DotplotView.js.map +1 -0
  167. package/esm/DotplotView/components/DotplotWarnings.d.ts +6 -0
  168. package/esm/DotplotView/components/DotplotWarnings.js +15 -0
  169. package/esm/DotplotView/components/DotplotWarnings.js.map +1 -0
  170. package/esm/DotplotView/components/ExportSvgDialog.d.ts +8 -0
  171. package/esm/DotplotView/components/ExportSvgDialog.js +50 -0
  172. package/esm/DotplotView/components/ExportSvgDialog.js.map +1 -0
  173. package/esm/DotplotView/components/Grid.d.ts +10 -0
  174. package/esm/DotplotView/components/Grid.js +53 -0
  175. package/esm/DotplotView/components/Grid.js.map +1 -0
  176. package/esm/DotplotView/components/Header.d.ts +10 -0
  177. package/esm/DotplotView/components/Header.js +140 -0
  178. package/esm/DotplotView/components/Header.js.map +1 -0
  179. package/esm/DotplotView/components/ImportCustomTrack.d.ts +11 -0
  180. package/esm/DotplotView/components/ImportCustomTrack.js +152 -0
  181. package/esm/DotplotView/components/ImportCustomTrack.js.map +1 -0
  182. package/esm/DotplotView/components/ImportForm.d.ts +6 -0
  183. package/esm/DotplotView/components/ImportForm.js +93 -0
  184. package/esm/DotplotView/components/ImportForm.js.map +1 -0
  185. package/esm/DotplotView/components/ImportSyntenyTrackSelector.d.ts +9 -0
  186. package/esm/DotplotView/components/ImportSyntenyTrackSelector.js +44 -0
  187. package/esm/DotplotView/components/ImportSyntenyTrackSelector.js.map +1 -0
  188. package/esm/DotplotView/components/PanButtons.d.ts +6 -0
  189. package/esm/DotplotView/components/PanButtons.js +55 -0
  190. package/esm/DotplotView/components/PanButtons.js.map +1 -0
  191. package/esm/DotplotView/components/WarningDialog.d.ts +16 -0
  192. package/esm/DotplotView/components/WarningDialog.js +36 -0
  193. package/esm/DotplotView/components/WarningDialog.js.map +1 -0
  194. package/esm/DotplotView/components/util.d.ts +19 -0
  195. package/esm/DotplotView/components/util.js +83 -0
  196. package/esm/DotplotView/components/util.js.map +1 -0
  197. package/esm/DotplotView/index.d.ts +2 -0
  198. package/esm/DotplotView/index.js +15 -0
  199. package/esm/DotplotView/index.js.map +1 -0
  200. package/esm/DotplotView/model.d.ts +616 -0
  201. package/esm/DotplotView/model.js +616 -0
  202. package/esm/DotplotView/model.js.map +1 -0
  203. package/esm/DotplotView/svgcomponents/SVGBackground.d.ts +5 -0
  204. package/esm/DotplotView/svgcomponents/SVGBackground.js +7 -0
  205. package/esm/DotplotView/svgcomponents/SVGBackground.js.map +1 -0
  206. package/esm/DotplotView/svgcomponents/SVGDotplotView.d.ts +2 -0
  207. package/esm/DotplotView/svgcomponents/SVGDotplotView.js +40 -0
  208. package/esm/DotplotView/svgcomponents/SVGDotplotView.js.map +1 -0
  209. package/esm/LaunchDotplotView.d.ts +2 -0
  210. package/esm/LaunchDotplotView.js +42 -0
  211. package/esm/LaunchDotplotView.js.map +1 -0
  212. package/esm/ServerSideRenderedBlockContent.d.ts +12 -0
  213. package/esm/ServerSideRenderedBlockContent.js +62 -0
  214. package/esm/ServerSideRenderedBlockContent.js.map +1 -0
  215. package/esm/ServerSideSyntenyRendering.d.ts +23 -0
  216. package/esm/ServerSideSyntenyRendering.js +29 -0
  217. package/esm/ServerSideSyntenyRendering.js.map +1 -0
  218. package/esm/index.d.ts +7 -0
  219. package/esm/index.js +38 -0
  220. package/esm/index.js.map +1 -0
  221. package/esm/util.d.ts +9 -0
  222. package/esm/util.js +5 -0
  223. package/esm/util.js.map +1 -0
  224. package/package.json +69 -0
  225. package/src/ComparativeRenderer/index.ts +87 -0
  226. package/src/DotplotDisplay/components/DotplotDisplay.tsx +34 -0
  227. package/src/DotplotDisplay/index.ts +48 -0
  228. package/src/DotplotDisplay/renderDotplotBlock.ts +60 -0
  229. package/src/DotplotDisplay/stateModelFactory.tsx +196 -0
  230. package/src/DotplotReadVsRef/DotplotReadVsRef.ts +115 -0
  231. package/src/DotplotReadVsRef/index.ts +50 -0
  232. package/src/DotplotRenderer/ComparativeRenderRpc.ts +87 -0
  233. package/src/DotplotRenderer/DotplotRenderer.ts +328 -0
  234. package/src/DotplotRenderer/__image_snapshots__/linear-synteny-renderer-test-ts-test-rendering-a-simple-synteny-from-fake-data-1-snap.png +0 -0
  235. package/src/DotplotRenderer/components/DotplotRendering.tsx +12 -0
  236. package/src/DotplotRenderer/configSchema.ts +92 -0
  237. package/src/DotplotRenderer/index.ts +16 -0
  238. package/src/DotplotView/1dview.ts +98 -0
  239. package/src/DotplotView/blockTypes.ts +140 -0
  240. package/src/DotplotView/components/Axes.tsx +246 -0
  241. package/src/DotplotView/components/CursorIcon.tsx +24 -0
  242. package/src/DotplotView/components/DotplotTooltip.tsx +163 -0
  243. package/src/DotplotView/components/DotplotView.tsx +348 -0
  244. package/src/DotplotView/components/DotplotWarnings.tsx +26 -0
  245. package/src/DotplotView/components/ExportSvgDialog.tsx +129 -0
  246. package/src/DotplotView/components/Grid.tsx +112 -0
  247. package/src/DotplotView/components/Header.tsx +182 -0
  248. package/src/DotplotView/components/ImportCustomTrack.tsx +262 -0
  249. package/src/DotplotView/components/ImportForm.tsx +209 -0
  250. package/src/DotplotView/components/ImportSyntenyTrackSelector.tsx +90 -0
  251. package/src/DotplotView/components/PanButtons.tsx +93 -0
  252. package/src/DotplotView/components/WarningDialog.tsx +74 -0
  253. package/src/DotplotView/components/util.ts +118 -0
  254. package/src/DotplotView/index.ts +16 -0
  255. package/src/DotplotView/model.test.ts +17 -0
  256. package/src/DotplotView/model.ts +719 -0
  257. package/src/DotplotView/svgcomponents/SVGBackground.tsx +21 -0
  258. package/src/DotplotView/svgcomponents/SVGDotplotView.tsx +68 -0
  259. package/src/LaunchDotplotView.ts +63 -0
  260. package/src/ServerSideRenderedBlockContent.tsx +86 -0
  261. package/src/ServerSideSyntenyRendering.tsx +54 -0
  262. package/src/index.ts +41 -0
  263. package/src/util.ts +14 -0
@@ -0,0 +1,246 @@
1
+ import React from 'react'
2
+ import { makeStyles } from 'tss-react/mui'
3
+ import { observer } from 'mobx-react'
4
+ import { getSnapshot } from 'mobx-state-tree'
5
+ import { getTickDisplayStr } from '@jbrowse/core/util'
6
+ import { bpToPx } from '@jbrowse/core/util/Base1DUtils'
7
+ import { useTheme } from '@mui/material'
8
+
9
+ // locals
10
+ import { getBlockLabelKeysToHide } from './util'
11
+ import { DotplotViewModel } from '../model'
12
+
13
+ const useStyles = makeStyles()(() => ({
14
+ vtext: {
15
+ gridColumn: '1/2',
16
+ gridRow: '1/2',
17
+ pointerEvents: 'none',
18
+ userSelect: 'none',
19
+ },
20
+ htext: {
21
+ gridColumn: '2/2',
22
+ gridRow: '2/2',
23
+ pointerEvents: 'none',
24
+ userSelect: 'none',
25
+ },
26
+ }))
27
+
28
+ export const HorizontalAxis = observer(function ({
29
+ model,
30
+ }: {
31
+ model: DotplotViewModel
32
+ }) {
33
+ const { viewWidth, borderY } = model
34
+ const { classes } = useStyles()
35
+ return (
36
+ <svg width={viewWidth} height={borderY} className={classes.htext}>
37
+ <HorizontalAxisRaw model={model} />
38
+ </svg>
39
+ )
40
+ })
41
+
42
+ export const HorizontalAxisRaw = observer(function ({
43
+ model,
44
+ }: {
45
+ model: DotplotViewModel
46
+ }) {
47
+ const { viewWidth, borderX, borderY, hview, htextRotation, hticks } = model
48
+ const { offsetPx, width, dynamicBlocks, bpPerPx } = hview
49
+ const dblocks = dynamicBlocks.contentBlocks
50
+ const hide = getBlockLabelKeysToHide(dblocks, viewWidth, offsetPx)
51
+ const theme = useTheme()
52
+ const hviewSnap = {
53
+ ...getSnapshot(hview),
54
+ width,
55
+ staticBlocks: hview.staticBlocks,
56
+ }
57
+
58
+ return (
59
+ <>
60
+ {dblocks
61
+ .filter(region => !hide.has(region.key))
62
+ .map(region => {
63
+ const x = region.offsetPx
64
+ const y = 0
65
+ const xoff = Math.floor(x - hview.offsetPx)
66
+
67
+ return (
68
+ <text
69
+ transform={`rotate(${htextRotation},${xoff},${y})`}
70
+ key={JSON.stringify(region)}
71
+ x={xoff}
72
+ y={y + 1}
73
+ fill={theme.palette.text.primary}
74
+ fontSize={11}
75
+ dominantBaseline="hanging"
76
+ textAnchor="end"
77
+ >
78
+ {region.refName}
79
+ </text>
80
+ )
81
+ })}
82
+ {hticks.map(tick => {
83
+ const x =
84
+ (bpToPx({
85
+ refName: tick.refName,
86
+ coord: tick.base,
87
+ self: hviewSnap,
88
+ })?.offsetPx || 0) - offsetPx
89
+ return (
90
+ <line
91
+ key={`line-${JSON.stringify(tick)}`}
92
+ x1={x}
93
+ x2={x}
94
+ y1={0}
95
+ y2={tick.type === 'major' ? 6 : 4}
96
+ strokeWidth={1}
97
+ stroke={theme.palette.divider}
98
+ />
99
+ )
100
+ })}
101
+ {hticks
102
+ .filter(tick => tick.type === 'major')
103
+ .map(tick => {
104
+ const x =
105
+ (bpToPx({
106
+ refName: tick.refName,
107
+ coord: tick.base,
108
+ self: hviewSnap,
109
+ })?.offsetPx || 0) - offsetPx
110
+ const y = 0
111
+ return x > 10 ? (
112
+ <text
113
+ x={x - 7}
114
+ y={y}
115
+ transform={`rotate(${htextRotation},${x},${y})`}
116
+ key={`text-${JSON.stringify(tick)}`}
117
+ fill={theme.palette.text.primary}
118
+ fontSize={11}
119
+ dominantBaseline="middle"
120
+ textAnchor="end"
121
+ >
122
+ {getTickDisplayStr(tick.base + 1, bpPerPx)}
123
+ </text>
124
+ ) : null
125
+ })}
126
+ <text
127
+ y={borderY - 12}
128
+ x={(viewWidth - borderX) / 2}
129
+ fill={theme.palette.text.primary}
130
+ textAnchor="middle"
131
+ fontSize={11}
132
+ dominantBaseline="hanging"
133
+ >
134
+ {hview.assemblyNames.join(',')}
135
+ </text>
136
+ </>
137
+ )
138
+ })
139
+
140
+ export const VerticalAxis = observer(function ({
141
+ model,
142
+ }: {
143
+ model: DotplotViewModel
144
+ }) {
145
+ const { borderX, viewHeight } = model
146
+ const { classes } = useStyles()
147
+ return (
148
+ <svg className={classes.vtext} width={borderX} height={viewHeight}>
149
+ <VerticalAxisRaw model={model} />
150
+ </svg>
151
+ )
152
+ })
153
+
154
+ export const VerticalAxisRaw = observer(function ({
155
+ model,
156
+ }: {
157
+ model: DotplotViewModel
158
+ }) {
159
+ const { viewHeight, borderX, borderY, vview, vtextRotation, vticks } = model
160
+ const { offsetPx, width, dynamicBlocks, bpPerPx } = vview
161
+ const dblocks = dynamicBlocks.contentBlocks
162
+ const hide = getBlockLabelKeysToHide(dblocks, viewHeight, offsetPx)
163
+ const theme = useTheme()
164
+ const vviewSnap = {
165
+ ...getSnapshot(vview),
166
+ width,
167
+ staticBlocks: vview.staticBlocks,
168
+ }
169
+ return (
170
+ <>
171
+ {dblocks
172
+ .filter(region => !hide.has(region.key))
173
+ .map(region => {
174
+ const y = region.offsetPx
175
+ const x = borderX
176
+ const yoff = Math.floor(viewHeight - y + offsetPx)
177
+
178
+ return (
179
+ <text
180
+ transform={`rotate(${vtextRotation},${x},${y})`}
181
+ key={JSON.stringify(region)}
182
+ x={x}
183
+ y={yoff}
184
+ fill={theme.palette.text.primary}
185
+ fontSize={11}
186
+ textAnchor="end"
187
+ >
188
+ {region.refName}
189
+ </text>
190
+ )
191
+ })}
192
+ {vticks.map(tick => {
193
+ const y =
194
+ (bpToPx({
195
+ refName: tick.refName,
196
+ coord: tick.base,
197
+ self: vviewSnap,
198
+ })?.offsetPx || 0) - offsetPx
199
+ return (
200
+ <line
201
+ key={`line-${JSON.stringify(tick)}`}
202
+ y1={viewHeight - y}
203
+ y2={viewHeight - y}
204
+ x1={borderX}
205
+ x2={borderX - (tick.type === 'major' ? 6 : 4)}
206
+ strokeWidth={1}
207
+ stroke={theme.palette.divider}
208
+ />
209
+ )
210
+ })}
211
+ {vticks
212
+ .filter(tick => tick.type === 'major')
213
+ .map(tick => {
214
+ const y =
215
+ (bpToPx({
216
+ refName: tick.refName,
217
+ coord: tick.base,
218
+ self: vviewSnap,
219
+ })?.offsetPx || 0) - offsetPx
220
+ return y > 10 ? (
221
+ <text
222
+ y={viewHeight - y - 3}
223
+ x={borderX - 7}
224
+ key={`text-${JSON.stringify(tick)}`}
225
+ textAnchor="end"
226
+ fill={theme.palette.text.primary}
227
+ dominantBaseline="hanging"
228
+ fontSize={11}
229
+ >
230
+ {getTickDisplayStr(tick.base + 1, bpPerPx)}
231
+ </text>
232
+ ) : null
233
+ })}
234
+ <text
235
+ y={(viewHeight - borderY) / 2}
236
+ x={12}
237
+ fill={theme.palette.text.primary}
238
+ transform={`rotate(-90,12,${(viewHeight - borderY) / 2})`}
239
+ textAnchor="middle"
240
+ fontSize={11}
241
+ >
242
+ {vview.assemblyNames.join(',')}
243
+ </text>
244
+ </>
245
+ )
246
+ })
@@ -0,0 +1,24 @@
1
+ import SvgIcon, { SvgIconProps } from '@mui/material/SvgIcon'
2
+ import React from 'react'
3
+
4
+ export function CursorMove(props: SvgIconProps) {
5
+ return (
6
+ <SvgIcon {...props}>
7
+ <path
8
+ fill="currentColor"
9
+ d="M13,6V11H18V7.75L22.25,12L18,16.25V13H13V18H16.25L12,22.25L7.75,18H11V13H6V16.25L1.75,12L6,7.75V11H11V6H7.75L12,1.75L16.25,6H13Z"
10
+ />
11
+ </SvgIcon>
12
+ )
13
+ }
14
+
15
+ export function CursorMouse(props: SvgIconProps) {
16
+ return (
17
+ <SvgIcon {...props}>
18
+ <path
19
+ fill="currentColor"
20
+ d="M10.07,14.27C10.57,14.03 11.16,14.25 11.4,14.75L13.7,19.74L15.5,18.89L13.19,13.91C12.95,13.41 13.17,12.81 13.67,12.58L13.95,12.5L16.25,12.05L8,5.12V15.9L9.82,14.43L10.07,14.27M13.64,21.97C13.14,22.21 12.54,22 12.31,21.5L10.13,16.76L7.62,18.78C7.45,18.92 7.24,19 7,19A1,1 0 0,1 6,18V3A1,1 0 0,1 7,2C7.24,2 7.47,2.09 7.64,2.23L7.65,2.22L19.14,11.86C19.57,12.22 19.62,12.85 19.27,13.27C19.12,13.45 18.91,13.57 18.7,13.61L15.54,14.23L17.74,18.96C18,19.46 17.76,20.05 17.26,20.28L13.64,21.97Z"
21
+ />
22
+ </SvgIcon>
23
+ )
24
+ }
@@ -0,0 +1,163 @@
1
+ import React, { useMemo, useRef, useState } from 'react'
2
+ import { observer } from 'mobx-react'
3
+ import { makeStyles } from 'tss-react/mui'
4
+
5
+ // locals
6
+ import { DotplotViewModel } from '../model'
7
+ import { locstr } from './util'
8
+ import { Portal, alpha } from '@mui/material'
9
+ import { usePopper } from 'react-popper'
10
+
11
+ export function round(value: number) {
12
+ return Math.round(value * 1e5) / 1e5
13
+ }
14
+ const useStyles = makeStyles()(theme => ({
15
+ // these styles come from
16
+ // https://github.com/mui-org/material-ui/blob/master/packages/material-ui/src/Tooltip/Tooltip.js
17
+ tooltip: {
18
+ position: 'absolute',
19
+ pointerEvents: 'none',
20
+ backgroundColor: alpha(theme.palette.grey[700], 0.9),
21
+ borderRadius: theme.shape.borderRadius,
22
+ color: theme.palette.common.white,
23
+ fontFamily: theme.typography.fontFamily,
24
+ padding: '4px 8px',
25
+ fontSize: theme.typography.pxToRem(12),
26
+ lineHeight: `${round(14 / 10)}em`,
27
+ maxWidth: 300,
28
+ wordWrap: 'break-word',
29
+ },
30
+ }))
31
+
32
+ type Coord = [number, number] | undefined
33
+ const blank = { left: 0, top: 0, width: 0, height: 0 }
34
+
35
+ export const TooltipWhereMouseovered = observer(function ({
36
+ model,
37
+ mouserect,
38
+ mouserectClient,
39
+ xdistance,
40
+ ydistance,
41
+ }: {
42
+ model: DotplotViewModel
43
+ mouserect: Coord
44
+ mouserectClient: Coord
45
+ xdistance: number
46
+ ydistance: number
47
+ }) {
48
+ const { classes } = useStyles()
49
+ const { hview, vview, viewHeight } = model
50
+ const [anchorEl, setAnchorEl] = useState<HTMLDivElement | null>(null)
51
+ const ref = useRef<HTMLDivElement>(null)
52
+ const rect = ref.current?.getBoundingClientRect() || blank
53
+ const offset = 6
54
+ const w = rect.height + offset * 2
55
+
56
+ // must be memoized a la https://github.com/popperjs/react-popper/issues/391
57
+ const virtElement = useMemo(
58
+ () => ({
59
+ getBoundingClientRect: () => {
60
+ const x = offset + (mouserectClient?.[0] || 0) - (xdistance < 0 ? w : 0)
61
+ const y = offset + (mouserectClient?.[1] || 0) - (ydistance < 0 ? w : 0)
62
+ return {
63
+ top: y,
64
+ left: x,
65
+ bottom: y,
66
+ right: x,
67
+ width: 0,
68
+ height: 0,
69
+ x,
70
+ y,
71
+ toJSON() {},
72
+ }
73
+ },
74
+ }),
75
+ [mouserectClient, xdistance, ydistance, w],
76
+ )
77
+ const { styles, attributes } = usePopper(virtElement, anchorEl, {
78
+ placement: xdistance < 0 ? 'left' : 'right',
79
+ })
80
+ return (
81
+ <>
82
+ {mouserect ? (
83
+ <Portal>
84
+ <div
85
+ ref={setAnchorEl}
86
+ className={classes.tooltip}
87
+ // zIndex needed to go over widget drawer
88
+ style={{ ...styles.popper, zIndex: 100000 }}
89
+ {...attributes.popper}
90
+ >
91
+ {`x - ${locstr(mouserect[0], hview)}`}
92
+ <br />
93
+ {`y - ${locstr(viewHeight - mouserect[1], vview)}`}
94
+ <br />
95
+ </div>
96
+ </Portal>
97
+ ) : null}
98
+ </>
99
+ )
100
+ })
101
+
102
+ export const TooltipWhereClicked = observer(function ({
103
+ model,
104
+ mousedown,
105
+ mousedownClient,
106
+ xdistance,
107
+ ydistance,
108
+ }: {
109
+ model: DotplotViewModel
110
+ mousedown: Coord
111
+ mousedownClient: Coord
112
+ xdistance: number
113
+ ydistance: number
114
+ }) {
115
+ const { classes } = useStyles()
116
+ const { hview, vview, viewHeight } = model
117
+ const [anchorEl, setAnchorEl] = useState<HTMLDivElement | null>(null)
118
+
119
+ // must be memoized a la https://github.com/popperjs/react-popper/issues/391
120
+ const virtElement = useMemo(
121
+ () => ({
122
+ getBoundingClientRect: () => {
123
+ const x = (mousedownClient?.[0] || 0) - (xdistance < 0 ? 0 : 0)
124
+ const y = (mousedownClient?.[1] || 0) - (ydistance < 0 ? 0 : 0)
125
+ return {
126
+ top: y,
127
+ left: x,
128
+ bottom: y,
129
+ right: x,
130
+ width: 0,
131
+ height: 0,
132
+ x,
133
+ y,
134
+ toJSON() {},
135
+ }
136
+ },
137
+ }),
138
+ [mousedownClient, xdistance, ydistance],
139
+ )
140
+ const { styles, attributes } = usePopper(virtElement, anchorEl, {
141
+ placement: xdistance < 0 ? 'right' : 'left',
142
+ })
143
+ return (
144
+ <>
145
+ {mousedown && Math.abs(xdistance) > 3 && Math.abs(ydistance) > 3 ? (
146
+ <Portal>
147
+ <div
148
+ ref={setAnchorEl}
149
+ className={classes.tooltip}
150
+ // zIndex needed to go over widget drawer
151
+ style={{ ...styles.popper, zIndex: 100000 }}
152
+ {...attributes.popper}
153
+ >
154
+ {`x - ${locstr(mousedown[0], hview)}`}
155
+ <br />
156
+ {`y - ${locstr(viewHeight - mousedown[1], vview)}`}
157
+ <br />
158
+ </div>
159
+ </Portal>
160
+ ) : null}
161
+ </>
162
+ )
163
+ })