• R/O
  • HTTP
  • SSH
  • HTTPS

importpicture: Commit


Commit MetaInfo

Revisionf981676e67330b84043f8c4ebaf7ec81b389d200 (tree)
Time2019-10-12 13:58:33
Authorhaya4 <hayashi.yuu@gmai...>
Commiterhaya4

Log Message

fixed: 画像ファイルが選択されたら次のパネルを有効にする

Change Summary

Incremental Difference

--- a/src/osm/jp/gpx/matchtime/gui/Card.java
+++ b/src/osm/jp/gpx/matchtime/gui/Card.java
@@ -1,9 +1,13 @@
11 package osm.jp.gpx.matchtime.gui;
22
33 import java.awt.BorderLayout;
4+import java.awt.Dimension;
45 import java.awt.event.ActionEvent;
6+import java.util.ArrayList;
57 import javax.swing.Box;
8+import javax.swing.BoxLayout;
69 import javax.swing.JButton;
10+import javax.swing.JComponent;
711 import javax.swing.JPanel;
812 import javax.swing.JTabbedPane;
913 import static osm.jp.gpx.matchtime.gui.AdjustTime.i18n;
@@ -56,6 +60,30 @@ public class Card extends JPanel {
5660 //}}
5761 }
5862
63+ public static JPanel packLine(JComponent[] components, JPanel panel) {
64+ panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
65+ int max = 0;
66+ for (JComponent component : components) {
67+ panel.add(component);
68+ Dimension size = component.getMaximumSize();
69+ if (max < size.height) {
70+ max = size.height;
71+ }
72+ }
73+ Dimension size = new Dimension();
74+ size.width = Short.MAX_VALUE;
75+ size.height = max;
76+ panel.setMaximumSize(size);
77+ return panel;
78+ }
79+
80+ public static JPanel packLine(JComponent component, JPanel panel) {
81+ ArrayList<JComponent> array = new ArrayList<>();
82+ array.add(component);
83+ return packLine(array.toArray(new JComponent[array.size()]), panel);
84+ }
85+
86+ @Override
5987 public void setEnabled(boolean enabled) {
6088 this.tabbe.setEnabledAt(nextNumber - 1, enabled);
6189 }
--- a/src/osm/jp/gpx/matchtime/gui/ParameterPanelImageFile.java
+++ b/src/osm/jp/gpx/matchtime/gui/ParameterPanelImageFile.java
@@ -28,46 +28,39 @@ public class ParameterPanelImageFile extends ParameterPanel {
2828 //Create a file chooser
2929 this.paramDir = paramDir;
3030 }
31-
31+
3232 class SelectButtonAction implements java.awt.event.ActionListener
3333 {
3434 @SuppressWarnings("override")
3535 public void actionPerformed(ActionEvent e) {
36- //Set up the file chooser.
37- File sdir = new File(paramDir.getText());
38- System.out.println(sdir.toPath());
39- if (sdir.isDirectory()) {
40- fc = new JFileChooser(sdir);
41- }
42- else {
43- fc = new JFileChooser();
44- }
45-
46- //Add a custom file filter and disable the default
47- //(Accept All) file filter.
48- fc.addChoosableFileFilter(new ImageFilter());
49- fc.setAcceptAllFileFilterUsed(false);
50-
51- //Add custom icons for file types.
52- fc.setFileView(new ImageFileView());
53-
54- //Add the preview pane.
55- fc.setAccessory(new ImagePreview(fc));
36+ selectImage_Action(e);
37+ }
38+ }
5639
57- //Show it.
58- int returnVal = fc.showDialog(ParameterPanelImageFile.this, "選択");
40+ public void selectImage_Action(ActionEvent ev) {
41+ File sdir = new File(paramDir.getText());
42+ System.out.println(sdir.toPath());
43+ if (sdir.isDirectory()) {
44+ fc = new JFileChooser(sdir);
45+ }
46+ else {
47+ fc = new JFileChooser();
48+ }
5949
60- //Process the results.
61- if (returnVal == JFileChooser.APPROVE_OPTION) {
62- File file = fc.getSelectedFile();
63- argField.setText(file.getName());
64- }
50+ fc.addChoosableFileFilter(new ImageFilter());
51+ fc.setAcceptAllFileFilterUsed(false);
52+ fc.setFileView(new ImageFileView());
53+ fc.setAccessory(new ImagePreview(fc));
6554
66- //Reset the file chooser for the next time it's shown.
67- fc.setSelectedFile(null);
55+ //Show it. "選択"
56+ int returnVal = fc.showDialog(ParameterPanelImageFile.this, i18n.getString("dialog.select"));
57+ if (returnVal == JFileChooser.APPROVE_OPTION) {
58+ File file = fc.getSelectedFile();
59+ argField.setText(file.getName());
6860 }
61+ fc.setSelectedFile(null);
6962 }
70-
63+
7164 /**
7265 *
7366 * @return
--- a/src/osm/jp/gpx/matchtime/gui/ParameterPanelTime.java
+++ b/src/osm/jp/gpx/matchtime/gui/ParameterPanelTime.java
@@ -22,6 +22,10 @@ public class ParameterPanelTime extends ParameterPanel implements ActionListener
2222 super(label, text);
2323 this.imageFile = imageFile;
2424 }
25+
26+ public ParameterPanelImageFile getImageFile() {
27+ return this.imageFile;
28+ }
2529
2630 @Override
2731 public void actionPerformed(ActionEvent arg0) {
--- a/src/osm/jp/gpx/matchtime/gui/restamp/CardFirstFile.java
+++ b/src/osm/jp/gpx/matchtime/gui/restamp/CardFirstFile.java
@@ -1,6 +1,7 @@
11 package osm.jp.gpx.matchtime.gui.restamp;
22
33 import java.awt.BorderLayout;
4+import java.awt.Dimension;
45 import javax.swing.BoxLayout;
56 import javax.swing.JLabel;
67 import javax.swing.JPanel;
@@ -10,41 +11,57 @@ import static osm.jp.gpx.matchtime.gui.AdjustTime.i18n;
1011 import osm.jp.gpx.matchtime.gui.Card;
1112 import osm.jp.gpx.matchtime.gui.PanelAction;
1213 import osm.jp.gpx.matchtime.gui.ParameterPanelImageFile;
14+import osm.jp.gpx.matchtime.gui.ParameterPanelTime;
1315
1416 /**
1517 * [基準画像(開始)]選択パネル
1618 * @author yuu
1719 */
1820 public class CardFirstFile extends Card implements PanelAction {
19- JPanel argsPanel; // パラメータ設定パネル (上部)
21+ //JPanel argsPanel; // パラメータ設定パネル (上部)
2022 ParameterPanelImageFile arg_baseTimeImg;
21-
23+ ParameterPanelTime arg_basetime;
24+
2225 /**
2326 * コンストラクタ
2427 * @param tabbe parent panel
25- * @param arg2_baseTimeImg
28+ * @param arg_basetime // 開始画像の基準時刻:
2629 */
2730 public CardFirstFile(
2831 JTabbedPane tabbe,
29- ParameterPanelImageFile arg2_baseTimeImg
32+ ParameterPanelTime arg_basetime
3033 ) {
3134 super(tabbe, AdjustTime.i18n.getString("tab.restamp.200"), 0, 2);
32- this.arg_baseTimeImg = arg2_baseTimeImg;
33- this.mainPanel.add(new JLabel(i18n.getString("label.200")), BorderLayout.NORTH);
35+ this.arg_baseTimeImg = arg_basetime.getImageFile();
36+ this.arg_basetime = arg_basetime;
37+
38+ JPanel argsPanel = new JPanel();
39+ argsPanel.setLayout(new BoxLayout(argsPanel, BoxLayout.PAGE_AXIS));
40+ argsPanel.add(packLine(new JLabel(i18n.getString("label.200")), new JPanel()));
41+ argsPanel.add(arg_baseTimeImg);
42+
43+ JPanel separater = new JPanel();
44+ separater.setMinimumSize(new Dimension(40, 20));
45+ argsPanel.add(separater);
46+
47+ argsPanel.add(packLine(new JLabel(i18n.getString("label.300")), new JPanel()));
48+ argsPanel.add(arg_basetime);
49+
50+ JPanel space = new JPanel();
51+ space.setMinimumSize(new Dimension(40, 20));
52+ space.setMaximumSize(new Dimension(40, Short.MAX_VALUE));
53+ argsPanel.add(space);
3454
35- argsPanel = new JPanel();
36- argsPanel.setLayout(new BoxLayout(argsPanel, BoxLayout.Y_AXIS));
37- argsPanel.add(arg2_baseTimeImg);
3855 this.mainPanel.add(argsPanel, BorderLayout.CENTER);
3956 }
40-
57+
4158 /**
4259 * 入力条件が満たされているかどうか
4360 * @return
4461 */
4562 @Override
4663 public boolean isEnable() {
47- return this.arg_baseTimeImg.isEnable();
64+ return (arg_baseTimeImg.isEnable() && arg_basetime.isEnable());
4865 }
4966
5067 @Override
--- a/src/osm/jp/gpx/matchtime/gui/restamp/RestampDialog.java
+++ b/src/osm/jp/gpx/matchtime/gui/restamp/RestampDialog.java
@@ -155,18 +155,23 @@ public class RestampDialog extends Dialog implements Observer
155155 null,
156156 arg1_srcFolder
157157 );
158- arg2_baseTimeImg.argField
159- .getDocument()
160- .addDocumentListener(
161- new SimpleDocumentListener() {
162- @Override
163- public void update(DocumentEvent e) {
164- toEnable(1, arg2_baseTimeImg.isEnable());
165- }
158+
159+ // 2a. 基準時刻:
160+ arg2_basetime = new ParameterPanelTime(
161+ i18n.getString("label.310"),
162+ null,
163+ arg2_baseTimeImg
164+ );
165+ arg2_basetime.argField.getDocument().addDocumentListener(
166+ new SimpleDocumentListener() {
167+ @Override
168+ public void update(DocumentEvent e) {
169+ toEnable(1, arg2_basetime.isEnable());
166170 }
167- );
171+ }
172+ );
168173
169- CardFirstFile card = new CardFirstFile(cardPanel, arg2_baseTimeImg);
174+ CardFirstFile card = new CardFirstFile(cardPanel, arg2_basetime);
170175 cardPanel.addTab(card.getTitle(), card);
171176 cardPanel.setEnabledAt(cardNo, false);
172177 cards[cardNo] = card;
@@ -176,23 +181,6 @@ public class RestampDialog extends Dialog implements Observer
176181 //---------------------------------------------------------------------
177182 // 2a. 開始画像の本当の時刻を設定の入力画面
178183 {
179- // 2a. 基準時刻:
180- arg2_basetime = new ParameterPanelTime(
181- i18n.getString("label.310"),
182- null,
183- arg2_baseTimeImg
184- );
185- arg2_basetime.argField
186- .getDocument()
187- .addDocumentListener(
188- new SimpleDocumentListener() {
189- @Override
190- public void update(DocumentEvent e) {
191- toEnable(2, arg2_basetime.isEnable());
192- }
193- }
194- );
195-
196184 CardCorectTime card = new CardCorectTime(cardPanel, arg2_basetime);
197185 cardPanel.addTab(card.getTitle(), card);
198186 cardPanel.setEnabledAt(cardNo, false);
Show on old repository browser