rowsLabel.setToolTipText(rb.getString("Set number of rows"));
colsLabel = new JLabel();
colsLabel.setToolTipText(rb.getString("Set number of columns"));
rowsLabel.setIcon(Utils.createImageIcon("resize-rows36.png","Rows"));
colsLabel.setIcon(Utils.createImageIcon("resize-columns36.png","Columns"));
final JSpinner rowSpinner=new JSpinner(new SpinnerNumberModel(rows,MINIMUM_SELECTABLE_PIXELS,Resource.MAXIMUM_GRID_SIZE,1));
final JSpinner columnSpinner=new JSpinner(new SpinnerNumberModel(cols,MINIMUM_SELECTABLE_PIXELS,Resource.MAXIMUM_GRID_SIZE,1));
rowSpinner.addChangeListener(new ChangeListener(){
public void stateChanged(ChangeEvent e){
int r=((Integer)(rowSpinner.getValue())).intValue();
if(lockAspectRatio){
columnSpinner.setValue(new Integer(Math.max(MINIMUM_SELECTABLE_PIXELS,(int)((double)r/imageAspectRatio))));
}
int c=((Integer)(columnSpinner.getValue())).intValue();
if(!lockAspectRatio)imageAspectRatio=(double)r/(double)c;
updateFinalImage(r,c);
}
});
columnSpinner.addChangeListener(new ChangeListener(){
public void stateChanged(ChangeEvent e){
if(!lockAspectRatio){
int c=((Integer)(columnSpinner.getValue())).intValue();
int r=((Integer)(rowSpinner.getValue())).intValue();
imageAspectRatio=(double)r/(double)c;
updateFinalImage(r,c);
}
}
});
JPanel rowColPanel=new JPanel(new GridLayout(1,0));
JPanel rp=new JPanel(new BorderLayout()); rp.add(rowsLabel,BorderLayout.LINE_START); rp.add(rowSpinner,BorderLayout.LINE_END);
JPanel cp=new JPanel(new BorderLayout()); cp.add(colsLabel,BorderLayout.LINE_START); cp.add(columnSpinner,BorderLayout.LINE_END);
rowColPanel.add(rp); rowColPanel.add(cp);
rowColPanel.setBorder(BorderFactory.createEtchedBorder());
JPanel upperPanel=new JPanel(new GridLayout(0,1));
upperPanel.add(rowColPanel);
upperPanel.add(backgroundPanel);
upperPanel.add(invertPanel);
JPanel thresholdPanel=new JPanel(new GridLayout(0,1));
thresholdPanel.add(redThresholdPanel);
thresholdPanel.add(greenThresholdPanel);
thresholdPanel.add(blueThresholdPanel);
thresholdPanel.add(alphaThresholdPanel);
JCheckBox lockCheckBox = new JCheckBox();
lockCheckBox.setIcon(Utils.createImageIcon("unlocked36.png","Unlocked"));
lockCheckBox.setSelectedIcon(Utils.createImageIcon("locked36.png","Locked"));
lockCheckBox.setRolloverEnabled(false);
lockCheckBox.setContentAreaFilled(false);
lockCheckBox.setSelected(false);
lockAspectRatio=false;
lockCheckBox.setHorizontalAlignment(SwingConstants.LEFT);
lockCheckBox.setToolTipText(rb.getString("Lock Aspect Ratio"));
lockCheckBox.addChangeListener(new ChangeListener(){
public void stateChanged(ChangeEvent e){
//ignore irrelevant events
if(lockAspectRatio=((JCheckBox)(e.getSource())).isSelected())return;
lockAspectRatio=!lockAspectRatio;
columnSpinner.setEnabled(!lockAspectRatio);
if(lockAspectRatio)originalImagePanel.selectAll();
}
});
JPanel controlPanel=new JPanel(new BorderLayout());