Generated on Fri Oct 6 16:26:43 2006 for Gecode/J by doxygen 1.4.7

FailureNode.java

Go to the documentation of this file.
00001 /*
00002  *  Main authors:
00003  *     Guido Tack <tack@gecode.org>
00004  *
00005  *  Copyright:
00006  *     Guido Tack, 2006
00007  *
00008  *  Last modified:
00009  *     $Date: 2006-02-09 16:32:56 +0100 (Thu, 09 Feb 2006) $ by $Author: tack $
00010  *     $Revision: 2943 $
00011  *
00012  *  This file is part of Gecode, the generic constraint
00013  *  development environment:
00014  *     http://www.gecode.org
00015  *
00016  *  See the file "LICENSE" for information on usage and
00017  *  redistribution of this file, and for a
00018  *     DISCLAIMER OF ALL WARRANTIES.
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 //         x_coord += xoff;
00058 //         Iterator childrenIterator = children.iterator();
00059 //         while (childrenIterator.hasNext()) {
00060 //             UINode child = (UINode) childrenIterator.next();
00061 //             child.move(xoff);
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 }