Subversion Repositories svn.mios

Compare Revisions

Ignore whitespace Rev 627 → Rev 628

/trunk/java/org/midibox/sidedit/gui/controls/SIDSysexParameterControlSlider.java
21,10 → 21,10
package org.midibox.sidedit.gui.controls;
 
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import java.awt.Dimension;
 
import javax.swing.JPanel;
import javax.swing.JSlider;
31,7 → 31,7
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
 
import org.midibox.sidedit.*;
import org.midibox.sidedit.SIDSysexParameterControl;
 
public class SIDSysexParameterControlSlider extends SIDSysexParameterControlGUI
implements ChangeListener, MouseWheelListener {
40,15 → 40,17
 
private JSlider slider;
 
public SIDSysexParameterControlSlider(SIDSysexParameterControl midiParameter,
JSlider slider, boolean showLabel, String labelLocation,
boolean valueBelow, boolean showValue) {
public SIDSysexParameterControlSlider(
SIDSysexParameterControl midiParameter, JSlider slider,
boolean showLabel, String labelLocation, boolean valueBelow,
boolean showValue) {
super(midiParameter, showLabel, labelLocation, valueBelow, showValue);
this.slider = slider;
slider.setMaximum(midiParameter.getMidiMaxValue()-midiParameter.getMidiMinValue());
slider.setMaximum(midiParameter.getMidiMaxValue()
- midiParameter.getMidiMinValue());
slider.setOpaque(false);
slider.setOrientation(JSlider.VERTICAL);
slider.setPreferredSize(new Dimension(20,80));
slider.setPreferredSize(new Dimension(20, 80));
JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0));
panel.setOpaque(false);
panel.add(slider);
58,9 → 60,9
slider.addMouseListener(this);
updateGraphics();
}
 
public void setHeight(int height) {
slider.setPreferredSize(new Dimension(20,height));
slider.setPreferredSize(new Dimension(20, height));
}
 
public void mouseWheelMoved(MouseWheelEvent mwe) {
72,23 → 74,30
public void stateChanged(ChangeEvent ce) {
if (update) {
update = false;
int newval = (int)((((float)slider.getValue() / (float)slider.getMaximum()) * ((float)midiParameter.getMidiMaxValue() - (float)midiParameter.getMidiMinValue())) + (float)midiParameter.getMidiMinValue());
int newval = (int) ((((float) slider.getValue() / (float) slider
.getMaximum()) * ((float) midiParameter.getMidiMaxValue() - (float) midiParameter
.getMidiMinValue())) + (float) midiParameter
.getMidiMinValue());
midiParameter.setMidiValue(newval, true);
 
for (int c = 0; c < midiParameters.size(); c++) {
SIDSysexParameterControl mp = (SIDSysexParameterControl) midiParameters.elementAt(c);
SIDSysexParameterControl mp = (SIDSysexParameterControl) midiParameters
.elementAt(c);
mp.setMidiValue(newval, false);
}
 
update = true;
}
}
 
public void updateGraphics() {
super.updateGraphics();
if (update) {
update = false;
int newval = (int) ((((float)midiParameter.getMidiValue()-(float)midiParameter.getMidiMinValue())/((float)midiParameter.getMidiMaxValue() - (float)midiParameter.getMidiMinValue())) * (float) slider.getMaximum());
int newval = (int) ((((float) midiParameter.getMidiValue() - (float) midiParameter
.getMidiMinValue()) / ((float) midiParameter
.getMidiMaxValue() - (float) midiParameter
.getMidiMinValue())) * (float) slider.getMaximum());
slider.setValue(newval);
update = true;
}