当前位置: 首页>>代码示例>>Java>>正文


Java JSlider.setPaintLabels方法代码示例

本文整理汇总了Java中javax.swing.JSlider.setPaintLabels方法的典型用法代码示例。如果您正苦于以下问题:Java JSlider.setPaintLabels方法的具体用法?Java JSlider.setPaintLabels怎么用?Java JSlider.setPaintLabels使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JSlider的用法示例。


在下文中一共展示了JSlider.setPaintLabels方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getControls

import javax.swing.JSlider; //导入方法依赖的package包/类
public Component getControls() {

      final JSlider slider = new JSlider(JSlider.HORIZONTAL,0,100,opacity);

      final HashMap<Integer,JLabel> labelTable = new HashMap<Integer,JLabel>();
      labelTable.put(0, new JLabel("Transparent"));
      labelTable.put(100, new JLabel("Opaque"));

      slider.setMajorTickSpacing(10);
      slider.setPaintTicks(true);
      // Note: JSlider uses the outdated Hashtable. Eventually Hashtable
      // will be deprecated and we'll be able to use the HashMap directly.
      slider.setLabelTable(new Hashtable<Integer,JLabel>(labelTable));
      slider.setPaintLabels(true);
      slider.setBorder(javax.swing.BorderFactory.createTitledBorder(name));
      slider.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
          final JSlider source = (JSlider) e.getSource();
          if (!source.getValueIsAdjusting()) {
            opacity = source.getValue();
          }
        }});

      return slider;
    }
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:26,代码来源:ZoneHighlight.java

示例2: setupInstance

import javax.swing.JSlider; //导入方法依赖的package包/类
protected void setupInstance(JSlider instance) {
    super.setupInstance(instance);
    
    instance.setPaintTicks(paintTicks);
    instance.setPaintTrack(paintTrack);
    instance.setPaintLabels(paintLabels);
    instance.setInverted(isInverted);
    if (sliderModel != null) instance.setModel(sliderModel.createInstance());
    instance.setMajorTickSpacing(majorTickSpacing);
    instance.setMinorTickSpacing(minorTickSpacing);
    instance.setSnapToTicks(snapToTicks);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:JComponentBuilders.java

示例3: getAnimationPanel

import javax.swing.JSlider; //导入方法依赖的package包/类
/**
 * Returns the frames-per-second slider for the animation dialog.
 */
final JPanel getAnimationPanel() {
    // lazily create the label
    if (this.animationPanel == null) {
        JLabel label = new JLabel("Animation Speed");
        label.setAlignmentX(Component.CENTER_ALIGNMENT);
        final JSlider slider = new JSlider(SwingConstants.HORIZONTAL, 1, 10, 2) {
            @Override
            public void updateUI() {
                setUI(BasicSliderUI.createUI(this));
            }
        };
        slider.setMajorTickSpacing(9);
        slider.setMinorTickSpacing(1);
        slider.setSnapToTicks(true);
        slider.setPaintTicks(true);
        slider.setPaintLabels(true);
        slider.setFocusable(false);
        slider.addChangeListener(new ChangeListener() {
            @Override
            public void stateChanged(ChangeEvent e) {
                int speed = slider.getValue();
                setSpeed(speed);
            }
        });
        slider.setAlignmentX(Component.CENTER_ALIGNMENT);
        this.animationPanel = new JPanel();
        this.animationPanel.setLayout(new BoxLayout(this.animationPanel, BoxLayout.Y_AXIS));
        this.animationPanel.add(label);
        this.animationPanel.add(slider);
    }
    return this.animationPanel;
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:36,代码来源:ExploreAction.java

示例4: PlayerControllPanel

import javax.swing.JSlider; //导入方法依赖的package包/类
/**
 * macht ein neues PlayerControllPanel
 * @param player : zu steuernder {@link MidiPlayer}
 */
public PlayerControllPanel(MidiPlayer player){
	super(new GridLayout(2,1));
	midiPlayer = player;
	midiPlayer.addObserver(this);
	panelNorth = new JPanel(new FlowLayout());
	ActionHandler aH = new ActionHandler();
	startButton = new JButton("Spielen");
	startButton.addActionListener(aH);
	pauseButton = new JButton("Pause");
	pauseButton.addActionListener(aH);
	stopButton = new JButton("Stop");
	stopButton.addActionListener(aH);
	playerTimeLabel = new JLabel();
	panelNorth.add(startButton);
	panelNorth.add(pauseButton);
	panelNorth.add(stopButton);
	panelNorth.add(playerTimeLabel);
	panelSouth = new JPanel(new FlowLayout());
	tempoSlider = new JSlider(60, 220, (int)midiPlayer.getTempoInBPM());
	tempoSlider.setMajorTickSpacing(40);
	tempoSlider.setMinorTickSpacing(10);
	tempoSlider.setPaintLabels(true);
	tempoSlider.setPaintTicks(true);
	tempoSlider.addChangeListener(new ChangeHandler());
	tempoLabel = new JLabel("Tempo in Beats pro Minute");
	panelSouth.add(tempoLabel);
	panelSouth.add(tempoSlider);
	this.add(panelNorth);
	this.add(panelSouth);
	//dis-/enable buttons depending on player state
	if(midiPlayer.isRunning()){
		startButton.setEnabled(false);
		pauseButton.setEnabled(true);
		stopButton.setEnabled(true);
	}else{
		stopButton.setEnabled(false);
		pauseButton.setEnabled(false);
		if(midiPlayer.sequenceLoaded()){
			startButton.setEnabled(true);
		}else{
			startButton.setEnabled(false);
		}
	}
}
 
开发者ID:Paulpanther,项目名称:Random-Music-Generator,代码行数:49,代码来源:PlayerControllPanel.java

示例5: RNNSearchDemo

import javax.swing.JSlider; //导入方法依赖的package包/类
public RNNSearchDemo() {
    super(new BorderLayout());

    startButton = new JButton("Start");
    startButton.setActionCommand("startButton");
    startButton.addActionListener(this);

    Hashtable<Integer, JLabel> logNLabelTable = new Hashtable<>();
    for (int i = 3; i <= 7; i++) {
        logNLabelTable.put(new Integer(i), new JLabel(String.valueOf(i)));
    }

    logNSlider = new JSlider(3, 7, logN);
    logNSlider.setLabelTable(logNLabelTable);
    logNSlider.setMajorTickSpacing(1);
    logNSlider.setPaintTicks(true);
    logNSlider.setPaintLabels(true);

    Hashtable<Integer, JLabel> dimensionLabelTable = new Hashtable<>();
    dimensionLabelTable.put(new Integer(2), new JLabel(String.valueOf(2)));
    for (int i = 20; i <= 120; i += 20) {
        dimensionLabelTable.put(new Integer(i), new JLabel(String.valueOf(i)));
    }

    dimensionSlider = new JSlider(2, 128, dimension);
    dimensionSlider.setLabelTable(dimensionLabelTable);
    dimensionSlider.setMajorTickSpacing(20);
    dimensionSlider.setMinorTickSpacing(5);
    dimensionSlider.setPaintTicks(true);
    dimensionSlider.setPaintLabels(true);

    radiusField = new JTextField(Double.toString(radius), 5);

    optionPane = new JPanel(new FlowLayout(FlowLayout.LEFT));
    optionPane.setBorder(BorderFactory.createRaisedBevelBorder());
    optionPane.add(startButton);
    optionPane.add(new JLabel("log N:"));
    optionPane.add(logNSlider);
    optionPane.add(new JLabel("Dimension:"));
    optionPane.add(dimensionSlider);
    optionPane.add(new JLabel("Radius:"));
    optionPane.add(radiusField);

    add(optionPane, BorderLayout.NORTH);

    canvas = new JPanel(new GridLayout(1, 2));
    canvas.setBackground(Color.WHITE);
    add(canvas, BorderLayout.CENTER);
}
 
开发者ID:takun2s,项目名称:smile_1.5.0_java7,代码行数:50,代码来源:RNNSearchDemo.java

示例6: NearestNeighborDemo

import javax.swing.JSlider; //导入方法依赖的package包/类
public NearestNeighborDemo() {
    super(new BorderLayout());

    startButton = new JButton("Start");
    startButton.setActionCommand("startButton");
    startButton.addActionListener(this);

    Hashtable<Integer, JLabel> logNLabelTable = new Hashtable<>();
    for (int i = 3; i <= 7; i++) {
        logNLabelTable.put(new Integer(i), new JLabel(String.valueOf(i)));
    }

    logNSlider = new JSlider(3, 7, logN);
    logNSlider.setLabelTable(logNLabelTable);
    logNSlider.setMajorTickSpacing(1);
    logNSlider.setPaintTicks(true);
    logNSlider.setPaintLabels(true);

    Hashtable<Integer, JLabel> dimensionLabelTable = new Hashtable<>();
    dimensionLabelTable.put(new Integer(2), new JLabel(String.valueOf(2)));
    for (int i = 20; i <= 120; i += 20) {
        dimensionLabelTable.put(new Integer(i), new JLabel(String.valueOf(i)));
    }

    dimensionSlider = new JSlider(2, 128, dimension);
    dimensionSlider.setLabelTable(dimensionLabelTable);
    dimensionSlider.setMajorTickSpacing(20);
    dimensionSlider.setMinorTickSpacing(5);
    dimensionSlider.setPaintTicks(true);
    dimensionSlider.setPaintLabels(true);

    optionPane = new JPanel(new FlowLayout(FlowLayout.LEFT));
    optionPane.setBorder(BorderFactory.createRaisedBevelBorder());
    optionPane.add(startButton);
    optionPane.add(new JLabel("log N:"));
    optionPane.add(logNSlider);
    optionPane.add(new JLabel("Dimension:"));
    optionPane.add(dimensionSlider);

    add(optionPane, BorderLayout.NORTH);

    canvas = new JPanel(new GridLayout(1, 2));
    canvas.setBackground(Color.WHITE);
    add(canvas, BorderLayout.CENTER);
}
 
开发者ID:takun2s,项目名称:smile_1.5.0_java7,代码行数:46,代码来源:NearestNeighborDemo.java

示例7: KNNDemo

import javax.swing.JSlider; //导入方法依赖的package包/类
public KNNDemo() {
    super(new BorderLayout());

    startButton = new JButton("Start");
    startButton.setActionCommand("startButton");
    startButton.addActionListener(this);

    Hashtable<Integer, JLabel> logNLabelTable = new Hashtable<>();
    for (int i = 3; i <= 7; i++) {
        logNLabelTable.put(new Integer(i), new JLabel(String.valueOf(i)));
    }

    logNSlider = new JSlider(3, 7, logN);
    logNSlider.setLabelTable(logNLabelTable);
    logNSlider.setMajorTickSpacing(1);
    logNSlider.setPaintTicks(true);
    logNSlider.setPaintLabels(true);

    Hashtable<Integer, JLabel> dimensionLabelTable = new Hashtable<>();
    dimensionLabelTable.put(new Integer(2), new JLabel(String.valueOf(2)));
    for (int i = 20; i <= 120; i += 20) {
        dimensionLabelTable.put(new Integer(i), new JLabel(String.valueOf(i)));
    }

    dimensionSlider = new JSlider(2, 128, dimension);
    dimensionSlider.setLabelTable(dimensionLabelTable);
    dimensionSlider.setMajorTickSpacing(20);
    dimensionSlider.setMinorTickSpacing(5);
    dimensionSlider.setPaintTicks(true);
    dimensionSlider.setPaintLabels(true);

    knnField = new JTextField(Integer.toString(knn), 5);

    optionPane = new JPanel(new FlowLayout(FlowLayout.LEFT));
    optionPane.setBorder(BorderFactory.createRaisedBevelBorder());
    optionPane.add(startButton);
    optionPane.add(new JLabel("log N:"));
    optionPane.add(logNSlider);
    optionPane.add(new JLabel("Dimension:"));
    optionPane.add(dimensionSlider);
    optionPane.add(new JLabel("K:"));
    optionPane.add(knnField);

    add(optionPane, BorderLayout.NORTH);

    canvas = new JPanel(new GridLayout(1, 2));
    canvas.setBackground(Color.WHITE);
    add(canvas, BorderLayout.CENTER);
}
 
开发者ID:takun2s,项目名称:smile_1.5.0_java7,代码行数:50,代码来源:KNNDemo.java

示例8: GaussianDistributionDemo

import javax.swing.JSlider; //导入方法依赖的package包/类
public GaussianDistributionDemo() {
    super(new BorderLayout());

    Hashtable<Integer, JLabel> labelTable = new Hashtable<>();
    for (int i = 0; i <= 50; i+=10) {
        labelTable.put(new Integer(i), new JLabel(String.valueOf(i/10)));
    }

    sigmaSlider = new JSlider(0, 50, (int) Math.round(sigma * 10));
    sigmaSlider.addChangeListener(this);
    sigmaSlider.setLabelTable(labelTable);
    sigmaSlider.setMajorTickSpacing(10);
    sigmaSlider.setMinorTickSpacing(2);
    sigmaSlider.setPaintTicks(true);
    sigmaSlider.setPaintLabels(true);

    optionPane = new JPanel(new FlowLayout(FlowLayout.LEFT));
    optionPane.setBorder(BorderFactory.createRaisedBevelBorder());
    optionPane.add(new JLabel("\u03C3:"));
    optionPane.add(sigmaSlider);

    add(optionPane, BorderLayout.NORTH);

    canvas = new JPanel(new GridLayout(2, 2));
    add(canvas, BorderLayout.CENTER);

    GaussianDistribution dist = new GaussianDistribution(0, sigma);

    double[][] p = new double[200][2];
    double[][] q = new double[200][2];
    for (int i = 0; i < p.length; i++) {
        p[i][0] = (i - 100) / 10.0;
        p[i][1] = dist.p(p[i][0]);
        q[i][0] = (i - 100) / 10.0;
        q[i][1] = dist.cdf(p[i][0]);
    }

    pdf = LinePlot.plot(p, Line.Style.SOLID, Color.BLUE);
    pdf.setTitle("PDF");
    canvas.add(pdf);

    cdf = LinePlot.plot(q, Line.Style.SOLID, Color.BLUE);
    cdf.setTitle("CDF");
    canvas.add(cdf);

    double[] data = new double[500];
    for (int i = 0; i < data.length; i++) {
        data[i] = dist.rand();
    }

    histogram = Histogram.plot(data, 20);
    histogram.setTitle("Histogram");
    canvas.add(histogram);

    qqplot = QQPlot.plot(data, dist);
    qqplot.setTitle("Q-Q Plot");
    canvas.add(qqplot);
}
 
开发者ID:takun2s,项目名称:smile_1.5.0_java7,代码行数:59,代码来源:GaussianDistributionDemo.java

示例9: WeibullDistributionDemo

import javax.swing.JSlider; //导入方法依赖的package包/类
public WeibullDistributionDemo() {
    super(new BorderLayout());

    Hashtable<Integer, JLabel> shapeLabelTable = new Hashtable<>();
    for (int i = 0; i <= 10; i+=2) {
        shapeLabelTable.put(new Integer(i), new JLabel(String.valueOf(i)));
    }

    shapeSlider = new JSlider(0, 10, (int) Math.round(shape));
    shapeSlider.addChangeListener(this);
    shapeSlider.setLabelTable(shapeLabelTable);
    shapeSlider.setMajorTickSpacing(2);
    shapeSlider.setMinorTickSpacing(1);
    shapeSlider.setPaintTicks(true);
    shapeSlider.setPaintLabels(true);

    Hashtable<Integer, JLabel> scaleLabelTable = new Hashtable<>();
    for (int i = 0; i <= 50; i+=10) {
        scaleLabelTable.put(new Integer(i), new JLabel(String.valueOf(i/10)));
    }

    scaleSlider = new JSlider(0, 50, (int) Math.round(scale*10));
    scaleSlider.addChangeListener(this);
    scaleSlider.setLabelTable(scaleLabelTable);
    scaleSlider.setMajorTickSpacing(10);
    scaleSlider.setMinorTickSpacing(2);
    scaleSlider.setPaintTicks(true);
    scaleSlider.setPaintLabels(true);

    optionPane = new JPanel(new FlowLayout(FlowLayout.LEFT));
    optionPane.setBorder(BorderFactory.createRaisedBevelBorder());
    optionPane.add(new JLabel("Shape:"));
    optionPane.add(shapeSlider);
    optionPane.add(new JLabel("Scale:"));
    optionPane.add(scaleSlider);

    add(optionPane, BorderLayout.NORTH);

    canvas = new JPanel(new GridLayout(2, 2));
    add(canvas, BorderLayout.CENTER);

    WeibullDistribution dist = new WeibullDistribution(shape, scale);

    double[][] p = new double[100][2];
    double[][] q = new double[100][2];
    for (int i = 0; i < p.length; i++) {
        p[i][0] = i / 20.0;
        p[i][1] = dist.p(p[i][0]);
        q[i][0] = i / 20.0;
        q[i][1] = dist.cdf(p[i][0]);
    }

    pdf = LinePlot.plot(p, Line.Style.SOLID, Color.BLUE);
    pdf.setTitle("PDF");
    canvas.add(pdf);

    cdf = LinePlot.plot(q, Line.Style.SOLID, Color.BLUE);
    cdf.setTitle("CDF");
    canvas.add(cdf);

    double[] data = new double[500];
    for (int i = 0; i < data.length; i++) {
        data[i] = dist.rand();
    }

    histogram = Histogram.plot(data, 20);
    histogram.setTitle("Histogram");
    canvas.add(histogram);

    qqplot = QQPlot.plot(data, dist);
    qqplot.setTitle("Q-Q Plot");
    canvas.add(qqplot);
}
 
开发者ID:takun2s,项目名称:smile_1.5.0_java7,代码行数:74,代码来源:WeibullDistributionDemo.java

示例10: ExponentialDistributionDemo

import javax.swing.JSlider; //导入方法依赖的package包/类
public ExponentialDistributionDemo() {
    super(new BorderLayout());

    Hashtable<Integer, JLabel> labelTable = new Hashtable<>();
    for (int i = 0; i <= 50; i+=10) {
        labelTable.put(new Integer(i), new JLabel(String.valueOf(i/10)));
    }

    lambdaSlider = new JSlider(0, 50, (int) Math.round(lambda * 10));
    lambdaSlider.addChangeListener(this);
    lambdaSlider.setLabelTable(labelTable);
    lambdaSlider.setMajorTickSpacing(10);
    lambdaSlider.setMinorTickSpacing(2);
    lambdaSlider.setPaintTicks(true);
    lambdaSlider.setPaintLabels(true);

    optionPane = new JPanel(new FlowLayout(FlowLayout.LEFT));
    optionPane.setBorder(BorderFactory.createRaisedBevelBorder());
    optionPane.add(new JLabel("\u03BB:"));
    optionPane.add(lambdaSlider);

    add(optionPane, BorderLayout.NORTH);

    canvas = new JPanel(new GridLayout(2, 2));
    add(canvas, BorderLayout.CENTER);

    ExponentialDistribution dist = new ExponentialDistribution(lambda);

    double[][] p = new double[100][2];
    double[][] q = new double[100][2];
    for (int i = 0; i < p.length; i++) {
        p[i][0] = i / 20.0;
        p[i][1] = dist.p(p[i][0]);
        q[i][0] = i / 20.0;
        q[i][1] = dist.cdf(p[i][0]);
    }

    pdf = LinePlot.plot(p, Line.Style.SOLID, Color.BLUE);
    pdf.setTitle("PDF");
    canvas.add(pdf);

    cdf = LinePlot.plot(q, Line.Style.SOLID, Color.BLUE);
    cdf.setTitle("CDF");
    canvas.add(cdf);

    double[] data = new double[500];
    for (int i = 0; i < data.length; i++) {
        data[i] = dist.rand();
    }

    histogram = Histogram.plot(data, 20);
    histogram.setTitle("Histogram");
    canvas.add(histogram);

    qqplot = QQPlot.plot(data, dist);
    qqplot.setTitle("Q-Q Plot");
    canvas.add(qqplot);
}
 
开发者ID:takun2s,项目名称:smile_1.5.0_java7,代码行数:59,代码来源:ExponentialDistributionDemo.java

示例11: BetaDistributionDemo

import javax.swing.JSlider; //导入方法依赖的package包/类
public BetaDistributionDemo() {
    super(new BorderLayout());

    Hashtable<Integer, JLabel> labelTable = new Hashtable<>();
    for (int i = 0; i <= 100; i+=20) {
        labelTable.put(new Integer(i), new JLabel(String.valueOf(i / 10)));
    }

    alphaSlider = new JSlider(0, 100, (int) Math.round(alpha * 10));
    alphaSlider.addChangeListener(this);
    alphaSlider.setLabelTable(labelTable);
    alphaSlider.setMajorTickSpacing(10);
    alphaSlider.setMinorTickSpacing(2);
    alphaSlider.setPaintTicks(true);
    alphaSlider.setPaintLabels(true);

    betaSlider = new JSlider(0, 100, (int) Math.round(beta * 10));
    betaSlider.addChangeListener(this);
    betaSlider.setLabelTable(labelTable);
    betaSlider.setMajorTickSpacing(10);
    betaSlider.setMinorTickSpacing(2);
    betaSlider.setPaintTicks(true);
    betaSlider.setPaintLabels(true);

    optionPane = new JPanel(new FlowLayout(FlowLayout.LEFT));
    optionPane.setBorder(BorderFactory.createRaisedBevelBorder());
    optionPane.add(new JLabel("\u03B1:"));
    optionPane.add(alphaSlider);
    optionPane.add(new JLabel("\u03B2:"));
    optionPane.add(betaSlider);

    add(optionPane, BorderLayout.NORTH);

    canvas = new JPanel(new GridLayout(2, 2));
    add(canvas, BorderLayout.CENTER);

    BetaDistribution dist = new BetaDistribution(alpha, beta);

    double[][] p = new double[99][2];
    double[][] q = new double[99][2];
    for (int i = 0; i < p.length; i++) {
        p[i][0] = (i+1) / 100.0;
        p[i][1] = dist.p(p[i][0]);
        q[i][0] = (i+1) / 100.0;
        q[i][1] = dist.cdf(p[i][0]);
    }

    pdf = LinePlot.plot(p, Line.Style.SOLID, Color.BLUE);
    pdf.setTitle("PDF");
    canvas.add(pdf);

    cdf = LinePlot.plot(q, Line.Style.SOLID, Color.BLUE);
    cdf.setTitle("CDF");
    canvas.add(cdf);

    double[] data = new double[500];
    for (int i = 0; i < data.length; i++) {
        data[i] = dist.rand();
    }

    histogram = Histogram.plot(data, 20);
    histogram.setTitle("Histogram");
    canvas.add(histogram);

    qqplot = QQPlot.plot(data, dist);
    qqplot.setTitle("Q-Q Plot");
    canvas.add(qqplot);
}
 
开发者ID:takun2s,项目名称:smile_1.5.0_java7,代码行数:69,代码来源:BetaDistributionDemo.java

示例12: FDistributionDemo

import javax.swing.JSlider; //导入方法依赖的package包/类
public FDistributionDemo() {
    super(new BorderLayout());

    Hashtable<Integer, JLabel> labelTable = new Hashtable<>();
    labelTable.put(1, new JLabel(String.valueOf(1)));
    for (int i = 20; i <= 100; i += 20) {
        labelTable.put(new Integer(i), new JLabel(String.valueOf(i)));
    }

    d1Slider = new JSlider(1, 100, d1);
    d1Slider.addChangeListener(this);
    d1Slider.setLabelTable(labelTable);
    d1Slider.setMajorTickSpacing(10);
    d1Slider.setMinorTickSpacing(2);
    d1Slider.setPaintTicks(true);
    d1Slider.setPaintLabels(true);

    d2Slider = new JSlider(1, 100, d2);
    d2Slider.addChangeListener(this);
    d2Slider.setLabelTable(labelTable);
    d2Slider.setMajorTickSpacing(10);
    d2Slider.setMinorTickSpacing(2);
    d2Slider.setPaintTicks(true);
    d2Slider.setPaintLabels(true);

    optionPane = new JPanel(new FlowLayout(FlowLayout.LEFT));
    optionPane.setBorder(BorderFactory.createRaisedBevelBorder());
    optionPane.add(new JLabel("Degree of Freedom 1:"));
    optionPane.add(d1Slider);
    optionPane.add(new JLabel("Degree of Freedom 2:"));
    optionPane.add(d2Slider);

    add(optionPane, BorderLayout.NORTH);

    canvas = new JPanel(new GridLayout(2, 2));
    add(canvas, BorderLayout.CENTER);

    FDistribution dist = new FDistribution(d1, d2);

    double[][] p = new double[100][2];
    double[][] q = new double[100][2];
    for (int i = 0; i < p.length; i++) {
        p[i][0] = (i+1) / 20.0;
        p[i][1] = dist.p(p[i][0]);
        q[i][0] = (i+1) / 20.0;
        q[i][1] = dist.cdf(p[i][0]);
    }

    pdf = LinePlot.plot(p, Line.Style.SOLID, Color.BLUE);
    pdf.setTitle("PDF");
    canvas.add(pdf);

    cdf = LinePlot.plot(q, Line.Style.SOLID, Color.BLUE);
    cdf.setTitle("CDF");
    canvas.add(cdf);

    double[] data = new double[500];
    for (int i = 0; i < data.length; i++) {
        data[i] = dist.rand();
    }

    histogram = Histogram.plot(data, 20);
    histogram.setTitle("Histogram");
    canvas.add(histogram);

    qqplot = QQPlot.plot(data, dist);
    qqplot.setTitle("Q-Q Plot");
    canvas.add(qqplot);
}
 
开发者ID:takun2s,项目名称:smile_1.5.0_java7,代码行数:70,代码来源:FDistributionDemo.java

示例13: MultivariateGaussianDistributionDemo

import javax.swing.JSlider; //导入方法依赖的package包/类
public MultivariateGaussianDistributionDemo() {
    super(new BorderLayout());

    Hashtable<Integer, JLabel> labelTable = new Hashtable<>();
    for (int i = 0; i <= 30; i+=10) {
        labelTable.put(new Integer(i), new JLabel(String.valueOf(i/10.0)));
    }

    sigma1Slider = new JSlider(0, 30, (int) (sigma[0]*10));
    sigma1Slider.addChangeListener(this);
    sigma1Slider.setLabelTable(labelTable);
    sigma1Slider.setMajorTickSpacing(10);
    sigma1Slider.setMinorTickSpacing(2);
    sigma1Slider.setPaintTicks(true);
    sigma1Slider.setPaintLabels(true);

    sigma2Slider = new JSlider(0, 30, (int) (sigma[1]*10));
    sigma2Slider.addChangeListener(this);
    sigma2Slider.setLabelTable(labelTable);
    sigma2Slider.setMajorTickSpacing(10);
    sigma2Slider.setMinorTickSpacing(2);
    sigma2Slider.setPaintTicks(true);
    sigma2Slider.setPaintLabels(true);

    optionPane = new JPanel();
    optionPane.setBorder(BorderFactory.createRaisedBevelBorder());
    optionPane.add(new JLabel("<html>\u03C3<sub>1</sub>:</html>"));
    optionPane.add(sigma1Slider);
    optionPane.add(new JLabel("<html>\u03C3<sub>2</sub>:</html>"));
    optionPane.add(sigma2Slider);

    add(optionPane, BorderLayout.NORTH);

    MultivariateGaussianDistribution g = new MultivariateGaussianDistribution(mu, sigma);

    for (int i = 0; i < m; i++) {
        for (int j = 0; j < n; j++) {
            z[i][j][0] = 6.0 * (i - m/2) / m;
            z[i][j][1] = 6.0 * (j - n/2) / n;
            double[] point = {z[i][j][0], z[i][j][1]};
            z[i][j][2] = g.p(point);
        }
    }

    pdf = Surface.plot(z);
    pdf.setTitle("Multivariate Gaussian");
    add(pdf, BorderLayout.CENTER);
}
 
开发者ID:takun2s,项目名称:smile_1.5.0_java7,代码行数:49,代码来源:MultivariateGaussianDistributionDemo.java

示例14: TDistributionDemo

import javax.swing.JSlider; //导入方法依赖的package包/类
public TDistributionDemo() {
    super(new BorderLayout());

    Hashtable<Integer, JLabel> labelTable = new Hashtable<>();
    labelTable.put(1, new JLabel(String.valueOf(1)));
    for (int i = 5; i <= 20; i += 5) {
        labelTable.put(new Integer(i), new JLabel(String.valueOf(i)));
    }

    nuSlider = new JSlider(1, 20, nu);
    nuSlider.addChangeListener(this);
    nuSlider.setLabelTable(labelTable);
    nuSlider.setMajorTickSpacing(5);
    nuSlider.setMinorTickSpacing(1);
    nuSlider.setPaintTicks(true);
    nuSlider.setPaintLabels(true);

    optionPane = new JPanel(new FlowLayout(FlowLayout.LEFT));
    optionPane.setBorder(BorderFactory.createRaisedBevelBorder());
    optionPane.add(new JLabel("Degree of Freedom:"));
    optionPane.add(nuSlider);

    add(optionPane, BorderLayout.NORTH);

    canvas = new JPanel(new GridLayout(2, 2));
    add(canvas, BorderLayout.CENTER);

    TDistribution dist = new TDistribution(nu);

    double[][] p = new double[100][2];
    double[][] q = new double[100][2];
    for (int i = 0; i < p.length; i++) {
        p[i][0] = (i - 50) / 10.0;
        p[i][1] = dist.p(p[i][0]);
        q[i][0] = (i - 50) / 10.0;
        q[i][1] = dist.cdf(p[i][0]);
    }

    pdf = LinePlot.plot(p, Line.Style.SOLID, Color.BLUE);
    pdf.setTitle("PDF");
    canvas.add(pdf);

    cdf = LinePlot.plot(q, Line.Style.SOLID, Color.BLUE);
    cdf.setTitle("CDF");
    canvas.add(cdf);

    double[] data = new double[500];
    for (int i = 0; i < data.length; i++) {
        data[i] = dist.rand();
    }

    histogram = Histogram.plot(data, 20);
    histogram.setTitle("Histogram");
    canvas.add(histogram);

    qqplot = QQPlot.plot(data, dist);
    qqplot.setTitle("Q-Q Plot");
    canvas.add(qqplot);
}
 
开发者ID:takun2s,项目名称:smile_1.5.0_java7,代码行数:60,代码来源:TDistributionDemo.java

示例15: GammaDistributionDemo

import javax.swing.JSlider; //导入方法依赖的package包/类
public GammaDistributionDemo() {
    super(new BorderLayout());

    Hashtable<Integer, JLabel> shapeLabelTable = new Hashtable<>();
    for (int i = 0; i <= 10; i+=2) {
        shapeLabelTable.put(new Integer(i), new JLabel(String.valueOf(i)));
    }

    shapeSlider = new JSlider(0, 10, (int) Math.round(shape));
    shapeSlider.addChangeListener(this);
    shapeSlider.setLabelTable(shapeLabelTable);
    shapeSlider.setMajorTickSpacing(2);
    shapeSlider.setMinorTickSpacing(1);
    shapeSlider.setPaintTicks(true);
    shapeSlider.setPaintLabels(true);

    Hashtable<Integer, JLabel> scaleLabelTable = new Hashtable<>();
    for (int i = 0; i <= 50; i+=10) {
        scaleLabelTable.put(new Integer(i), new JLabel(String.valueOf(i/10)));
    }

    scaleSlider = new JSlider(0, 50, (int) Math.round(scale*10));
    scaleSlider.addChangeListener(this);
    scaleSlider.setLabelTable(scaleLabelTable);
    scaleSlider.setMajorTickSpacing(10);
    scaleSlider.setMinorTickSpacing(2);
    scaleSlider.setPaintTicks(true);
    scaleSlider.setPaintLabels(true);

    optionPane = new JPanel(new FlowLayout(FlowLayout.LEFT));
    optionPane.setBorder(BorderFactory.createRaisedBevelBorder());
    optionPane.add(new JLabel("Shape:"));
    optionPane.add(shapeSlider);
    optionPane.add(new JLabel("Scale:"));
    optionPane.add(scaleSlider);

    add(optionPane, BorderLayout.NORTH);

    canvas = new JPanel(new GridLayout(2, 2));
    add(canvas, BorderLayout.CENTER);

    GammaDistribution dist = new GammaDistribution(shape, scale);

    double[][] p = new double[100][2];
    double[][] q = new double[100][2];
    for (int i = 0; i < p.length; i++) {
        p[i][0] = i / 5.0;
        p[i][1] = dist.p(p[i][0]);
        q[i][0] = i / 5.0;
        q[i][1] = dist.cdf(p[i][0]);
    }

    pdf = LinePlot.plot(p, Line.Style.SOLID, Color.BLUE);
    pdf.setTitle("PDF");
    canvas.add(pdf);

    cdf = LinePlot.plot(q, Line.Style.SOLID, Color.BLUE);
    cdf.setTitle("CDF");
    canvas.add(cdf);

    double[] data = new double[500];
    for (int i = 0; i < data.length; i++) {
        data[i] = dist.rand();
    }

    histogram = Histogram.plot(data, 20);
    histogram.setTitle("Histogram");
    canvas.add(histogram);

    qqplot = QQPlot.plot(data, dist);
    qqplot.setTitle("Q-Q Plot");
    canvas.add(qqplot);
}
 
开发者ID:takun2s,项目名称:smile_1.5.0_java7,代码行数:74,代码来源:GammaDistributionDemo.java


注:本文中的javax.swing.JSlider.setPaintLabels方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。