@vitessce/layer-controller 2.0.3-beta.0 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/deflate.b44720d0.mjs +13 -0
- package/dist/index.ca9e70ae.mjs +137540 -0
- package/dist/index.mjs +10 -0
- package/dist/jpeg.edb20ff0.mjs +840 -0
- package/dist/lerc.df2f1733.mjs +1943 -0
- package/dist/lzw.2a639594.mjs +128 -0
- package/dist/packbits.958f7a40.mjs +30 -0
- package/dist/pako.esm.4b234125.mjs +3940 -0
- package/dist/raw.4239192e.mjs +12 -0
- package/dist/webimage.de21cf13.mjs +32 -0
- package/{dist → dist-tsc}/index.js +0 -0
- package/package.json +10 -10
- package/src/BitmaskChannelController.js +63 -0
- package/src/ChannelOptions.js +62 -0
- package/src/ColorPalette.js +49 -0
- package/src/ImageAddButton.js +51 -0
- package/src/LayerController.js +599 -0
- package/src/LayerControllerSubscriber.js +510 -0
- package/src/LayerOptions.js +463 -0
- package/src/RasterChannelController.js +256 -0
- package/src/RasterChannelController.test.js +23 -0
- package/src/VectorLayerController.js +65 -0
- package/src/VolumeOptions.js +218 -0
- package/src/constants.js +14 -0
- package/src/index.js +3 -0
- package/{dist → src}/shared-channel-controls.js +35 -6
- package/src/styles.js +113 -0
- package/src/utils.js +129 -0
- package/dist/BitmaskChannelController.js +0 -31
- package/dist/ChannelOptions.js +0 -39
- package/dist/ColorPalette.js +0 -31
- package/dist/ImageAddButton.js +0 -28
- package/dist/LayerController.js +0 -311
- package/dist/LayerControllerSubscriber.js +0 -197
- package/dist/LayerOptions.js +0 -211
- package/dist/RasterChannelController.js +0 -160
- package/dist/RasterChannelController.test.js +0 -21
- package/dist/VectorLayerController.js +0 -30
- package/dist/VolumeOptions.js +0 -78
- package/dist/constants.js +0 -12
- package/dist/styles.js +0 -103
- package/dist/utils.js +0 -109
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { B as BaseDecoder } from "./index.ca9e70ae.mjs";
|
|
2
|
+
import "react";
|
|
3
|
+
import "@vitessce/vit-s";
|
|
4
|
+
import "react-dom";
|
|
5
|
+
class RawDecoder extends BaseDecoder {
|
|
6
|
+
decodeBlock(buffer) {
|
|
7
|
+
return buffer;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
RawDecoder as default
|
|
12
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { B as BaseDecoder } from "./index.ca9e70ae.mjs";
|
|
2
|
+
import "react";
|
|
3
|
+
import "@vitessce/vit-s";
|
|
4
|
+
import "react-dom";
|
|
5
|
+
class WebImageDecoder extends BaseDecoder {
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
if (typeof createImageBitmap === "undefined") {
|
|
9
|
+
throw new Error("Cannot decode WebImage as `createImageBitmap` is not available");
|
|
10
|
+
} else if (typeof document === "undefined" && typeof OffscreenCanvas === "undefined") {
|
|
11
|
+
throw new Error("Cannot decode WebImage as neither `document` nor `OffscreenCanvas` is not available");
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
async decode(fileDirectory, buffer) {
|
|
15
|
+
const blob = new Blob([buffer]);
|
|
16
|
+
const imageBitmap = await createImageBitmap(blob);
|
|
17
|
+
let canvas;
|
|
18
|
+
if (typeof document !== "undefined") {
|
|
19
|
+
canvas = document.createElement("canvas");
|
|
20
|
+
canvas.width = imageBitmap.width;
|
|
21
|
+
canvas.height = imageBitmap.height;
|
|
22
|
+
} else {
|
|
23
|
+
canvas = new OffscreenCanvas(imageBitmap.width, imageBitmap.height);
|
|
24
|
+
}
|
|
25
|
+
const ctx = canvas.getContext("2d");
|
|
26
|
+
ctx.drawImage(imageBitmap, 0, 0);
|
|
27
|
+
return ctx.getImageData(0, 0, imageBitmap.width, imageBitmap.height).data.buffer;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
WebImageDecoder as default
|
|
32
|
+
};
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitessce/layer-controller",
|
|
3
|
-
"version": "2.0.3
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"author": "Gehlenborg Lab",
|
|
5
5
|
"homepage": "http://vitessce.io",
|
|
6
6
|
"repository": {
|
|
@@ -8,20 +8,21 @@
|
|
|
8
8
|
"url": "git+https://github.com/vitessce/vitessce.git"
|
|
9
9
|
},
|
|
10
10
|
"license": "MIT",
|
|
11
|
-
"main": "dist/index.
|
|
11
|
+
"main": "dist/index.mjs",
|
|
12
12
|
"files": [
|
|
13
|
-
"dist"
|
|
13
|
+
"dist",
|
|
14
|
+
"src"
|
|
14
15
|
],
|
|
15
16
|
"dependencies": {
|
|
16
17
|
"@material-ui/core": "~4.12.3",
|
|
17
18
|
"@material-ui/icons": "~4.11.2",
|
|
18
19
|
"lodash": "^4.17.21",
|
|
19
20
|
"math.gl": "^3.5.6",
|
|
20
|
-
"@vitessce/constants-internal": "2.0.3
|
|
21
|
-
"@vitessce/gl": "2.0.3
|
|
22
|
-
"@vitessce/utils": "2.0.3
|
|
23
|
-
"@vitessce/
|
|
24
|
-
"@vitessce/
|
|
21
|
+
"@vitessce/constants-internal": "2.0.3",
|
|
22
|
+
"@vitessce/gl": "2.0.3",
|
|
23
|
+
"@vitessce/spatial-utils": "2.0.3",
|
|
24
|
+
"@vitessce/utils": "2.0.3",
|
|
25
|
+
"@vitessce/vit-s": "2.0.3"
|
|
25
26
|
},
|
|
26
27
|
"devDependencies": {
|
|
27
28
|
"react": "^18.0.0",
|
|
@@ -32,8 +33,7 @@
|
|
|
32
33
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
|
|
33
34
|
},
|
|
34
35
|
"scripts": {
|
|
35
|
-
"
|
|
36
|
-
"build": "tsc",
|
|
36
|
+
"bundle": "pnpm exec vite build -c ../../../scripts/vite.config.js",
|
|
37
37
|
"test": "pnpm exec vitest --run -r ../../../ --dir ."
|
|
38
38
|
}
|
|
39
39
|
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import RemoveCircleIcon from '@material-ui/icons/RemoveCircle';
|
|
3
|
+
import IconButton from '@material-ui/core/IconButton';
|
|
4
|
+
import Grid from '@material-ui/core/Grid';
|
|
5
|
+
import { ChannelSelectionDropdown, ChannelVisibilityCheckbox } from './shared-channel-controls';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Controller for the handling the bitmask channels.
|
|
9
|
+
* @prop {boolean} visibility Whether or not this channel is "on"
|
|
10
|
+
* @prop {string} dimName Name of the dimensions this slider controls (usually "channel").
|
|
11
|
+
* @prop {object} channelOptions All available options for this dimension (i.e channel names).
|
|
12
|
+
* @prop {function} handlePropertyChange Callback for when a property (color, slider etc.) changes.
|
|
13
|
+
* @prop {function} handleChannelRemove When a channel is removed, this is called.
|
|
14
|
+
* @prop {number} selectionIndex The current numeric index of the selection.
|
|
15
|
+
* @prop {boolean} disableOptions Whether or not channel options are be disabled (default: false).
|
|
16
|
+
*/
|
|
17
|
+
function BitmaskChannelController({
|
|
18
|
+
visibility = false,
|
|
19
|
+
dimName,
|
|
20
|
+
channelOptions,
|
|
21
|
+
handlePropertyChange,
|
|
22
|
+
handleChannelRemove,
|
|
23
|
+
selectionIndex,
|
|
24
|
+
disableOptions = false,
|
|
25
|
+
}) {
|
|
26
|
+
/* A valid selection is defined by an object where the keys are
|
|
27
|
+
* the name of a dimension of the data, and the values are the
|
|
28
|
+
* index of the image along that particular dimension.
|
|
29
|
+
*
|
|
30
|
+
* Since we currently only support making a selection along one
|
|
31
|
+
* addtional dimension (i.e. the dropdown just has channels or mz)
|
|
32
|
+
* we have a helper function to create the selection.
|
|
33
|
+
*
|
|
34
|
+
* e.g { channel: 2 } // channel dimension, third channel
|
|
35
|
+
*/
|
|
36
|
+
const createSelection = index => ({ [dimName]: index });
|
|
37
|
+
return (
|
|
38
|
+
<Grid container direction="row" justifyContent="space-between">
|
|
39
|
+
<Grid item xs={2}>
|
|
40
|
+
<ChannelVisibilityCheckbox
|
|
41
|
+
color={[220, 220, 220]}
|
|
42
|
+
checked={visibility}
|
|
43
|
+
toggle={() => handlePropertyChange('visible', !visibility)}
|
|
44
|
+
/>
|
|
45
|
+
</Grid>
|
|
46
|
+
<Grid item xs={9}>
|
|
47
|
+
<ChannelSelectionDropdown
|
|
48
|
+
handleChange={v => handlePropertyChange('selection', createSelection(v))}
|
|
49
|
+
selectionIndex={selectionIndex}
|
|
50
|
+
disableOptions={disableOptions}
|
|
51
|
+
channelOptions={channelOptions}
|
|
52
|
+
/>
|
|
53
|
+
</Grid>
|
|
54
|
+
<Grid item xs={1}>
|
|
55
|
+
<IconButton onClick={handleChannelRemove} style={{ padding: '6px 6px 6px 0px' }}>
|
|
56
|
+
<RemoveCircleIcon />
|
|
57
|
+
</IconButton>
|
|
58
|
+
</Grid>
|
|
59
|
+
</Grid>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export default BitmaskChannelController;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { makeStyles } from '@material-ui/core/styles';
|
|
3
|
+
import MoreVertIcon from '@material-ui/icons/MoreVert';
|
|
4
|
+
import MenuItem from '@material-ui/core/MenuItem';
|
|
5
|
+
import { PopperMenu } from '@vitessce/vit-s';
|
|
6
|
+
import { MuiSpan } from './styles';
|
|
7
|
+
import ColorPalette from './ColorPalette';
|
|
8
|
+
|
|
9
|
+
const useStyles = makeStyles(() => ({
|
|
10
|
+
menuButton: {
|
|
11
|
+
backgroundColor: 'transparent',
|
|
12
|
+
},
|
|
13
|
+
colors: {
|
|
14
|
+
'&:hover': {
|
|
15
|
+
backgroundColor: 'transparent',
|
|
16
|
+
},
|
|
17
|
+
paddingLeft: '2px',
|
|
18
|
+
paddingRight: '2px',
|
|
19
|
+
},
|
|
20
|
+
}));
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Dropdown for options for a channel on the three dots button.
|
|
24
|
+
* @prop {function} handlePropertyChange Callback for changing property (color, IQR of sliders).
|
|
25
|
+
* @prop {function} handleChannelRemove Callback for channel removal.
|
|
26
|
+
* @prop {function} handleIQRUpdate Callback for IQR slider update.
|
|
27
|
+
*/
|
|
28
|
+
function ChannelOptions({ handlePropertyChange, handleChannelRemove, handleIQRUpdate }) {
|
|
29
|
+
const [open, setOpen] = useState(false);
|
|
30
|
+
|
|
31
|
+
const classes = useStyles();
|
|
32
|
+
|
|
33
|
+
const handleColorSelect = (color) => {
|
|
34
|
+
handlePropertyChange('color', color);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const handleRemove = () => {
|
|
38
|
+
setOpen(false);
|
|
39
|
+
handleChannelRemove();
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<PopperMenu
|
|
44
|
+
open={open}
|
|
45
|
+
setOpen={setOpen}
|
|
46
|
+
buttonIcon={<MoreVertIcon fontSize="small" />}
|
|
47
|
+
buttonClassName={classes.menuButton}
|
|
48
|
+
>
|
|
49
|
+
<MenuItem dense disableGutters onClick={handleRemove}>
|
|
50
|
+
<MuiSpan>Remove</MuiSpan>
|
|
51
|
+
</MenuItem>
|
|
52
|
+
<MenuItem dense disableGutters onClick={handleIQRUpdate}>
|
|
53
|
+
<MuiSpan>Use IQR</MuiSpan>
|
|
54
|
+
</MenuItem>
|
|
55
|
+
<MenuItem dense disableGutters className={classes.colors}>
|
|
56
|
+
<ColorPalette handleChange={handleColorSelect} />
|
|
57
|
+
</MenuItem>
|
|
58
|
+
</PopperMenu>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export default ChannelOptions;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import IconButton from '@material-ui/core/IconButton';
|
|
3
|
+
import LensIcon from '@material-ui/icons/Lens';
|
|
4
|
+
import { makeStyles } from '@material-ui/core/styles';
|
|
5
|
+
import { VIEWER_PALETTE } from '@vitessce/utils';
|
|
6
|
+
|
|
7
|
+
const useStyles = makeStyles(theme => ({
|
|
8
|
+
container: {
|
|
9
|
+
width: '70px',
|
|
10
|
+
height: '40px',
|
|
11
|
+
display: 'flex',
|
|
12
|
+
justifyContent: 'space-between',
|
|
13
|
+
alignItems: 'center',
|
|
14
|
+
flexWrap: 'wrap',
|
|
15
|
+
},
|
|
16
|
+
button: {
|
|
17
|
+
padding: '3px',
|
|
18
|
+
width: '16px',
|
|
19
|
+
},
|
|
20
|
+
icon: {
|
|
21
|
+
width: '17px',
|
|
22
|
+
height: '17px',
|
|
23
|
+
stroke: theme.palette.action.selected,
|
|
24
|
+
'stroke-width': '1px',
|
|
25
|
+
},
|
|
26
|
+
}));
|
|
27
|
+
|
|
28
|
+
const ColorPalette = ({ handleChange }) => {
|
|
29
|
+
const classes = useStyles();
|
|
30
|
+
return (
|
|
31
|
+
<div className={classes.container} aria-label="color-swatch">
|
|
32
|
+
{VIEWER_PALETTE.map(color => (
|
|
33
|
+
<IconButton
|
|
34
|
+
className={classes.button}
|
|
35
|
+
key={color}
|
|
36
|
+
onClick={() => handleChange(color)}
|
|
37
|
+
>
|
|
38
|
+
<LensIcon
|
|
39
|
+
fontSize="small"
|
|
40
|
+
style={{ color: `rgb(${color})` }}
|
|
41
|
+
className={classes.icon}
|
|
42
|
+
/>
|
|
43
|
+
</IconButton>
|
|
44
|
+
))}
|
|
45
|
+
</div>
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export default ColorPalette;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { makeStyles } from '@material-ui/core/styles';
|
|
3
|
+
import AddIcon from '@material-ui/icons/Add';
|
|
4
|
+
import MenuItem from '@material-ui/core/MenuItem';
|
|
5
|
+
import { PopperMenu } from '@vitessce/vit-s';
|
|
6
|
+
|
|
7
|
+
const useStyles = makeStyles(() => ({
|
|
8
|
+
addButton: {
|
|
9
|
+
marginTop: '10px',
|
|
10
|
+
marginBottom: '10px',
|
|
11
|
+
fontWeight: 400,
|
|
12
|
+
},
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
function ImageAddIcon() {
|
|
16
|
+
return (
|
|
17
|
+
<>
|
|
18
|
+
<AddIcon />
|
|
19
|
+
Add Image Layer
|
|
20
|
+
</>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function ImageAddButton({ imageOptions, handleImageAdd }) {
|
|
25
|
+
const [open, setOpen] = useState(false);
|
|
26
|
+
const classes = useStyles();
|
|
27
|
+
|
|
28
|
+
const handleAdd = (imgData) => {
|
|
29
|
+
setOpen(prev => !prev);
|
|
30
|
+
handleImageAdd(imgData);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
if (!imageOptions) return null;
|
|
34
|
+
return (
|
|
35
|
+
<PopperMenu
|
|
36
|
+
open={open}
|
|
37
|
+
setOpen={setOpen}
|
|
38
|
+
buttonIcon={<ImageAddIcon />}
|
|
39
|
+
buttonClassName={classes.addButton}
|
|
40
|
+
placement="bottom-start"
|
|
41
|
+
>
|
|
42
|
+
{imageOptions.map((imgData, i) => (
|
|
43
|
+
<MenuItem dense key={imgData.name} onClick={() => handleAdd(i)}>
|
|
44
|
+
<span>{imgData.name}</span>
|
|
45
|
+
</MenuItem>
|
|
46
|
+
))}
|
|
47
|
+
</PopperMenu>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export default ImageAddButton;
|