001/* 002 * $Id: ShapeUIResource.java 4028 2011-06-03 19:32:19Z kschaefe $ 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 022package org.jdesktop.swingx.plaf; 023 024import java.awt.Rectangle; 025import java.awt.Shape; 026import java.awt.geom.AffineTransform; 027import java.awt.geom.PathIterator; 028import java.awt.geom.Point2D; 029import java.awt.geom.Rectangle2D; 030 031import 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 */ 039public 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 @Override 048 public boolean contains(Point2D p) { 049 return s.contains(p); 050 } 051 052 @Override 053 public boolean contains(Rectangle2D r) { 054 return s.contains(r); 055 } 056 057 @Override 058 public boolean contains(double x, double y) { 059 return s.contains(x, y); 060 } 061 062 @Override 063 public boolean contains(double x, double y, double w, double h) { 064 return s.contains(x, y, w, h); 065 } 066 067 @Override 068 public Rectangle getBounds() { 069 return s.getBounds(); 070 } 071 072 @Override 073 public Rectangle2D getBounds2D() { 074 return s.getBounds2D(); 075 } 076 077 @Override 078 public PathIterator getPathIterator(AffineTransform at) { 079 return s.getPathIterator(at); 080 } 081 082 @Override 083 public PathIterator getPathIterator(AffineTransform at, double flatness) { 084 return s.getPathIterator(at, flatness); 085 } 086 087 @Override 088 public boolean intersects(Rectangle2D r) { 089 return s.intersects(r); 090 } 091 092 @Override 093 public boolean intersects(double x, double y, double w, double h) { 094 return s.intersects(x, y, w, h); 095 } 096}