/* * Point.java * * Created on July 5, 2002, 4:46 PM */ package uk.ac.leeds.ccg.projects.MedAction.FuzzyInference; /** * * a fuzzy point is simply a double x, y value point which is the value in fuzzy variable definition, * but with a Color member as * the attribute for being painted in FuzzyPanel. when a point is being selected * it will be set by another color for showing being selected in fuzzy panel, fuzzy panel's * custamized paintComponent() method will take every point's color and use it to paint them. * please be aware that the point x, y value is not the position in a fuzzy panel, but the * position value in a theriotical fuzzy variable value space. fuzzy panel will get the x, y value * and calculate the screen position in fuzzy panel. * * @author jianhui jin */ import java.awt.Color; import java.awt.geom.Point2D; public class FuzzyPoint extends java.awt.geom.Point2D.Double implements java.io.Serializable { // color for this point to be painted in a fuzzyPanel, private Color color = Color.black; /** Creates a new instance of Point */ public FuzzyPoint(){ super(); } /** * create a fuzzy point with double value x, y, fuzzy point * the value is not the screen position, is the value in fuzzy variable definition. * @param x * @param y */ public FuzzyPoint( double x, double y ) { super( x, y ); } /** * set the point location in a fuzzy variable * @param x * @param y */ public void setLocation( double x, double y ) { super.setLocation( x, y ); } /** * calculate the distance between two fuzzy points in fuzzy variable space. * @param p1 * @param p2 * @return a double value */ public static double distance( Point2D p1, Point2D p2 ) { return Math.sqrt( ( p1.getX() - p2.getX() ) * ( p1.getX() - p2.getX() ) + ( p1.getY() - p2.getY() ) * ( p1.getY() - p2.getY() ) ); } /** * get double value x * @return */ public double getX() { return super.getX(); } /** * get double value y * @return */ public double getY() { return super.getY();} /** * set double value x * @param x */ public void setX( double x ) { super.setLocation( x, getY() ); } /** * set double value y * @param y */ public void setY( double y ) { super.setLocation( getX(), y ); } /** * get the color of this point * @return an Color Object */ public Color getColor() { return color; } /** * set the color of this point * @param color */ public void setColor( Color color ) { this.color = color; } }