Skip to content

SurfaceText has no rotation support #37

@EMaksymenko

Description

@EMaksymenko

Sometimes it is required to put SurfaceText rotated according North.
This possibility is absent but easy to add.

  1. Add angle attribute, its setter and getter to SurfaceText class.
  2. Add glRotated method call into applyDrawTransform.

See example of overridden class:

public class CustomSurfaceText extends SurfaceText {

    private double angle;

    public CustomSurfaceText(String text, Position position) {
        super(text, position);
    }

    public CustomSurfaceText(String text, Position position, Font font, Color color) {
        super(text, position, font, color);
    }

    public double getAngle() {
        return angle;
    }

    public void setAngle(double angle) {
        this.angle = angle;
    }

    @Override
    protected void applyDrawTransform(DrawContext dc, SurfaceTileDrawContext sdc) {
        super.applyDrawTransform(dc, sdc);
        dc.getGL().getGL2().glRotated(-angle, 0, 0, 1);
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions