Skip to content
Snippets Groups Projects
Commit e9ae3871 authored by Tran Peter's avatar Tran Peter
Browse files

add(controller): cherry pick utility package from ui-gameScene

parent 7eca9919
No related branches found
No related tags found
5 merge requests!74V1,!73Initial commit,!71Merge DataBase into Development,!10Mergin ui into development,!9Merging ui into development
package de.hdm_stuttgart.battlearena.Controller.Utilities;
public enum ScreenClasses {
// enums have a range because the screen calculations are not precise, especially with screen scaling in the OS settings
INCH27(26, 28),
INCH24(23, 25),
INCH13_SURFACE(12, 14);
final int lBound, uBound;
ScreenClasses(int lBound, int uBound) {
this.lBound = lBound;
this.uBound = uBound;
}
public static ScreenClasses inRange(int inches) {
for (ScreenClasses screens : ScreenClasses.values()) {
if (screens.isInRange(inches)) {
return screens;
}
}
return null;
}
private boolean isInRange(int inches) {
return inches >= lBound && inches <= uBound;
}
}
package de.hdm_stuttgart.battlearena.Controller.Utilities;
public class ScreenDimensionCalculator {
public double calculateDiagonalInches(double width, double height, double dpi) {
double diagonalPixels = Math.sqrt(Math.pow(width, 2) + Math.pow(height, 2));
double diagonalInches = diagonalPixels / dpi;
System.out.println("diagonal pixels: " + diagonalPixels);
System.out.println("width: " + width);
System.out.println("height: " + height);
return diagonalInches;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment