1/*
2 * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.  Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26package sun.font;
27
28import java.awt.Rectangle;
29import java.awt.Shape;
30import java.awt.geom.AffineTransform;
31import java.awt.geom.PathIterator;
32import java.awt.geom.Point2D;
33import java.awt.geom.Rectangle2D;
34
35/**
36 * To avoid people downcasting Shape to a known mutable subclass and
37 * mucking with its internals, we need to interpose a subclass that
38 * cannot be mutated or downcasted.
39 */
40public final class DelegatingShape implements Shape {
41    Shape delegate;
42
43    public DelegatingShape(Shape delegate) {
44        this.delegate = delegate;
45    }
46
47    public Rectangle getBounds() {
48        return delegate.getBounds(); // assumes all delegates are immutable via the returned Rectangle
49    }
50
51    public Rectangle2D getBounds2D() {
52        return delegate.getBounds2D();  // assumes all delegates are immutable via the returned Rectangle2D
53    }
54
55    public boolean contains(double x, double y) {
56        return delegate.contains(x, y);
57    }
58
59    public boolean contains(Point2D p) {
60        return delegate.contains(p);
61    }
62
63    public boolean intersects(double x, double y, double w, double h) {
64        return delegate.intersects(x, y, w, h);
65    }
66
67    public boolean intersects(Rectangle2D r) {
68        return delegate.intersects(r);
69    }
70
71    public boolean contains(double x, double y, double w, double h) {
72        return delegate.contains(x, y, w, h);
73    }
74
75    public boolean contains(Rectangle2D r) {
76        return delegate.contains(r);
77    }
78
79    public PathIterator getPathIterator(AffineTransform at) {
80        return delegate.getPathIterator(at);
81    }
82
83    public PathIterator getPathIterator(AffineTransform at, double flatness) {
84        return delegate.getPathIterator(at, flatness);
85    }
86}
87