Back to index

moin  1.9.0~rc2
BorderDecorator.java
Go to the documentation of this file.
00001 /*
00002  * @(#)BorderDecorator.java 5.1
00003  *
00004  */
00005 
00006 package CH.ifa.draw.figures;
00007 
00008 import java.awt.*;
00009 import java.util.*;
00010 
00011 import CH.ifa.draw.framework.*;
00012 import CH.ifa.draw.standard.*;
00013 
00018 public  class BorderDecorator extends DecoratorFigure {
00019 
00020     /*
00021      * Serialization support.
00022      */
00023     private static final long serialVersionUID = 1205601808259084917L;
00024     private int borderDecoratorSerializedDataVersion = 1;
00025 
00026     public BorderDecorator() { }
00027     public BorderDecorator(Figure figure) {
00028         super(figure);
00029     }
00030 
00031     private Point border() {
00032         return new Point(3,3);
00033     }
00034 
00038     public void draw(Graphics g, boolean showGuides) {
00039         Rectangle r = displayBox();
00040         super.draw(g, showGuides);
00041         g.setColor(Color.white);
00042         g.drawLine(r.x, r.y, r.x, r.y + r.height);
00043         g.drawLine(r.x, r.y, r.x + r.width, r.y);
00044         g.setColor(Color.gray);
00045         g.drawLine(r.x + r.width, r.y, r.x + r.width, r.y + r.height);
00046         g.drawLine(r.x , r.y + r.height, r.x + r.width, r.y + r.height);
00047     }
00048 
00052     public Rectangle displayBox() {
00053         Rectangle r = fComponent.displayBox();
00054         r.grow(border().x, border().y);
00055         return r;
00056     }
00057 
00061     public void figureInvalidated(FigureChangeEvent e) {
00062         Rectangle rect = e.getInvalidatedRectangle();
00063         rect.grow(border().x, border().y);
00064         super.figureInvalidated(new FigureChangeEvent(e.getFigure(), rect));
00065     }
00066 
00067     public Insets connectionInsets() {
00068         Insets i = super.connectionInsets();
00069         i.top -= 3;
00070         i.bottom -= 3;
00071         i.left -= 3;
00072         i.right -= 3;
00073         return i;
00074     }
00075 }