Back to index

moin  1.9.0~rc2
NumberTextFigure.java
Go to the documentation of this file.
00001 /*
00002  * @(#)NumberTextFigure.java 5.1
00003  *
00004  */
00005 
00006 package CH.ifa.draw.figures;
00007 
00008 import java.util.*;
00009 import java.awt.*;
00010 import java.io.IOException;
00011 import CH.ifa.draw.framework.*;
00012 import CH.ifa.draw.standard.*;
00013 
00017 public  class NumberTextFigure extends TextFigure {
00018 
00019     /*
00020      * Serialization support.
00021      */
00022     private static final long serialVersionUID = -4056859232918336475L;
00023     private int numberTextFigureSerializedDataVersion = 1;
00024 
00029     public int overlayColumns() {
00030         return Math.max(4, getText().length());
00031     }
00032 
00033     public int overlayRows() {
00034        return 1;
00035     }
00036 
00041     public int getValue() {
00042         int value = 0;
00043         try {
00044             value = Integer.parseInt(getText());
00045         } catch (NumberFormatException e) {
00046             value = 0;
00047         }
00048         return value;
00049     }
00050 
00054     public void setValue(int value) {
00055         setText(Integer.toString(value));
00056     }
00057 
00058 }