-
Notifications
You must be signed in to change notification settings - Fork 982
/
MilestoneDisplayer.java
60 lines (50 loc) · 1.77 KB
/
MilestoneDisplayer.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package org.osmdroid.views.overlay.milestones;
import android.graphics.Canvas;
/**
* Displayer of `MilestoneStep`s
* Created by Fabrice Fontaine on 22/12/2017.
*
* @since 6.0.0
*/
public abstract class MilestoneDisplayer {
/**
* Initial orientation (in degrees) of the milestone display.
* For instance, if we're talking about bitmaps,
* a "up arrow" would use 90 and a "right arrow" would use 0.
*/
private final double mInitialOrientation;
/**
* "Should we follow the trajectory?"
* For instance, if we're talking about bitmaps,
* an arrow would use true - in order to follow the polyline's trajectory,
* and a work-in-progress logo would use false - in order to display always the same orientation
* of logo, regardless of the polyline's trajectory
*/
private final boolean mFollowTrajectory;
public MilestoneDisplayer(final double pInitialOrientation, final boolean pFollowTrajectory) {
mInitialOrientation = pInitialOrientation;
mFollowTrajectory = pFollowTrajectory;
}
public void draw(final Canvas pCanvas, final MilestoneStep pStep) {
final double orientation = mInitialOrientation + (mFollowTrajectory ? pStep.getOrientation() : 0);
pCanvas.save();
pCanvas.rotate((float) orientation, pStep.getX(), pStep.getY());
pCanvas.translate(pStep.getX(), pStep.getY());
draw(pCanvas, pStep.getObject());
pCanvas.restore();
}
/**
* Draw on pixel (0,0) with no rotation
*/
protected abstract void draw(final Canvas pCanvas, final Object pParameter);
/**
* @since 6.0.2
*/
public void drawBegin(final Canvas pCanvas) {
}
/**
* @since 6.0.2
*/
public void drawEnd(final Canvas pCanvas) {
}
}