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

Improve text rotation #283

Open
jzy3d opened this issue Jun 16, 2022 · 0 comments
Open

Improve text rotation #283

jzy3d opened this issue Jun 16, 2022 · 0 comments

Comments

@jzy3d
Copy link
Owner

jzy3d commented Jun 16, 2022

Text is always rotated from center, whatever its layout. LEFT/RIGHT aligned text should rather have their rotation point on the anchor.

Capture d’écran 2022-06-16 à 15 06 27

This would ease positioning Y axis label in the 2D case as the default layout is

Capture d’écran 2022-06-16 à 15 09 25

but which is fixed with a undesirable fix in AxisLabelProcessor.axisLabelPosition_2D with the below code

if(!LabelOrientation.HORIZONTAL.equals(axisLayout.getYAxisLabelOrientation())) {
      
      // consider the rotation & offset due to vertical text 
      int textLength = view.getPainter().getTextLengthInPixels(axisLayout.getFont(), axisLayout.getYAxisLabel());
      
      // hack the emulgl vertical Y axis case by ignoring pixel scale for text
      if(!view.getCanvas().isNative())
        textLength /= pixelScale.y;
      
      xShiftPx -= textLength/2;
      
      int textHeight = axisLayout.getFont().getHeight();
      
      // hack the emulgl vertical Y axis case by ignoring pixel scale for text
      if(!view.getCanvas().isNative())
        textHeight /= pixelScale.x;

      xShiftPx += textHeight/2;
    }
@jzy3d jzy3d added this to the 2.2.0 milestone Jun 16, 2022
@jzy3d jzy3d removed this from the 2.2.0 milestone Aug 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant