import _ from "lodash"; import { action, makeObservable, observable } from "mobx"; import { observer } from "mobx-react"; import React from "react"; import { Button, Checkbox, Col, ControlLabel, Form, FormControl, InputGroup, Modal } from "react-bootstrap"; import EditorActionsManager from "../managers/EditorActionsManager"; import { EModalType } from "../ui/react-pathway-mapper"; import PathwayActions from "../utils/PathwayActions"; interface ILayoutPropertiesProps { show: boolean; handleClose: (modelId: EModalType) => void; pathwayActions: PathwayActions; } export interface ILayoutProperties { name: string; animationDuration: number; animationEasing: string; nodeRepulsion: number; idealEdgeLength: number; edgeElasticity: number; nestingFactor: number; gravity: number; numIter: number; gravityRangeCompound: number; gravityCompound: number; gravityRange: number; tilingPaddingVertical: number; tilingPaddingHorizontal: number; initialEnergyOnIncremental: number; tile: boolean; animate: boolean; randomize: boolean; nodeDimensionsIncludeLabels: boolean } @observer export default class LayoutProperties extends React.Component< ILayoutPropertiesProps > { static layoutProperties: ILayoutProperties; @observable internalLayoutProperties: ILayoutProperties; constructor(props: ILayoutPropertiesProps) { super(props); makeObservable(this); this.internalLayoutProperties = _.clone( EditorActionsManager.defaultLayoutProperties ); LayoutProperties.layoutProperties = _.clone(EditorActionsManager.defaultLayoutProperties); } @action.bound updateInternalLayoutProperty(property: string, val: boolean | number) { this.internalLayoutProperties[property] = val; } render() { return ( { this.internalLayoutProperties = _.clone(LayoutProperties.layoutProperties); }} onHide={() => { this.internalLayoutProperties = _.clone(LayoutProperties.layoutProperties); this.props.handleClose(EModalType.LAYOUT); }} > Layout Properties
Node Repulsion: { this.updateInternalLayoutProperty("nodeRepulsion", Number(e.target.value)); }} /> Ideal Edge Length: { this.updateInternalLayoutProperty("idealEdgeLength", Number(e.target.value)); }} /> Edge Elasticity: { this.updateInternalLayoutProperty("edgeElasticity", Number(e.target.value)); }} /> Nesting Factor: { this.updateInternalLayoutProperty("nestingFactor", Number(e.target.value)); }} /> Gravity: { this.updateInternalLayoutProperty("gravity", Number(e.target.value)); }} /> Gravity Range: { this.updateInternalLayoutProperty("gravityRange", Number(e.target.value)); }} /> Compound Gravity: { this.updateInternalLayoutProperty("gravityCompound", Number(e.target.value)); }} /> Compound Gravity Range: { this.updateInternalLayoutProperty("gravityRangeCompound", Number(e.target.value)); }} /> Number of Iterations: { this.updateInternalLayoutProperty("numIter", Number(e.target.value)); }} /> Tiling Vertical Padding: { this.updateInternalLayoutProperty("tilingPaddingVertical", Number(e.target.value)); }} /> Tiling Horizontal Padding: { this.updateInternalLayoutProperty("tilingPaddingHorizontal", Number(e.target.value)); }} /> Tile Disconnected: { this.updateInternalLayoutProperty("tile", !this.internalLayoutProperties.tile); }} > Animate: { this.updateInternalLayoutProperty("animate",!this.internalLayoutProperties.animate); }} > Incremental: { this.updateInternalLayoutProperty("randomize", !this.internalLayoutProperties.randomize); }} > Incremental Cooling Factor: { this.updateInternalLayoutProperty("initialEnergyOnIncremental", Number(e.target.value)); }} />
); } }