Skip to content

Commit

Permalink
Removes all the layout options, except the FDL ('euler') -- #13
Browse files Browse the repository at this point in the history
  • Loading branch information
chrtannus committed Jan 8, 2025
1 parent de9bcb5 commit b1a1027
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 112 deletions.
75 changes: 13 additions & 62 deletions src/client/components/network-editor/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,6 @@ export const DEFAULT_LAYOUT_OPTIONS = {
};


// Keys for scratch data
export const Scratch = {
// boolean flag indicating if the expand/collapse layout is currently running, attached to parent nodes
LAYOUT_RUNNING: '_layoutRunning',
// BubblePath instance, attached to parent nodes
BUBBLE: '_bubble',
// The HTML element for the expand/collapse toggle buttons, attached to parent nodes
TOGGLE_BUTTON_ELEM: '_buttonElem',
AUTOMOVE_RULE: '_automoveRule'
};


/**
* The network editor controller contains all high-level model operations that the network
* editor view can perform.
Expand Down Expand Up @@ -222,37 +210,10 @@ export class NetworkEditorController {
});
}

// _computeFCOSEidealEdgeLengthMap(clusterLabels, clusterAttr) {
// const idealLength = size => {
// switch(true) {
// case size < 10: return 40;
// case size < 20: return 75;
// case size < 30: return 120;
// case size < 40: return 180;
// default: return 250;
// }
// };

// const edgeLengthMap = new Map();

// clusterLabels.forEach(({ clusterId }) => {
// const cluster = this.cy.elements(`node[${clusterAttr}="${clusterId}"]`);
// if(!cluster.empty()) {
// const ideal = idealLength(cluster.size());
// cluster.internalEdges().forEach(edge => {
// edgeLengthMap.set(edge.data('id'), ideal);
// });
// }
// });

// return edgeLengthMap;
// }


async applyLayout(options) {
async applyLayout(eles, options) {
const { cy } = this;

await this._applyLayoutToEles(cy.elements(), options);
await this._applyLayoutToEles(eles || cy.elements(), options || DEFAULT_LAYOUT_OPTIONS);
cy.fit(DEFAULT_PADDING);
}

Expand Down Expand Up @@ -280,16 +241,6 @@ export class NetworkEditorController {
cy.minZoom(-1e50);
cy.maxZoom(1e50);

// const idealLengths = this._computeFCOSEidealEdgeLengthMap(clusterLabels, clusterAttr);

// const options = {
// name: 'fcose',
// animate: false,
// // idealEdgeLength: edge => idealLengths.get(edge.data('id')) || 50,
// nodeRepulsion: 100000
// };
options = options || DEFAULT_LAYOUT_OPTIONS;

const allNodes = eles.nodes();
const disconnectedNodes = allNodes.filter(n => n.degree() === 0); // careful, our compound nodes have degree 0
const connectedNodes = allNodes.not(disconnectedNodes);
Expand Down Expand Up @@ -599,17 +550,17 @@ export class NetworkEditorController {
}


/**
* Delete the selected (i.e. :selected) elements in the graph
*/
deleteSelectedNodes() {
let selectedNodes = this.cy.nodes(':selected');
selectedNodes = selectedNodes.filter(n => n.children().empty()); // Filter out parent nodes
if (!selectedNodes.empty()) {
const deletedNodes = selectedNodes.remove();
this.bus.emit('deletedSelectedNodes', deletedNodes);
}
}
// /**
// * Delete the selected (i.e. :selected) elements in the graph
// */
// deleteSelectedNodes() {
// let selectedNodes = this.cy.nodes(':selected');
// selectedNodes = selectedNodes.filter(n => n.children().empty()); // Filter out parent nodes
// if (!selectedNodes.empty()) {
// const deletedNodes = selectedNodes.remove();
// this.bus.emit('deletedSelectedNodes', deletedNodes);
// }
// }

/**
* @param {boolean} isQuery if `true`, the returned list will contain only query genes
Expand Down
51 changes: 1 addition & 50 deletions src/client/components/network-editor/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ import UndoIcon from '@mui/icons-material/Undo';
import RestoreIcon from '@mui/icons-material/SettingsBackupRestore';
import KeyboardReturnIcon from '@mui/icons-material/KeyboardReturn';
import { DragSelectIcon, DownloadIcon, ShareIcon } from '../svg-icons';
import ConcentricLayoutIcon from '@mui/icons-material/Adjust';
import LayeredLayoutIcon from '@mui/icons-material/FormatAlignCenter';
import ClustersLayoutIcon from '@mui/icons-material/WorkspacesOutlined';
import PhysicsLayoutIcon from '@mui/icons-material/Grain';


const useStyles = makeStyles((theme) => ({
Expand Down Expand Up @@ -275,9 +271,6 @@ const Main = ({
const shiftXCy = openLeftDrawer && !isMobile && !isTablet;
const shiftYCy = openBottomDrawer;

const handleNetworkRestore = () => {
setConfirmDialogOpen(true);
};
const onConfirmCancel = () => {
setConfirmDialogOpen(false);
};
Expand Down Expand Up @@ -360,50 +353,8 @@ const Main = ({
{
title: "Apply Network Layout",
icon: <RestoreIcon />,
onClick: handleNetworkRestore,
onClick: () => controller.applyLayout(),
unrelated: true,
subMenu: [
{
title: "Layered - Circle",
icon: <ConcentricLayoutIcon />,
onClick: () => controller.applyLayout({ name: 'breadthfirst', circle: true }),
},
{
title: "Layered - Top Down",
icon: <LayeredLayoutIcon />,
onClick: () => controller.applyLayout({ name: 'breadthfirst', circle: false, grid: false }),
},
{
title: "Concentric",
icon: <ConcentricLayoutIcon />,
onClick: () => controller.applyLayout({ name: 'concentric' }),
},
{
title: "Clusters",
icon: <ClustersLayoutIcon />,
onClick: () => controller.applyLayout({ name: 'cise', clusters: createClusterArrays() }),
},
{
title: "Physics Simulation",
icon: <PhysicsLayoutIcon />,
onClick: () => controller.applyLayout({
name: 'euler',
animate: false,
mass: (n) => n.data('regulatoryFunction') === 'regulator' ? 480 : 12,
springLength: () => 120,
}),
},
// {
// title: "CoSE",
// icon: <RestoreIcon />,
// onClick: () => controller.applyLayout({ name: 'cose', animate: false, nodeRepulsion: 100000 }),
// },
// {
// title: "Cola",
// icon: <RestoreIcon />,
// onClick: () => controller.applyLayout({ name: 'cola', animate: false }),
// },
],
}, {
title: "Download Data and Images",
icon: <DownloadIcon />,
Expand Down

0 comments on commit b1a1027

Please sign in to comment.