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      private static final int DEFAULT_SIZE = 6;
21  
22      /**
23       * Creates an instance with a default cross size of 4.
24       * <p>
25       */
26      public PointPainterCross(int crossSize) {
27          this.crossSize = crossSize;
28      }
29  
30      /**
31       * Creates an instance with the given cross size.
32       * 
33       * @param crossSize
34       *            the cross size in pixel to use.
35       */
36      public PointPainterCross() {
37          this.crossSize = 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 PointPainterCross other = (PointPainterCross) obj;
55          if (this.crossSize != other.crossSize) {
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.crossSize;
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.crossSize / 2, absoluteY - this.crossSize
80                  / 2, absoluteX + this.crossSize / 2, absoluteY + this.crossSize
81                  / 2);
82          g.drawLine(absoluteX - this.crossSize / 2, absoluteY + this.crossSize
83                  / 2, absoluteX + this.crossSize / 2, absoluteY - this.crossSize
84                  / 2);
85      }
86  
87      /**
88       * Returns the size of the cross point in pixels
89       * <p>
90       * 
91       * @return the size of the cross point in pixels
92       */
93      public int getCrossSize() {
94          return this.crossSize;
95      }
96  
97      /**
98       * Sets the size of the cross point in pixels
99       * 
100      * @param crossSize
101      *            the size of the cross point in pixels
102      */
103     public void setCrossSize(int crossSize) {
104         this.crossSize = crossSize;
105     }
106 
107 }