public float calcDistance(LayoutValues device) {
...
float sameOrientation = ((Math.signum(w - h) == Math.signum((device.Width - device.Height))) ? false : 100);
return Math.abs(w - device.Width) + Math.abs(h - device.Height) + 100.0F * Math.abs(this.Scale - device.Scale) + sameOrientation;