Skip to content

Commit

Permalink
Rename GlyphView.{base->base_glyph}
Browse files Browse the repository at this point in the history
  • Loading branch information
mattpap committed Jan 10, 2024
1 parent 6726539 commit 9126d7f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 37 deletions.
58 changes: 29 additions & 29 deletions bokehjs/src/lib/models/glyphs/glyph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ export abstract class GlyphView extends View {
}

get data_size(): number {
const {base} = this
if (base != null) {
return base.data_size
const {base_glyph} = this
if (base_glyph != null) {
return base_glyph.data_size
} else {
const {_data_size} = this
if (_data_size != null)
Expand Down Expand Up @@ -115,7 +115,7 @@ export abstract class GlyphView extends View {

render(ctx: Context2d, indices: number[], data?: Partial<Glyph.Data>): void {
if (this.glglyph != null) {
this.glglyph.render(ctx, indices, this.base ?? this)
this.glglyph.render(ctx, indices, this.base_glyph ?? this)
} else if (this.canvas.webgl != null && settings.force_webgl) {
throw new Error(`${this} doesn't support webgl rendering`)
} else {
Expand Down Expand Up @@ -240,17 +240,17 @@ export abstract class GlyphView extends View {
}
}

protected _base: this | null = null
protected _base_glyph: this | null = null

get base(): this | null {
return this._base
get base_glyph(): this | null {
return this._base_glyph
}

set_base<T extends this>(base: T): void {
if (base != this && base instanceof this.constructor) {
this._base = base
set_base_glyph<T extends this>(base_glyph: T): void {
if (base_glyph != this && base_glyph instanceof this.constructor) {
this._base_glyph = base_glyph
} else {
this._base = null
this._base_glyph = null
}
}

Expand All @@ -273,17 +273,17 @@ export abstract class GlyphView extends View {
}

protected _inherit_attr<Data>(attr: keyof Data): void {
const {base} = this
assert(base != null)
this._inherit_from(attr, base)
const {base_glyph} = this
assert(base_glyph != null)
this._inherit_from(attr, base_glyph)
}

protected _inherit_from<Data>(attr: keyof Data, base: this): void {
protected _inherit_from<Data>(attr: keyof Data, base_glyph: this): void {
Object.defineProperty(this, attr, {
configurable: true,
enumerable: true,
get() {
return base[attr as keyof typeof base]
return base_glyph[attr as keyof typeof base_glyph]
},
})
this._define_inherited(attr, true)
Expand All @@ -297,8 +297,8 @@ export abstract class GlyphView extends View {
})
}

protected _can_inherit_from<T>(prop: p.Property<T>, base: this): boolean {
const base_prop = base.model.property(prop.attr)
protected _can_inherit_from<T>(prop: p.Property<T>, base_glyph: this): boolean {
const base_prop = base_glyph.model.property(prop.attr)

const value = prop.get_value()
const base_value = base_prop.get_value()
Expand All @@ -320,9 +320,9 @@ export abstract class GlyphView extends View {

set_visuals(source: ColumnarDataSource, indices: Indices): void {
for (const prop of this._iter_visuals()) {
const {base} = this
if (base != null && this._can_inherit_from(prop, base)) {
this._inherit_from(prop.attr, base)
const {base_glyph} = this
if (base_glyph != null && this._can_inherit_from(prop, base_glyph)) {
this._inherit_from(prop.attr, base_glyph)
} else {
const uniform = prop.uniform(source).select(indices)
this._define_attr(prop.attr, uniform)
Expand Down Expand Up @@ -368,7 +368,7 @@ export abstract class GlyphView extends View {

async set_data(source: ColumnarDataSource, indices: Indices, indices_to_update?: number[]): Promise<void> {
const visuals = new Set(this._iter_visuals())
const {base} = this
const {base_glyph} = this

this._data_size = indices.count

Expand All @@ -381,11 +381,11 @@ export abstract class GlyphView extends View {
continue
}

if (base != null && this._can_inherit_from(prop, base)) {
this._inherit_from(prop.attr, base)
if (base_glyph != null && this._can_inherit_from(prop, base_glyph)) {
this._inherit_from(prop.attr, base_glyph)

if (prop instanceof p.DistanceSpec || prop instanceof p.ScreenSizeSpec) {
this._inherit_from(`max_${prop.attr}`, base)
this._inherit_from(`max_${prop.attr}`, base_glyph)
}
} else {
if (prop instanceof p.BaseCoordinateSpec) {
Expand Down Expand Up @@ -416,7 +416,7 @@ export abstract class GlyphView extends View {

this.glglyph?.set_data_changed()

if (base == null) {
if (base_glyph == null) {
this.index_data()
}
}
Expand Down Expand Up @@ -456,7 +456,7 @@ export abstract class GlyphView extends View {

map_data(): void {
const {x_scale, y_scale} = this.renderer.coordinates
const {base} = this
const {base_glyph} = this

const v_compute = <T>(prop: p.BaseCoordinateSpec<T>) => {
const scale = prop.dimension == "x" ? x_scale : y_scale
Expand All @@ -470,8 +470,8 @@ export abstract class GlyphView extends View {

for (const prop of this.model) {
if (prop instanceof p.BaseCoordinateSpec) {
if (base != null && this._is_inherited(prop)) {
this._inherit_from(`s${prop.attr}`, base)
if (base_glyph != null && this._is_inherited(prop)) {
this._inherit_from(`s${prop.attr}`, base_glyph)
} else {
const array = v_compute(prop)
this._define_attr(`s${prop.attr}`, array)
Expand Down
2 changes: 1 addition & 1 deletion bokehjs/src/lib/models/glyphs/math_text_glyph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export abstract class MathTextGlyphView extends TextView {
protected abstract _build_label(text: string): BaseText

protected override async _build_labels(): Promise<void> {
const {text} = this.base ?? this
const {text} = this.base_glyph ?? this

const labels = Array.from(text, (text_i) => {
return text_i == null ? null : this._build_label(text_i)
Expand Down
4 changes: 2 additions & 2 deletions bokehjs/src/lib/models/glyphs/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class TextView extends XYGlyphView {
declare visuals: Text.Visuals

protected async _build_labels(): Promise<void> {
const {text} = this.base ?? this
const {text} = this.base_glyph ?? this
this.labels = Array.from(text, (value) => {
if (value == null) {
return null
Expand All @@ -46,7 +46,7 @@ export class TextView extends XYGlyphView {
super.after_visuals()

const n = this.data_size
const {anchor} = this.base ?? this
const {anchor} = this.base_glyph ?? this
const {padding, border_radius} = this.model

const {text_align, text_baseline} = this.visuals.text
Expand Down
10 changes: 5 additions & 5 deletions bokehjs/src/lib/models/renderers/glyph_renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,11 @@ export class GlyphRendererView extends DataRendererView {
const decimated_glyph = glyph_from_mode(decimated_defaults, "auto")
this.decimated_glyph = await this.build_glyph_view(decimated_glyph)

this.selection_glyph.set_base(this.glyph)
this.nonselection_glyph.set_base(this.glyph)
this.hover_glyph?.set_base(this.glyph)
this.muted_glyph.set_base(this.glyph)
this.decimated_glyph.set_base(this.glyph)
this.selection_glyph.set_base_glyph(this.glyph)
this.nonselection_glyph.set_base_glyph(this.glyph)
this.hover_glyph?.set_base_glyph(this.glyph)
this.muted_glyph.set_base_glyph(this.glyph)
this.decimated_glyph.set_base_glyph(this.glyph)

await this.set_data()
}
Expand Down

0 comments on commit 9126d7f

Please sign in to comment.