import java.awt.Graphics;
import java.awt.Image;
-
public class ToolButton extends Button {
- private Image icon;
- private int orx; // X of the icon top left corner
- private int ory; // Y of the icon top left corner
- private String link;
- private String target;
+ private transient final Image _icon;
+ private transient int _orx; // X of the icon top left corner
+ private transient int _ory; // Y of the icon top left corner
+ private transient final String _link;
+ private transient final String _target;
private static final long serialVersionUID = 5723786125423445749L;
-
-// ==============================================================================================================================
-// Constructors
-// ==============================================================================================================================
- public ToolButton (int size, Image icon, String link) {
-// -----------------------------------------------------
+ // ==============================================================================================================================
+ // Constructors
+ // ==============================================================================================================================
+
+ public ToolButton(final int size, final Image icon, final String link) {
this(size, icon, link, null);
}
- public ToolButton (int size, Image icon, String link, String target) {
-// --------------------------------------------------------------------
- orx = 24; // icon.getWidth(this); seems returning 0 before being painted
- ory = 24; // icon.getHeight(this); seems returning 0 before being painted
- if (orx < size) orx = (size - orx) / 2;
- else orx = 0;
- if (ory < size) ory = (size - ory) / 2;
- else ory = 0;
-
- this.icon = icon;
- this.link = link;
- this.target = target;
- this.setSize(size, size);
- this.setCursor(new Cursor(Cursor.HAND_CURSOR));
+
+ public ToolButton(final int size, final Image icon, final String link,
+ final String target) {
+ super();
+ _orx = 24; // icon.getWidth(this); seems returning 0 before being painted
+ _ory = 24; // icon.getHeight(this); seems returning 0 before being painted
+ if (_orx < size) {
+ _orx = (size - _orx) / 2;
+ } else {
+ _orx = 0;
+ }
+ if (_ory < size) {
+ _ory = (size - _ory) / 2;
+ } else {
+ _ory = 0;
+ }
+
+ this._icon = icon;
+ this._link = link;
+ this._target = target;
+ this.setSize(size, size);
+ this.setCursor(new Cursor(Cursor.HAND_CURSOR));
}
-
-// ==============================================================================================================================
-// Overridden functions
-// ==============================================================================================================================
- public void paint(Graphics screen) {
-// ----------------------------------
- screen.drawImage(icon, orx, ory, new Color(205, 229, 255), this);
- }
-
-// ==============================================================================================================================
-// Member functions
-// ==============================================================================================================================
+ // ==============================================================================================================================
+ // Overridden functions
+ // ==============================================================================================================================
- public String getTool () {
-// ------------------------
- return link;
- }
+ @Override
+ public void paint(final Graphics screen) {
+ screen.drawImage(_icon, _orx, _ory, new Color(205, 229, 255), this);
+ }
- public String getTarget () {
-// --------------------------
- return target;
- }
+ // ==============================================================================================================================
+ // Member functions
+ // ==============================================================================================================================
+
+ public String getTool() {
+ return _link;
+ }
+
+ public String getTarget() {
+ return _target;
+ }
}
\ No newline at end of file