diff --git a/src/osm/jp/gpx/matchtime/gui/Card.java b/src/osm/jp/gpx/matchtime/gui/Card.java index f01e7da..1956aeb 100644 --- a/src/osm/jp/gpx/matchtime/gui/Card.java +++ b/src/osm/jp/gpx/matchtime/gui/Card.java @@ -1,9 +1,13 @@ package osm.jp.gpx.matchtime.gui; import java.awt.BorderLayout; +import java.awt.Dimension; import java.awt.event.ActionEvent; +import java.util.ArrayList; import javax.swing.Box; +import javax.swing.BoxLayout; import javax.swing.JButton; +import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.JTabbedPane; import static osm.jp.gpx.matchtime.gui.AdjustTime.i18n; @@ -56,6 +60,30 @@ //}} } + public static JPanel packLine(JComponent[] components, JPanel panel) { + panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS)); + int max = 0; + for (JComponent component : components) { + panel.add(component); + Dimension size = component.getMaximumSize(); + if (max < size.height) { + max = size.height; + } + } + Dimension size = new Dimension(); + size.width = Short.MAX_VALUE; + size.height = max; + panel.setMaximumSize(size); + return panel; + } + + public static JPanel packLine(JComponent component, JPanel panel) { + ArrayList array = new ArrayList<>(); + array.add(component); + return packLine(array.toArray(new JComponent[array.size()]), panel); + } + + @Override public void setEnabled(boolean enabled) { this.tabbe.setEnabledAt(nextNumber - 1, enabled); } diff --git a/src/osm/jp/gpx/matchtime/gui/ParameterPanelImageFile.java b/src/osm/jp/gpx/matchtime/gui/ParameterPanelImageFile.java index a381b62..1cb8853 100644 --- a/src/osm/jp/gpx/matchtime/gui/ParameterPanelImageFile.java +++ b/src/osm/jp/gpx/matchtime/gui/ParameterPanelImageFile.java @@ -28,46 +28,39 @@ //Create a file chooser this.paramDir = paramDir; } - + class SelectButtonAction implements java.awt.event.ActionListener { @SuppressWarnings("override") public void actionPerformed(ActionEvent e) { - //Set up the file chooser. - File sdir = new File(paramDir.getText()); - System.out.println(sdir.toPath()); - if (sdir.isDirectory()) { - fc = new JFileChooser(sdir); - } - else { - fc = new JFileChooser(); - } - - //Add a custom file filter and disable the default - //(Accept All) file filter. - fc.addChoosableFileFilter(new ImageFilter()); - fc.setAcceptAllFileFilterUsed(false); - - //Add custom icons for file types. - fc.setFileView(new ImageFileView()); - - //Add the preview pane. - fc.setAccessory(new ImagePreview(fc)); - - //Show it. - int returnVal = fc.showDialog(ParameterPanelImageFile.this, "選択"); - - //Process the results. - if (returnVal == JFileChooser.APPROVE_OPTION) { - File file = fc.getSelectedFile(); - argField.setText(file.getName()); - } - - //Reset the file chooser for the next time it's shown. - fc.setSelectedFile(null); + selectImage_Action(e); } } + public void selectImage_Action(ActionEvent ev) { + File sdir = new File(paramDir.getText()); + System.out.println(sdir.toPath()); + if (sdir.isDirectory()) { + fc = new JFileChooser(sdir); + } + else { + fc = new JFileChooser(); + } + + fc.addChoosableFileFilter(new ImageFilter()); + fc.setAcceptAllFileFilterUsed(false); + fc.setFileView(new ImageFileView()); + fc.setAccessory(new ImagePreview(fc)); + + //Show it. "選択" + int returnVal = fc.showDialog(ParameterPanelImageFile.this, i18n.getString("dialog.select")); + if (returnVal == JFileChooser.APPROVE_OPTION) { + File file = fc.getSelectedFile(); + argField.setText(file.getName()); + } + fc.setSelectedFile(null); + } + /** * * @return diff --git a/src/osm/jp/gpx/matchtime/gui/ParameterPanelTime.java b/src/osm/jp/gpx/matchtime/gui/ParameterPanelTime.java index 4c2e967..8c27aeb 100644 --- a/src/osm/jp/gpx/matchtime/gui/ParameterPanelTime.java +++ b/src/osm/jp/gpx/matchtime/gui/ParameterPanelTime.java @@ -22,6 +22,10 @@ super(label, text); this.imageFile = imageFile; } + + public ParameterPanelImageFile getImageFile() { + return this.imageFile; + } @Override public void actionPerformed(ActionEvent arg0) { diff --git a/src/osm/jp/gpx/matchtime/gui/restamp/CardFirstFile.java b/src/osm/jp/gpx/matchtime/gui/restamp/CardFirstFile.java index b9a0bf8..1376423 100644 --- a/src/osm/jp/gpx/matchtime/gui/restamp/CardFirstFile.java +++ b/src/osm/jp/gpx/matchtime/gui/restamp/CardFirstFile.java @@ -1,6 +1,7 @@ package osm.jp.gpx.matchtime.gui.restamp; import java.awt.BorderLayout; +import java.awt.Dimension; import javax.swing.BoxLayout; import javax.swing.JLabel; import javax.swing.JPanel; @@ -10,41 +11,57 @@ import osm.jp.gpx.matchtime.gui.Card; import osm.jp.gpx.matchtime.gui.PanelAction; import osm.jp.gpx.matchtime.gui.ParameterPanelImageFile; +import osm.jp.gpx.matchtime.gui.ParameterPanelTime; /** * [基準画像(開始)]選択パネル * @author yuu */ public class CardFirstFile extends Card implements PanelAction { - JPanel argsPanel; // パラメータ設定パネル (上部) + //JPanel argsPanel; // パラメータ設定パネル (上部) ParameterPanelImageFile arg_baseTimeImg; - + ParameterPanelTime arg_basetime; + /** * コンストラクタ * @param tabbe parent panel - * @param arg2_baseTimeImg + * @param arg_basetime // 開始画像の基準時刻: */ public CardFirstFile( JTabbedPane tabbe, - ParameterPanelImageFile arg2_baseTimeImg + ParameterPanelTime arg_basetime ) { super(tabbe, AdjustTime.i18n.getString("tab.restamp.200"), 0, 2); - this.arg_baseTimeImg = arg2_baseTimeImg; - this.mainPanel.add(new JLabel(i18n.getString("label.200")), BorderLayout.NORTH); + this.arg_baseTimeImg = arg_basetime.getImageFile(); + this.arg_basetime = arg_basetime; - argsPanel = new JPanel(); - argsPanel.setLayout(new BoxLayout(argsPanel, BoxLayout.Y_AXIS)); - argsPanel.add(arg2_baseTimeImg); + JPanel argsPanel = new JPanel(); + argsPanel.setLayout(new BoxLayout(argsPanel, BoxLayout.PAGE_AXIS)); + argsPanel.add(packLine(new JLabel(i18n.getString("label.200")), new JPanel())); + argsPanel.add(arg_baseTimeImg); + + JPanel separater = new JPanel(); + separater.setMinimumSize(new Dimension(40, 20)); + argsPanel.add(separater); + + argsPanel.add(packLine(new JLabel(i18n.getString("label.300")), new JPanel())); + argsPanel.add(arg_basetime); + + JPanel space = new JPanel(); + space.setMinimumSize(new Dimension(40, 20)); + space.setMaximumSize(new Dimension(40, Short.MAX_VALUE)); + argsPanel.add(space); + this.mainPanel.add(argsPanel, BorderLayout.CENTER); } - + /** * 入力条件が満たされているかどうか * @return */ @Override public boolean isEnable() { - return this.arg_baseTimeImg.isEnable(); + return (arg_baseTimeImg.isEnable() && arg_basetime.isEnable()); } @Override diff --git a/src/osm/jp/gpx/matchtime/gui/restamp/RestampDialog.java b/src/osm/jp/gpx/matchtime/gui/restamp/RestampDialog.java index 64477cb..223de8e 100644 --- a/src/osm/jp/gpx/matchtime/gui/restamp/RestampDialog.java +++ b/src/osm/jp/gpx/matchtime/gui/restamp/RestampDialog.java @@ -155,18 +155,23 @@ null, arg1_srcFolder ); - arg2_baseTimeImg.argField - .getDocument() - .addDocumentListener( - new SimpleDocumentListener() { - @Override - public void update(DocumentEvent e) { - toEnable(1, arg2_baseTimeImg.isEnable()); - } - } - ); - CardFirstFile card = new CardFirstFile(cardPanel, arg2_baseTimeImg); + // 2a. 基準時刻: + arg2_basetime = new ParameterPanelTime( + i18n.getString("label.310"), + null, + arg2_baseTimeImg + ); + arg2_basetime.argField.getDocument().addDocumentListener( + new SimpleDocumentListener() { + @Override + public void update(DocumentEvent e) { + toEnable(1, arg2_basetime.isEnable()); + } + } + ); + + CardFirstFile card = new CardFirstFile(cardPanel, arg2_basetime); cardPanel.addTab(card.getTitle(), card); cardPanel.setEnabledAt(cardNo, false); cards[cardNo] = card; @@ -176,23 +181,6 @@ //--------------------------------------------------------------------- // 2a. 開始画像の本当の時刻を設定の入力画面 { - // 2a. 基準時刻: - arg2_basetime = new ParameterPanelTime( - i18n.getString("label.310"), - null, - arg2_baseTimeImg - ); - arg2_basetime.argField - .getDocument() - .addDocumentListener( - new SimpleDocumentListener() { - @Override - public void update(DocumentEvent e) { - toEnable(2, arg2_basetime.isEnable()); - } - } - ); - CardCorectTime card = new CardCorectTime(cardPanel, arg2_basetime); cardPanel.addTab(card.getTitle(), card); cardPanel.setEnabledAt(cardNo, false);