SuccessNode.java
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 package org.gecode.explorer.swing;
00023
00024 import java.awt.*;
00025 import java.awt.geom.*;
00026 import org.gecode.explorer.*;
00027
00028 class SuccessNode extends GraphicsNode {
00029
00030 static int x1Points[] = {0, halfUnit, 0, -halfUnit};
00031 static int y1Points[] = {0, halfUnit, unit, halfUnit};
00032 static GeneralPath diamond = new GeneralPath(GeneralPath.WIND_NON_ZERO,
00033 x1Points.length);
00034 static {
00035 diamond.moveTo(x1Points[0], y1Points[0]);
00036 for ( int index = 1; index < x1Points.length; index++ ) {
00037 diamond.lineTo(x1Points[index], y1Points[index]);
00038 };
00039 diamond.closePath();
00040 }
00041
00042 public SuccessNode() {}
00043
00044 public void draw(Graphics2D g2, int x, int y, boolean hasShadow) {
00045 if (hasShadow) {
00046 int sx = x+shadowOff; int sy = y+shadowOff;
00047
00048 int x1Points[] = {sx, sx+halfUnit, sx, sx-halfUnit};
00049 int y1Points[] = {sy, sy+halfUnit, sy+unit, sy+halfUnit};
00050 GeneralPath diamond = new GeneralPath(GeneralPath.WIND_NON_ZERO,
00051 x1Points.length);
00052 diamond.moveTo(x1Points[0], y1Points[0]);
00053 for ( int index = 1; index < x1Points.length; index++ ) {
00054 diamond.lineTo(x1Points[index], y1Points[index]);
00055 };
00056 diamond.closePath();
00057 g2.setPaint(shadow);
00058 g2.fill(diamond);
00059
00060 g2.setPaint(shadow);
00061 g2.setStroke(stroke);
00062 g2.draw(diamond);
00063 }
00064
00065
00066 int x1Points[] = {x, x+halfUnit, x, x-halfUnit};
00067 int y1Points[] = {y, y+halfUnit, y+unit, y+halfUnit};
00068 GeneralPath diamond = new GeneralPath(GeneralPath.WIND_NON_ZERO,
00069 x1Points.length);
00070 diamond.moveTo(x1Points[0], y1Points[0]);
00071 for ( int index = 1; index < x1Points.length; index++ ) {
00072 diamond.lineTo(x1Points[index], y1Points[index]);
00073 };
00074 diamond.closePath();
00075 g2.setPaint(green);
00076 g2.fill(diamond);
00077
00078 g2.setPaint(fg);
00079 g2.setStroke(stroke);
00080 g2.draw(diamond);
00081 }
00082 public void move(int xoff) {
00083
00084
00085
00086
00087
00088
00089 }
00090 public void connect(Graphics2D g2,
00091 int x, int y,
00092 int child_x, int child_y) {
00093 g2.setPaint(fg);
00094 g2.setStroke(stroke);
00095 g2.draw(new Line2D.Double(x, y, child_x, child_y));
00096 }
00097
00098 Point getConnector(int x, int y) {
00099 return new Point(x, y);
00100 }
00101
00102 public boolean containsPoint(Coordinate x) {
00103 return diamond.contains(new Point(x.x(), x.y()));
00104 }
00105 }