Commit 9d0507b Matt Lythgoe
committed
1 parent e017b75 commit 9d0507b Copy full SHA for 9d0507b
File tree 2 files changed +6
-4
lines changed
2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change 18
18
public class Plotter extends JPanel {
19
19
20
20
private static final long serialVersionUID = 1L ;
21
- private static String fieldImage = "/field_image_2020_large .png" ;
21
+ private static String fieldImage = "/2021_at_home .png" ;
22
22
private BufferedImage img ;
23
23
private static double scale ;
24
24
private int fieldHeight ;
25
25
private WaypointListener waypointListener ;
26
26
private String pathName ;
27
27
28
+ private static final double FIELD_HEIGHT = 15.0 ;
29
+
28
30
public Plotter (String pathName ) {
29
31
waypointListener = new WaypointListener (this );
30
32
try {
31
33
this .pathName = pathName ;
32
34
img = ImageIO .read (getClass ().getResourceAsStream (fieldImage ));
33
- scale = img .getHeight () / 27.0 ;
35
+ scale = img .getHeight () / FIELD_HEIGHT ;
34
36
fieldHeight = img .getHeight ();
35
37
} catch (IOException e ) {
36
38
e .printStackTrace ();
@@ -87,11 +89,11 @@ public static double convertXFromPixel(double pixel) {
87
89
}
88
90
89
91
public static int convertYToPixel (double value ) {
90
- return (int )((13.5 - value ) * scale );
92
+ return (int )((FIELD_HEIGHT / 2 - value ) * scale );
91
93
}
92
94
93
95
public static double convertYFromPixel (double pixel ) {
94
- return (27 - pixel / scale ) - 13.5 ;
96
+ return (FIELD_HEIGHT - pixel / scale ) - FIELD_HEIGHT / 2 ;
95
97
}
96
98
97
99
public BobPath getPath () {
You can’t perform that action at this time.
0 commit comments