LineStyle.java
4.39 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/*
* Decompiled with CFR 0_118.
*/
package com.day.image;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Paint;
import java.awt.PaintContext;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.Shape;
import java.awt.Stroke;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
import java.awt.image.ColorModel;
public final class LineStyle
implements Paint,
Stroke {
public static final int STYLE_SOLID = 0;
public static final int STYLE_DOTTED = 1;
public static final int STYLE_DASHED = 2;
public static final int STYLE_FANCY = 3;
private static final Color DEFAULT_COLOR = Color.black;
public static final LineStyle DEFAULT = new LineStyle(DEFAULT_COLOR);
private static final float DEFAULT_MARK = 0.0f;
private static final float DEFAULT_BLANK = 0.0f;
private static final float DEFAULT_WIDTH = 1.0f;
private final int style;
private final float mark;
private final float blank;
private final float width;
private final Paint paint;
private Stroke lineStroke = null;
private String stringValue = null;
public LineStyle(Paint paint) {
this(paint, Float.NaN, Float.NaN, Float.NaN);
}
public LineStyle(Paint paint, float mark, float blank, float width) {
int style;
if (paint == null) {
paint = DEFAULT_COLOR;
}
if (Float.isNaN(mark) || mark < 0.0f) {
mark = 0.0f;
}
if (Float.isNaN(blank) || blank < 0.0f) {
blank = 0.0f;
}
if (Float.isNaN(width) || width <= 0.0f) {
width = 1.0f;
}
if (mark == 0.0f) {
switch ((int)blank) {
case 1: {
style = 1;
mark = 1.0f * width;
blank = 1.0f * width;
break;
}
case 2: {
style = 2;
mark = 3.0f * width;
blank = 2.0f * width;
break;
}
default: {
style = 0;
mark = 1.0f;
blank = 0.0f;
break;
}
}
} else if (mark <= 0.0f || blank <= 0.0f) {
style = 0;
mark = 1.0f;
blank = 0.0f;
} else {
style = 3;
}
this.paint = paint;
this.style = style;
this.mark = mark;
this.blank = blank;
this.width = width;
}
public int getStyle() {
return this.style;
}
public float getMark() {
return this.mark;
}
public float getBlank() {
return this.blank;
}
public float getWidth() {
return this.width;
}
public PaintContext createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform xform, RenderingHints hints) {
return this.paint.createContext(cm, deviceBounds, userBounds, xform, hints);
}
public int getTransparency() {
return this.paint.getTransparency();
}
public Shape createStrokedShape(Shape p) {
if (this.lineStroke == null) {
this.lineStroke = this.style == 0 ? new BasicStroke(this.width, 2, 0, 10.0f) : new BasicStroke(this.width, 2, 0, 10.0f, new float[]{this.mark, this.blank}, 0.0f);
}
return this.lineStroke.createStrokedShape(p);
}
public String toString() {
if (this.stringValue == null) {
StringBuffer buf = new StringBuffer();
buf.append("LineStyle: paint=0x");
buf.append(this.paint);
buf.append(", width=");
buf.append(this.width);
switch (this.style) {
case 0: {
buf.append(", solid");
break;
}
case 1: {
buf.append(", dotted");
break;
}
case 2: {
buf.append(", dashed");
break;
}
case 3: {
buf.append(", fancy: mark=");
buf.append(this.mark);
buf.append(", blank=");
buf.append(this.blank);
}
}
this.stringValue = buf.toString();
}
return this.stringValue;
}
}