@jbrowse/plugin-dotplot-view 2.6.1 → 2.6.2

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 (188) hide show
  1. package/dist/ComparativeRenderer/index.js +0 -1
  2. package/dist/DotplotDisplay/components/DotplotDisplay.js +0 -1
  3. package/dist/DotplotDisplay/index.js +0 -1
  4. package/dist/DotplotDisplay/renderDotplotBlock.js +0 -1
  5. package/dist/DotplotDisplay/stateModelFactory.js +0 -1
  6. package/dist/DotplotReadVsRef/DotplotReadVsRef.js +0 -1
  7. package/dist/DotplotReadVsRef/index.js +0 -1
  8. package/dist/DotplotRenderer/ComparativeRenderRpc.js +0 -1
  9. package/dist/DotplotRenderer/DotplotRenderer.js +0 -1
  10. package/dist/DotplotRenderer/components/DotplotRendering.js +0 -1
  11. package/dist/DotplotRenderer/configSchema.js +0 -1
  12. package/dist/DotplotRenderer/index.js +0 -1
  13. package/dist/DotplotView/1dview.js +0 -1
  14. package/dist/DotplotView/blockTypes.js +0 -1
  15. package/dist/DotplotView/components/Axes.js +0 -1
  16. package/dist/DotplotView/components/CursorIcon.js +0 -1
  17. package/dist/DotplotView/components/DotplotTooltip.js +0 -1
  18. package/dist/DotplotView/components/DotplotView.js +0 -1
  19. package/dist/DotplotView/components/DotplotWarnings.js +0 -1
  20. package/dist/DotplotView/components/ExportSvgDialog.js +0 -1
  21. package/dist/DotplotView/components/Grid.js +0 -1
  22. package/dist/DotplotView/components/Header.js +0 -1
  23. package/dist/DotplotView/components/ImportCustomTrack.js +0 -1
  24. package/dist/DotplotView/components/ImportForm.js +0 -1
  25. package/dist/DotplotView/components/ImportSyntenyTrackSelector.js +0 -1
  26. package/dist/DotplotView/components/PanButtons.js +0 -1
  27. package/dist/DotplotView/components/WarningDialog.js +0 -1
  28. package/dist/DotplotView/components/util.js +0 -1
  29. package/dist/DotplotView/index.js +0 -1
  30. package/dist/DotplotView/model.js +0 -1
  31. package/dist/DotplotView/svgcomponents/SVGBackground.js +0 -1
  32. package/dist/DotplotView/svgcomponents/SVGDotplotView.js +0 -1
  33. package/dist/LaunchDotplotView.js +0 -1
  34. package/dist/ServerSideRenderedBlockContent.js +0 -1
  35. package/dist/ServerSideSyntenyRendering.js +0 -1
  36. package/dist/index.js +0 -1
  37. package/dist/util.js +0 -1
  38. package/esm/ComparativeRenderer/index.js +0 -1
  39. package/esm/DotplotDisplay/components/DotplotDisplay.js +0 -1
  40. package/esm/DotplotDisplay/index.js +0 -1
  41. package/esm/DotplotDisplay/renderDotplotBlock.js +0 -1
  42. package/esm/DotplotDisplay/stateModelFactory.js +0 -1
  43. package/esm/DotplotReadVsRef/DotplotReadVsRef.js +0 -1
  44. package/esm/DotplotReadVsRef/index.js +0 -1
  45. package/esm/DotplotRenderer/ComparativeRenderRpc.js +0 -1
  46. package/esm/DotplotRenderer/DotplotRenderer.js +0 -1
  47. package/esm/DotplotRenderer/components/DotplotRendering.js +0 -1
  48. package/esm/DotplotRenderer/configSchema.js +0 -1
  49. package/esm/DotplotRenderer/index.js +0 -1
  50. package/esm/DotplotView/1dview.js +0 -1
  51. package/esm/DotplotView/blockTypes.js +0 -1
  52. package/esm/DotplotView/components/Axes.js +0 -1
  53. package/esm/DotplotView/components/CursorIcon.js +0 -1
  54. package/esm/DotplotView/components/DotplotTooltip.js +0 -1
  55. package/esm/DotplotView/components/DotplotView.js +0 -1
  56. package/esm/DotplotView/components/DotplotWarnings.js +0 -1
  57. package/esm/DotplotView/components/ExportSvgDialog.js +0 -1
  58. package/esm/DotplotView/components/Grid.js +0 -1
  59. package/esm/DotplotView/components/Header.js +0 -1
  60. package/esm/DotplotView/components/ImportCustomTrack.js +0 -1
  61. package/esm/DotplotView/components/ImportForm.js +0 -1
  62. package/esm/DotplotView/components/ImportSyntenyTrackSelector.js +0 -1
  63. package/esm/DotplotView/components/PanButtons.js +0 -1
  64. package/esm/DotplotView/components/WarningDialog.js +0 -1
  65. package/esm/DotplotView/components/util.js +0 -1
  66. package/esm/DotplotView/index.js +0 -1
  67. package/esm/DotplotView/model.js +0 -1
  68. package/esm/DotplotView/svgcomponents/SVGBackground.js +0 -1
  69. package/esm/DotplotView/svgcomponents/SVGDotplotView.js +0 -1
  70. package/esm/LaunchDotplotView.js +0 -1
  71. package/esm/ServerSideRenderedBlockContent.js +0 -1
  72. package/esm/ServerSideSyntenyRendering.js +0 -1
  73. package/esm/index.js +0 -1
  74. package/esm/util.js +0 -1
  75. package/package.json +3 -4
  76. package/dist/ComparativeRenderer/index.js.map +0 -1
  77. package/dist/DotplotDisplay/components/DotplotDisplay.js.map +0 -1
  78. package/dist/DotplotDisplay/index.js.map +0 -1
  79. package/dist/DotplotDisplay/renderDotplotBlock.js.map +0 -1
  80. package/dist/DotplotDisplay/stateModelFactory.js.map +0 -1
  81. package/dist/DotplotReadVsRef/DotplotReadVsRef.js.map +0 -1
  82. package/dist/DotplotReadVsRef/index.js.map +0 -1
  83. package/dist/DotplotRenderer/ComparativeRenderRpc.js.map +0 -1
  84. package/dist/DotplotRenderer/DotplotRenderer.js.map +0 -1
  85. package/dist/DotplotRenderer/components/DotplotRendering.js.map +0 -1
  86. package/dist/DotplotRenderer/configSchema.js.map +0 -1
  87. package/dist/DotplotRenderer/index.js.map +0 -1
  88. package/dist/DotplotView/1dview.js.map +0 -1
  89. package/dist/DotplotView/blockTypes.js.map +0 -1
  90. package/dist/DotplotView/components/Axes.js.map +0 -1
  91. package/dist/DotplotView/components/CursorIcon.js.map +0 -1
  92. package/dist/DotplotView/components/DotplotTooltip.js.map +0 -1
  93. package/dist/DotplotView/components/DotplotView.js.map +0 -1
  94. package/dist/DotplotView/components/DotplotWarnings.js.map +0 -1
  95. package/dist/DotplotView/components/ExportSvgDialog.js.map +0 -1
  96. package/dist/DotplotView/components/Grid.js.map +0 -1
  97. package/dist/DotplotView/components/Header.js.map +0 -1
  98. package/dist/DotplotView/components/ImportCustomTrack.js.map +0 -1
  99. package/dist/DotplotView/components/ImportForm.js.map +0 -1
  100. package/dist/DotplotView/components/ImportSyntenyTrackSelector.js.map +0 -1
  101. package/dist/DotplotView/components/PanButtons.js.map +0 -1
  102. package/dist/DotplotView/components/WarningDialog.js.map +0 -1
  103. package/dist/DotplotView/components/util.js.map +0 -1
  104. package/dist/DotplotView/index.js.map +0 -1
  105. package/dist/DotplotView/model.js.map +0 -1
  106. package/dist/DotplotView/svgcomponents/SVGBackground.js.map +0 -1
  107. package/dist/DotplotView/svgcomponents/SVGDotplotView.js.map +0 -1
  108. package/dist/LaunchDotplotView.js.map +0 -1
  109. package/dist/ServerSideRenderedBlockContent.js.map +0 -1
  110. package/dist/ServerSideSyntenyRendering.js.map +0 -1
  111. package/dist/index.js.map +0 -1
  112. package/dist/util.js.map +0 -1
  113. package/esm/ComparativeRenderer/index.js.map +0 -1
  114. package/esm/DotplotDisplay/components/DotplotDisplay.js.map +0 -1
  115. package/esm/DotplotDisplay/index.js.map +0 -1
  116. package/esm/DotplotDisplay/renderDotplotBlock.js.map +0 -1
  117. package/esm/DotplotDisplay/stateModelFactory.js.map +0 -1
  118. package/esm/DotplotReadVsRef/DotplotReadVsRef.js.map +0 -1
  119. package/esm/DotplotReadVsRef/index.js.map +0 -1
  120. package/esm/DotplotRenderer/ComparativeRenderRpc.js.map +0 -1
  121. package/esm/DotplotRenderer/DotplotRenderer.js.map +0 -1
  122. package/esm/DotplotRenderer/components/DotplotRendering.js.map +0 -1
  123. package/esm/DotplotRenderer/configSchema.js.map +0 -1
  124. package/esm/DotplotRenderer/index.js.map +0 -1
  125. package/esm/DotplotView/1dview.js.map +0 -1
  126. package/esm/DotplotView/blockTypes.js.map +0 -1
  127. package/esm/DotplotView/components/Axes.js.map +0 -1
  128. package/esm/DotplotView/components/CursorIcon.js.map +0 -1
  129. package/esm/DotplotView/components/DotplotTooltip.js.map +0 -1
  130. package/esm/DotplotView/components/DotplotView.js.map +0 -1
  131. package/esm/DotplotView/components/DotplotWarnings.js.map +0 -1
  132. package/esm/DotplotView/components/ExportSvgDialog.js.map +0 -1
  133. package/esm/DotplotView/components/Grid.js.map +0 -1
  134. package/esm/DotplotView/components/Header.js.map +0 -1
  135. package/esm/DotplotView/components/ImportCustomTrack.js.map +0 -1
  136. package/esm/DotplotView/components/ImportForm.js.map +0 -1
  137. package/esm/DotplotView/components/ImportSyntenyTrackSelector.js.map +0 -1
  138. package/esm/DotplotView/components/PanButtons.js.map +0 -1
  139. package/esm/DotplotView/components/WarningDialog.js.map +0 -1
  140. package/esm/DotplotView/components/util.js.map +0 -1
  141. package/esm/DotplotView/index.js.map +0 -1
  142. package/esm/DotplotView/model.js.map +0 -1
  143. package/esm/DotplotView/svgcomponents/SVGBackground.js.map +0 -1
  144. package/esm/DotplotView/svgcomponents/SVGDotplotView.js.map +0 -1
  145. package/esm/LaunchDotplotView.js.map +0 -1
  146. package/esm/ServerSideRenderedBlockContent.js.map +0 -1
  147. package/esm/ServerSideSyntenyRendering.js.map +0 -1
  148. package/esm/index.js.map +0 -1
  149. package/esm/util.js.map +0 -1
  150. package/src/ComparativeRenderer/index.ts +0 -87
  151. package/src/DotplotDisplay/components/DotplotDisplay.tsx +0 -34
  152. package/src/DotplotDisplay/index.ts +0 -48
  153. package/src/DotplotDisplay/renderDotplotBlock.ts +0 -60
  154. package/src/DotplotDisplay/stateModelFactory.tsx +0 -196
  155. package/src/DotplotReadVsRef/DotplotReadVsRef.ts +0 -115
  156. package/src/DotplotReadVsRef/index.ts +0 -50
  157. package/src/DotplotRenderer/ComparativeRenderRpc.ts +0 -87
  158. package/src/DotplotRenderer/DotplotRenderer.ts +0 -328
  159. package/src/DotplotRenderer/__image_snapshots__/linear-synteny-renderer-test-ts-test-rendering-a-simple-synteny-from-fake-data-1-snap.png +0 -0
  160. package/src/DotplotRenderer/components/DotplotRendering.tsx +0 -12
  161. package/src/DotplotRenderer/configSchema.ts +0 -92
  162. package/src/DotplotRenderer/index.ts +0 -16
  163. package/src/DotplotView/1dview.ts +0 -98
  164. package/src/DotplotView/blockTypes.ts +0 -140
  165. package/src/DotplotView/components/Axes.tsx +0 -246
  166. package/src/DotplotView/components/CursorIcon.tsx +0 -24
  167. package/src/DotplotView/components/DotplotTooltip.tsx +0 -163
  168. package/src/DotplotView/components/DotplotView.tsx +0 -348
  169. package/src/DotplotView/components/DotplotWarnings.tsx +0 -26
  170. package/src/DotplotView/components/ExportSvgDialog.tsx +0 -129
  171. package/src/DotplotView/components/Grid.tsx +0 -112
  172. package/src/DotplotView/components/Header.tsx +0 -182
  173. package/src/DotplotView/components/ImportCustomTrack.tsx +0 -262
  174. package/src/DotplotView/components/ImportForm.tsx +0 -209
  175. package/src/DotplotView/components/ImportSyntenyTrackSelector.tsx +0 -90
  176. package/src/DotplotView/components/PanButtons.tsx +0 -93
  177. package/src/DotplotView/components/WarningDialog.tsx +0 -74
  178. package/src/DotplotView/components/util.ts +0 -118
  179. package/src/DotplotView/index.ts +0 -16
  180. package/src/DotplotView/model.test.ts +0 -17
  181. package/src/DotplotView/model.ts +0 -719
  182. package/src/DotplotView/svgcomponents/SVGBackground.tsx +0 -21
  183. package/src/DotplotView/svgcomponents/SVGDotplotView.tsx +0 -68
  184. package/src/LaunchDotplotView.ts +0 -63
  185. package/src/ServerSideRenderedBlockContent.tsx +0 -86
  186. package/src/ServerSideSyntenyRendering.tsx +0 -54
  187. package/src/index.ts +0 -41
  188. package/src/util.ts +0 -14
@@ -1,348 +0,0 @@
1
- import React, { useState, useEffect, useRef } from 'react'
2
- import { LoadingEllipses, Menu, ResizeHandle } from '@jbrowse/core/ui'
3
- import { observer } from 'mobx-react'
4
- import { transaction } from 'mobx'
5
- import { makeStyles } from 'tss-react/mui'
6
- import normalizeWheel from 'normalize-wheel'
7
-
8
- // locals
9
- import { DotplotViewModel } from '../model'
10
- import ImportForm from './ImportForm'
11
- import Header from './Header'
12
- import Grid from './Grid'
13
- import { HorizontalAxis, VerticalAxis } from './Axes'
14
- import { TooltipWhereClicked, TooltipWhereMouseovered } from './DotplotTooltip'
15
-
16
- const blank = { left: 0, top: 0, width: 0, height: 0 }
17
-
18
- const useStyles = makeStyles()(theme => ({
19
- spacer: {
20
- gridColumn: '1/2',
21
- gridRow: '2/2',
22
- },
23
- root: {
24
- position: 'relative',
25
- marginBottom: theme.spacing(1),
26
- overflow: 'hidden',
27
- },
28
-
29
- container: {
30
- display: 'grid',
31
- padding: 5,
32
- position: 'relative',
33
- },
34
- overlay: {
35
- pointerEvents: 'none',
36
- overflow: 'hidden',
37
- display: 'flex',
38
- width: '100%',
39
- gridRow: '1/2',
40
- gridColumn: '2/2',
41
- zIndex: 100, // needs to be below controls
42
- '& path': {
43
- cursor: 'crosshair',
44
- fill: 'none',
45
- },
46
- },
47
-
48
- content: {
49
- position: 'relative',
50
- gridColumn: '2/2',
51
- gridRow: '1/2',
52
- },
53
-
54
- resizeHandle: {
55
- height: 4,
56
- background: '#ccc',
57
- boxSizing: 'border-box',
58
- borderTop: '1px solid #fafafa',
59
- },
60
- }))
61
-
62
- type Coord = [number, number] | undefined
63
- type Rect = { left: number; top: number }
64
-
65
- // produces offsetX/offsetY coordinates from a clientX and an element's
66
- // getBoundingClientRect
67
- function getOffset(coord: Coord, rect: Rect) {
68
- return coord && ([coord[0] - rect.left, coord[1] - rect.top] as Coord)
69
- }
70
-
71
- const RenderedComponent = observer(({ model }: { model: DotplotViewModel }) => {
72
- const { classes } = useStyles()
73
- return (
74
- <div className={classes.overlay}>
75
- {model.tracks.map(track => {
76
- const [display] = track.displays
77
- const { RenderingComponent } = display
78
- return RenderingComponent ? (
79
- <RenderingComponent
80
- key={track.configuration.trackId}
81
- model={display}
82
- />
83
- ) : null
84
- })}
85
- </div>
86
- )
87
- })
88
-
89
- const DotplotViewInternal = observer(function ({
90
- model,
91
- }: {
92
- model: DotplotViewModel
93
- }) {
94
- const { classes } = useStyles()
95
- const [mousecurrClient, setMouseCurrClient] = useState<Coord>()
96
- const [mousedownClient, setMouseDownClient] = useState<Coord>()
97
- const [mouseOvered, setMouseOvered] = useState(false)
98
- const [mouseupClient, setMouseUpClient] = useState<Coord>()
99
- const ref = useRef<HTMLDivElement>(null)
100
- const root = useRef<HTMLDivElement>(null)
101
- const distanceX = useRef(0)
102
- const distanceY = useRef(0)
103
- const scheduled = useRef(false)
104
- const [ctrlKeyWasUsed, setCtrlKeyWasUsed] = useState(false)
105
- const svg = ref.current?.getBoundingClientRect() || blank
106
- const rootRect = ref.current?.getBoundingClientRect() || blank
107
- const mousedown = getOffset(mousedownClient, svg)
108
- const mousecurr = getOffset(mousecurrClient, svg)
109
- const mouseup = getOffset(mouseupClient, svg)
110
- const mouserectClient = mouseupClient || mousecurrClient
111
- const mouserect = mouseup || mousecurr
112
- const xdistance = mousedown && mouserect ? mouserect[0] - mousedown[0] : 0
113
- const ydistance = mousedown && mouserect ? mouserect[1] - mousedown[1] : 0
114
- const { hview, vview, wheelMode, cursorMode } = model
115
-
116
- const validPan =
117
- (cursorMode === 'move' && !ctrlKeyWasUsed) ||
118
- (cursorMode === 'crosshair' && ctrlKeyWasUsed)
119
-
120
- const validSelect =
121
- (cursorMode === 'move' && ctrlKeyWasUsed) ||
122
- (cursorMode === 'crosshair' && !ctrlKeyWasUsed)
123
-
124
- // use non-React wheel handler to properly prevent body scrolling
125
- useEffect(() => {
126
- function onWheel(origEvent: WheelEvent) {
127
- const event = normalizeWheel(origEvent)
128
- origEvent.preventDefault()
129
-
130
- distanceX.current += event.pixelX
131
- distanceY.current -= event.pixelY
132
- if (!scheduled.current) {
133
- scheduled.current = true
134
-
135
- window.requestAnimationFrame(() => {
136
- transaction(() => {
137
- if (wheelMode === 'pan') {
138
- hview.scroll(distanceX.current / 3)
139
- vview.scroll(distanceY.current / 10)
140
- } else if (wheelMode === 'zoom') {
141
- if (
142
- Math.abs(distanceY.current) > Math.abs(distanceX.current) * 2 &&
143
- mousecurr
144
- ) {
145
- const val = distanceY.current < 0 ? 1.1 : 0.9
146
- hview.zoomTo(hview.bpPerPx * val, mousecurr[0])
147
- vview.zoomTo(
148
- vview.bpPerPx * val,
149
- rootRect.height - mousecurr[1],
150
- )
151
- }
152
- }
153
- })
154
- scheduled.current = false
155
- distanceX.current = 0
156
- distanceY.current = 0
157
- })
158
- }
159
- }
160
- if (ref.current) {
161
- const curr = ref.current
162
- curr.addEventListener('wheel', onWheel)
163
- return () => curr.removeEventListener('wheel', onWheel)
164
- }
165
- return () => {}
166
- }, [hview, vview, wheelMode, mousecurr, rootRect.height])
167
-
168
- useEffect(() => {
169
- function globalMouseMove(event: MouseEvent) {
170
- setMouseCurrClient([event.clientX, event.clientY])
171
-
172
- if (mousecurrClient && mousedownClient && validPan && !mouseupClient) {
173
- hview.scroll(-event.clientX + mousecurrClient[0])
174
- vview.scroll(event.clientY - mousecurrClient[1])
175
- }
176
- }
177
-
178
- window.addEventListener('mousemove', globalMouseMove)
179
- return () => window.removeEventListener('mousemove', globalMouseMove)
180
- }, [
181
- validPan,
182
- mousecurrClient,
183
- mousedownClient,
184
- cursorMode,
185
- ctrlKeyWasUsed,
186
- mouseupClient,
187
- hview,
188
- vview,
189
- ])
190
-
191
- // detect a mouseup after a mousedown was submitted, autoremoves mouseup
192
- // once that single mouseup is set
193
- useEffect(() => {
194
- function globalMouseUp(event: MouseEvent) {
195
- if (Math.abs(xdistance) > 3 && Math.abs(ydistance) > 3 && validSelect) {
196
- setMouseUpClient([event.clientX, event.clientY])
197
- } else {
198
- setMouseDownClient(undefined)
199
- }
200
- }
201
-
202
- if (mousedown && !mouseup) {
203
- window.addEventListener('mouseup', globalMouseUp, true)
204
- return () => window.removeEventListener('mouseup', globalMouseUp, true)
205
- }
206
- return () => {}
207
- }, [
208
- validSelect,
209
- mousedown,
210
- mousecurr,
211
- mouseup,
212
- xdistance,
213
- ydistance,
214
- ctrlKeyWasUsed,
215
- cursorMode,
216
- ])
217
-
218
- return (
219
- <div>
220
- <Header
221
- model={model}
222
- selection={
223
- !validSelect || !(mousedown && mouserect)
224
- ? undefined
225
- : {
226
- width: Math.abs(xdistance),
227
- height: Math.abs(ydistance),
228
- }
229
- }
230
- />
231
- <div
232
- ref={root}
233
- className={classes.root}
234
- onMouseLeave={() => setMouseOvered(false)}
235
- onMouseEnter={() => setMouseOvered(true)}
236
- >
237
- <div className={classes.container}>
238
- <VerticalAxis model={model} />
239
- <HorizontalAxis model={model} />
240
- <div ref={ref} className={classes.content}>
241
- {mouseOvered && validSelect ? (
242
- <TooltipWhereMouseovered
243
- model={model}
244
- mouserect={mouserect}
245
- mouserectClient={mouserectClient}
246
- xdistance={xdistance}
247
- ydistance={ydistance}
248
- />
249
- ) : null}
250
- {validSelect ? (
251
- <TooltipWhereClicked
252
- model={model}
253
- mousedown={mousedown}
254
- mousedownClient={mousedownClient}
255
- xdistance={xdistance}
256
- ydistance={ydistance}
257
- />
258
- ) : null}
259
- <div
260
- style={{ cursor: ctrlKeyWasUsed ? 'pointer' : cursorMode }}
261
- onMouseDown={event => {
262
- if (event.button === 0) {
263
- const { clientX, clientY } = event
264
- setMouseDownClient([clientX, clientY])
265
- setMouseCurrClient([clientX, clientY])
266
- setCtrlKeyWasUsed(event.ctrlKey)
267
- }
268
- }}
269
- >
270
- <Grid model={model}>
271
- {validSelect && mousedown && mouserect ? (
272
- <rect
273
- fill="rgba(255,0,0,0.3)"
274
- x={Math.min(mouserect[0], mousedown[0])}
275
- y={Math.min(mouserect[1], mousedown[1])}
276
- width={Math.abs(xdistance)}
277
- height={Math.abs(ydistance)}
278
- />
279
- ) : null}
280
- </Grid>
281
- </div>
282
- <div className={classes.spacer} />
283
- </div>
284
- <RenderedComponent model={model} />
285
- <Menu
286
- open={Boolean(mouseup)}
287
- onMenuItemClick={(_, callback) => {
288
- callback()
289
- setMouseUpClient(undefined)
290
- setMouseDownClient(undefined)
291
- }}
292
- onClose={() => {
293
- setMouseUpClient(undefined)
294
- setMouseDownClient(undefined)
295
- }}
296
- anchorReference="anchorPosition"
297
- anchorPosition={
298
- mouseupClient
299
- ? {
300
- top: mouseupClient[1] + 50,
301
- left: mouseupClient[0] + 50,
302
- }
303
- : undefined
304
- }
305
- style={{ zIndex: 10000 }}
306
- menuItems={[
307
- {
308
- label: 'Zoom in',
309
- onClick: () => {
310
- if (mousedown && mouseup) {
311
- model.zoomIn(mousedown, mouseup)
312
- }
313
- },
314
- },
315
- {
316
- label: 'Open linear synteny view',
317
- onClick: () => {
318
- if (mousedown && mouseup) {
319
- model.onDotplotView(mousedown, mouseup)
320
- }
321
- },
322
- },
323
- ]}
324
- />
325
- </div>
326
- <ResizeHandle
327
- onDrag={n => model.setHeight(model.height + n)}
328
- className={classes.resizeHandle}
329
- />
330
- </div>
331
- </div>
332
- )
333
- })
334
- const DotplotView = observer(({ model }: { model: DotplotViewModel }) => {
335
- const { initialized, loading, error } = model
336
-
337
- if ((!initialized && !loading) || error) {
338
- return <ImportForm model={model} />
339
- }
340
-
341
- if (loading) {
342
- return <LoadingEllipses variant="h6" />
343
- }
344
-
345
- return <DotplotViewInternal model={model} />
346
- })
347
-
348
- export default DotplotView
@@ -1,26 +0,0 @@
1
- import React, { lazy, useState } from 'react'
2
- import { Alert, Button } from '@mui/material'
3
- import { observer } from 'mobx-react'
4
-
5
- // locals
6
- import { DotplotViewModel } from '../model'
7
-
8
- // lazy components
9
- const WarningDialog = lazy(() => import('./WarningDialog'))
10
-
11
- export default observer(function ({ model }: { model: DotplotViewModel }) {
12
- const trackWarnings = model.tracks.filter(t => t.displays[0].warnings?.length)
13
- const [shown, setShown] = useState(false)
14
- return trackWarnings.length ? (
15
- <Alert severity="warning">
16
- Warnings during render{' '}
17
- <Button onClick={() => setShown(true)}>More info</Button>
18
- {shown ? (
19
- <WarningDialog
20
- trackWarnings={trackWarnings}
21
- handleClose={() => setShown(false)}
22
- />
23
- ) : null}
24
- </Alert>
25
- ) : null
26
- })
@@ -1,129 +0,0 @@
1
- import React, { useState } from 'react'
2
- import {
3
- Button,
4
- Checkbox,
5
- CircularProgress,
6
- DialogActions,
7
- DialogContent,
8
- FormControlLabel,
9
- MenuItem,
10
- TextField,
11
- Typography,
12
- } from '@mui/material'
13
- import { Dialog, ErrorMessage } from '@jbrowse/core/ui'
14
- import { ExportSvgOptions } from '../model'
15
- import { getSession, useLocalStorage } from '@jbrowse/core/util'
16
-
17
- function LoadingMessage() {
18
- return (
19
- <div>
20
- <CircularProgress size={20} style={{ marginRight: 20 }} />
21
- <Typography display="inline">Creating SVG</Typography>
22
- </div>
23
- )
24
- }
25
-
26
- function useSvgLocal<T>(key: string, val: T) {
27
- return useLocalStorage('svg-' + key, val)
28
- }
29
-
30
- export default function ExportSvgDlg({
31
- model,
32
- handleClose,
33
- }: {
34
- model: { exportSvg(opts: ExportSvgOptions): Promise<void> }
35
- handleClose: () => void
36
- }) {
37
- const session = getSession(model)
38
- const offscreenCanvas = typeof OffscreenCanvas !== 'undefined'
39
- const [rasterizeLayers, setRasterizeLayers] = useState(offscreenCanvas)
40
- const [loading, setLoading] = useState(false)
41
- const [error, setError] = useState<unknown>()
42
- const [filename, setFilename] = useSvgLocal('file', 'jbrowse.svg')
43
- const [themeName, setThemeName] = useSvgLocal(
44
- 'theme',
45
- session.themeName || 'default',
46
- )
47
- return (
48
- <Dialog open onClose={handleClose} title="Export SVG">
49
- <DialogContent>
50
- {error ? (
51
- <ErrorMessage error={error} />
52
- ) : loading ? (
53
- <LoadingMessage />
54
- ) : null}
55
- <TextField
56
- helperText="filename"
57
- value={filename}
58
- onChange={event => setFilename(event.target.value)}
59
- />
60
- <br />
61
- {session.allThemes ? (
62
- <TextField
63
- select
64
- label="Theme"
65
- value={themeName}
66
- onChange={event => setThemeName(event.target.value)}
67
- >
68
- {Object.entries(session.allThemes()).map(([key, val]) => (
69
- <MenuItem key={key} value={key}>
70
- {
71
- // @ts-expect-error
72
- val.name || '(Unknown name)'
73
- }
74
- </MenuItem>
75
- ))}
76
- </TextField>
77
- ) : null}
78
- {offscreenCanvas ? (
79
- <FormControlLabel
80
- control={
81
- <Checkbox
82
- checked={rasterizeLayers}
83
- onChange={() => setRasterizeLayers(val => !val)}
84
- />
85
- }
86
- label="Rasterize canvas based tracks? File may be much larger if this is turned off"
87
- />
88
- ) : (
89
- <Typography>
90
- Note: rasterizing layers not yet supported in this browser, so SVG
91
- size may be large
92
- </Typography>
93
- )}
94
- </DialogContent>
95
- <DialogActions>
96
- <Button
97
- variant="contained"
98
- color="secondary"
99
- onClick={() => handleClose()}
100
- >
101
- Cancel
102
- </Button>
103
- <Button
104
- variant="contained"
105
- color="primary"
106
- type="submit"
107
- onClick={async () => {
108
- setLoading(true)
109
- setError(undefined)
110
- try {
111
- await model.exportSvg({
112
- rasterizeLayers,
113
- filename,
114
- themeName,
115
- })
116
- handleClose()
117
- } catch (e) {
118
- console.error(e)
119
- setError(e)
120
- setLoading(false)
121
- }
122
- }}
123
- >
124
- Submit
125
- </Button>
126
- </DialogActions>
127
- </Dialog>
128
- )
129
- }
@@ -1,112 +0,0 @@
1
- import React from 'react'
2
- import { observer } from 'mobx-react'
3
- import { useTheme } from '@mui/material'
4
-
5
- // locals
6
- import { DotplotViewModel } from '../model'
7
-
8
- export const GridRaw = observer(function ({
9
- model,
10
- children,
11
- }: {
12
- model: DotplotViewModel
13
- children?: React.ReactNode
14
- }) {
15
- const { viewWidth, viewHeight, hview, vview } = model
16
- const hblocks = hview.dynamicBlocks.contentBlocks
17
- const vblocks = vview.dynamicBlocks.contentBlocks
18
- if (!hblocks.length || !vblocks.length) {
19
- return null
20
- }
21
- const htop = hview.displayedRegionsTotalPx - hview.offsetPx
22
- const vtop = vview.displayedRegionsTotalPx - vview.offsetPx
23
- const hbottom = hblocks[0].offsetPx - hview.offsetPx
24
- const vbottom = vblocks[0].offsetPx - vview.offsetPx
25
- const theme = useTheme()
26
- const stroke = theme.palette.divider
27
-
28
- // Uses math.max/min avoid making very large SVG rect offscreen element,
29
- // which can sometimes fail to draw
30
- const rx = Math.max(hbottom, 0)
31
- const ry = Math.max(viewHeight - vtop, 0)
32
- const w = Math.min(htop - hbottom, viewWidth)
33
- const h = Math.min(viewHeight - vbottom - ry, viewHeight)
34
-
35
- let lastx = Infinity
36
- let lasty = Infinity
37
- return (
38
- <>
39
- <rect
40
- x={rx}
41
- y={ry}
42
- width={w}
43
- height={h}
44
- fill={theme.palette.background.default}
45
- />
46
- <g>
47
- {hblocks.map(region => {
48
- const x = region.offsetPx - hview.offsetPx
49
- const render = Math.floor(x) !== Math.floor(lastx)
50
- if (render) {
51
- lastx = x
52
- }
53
- return render ? (
54
- <line
55
- key={JSON.stringify(region)}
56
- x1={x}
57
- y1={0}
58
- x2={x}
59
- y2={viewHeight}
60
- stroke={stroke}
61
- />
62
- ) : null
63
- })}
64
- {vblocks.map(region => {
65
- const y = viewHeight - (region.offsetPx - vview.offsetPx)
66
- const render = Math.floor(y) !== Math.floor(lasty)
67
- if (render) {
68
- lasty = y
69
- }
70
- return render ? (
71
- <line
72
- key={JSON.stringify(region)}
73
- x1={0}
74
- y1={y}
75
- x2={viewWidth}
76
- y2={y}
77
- stroke={stroke}
78
- />
79
- ) : null
80
- })}
81
- <line x1={htop} y1={0} x2={htop} y2={viewHeight} stroke={stroke} />
82
- <line
83
- x1={0}
84
- y1={viewHeight - vtop}
85
- x2={viewWidth}
86
- y2={viewHeight - vtop}
87
- stroke={stroke}
88
- />
89
- </g>
90
- {children}
91
- </>
92
- )
93
- })
94
-
95
- export default function Grid({
96
- model,
97
- children,
98
- }: {
99
- model: DotplotViewModel
100
- children?: React.ReactNode
101
- }) {
102
- const { viewWidth, viewHeight } = model
103
- return (
104
- <svg
105
- width={viewWidth}
106
- height={viewHeight}
107
- style={{ background: 'rgba(0,0,0,0.12)' }}
108
- >
109
- <GridRaw model={model}>{children}</GridRaw>
110
- </svg>
111
- )
112
- }