com.eliad.util
Class EliadGraphicsUtilities

java.lang.Object
  |
  +--com.eliad.util.EliadGraphicsUtilities

public class EliadGraphicsUtilities
extends java.lang.Object

A room for static geometric methods.

Version:
1.0 00/04/10
Author:
Patrick Mérissert-Coffinières

Method Summary
static java.awt.Rectangle coalesceRects(java.awt.Rectangle oldRect, java.awt.Rectangle newRect)
          Coalesces two rectangles into one.
static java.awt.Rectangle[] computeDifference(java.awt.Rectangle r0, java.awt.Rectangle r1)
          It is another, more efficient way to implement SwingUtilities.computeDifference
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

computeDifference

public static java.awt.Rectangle[] computeDifference(java.awt.Rectangle r0,
                                                     java.awt.Rectangle r1)
It is another, more efficient way to implement SwingUtilities.computeDifference
Parameters:
r0 - the rectangle from whom subtraction must be done.
r1 - the rectangle which must be subtracted
Returns:
an array containing from 0 to 4 disjoint rectangles which represent the area in r0 not covered by r1.
Preconditions:
r0 != null && !r0.isEmpty()
r1 != null && !r1.isEmpty()
Postconditions:
return.length <= 4
forall int i in [0, return.length[ | return[i] != null && !return[i].isEmpty()
forall int i in [0, return.length[ | forall int j in [i+1, return.length[ | !return[i].intersects(return[j])
forall int i in [0, return.length[ | !return[i].intersects(r1)
forall int i in [0, return.length[ | r0.contains(return[i])
forall Point pt in r0 | !r1.contains(pt) implies exists int i in [0, return.length[ | return[i].contains(pt)

coalesceRects

public static java.awt.Rectangle coalesceRects(java.awt.Rectangle oldRect,
                                               java.awt.Rectangle newRect)
Coalesces two rectangles into one.
Parameters:
oldRect - the 1st rectangle
newRect - the 2nd rectangle
Returns:
a coalesced rectangle, or null indicating that no coalescing was done.
Preconditions:
oldRect !=null && !oldRect.isEmpty()
newRect !=null && !newRect.isEmpty()
Postconditions:
return != null implies return.equals(oldRect.union(newRect))
return != null implies forall Point pt in return | oldRect.contains(ps) || newRect.contains(pt)
return == null implies exists Point pt in oldRect.union(newRect) | !oldRect.contains(pt) && !newRect.contains(pt)