1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package net.sf.magicproject.ui;
24
25 import java.io.IOException;
26 import java.io.InputStream;
27
28 import net.sf.magicproject.clickable.targetable.card.MCard;
29 import net.sf.magicproject.test.Test;
30 import net.sf.magicproject.test.TestFactory;
31 import net.sf.magicproject.tools.Log;
32
33 /***
34 * @author <a href="mailto:fabdouglas@users.sourceforge.net">Fabrice Daugan </a>
35 * @since 0.80
36 */
37 public class TooltipFilter {
38
39 /***
40 * <ul>
41 * Structure of stream : Data[size]
42 * <li>display powerANDtoughness yes=1,no=0 [1]</li>
43 * <li>display states yes=1,no=0 [1]</li>
44 * <li>display types yes=1,no=0 [1]</li>
45 * <li>display colors yes=1,no=0 [1]</li>
46 * <li>display properties yes=1,no=0 [1]</li>
47 * <li>display damage yes=1,no=0 [1]</li>
48 * <li>filter [...]</li>
49 * </ul>
50 *
51 * @param inputFile
52 * file containing the states picture
53 * @throws IOException
54 * If some other I/O error occurs
55 */
56 public TooltipFilter(InputStream inputFile) throws IOException {
57 powerANDtoughness = inputFile.read() == 1;
58 states = inputFile.read() == 1;
59 types = inputFile.read() == 1;
60 colors = inputFile.read() == 1;
61 properties = inputFile.read() == 1;
62 damage = inputFile.read() == 1;
63 test = TestFactory.readNextTest(inputFile);
64 }
65
66 /***
67 * The instance of TooltipFilter containing all fields set to
68 * <code>true</code>
69 */
70 public static TooltipFilter fullInstance = new TooltipFilter();
71
72 /***
73 * Creates a new instance of TooltipFilter with all displayed information <br>
74 */
75 private TooltipFilter() {
76 powerANDtoughness = true;
77 states = true;
78 types = true;
79 colors = true;
80 properties = true;
81 damage = true;
82 }
83
84 /***
85 * Return true if this tooltip can be displayed for this specified card.
86 *
87 * @param card
88 * the tested card.
89 * @return true if this tooltip can be displayed for this specified card.
90 */
91 public boolean suits(MCard card) {
92 try {
93 return test.test(null, card);
94 } catch (NullPointerException e) {
95 Log
96 .error("Test of tooltip filter should 'onTestedCard'. Fix this error and rebuild this TBS\n\t error : "
97 + e.getStackTrace()[0]);
98 return false;
99 }
100 }
101
102 /***
103 * Are the power / toughness displayed
104 */
105 public boolean powerANDtoughness;
106
107 /***
108 * Are the states displayed
109 */
110 public boolean states;
111
112 /***
113 * Are the types displayed
114 */
115 public boolean types;
116
117 /***
118 * Are the properties displayed
119 */
120 public boolean properties;
121
122 /***
123 * Are the colors displayed
124 */
125 public boolean colors;
126
127 /***
128 * Are the damage displayed
129 */
130 public boolean damage;
131
132 /***
133 * The filtering test of this tooltip.
134 */
135 public Test test;
136
137 }