home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-03-20 | 2.7 KB | 111 lines |
- /*
- * @(#)Highlight.java 1.5 98/03/18
- *
- * Copyright 1998 by Sun Microsystems, Inc.,
- * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
- * All rights reserved.
- *
- * This software is the confidential and proprietary information
- * of Sun Microsystems, Inc. ("Confidential Information"). You
- * shall not disclose such Confidential Information and shall use
- * it only in accordance with the terms of the license agreement
- * you entered into with Sun.
- */
-
- /*
- * (C) Copyright Taligent, Inc. 1996 - 1997, All Rights Reserved
- * (C) Copyright IBM Corp. 1996 - 1998, All Rights Reserved
- *
- * The original version of this source code and documentation is
- * copyrighted and owned by Taligent, Inc., a wholly-owned subsidiary
- * of IBM. These materials are provided under terms of a License
- * Agreement between Taligent and Sun. This technology is protected
- * by multiple US and International patents.
- *
- * This notice and attribution to Taligent may not be removed.
- * Taligent is a registered trademark of Taligent, Inc.
- *
- */
-
- package java.awt.font;
-
- import java.awt.geom.GeneralPath;
- import java.awt.geom.AffineTransform;
- import java.awt.geom.Rectangle2D;
- import java.awt.Graphics;
- import java.awt.Shape;
- import java.awt.Rectangle;
- import java.awt.Graphics2D;
-
- final class Highlight {
-
- private GeneralPath fPath;
- private boolean fStroke;
-
- // Package-only constructor. For performance,
- // it doesn't clone so be nice.
- Highlight(GeneralPath path, boolean stroke) {
-
- fPath = path;
- fStroke = stroke;
- }
-
- public void draw(Graphics2D g2d) {
-
- /*Graphics2D g2d = new Graphics2D(g);*/
- if (fStroke) {
- g2d.draw(fPath);
- }
- else {
- g2d.fill(fPath);
- }
- }
-
- public void translate(double dx, double dy) {
-
- AffineTransform t = new AffineTransform();
- t.setToTranslation(dx, dy);
- fPath = (GeneralPath) fPath.createTransformedShape(t);
- }
-
- public void add(Highlight h) {
-
- fPath.append(h.fPath, false);
- }
-
- public Rectangle2D getBounds2D() {
-
- return fPath.getBounds2D();
- }
-
- public Rectangle getBounds() {
-
- return fPath.getBounds();
- }
-
- public boolean equals(Object rhs) {
-
- try {
- return equals((Highlight) rhs);
- }
- catch(ClassCastException e) {
- return false;
- }
- }
-
- public boolean equals(Highlight rhs) {
-
- return fPath.equals(rhs.fPath) && fStroke == rhs.fStroke;
- }
-
- public Shape createPath() {
-
- // clone would be better...
- AffineTransform t = new AffineTransform();
- t.setToTranslation(0, 0);
- return fPath.createTransformedShape(t);
- }
- }
-
-
-