001    /*
002     * $Id: ShapeUIResource.java 2565 2008-01-03 19:08:32Z rah003 $
003     *
004     * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
005     * Santa Clara, California 95054, U.S.A. All rights reserved.
006     *
007     * This library is free software; you can redistribute it and/or
008     * modify it under the terms of the GNU Lesser General Public
009     * License as published by the Free Software Foundation; either
010     * version 2.1 of the License, or (at your option) any later version.
011     * 
012     * This library is distributed in the hope that it will be useful,
013     * but WITHOUT ANY WARRANTY; without even the implied warranty of
014     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
015     * Lesser General Public License for more details.
016     * 
017     * You should have received a copy of the GNU Lesser General Public
018     * License along with this library; if not, write to the Free Software
019     * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
020     */
021    
022    package org.jdesktop.swingx.plaf;
023    
024    import java.awt.Rectangle;
025    import java.awt.Shape;
026    import java.awt.geom.AffineTransform;
027    import java.awt.geom.PathIterator;
028    import java.awt.geom.Point2D;
029    import java.awt.geom.Rectangle2D;
030    
031    import javax.swing.plaf.UIResource;
032    
033    /**
034     * An implementation of Shape that implements UIResource.  UI
035     * classes that create Shapes should use this class.
036     *
037     * @author rah003
038     */
039    public class ShapeUIResource implements Shape, UIResource {
040        private Shape s;
041        
042        /** Creates a new instance of PainterUIResource */
043        public ShapeUIResource(Shape p) {
044            this.s = p;
045        }
046        
047        public boolean contains(Point2D p) {
048            return s.contains(p);
049        }
050    
051        public boolean contains(Rectangle2D r) {
052            return s.contains(r);
053        }
054    
055        public boolean contains(double x, double y) {
056            return s.contains(x, y);
057        }
058    
059        public boolean contains(double x, double y, double w, double h) {
060            return s.contains(x, y, w, h);
061        }
062    
063        public Rectangle getBounds() {
064            return s.getBounds();
065        }
066    
067        public Rectangle2D getBounds2D() {
068            return s.getBounds2D();
069        }
070    
071        public PathIterator getPathIterator(AffineTransform at) {
072            return s.getPathIterator(at);
073        }
074    
075        public PathIterator getPathIterator(AffineTransform at, double flatness) {
076            return s.getPathIterator(at, flatness);
077        }
078    
079        public boolean intersects(Rectangle2D r) {
080            return s.intersects(r);
081        }
082    
083        public boolean intersects(double x, double y, double w, double h) {
084            return s.intersects(x, y, w, h);
085        }
086    }