FailureNode.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 FailureNode extends GraphicsNode {
00029
00030 private final int failedWidth = (unit*14)/20;
00031 private final int halfFailedWidth = failedWidth / 2;
00032
00033 public FailureNode() {}
00034
00035 public void draw(Graphics2D g2, int x, int y, boolean hasShadow) {
00036 if (hasShadow) {
00037 int sx = x+shadowOff; int sy = y+shadowOff;
00038 Rectangle rect = new Rectangle(sx-halfFailedWidth, sy,
00039 failedWidth, failedWidth);
00040 g2.setPaint(shadow);
00041 g2.fill(rect);
00042
00043 g2.setPaint(shadow);
00044 g2.setStroke(stroke);
00045 g2.draw(rect);
00046 }
00047 Rectangle rect = new Rectangle(x-halfFailedWidth, y,
00048 failedWidth, failedWidth);
00049 g2.setPaint(red);
00050 g2.fill(rect);
00051
00052 g2.setPaint(fg);
00053 g2.setStroke(stroke);
00054 g2.draw(rect);
00055 }
00056 public void move(int xoff) {
00057
00058
00059
00060
00061
00062
00063 }
00064 public void connect(Graphics2D g2,
00065 int x, int y,
00066 int child_x, int child_y) {
00067 g2.setPaint(fg);
00068 g2.setStroke(stroke);
00069 g2.draw(new Line2D.Double(x, y, child_x, child_y));
00070 }
00071
00072 Point getConnector(int x, int y) {
00073 return new Point(x, y);
00074 }
00075
00076 public boolean containsPoint(Coordinate c) {
00077 int x = c.x();
00078 int y = c.y();
00079
00080 return (x<=halfFailedWidth &&
00081 x>=-halfFailedWidth &&
00082 y<=failedWidth &&
00083 y>=0);
00084 }
00085 }