1
2
3
4
5
6
7 package com.octo.captcha.component.image.fontgenerator;
8
9 /***
10 * <p/>
11 * Base class for Font generators. Sub classes must implement the getFont() method that return a Font.</br> use
12 * constructor to specify your generator properties. This base class only use two parameters, minFontSize and
13 * maxFontsize wich are the size font boundaries returned by the implementation. By default minFontSize=10 and
14 * maxFontSize = 14. </p>
15 *
16 * @author <a href="mailto:mag@jcaptcha.net">Marc-Antoine Garrigue </a>
17 * @version 1.0
18 */
19 public abstract class AbstractFontGenerator implements FontGenerator {
20
21 /***
22 * Min Size for the font
23 */
24 private int minFontSize = 10;
25
26 /***
27 * Max Size for the font
28 */
29 private int maxFontSize = 14;
30
31 /***
32 * Default constructor for the FontGenerator
33 */
34 AbstractFontGenerator(Integer minFontSize, Integer maxFontSize) {
35 this.minFontSize = minFontSize != null ? minFontSize.intValue() : this.minFontSize;
36 this.maxFontSize = maxFontSize != null && maxFontSize.intValue() >= this.minFontSize ? maxFontSize
37 .intValue()
38 : Math.max(this.maxFontSize, this.minFontSize + 1);
39 }
40
41 /***
42 * @return the min font size for the generated image
43 */
44 public int getMinFontSize() {
45 return minFontSize;
46 }
47
48 /***
49 * @return the max font size for the generated image
50 */
51 public int getMaxFontSize() {
52 return maxFontSize;
53 }
54 }