Rectangle.java 1.15 KB
Newer Older
Florian Grabowski's avatar
Florian Grabowski committed
1
package de._82grfl1bif.kpiVisualizer.layouts.treeMap;
Florian Grabowski's avatar
Florian Grabowski committed
2

Florian Grabowski's avatar
Florian Grabowski committed
3
import java.awt.Point;
Florian Grabowski's avatar
Florian Grabowski committed
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57

public class Rectangle{

    private double area;
    private double width;
    private double height;
    private Point origin;

    public void setHeight(double height) {
        this.height = height;
        this.width = area/height;
    }

    public void setWidth(double width) {
        this.width = width;
        this.height = area/width;
    }

    public double getArea() {
        return area;
    }

    public double getWidth() {
        return width;
    }

    public double getHeight() {
        return height;
    }

    public Point getOrigin() {
        return origin;
    }

    public void setOrigin(Point origin) {
        this.origin = origin;
    }

    public Rectangle(double area,double width,Point origin){
        this.area = area;
        this.origin = origin;
        setWidth(width);
    }

    public double getSideRelation(){
        return Math.max(width/height,height/width);
    }

    public boolean checkSideRelation(double side){
        return !(getSideRelation() < Math.max((area/side)/side,side/(area/side)));// false if the Relation gets worse.
    }


}