/** * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Paul Luna */ import { PointComponent } from './point-component'; import * as React from 'react'; import { Vec2 } from '../../../mol-math/linear-algebra'; interface LineGraphComponentState { points: Vec2[], copyPoint: any, canSelectMultiple: boolean, } export class LineGraphComponent extends React.Component { private myRef: any; private height: number; private width: number; private padding: number; private updatedX: number; private updatedY: number; private selected?: number[]; private ghostPoints: SVGElement[]; private gElement: SVGElement; private namespace: string; constructor(props: any) { super(props); this.myRef = React.createRef(); this.state = { points: [ Vec2.create(0, 0), Vec2.create(1, 0) ], copyPoint: undefined, canSelectMultiple: false, }; this.height = 400; this.width = 600; this.padding = 70; this.selected = undefined; this.ghostPoints = []; this.namespace = 'http://www.w3.org/2000/svg'; for (const point of this.props.data) { this.state.points.push(point); } this.state.points.sort((a, b) => { if (a[0] === b[0]) { if (a[0] === 0) { return a[1] - b[1]; } if (a[1] === 1) { return b[1] - a[1]; } return a[1] - b[1]; } return a[0] - b[0]; }); this.handleDrag = this.handleDrag.bind(this); this.handleMultipleDrag = this.handleMultipleDrag.bind(this); this.handleDoubleClick = this.handleDoubleClick.bind(this); this.refCallBack = this.refCallBack.bind(this); this.handlePointUpdate = this.handlePointUpdate.bind(this); this.change = this.change.bind(this); this.handleKeyUp = this.handleKeyUp.bind(this); this.handleLeave = this.handleLeave.bind(this); this.handleEnter = this.handleEnter.bind(this); } public render() { const points = this.renderPoints(); const lines = this.renderLines(); return ([
{lines} {points}
,