@@ -58,6 +58,11 @@ export interface ElementStyle {
58
58
/**
59
59
* Element implements a generic base class for VexFlow, with implementations
60
60
* of general functions and properties that can be inherited by all VexFlow elements.
61
+ *
62
+ * The Element is an abstract class that needs to be subclassed to work. It handles
63
+ * style and text-font properties for the Element and any child elements, along with
64
+ * working with the Registry to create unique ids, but does not have any tools for
65
+ * formatting x or y positions or connections to a Stave.
61
66
*/
62
67
export abstract class Element {
63
68
static get CATEGORY ( ) : string {
@@ -66,7 +71,6 @@ export abstract class Element {
66
71
67
72
// all Element objects keep a list of children that they are responsible and which
68
73
// inherit the style of their parents.
69
- // Currently used by StaveNote for noteheads and
70
74
protected children : Element [ ] = [ ] ;
71
75
protected static ID : number = 1000 ;
72
76
protected static newID ( ) : string {
@@ -270,7 +274,7 @@ export abstract class Element {
270
274
return this . attrs ;
271
275
}
272
276
273
- /** Return an attribute. */
277
+ /** Return an attribute, such as 'id', 'type' or 'class' . */
274
278
// eslint-disable-next-line
275
279
getAttribute ( name : string ) : any {
276
280
return this . attrs [ name ] ;
@@ -283,7 +287,7 @@ export abstract class Element {
283
287
if ( element ) return element as unknown as SVGElement ;
284
288
}
285
289
286
- /** Set an attribute. */
290
+ /** Set an attribute such as 'id', 'class', or 'type' . */
287
291
setAttribute ( name : string , value : string | undefined ) : this {
288
292
const oldID = this . attrs . id ;
289
293
const oldValue = this . attrs [ name ] ;
@@ -298,18 +302,18 @@ export abstract class Element {
298
302
return this . boundingBox ;
299
303
}
300
304
301
- /** Return the context. */
305
+ /** Return the context, such as an SVGContext or CanvasContext object . */
302
306
getContext ( ) : RenderContext | undefined {
303
307
return this . context ;
304
308
}
305
309
306
- /** Set the context. */
310
+ /** Set the context to an SVGContext or CanvasContext object */
307
311
setContext ( context ?: RenderContext ) : this {
308
312
this . context = context ;
309
313
return this ;
310
314
}
311
315
312
- /** Validate and return the context. */
316
+ /** Validate and return the rendering context. */
313
317
checkContext ( ) : RenderContext {
314
318
return defined ( this . context , 'NoContext' , 'No rendering context attached to instance.' ) ;
315
319
}
@@ -318,19 +322,24 @@ export abstract class Element {
318
322
// Font Handling
319
323
320
324
/**
321
- * Provide a CSS compatible font string (e.g., 'bold 16px Arial').
325
+ * Provide a CSS compatible font string (e.g., 'bold 16px Arial') that will be applied
326
+ * to text (not glyphs).
322
327
*/
323
328
set font ( f : string ) {
324
329
this . setFont ( f ) ;
325
330
}
326
331
327
- /** Returns the CSS compatible font string. */
332
+ /** Returns the CSS compatible font string for the text font . */
328
333
get font ( ) : string {
329
334
return Font . toCSSString ( this . textFont ) ;
330
335
}
331
336
332
337
/**
333
- * Set the element's font family, size, weight, style (e.g., `Arial`, `10pt`, `bold`, `italic`).
338
+ * Set the element's text font family, size, weight, style
339
+ * (e.g., `Arial`, `10pt`, `bold`, `italic`).
340
+ *
341
+ * This attribute does not determine the font used for musical Glyphs like treble clefs.
342
+ *
334
343
* @param font is 1) a `FontInfo` object or
335
344
* 2) a string formatted as CSS font shorthand (e.g., 'bold 10pt Arial') or
336
345
* 3) a string representing the font family (at least one of `size`, `weight`, or `style` must also be provided).
@@ -376,6 +385,10 @@ export abstract class Element {
376
385
return this ;
377
386
}
378
387
388
+ /**
389
+ * Get the css string describing this Element's text font. e.g.,
390
+ * 'bold 10pt Arial'.
391
+ */
379
392
getFont ( ) : string {
380
393
if ( ! this . textFont ) {
381
394
this . resetFont ( ) ;
0 commit comments