本文整理汇总了Java中javax.swing.JSlider.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java JSlider.getValue方法的具体用法?Java JSlider.getValue怎么用?Java JSlider.getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JSlider
的用法示例。
在下文中一共展示了JSlider.getValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sliderStateChanged
import javax.swing.JSlider; //导入方法依赖的package包/类
/**
* when slider is moved, event is sent here. The slider is the 'master' of the value in the text field.
* Slider is linear scale, from pot min to pot max
*
* @param e
* the ChangeEvent
*/
private void sliderStateChanged(javax.swing.event.ChangeEvent evt) {// GEN-FIRST:event_sliderStateChanged
if (sliderDontProcess) {
return;
}
// we can get a double send here if user presses uparrow key, resulting in new pot value,
// which updates the slider position, which ends up with a different bitvalue that makes a new
// pot value.
// See http://java.sun.com/docs/books/tutorial/uiswing/components/slider.html
// System.out.println("slider state changed");
// slider is only source of ChangeEvents
JSlider s = (JSlider) evt.getSource();
// System.out.println("slider state changed for "+pot);
int v = s.getValue(); // slider value
if (v == 0) {
pot.setBitValue(0); // these pot chanages will come back to us as Observer events
// a problem because they will updateAappearance, which will change slider state
// and generate possibly a new slider changeevent
}
else {
v = sliderValueFromBitValue(s);
pot.setBitValue(v);
}
}
示例2: sliderStateChanged
import javax.swing.JSlider; //导入方法依赖的package包/类
/** when slider is moved, event is sent here. The slider is the 'master' of the value in the text field.
* Slider is linear scale, from pot min to pot max
* @param e the ChangeEvent
*/
private void sliderStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_sliderStateChanged
if(sliderDontProcess) return;
// we can get a double send here if user presses uparrow key, resulting in new pot value,
// which updates the slider position, which ends up with a different bitvalue that makes a new
// pot value.
//See http://java.sun.com/docs/books/tutorial/uiswing/components/slider.html
// System.out.println("slider state changed");
// slider is only source of ChangeEvents
JSlider s = (JSlider) evt.getSource();
// System.out.println("slider state changed for "+pot);
int v = (int) s.getValue(); // slider value
if (v == 0) {
pot.setBitValue(0); // these pot chanages will come back to us as Observer events
// a problem because they will updateAappearance, which will change slider state
// and generate possibly a new slider changeevent
} else {
v = sliderValueFromBitValue(s);
pot.setBitValue(v);
}
}
示例3: stateChanged
import javax.swing.JSlider; //导入方法依赖的package包/类
@Override
public void stateChanged(ChangeEvent e) {
JSlider source = (JSlider)e.getSource();
if (!source.getValueIsAdjusting()) {
int fps = source.getValue();
String varName = source.getName();
//regenerate data set and repaint
int i;
for( i = 1; i<vars.size();i++)
if(vars.get(i).contentEquals(varName))
break;
varsValues.set(i,rangesLeft.get(i).add(steps.get(i).multiply(new BigDecimal(fps))));
//System.out.println(i);
String chartName=FunctionToPlot;
for(int j = 1; j < vars.size();j++){
chartName = SmartReplace.get(chartName,vars.get(j),varsValues.get(j).toPlainString());
//chartName = chartName.replace(vars.get(j),varsValues.get(j).toPlainString());
sliderLabels[j-1].setText(vars.get(j)+'='+varsValues.get(j).toPlainString());
}
try{
chartP.setChart(createChart(getDataset(),chartName));
}
catch(Exception ex){
System.out.println(ex.getMessage());
}
// chartPanel = new ChartPanel(chart);
//contentPanel.repaint();
//this.repaint();
//this.setVisible(true);
}
//throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
示例4: stateChanged
import javax.swing.JSlider; //导入方法依赖的package包/类
@Override
public void stateChanged(ChangeEvent e) {
JSlider source = (JSlider)e.getSource();
if (!source.getValueIsAdjusting()) {
int fps = source.getValue();
String varName = source.getName();
//regenerate data set and repaint
int i;
for( i = 1; i<vars.size();i++)
if(vars.get(i).contentEquals(varName))
break;
varsValues.set(i,rangesLeft.get(i).add(steps.get(i).multiply(new BigDecimal(fps))));
//System.out.println(i);
String chartName=FunctionToPlot;
for(int j = 1; j < vars.size();j++){
chartName = SmartReplace.get(chartName,vars.get(j),varsValues.get(j).toPlainString());
//chartName = chartName.replace(vars.get(j),varsValues.get(j).toPlainString());
sliderLabels[j-1].setText(vars.get(j)+'='+varsValues.get(j).toPlainString());
}
try{
chartP.setChart(createPolarChart(getDataset(),chartName));
}
catch(Exception ex){
System.out.println(ex.getMessage());
}
// chartPanel = new ChartPanel(chart);
//contentPanel.repaint();
//this.repaint();
//this.setVisible(true);
}
}
示例5: createLabelField
import javax.swing.JSlider; //导入方法依赖的package包/类
public static JPanel createLabelField(String preText, String postText, JSlider s) {
JPanel p = new JPanel();
JSpinner spin = new JSpinner(new SpinnerNumberModel(s.getValue(), s.getMinimum(), s.getMaximum(), 1));
spin.addChangeListener(ce -> {s.setValue((Integer) spin.getValue());});
p.add(new JLabel(preText));
p.add(spin);
p.add(new JLabel(postText));
return p;
}
示例6: sliderVal2BitVal
import javax.swing.JSlider; //导入方法依赖的package包/类
/**
* Maps from linear slider to linear/exponential bit value.
*
* @param vmax max bit value.
* @param slider the slider.
* @return the bit value.
*/
private int sliderVal2BitVal(final int vmax, final JSlider slider) {
int v = 0;
final int s = slider.getValue();
final double sm = slider.getMaximum();
final double vm = vmax;
v = (int) Math.round((vm * s) / sm);
// log.info("sliderValue=" + s + " -> bitValue=" + v);
return v;
}
示例7: sliderStateChanged
import javax.swing.JSlider; //导入方法依赖的package包/类
/**
* when slider is moved, event is sent here. The slider is the 'master' of the value in the text field.
* Slider is log scale, from pot min to pot max with caveat that zero position is zero current (no current splitter
* outputs switched on) and rest of values are log scale from pot.getCurrentResolution to pot.getMaxCurrent
*
* @param e
* the ChangeEvent
*/
private void sliderStateChanged(final javax.swing.event.ChangeEvent evt) {// GEN-FIRST:event_sliderStateChanged
// we can get a double send here if user presses uparrow key,
// resulting in new pot value,
// which updates the slider position, which ends up with
// a different bitvalue that makes a new
// pot value.
// See http://java.sun.com/docs/books/tutorial/uiswing/components/slider.html
// System.out.println("slider state changed");
// slider is only source of ChangeEvents
final JSlider s = (JSlider) evt.getSource();
// System.out.println("slider state changed for "+pot);
// if(!s.getValueIsAdjusting()){
// startEdit();
// }
int v = s.getValue();
// System.out.println("v="+v+" "+evt.toString());
if (v == 0) {
pot.setBitValue(0); // these pot chanages will come back to us as Observer events
// a problem because they will updateAappearance, which will change slider state
// and generate possibly a new slider changeevent
}
else {
v = sliderValueFromBitValue(s);
pot.setBitValue(v);
}
// if(!s.getValueIsAdjusting()){
//// System.out.println("slider done");
// endEdit();
// }
}
示例8: setServo
import javax.swing.JSlider; //导入方法依赖的package包/类
void setServo (int servo,ChangeEvent evt){
if(hwInterface==null){
log.warning("interface is null");
return;
}
if ( !( evt.getSource() instanceof JSlider ) ){
log.warning("evt not from a slider: " + evt);
}
JSlider slider = (JSlider)evt.getSource();
if ( !liveSlidersEnabled && slider.getValueIsAdjusting() ){
return;
}
float f = (float)slider.getValue() / MAX_SLIDER;
if ( hwInterface == null ){
log.warning("null hardware interface");
return;
}
try{
if ( synchronizeCheckBox.isSelected() ){
setAllServos(f);
} else{
hwInterface.setServoValue(servo,f);
}
} catch ( HardwareInterfaceException e ){
e.printStackTrace();
}
}
示例9: sliderVal2BitVal
import javax.swing.JSlider; //导入方法依赖的package包/类
/** Maps from linear slider to linear/exponential bit value.
*
* @param vmax max bit value.
* @param slider the slider.au
* @return the bit value.
*/
private int sliderVal2BitVal(int vmax, JSlider slider) {
int v = 0;
float s = slider.getValue();
double sm = slider.getMaximum();
double vm = vmax;
v = (int) Math.round(vm*s/sm);
// log.info("sliderValue=" + s + " -> bitValue=" + v +" Max bit: "+vmax+" Max slider: "+sm);
return v;
}
示例10: sliderVal2BitVal
import javax.swing.JSlider; //导入方法依赖的package包/类
/** Maps from linear slider to linear/exponential bit value.
*
* @param vmax max bit value.
* @param slider the slider.
* @return the bit value.
*/
private int sliderVal2BitVal(int vmax, JSlider slider) {
int v = 0;
int s = slider.getValue();
double sm = slider.getMaximum();
double vm = vmax;
v = (int) Math.round(vm*s/sm);
// log.info("sliderValue=" + s + " -> bitValue=" + v);
return v;
}
示例11: sliderStateChanged
import javax.swing.JSlider; //导入方法依赖的package包/类
/** when slider is moved, event is sent here. The slider is the 'master' of the value in the text field.
* Slider is log scale, from pot min to pot max with caveat that zero position is zero current (no current splitter
* outputs switched on) and rest of values are log scale from pot.getCurrentResolution to pot.getMaxCurrent
* @param e the ChangeEvent
*/
private void sliderStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_sliderStateChanged
// we can get a double send here if user presses uparrow key,
// resulting in new pot value,
// which updates the slider position, which ends up with
// a different bitvalue that makes a new
// pot value.
//See http://java.sun.com/docs/books/tutorial/uiswing/components/slider.html
// System.out.println("slider state changed");
// slider is only source of ChangeEvents
JSlider s = (JSlider) evt.getSource();
// System.out.println("slider state changed for "+pot);
// if(!s.getValueIsAdjusting()){
// startEdit();
// }
int v = (int) s.getValue();
// System.out.println("v="+v+" "+evt.toString());
if (v == 0) {
pot.setBitValue(0); // these pot chanages will come back to us as Observer events
// a problem because they will updateAappearance, which will change slider state
// and generate possibly a new slider changeevent
} else {
v = sliderValueFromBitValue(s);
pot.setBitValue(v);
}
// if(!s.getValueIsAdjusting()){
//// System.out.println("slider done");
// endEdit();
// }
}
示例12: sliderVal2BitVal
import javax.swing.JSlider; //导入方法依赖的package包/类
/** Maps from linear slider to linear/exponential bit value.
*
* @param vmax max bit value.
* @param slider the slider.
* @return the bit value.
*/
private int sliderVal2BitVal(int vmax, JSlider slider) {
int v = 0;
int s = slider.getValue();
if (s < knee) {
v = s;
} else {
double sm = slider.getMaximum();
double vm = vmax;
v = (int) (knee - 1 + Math.round(Math.pow(2, (s - knee) * (log2(vm - (knee - 1))) / (sm - knee))));
}
// log.info("sliderValue=" + s + " -> bitValue=" + v);
return v;
}
示例13: debugCompareProfs
import javax.swing.JSlider; //导入方法依赖的package包/类
public void debugCompareProfs (List<Prof> profs) {
JSlider slider1 = new JSlider( SwingConstants.VERTICAL, -1, profs.size() - 1, 0 );
JSlider slider2 = new JSlider( SwingConstants.VERTICAL, -1, profs.size() - 1, 0 );
final Plot pot = new Plot( slider1, slider2 );
ChangeListener cl = new ChangeListener() {
@Override
public void stateChanged( ChangeEvent arg0 ) {
pot.toPaint.clear();
PaintThing.debug.clear();
pot.toPaint.add(""+profs.size());
if (slider1.getValue() == -1 || slider2.getValue() == -1 ) {
for (Prof p : profs)
PaintThing.debug (new Color(0,0,0,50), 1f, p);
pot.repaint();
return;
}
Prof p = profs.get(slider1.getValue()),
d = profs.get(slider2.getValue());
pot.toPaint.add( p );
pot.toPaint.add( d );
pot.toPaint.add("pair distance: "+
d.distance( p, false, true, true )
);
pot.repaint();
}
};
slider1.addChangeListener( cl );
slider2.addChangeListener( cl );
}
示例14: sliderValueFromBitValue
import javax.swing.JSlider; //导入方法依赖的package包/类
private int sliderValueFromBitValue(final JSlider s) {
return s.getValue();
}
示例15: sliderValueFromBitValue
import javax.swing.JSlider; //导入方法依赖的package包/类
private int sliderValueFromBitValue(JSlider s) {
double f = (double) s.getValue() / s.getMaximum(); // fraction of slider
int v = (int) Math.round(f * pot.getMaxBitValue());
return v;
}