99 lines
2.4 KiB
Java
99 lines
2.4 KiB
Java
package org.hwo.ui;
|
|
|
|
import java.awt.BorderLayout;
|
|
import java.awt.EventQueue;
|
|
|
|
import javax.swing.JFrame;
|
|
import javax.swing.JPanel;
|
|
import javax.swing.border.EmptyBorder;
|
|
|
|
import org.hwo.ui.diagram.CirclePlotPainter;
|
|
import org.hwo.ui.diagram.SimplePlotProvider;
|
|
|
|
import java.awt.GridBagLayout;
|
|
import java.awt.GridBagConstraints;
|
|
import java.awt.Color;
|
|
import java.awt.Font;
|
|
|
|
public class JUITest extends JFrame {
|
|
|
|
private JPanel contentPane;
|
|
private JDiagram diagram;
|
|
|
|
/**
|
|
* Launch the application.
|
|
*/
|
|
public static void main(String[] args) {
|
|
EventQueue.invokeLater(new Runnable() {
|
|
public void run() {
|
|
try {
|
|
JUITest frame = new JUITest();
|
|
frame.setVisible(true);
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Create the frame.
|
|
*/
|
|
public JUITest() {
|
|
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
setBounds(100, 100, 1111, 342);
|
|
contentPane = new JPanel();
|
|
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
|
|
setContentPane(contentPane);
|
|
GridBagLayout gbl_contentPane = new GridBagLayout();
|
|
gbl_contentPane.columnWidths = new int[]{186, 0};
|
|
gbl_contentPane.rowHeights = new int[]{0, 0};
|
|
gbl_contentPane.columnWeights = new double[]{1.0, Double.MIN_VALUE};
|
|
gbl_contentPane.rowWeights = new double[]{1.0, Double.MIN_VALUE};
|
|
contentPane.setLayout(gbl_contentPane);
|
|
|
|
diagram = new JDiagram();
|
|
diagram.setLabelFormatSpec("%.2f");
|
|
diagram.setNumLabels(6);
|
|
diagram.setFont(new Font("Nimbus Mono L", Font.PLAIN, 14));
|
|
GridBagConstraints gbc_diagram = new GridBagConstraints();
|
|
gbc_diagram.fill = GridBagConstraints.BOTH;
|
|
gbc_diagram.gridx = 0;
|
|
gbc_diagram.gridy = 0;
|
|
contentPane.add(diagram, gbc_diagram);
|
|
|
|
this.initialize();
|
|
}
|
|
|
|
private void initialize(){
|
|
SimplePlotProvider p = new SimplePlotProvider(2, 32);
|
|
|
|
Float f = 0.0f;
|
|
Float[] values = p.getMatrix()[0];
|
|
for (int i=0;i<p.getPoints();i++){
|
|
f += (float)(Math.random()-0.5f)*0.5f;
|
|
values[i] = f;
|
|
}
|
|
p.getColors()[0] = Color.BLUE;
|
|
|
|
values = p.getMatrix()[1];
|
|
for (int i=0;i<p.getPoints();i++){
|
|
if ((i&1) == 0){
|
|
f += (float)(Math.random()-0.5f)*0.5f;
|
|
values[i] = f;
|
|
} else {
|
|
values[i] = null;
|
|
}
|
|
}
|
|
|
|
diagram.getDiagram().setPlotPainter(new CirclePlotPainter());
|
|
diagram.getDiagram().setPlotProvider(p);
|
|
|
|
diagram.getDiagram().setYoffset(-3.0f);
|
|
diagram.getDiagram().setYscale(6.0f);
|
|
|
|
//diagram.getDiagram().autoScale();
|
|
}
|
|
|
|
}
|