/** * Add a class to this package. * * @param sName * Name of class to be added to this package * @return Newly generated class * @exception JSNameAlreadyExistsException * When the specified class/interface was already created. */ @Nonnull public JSDefinedClass _class (@Nonnull @Nonempty final String sName) throws JSNameAlreadyExistsException { final JSDefinedClass aDefinedClass = new JSDefinedClass (sName); return addDeclaration (aDefinedClass); }
/** * Add a class to this package. * * @param sName * Name of class to be added to this package * @return Newly generated class * @exception JSNameAlreadyExistsException * When the specified class/interface was already created. */ @Nonnull public JSDefinedClass _class (@Nonnull @Nonempty final String sName) throws JSNameAlreadyExistsException { final JSDefinedClass aDefinedClass = new JSDefinedClass (sName); return addDeclaration (aDefinedClass); }
/** * Update the chart with new datasets. This destroys the old chart. * * @param aJSDataVar * The data parameter used to draw the graph. * @return The JS code needed to do so. */ @Nonnull public IHasJSCode getJSUpdateCode (@Nonnull final IJSExpression aJSDataVar) { final JSPackage ret = new JSPackage (); // Cleanup old chart ret.invoke (JSExpr.ref (getJSChartVar ()), "destroy"); // Use new chart ret.assign (JSExpr.ref (getJSChartVar ()), new JSDefinedClass ("Chart")._new () .arg (JSExpr.ref (getCanvasID ()) .invoke ("getContext") .arg ("2d")) .invoke (m_aChart.getJSMethodName ()) .arg (aJSDataVar) .arg (getJSOptions ())); return ret; } }
new JSDefinedClass ("Chart")._new () .arg (aJSCanvas.invoke ("getContext").arg ("2d")) .invoke (m_aChart.getJSMethodName ())