Skip to content
Snippets Groups Projects
tool.js 3.58 KiB
Newer Older
  • Learn to ignore specific revisions
  • export default class Tool {
    
        constructor(name, icon, key, menu, toggleBehaviour = false) {
    
    Maximilian Giller's avatar
    Maximilian Giller committed
            this.name = name;
    
            this.icon = icon;
    
    Maximilian Giller's avatar
    Maximilian Giller committed
            this.key = key;
            this.warnings = false;
    
            this.toggleBehaviour = toggleBehaviour;
    
            this.isActive = false;
    
    
            if (this.menu !== undefined) {
                this.menu.loadTool(this);
            }
    
    Maximilian Giller's avatar
    Maximilian Giller committed
        }
    
        getName() {
            return this.name;
        }
    
        getKey() {
            return this.key;
        }
    
    
        getIcon() {
            return this.icon;
        }
    
    
        onMenuChange(key, value) {
            if (this.warnings) {
                console.warn('Method "onMenuChange" not implemented.');
            }
        }
    
    
        activateTool() {
    
            this.isActive = true;
    
            if (this.menu !== undefined) {
                this.menu.show();
    
    
            this.onToolActivate();
    
        deactivateTool(nextTool) {
    
            this.isActive = false;
    
            this.onToolDeactivate(nextTool);
    
            if (this.menu !== undefined) {
                this.menu.hide();
    
        onToolActivate() {
    
            if (this.warnings) {
                console.warn('Method "onToolActivate" not implemented.');
            }
    
        }
    
        onToolDeactivate(nextTool) {
    
            if (this.warnings) {
                console.warn('Method "onToolDeactivate" not implemented.');
            }
    
    Maximilian Giller's avatar
    Maximilian Giller committed
        onNodeClick(node) {
            if (this.warnings) {
                console.warn('Method "onNodeClick" not implemented.');
            }
        }
    
        onLinkClick(link) {
            if (this.warnings) {
                console.warn('Method "onLinkClick" not implemented.');
            }
        }
    
        onKeyDown(key) {
            if (this.warnings) {
                console.warn('Method "onKeyDown" not implemented.');
            }
        }
    
        onKeyUp(key) {
            if (this.warnings) {
                console.warn('Method "onKeyUp" not implemented.');
            }
        }
    
    
        nodeCanvasObject(node, ctx, globalScale) {
    
    Maximilian Giller's avatar
    Maximilian Giller committed
            if (this.warnings) {
                console.warn('Method "nodeCanvasObject" not implemented.');
            }
        }
    
        nodeCanvasObjectMode(node) {
            if (this.warnings) {
                console.warn('Method "nodeCanvasObjectMode" not implemented.');
            }
        }
    
    
        linkCanvasObject(link, ctx, globalScale) {
            if (this.warnings) {
                console.warn('Method "linkCanvasObject" not implemented.');
            }
        }
    
        linkCanvasObjectMode(link) {
            if (this.warnings) {
                console.warn('Method "linkCanvasObjectMode" not implemented.');
            }
        }
    
    
    Maximilian Giller's avatar
    Maximilian Giller committed
        nodePointerAreaPaint(node, color, ctx) {
            if (this.warnings) {
                console.warn('Method "nodePointerAreaPaint" not implemented.');
            }
        }
    
        linkWidth(link) {
            if (this.warnings) {
                console.warn('Method "linkWidth" not implemented.');
            }
        }
    
        linkDirectionalParticles() {
            if (this.warnings) {
                console.warn('Method "linkDirectionalParticles" not implemented.');
            }
        }
    
        linkDirectionalParticleWidth(link) {
            if (this.warnings) {
                console.warn(
                    'Method "linkDirectionalParticleWidth" not implemented.'
                );
            }
        }
    
        linkColor(link) {
            if (this.warnings) {
                console.warn(
                    'Method "linkColor" not implemented.'
                );
            }
        }
    
        nodeColor(node) {
            if (this.warnings) {
                console.warn(
                    'Method "nodeColor" not implemented.'
                );
            }
        }
    
    
        onBackgroundClick(event, positions) {
            if (this.warnings) {
    
                console.warn('Method "onBackgroundClick" not implemented.');
    
    Maximilian Giller's avatar
    Maximilian Giller committed
    }