1 | package org.expeditee.core;
|
---|
2 |
|
---|
3 | /**
|
---|
4 | * Represents how lines/polylines are rendered.
|
---|
5 | *
|
---|
6 | * @author cts16
|
---|
7 | */
|
---|
8 | public class Stroke {
|
---|
9 |
|
---|
10 | /** The dash array to use for a solid line. */
|
---|
11 | public static final float[] SOLID_DASH_ARRAY = new float[] { 1.0f, 0.0f };
|
---|
12 |
|
---|
13 | /** The methods of rendering the open end of a line. */
|
---|
14 | public enum CAP {
|
---|
15 | BUTT, // Hard squared-off cap at the logical end of the line
|
---|
16 | ROUND, // Semi-circular cap with radius equal to the line thickness
|
---|
17 | SQUARE // Similar to BUTT but extends from the logical end of the line by half the line thickness
|
---|
18 | }
|
---|
19 |
|
---|
20 | /** The methods of rendering the joining point between two segments of a polyline. */
|
---|
21 | public enum JOIN {
|
---|
22 | BEVEL, // Corners of line are connected
|
---|
23 | MITER, // Edges of line extend to meet each other
|
---|
24 | ROUND // Joins are rendered as circles
|
---|
25 | }
|
---|
26 |
|
---|
27 | /** The thickness of the line. */
|
---|
28 | public float thickness;
|
---|
29 | /** The method for rendering line ends. */
|
---|
30 | public CAP capType;
|
---|
31 | /** The method for rendering line joins. */
|
---|
32 | public JOIN joinType;
|
---|
33 | /** An array of distances for on- and off-strokes when rendering dashed lines. */
|
---|
34 | public float[] dashArray;
|
---|
35 | /** Where to start in the dash array. */
|
---|
36 | public float dashPhase;
|
---|
37 |
|
---|
38 | /** Default constructor. */
|
---|
39 | public Stroke()
|
---|
40 | {
|
---|
41 | this(1.0f);
|
---|
42 | }
|
---|
43 |
|
---|
44 | /** Standard constructor. Defaults to butt caps, bevel joins and a solid line. */
|
---|
45 | public Stroke(float thickness)
|
---|
46 | {
|
---|
47 | this(thickness, CAP.BUTT, JOIN.BEVEL);
|
---|
48 | }
|
---|
49 |
|
---|
50 | /** Standard constructor. Defaults to a solid line. */
|
---|
51 | public Stroke(float thickness, CAP capType, JOIN joinType)
|
---|
52 | {
|
---|
53 | this(thickness, capType, joinType, SOLID_DASH_ARRAY, 0.0f);
|
---|
54 | }
|
---|
55 |
|
---|
56 | /** Standard constructor. */
|
---|
57 | public Stroke(float thickness, CAP capType, JOIN joinType, float[] dashArray, float dashPhase)
|
---|
58 | {
|
---|
59 | this.thickness = thickness;
|
---|
60 | this.capType = capType;
|
---|
61 | this.joinType = joinType;
|
---|
62 | this.dashArray = dashArray;
|
---|
63 | this.dashPhase = dashPhase;
|
---|
64 | }
|
---|
65 |
|
---|
66 |
|
---|
67 | }
|
---|