|
What this is
Other links
The source code/*
* Sun Public License Notice
*
* The contents of this file are subject to the Sun Public License Version
* 1.0 (the "License"). You may not use this file except in compliance
* with the License. A copy of the License is available at
* http://www.sun.com/
*
* The Original Code is Terminal Emulator.
* The Initial Developer of the Original Code is Sun Microsystems, Inc..
* Portions created by Sun Microsystems, Inc. are Copyright (C) 2001.
* All Rights Reserved.
*
* Contributor(s): Ivan Soleimanipour.
*/
/*
* "Extent.java"
* Extent.java 1.5 01/07/26
*/
package org.netbeans.lib.terminalemulator;
public class Extent {
public Coord begin;
public Coord end;
public Extent(Coord begin, Coord end) {
this.begin = (Coord) begin.clone();
this.end = (Coord) end.clone();
}
/**
* Override Object.toString
*/
public String toString() {
return "Extent[" + begin + " " + end + "]"; // NOI18N
}
/**
* Ensure that 'begin' is before 'end'.
*/
public Extent order() {
if (begin.compareTo(end) > 0) {
Coord tmp = begin;
begin = end;
end = tmp;
}
return this;
}
/*
* Return true if selection intersects the given row/column
*/
public boolean intersects(int arow, int col) {
if (begin.row > arow)
return false;
else if (end.row < arow)
return false;
else if (begin.row == end.row)
return col >= begin.col && col <= end.col;
else if (arow == begin.row)
return col >= begin.col;
else if (arow == end.row)
return col <= end.col;
else
return true;
}
}
|
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.