1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package de.desy.acop.chart;
24 import java.awt.BasicStroke;
25
26 public class AcopLine
27 {
28 private static int dash = 6,
29 dot = 3,
30 empty = 3;
31 protected static java.awt.Graphics a;
32 protected static BasicStroke stroke = new BasicStroke(1.0f);
33
34 protected int LineMode;
35 protected java.awt.Color LineColor;
36 protected int LineWidth;
37
38 public AcopLine()
39 {
40 }
41
42
43
44
45
46
47 protected void drawAcopLine(int x1, int y1, int x2, int y2)
48 { int length,tmp;
49
50 if ( x1 == x2 )
51 {
52 if (y2<y1)
53 {
54 tmp = y2;
55 y2=y1;
56 y1=tmp;
57 }
58 }
59 else
60 {
61 if (x2<x1)
62 {
63 tmp = x2;
64 x2=x1;
65 x1=tmp;
66 }
67 }
68
69 if ( LineMode == 0 )
70 {
71 if ( LineWidth < 2 ) a.drawLine(x1,y1,x2,y2);
72 else
73 {
74 if ( y1 == y2 ) a.fillRect(x1,y1-LineWidth/2,x2-x1,LineWidth);
75 else a.fillRect(x1-LineWidth/2,y1,LineWidth,y2-y1);
76 }
77 }
78 else
79 {
80 if ( LineMode == 2 ) length = dot;
81 else length = dash;
82
83 if ( x1 == x2 )
84 {
85 for ( ; y1 < y2; )
86 {
87 if ( y2-y1 >= length )
88 {
89 if ( LineWidth < 2 ) a.drawLine(x1,y1,x2,y1+length);
90 else a.fillRect(x1-LineWidth/2,y1,LineWidth,length);
91
92 y1 += length + empty;
93 if ( LineMode == 3 )
94 {
95 if ( y1 + (dot + empty) < y2 )
96 {
97 if ( LineWidth < 2 ) a.drawLine(x1,y1,x2,y1+dot);
98 else a.fillRect(x1-LineWidth/2,y1,LineWidth,dot);
99 y1 += (dot + empty);
100 if ( y1 + (dot + empty) < y2 )
101 {
102 if ( LineWidth < 2 ) a.drawLine(x1,y1,x2,y1+dot);
103 else a.fillRect(x1-LineWidth/2,y1,LineWidth,dot);
104 y1 += (dot + empty);
105 }
106 }
107 }
108 }
109 else
110 {
111 if ( LineWidth < 2 ) a.drawLine(x1,y1,x2,y2);
112 else a.fillRect(x1-LineWidth/2,y1,LineWidth,y2-y1);
113 break;
114 }
115 }
116 }
117 else
118 {
119 for ( ; x1 < x2; )
120 {
121 if ( x2-x1 >= length )
122 {
123 if ( LineWidth < 2 ) a.drawLine(x1,y1,x1+length,y2);
124 else a.fillRect(x1,y1-LineWidth/2,length,LineWidth);
125 x1 += length+empty;
126 if ( LineMode == 3 )
127 {
128 if ( x1 + (dot + empty) < x2 )
129 {
130 if ( LineWidth < 2 ) a.drawLine(x1,y1,x1+dot,y2);
131 else a.fillRect(x1,y1-LineWidth/2,dot,LineWidth);
132 x1 += (dot + empty);
133 if ( x1 + (dot + empty) < x2 )
134 {
135 if ( LineWidth < 2 ) a.drawLine(x1,y1,x1+dot,y2);
136 else a.fillRect(x1,y1-LineWidth/2,dot,LineWidth);
137 x1 += (dot + empty);
138 }
139 }
140 }
141 }
142 else
143 {
144 if ( LineWidth < 2 ) a.drawLine(x1,y1,x2,y2);
145 else a.fillRect(x1,y1-LineWidth/2,x2-x1,LineWidth);
146 break;
147 }
148 }
149 }
150 }
151
152 }
153 }