View Javadoc

1   package org.sat4j.sat.visu;
2   
3   import info.monitorenter.gui.chart.ITracePoint2D;
4   import info.monitorenter.gui.chart.pointpainters.APointPainter;
5   
6   import java.awt.Graphics;
7   
8   public class PointPainterPlus extends APointPainter<PointPainterPlus> {
9   
10      /**
11  	 * 
12  	 */
13      private static final long serialVersionUID = 1L;
14  
15      /**
16       * The size of the plus point in pixels
17       */
18      private int plusSize;
19  
20      private static final int DEFAULT_SIZE = 6;
21  
22      /**
23       * Creates an instance with a default plus size of 4.
24       * <p>
25       */
26      public PointPainterPlus(int plusSize) {
27          this.plusSize = plusSize;
28      }
29  
30      /**
31       * Creates an instance with the given plus size.
32       * 
33       * @param plusSize
34       *            the plus size in pixel to use.
35       */
36      public PointPainterPlus() {
37          this.plusSize = DEFAULT_SIZE;
38      }
39  
40      /**
41       * @see info.monitorenter.gui.chart.pointpainters.APointPainter#equals(java.lang.Object)
42       */
43      @Override
44      public boolean equals(final Object obj) {
45          if (this == obj) {
46              return true;
47          }
48          if (!super.equals(obj)) {
49              return false;
50          }
51          if (this.getClass() != obj.getClass()) {
52              return false;
53          }
54          final PointPainterPlus other = (PointPainterPlus) obj;
55          if (this.plusSize != other.plusSize) {
56              return false;
57          }
58          return true;
59      }
60  
61      /**
62       * @see info.monitorenter.gui.chart.pointpainters.APointPainter#hashCode()
63       */
64      @Override
65      public int hashCode() {
66          final int prime = 31;
67          int result = super.hashCode();
68          result = prime * result + this.plusSize;
69          return result;
70      }
71  
72      /**
73       * @see info.monitorenter.gui.chart.IPointPainter#paintPoint(int, int, int,
74       *      int, java.awt.Graphics, info.monitorenter.gui.chart.ITracePoint2D)
75       */
76      public void paintPoint(final int absoluteX, final int absoluteY,
77              final int nextX, final int nextY, final Graphics g,
78              final ITracePoint2D original) {
79          g.drawLine(absoluteX - this.plusSize / 2, absoluteY, absoluteX
80                  + this.plusSize / 2, absoluteY);
81          g.drawLine(absoluteX, absoluteY - this.plusSize / 2, absoluteX,
82                  absoluteY + this.plusSize / 2);
83      }
84  
85      /**
86       * Returns the size of the plus point in pixels
87       * <p>
88       * 
89       * @return the size of the plus point in pixels
90       */
91      public int getPlusSize() {
92          return this.plusSize;
93      }
94  
95      /**
96       * Sets the size of the plus point in pixels
97       * 
98       * @param plusSize
99       *            the size of the plus point in pixels
100      */
101     public void setPlusSize(int plusSize) {
102         this.plusSize = plusSize;
103     }
104 
105 }