Back to index

moin  1.9.0~rc2
DecoratorFigure.java
Go to the documentation of this file.
00001 /*
00002  * @(#)DecoratorFigure.java 5.1
00003  *
00004  */
00005 
00006 package CH.ifa.draw.standard;
00007 
00008 import CH.ifa.draw.util.*;
00009 import CH.ifa.draw.framework.*;
00010 
00011 import java.awt.*;
00012 import java.util.*;
00013 import java.io.*;
00014 
00029 public abstract class DecoratorFigure
00030                 extends AbstractFigure
00031                 implements FigureChangeListener {
00032 
00036     protected Figure fComponent;
00037 
00038     /*
00039      * Serialization support.
00040      */
00041     private static final long serialVersionUID = 8993011151564573288L;
00042     private int decoratorFigureSerializedDataVersion = 1;
00043 
00044     public DecoratorFigure() { }
00045 
00049     public DecoratorFigure(Figure figure) {
00050         decorate(figure);
00051     }
00052 
00056     public Insets connectionInsets() {
00057         return fComponent.connectionInsets();
00058     }
00059 
00063     public boolean canConnect() {
00064         return fComponent.canConnect();
00065     }
00066 
00070     public boolean containsPoint(int x, int y) {
00071         return fComponent.containsPoint(x, y);
00072     }
00073 
00077     public void decorate(Figure figure) {
00078         fComponent = figure;
00079         fComponent.addToContainer(this);
00080     }
00081 
00085     public Figure peelDecoration() {
00086         fComponent.removeFromContainer(this); //??? set the container to the listener()?
00087         return fComponent;
00088     }
00089 
00093     public Rectangle displayBox() {
00094         return fComponent.displayBox();
00095     }
00096 
00100     public void basicDisplayBox(Point origin, Point corner) {
00101         fComponent.basicDisplayBox(origin, corner);
00102     }
00103 
00107     public void draw(Graphics g, boolean showGuides) {
00108         fComponent.draw(g, showGuides);
00109     }
00110 
00114     public Figure findFigureInside(int x, int y) {
00115         return fComponent.findFigureInside(x, y);
00116     }
00117 
00121     public Vector handles() {
00122         return fComponent.handles();
00123     }
00124 
00128     public boolean includes(Figure figure) {
00129         return (super.includes(figure) || fComponent.includes(figure));
00130     }
00131 
00135     public void moveBy(int x, int y) {
00136         fComponent.moveBy(x, y);
00137     }
00138 
00142     protected void basicMoveBy(int x, int y) {
00143         // this will never be called
00144     }
00145 
00149     public void release() {
00150         super.release();
00151         fComponent.removeFromContainer(this);
00152         fComponent.release();
00153     }
00154 
00159     public void figureInvalidated(FigureChangeEvent e) {
00160         if (listener() != null)
00161             listener().figureInvalidated(e);
00162     }
00163 
00164     public void figureChanged(FigureChangeEvent e) {
00165     }
00166 
00167     public void figureRemoved(FigureChangeEvent e) {
00168     }
00169 
00174     public  void figureRequestUpdate(FigureChangeEvent e) {
00175         if (listener() != null)
00176             listener().figureRequestUpdate(e);
00177     }
00178 
00183     public void figureRequestRemove(FigureChangeEvent e) {
00184         if (listener() != null)
00185             listener().figureRequestRemove(new FigureChangeEvent(this));
00186     }
00187 
00191     public FigureEnumeration figures() {
00192         return fComponent.figures();
00193     }
00194 
00198     public FigureEnumeration decompose() {
00199         return fComponent.decompose();
00200     }
00201 
00205     public void setAttribute(String name, Object value) {
00206         fComponent.setAttribute(name, value);
00207     }
00208 
00212     public Object getAttribute(String name) {
00213         return fComponent.getAttribute(name);
00214     }
00215 
00219     public Locator connectedTextLocator(Figure text) {
00220         return fComponent.connectedTextLocator(text);
00221     }
00222 
00226     public Connector connectorAt(int x, int y) {
00227         return fComponent.connectorAt(x, y);
00228     }
00229 
00233     public void connectorVisibility(boolean isVisible) {
00234         fComponent.connectorVisibility(isVisible);
00235     }
00236 
00240     public void write(StorableOutput dw) {
00241         super.write(dw);
00242         dw.writeStorable(fComponent);
00243     }
00244 
00245     public String getMap() {
00246        return "";
00247     }
00248 
00252     public void read(StorableInput dr) throws IOException {
00253         super.read(dr);
00254         decorate((Figure)dr.readStorable());
00255     }
00256 
00257     private void readObject(ObjectInputStream s)
00258         throws ClassNotFoundException, IOException {
00259 
00260         s.defaultReadObject();
00261 
00262         fComponent.addToContainer(this);
00263     }
00264 }