本文整理匯總了Java中javax.swing.JSlider.getMaximum方法的典型用法代碼示例。如果您正苦於以下問題:Java JSlider.getMaximum方法的具體用法?Java JSlider.getMaximum怎麽用?Java JSlider.getMaximum使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.JSlider
的用法示例。
在下文中一共展示了JSlider.getMaximum方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: updateSliderSpacing
import javax.swing.JSlider; //導入方法依賴的package包/類
public void updateSliderSpacing(JSlider slider) {
int width = slider.getBounds().width;
int max = slider.getMaximum();
int spacing = 1;
int mode = 1;
double pxPerLabel = (double) width * spacing / max;
if (pxPerLabel <= 0) {
return;
}
while (pxPerLabel <= 30) {
if (mode == 1) {
spacing *= 2;
pxPerLabel *= 2;
mode = 2;
} else if (mode == 2) {
spacing = spacing * 5 / 2;
pxPerLabel *= 2.5;
mode = 5;
} else {
spacing *= 2;
pxPerLabel *= 2;
mode = 1;
}
}
slider.setMajorTickSpacing(spacing);
int min = slider.getMinimum();
if (min % spacing > 0) {
min += (spacing - (min % spacing));
}
slider.setLabelTable(slider.createStandardLabels(spacing, min));
}
示例2: 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;
}
示例3: bitVal2SliderVal
import javax.swing.JSlider; //導入方法依賴的package包/類
/**
* Maps from bit value to linear/log slider value.
*
* @param v bit value.
* @param vmax max bit value.
* @param slider the slider for the value.
* @return the correct slider value.
*/
private int bitVal2SliderVal(final int v, final int vmax, final JSlider slider) {
int s = 0;
final double sm = slider.getMaximum();
final double vm = vmax;
s = (int) Math.round((sm * v) / vm);
// log.info("bitValue=" + v + " -> sliderValue=" + s);
return s;
}
示例4: 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;
}
示例5: bitVal2SliderVal
import javax.swing.JSlider; //導入方法依賴的package包/類
/** Maps from bit value to linear/log slider value.
*
* @param v bit value.
* @param vmax max bit value.
* @param slider the slider for the value.
* @return the correct slider value.
*/
private int bitVal2SliderVal(int v, int vmax, JSlider slider) {
int s = 0;
double sm = slider.getMaximum();
double vm = vmax;
s = (int) Math.round(sm*v/vm);
//log.info("bitValue=" + v + " -> sliderValue=" + s);
return s;
}
示例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.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;
}
示例7: bitVal2SliderVal
import javax.swing.JSlider; //導入方法依賴的package包/類
/** Maps from bit value to linear/log slider value.
*
* @param v bit value.
* @param vmax max bit value.
* @param slider the slider for the value.
* @return the correct slider value.
*/
private int bitVal2SliderVal(int v, int vmax, JSlider slider) {
int s = 0;
double sm = slider.getMaximum();
double vm = vmax;
s = (int) Math.round(sm*v/vm);;
// log.info("bitValue=" + v + " -> sliderValue=" + s);
return s;
}
示例8: 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;
}
示例9: bitVal2SliderVal
import javax.swing.JSlider; //導入方法依賴的package包/類
/** Maps from bit value to linear/log slider value.
*
* @param v bit value.
* @param vmax max bit value.
* @param slider the slider for the value.
* @return the correct slider value.
*/
private int bitVal2SliderVal(int v, int vmax, JSlider slider) {
int s = 0;
if (v < knee) {
s = v;
} else {
double sm = slider.getMaximum();
double vm = vmax;
s = (int) (knee + Math.round((sm - knee) * log2((double) v - (knee - 1)) / log2(vm - (knee - 1))));
}
// log.info("bitValue=" + v + " -> sliderValue=" + s);
return s;
}
示例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();
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;
}
示例11: 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;
}
示例12: 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(Math.pow(2, f * pot.getNumBits())); // bit value is 2^(frac*Numbits)
return v;
}