-
Notifications
You must be signed in to change notification settings - Fork 274
Make Scale read-only
#5851
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make Scale read-only
#5851
Conversation
Add `Scale#toWorldTransform()` and `Scale#toScreenTransform()` to build `AffineTransform` for either direction. Remove most conversion methods from `ScreenPoint`. The only ones left are conveniences for rounded conversions. These remaining methods also accept a `Scale` rather than requiring a full `ZoneRenderer`.
The fields are still mutable for the sake of serialization. But there is no longer any way to modify a `Scale` by normal means. Instead, new methods allow creating new `Scale` objects with altered properties. This will allow better sharing of `Scale` between components and threads.
- `#getOffV(ZoneRenderer)` => `#getOffV(Scale)` - `#getOffU(ZoneRenderer)` => `#getOffV(Scale)` - `#getRendererSizeU(ZoneRenderer)` => `#getSizeU(Dimension2D)` - `#getRendererSizeV(ZoneRenderer)` => `#getSizeV(Dimension2D)`
Rather than having to pass the x/y offsets and scale separate, we can now pass a full `Scale` to resolve corresponding AWT paint.
All direct `Scale` mutators in `ZoneRenderer` have been removed, requiring callers to update the `ZoneViewModel` directly via `#getZoneScale()` and `#setZoneScale(Scale)`. A few indirect mutators remain in `ZoneRenderer` in the form of convenience methods that do other work in addition to modify the zone scale.
969ab06 to
5bdfab5
Compare
Issues attributed to commits in this pull requestThis pull request was merged and Sentry observed the following issues:
|
|
Was just going to raise a bug ticket to say that MapTool-nightly-20251109 is broken, as when trying to run the win exe I get the following error: |
|
Whoops, I'll get this fixed up ASAP. |
|
On the plus side, I think this is the first time sentry has correctly identified the source of a problem 😅 |
You know what they say about broken clocks :) |
Identify the Bug or Feature request
Resolves #5849
Description of the Change
Changes the interface of
Scaleso its properties can no longer be modified. The fields are notfinalso that serialization continues to work, but they are effectively immutable. As a proper value type,Scalenow has#equals(Object)and#hashCode()methods. This also meansScaleis no longer reponsible for pumping events when modified, so thePropertyChangeSupporthas been removed.Scaleis now the only place that defines transformations between world and screen space. It provides generalAffineTransforms in both directions via#toWorldTransform()and#toScreenTransform(). Also, most conversion methods onScreenPointhave been removed in favour of using theScalefor conversions. Those conversion methods that remain inScreenPointare wrappers around the ones inScalefor specific circumstances, and they all accept a simpleScalerather than an entireZoneRenderer.The
ZoneViewModelnow manages theScalefor aZone(used to be inZoneRenderer). This is just one more step along the road of removing dependencies onZoneRenderer, though for now most components still look up the view model from the renderer.ZoneRenderernow longer offers methods to directly change the currentScale, though it does offer a few convenience methods that may do so among other things.A few
Scale-related improvements as well:RepaintZoneRequestedevent gives a way for any component to trigger a repaint via the event bus. For now onlyZoneViewModeluses it when theScaleis changed, but there are plenty of other places that will benefit from this as well.HexGrid#getOffV(ZoneRenderer)andHexGrid#getOffU(ZoneRenderer)now accept aScaleinstead of aZoneRenderer. Similarly,HexGrid#getRendererSizeV(ZoneRenderer)andHexGrid#getRendererSizeU(ZoneRenderer)are nowHexGrid#getSizeV(Dimension2D)andHexGrid#getSizeU(Dimension2D).DrawablePaintandDrawableNoisenow accept a fullScalewhen getting the AWT paint. This isn't used much now, but will be more common with some upcoming rendering changes.Possible Drawbacks
Some scaling operations are more verbose to write now, though that will improve as
ZoneRendereris pushed out of the limelight.Documentation Notes
N/A
Release Notes
This change is