📄 numbertextfigure.java
字号:
/*
* @(#)NumberTextFigure.java 5.2
*
*/
package CH.ifa.draw.figures;
import java.util.*;
import java.awt.*;
import java.io.IOException;
import CH.ifa.draw.framework.*;
import CH.ifa.draw.standard.*;
/**
* A TextFigure specialized to edit numbers.
*/
public class NumberTextFigure extends TextFigure {
/*
* Serialization support.
*/
private static final long serialVersionUID = -4056859232918336475L;
private int numberTextFigureSerializedDataVersion = 1;
/**
* Gets the number of columns to be used by the text overlay.
* @see CH.ifa.draw.util.FloatingTextField
*/
public int overlayColumns() {
return Math.max(4, getText().length());
}
/**
* Gets the numerical value of the contained text.
* return the value or 0 in the case of an illegal number format.
*/
public int getValue() {
int value = 0;
try {
value = Integer.parseInt(getText());
} catch (NumberFormatException e) {
value = 0;
}
return value;
}
/**
* Sets the numberical value of the contained text.
*/
public void setValue(int value) {
setText(Integer.toString(value));
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -