1 package com.atlassian.selenium.visualcomparison.utils;
2
3 import com.atlassian.annotations.Internal;
4
5 import java.awt.*;
6
7 @Internal
8 public class ScreenResolution extends Dimension implements Comparable<ScreenResolution>
9 {
10 public ScreenResolution(int width, int height)
11 {
12 super(width, height);
13 }
14
15 public ScreenResolution(String value)
16 {
17 String[] parts = value.split("x");
18 if (parts.length != 2)
19 {
20 throw new RuntimeException(value + " is not a valid screen resolution");
21 }
22 int width = Integer.parseInt(parts[0]);
23 int height = Integer.parseInt(parts[1]);
24
25 setSize(width, height);
26 }
27
28 public int compareTo(ScreenResolution other)
29 {
30 if (this.width < other.width)
31 {
32 return -1;
33 }
34 if (this.width > other.width)
35 {
36 return 1;
37 }
38 if (this.height < other.height)
39 {
40 return -1;
41 }
42 if (this.height > other.height)
43 {
44 return 1;
45 }
46 return 0;
47 }
48
49 public String toString()
50 {
51 return width + "x" + height;
52 }
53 }