1
2
3
4
5
6
7
8
9
10 package nl.tudelft.simulation.language.filters;
11
12 /***
13 * The histogram specifies a histogram chart for the DSOL framework.
14 * <p>
15 * (c) copyright 2004 <a href="http://www.simulation.tudelft.nl/dsol/">Delft
16 * University of Technology </a>, the Netherlands. <br>
17 * See for project information <a href="http://www.simulation.tudelft.nl/dsol/">
18 * www.simulation.tudelft.nl/dsol </a> <br>
19 * License of use: <a href="http://www.gnu.org/copyleft/gpl.html">General Public
20 * License (GPL) </a>, no warranty <br>
21 *
22 * @author <a href="http://www.tbm.tudelft.nl/webstaf/peterja/index.htm"> Peter
23 * Jacobs </a>
24 * @version 1.0 Oct 26, 2004
25 * @since 1.2
26 */
27 public class MaxPointFilter extends AbstractFilter
28 {
29 /*** the maxPoints to use */
30 private long maxPoints = -1;
31
32 /*** the amount of points already accepted */
33 private long accepted = 0;
34
35 /***
36 * constructs a new MaxPointFilter
37 *
38 * @param maxPoints the maximum points to display
39 */
40 public MaxPointFilter(final long maxPoints)
41 {
42 super();
43 this.maxPoints = maxPoints;
44 }
45
46 /***
47 * @see nl.tudelft.simulation.language.filters.AbstractFilter#filter(java.lang.Object)
48 */
49 protected synchronized boolean filter(final Object entry)
50 {
51 this.accepted++;
52 if (this.accepted > this.maxPoints)
53 {
54 return false;
55 }
56 return true;
57 }
58
59 /***
60 * @see nl.tudelft.simulation.language.filters.Filterinterface#getCriterium()
61 */
62 public String getCriterium()
63 {
64 return "accepts the first MaxPoint(=" + this.maxPoints + ") entries";
65 }
66 }