View Javadoc

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