@jbrowse/plugin-dotplot-view 3.6.5 → 4.0.0

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 (210) hide show
  1. package/esm/ComparativeRenderer/index.d.ts +10 -10
  2. package/esm/ComparativeRenderer/index.js +4 -17
  3. package/esm/DiagonalizeDotplotRpc.d.ts +30 -0
  4. package/esm/DiagonalizeDotplotRpc.js +147 -0
  5. package/esm/DotplotDisplay/components/DotplotDisplay.d.ts +1 -1
  6. package/esm/DotplotDisplay/index.d.ts +3 -3
  7. package/esm/DotplotDisplay/index.js +4 -4
  8. package/esm/DotplotDisplay/renderDotplotBlock.d.ts +2 -1
  9. package/esm/DotplotDisplay/renderDotplotBlock.js +9 -4
  10. package/esm/DotplotDisplay/stateModelFactory.d.ts +148 -29
  11. package/esm/DotplotDisplay/stateModelFactory.js +17 -11
  12. package/esm/DotplotReadVsRef/DotplotReadVsRef.js +5 -6
  13. package/esm/DotplotReadVsRef/index.js +1 -1
  14. package/esm/DotplotRenderer/DotplotRenderer.d.ts +30 -48
  15. package/esm/DotplotRenderer/DotplotRenderer.js +55 -22
  16. package/esm/DotplotRenderer/clamp.d.ts +7 -0
  17. package/esm/DotplotRenderer/clamp.js +58 -0
  18. package/esm/DotplotRenderer/components/DotplotRendering.d.ts +1 -1
  19. package/esm/DotplotRenderer/components/DotplotRendering.js +1 -1
  20. package/esm/DotplotRenderer/configSchema.d.ts +3 -3
  21. package/esm/DotplotRenderer/configSchema.js +1 -1
  22. package/esm/DotplotRenderer/drawDotplot.d.ts +7 -6
  23. package/esm/DotplotRenderer/drawDotplot.js +95 -100
  24. package/esm/DotplotRenderer/index.js +4 -4
  25. package/esm/DotplotView/1dview.d.ts +25 -25
  26. package/esm/DotplotView/1dview.js +16 -4
  27. package/esm/DotplotView/components/Axes.d.ts +1 -1
  28. package/esm/DotplotView/components/Axes.js +31 -41
  29. package/esm/DotplotView/components/ColorBySelector.d.ts +5 -0
  30. package/esm/DotplotView/components/ColorBySelector.js +73 -0
  31. package/esm/DotplotView/components/DiagonalizationProgressDialog.d.ts +6 -0
  32. package/esm/DotplotView/components/DiagonalizationProgressDialog.js +123 -0
  33. package/esm/DotplotView/components/DotplotControls.d.ts +1 -1
  34. package/esm/DotplotView/components/DotplotControls.js +53 -15
  35. package/esm/DotplotView/components/DotplotGrid.d.ts +6 -0
  36. package/esm/DotplotView/components/{Grid.js → DotplotGrid.js} +19 -20
  37. package/esm/DotplotView/components/DotplotGridWrapper.d.ts +6 -0
  38. package/esm/DotplotView/components/DotplotGridWrapper.js +8 -0
  39. package/esm/DotplotView/components/DotplotTooltipClick.d.ts +2 -2
  40. package/esm/DotplotView/components/DotplotTooltipClick.js +4 -4
  41. package/esm/DotplotView/components/DotplotTooltipMouseover.d.ts +1 -1
  42. package/esm/DotplotView/components/DotplotTooltipMouseover.js +2 -2
  43. package/esm/DotplotView/components/DotplotTooltips.d.ts +15 -0
  44. package/esm/DotplotView/components/DotplotTooltips.js +7 -0
  45. package/esm/DotplotView/components/DotplotView.d.ts +2 -2
  46. package/esm/DotplotView/components/DotplotView.js +31 -171
  47. package/esm/DotplotView/components/DotplotWarnings.d.ts +1 -1
  48. package/esm/DotplotView/components/DotplotWarnings.js +7 -7
  49. package/esm/DotplotView/components/ExportSvgDialog.d.ts +1 -1
  50. package/esm/DotplotView/components/Header.d.ts +1 -1
  51. package/esm/DotplotView/components/Header.js +5 -5
  52. package/esm/DotplotView/components/ImportForm/ImportSyntenyOpenCustomTrack.d.ts +1 -1
  53. package/esm/DotplotView/components/ImportForm/ImportSyntenyOpenCustomTrack.js +6 -5
  54. package/esm/DotplotView/components/ImportForm/ImportSyntenyTrackSelector.d.ts +1 -1
  55. package/esm/DotplotView/components/ImportForm/ImportSyntenyTrackSelector.js +2 -3
  56. package/esm/DotplotView/components/ImportForm/TrackSelector.d.ts +10 -1
  57. package/esm/DotplotView/components/ImportForm/TrackSelector.js +8 -4
  58. package/esm/DotplotView/components/ImportForm/index.d.ts +1 -1
  59. package/esm/DotplotView/components/ImportForm/index.js +4 -10
  60. package/esm/DotplotView/components/ImportForm/selectors/AnchorsFileSelector.d.ts +1 -1
  61. package/esm/DotplotView/components/ImportForm/selectors/AnchorsFileSelector.js +2 -2
  62. package/esm/DotplotView/components/ImportForm/selectors/PifGzSelector.d.ts +1 -1
  63. package/esm/DotplotView/components/ImportForm/selectors/PifGzSelector.js +2 -2
  64. package/esm/DotplotView/components/ImportForm/selectors/SwapAssemblies.js +3 -3
  65. package/esm/DotplotView/components/ImportForm/selectors/SyntenyFileSelector.d.ts +1 -1
  66. package/esm/DotplotView/components/ImportForm/selectors/SyntenyFileSelector.js +3 -3
  67. package/esm/DotplotView/components/ImportForm/selectors/index.d.ts +3 -3
  68. package/esm/DotplotView/components/ImportForm/selectors/index.js +3 -3
  69. package/esm/DotplotView/components/MinLengthSlider.d.ts +5 -0
  70. package/esm/DotplotView/components/MinLengthSlider.js +39 -0
  71. package/esm/DotplotView/components/MouseInteractionLayer.d.ts +17 -0
  72. package/esm/DotplotView/components/MouseInteractionLayer.js +14 -0
  73. package/esm/DotplotView/components/OpacitySlider.d.ts +5 -0
  74. package/esm/DotplotView/components/OpacitySlider.js +37 -0
  75. package/esm/DotplotView/components/PanButtons.d.ts +1 -1
  76. package/esm/DotplotView/components/PanButtons.js +1 -1
  77. package/esm/DotplotView/components/SelectionContextMenu.d.ts +13 -0
  78. package/esm/DotplotView/components/SelectionContextMenu.js +39 -0
  79. package/esm/DotplotView/components/SliderTooltip.d.ts +2 -0
  80. package/esm/DotplotView/components/SliderTooltip.js +6 -0
  81. package/esm/DotplotView/components/WarningDialog.js +1 -1
  82. package/esm/DotplotView/components/hooks/useCtrlKeyTracking.d.ts +1 -0
  83. package/esm/DotplotView/components/hooks/useCtrlKeyTracking.js +21 -0
  84. package/esm/DotplotView/components/hooks/useCursorMode.d.ts +7 -0
  85. package/esm/DotplotView/components/hooks/useCursorMode.js +16 -0
  86. package/esm/DotplotView/components/hooks/useMouseCoordinates.d.ts +29 -0
  87. package/esm/DotplotView/components/hooks/useMouseCoordinates.js +49 -0
  88. package/esm/DotplotView/components/hooks/useMouseMoveHandler.d.ts +6 -0
  89. package/esm/DotplotView/components/hooks/useMouseMoveHandler.js +24 -0
  90. package/esm/DotplotView/components/hooks/useMouseUpHandler.d.ts +3 -0
  91. package/esm/DotplotView/components/hooks/useMouseUpHandler.js +28 -0
  92. package/esm/DotplotView/components/hooks/useWheelHandler.d.ts +8 -0
  93. package/esm/DotplotView/components/hooks/useWheelHandler.js +44 -0
  94. package/esm/DotplotView/components/util.d.ts +1 -1
  95. package/esm/DotplotView/components/util.js +18 -8
  96. package/esm/DotplotView/index.js +2 -2
  97. package/esm/DotplotView/model.d.ts +213 -90
  98. package/esm/DotplotView/model.js +147 -93
  99. package/esm/DotplotView/svgcomponents/SVGDotplotView.d.ts +1 -1
  100. package/esm/DotplotView/svgcomponents/SVGDotplotView.js +5 -6
  101. package/esm/DotplotView/types.d.ts +7 -1
  102. package/esm/LaunchDotplotView.js +6 -36
  103. package/esm/ServerSideRenderedBlockContent.js +6 -27
  104. package/esm/ServerSideSyntenyRendering.d.ts +1 -1
  105. package/esm/ServerSideSyntenyRendering.js +1 -1
  106. package/esm/index.d.ts +1 -0
  107. package/esm/index.js +9 -10
  108. package/esm/util.d.ts +1 -1
  109. package/package.json +28 -35
  110. package/dist/ComparativeRenderer/index.d.ts +0 -22
  111. package/dist/ComparativeRenderer/index.js +0 -53
  112. package/dist/DotplotDisplay/components/DotplotDisplay.d.ts +0 -6
  113. package/dist/DotplotDisplay/components/DotplotDisplay.js +0 -18
  114. package/dist/DotplotDisplay/index.d.ts +0 -5
  115. package/dist/DotplotDisplay/index.js +0 -36
  116. package/dist/DotplotDisplay/renderDotplotBlock.d.ts +0 -11
  117. package/dist/DotplotDisplay/renderDotplotBlock.js +0 -49
  118. package/dist/DotplotDisplay/stateModelFactory.d.ts +0 -102
  119. package/dist/DotplotDisplay/stateModelFactory.js +0 -119
  120. package/dist/DotplotReadVsRef/DotplotReadVsRef.d.ts +0 -3
  121. package/dist/DotplotReadVsRef/DotplotReadVsRef.js +0 -100
  122. package/dist/DotplotReadVsRef/index.d.ts +0 -2
  123. package/dist/DotplotReadVsRef/index.js +0 -41
  124. package/dist/DotplotRenderer/ComparativeRenderRpc.d.ts +0 -22
  125. package/dist/DotplotRenderer/ComparativeRenderRpc.js +0 -53
  126. package/dist/DotplotRenderer/DotplotRenderer.d.ts +0 -74
  127. package/dist/DotplotRenderer/DotplotRenderer.js +0 -102
  128. package/dist/DotplotRenderer/components/DotplotRendering.d.ts +0 -3
  129. package/dist/DotplotRenderer/components/DotplotRendering.js +0 -9
  130. package/dist/DotplotRenderer/configSchema.d.ts +0 -40
  131. package/dist/DotplotRenderer/configSchema.js +0 -57
  132. package/dist/DotplotRenderer/drawDotplot.d.ts +0 -21
  133. package/dist/DotplotRenderer/drawDotplot.js +0 -213
  134. package/dist/DotplotRenderer/index.d.ts +0 -2
  135. package/dist/DotplotRenderer/index.js +0 -17
  136. package/dist/DotplotView/1dview.d.ts +0 -199
  137. package/dist/DotplotView/1dview.js +0 -63
  138. package/dist/DotplotView/components/Axes.d.ts +0 -13
  139. package/dist/DotplotView/components/Axes.js +0 -107
  140. package/dist/DotplotView/components/CursorIcon.d.ts +0 -3
  141. package/dist/DotplotView/components/CursorIcon.js +0 -15
  142. package/dist/DotplotView/components/DotplotControls.d.ts +0 -5
  143. package/dist/DotplotView/components/DotplotControls.js +0 -115
  144. package/dist/DotplotView/components/DotplotTooltipClick.d.ts +0 -10
  145. package/dist/DotplotView/components/DotplotTooltipClick.js +0 -17
  146. package/dist/DotplotView/components/DotplotTooltipMouseover.d.ts +0 -9
  147. package/dist/DotplotView/components/DotplotTooltipMouseover.js +0 -16
  148. package/dist/DotplotView/components/DotplotView.d.ts +0 -5
  149. package/dist/DotplotView/components/DotplotView.js +0 -275
  150. package/dist/DotplotView/components/DotplotWarnings.d.ts +0 -5
  151. package/dist/DotplotView/components/DotplotWarnings.js +0 -53
  152. package/dist/DotplotView/components/ExportSvgDialog.d.ts +0 -7
  153. package/dist/DotplotView/components/ExportSvgDialog.js +0 -53
  154. package/dist/DotplotView/components/Grid.d.ts +0 -9
  155. package/dist/DotplotView/components/Grid.js +0 -47
  156. package/dist/DotplotView/components/Header.d.ts +0 -9
  157. package/dist/DotplotView/components/Header.js +0 -33
  158. package/dist/DotplotView/components/ImportForm/ImportSyntenyOpenCustomTrack.d.ts +0 -7
  159. package/dist/DotplotView/components/ImportForm/ImportSyntenyOpenCustomTrack.js +0 -78
  160. package/dist/DotplotView/components/ImportForm/ImportSyntenyTrackSelector.d.ts +0 -7
  161. package/dist/DotplotView/components/ImportForm/ImportSyntenyTrackSelector.js +0 -42
  162. package/dist/DotplotView/components/ImportForm/TrackSelector.d.ts +0 -7
  163. package/dist/DotplotView/components/ImportForm/TrackSelector.js +0 -23
  164. package/dist/DotplotView/components/ImportForm/getAdapter.d.ts +0 -117
  165. package/dist/DotplotView/components/ImportForm/getAdapter.js +0 -68
  166. package/dist/DotplotView/components/ImportForm/index.d.ts +0 -5
  167. package/dist/DotplotView/components/ImportForm/index.js +0 -76
  168. package/dist/DotplotView/components/ImportForm/selectors/AnchorsFileSelector.d.ts +0 -3
  169. package/dist/DotplotView/components/ImportForm/selectors/AnchorsFileSelector.js +0 -23
  170. package/dist/DotplotView/components/ImportForm/selectors/PifGzSelector.d.ts +0 -3
  171. package/dist/DotplotView/components/ImportForm/selectors/PifGzSelector.js +0 -13
  172. package/dist/DotplotView/components/ImportForm/selectors/SelectorTypes.d.ts +0 -23
  173. package/dist/DotplotView/components/ImportForm/selectors/SelectorTypes.js +0 -10
  174. package/dist/DotplotView/components/ImportForm/selectors/SwapAssemblies.d.ts +0 -13
  175. package/dist/DotplotView/components/ImportForm/selectors/SwapAssemblies.js +0 -32
  176. package/dist/DotplotView/components/ImportForm/selectors/SyntenyFileSelector.d.ts +0 -3
  177. package/dist/DotplotView/components/ImportForm/selectors/SyntenyFileSelector.js +0 -24
  178. package/dist/DotplotView/components/ImportForm/selectors/index.d.ts +0 -3
  179. package/dist/DotplotView/components/ImportForm/selectors/index.js +0 -12
  180. package/dist/DotplotView/components/ImportForm/util.d.ts +0 -10
  181. package/dist/DotplotView/components/ImportForm/util.js +0 -24
  182. package/dist/DotplotView/components/PanButtons.d.ts +0 -5
  183. package/dist/DotplotView/components/PanButtons.js +0 -47
  184. package/dist/DotplotView/components/WarningDialog.d.ts +0 -16
  185. package/dist/DotplotView/components/WarningDialog.js +0 -39
  186. package/dist/DotplotView/components/util.d.ts +0 -14
  187. package/dist/DotplotView/components/util.js +0 -82
  188. package/dist/DotplotView/index.d.ts +0 -2
  189. package/dist/DotplotView/index.js +0 -52
  190. package/dist/DotplotView/model.d.ts +0 -435
  191. package/dist/DotplotView/model.js +0 -487
  192. package/dist/DotplotView/svgcomponents/SVGBackground.d.ts +0 -4
  193. package/dist/DotplotView/svgcomponents/SVGBackground.js +0 -10
  194. package/dist/DotplotView/svgcomponents/SVGDotplotView.d.ts +0 -2
  195. package/dist/DotplotView/svgcomponents/SVGDotplotView.js +0 -30
  196. package/dist/DotplotView/types.d.ts +0 -12
  197. package/dist/DotplotView/types.js +0 -2
  198. package/dist/LaunchDotplotView.d.ts +0 -2
  199. package/dist/LaunchDotplotView.js +0 -43
  200. package/dist/ServerSideRenderedBlockContent.d.ts +0 -12
  201. package/dist/ServerSideRenderedBlockContent.js +0 -65
  202. package/dist/ServerSideSyntenyRendering.d.ts +0 -13
  203. package/dist/ServerSideSyntenyRendering.js +0 -23
  204. package/dist/index.d.ts +0 -7
  205. package/dist/index.js +0 -40
  206. package/dist/util.d.ts +0 -9
  207. package/dist/util.js +0 -7
  208. package/esm/DotplotRenderer/ComparativeRenderRpc.d.ts +0 -22
  209. package/esm/DotplotRenderer/ComparativeRenderRpc.js +0 -47
  210. package/esm/DotplotView/components/Grid.d.ts +0 -9
@@ -0,0 +1,39 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useState } from 'react';
3
+ import { toLocale } from '@jbrowse/core/util';
4
+ import { makeStyles } from '@jbrowse/core/util/tss-react';
5
+ import { Slider, Typography } from '@mui/material';
6
+ import { observer } from 'mobx-react';
7
+ import SliderTooltip from "./SliderTooltip.js";
8
+ const useStyles = makeStyles()({
9
+ container: {
10
+ display: 'flex',
11
+ alignItems: 'center',
12
+ marginLeft: 16,
13
+ marginRight: 16,
14
+ minWidth: 150,
15
+ },
16
+ });
17
+ const MinLengthSlider = observer(function MinLengthSlider({ model, }) {
18
+ const { classes } = useStyles();
19
+ const firstDisplay = model.tracks[0]?.displays[0];
20
+ const minAlignmentLength = firstDisplay?.minAlignmentLength ?? 0;
21
+ const [minLengthValue, setMinLengthValue] = useState(Math.log2(Math.max(1, minAlignmentLength)) * 100);
22
+ useEffect(() => {
23
+ setMinLengthValue(Math.log2(Math.max(1, minAlignmentLength)) * 100);
24
+ }, [minAlignmentLength]);
25
+ return (_jsxs("span", { className: classes.container, children: [_jsx(Typography, { variant: "body2", style: { marginRight: 8 }, children: "Min length:" }), _jsx(Slider, { value: minLengthValue, onChange: (_, val) => {
26
+ setMinLengthValue(val);
27
+ }, onChangeCommitted: () => {
28
+ const newMinLength = Math.round(2 ** (minLengthValue / 100));
29
+ for (const track of model.tracks) {
30
+ for (const display of track.displays) {
31
+ ;
32
+ display.setMinAlignmentLength(newMinLength);
33
+ }
34
+ }
35
+ }, min: 0, max: Math.log2(1000000) * 100, valueLabelDisplay: "auto", valueLabelFormat: newValue => toLocale(Math.round(2 ** (newValue / 100))), size: "small", style: { minWidth: 100 }, slots: {
36
+ valueLabel: SliderTooltip,
37
+ } })] }));
38
+ });
39
+ export default MinLengthSlider;
@@ -0,0 +1,17 @@
1
+ import type { DotplotViewModel } from '../model.ts';
2
+ type Coord = [number, number] | undefined;
3
+ interface MouseInteractionLayerProps {
4
+ model: DotplotViewModel;
5
+ ctrlKeyDown: boolean;
6
+ cursorMode: string;
7
+ validSelect: boolean;
8
+ mousedown: Coord;
9
+ mouserect: Coord;
10
+ xdistance: number;
11
+ ydistance: number;
12
+ setMouseDownClient: (coord: Coord) => void;
13
+ setMouseCurrClient: (coord: Coord) => void;
14
+ setCtrlKeyWasUsed: (wasUsed: boolean) => void;
15
+ }
16
+ declare const MouseInteractionLayer: ({ model, ctrlKeyDown, cursorMode, validSelect, mousedown, mouserect, xdistance, ydistance, setMouseDownClient, setMouseCurrClient, setCtrlKeyWasUsed, }: MouseInteractionLayerProps) => import("react/jsx-runtime").JSX.Element;
17
+ export default MouseInteractionLayer;
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { observer } from 'mobx-react';
3
+ import DotplotGridWrapper from "./DotplotGridWrapper.js";
4
+ const MouseInteractionLayer = observer(function MouseInteractionLayer({ model, ctrlKeyDown, cursorMode, validSelect, mousedown, mouserect, xdistance, ydistance, setMouseDownClient, setMouseCurrClient, setCtrlKeyWasUsed, }) {
5
+ return (_jsx("div", { style: { cursor: ctrlKeyDown ? 'pointer' : cursorMode }, onMouseDown: event => {
6
+ if (event.button === 0) {
7
+ const { clientX, clientY } = event;
8
+ setMouseDownClient([clientX, clientY]);
9
+ setMouseCurrClient([clientX, clientY]);
10
+ setCtrlKeyWasUsed(ctrlKeyDown);
11
+ }
12
+ }, children: _jsx(DotplotGridWrapper, { model: model, children: validSelect && mousedown && mouserect ? (_jsx("rect", { fill: "rgba(255,0,0,0.3)", x: Math.min(mouserect[0], mousedown[0]), y: Math.min(mouserect[1], mousedown[1]), width: Math.abs(xdistance), height: Math.abs(ydistance) })) : null }) }));
13
+ });
14
+ export default MouseInteractionLayer;
@@ -0,0 +1,5 @@
1
+ import type { DotplotViewModel } from '../model.ts';
2
+ declare const OpacitySlider: ({ model, }: {
3
+ model: DotplotViewModel;
4
+ }) => import("react/jsx-runtime").JSX.Element;
5
+ export default OpacitySlider;
@@ -0,0 +1,37 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { makeStyles } from '@jbrowse/core/util/tss-react';
3
+ import { Slider, Typography } from '@mui/material';
4
+ import { observer } from 'mobx-react';
5
+ import SliderTooltip from "./SliderTooltip.js";
6
+ const useStyles = makeStyles()({
7
+ container: {
8
+ display: 'flex',
9
+ alignItems: 'center',
10
+ marginLeft: 16,
11
+ marginRight: 16,
12
+ minWidth: 150,
13
+ },
14
+ });
15
+ const OpacitySlider = observer(function OpacitySlider({ model, }) {
16
+ const { classes } = useStyles();
17
+ const firstDisplay = model.tracks[0]?.displays[0];
18
+ const alpha = firstDisplay?.alpha ?? 1;
19
+ const exponent = 3;
20
+ const alphaToSlider = (a) => Math.pow(a, 1 / exponent);
21
+ const sliderToAlpha = (s) => Math.pow(s, exponent);
22
+ const sliderValue = alphaToSlider(alpha);
23
+ const handleAlphaChange = (_event, value) => {
24
+ const sliderVal = typeof value === 'number' ? value : value[0];
25
+ const newAlpha = sliderToAlpha(sliderVal);
26
+ for (const track of model.tracks) {
27
+ for (const display of track.displays) {
28
+ ;
29
+ display.setAlpha(newAlpha);
30
+ }
31
+ }
32
+ };
33
+ return (_jsxs("span", { className: classes.container, children: [_jsx(Typography, { variant: "body2", style: { marginRight: 8 }, children: "Opacity:" }), _jsx(Slider, { value: sliderValue, onChange: handleAlphaChange, min: 0, max: 1, step: 0.01, valueLabelDisplay: "auto", size: "small", style: { minWidth: 100 }, slots: {
34
+ valueLabel: SliderTooltip,
35
+ }, valueLabelFormat: value => sliderToAlpha(value).toFixed(3) })] }));
36
+ });
37
+ export default OpacitySlider;
@@ -1,4 +1,4 @@
1
- import type { DotplotViewModel } from '../model';
1
+ import type { DotplotViewModel } from '../model.ts';
2
2
  declare const PanButtons: ({ model, }: {
3
3
  model: DotplotViewModel;
4
4
  }) => import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { makeStyles } from '@jbrowse/core/util/tss-react';
2
3
  import ArrowDropDown from '@mui/icons-material/ArrowDropDown';
3
4
  import ArrowDropUp from '@mui/icons-material/ArrowDropUp';
4
5
  import ArrowLeft from '@mui/icons-material/ArrowLeft';
@@ -7,7 +8,6 @@ import ZoomIn from '@mui/icons-material/ZoomIn';
7
8
  import ZoomOut from '@mui/icons-material/ZoomOut';
8
9
  import { IconButton, Paper } from '@mui/material';
9
10
  import { observer } from 'mobx-react';
10
- import { makeStyles } from 'tss-react/mui';
11
11
  const useStyles = makeStyles()({
12
12
  dpad: {
13
13
  display: 'grid',
@@ -0,0 +1,13 @@
1
+ import type { DotplotViewModel } from '../model.ts';
2
+ type Coord = [number, number] | undefined;
3
+ interface SelectionContextMenuProps {
4
+ model: DotplotViewModel;
5
+ mouseup: Coord;
6
+ mouseupClient: Coord;
7
+ mousedown: Coord;
8
+ setMouseUpClient: (coord: Coord) => void;
9
+ setMouseDownClient: (coord: Coord) => void;
10
+ setMouseOvered: (isOvered: boolean) => void;
11
+ }
12
+ export default function SelectionContextMenu({ model, mouseup, mouseupClient, mousedown, setMouseUpClient, setMouseDownClient, setMouseOvered, }: SelectionContextMenuProps): import("react/jsx-runtime").JSX.Element;
13
+ export {};
@@ -0,0 +1,39 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Menu } from '@jbrowse/core/ui';
3
+ function getSelectionMenuItems(model, mousedown, mouseup, setMouseOvered) {
4
+ return [
5
+ {
6
+ label: 'Zoom in',
7
+ onClick: () => {
8
+ if (mousedown && mouseup) {
9
+ model.zoomInToMouseCoords(mousedown, mouseup);
10
+ }
11
+ setMouseOvered(false);
12
+ },
13
+ },
14
+ {
15
+ label: 'Open linear synteny view',
16
+ onClick: () => {
17
+ if (mousedown && mouseup) {
18
+ model.onDotplotView(mousedown, mouseup);
19
+ }
20
+ setMouseOvered(false);
21
+ },
22
+ },
23
+ ];
24
+ }
25
+ export default function SelectionContextMenu({ model, mouseup, mouseupClient, mousedown, setMouseUpClient, setMouseDownClient, setMouseOvered, }) {
26
+ return (_jsx(Menu, { open: Boolean(mouseup), onMenuItemClick: (_, callback) => {
27
+ callback();
28
+ setMouseUpClient(undefined);
29
+ setMouseDownClient(undefined);
30
+ }, onClose: () => {
31
+ setMouseUpClient(undefined);
32
+ setMouseDownClient(undefined);
33
+ }, anchorReference: "anchorPosition", anchorPosition: mouseupClient
34
+ ? {
35
+ top: mouseupClient[1] + 50,
36
+ left: mouseupClient[0] + 50,
37
+ }
38
+ : undefined, style: { zIndex: 11000 }, menuItems: getSelectionMenuItems(model, mousedown, mouseup, setMouseOvered) }));
39
+ }
@@ -0,0 +1,2 @@
1
+ import type { SliderValueLabelProps } from '@mui/material';
2
+ export default function SliderTooltip(props: SliderValueLabelProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Tooltip } from '@mui/material';
3
+ export default function SliderTooltip(props) {
4
+ const { children, open, value } = props;
5
+ return (_jsx(Tooltip, { open: open, enterTouchDelay: 0, placement: "top", title: value, arrow: true, children: children }));
6
+ }
@@ -2,10 +2,10 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { getConf } from '@jbrowse/core/configuration';
3
3
  import { Dialog } from '@jbrowse/core/ui';
4
4
  import { measureGridWidth } from '@jbrowse/core/util';
5
+ import { makeStyles } from '@jbrowse/core/util/tss-react';
5
6
  import { DialogContent, DialogContentText } from '@mui/material';
6
7
  import { DataGrid } from '@mui/x-data-grid';
7
8
  import { observer } from 'mobx-react';
8
- import { makeStyles } from 'tss-react/mui';
9
9
  const useStyles = makeStyles()({
10
10
  content: {
11
11
  minWidth: 600,
@@ -0,0 +1 @@
1
+ export declare function useCtrlKeyTracking(setCtrlKeyDown: (isDown: boolean) => void): void;
@@ -0,0 +1,21 @@
1
+ import { useEffect } from 'react';
2
+ export function useCtrlKeyTracking(setCtrlKeyDown) {
3
+ useEffect(() => {
4
+ function globalCtrlKeyDown(event) {
5
+ if (event.metaKey || event.ctrlKey) {
6
+ setCtrlKeyDown(true);
7
+ }
8
+ }
9
+ function globalCtrlKeyUp(event) {
10
+ if (!event.metaKey && !event.ctrlKey) {
11
+ setCtrlKeyDown(false);
12
+ }
13
+ }
14
+ window.addEventListener('keydown', globalCtrlKeyDown);
15
+ window.addEventListener('keyup', globalCtrlKeyUp);
16
+ return () => {
17
+ window.removeEventListener('keydown', globalCtrlKeyDown);
18
+ window.removeEventListener('keyup', globalCtrlKeyUp);
19
+ };
20
+ }, [setCtrlKeyDown]);
21
+ }
@@ -0,0 +1,7 @@
1
+ export declare function useCursorMode(cursorMode: string): {
2
+ ctrlKeyDown: boolean;
3
+ validPan: boolean;
4
+ validSelect: boolean;
5
+ setCtrlKeyWasUsed: import("react").Dispatch<import("react").SetStateAction<boolean>>;
6
+ setCtrlKeyDown: import("react").Dispatch<import("react").SetStateAction<boolean>>;
7
+ };
@@ -0,0 +1,16 @@
1
+ import { useState } from 'react';
2
+ export function useCursorMode(cursorMode) {
3
+ const [ctrlKeyWasUsed, setCtrlKeyWasUsed] = useState(false);
4
+ const [ctrlKeyDown, setCtrlKeyDown] = useState(false);
5
+ const validPan = (cursorMode === 'move' && !ctrlKeyWasUsed) ||
6
+ (cursorMode === 'crosshair' && ctrlKeyWasUsed);
7
+ const validSelect = (cursorMode === 'move' && ctrlKeyWasUsed) ||
8
+ (cursorMode === 'crosshair' && !ctrlKeyWasUsed);
9
+ return {
10
+ ctrlKeyDown,
11
+ validPan,
12
+ validSelect,
13
+ setCtrlKeyWasUsed,
14
+ setCtrlKeyDown,
15
+ };
16
+ }
@@ -0,0 +1,29 @@
1
+ type Coord = [number, number] | undefined;
2
+ interface Rect {
3
+ left: number;
4
+ top: number;
5
+ width: number;
6
+ height: number;
7
+ }
8
+ export declare function useMouseCoordinates(): {
9
+ mousecurrClient: Coord;
10
+ mousedownClient: Coord;
11
+ mouseupClient: Coord;
12
+ mouseOvered: boolean;
13
+ setMouseCurrClient: import("react").Dispatch<import("react").SetStateAction<Coord>>;
14
+ setMouseDownClient: import("react").Dispatch<import("react").SetStateAction<Coord>>;
15
+ setMouseUpClient: import("react").Dispatch<import("react").SetStateAction<Coord>>;
16
+ setMouseOvered: import("react").Dispatch<import("react").SetStateAction<boolean>>;
17
+ ref: import("react").RefObject<HTMLDivElement | null>;
18
+ root: import("react").RefObject<HTMLDivElement | null>;
19
+ svg: Rect;
20
+ rootRect: Rect;
21
+ mousedown: Coord;
22
+ mousecurr: Coord;
23
+ mouseup: Coord;
24
+ mouserect: Coord;
25
+ mouserectClient: Coord;
26
+ xdistance: number;
27
+ ydistance: number;
28
+ };
29
+ export {};
@@ -0,0 +1,49 @@
1
+ import { useLayoutEffect, useRef, useState } from 'react';
2
+ const blank = { left: 0, top: 0, width: 0, height: 0 };
3
+ function getOffset(coord, rect) {
4
+ return coord && [coord[0] - rect.left, coord[1] - rect.top];
5
+ }
6
+ export function useMouseCoordinates() {
7
+ const [mousecurrClient, setMouseCurrClient] = useState();
8
+ const [mousedownClient, setMouseDownClient] = useState();
9
+ const [mouseupClient, setMouseUpClient] = useState();
10
+ const [mouseOvered, setMouseOvered] = useState(false);
11
+ const [rect, setRect] = useState(blank);
12
+ const ref = useRef(null);
13
+ const root = useRef(null);
14
+ useLayoutEffect(() => {
15
+ if (ref.current) {
16
+ setRect(ref.current.getBoundingClientRect());
17
+ }
18
+ }, [mousecurrClient, mousedownClient, mouseupClient]);
19
+ const svg = rect;
20
+ const rootRect = rect;
21
+ const mousedown = getOffset(mousedownClient, rect);
22
+ const mousecurr = getOffset(mousecurrClient, rect);
23
+ const mouseup = getOffset(mouseupClient, rect);
24
+ const mouserect = mouseup || mousecurr;
25
+ const mouserectClient = mouseupClient || mousecurrClient;
26
+ const xdistance = mousedown && mouserect ? mouserect[0] - mousedown[0] : 0;
27
+ const ydistance = mousedown && mouserect ? mouserect[1] - mousedown[1] : 0;
28
+ return {
29
+ mousecurrClient,
30
+ mousedownClient,
31
+ mouseupClient,
32
+ mouseOvered,
33
+ setMouseCurrClient,
34
+ setMouseDownClient,
35
+ setMouseUpClient,
36
+ setMouseOvered,
37
+ ref,
38
+ root,
39
+ svg,
40
+ rootRect,
41
+ mousedown,
42
+ mousecurr,
43
+ mouseup,
44
+ mouserect,
45
+ mouserectClient,
46
+ xdistance,
47
+ ydistance,
48
+ };
49
+ }
@@ -0,0 +1,6 @@
1
+ type Coord = [number, number] | undefined;
2
+ interface View {
3
+ scroll: (distance: number) => void;
4
+ }
5
+ export declare function useMouseMoveHandler(mousecurrClient: Coord, mousedownClient: Coord, mouseupClient: Coord, validPan: boolean, hview: View, vview: View, setMouseCurrClient: (coord: Coord) => void): void;
6
+ export {};
@@ -0,0 +1,24 @@
1
+ import { useEffect } from 'react';
2
+ export function useMouseMoveHandler(mousecurrClient, mousedownClient, mouseupClient, validPan, hview, vview, setMouseCurrClient) {
3
+ useEffect(() => {
4
+ function globalMouseMove(event) {
5
+ setMouseCurrClient([event.clientX, event.clientY]);
6
+ if (mousecurrClient && mousedownClient && validPan && !mouseupClient) {
7
+ hview.scroll(-event.clientX + mousecurrClient[0]);
8
+ vview.scroll(event.clientY - mousecurrClient[1]);
9
+ }
10
+ }
11
+ window.addEventListener('mousemove', globalMouseMove);
12
+ return () => {
13
+ window.removeEventListener('mousemove', globalMouseMove);
14
+ };
15
+ }, [
16
+ validPan,
17
+ mousecurrClient,
18
+ mousedownClient,
19
+ mouseupClient,
20
+ hview,
21
+ vview,
22
+ setMouseCurrClient,
23
+ ]);
24
+ }
@@ -0,0 +1,3 @@
1
+ type Coord = [number, number] | undefined;
2
+ export declare function useMouseUpHandler(mousedown: Coord, mouseup: Coord, xdistance: number, ydistance: number, validSelect: boolean, setMouseUpClient: (coord: Coord) => void, setMouseDownClient: (coord: Coord) => void): void;
3
+ export {};
@@ -0,0 +1,28 @@
1
+ import { useEffect } from 'react';
2
+ export function useMouseUpHandler(mousedown, mouseup, xdistance, ydistance, validSelect, setMouseUpClient, setMouseDownClient) {
3
+ useEffect(() => {
4
+ function globalMouseUp(event) {
5
+ if (Math.abs(xdistance) > 3 && Math.abs(ydistance) > 3 && validSelect) {
6
+ setMouseUpClient([event.clientX, event.clientY]);
7
+ }
8
+ else {
9
+ setMouseDownClient(undefined);
10
+ }
11
+ }
12
+ if (mousedown && !mouseup) {
13
+ window.addEventListener('mouseup', globalMouseUp, true);
14
+ return () => {
15
+ window.removeEventListener('mouseup', globalMouseUp, true);
16
+ };
17
+ }
18
+ return () => { };
19
+ }, [
20
+ validSelect,
21
+ mousedown,
22
+ mouseup,
23
+ xdistance,
24
+ ydistance,
25
+ setMouseUpClient,
26
+ setMouseDownClient,
27
+ ]);
28
+ }
@@ -0,0 +1,8 @@
1
+ type Coord = [number, number] | undefined;
2
+ interface View {
3
+ scroll: (distance: number) => void;
4
+ zoomTo: (bpPerPx: number, position: number) => void;
5
+ bpPerPx: number;
6
+ }
7
+ export declare function useWheelHandler(ref: React.RefObject<HTMLDivElement | null>, wheelMode: string, hview: View, vview: View, mousecurr: Coord, rootRectHeight: number): void;
8
+ export {};
@@ -0,0 +1,44 @@
1
+ import { useEffect, useRef } from 'react';
2
+ import { transaction } from 'mobx';
3
+ export function useWheelHandler(ref, wheelMode, hview, vview, mousecurr, rootRectHeight) {
4
+ const distanceX = useRef(0);
5
+ const distanceY = useRef(0);
6
+ const scheduled = useRef(false);
7
+ useEffect(() => {
8
+ function onWheel(event) {
9
+ event.preventDefault();
10
+ distanceX.current += event.deltaX;
11
+ distanceY.current -= event.deltaY;
12
+ if (!scheduled.current) {
13
+ scheduled.current = true;
14
+ window.requestAnimationFrame(() => {
15
+ transaction(() => {
16
+ if (wheelMode === 'pan') {
17
+ hview.scroll(distanceX.current / 3);
18
+ vview.scroll(distanceY.current / 10);
19
+ }
20
+ else if (wheelMode === 'zoom') {
21
+ if (Math.abs(distanceY.current) > Math.abs(distanceX.current) * 2 &&
22
+ mousecurr) {
23
+ const val = distanceY.current < 0 ? 1.1 : 0.9;
24
+ hview.zoomTo(hview.bpPerPx * val, mousecurr[0]);
25
+ vview.zoomTo(vview.bpPerPx * val, rootRectHeight - mousecurr[1]);
26
+ }
27
+ }
28
+ });
29
+ scheduled.current = false;
30
+ distanceX.current = 0;
31
+ distanceY.current = 0;
32
+ });
33
+ }
34
+ }
35
+ if (ref.current) {
36
+ const curr = ref.current;
37
+ curr.addEventListener('wheel', onWheel);
38
+ return () => {
39
+ curr.removeEventListener('wheel', onWheel);
40
+ };
41
+ }
42
+ return () => { };
43
+ }, [hview, vview, wheelMode, mousecurr, rootRectHeight, ref]);
44
+ }
@@ -1,4 +1,4 @@
1
- import type { Dotplot1DViewModel } from '../model';
1
+ import type { Dotplot1DViewModel } from '../model.ts';
2
2
  import type { BaseBlock } from '@jbrowse/core/util/blockTypes';
3
3
  export declare function locstr(px: number, view: Dotplot1DViewModel, includeAsm?: boolean): string;
4
4
  export declare function getBlockLabelKeysToHide(blocks: BaseBlock[], length: number, viewOffsetPx: number): Set<string>;
@@ -1,9 +1,10 @@
1
+ import { toLocale } from '@jbrowse/core/util';
1
2
  export function locstr(px, view, includeAsm = true) {
2
3
  const { assemblyName, refName, start, offset, oob } = view.pxToBp(px);
3
4
  const coord = Math.floor(start + offset);
4
5
  return oob
5
6
  ? 'out of bounds'
6
- : `${includeAsm ? `{${assemblyName}}` : ''}${refName}:${coord.toLocaleString('en-US')}`;
7
+ : `${includeAsm ? `{${assemblyName}}` : ''}${refName}:${toLocale(coord)}`;
7
8
  }
8
9
  export function getBlockLabelKeysToHide(blocks, length, viewOffsetPx) {
9
10
  const blockLabelKeysToHide = new Set();
@@ -12,15 +13,26 @@ export function getBlockLabelKeysToHide(blocks, length, viewOffsetPx) {
12
13
  const blen = b.end - b.start;
13
14
  return blen - alen;
14
15
  });
15
- const positions = Array.from({ length: Math.round(length) });
16
+ const occupiedPositions = new Set();
16
17
  for (const { key, offsetPx } of sortedBlocks) {
17
18
  const y = Math.round(length - offsetPx + viewOffsetPx);
18
- const labelBounds = [Math.max(y - 12, 0), y];
19
- if (y === 0 || positions.slice(...labelBounds).some(Boolean)) {
19
+ const labelStart = Math.max(y - 12, 0);
20
+ let hasOverlap = y === 0;
21
+ if (!hasOverlap) {
22
+ for (let i = labelStart; i < y; i++) {
23
+ if (occupiedPositions.has(i)) {
24
+ hasOverlap = true;
25
+ break;
26
+ }
27
+ }
28
+ }
29
+ if (hasOverlap) {
20
30
  blockLabelKeysToHide.add(key);
21
31
  }
22
32
  else {
23
- positions.fill(true, ...labelBounds);
33
+ for (let i = labelStart; i < y; i++) {
34
+ occupiedPositions.add(i);
35
+ }
24
36
  }
25
37
  }
26
38
  return blockLabelKeysToHide;
@@ -28,9 +40,7 @@ export function getBlockLabelKeysToHide(blocks, length, viewOffsetPx) {
28
40
  export function chooseGridPitch(scale, minMajorPitchPx, minMinorPitchPx) {
29
41
  scale = Math.abs(scale);
30
42
  const minMajorPitchBp = minMajorPitchPx * scale;
31
- const majorMagnitude = +Number(minMajorPitchBp)
32
- .toExponential()
33
- .split(/e/i)[1];
43
+ const majorMagnitude = +minMajorPitchBp.toExponential().split(/e/i)[1];
34
44
  let majorPitch = 10 ** majorMagnitude;
35
45
  while (majorPitch < minMajorPitchBp) {
36
46
  majorPitch *= 2;
@@ -1,13 +1,13 @@
1
1
  import { lazy } from 'react';
2
2
  import ViewType from '@jbrowse/core/pluggableElementTypes/ViewType';
3
- import stateModelFactory from './model';
3
+ import stateModelFactory from "./model.js";
4
4
  export default function DotplotViewF(pluginManager) {
5
5
  pluginManager.addViewType(() => {
6
6
  return new ViewType({
7
7
  name: 'DotplotView',
8
8
  displayName: 'Dotplot view',
9
9
  stateModel: stateModelFactory(pluginManager),
10
- ReactComponent: lazy(() => import('./components/DotplotView')),
10
+ ReactComponent: lazy(() => import("./components/DotplotView.js")),
11
11
  });
12
12
  });
13
13
  }