-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from Monjisan/feature/labeling_tool_copy
Labeling Tool Features: Copy / Paste
- Loading branch information
Showing
4 changed files
with
177 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
|
||
import Grid from '@material-ui/core/Grid'; | ||
import Button from '@material-ui/core/Button'; | ||
|
||
class Clipboard extends React.Component { | ||
|
||
constructor(props) { | ||
super(props); | ||
this.annotation = null; | ||
this._controls = props.controls; | ||
this.state = { | ||
copy: null | ||
}; | ||
props.getRef(this); | ||
} | ||
init(annotation) { | ||
this.annotation = annotation; | ||
} | ||
hasCopy() { | ||
return this.state.copy != null; | ||
} | ||
copy(isAll) { | ||
if (isAll === null) { | ||
isAll = this.annotation.getTarget() == null; | ||
} | ||
const copy = this.annotation.copyLabels(isAll); | ||
if (copy.length === 0) { | ||
return; | ||
} | ||
this.setState({ copy: copy }); | ||
} | ||
paste() { | ||
const copy = this.state.copy; | ||
this.annotation.pasteLabels(copy); | ||
} | ||
|
||
render() { | ||
return ( | ||
<Grid item xs={12}> | ||
<Button onClick={() => this.copy(false)}>Copy</Button> | ||
<Button onClick={() => this.copy(true)}>Copy ALL</Button> | ||
<Button onClick={() => this.paste()} disabled={!this.hasCopy()}>Paste</Button> | ||
</Grid> | ||
); | ||
} | ||
} | ||
export default Clipboard; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters