001/** 002 * 003 */ 004package icy.gui.sequence.tools; 005 006import icy.image.IcyBufferedImageUtil.FilterType; 007import icy.sequence.Sequence; 008 009import java.awt.GridBagConstraints; 010import java.awt.Insets; 011import java.awt.event.ActionEvent; 012import java.awt.event.ActionListener; 013 014import javax.swing.DefaultComboBoxModel; 015import javax.swing.JComboBox; 016import javax.swing.JLabel; 017import javax.swing.SwingConstants; 018 019/** 020 * @author Stephane 021 */ 022public class SequenceResizePanel extends SequenceBaseResizePanel 023{ 024 /** 025 * 026 */ 027 private static final long serialVersionUID = 5366610917009978874L; 028 029 private JComboBox filterComboBox; 030 private JLabel lblFilterType; 031 032 public SequenceResizePanel(Sequence sequence) 033 { 034 super(sequence); 035 036 keepRatioCheckBox.setSelected(true); 037 038 filterComboBox.addActionListener(new ActionListener() 039 { 040 @Override 041 public void actionPerformed(ActionEvent e) 042 { 043 updatePreview(); 044 } 045 }); 046 } 047 048 @Override 049 protected void initialize() 050 { 051 super.initialize(); 052 053 lblFilterType = new JLabel("Filter type"); 054 GridBagConstraints gbc_lblFilterType = new GridBagConstraints(); 055 gbc_lblFilterType.fill = GridBagConstraints.BOTH; 056 gbc_lblFilterType.insets = new Insets(0, 0, 5, 5); 057 gbc_lblFilterType.gridx = 5; 058 gbc_lblFilterType.gridy = 0; 059 settingPanel.add(lblFilterType, gbc_lblFilterType); 060 061 filterComboBox = new JComboBox(); 062 filterComboBox.setModel(new DefaultComboBoxModel(new String[] {"Nearest", "Bilinear", "Bicubic"})); 063 filterComboBox.setSelectedIndex(1); 064 GridBagConstraints gbc_filterComboBox = new GridBagConstraints(); 065 gbc_filterComboBox.insets = new Insets(0, 0, 5, 5); 066 gbc_filterComboBox.fill = GridBagConstraints.HORIZONTAL; 067 gbc_filterComboBox.gridx = 5; 068 gbc_filterComboBox.gridy = 1; 069 settingPanel.add(filterComboBox, gbc_filterComboBox); 070 } 071 072 @Override 073 public FilterType getFilterType() 074 { 075 switch (filterComboBox.getSelectedIndex()) 076 { 077 default: 078 case 0: 079 return FilterType.NEAREST; 080 case 1: 081 return FilterType.BILINEAR; 082 case 2: 083 return FilterType.BICUBIC; 084 } 085 } 086 087 @Override 088 public boolean getResizeContent() 089 { 090 return true; 091 } 092 093 @Override 094 public int getXAlign() 095 { 096 return SwingConstants.CENTER; 097 } 098 099 @Override 100 public int getYAlign() 101 { 102 return SwingConstants.CENTER; 103 } 104}