Back to index

moin  1.9.0~rc2
ConnectedTextTool.java
Go to the documentation of this file.
00001 /*
00002  * @(#)ConnectedTextTool.java 5.1
00003  *
00004  */
00005 
00006 package CH.ifa.draw.figures;
00007 
00008 import java.awt.*;
00009 import java.awt.event.MouseEvent;
00010 import CH.ifa.draw.framework.*;
00011 import CH.ifa.draw.standard.*;
00012 
00019 public  class ConnectedTextTool extends TextTool {
00020 
00021     boolean     fConnected = false;
00022 
00023     public ConnectedTextTool(DrawingView view, Figure prototype) {
00024         super(view, prototype);
00025     }
00026 
00031     public void mouseDown(MouseEvent e, int x, int y) {
00032         super.mouseDown(e, x, y);
00033 
00034            Figure pressedFigure =  drawing().findFigureInside(x, y);
00035 
00036            TextHolder textHolder = (TextHolder)createdFigure();
00037         if (!fConnected && pressedFigure != null &&
00038                      textHolder != null && pressedFigure != textHolder) {
00039             textHolder.connect(pressedFigure);
00040             fConnected = true;
00041         }
00042     }
00043 
00048     public void activate() {
00049         fConnected = false;
00050     }
00051 }
00052