aboutsummaryrefslogtreecommitdiff
path: root/src/WindowRange.java
blob: 19edd0f0d3f0b966239623805301f3bd5d5150fa (plain) (blame)
1
2
3
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*    */ public class WindowRange
/*    */ {
/*    */   private double xMin;
/*    */   private double xMax;
/*    */   private double yMin;
/*    */   private double yMax;
/*    */ 
/*    */   public WindowRange(double xMin, double yMin, double xMax, double yMax)
/*    */   {
/* 10 */     this.xMin = xMin;
/* 11 */     this.xMax = xMax;
/* 12 */     this.yMin = yMin;
/* 13 */     this.yMax = yMax;
/*    */   }
/*    */   private WindowRange(double[] args) {
/* 16 */     this(args[0], args[1], args[2], args[3]);
/*    */   }
/*    */   public WindowRange(Point2D p1, Point2D p2) {
/* 19 */     this(getFromPoints(p1, p2));
/*    */   }
/*    */   public WindowRange() {
/* 22 */     this(-10.0D, -10.0D, 10.0D, 10.0D);
/*    */   }
/*    */   public double getXMin() {
/* 25 */     return this.xMin;
/*    */   }
/*    */   public double getYMin() {
/* 28 */     return this.yMin;
/*    */   }
/*    */   public double getXMax() {
/* 31 */     return this.xMax;
/*    */   }
/*    */   public double getYMax() {
/* 34 */     return this.yMax;
/*    */   }
/*    */ 
/*    */   public WindowRange getScaledInstance(double scale) {
/* 38 */     WindowRange ret = new WindowRange();
/* 39 */     double origdifx = getXMax() - getXMin();
/* 40 */     double newdifx = origdifx * scale;
/* 41 */     double change = (newdifx - origdifx) / 2.0D;
/* 42 */     ret.xMin = (getXMin() - change);
/* 43 */     ret.xMax = (getXMax() + change);
/*    */ 
/* 45 */     double origdify = getYMax() - getYMin();
/* 46 */     double newdify = origdify * scale;
/* 47 */     change = (newdify - origdify) / 2.0D;
/* 48 */     ret.yMin = (getYMin() - change);
/* 49 */     ret.yMax = (getYMax() + change);
/*    */ 
/* 51 */     return ret;
/*    */   }
/*    */   public WindowRange getTranslatedInstance(double difx, double dify) {
/* 54 */     return new WindowRange(this.xMin - difx, this.yMin + dify, this.xMax - difx, this.yMax + dify);
/*    */   }
/*    */ 
/*    */   private static double[] getFromPoints(Point2D p1, Point2D p2)
/*    */   {
/*    */     double s3;
/*    */     double s3;
/*    */     double s1;
/* 58 */     if (p1.getX() > p2.getX()) {
/* 59 */       double s1 = p2.getX();
/* 60 */       s3 = p1.getX();
/*    */     } else {
/* 62 */       s3 = p2.getX();
/* 63 */       s1 = p1.getX();
/*    */     }
/*    */     double s4;
/*    */     double s4;
/*    */     double s2;
/* 66 */     if (p1.getY() > p2.getY()) {
/* 67 */       double s2 = p2.getY();
/* 68 */       s4 = p1.getY();
/*    */     } else {
/* 70 */       s4 = p2.getY();
/* 71 */       s2 = p1.getY();
/*    */     }
/* 73 */     return new double[] { s1, s2, s3, s4 };
/*    */   }
/*    */ }

/* Location:           Modulus.jar
 * Qualified Name:     WindowRange
 * JD-Core Version:    0.6.2
 */