jdk/make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/SimpleShape.java
changeset 3754 41a9e8c0158c
parent 3725 b2169a6c9c86
parent 3753 c0c9b5f2c874
child 3755 683ea3f13029
equal deleted inserted replaced
3725:b2169a6c9c86 3754:41a9e8c0158c
     1 /*
       
     2  * Copyright 2002-2007 Sun Microsystems, Inc.  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.  Sun designates this
       
     8  * particular file as subject to the "Classpath" exception as provided
       
     9  * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
       
    22  * CA 95054 USA or visit www.sun.com if you need additional information or
       
    23  * have any questions.
       
    24  */
       
    25 package org.jdesktop.swingx.designer;
       
    26 
       
    27 import org.jdesktop.beans.AbstractBean;
       
    28 
       
    29 import java.awt.Graphics2D;
       
    30 import java.awt.Shape;
       
    31 import java.awt.geom.AffineTransform;
       
    32 import java.awt.geom.Point2D;
       
    33 import java.awt.geom.Rectangle2D;
       
    34 import java.util.List;
       
    35 
       
    36 /**
       
    37  * SimpleShape
       
    38  *
       
    39  * @author Created by Jasper Potts (May 22, 2007)
       
    40  */
       
    41 public abstract class SimpleShape extends AbstractBean {
       
    42 
       
    43     protected AffineTransform transform = new AffineTransform();
       
    44     protected LayerContainer parent = null;
       
    45 
       
    46     public void applyTransform(AffineTransform t) {
       
    47         transform.concatenate(t);
       
    48     }
       
    49 
       
    50     public abstract Rectangle2D getBounds(double pixelSize);
       
    51 
       
    52     public abstract void paint(Graphics2D g2, double pixelSize);
       
    53 
       
    54     public abstract boolean isHit(Point2D p, double pixelSize);
       
    55 
       
    56     public boolean intersects(Rectangle2D rect, double pixelSize) {
       
    57         return getBounds(pixelSize).intersects(rect);
       
    58     }
       
    59 
       
    60     public abstract List<? extends ControlPoint> getControlPoints();
       
    61 
       
    62     public abstract void paintControls(Graphics2D g2, double pixelSize, boolean paintControlLines);
       
    63 
       
    64     public void move(double moveX, double moveY, boolean snapPixels) {
       
    65         for (ControlPoint controlPoint : getControlPoints()) {
       
    66             controlPoint.move(moveX, moveY, snapPixels);
       
    67         }
       
    68     }
       
    69 
       
    70     public LayerContainer getParent() {
       
    71         return parent;
       
    72     }
       
    73 
       
    74     public void setParent(LayerContainer parent) {
       
    75         LayerContainer old = getParent();
       
    76         this.parent = parent;
       
    77         firePropertyChange("parent", old, getParent());
       
    78     }
       
    79 
       
    80     public abstract Shape getShape();
       
    81 }