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
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.
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.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 fieldRectangle2D coordinateView
is then sized accordingly so thatdesiredCoordinateView
fits inside. This means thatcoordinateView
is allowed to be either taller or wider thandesiredCoordinateView
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 forcomponentResized
event awareness we complicate the API of theCoordSysRenderer
class (which is already quite large). Instead we could introduce a new class for controllingCoordSysRenderer.coordinateView
. We already have the interaction classesCoordSysPanning
,CoordSysViewSelector
andCoordSysScrollZoom
that change the coordinate view and listen to events of the canvas. Similarly we could introduce a classCoordSysViewController
that holds the fieldRectangle2D desiredCoordinateView
and adaptsCoordSysRenderer.coordinateView
when canvas is resized ordesiredCoordinateView
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.