29.07.2013 Views

Master of Science thesis Fighting Spam

Master of Science thesis Fighting Spam

Master of Science thesis Fighting Spam

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

{<br />

}<br />

this.buttonHeight = buttonHeight;<br />

initImageButton(buttonName, buttonText);<br />

public ImageButton(String buttonName, String buttonText, int buttonHeight, int<br />

buttonWidth)<br />

{<br />

this.buttonHeight = buttonHeight;<br />

this.buttonWidth = buttonWidth;<br />

initImageButton(buttonName, buttonText);<br />

}<br />

public ImageButton(String buttonName, String buttonText)<br />

{<br />

initImageButton(buttonName, buttonText);<br />

}<br />

public void initImageButton(String buttonName, String buttonText)<br />

{<br />

this.buttonName = buttonName;<br />

this.buttonText = buttonText;<br />

buttonIcons = new ImageIcon[buttonTypeNames.length];<br />

for(int t = 0; t < buttonTypeNames.length; t++)<br />

buttonIcons[t] = new<br />

ImageIcon(Toolkit.getDefaultToolkit().getImage(Config.imagedir<br />

System.getProperty("file.separator")<br />

buttonName + buttonTypeNames[t]<br />

".gif"));<br />

buttonLabel = new JLabel(buttonIcons[0]);<br />

if(buttonHeight == 0)<br />

{<br />

buttonHeight =<br />

buttonIcons[0].getImage().getHeight(buttonIcons[0].getImageObserver());<br />

}<br />

buttonWidth =<br />

buttonIcons[0].getImage().getWidth(buttonIcons[0].getImageObserver());<br />

//At least 10 in fontsize<br />

font = new Font("font", Font.PLAIN,<br />

(int) (buttonHeight * percentOfHeight) < 12 ? 12 : (int)<br />

(buttonHeight * percentOfHeight));<br />

}<br />

setLayout(new BorderLayout());<br />

setPreferredSize(new Dimension(buttonWidth, buttonHeight));<br />

setMaximumSize(new Dimension(buttonWidth, buttonHeight));<br />

add(buttonLabel, "Center");<br />

addMouseListener(new buttonListener());<br />

public void paint(Graphics g)<br />

{<br />

g.fillRect(0, 0, getWidth(), getHeight());<br />

this.paintChildren(g);<br />

g.setColor(textColor);<br />

g.setFont(font);<br />

if(!setTextCoords)<br />

{<br />

FontMetrics metrics = g.getFontMetrics();<br />

Rectangle2D bounds = metrics.getStringBounds(buttonText, g);<br />

x = (buttonWidth - (int) bounds.getWidth()) / 2;<br />

240<br />

+<br />

+<br />

+

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!