Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/arranger/jarl/test/frac/ComplexRectangle.java


1   ////////////////////////////////////////////////////////////////////////////////
2   // ComplexRectangle Class //////////////////////////////////////////////////////
3   ////////////////////////////////////////////////////////////////////////////////
4   // Copyright 2000 - David Leberknight - Anyone may use this code for any reason
5   // at any time, provided that they give an appropriate reference to this source,
6   // and send David some email ( david@leberknight.com ).
7   //
8   // The ComplexRectangle class holds a rectangle of complex coordinates.
9   
10  package com.arranger.jarl.test.frac;
11  
12  
13  
14  public class ComplexRectangle {
15      private double iMin; // imaginary
16      private double iMax;
17      private double rMin; // real
18      private double rMax;
19  
20      public ComplexRectangle(double r1, double r2, double i1, double i2) {
21          set(r1, r2, i1, i2);
22      }
23  
24      public ComplexRectangle() {
25          set(0.0, 0.0, 0.0, 0.0);
26      }
27  
28      public ComplexRectangle(ComplexRectangle cr) {
29          set(cr);
30      }
31  
32      public double getIMin() {
33          return iMin;
34      }
35  
36      public double getIMax() {
37          return iMax;
38      }
39  
40      public double getRMin() {
41          return rMin;
42      }
43  
44      public double getRMax() {
45          return rMax;
46      }
47  
48      public double getHeight() {
49          return iMax - iMin;
50      }
51  
52      public double getWidth() {
53          return rMax - rMin;
54      }
55  
56      public void set(ComplexRectangle cr) {
57          set(cr.getRMin(), cr.getRMax(), cr.getIMin(), cr.getIMax());
58      }
59  
60      public void set(ComplexPoint p1, ComplexPoint p2) {
61          set(p1.getReal(), p2.getReal(), p1.getImaginary(), p2.getImaginary());
62      }
63  
64      public void set(double r1, double r2, double i1, double i2) {
65          if (r1 > r2) {
66              rMin = r2;
67              rMax = r1;
68          } else {
69              rMin = r1;
70              rMax = r2;
71          }
72          if (i1 > i2) {
73              iMin = i2;
74              iMax = i1;
75          } else {
76              iMin = i1;
77              iMax = i2;
78          }
79      }
80  }