1 22 23 27 28 package org.netbeans.lib.terminalemulator; 29 30 public class Extent { 31 public Coord begin; 32 public Coord end; 33 34 public Extent(Coord begin, Coord end) { 35 this.begin = (Coord) begin.clone(); 36 this.end = (Coord) end.clone(); 37 } 38 39 42 public String toString() { 43 return "Extent[" + begin + " " + end + "]"; } 45 46 49 public Extent order() { 50 if (begin.compareTo(end) > 0) { 51 Coord tmp = begin; 52 begin = end; 53 end = tmp; 54 } 55 return this; 56 } 57 58 61 public boolean intersects(int arow, int col) { 62 if (begin.row > arow) 63 return false; 64 else if (end.row < arow) 65 return false; 66 else if (begin.row == end.row) 67 return col >= begin.col && col <= end.col; 68 else if (arow == begin.row) 69 return col >= begin.col; 70 else if (arow == end.row) 71 return col <= end.col; 72 else 73 return true; 74 } 75 } 76 | Popular Tags |