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