Back to index

moin  1.9.0~rc2
FontSizeHandle.java
Go to the documentation of this file.
00001 /*
00002  * @(#)FontSizeHandle.java 5.1
00003  *
00004  */
00005 
00006 package CH.ifa.draw.figures;
00007 
00008 import java.awt.*;
00009 import CH.ifa.draw.framework.*;
00010 import CH.ifa.draw.standard.*;
00011 
00015 public class FontSizeHandle extends LocatorHandle {
00016 
00017     private Font    fFont;
00018     private int     fSize;
00019 
00020     public FontSizeHandle(Figure owner, Locator l) {
00021         super(owner, l);
00022     }
00023 
00024     public void invokeStart(int  x, int  y, DrawingView view) {
00025         TextFigure textOwner = (TextFigure) owner();
00026         fFont = textOwner.getFont();
00027         fSize = fFont.getSize();
00028     }
00029 
00030     public void invokeStep (int x, int y, int anchorX, int anchorY, DrawingView view) {
00031         TextFigure textOwner = (TextFigure) owner();
00032         int newSize = fSize + y-anchorY;
00033         textOwner.setFont(new Font(fFont.getName(), fFont.getStyle(), newSize) );
00034     }
00035 
00036     public void draw(Graphics g) {
00037         Rectangle r = displayBox();
00038 
00039         g.setColor(Color.yellow);
00040         g.fillOval(r.x, r.y, r.width, r.height);
00041 
00042         g.setColor(Color.black);
00043         g.drawOval(r.x, r.y, r.width, r.height);
00044     }
00045 }