Skip to content
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

possibility to adapt view to aspect ratio of coordinate system #40

Open
hageldave opened this issue Jun 7, 2022 · 1 comment
Open
Assignees
Labels
enhancement New feature or request

Comments

@hageldave
Copy link
Owner

hageldave commented Jun 7, 2022

When resizing the canvas holding a CoordSysRenderer its coordinate view stays the same but is stretched visually to span over the available area. This distorts the contents of the coordinate system and can be undesired. See the example below where the coordinate view stays the same but the coordinate area changed and squishes the lines and distorts the shape.

matching view and viewport different aspect ratios desired behaviour
Screenshot from 2022-06-07 12-47-59 Screenshot from 2022-06-07 13-05-15 Screenshot from 2022-06-07 13-08-21

It is not always problematic when aspect ratios of view and viewport (coordsys area) do not match, but there should be a mechanism that automatically adapts the view to keep up with the areas aspect ratio.

Proposed mechanism:
There will be a new field Rectangle2D desiredCoordinateView which holds the view that should be shown leastwise. The existing field Rectangle2D coordinateView is then sized accordingly so that desiredCoordinateView fits inside. This means that coordinateView is allowed to be either taller or wider than desiredCoordinateView and can be sized so it matches the aspect ratio of the coordinate system area (getCoordSysArea()).

For the automatic coordinate view adaption the CoordSysRenderer has to be made aware of 'componentResized(..)' events of its canvas. When the canvas is resized, the view is resized so that it has the same aspect ratio as the view area and contains the desired view.

Refined Mechanism Proposal:
With the introduction of a second view field in CoordSysRenderer and the need for componentResized event awareness we complicate the API of the CoordSysRenderer class (which is already quite large). Instead we could introduce a new class for controlling CoordSysRenderer.coordinateView.
We already have the interaction classes CoordSysPanning, CoordSysViewSelector and CoordSysScrollZoom that change the coordinate view and listen to events of the canvas. Similarly we could introduce a class CoordSysViewController that holds the field Rectangle2D desiredCoordinateView and adapts CoordSysRenderer.coordinateView when canvas is resized or desiredCoordinateView changes.

Implication: The already mentioned interaction classes for changing the view will have to use the new CoordSysViewController instead of directly manipulating the view. Otherwise changes to the view will be overwritten when component is resized.

@hageldave
Copy link
Owner Author

@reichmla reichmla self-assigned this May 5, 2023
@reichmla reichmla added the enhancement New feature or request label May 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants