1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package com.cosylab.gui.components.gauger;
21
22 import java.awt.geom.Point2D;
23
24
25
26
27
28
29
30
31
32 public class PolarFullTransform extends PolarTransform
33 {
34 private static final int MAXIMUM_HEIGHT = 60;
35 private static final int MINIMUM_HEIGHT = 35;
36 private static final double RELATIVE_OFFSET = 0.9;
37 private static final double RELATIVE_SCALE_SIZE_COMPARED_TO_SIZE = 0.15;
38
39
40
41
42 public void setParameters(int w, int h, int marginX, int marginY,
43 int tickOffset)
44 {
45 super.setParameters(w, h, marginX, marginY, tickOffset);
46
47 double size = (Math.min(w, h * 1.171573411) * RELATIVE_OFFSET);
48
49 R = size / 2.0;
50 centre = new Point2D.Double(0.5 * w, 0.5 * h + (R * 0.17));
51
52 h = (int)(h * RELATIVE_SCALE_SIZE_COMPARED_TO_SIZE);
53 h = Math.min(h, MAXIMUM_HEIGHT);
54 h = Math.max(h, MINIMUM_HEIGHT);
55 height = h;
56
57 r = R - h;
58
59 alpha = 225.0;
60 span = 270.0;
61
62 setLabelPosition((int)centre.getX(), (int)centre.getY());
63
64
65 this.tickOffset = Math.toDegrees(tickOffset) / r;
66
67 ArcSegment segment = new ArcSegment(centre, r, R, alpha, span);
68 addSegment(segment);
69 }
70 }
71
72