UNPKG

@teachinglab/omd

Version:

omd

55 lines (45 loc) 1.5 kB
import { omdColor } from "./omdColor.js"; import { jsvgGroup, jsvgTextBox } from "@teachinglab/jsvg"; export class omdProblem extends jsvgGroup { constructor() { // initialization super(); this.type = "omdProblem"; this.theText = ""; this.problemText = new jsvgTextBox(); this.problemText.setWidthAndHeight( 400,130 ); this.problemText.setText ( "this it the problem text" ); this.problemText.setFontFamily( "Albert Sans" ); this.problemText.setFontColor( "black" ); this.problemText.setFontSize( 18 ); this.addChild( this.problemText ); } loadFromJSON( data ) { if ( typeof data.problemText != "undefined" ) this.theText = data.problemText; if ( typeof data.visualization != "undefined" ) { this.visualJSON = data.visualization; console.log( this.visualJSON ); var obj = window.theApp.handleAIResponse( this.visualJSON ); obj.parent.removeChild( obj ); this.addChild( obj ); obj.setPosition( 0,150 ); //obj.setPosition( obj.xpos, obj.ypos+120 ); } this.updateLayout(); } setName( newName ) { this.name = newName; this.updateLayout(); } updateLayout() { this.problemText.setText ( this.theText ); this.setWidthAndHeight( 300,200 ); } }