Skip to content

Conversation

@BryonLewis
Copy link
Collaborator

@BryonLewis BryonLewis commented Aug 25, 2025

I believe this was part of feedback related to the UI.

Previous Problem:

  • When zooming and zooming out the text labels could possible overlap because of the scaling mode in geoJS. I had set the scaling to make it so the text renamed the same size without moving around. This would cause text to overlap if you zoomed out too far.

Updates:

  • Text should remain relatively the same size while zooming in. Once the user zooms out far enough (I chose -1.5 zoomlevel but this may need to be updated in the future if we have different resolution waveforms) it will swap to true zooming and max the text smaller. This will make it so the text can fit on the screen without overlapping.
  • I may some small changes so that when zoomed in and the text labels are on the inside of the spectrogram (They switch from outside to in based zooming) it will remove the inside X-Axis labels (time in ms) before they overlap with the y-axis labels (frequence in KHz).
  • When changing the zooming levels, I redid some logic related to the text anchoring positions as well as the offsets to make the alignment a bit better.
  • Species, Frequency, Time measurements have all been adjusted as well to have better scaling
  • Small update to reference the proper file with ningx.nominio.template
BATAI-TextScaling_small.mp4

@BryonLewis BryonLewis marked this pull request as ready for review September 1, 2025 14:44
@BryonLewis BryonLewis requested a review from naglepuff September 1, 2025 14:44
Copy link
Collaborator

@naglepuff naglepuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks good, and the text layers are all much easier to read.

One thing that might still be a concern is how to time labels bunch up on the x-axis:
image

Do you think it would be an improvement to change the font size (i.e. make it smaller) for lower x-scale values?

geoViewer.value.zoomRange({
// do not set a min limit so that bounds clamping determines min
min: -Infinity,
// 4x zoom max
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this comment still true now that the value of max has changed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was playing around with it because even a 2x scaling mode on a image that is 64k pixel wide is crazy, I'll revert it.

Comment on lines 106 to 116
onZoom(event: {zoomLevel: number}) {
this.zoomLevel = event.zoomLevel;
this.textScaled = undefined;
if ((this.zoomLevel || 0) < -1.5 ) {
this.textScaled = -1.5;
} else if ((this.zoomLevel || 0) > 0) {
this.textScaled = Math.sqrt(this.zoomLevel || 1);
} else {
this.textScaled = this.zoomLevel;
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's worth noting that this function is the same as the one on freqLayer, and could potentially be moved to a parent class or interface. not saying it needs to be done here, but as these layer classes get more and more of the same functions, I think the argument for a parent class gets stronger.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was something I was debating doing. It really only applies to layers that have Text values in them.
That would be
freqLayer, legendLayer, speciesLayer, timeLayer.
so maybe there is a secondary Abstract Base layer type that is a TextLayer that will have this function and items.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't have to do it here, I could see an argument for it being out of scope. As long as its tracked as an issue or a code comment at the least.

@BryonLewis
Copy link
Collaborator Author

Created the Abstract BaseTextLayer that abstracts out duplicated properties and functions into a base class.

I attempted to make a font-scaling tool for when the user adjusts the xScale (thanks I missed that in my initial testing). It's not perfect because if you reduce the compressed scale to 1 and then zoom in, the text remains fairly small. It may need some more logic to handle that conditional.

Copy link
Collaborator

@naglepuff naglepuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I left one comment about code style. Feel free to merge after fixing that

Comment on lines 75 to 85
this.zoomLevel = event.zoomLevel;
this.textScaled = undefined;
if ((this.zoomLevel || 0) < -1.5 ) {
this.textScaled = -1.5;
} else if ((this.zoomLevel || 0) > 0) {
this.textScaled = Math.sqrt(this.zoomLevel || 1);
} else {
this.textScaled = this.zoomLevel;
}
this.redraw();
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this function just needs to be indented.

@BryonLewis BryonLewis merged commit 8123a0e into main Sep 2, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants