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

ChoiceNode.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 org.gecode.explorer.Coordinate;
00025 import java.awt.*;
00026 import java.awt.geom.*;
00027 
00028 class ChoiceNode extends GraphicsNode {
00029 
00030     static Ellipse2D.Double ellipse = new Ellipse2D.Double(-halfUnit, 0,
00031                                                            unit, unit);
00032 
00033     public ChoiceNode() {}
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             Ellipse2D.Double myEllipse = new Ellipse2D.Double(sx-halfUnit, sy,
00039                                                               unit, unit);
00040             g2.setPaint(shadow);
00041             g2.fill(myEllipse);
00042             g2.setStroke(stroke);
00043             g2.draw(myEllipse);
00044         }
00045         Ellipse2D.Double myEllipse = new Ellipse2D.Double(x-halfUnit, y,
00046                                                           unit, unit);
00047         g2.setPaint(blue);
00048         g2.fill(myEllipse);
00049 
00050         g2.setPaint(fg);
00051         g2.setStroke(stroke);
00052         g2.draw(myEllipse);
00053     }
00054     public void move(int xoff) {
00055 //         x_coord += xoff;
00056 //         Iterator childrenIterator = children.iterator();
00057 //         while (childrenIterator.hasNext()) {
00058 //             UINode child = (UINode) childrenIterator.next();
00059 //             child.move(xoff);
00060 //         }
00061 //         myEllipse.setFrameFromDiagonal(x_coord-10, y_coord,
00062 //                                        x_coord+10, y_coord+20);
00063     }
00064     public void connect(Graphics2D g2, int x, int y,
00065                         int child_x, int child_y) {
00066         g2.setPaint(fg);
00067         g2.setStroke(stroke);
00068         
00069         g2.draw(new Line2D.Double(x, y+unit, child_x, child_y));
00070     }
00071 
00072     Point getConnector(int x, int y) {
00073         return new Point(x, y+unit);
00074     }
00075 
00076 
00077     public boolean containsPoint(Coordinate x) {
00078         return ellipse.contains(new Point(x.x(), x.y()));
00079     }
00080 }