date.iterator.count.pic.PicTest Maven / Gradle / Ivy
package date.iterator.count.pic;
import java.awt.RenderingHints;
import java.util.List;
import date.iterator.count.isodata.Cluster;
import date.iterator.count.isodata.ISOData;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.FastScatterPlot;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;
public class PicTest extends ApplicationFrame {
/** A constant for the number of items in the sample dataset. */
private static final int COUNT = 500;
/** The data. */
private float[][] data = new float[2][COUNT];
private void populateData(int length) {
/*int expectK = 15; // 预期的聚类中心数目;
int totalLoopI = 10000; // 迭代运算的次数。
double theta_S = 1; //θS 一个类中样本距离分布的标准差阈值。类内最大标准差分量应小于 θs
double theta_c = 3; //θc 两个聚类中心间的最小距离,若小于此数,两个聚类需进行合并;
int initK = 5;
ISOData isoData = new ISOData(expectK, totalLoopI, theta_S, theta_c);
List clusters = isoData.calculate(initK, isoData.testPoints());*/
for (int i = 0; i < length; i++) {
final float x = (float) i;
this.data[0][i%COUNT] = x;
this.data[1][i%COUNT] = (float) Math.random() * COUNT;
}
}
/**
* Creates a new fast scatter plot demo.
*
* @param title the frame title.
*/
public PicTest(final String title) {
super(title);
populateData(1000);
final NumberAxis domainAxis = new NumberAxis("X");
domainAxis.setAutoRangeIncludesZero(false);
final NumberAxis rangeAxis = new NumberAxis("Y");
rangeAxis.setAutoRangeIncludesZero(false);
final FastScatterPlot plot = new FastScatterPlot(this.data, domainAxis, rangeAxis);
populateData(5000);
plot.setData(this.data);
final JFreeChart chart = new JFreeChart("Fast Scatter Plot", plot);
// chart.setLegend(null);
// force aliasing of the rendered content..
chart.getRenderingHints().put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
final ChartPanel panel = new ChartPanel(chart, true);
panel.setPreferredSize(new java.awt.Dimension(500, 270));
// panel.setHorizontalZoom(true);
// panel.setVerticalZoom(true);
panel.setMinimumDrawHeight(10);
panel.setMaximumDrawHeight(2000);
panel.setMinimumDrawWidth(20);
panel.setMaximumDrawWidth(2000);
setContentPane(panel);
}
/**
* Starting point for the demonstration application.
*
* @param args ignored.
*/
public static void main(final String[] args) {
final PicTest demo = new PicTest("Fast Scatter Plot Demo");
demo.pack();
RefineryUtilities.centerFrameOnScreen(demo);
demo.setVisible(true);
}
}