diff --git a/src/java/com/threerings/geom/GeomUtil.java b/src/java/com/threerings/geom/GeomUtil.java index e21ab412f..4559c5893 100644 --- a/src/java/com/threerings/geom/GeomUtil.java +++ b/src/java/com/threerings/geom/GeomUtil.java @@ -1,5 +1,5 @@ // -// $Id: GeomUtil.java,v 1.3 2002/10/29 06:07:22 mdb Exp $ +// $Id: GeomUtil.java,v 1.4 2003/04/28 20:27:52 mdb Exp $ package com.threerings.geom; @@ -140,4 +140,25 @@ public class GeomUtil tainer.y = tained.y - (tainer.height - tained.height); } } + + /** + * Adds the target rectangle to the bounds of the source rectangle. If + * the source rectangle is null, a new rectangle is created that is the + * size of the target rectangle. + * + * @return the source rectangle. + */ + public static Rectangle grow (Rectangle source, Rectangle target) + { + if (target == null) { + Log.warning("Can't grow with null rectangle [src=" + source + + ", tgt=" + target + "]."); + Thread.dumpStack(); + } else if (source == null) { + source = new Rectangle(target); + } else { + source.add(target); + } + return source; + } } diff --git a/src/java/com/threerings/geom/Log.java b/src/java/com/threerings/geom/Log.java new file mode 100644 index 000000000..26db5b321 --- /dev/null +++ b/src/java/com/threerings/geom/Log.java @@ -0,0 +1,45 @@ +// +// $Id: Log.java,v 1.1 2003/04/28 20:27:52 mdb Exp $ + +package com.threerings.geom; + +/** + * A placeholder class that contains a reference to the log object used by + * this package. + */ +public class Log +{ + public static final String PACKAGE = "geom"; + + public static com.samskivert.util.Log log = + new com.samskivert.util.Log(PACKAGE); + + /** Convenience function. */ + public static void debug (String message) + { + log.debug(message); + } + + /** Convenience function. */ + public static void info (String message) + { + log.info(message); + } + + /** Convenience function. */ + public static void warning (String message) + { + log.warning(message); + } + + /** Convenience function. */ + public static void logStackTrace (Throwable t) + { + log.logStackTrace(com.samskivert.util.Log.WARNING, t); + } + + public static int getLevel () + { + return log.getLevel(PACKAGE); + } +}