@jbrowse/plugin-circular-view 2.1.4 → 2.1.6
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.
- package/dist/BaseChordDisplay/components/DisplayError.d.ts +6 -5
- package/dist/BaseChordDisplay/components/DisplayError.js +6 -13
- package/dist/BaseChordDisplay/components/DisplayError.js.map +1 -1
- package/dist/BaseChordDisplay/components/RpcRenderedSvgGroup.d.ts +10 -2
- package/dist/BaseChordDisplay/components/RpcRenderedSvgGroup.js +1 -1
- package/dist/BaseChordDisplay/components/RpcRenderedSvgGroup.js.map +1 -1
- package/dist/BaseChordDisplay/models/BaseChordDisplayModel.d.ts +3 -3
- package/dist/BaseChordDisplay/models/BaseChordDisplayModel.js +31 -33
- package/dist/BaseChordDisplay/models/BaseChordDisplayModel.js.map +1 -1
- package/dist/BaseChordDisplay/models/renderReaction.d.ts +22 -27
- package/dist/BaseChordDisplay/models/renderReaction.js +53 -49
- package/dist/BaseChordDisplay/models/renderReaction.js.map +1 -1
- package/dist/CircularView/components/CircularView.d.ts +5 -3
- package/dist/CircularView/components/CircularView.js +8 -4
- package/dist/CircularView/components/CircularView.js.map +1 -1
- package/dist/CircularView/components/Ruler.d.ts +7 -4
- package/dist/CircularView/components/Ruler.js +11 -5
- package/dist/CircularView/components/Ruler.js.map +1 -1
- package/dist/CircularView/models/CircularView.d.ts +5 -4
- package/dist/CircularView/models/CircularView.js +5 -3
- package/dist/CircularView/models/CircularView.js.map +1 -1
- package/dist/CircularView/models/slices.d.ts +6 -1
- package/dist/CircularView/models/slices.js +1 -4
- package/dist/CircularView/models/slices.js.map +1 -1
- package/dist/CircularView/models/viewportVisibleRegion.d.ts +2 -2
- package/dist/CircularView/models/viewportVisibleRegion.js.map +1 -1
- package/esm/BaseChordDisplay/components/DisplayError.d.ts +6 -5
- package/esm/BaseChordDisplay/components/DisplayError.js +6 -13
- package/esm/BaseChordDisplay/components/DisplayError.js.map +1 -1
- package/esm/BaseChordDisplay/components/RpcRenderedSvgGroup.d.ts +10 -2
- package/esm/BaseChordDisplay/components/RpcRenderedSvgGroup.js +1 -1
- package/esm/BaseChordDisplay/components/RpcRenderedSvgGroup.js.map +1 -1
- package/esm/BaseChordDisplay/models/BaseChordDisplayModel.d.ts +3 -3
- package/esm/BaseChordDisplay/models/BaseChordDisplayModel.js +31 -33
- package/esm/BaseChordDisplay/models/BaseChordDisplayModel.js.map +1 -1
- package/esm/BaseChordDisplay/models/renderReaction.d.ts +22 -27
- package/esm/BaseChordDisplay/models/renderReaction.js +50 -49
- package/esm/BaseChordDisplay/models/renderReaction.js.map +1 -1
- package/esm/CircularView/components/CircularView.d.ts +5 -3
- package/esm/CircularView/components/CircularView.js +8 -4
- package/esm/CircularView/components/CircularView.js.map +1 -1
- package/esm/CircularView/components/Ruler.d.ts +7 -4
- package/esm/CircularView/components/Ruler.js +11 -5
- package/esm/CircularView/components/Ruler.js.map +1 -1
- package/esm/CircularView/models/CircularView.d.ts +5 -4
- package/esm/CircularView/models/CircularView.js +5 -3
- package/esm/CircularView/models/CircularView.js.map +1 -1
- package/esm/CircularView/models/slices.d.ts +6 -1
- package/esm/CircularView/models/slices.js +1 -4
- package/esm/CircularView/models/slices.js.map +1 -1
- package/esm/CircularView/models/viewportVisibleRegion.d.ts +2 -2
- package/esm/CircularView/models/viewportVisibleRegion.js.map +1 -1
- package/package.json +2 -2
- package/src/BaseChordDisplay/components/{DisplayError.js → DisplayError.tsx} +9 -28
- package/src/BaseChordDisplay/components/{RpcRenderedSvgGroup.js → RpcRenderedSvgGroup.tsx} +14 -2
- package/src/BaseChordDisplay/models/BaseChordDisplayModel.ts +51 -53
- package/src/BaseChordDisplay/models/renderReaction.ts +72 -0
- package/src/CircularView/components/{CircularView.js → CircularView.tsx} +80 -69
- package/src/CircularView/components/Ruler.tsx +260 -0
- package/src/CircularView/models/CircularView.ts +7 -4
- package/src/CircularView/models/slices.ts +4 -3
- package/src/CircularView/models/viewportVisibleRegion.ts +4 -4
- package/src/BaseChordDisplay/models/renderReaction.js +0 -70
- package/src/CircularView/components/Ruler.js +0 -222
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { observer } from 'mobx-react'
|
|
3
|
-
import {
|
|
4
|
-
getSession,
|
|
5
|
-
polarToCartesian,
|
|
6
|
-
radToDeg,
|
|
7
|
-
assembleLocString,
|
|
8
|
-
} from '@jbrowse/core/util'
|
|
9
|
-
import { makeContrasting } from '@jbrowse/core/util/color'
|
|
10
|
-
import { useTheme } from '@mui/material/styles'
|
|
11
|
-
import { makeStyles } from 'tss-react/mui'
|
|
12
|
-
|
|
13
|
-
const useStyles = makeStyles()({
|
|
14
|
-
rulerLabel: {
|
|
15
|
-
fontSize: '0.8rem',
|
|
16
|
-
fontWeight: 500,
|
|
17
|
-
lineHeight: 1.6,
|
|
18
|
-
letterSpacing: '0.0075em',
|
|
19
|
-
},
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
function sliceArcPath(slice, radiusPx, startBase, endBase) {
|
|
23
|
-
// A rx ry x-axis-rotation large-arc-flag sweep-flag x y
|
|
24
|
-
if (slice.flipped) {
|
|
25
|
-
;[startBase, endBase] = [endBase, startBase]
|
|
26
|
-
}
|
|
27
|
-
const startXY = slice.bpToXY(startBase, radiusPx)
|
|
28
|
-
const endXY = slice.bpToXY(endBase, radiusPx)
|
|
29
|
-
const largeArc =
|
|
30
|
-
Math.abs(endBase - startBase) / slice.bpPerRadian > Math.PI ? '1' : '0'
|
|
31
|
-
const sweepFlag = '1'
|
|
32
|
-
return [
|
|
33
|
-
'M',
|
|
34
|
-
...startXY,
|
|
35
|
-
'A',
|
|
36
|
-
radiusPx,
|
|
37
|
-
radiusPx,
|
|
38
|
-
'0',
|
|
39
|
-
largeArc,
|
|
40
|
-
sweepFlag,
|
|
41
|
-
...endXY,
|
|
42
|
-
].join(' ')
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const ElisionRulerArc = observer(({ model, slice }) => {
|
|
46
|
-
const theme = useTheme()
|
|
47
|
-
const { radiusPx: modelRadiusPx } = model
|
|
48
|
-
const radiusPx = modelRadiusPx + 1
|
|
49
|
-
const { endRadians, startRadians, region } = slice
|
|
50
|
-
const startXY = polarToCartesian(radiusPx, startRadians)
|
|
51
|
-
const endXY = polarToCartesian(radiusPx, endRadians)
|
|
52
|
-
const widthPx = (endRadians - startRadians) * radiusPx
|
|
53
|
-
const largeArc = endRadians - startRadians > Math.PI ? '1' : '0'
|
|
54
|
-
// TODO: draw the elision
|
|
55
|
-
const centerRadians = (endRadians + startRadians) / 2
|
|
56
|
-
const regionCountString = `[${Number(
|
|
57
|
-
region.regions.length,
|
|
58
|
-
).toLocaleString()}]`
|
|
59
|
-
return (
|
|
60
|
-
<>
|
|
61
|
-
<RulerLabel
|
|
62
|
-
text={regionCountString}
|
|
63
|
-
view={model}
|
|
64
|
-
maxWidthPx={widthPx}
|
|
65
|
-
radians={centerRadians}
|
|
66
|
-
radiusPx={radiusPx}
|
|
67
|
-
title={`${Number(region.regions.length).toLocaleString()} more regions`}
|
|
68
|
-
color={theme.palette.text.primary}
|
|
69
|
-
/>
|
|
70
|
-
<path
|
|
71
|
-
d={[
|
|
72
|
-
'M',
|
|
73
|
-
...startXY,
|
|
74
|
-
'A',
|
|
75
|
-
radiusPx,
|
|
76
|
-
radiusPx,
|
|
77
|
-
'0',
|
|
78
|
-
largeArc,
|
|
79
|
-
'1',
|
|
80
|
-
...endXY,
|
|
81
|
-
].join(' ')}
|
|
82
|
-
stroke={theme.palette.text.secondary}
|
|
83
|
-
strokeWidth={2}
|
|
84
|
-
strokeDasharray="2,2"
|
|
85
|
-
fill="none"
|
|
86
|
-
/>
|
|
87
|
-
</>
|
|
88
|
-
)
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
const RulerLabel = observer(
|
|
92
|
-
({ view, text, maxWidthPx, radians, radiusPx, title, color }) => {
|
|
93
|
-
const { classes } = useStyles()
|
|
94
|
-
const textXY = polarToCartesian(radiusPx + 5, radians)
|
|
95
|
-
if (!text) {
|
|
96
|
-
return null
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if (text.length * 6.5 < maxWidthPx) {
|
|
100
|
-
// text is rotated parallel to the ruler arc
|
|
101
|
-
return (
|
|
102
|
-
<text
|
|
103
|
-
x={0}
|
|
104
|
-
y={0}
|
|
105
|
-
className={classes.rulerLabel}
|
|
106
|
-
textAnchor="middle"
|
|
107
|
-
dominantBaseline="baseline"
|
|
108
|
-
transform={`translate(${textXY}) rotate(${radToDeg(radians) + 90})`}
|
|
109
|
-
style={{ fill: color }}
|
|
110
|
-
>
|
|
111
|
-
{text}
|
|
112
|
-
<title>{title || text}</title>
|
|
113
|
-
</text>
|
|
114
|
-
)
|
|
115
|
-
}
|
|
116
|
-
if (maxWidthPx > 4) {
|
|
117
|
-
// text is rotated perpendicular to the ruler arc
|
|
118
|
-
const overallRotation = radToDeg(
|
|
119
|
-
radians + view.offsetRadians - Math.PI / 2,
|
|
120
|
-
)
|
|
121
|
-
if (overallRotation >= 180) {
|
|
122
|
-
return (
|
|
123
|
-
<text
|
|
124
|
-
x={0}
|
|
125
|
-
y={0}
|
|
126
|
-
className={classes.rulerLabel}
|
|
127
|
-
textAnchor="start"
|
|
128
|
-
dominantBaseline="middle"
|
|
129
|
-
transform={`translate(${textXY}) rotate(${radToDeg(radians)})`}
|
|
130
|
-
style={{ fill: color }}
|
|
131
|
-
>
|
|
132
|
-
{text}
|
|
133
|
-
<title>{title || text}</title>
|
|
134
|
-
</text>
|
|
135
|
-
)
|
|
136
|
-
}
|
|
137
|
-
return (
|
|
138
|
-
<text
|
|
139
|
-
x={0}
|
|
140
|
-
y={0}
|
|
141
|
-
className={classes.rulerLabel}
|
|
142
|
-
textAnchor="end"
|
|
143
|
-
dominantBaseline="middle"
|
|
144
|
-
transform={`translate(${textXY}) rotate(${radToDeg(radians) + 180})`}
|
|
145
|
-
style={{ fill: color }}
|
|
146
|
-
>
|
|
147
|
-
{text}
|
|
148
|
-
<title>{title || text}</title>
|
|
149
|
-
</text>
|
|
150
|
-
)
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
// if you get here there is no room for the text at all
|
|
154
|
-
return null
|
|
155
|
-
},
|
|
156
|
-
)
|
|
157
|
-
|
|
158
|
-
const RegionRulerArc = observer(({ model, slice }) => {
|
|
159
|
-
const theme = useTheme()
|
|
160
|
-
const { radiusPx } = model
|
|
161
|
-
const { region, endRadians, startRadians } = slice
|
|
162
|
-
const centerRadians = (endRadians + startRadians) / 2
|
|
163
|
-
const widthPx = (endRadians - startRadians) * radiusPx
|
|
164
|
-
const session = getSession(model)
|
|
165
|
-
let color
|
|
166
|
-
const assembly = session.assemblyManager.get(slice.region.assemblyName)
|
|
167
|
-
if (assembly) {
|
|
168
|
-
color = assembly.getRefNameColor(region.refName)
|
|
169
|
-
}
|
|
170
|
-
if (color) {
|
|
171
|
-
try {
|
|
172
|
-
color = makeContrasting(color, theme.palette.background.paper)
|
|
173
|
-
} catch (error) {
|
|
174
|
-
color = theme.palette.text.primary
|
|
175
|
-
}
|
|
176
|
-
} else {
|
|
177
|
-
color = theme.palette.text.primary
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
// TODO: slice flipping
|
|
181
|
-
return (
|
|
182
|
-
<>
|
|
183
|
-
<RulerLabel
|
|
184
|
-
text={region.refName}
|
|
185
|
-
view={model}
|
|
186
|
-
maxWidthPx={widthPx}
|
|
187
|
-
radians={centerRadians}
|
|
188
|
-
radiusPx={radiusPx}
|
|
189
|
-
color={color}
|
|
190
|
-
/>
|
|
191
|
-
<path
|
|
192
|
-
d={sliceArcPath(slice, radiusPx + 1, region.start, region.end)}
|
|
193
|
-
stroke={color}
|
|
194
|
-
strokeWidth={2}
|
|
195
|
-
fill="none"
|
|
196
|
-
>
|
|
197
|
-
<title>{region.refName}</title>
|
|
198
|
-
</path>
|
|
199
|
-
</>
|
|
200
|
-
)
|
|
201
|
-
})
|
|
202
|
-
|
|
203
|
-
const CircularRuler = observer(function Ruler({ model, slice }) {
|
|
204
|
-
if (slice.region.elided) {
|
|
205
|
-
return (
|
|
206
|
-
<ElisionRulerArc
|
|
207
|
-
key={assembleLocString(slice.region.regions[0])}
|
|
208
|
-
model={model}
|
|
209
|
-
slice={slice}
|
|
210
|
-
/>
|
|
211
|
-
)
|
|
212
|
-
}
|
|
213
|
-
return (
|
|
214
|
-
<RegionRulerArc
|
|
215
|
-
key={assembleLocString(slice.region)}
|
|
216
|
-
model={model}
|
|
217
|
-
slice={slice}
|
|
218
|
-
/>
|
|
219
|
-
)
|
|
220
|
-
})
|
|
221
|
-
|
|
222
|
-
export default CircularRuler
|