/* dIntProg Browser. A webbrowser written in Java. * Copyright (C) 2001 Martin Geisler * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the * * Free Software Foundation, Inc., * 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ import java.net.*; /** A hyperlink. A hyperlink is a collection of an URL and a * rectangle. The hyperlink is active within that rectangle. */ public class HyperLink { private URL url; private int x, y, w, h; /** Creates a new hyperlink. * @param x the x coordinate of the top-left corner. * @param y the y coordinate of the top-left corner. * @param w the width of the link. * @param h the height of the link. * @param u the {@link URL} this links points to. */ public HyperLink(int x, int y, int w, int h, URL u) { this.x = x; this.y = y; this.w = w; this.h = h; url = u; } /** Checks to see if (a, b) is within this link. * @param a the x coordinate. * @param b the y coordinate. * @return true if (a, b) * is within the boundaries of this link. */ public boolean contains(int a, int b) { return (x < a && a < x + w && y < b && b < y + h); } /** Returns the URL of this hyperlink. * @return the URL. */ public URL getURL() { return url; } }