⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 point.java

📁 一个k-means算法的改进。使用了模糊聚类的方法
💻 JAVA
字号:
package kc.test.fuzzy;

import java.awt.*;

/**
 * @author Thomas Neidhart, thomas.neidhart@gmail.com, all rights by Know-Center
 * Date: Aug 3, 2005
 *
 * Represents a point
 */
public class Point implements Comparable, Cloneable
{
    /**
     * The position of the point on the x-axis
     */
    protected int m_x;
    /**
     * Additional color information
     */
    protected Color m_c;

    /**
     * Create a new point object
     * @param x the position on the x-axis
     */
    public Point(int x) {
        m_x = x;
        // init all points to a gray color
        m_c = Color.gray;
    }

    /**
     * Create a new point object
     * @param x the position on the x-axis
     * @param c the color
     */
    public Point(int x, Color c) {
        m_x = x;
        // init all points to a gray color
        m_c = c;
    }

    /**
     * Get the value for x
     * @return x
     */
    public int getX() {
        return m_x;
    }

    /**
     * Set a new value for x
     * @param x new x value
     */
    public void setX(int x) {
        m_x = x;
    }

    /**
     * Get the actual color of this point
     * @return the color
     */
    public Color getColor() {
        return m_c;
    }

    /**
     * Set a new color
     * @param c new color
     */
    public void setColor(Color c) {
        m_c = c;
    }

    /**
     * Compare a point to another instance of type kc.test.fuzzy.kc.test.kmeans.Point
     * @param o the point to compare to
     * @return @see Comparable.compareTo
     */
    public int compareTo(Object o) {
        if (o == null) throw new NullPointerException();
        if (!(o instanceof Point)) throw new IllegalArgumentException("instance of type kc.test.fuzzy.kc.test.kmeans.Point required");
        return (m_x - ((Point) o).m_x);
    }

    /**
     * Override clone of Object to support cloning of array containing points
     * @return the cloned point
     */
    public Point clone() {
        Point p = null;
        try {
            p = (Point) super.clone();
        } catch (CloneNotSupportedException e) {}
        return p;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -