From: yuuhayashi Date: Fri, 20 Jun 2014 14:08:58 +0000 (+0900) Subject: new branch 'gui' X-Git-Tag: release_2016-10-30~63 X-Git-Url: http://git.osdn.net/view?p=importpicture%2Fimportpicture.git;a=commitdiff_plain;h=06313c6d25a83a29cacd0c73a33921c46488b96f new branch 'gui' --- diff --git a/importPicture/.classpath b/importPicture/.classpath index 2061450..1687303 100644 --- a/importPicture/.classpath +++ b/importPicture/.classpath @@ -2,5 +2,6 @@ + diff --git a/importPicture/LICENSE.txt b/importPicture/LICENSE.txt new file mode 100644 index 0000000..9586edf --- /dev/null +++ b/importPicture/LICENSE.txt @@ -0,0 +1,35 @@ +The MIT License (MIT) + +Copyright (c) 2014 Yuu Hayashi + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + +以下に定める条件に従い、本ソフトウェアおよび関連文書のファイル(以下「ソフトウェア」)の複製を取得するすべて +の人に対し、ソフトウェアを無制限に扱うことを無償で許可します。これには、ソフトウェアの複製を使用、複写、変 +更、結合、掲載、頒布、サブライセンス、および/または販売する権利、およびソフトウェアを提供する相手に同じこ +とを許可する権利も無制限に含まれます。 + +上記の著作権表示および本許諾表示を、ソフトウェアのすべての複製または重要な部分に記載するものとします。 + +ソフトウェアは「現状のまま」で、明示であるか暗黙であるかを問わず、何らの保証もなく提供されます。ここでいう保証 +とは、商品性、特定の目的への適合性、および権利非侵害についての保証も含みますが、それに限定されるもので +はありません。 作者または著作権者は、契約行為、不法行為、またはそれ以外であろうと、ソフトウェアに起因または +関連し、あるいはソフトウェアの使用またはその他の扱いによって生じる一切の請求、損害、その他の義務について何 +らの責任も負わないものとします。 diff --git a/importPicture/README.jp.txt b/importPicture/README.jp.txt index 487cefc..c6f273e 100644 --- a/importPicture/README.jp.txt +++ b/importPicture/README.jp.txt @@ -26,4 +26,6 @@ exp) > java -jar importPicture.jar list.csv . IMG_01234.JPG 2012-06-15T12:52:22 鎌倉宮_2012-06-15_12-00-16.gpx - +------------------------------------------------------------------- +Copyright (c) 2014 Yuu Hayashi +This software is released under the MIT License, see LICENSE.txt. \ No newline at end of file diff --git a/importPicture/src/hayashi/yuu/gpx/gui/AboutDialog.java b/importPicture/src/hayashi/yuu/gpx/gui/AboutDialog.java new file mode 100644 index 0000000..585e05b --- /dev/null +++ b/importPicture/src/hayashi/yuu/gpx/gui/AboutDialog.java @@ -0,0 +1,157 @@ +package hayashi.yuu.gpx.gui; +import java.awt.BorderLayout; +import java.awt.FlowLayout; +import java.awt.Font; +import java.awt.Rectangle; +import java.awt.Toolkit; +import java.awt.event.WindowEvent; +import java.awt.event.WindowListener; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; + +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; + +import osm.jp.gpx.ImportPicture; + +@SuppressWarnings("serial") +public class AboutDialog extends JDialog implements WindowListener +{ + static final String TITLE = PictureMapper.PROGRAM_NAME; + static final String COPY_RIGHT = "Copyright (c) 2014 Yuu Hayashi. This software is released under the MIT License."; + + JLabel label1; + JButton okButton; + JLabel label2; + JTextArea textArea; + JFrame parent; + + public AboutDialog(JFrame parent, boolean modal) { + super(parent, modal); + addWindowListener(this); + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + + this.parent = parent; + setTitle("About..."); + getContentPane().setLayout(new BorderLayout()); + setSize(512,320); + + //-------------------------------------------------------- + // 上部パネル + //----------------------------------------------- + label1 = new JLabel(TITLE, JLabel.CENTER); + add(BorderLayout.NORTH, label1); + + //-------------------------------------------------------- + // 中央パネル + //----------------------------------------------- + + /* + * [README.txt]ファイルの内容を表示するTEXTAREA + */ + textArea = new JTextArea(7, 60); + textArea.setEditable(false); + textArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12)); + JScrollPane scrollPane = new JScrollPane(textArea); + scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + add(BorderLayout.CENTER, scrollPane); + + URL url = getClass().getResource("/README.txt"); + InputStream is; + try { + is = url.openStream(); + BufferedReader br = new BufferedReader(new InputStreamReader(is)); + while (br.ready()) { + textArea.append(br.readLine() + "\n"); + } + textArea.setCaretPosition(0); + br.close(); + is.close(); + } catch (IOException e) { + e.printStackTrace(); + } + + //-------------------------------------------------------- + // 下部パネル + //----------------------------------------------- + JPanel bottonPanel = new JPanel(); + bottonPanel.setLayout(new BorderLayout()); + add(BorderLayout.SOUTH, bottonPanel); + + /* + * [OK]ボタン : このダイアログウインドウを閉じる + */ + okButton = new JButton("OK"); + okButton.setBounds(145,65,66,27); + okButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(new WindowEvent(AboutDialog.this, WindowEvent.WINDOW_CLOSING)); + setVisible(false); + } + }); + JPanel okPanel = new JPanel(new FlowLayout()); + try { + okPanel.add(okButton); + } + catch(Exception e) { + e.printStackTrace(); + ImportPicture.logger.warning(e.toString()); + } + bottonPanel.add(BorderLayout.CENTER, okPanel); + + /* + * コピーライト表示 + */ + label2 = new JLabel(COPY_RIGHT, JLabel.CENTER); + label2.setBounds(10,40,340,20); + bottonPanel.add(BorderLayout.SOUTH, label2); + + setVisible(true); + } + + /** + * Shows or hides the component depending on the boolean flag b. + * @param b if true, show the component; otherwise, hide the component. + * @see java.awt.Component#isVisible + */ + public void setVisible(boolean b) { + if (b) { + Rectangle bounds = getParent().getBounds(); + Rectangle abounds = getBounds(); + setLocation(bounds.x + (bounds.width - abounds.width)/ 2, + bounds.y + (bounds.height - abounds.height)/2); + } + super.setVisible(b); + } + + public void windowClosed(WindowEvent e) { + setVisible(false); + } + + public void windowActivated(WindowEvent arg0) { + } + + public void windowClosing(WindowEvent arg0) { + setVisible(false); + } + + public void windowDeactivated(WindowEvent arg0) { + } + + public void windowDeiconified(WindowEvent arg0) { + } + + public void windowIconified(WindowEvent arg0) { + } + + public void windowOpened(WindowEvent arg0) { + } +} diff --git a/importPicture/src/hayashi/yuu/gpx/gui/CollectData.java b/importPicture/src/hayashi/yuu/gpx/gui/CollectData.java new file mode 100644 index 0000000..92c8d54 --- /dev/null +++ b/importPicture/src/hayashi/yuu/gpx/gui/CollectData.java @@ -0,0 +1,137 @@ +package hayashi.yuu.gpx.gui; + +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.Iterator; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +import jp.co.areaweb.tools.csv.CsvRecord; + +public class CollectData +{ + public Calendar date = Calendar.getInstance(); + public String address = null; + public String name = null; + public String data = ""; + public static Calendar baseDate = null; + public static String[] columnNames = {"日時", "カードID", "送信先アドレス","なまえ"}; + + static final String DATETIME_PATTERN = "yyyy/MM/dd'-'HH:mm:ss"; + static SimpleDateFormat dateTimePattern = new SimpleDateFormat(DATETIME_PATTERN); + + /** + * コンストラクタ: データコレクタで取得したデータ + * @param datetime + * @param data + * @param address + * @param name + */ + public CollectData(Date datetime, String data, String address, String name) { + date.setTime(datetime); + if (date.get(Calendar.YEAR) < 2000) { + if (baseDate != null) { + date.set(baseDate.get(Calendar.YEAR), baseDate.get(Calendar.MONTH), baseDate.get(Calendar.DAY_OF_MONTH)); + } + } + else { + CollectData.baseDate = Calendar.getInstance(); + CollectData.baseDate.set(date.get(Calendar.YEAR), date.get(Calendar.MONTH), date.get(Calendar.DAY_OF_MONTH)); + } + this.data = data; + if (address == null) { + this.address = getAddress(data); + } + else { + this.address = address; + } + if (name == null) { + this.name = getName(data); + } + else { + this.name = name; + } + } + + public CollectData(Date datetime, String data) { + this(datetime, data, null, null); + } + + /** + * 収集データをXML形式にして表現する。 + * @return XMLレコード + */ + public Element getXmlElement(Document document) { + Element point = document.createElement("point"); + point.setAttribute("id", this.data); + point.setAttribute("datetime", dateTimePattern.format(this.date.getTime())); + + Element addrEle = document.createElement("address"); + addrEle.appendChild(document.createTextNode(this.address)); + point.appendChild(addrEle); + + Element nameEle = document.createElement("name"); + nameEle.appendChild(document.createTextNode(this.name)); + point.appendChild(nameEle); + + return point; + } + + + /** + * [javax.swing.table.DefaultTableModel]用のレコード形式を取得する。 + * @return + */ + public String[] getRecordStrs() { + String[] strs = new String[4]; + strs[0] = dateTimePattern.format(this.date.getTime()); + strs[1] = this.data; + strs[2] = this.address; + strs[3] = this.name; + return strs; + } + + /** + * カードIDを取得する + * @return カードID(IDm) - 16文字の16進表記 '01010310DA09D027' + */ + public long getId() { + return Long.parseLong(this.data, 16); + } + + public String getAddress(String dataStr) { + if (PictureMapper.taglistFile == null) { + return ""; + } + for (Iterator i = PictureMapper.taglistFile.iterator(); i.hasNext(); ) { + CsvRecord record = i.next(); + String idStr = (String)record.get(0); // ID + if (idStr.equals(dataStr)) { + return (String)record.get(1); // ID + } + } + return ""; + } + + public String getName(String dataStr) { + if (PictureMapper.taglistFile == null) { + return ""; + } + for (Iterator i = PictureMapper.taglistFile.iterator(); i.hasNext(); ) { + CsvRecord record = i.next(); + String idStr = (String)record.get(0); // ID + if (idStr.equals(dataStr)) { + try { + String ret = (String)record.get(2); // ID + return ret; // ID + } + catch (IndexOutOfBoundsException ioobe) { + return ""; + } + } + } + return ""; + } +} diff --git a/importPicture/src/hayashi/yuu/gpx/gui/DeviceItem.java b/importPicture/src/hayashi/yuu/gpx/gui/DeviceItem.java new file mode 100644 index 0000000..c04b69c --- /dev/null +++ b/importPicture/src/hayashi/yuu/gpx/gui/DeviceItem.java @@ -0,0 +1,76 @@ +package hayashi.yuu.gpx.gui; + +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JPanel; + +/** + * public class PropertyItem extends JPanel implements ActionListener + * @author hayashi + * + */ +@SuppressWarnings("serial") +public abstract class DeviceItem extends JPanel implements ActionListener +{ + JLabel label; + JComponent field; + String value; // 設定データを保持する領域 + public static final int ITEM_WIDTH_1 = 120; + public static final int ITEM_WIDTH_2 = 80; + public static final int LINE_WIDTH = ITEM_WIDTH_1 + ITEM_WIDTH_2; + public static final int LINE_HEIGHT = 18; + + /** + * コンストラクタ + * @param prop2 + * @param name + * @param editable + */ + public DeviceItem(String name) { + super(null); + this.value = new String(""); + } + + void createItem(String name, String value) { + this.value = value; + setupLabel(name, value); + setupField(value); + + label.setBounds(0, 0, ITEM_WIDTH_1 - 6, LINE_HEIGHT); + field.setBounds(ITEM_WIDTH_1, 0, ITEM_WIDTH_2, LINE_HEIGHT); + setPreferredSize(new Dimension(ITEM_WIDTH_1, LINE_HEIGHT)); + } + + JLabel setupLabel(String name, String value) { + label = new JLabel(name, JLabel.RIGHT); + add(label); + return label; + } + + /** + * コーディング例: + * + * void setupField(String name, String value) { + * this.value = value; + * ((JTextField)field).setText(value); + * field.setFont(new Font("MS UI Gothic", Font.PLAIN, 12)); + * add(field); + * } + */ + abstract void setupField(String value); + + /** + * [反映]ボタンがクリックされたときの処理 + * + * public void actionPerformed(ActionEvent e) { + * GuardixMonitor.logger.fine("[反映] "+ label.getText() +" = "+ text.getText()); + * prop.setProperty(label.getText(), text.getText()); + * } + * @param e + */ + public abstract void actionPerformed(ActionEvent e); +} diff --git a/importPicture/src/hayashi/yuu/gpx/gui/FooterPanel.java b/importPicture/src/hayashi/yuu/gpx/gui/FooterPanel.java new file mode 100644 index 0000000..5db1fe8 --- /dev/null +++ b/importPicture/src/hayashi/yuu/gpx/gui/FooterPanel.java @@ -0,0 +1,36 @@ +package hayashi.yuu.gpx.gui; + +import javax.swing.*; + +import java.awt.Color; +import java.awt.FlowLayout; +import java.awt.GridBagLayout; + +@SuppressWarnings("serial") +public class FooterPanel extends JPanel +{ + GridBagLayout gbLayout = new GridBagLayout(); + + /** + * コンストラクタ + * @param keytagID + * @throws Exception + */ + public FooterPanel(String siteName) throws Exception { + super(); + this.setBackground(Color.DARK_GRAY); + + //------------------------------------------- + // Inner Reader panel + //---- + this.setLayout(new FlowLayout(FlowLayout.CENTER)); + this.setSize(800, 100); + + //------------------------------------------- + // ユーザーサイト名称 + //---- + JLabel siteNameLabel = new JLabel("ユーザーサイト : '"+ siteName +"' "); + siteNameLabel.setForeground(Color.LIGHT_GRAY); + add(siteNameLabel); + } +} diff --git a/importPicture/src/hayashi/yuu/gpx/gui/MainPanel.java b/importPicture/src/hayashi/yuu/gpx/gui/MainPanel.java new file mode 100644 index 0000000..61ae809 --- /dev/null +++ b/importPicture/src/hayashi/yuu/gpx/gui/MainPanel.java @@ -0,0 +1,55 @@ +package hayashi.yuu.gpx.gui; + +import javax.swing.JPanel; + + +@SuppressWarnings("serial") +public class MainPanel extends JPanel implements MainPanelData +{ + + ///////////////////////////////////////////////////////////////////////////////////////////////// + // + // スレッド に関するメソッド + // + + public static int timecount = 0; + + public static int getTimecount() { + return timecount; + } + + public static void setTimecount(int timecount) { + MainPanel.timecount = timecount; + } + + + ///////////////////////////////////////////////////////////////////////////////////////////////// + // + // MainPanel に関する共通メソッド + // + TouchScreen parentFrame; // 親フレーム + CollectData loginUser; // 認証されたユーザー(USER_MODEのときのみ有効) + + public long getLoginUserId() { + if (this.loginUser == null) { + return 0L; + } + return this.loginUser.getId(); + } + + public CollectData getLoginUser() { + return this.loginUser; + } + + public TouchScreen getParentFrame() { + return this.parentFrame; + } + + public void setLoginUser(CollectData loginUser) { + this.loginUser = loginUser; + } + + public void setParentFrame(TouchScreen touchScreen) { + this.parentFrame = touchScreen; + } +} diff --git a/importPicture/src/hayashi/yuu/gpx/gui/MainPanelData.java b/importPicture/src/hayashi/yuu/gpx/gui/MainPanelData.java new file mode 100644 index 0000000..d64cca9 --- /dev/null +++ b/importPicture/src/hayashi/yuu/gpx/gui/MainPanelData.java @@ -0,0 +1,35 @@ +package hayashi.yuu.gpx.gui; + + +public interface MainPanelData { + /** + * 親フレームの設定 + * @param parentFrame + */ + public void setParentFrame(TouchScreen parentFrame); + + /** + * 親フレームの取得 + * @return + */ + public TouchScreen getParentFrame(); + + /** + * ログインユーザーの設定 + * @param loginUser + */ + public void setLoginUser(CollectData loginUser); + + /** + * ログインユーザーの取得 + * @return + */ + public CollectData getLoginUser(); + + /** + * ログインユーザーの取得 + * @return + */ + public long getLoginUserId(); + +} diff --git a/importPicture/src/hayashi/yuu/gpx/gui/PictureMapper.java b/importPicture/src/hayashi/yuu/gpx/gui/PictureMapper.java new file mode 100644 index 0000000..a58c809 --- /dev/null +++ b/importPicture/src/hayashi/yuu/gpx/gui/PictureMapper.java @@ -0,0 +1,521 @@ +package hayashi.yuu.gpx.gui; + +import hayashi.yuu.tools.mail.gui.SettingDialog; + +import java.awt.*; +import java.awt.event.*; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.util.Calendar; +import java.util.Iterator; +import java.util.Vector; +import java.util.logging.LogManager; +import java.util.logging.Logger; + +import javax.swing.JFrame; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JTextArea; +import javax.swing.JToggleButton; +import javax.swing.WindowConstants; +import javax.swing.table.DefaultTableColumnModel; +import javax.swing.table.DefaultTableModel; + +import jp.co.areaweb.tools.csv.CsvFile; +import jp.co.areaweb.tools.csv.CsvRecord; + + +/** + * メインウインドウフレーム
+ * GUIでの操作。
+ * + * メニュー構成:
+ * [メニュー]
+ * [メニュー]->[ファイル(F)]
+ * [メニュー]->[ファイル(F)]->[設定...]
+ * [メニュー]->[ファイル(F)]->[カード名の保存(S)]
+ * [メニュー]->[ファイル(F)]->[終了(X)]
+ * [メニュー]->[モード(M)]
+ * [メニュー]->[モード(M)]->[冗長モード(V)]
+ * [メニュー]->[モード(M)]->[メール送信]
+ * [メニュー]->[モード(M)]->[XMLファイル出力]
+ * [メニュー]->[ヘルプ(H)]
+ * [メニュー]->[ヘルプ(H)]->[このプログラムについて...(A)]
+ *
+ * パネル構成:
+ * ・中央に、メインパネルを配置
+ * ・メインパネルに、テキスト表示パネルを配置
+ * ・メインパネルに、蒐集データを表示するテーブルパネルを配置
+ * ・下部にシリアル通信制御を行う「実行/停止」ボタンを配置
+ * + * @author hayashi + * + */ +public class PictureMapper extends JFrame implements ActionListener, WindowListener, PropertyChangeListener +{ + /** + * + */ + private static final long serialVersionUID = 1L; + + public static final String PROGRAM_NAME = "OSM PICTURE-mapper"; + + /** + * ログ設定プロパティファイルのファイル内容 + */ + protected static final String LOGGING_PROPERTIES_DATA + = "handlers=java.util.logging.ConsoleHandler\n" + + ".level=FINEST\n" + + "java.util.logging.ConsoleHandler.level=INFO\n" + + "java.util.logging.ConsoleHandler.formatter=deister.jp.tools.YuuLogFormatter"; + + /** + * static initializer によるログ設定の初期化 + */ + static { + final Logger logger = Logger.getLogger("SampleLogging"); + InputStream inStream = null; + try { + inStream = new ByteArrayInputStream(LOGGING_PROPERTIES_DATA.getBytes("UTF-8")); + try { + LogManager.getLogManager().readConfiguration(inStream); + logger.config("ログ設定: LogManagerを設定しました。"); + } + catch (IOException e) { + logger.warning("ログ設定: LogManager設定の際に例外が発生しました。:" + e.toString()); + } + } + catch (UnsupportedEncodingException e) { + logger.severe("ログ設定: UTF-8エンコーディングがサポートされていません。:" + e.toString()); + } + finally { + try { + if (inStream != null) { + inStream.close(); + } + } catch (IOException e) { + logger.warning("ログ設定: ログ設定プロパティファイルのストリームクローズ時に例外が発生しました。:"+ e.toString()); + } + } + } + + public static PictureMapper mainFrame; + boolean fComponentsAdjusted; + JPanel buttonPanel; + JToggleButton openButton; + JMenuBar mainMenuBar; // [メニュー] + JMenu menuFile; // [メニュー]->[ファイル(F)] + JMenuItem miSetting; // [メニュー]->[ファイル(F)]->[設定...] + + JMenuItem miSave; // [メニュー]->[ファイル(F)]->[登録データの保存(S)] + JMenuItem miExit; // [メニュー]->[ファイル(F)]->[終了(X)] + JMenu menuHelp; // [メニュー]->[ヘルプ(H)] + JMenuItem miAbout; // [メニュー]->[ヘルプ(H)]->[このプログラムについて...(A)] + public static JTextArea textArea; + public static JTable recordTable; + public static DefaultTableModel tmodel; + public static SettingDialog settingDialog; + + static boolean tagmenteMode = false; + static boolean autoMode = false; + public static Logger logger = Logger.getLogger(PROGRAM_NAME); // Loggerオブジェクトの生成 + protected boolean openFlag = false; + + //============================================ + // 以下は、データコレクターから読み取ったデータ + // + + /** + * データコレクターから読み取ったレコードを保持します。 + */ + public static Vector dataStore = new Vector(); + + /** + * カードの名称を定義したCSVファイル + */ + public static CsvFile taglistFile = null; + + // + // 以上 + //============================================ + + /** + * 「ImportPicture」
+ */ + public static void main(String args[]) throws Exception { + (new PictureMapper()).setVisible(true); + } + + /** + * コンストラクタ
+ * + * @throws Exception + */ + @SuppressWarnings("serial") + public PictureMapper() throws Exception { + // ログ出力 + PictureMapper.logger.info(PROGRAM_NAME + " - プログラム起動"); + + // 初期設定 + fComponentsAdjusted = false; + addWindowListener((WindowListener) this); + setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); + Container container = getContentPane(); + container.setLayout(new BorderLayout()); + setTitle(PROGRAM_NAME); + + mainFrame = this; + + this.openFlag = false; + + // [メニュー]->[ファイル(F)] + menuFile = new JMenu("ファイル(F)"); + menuFile.setMnemonic('F'); + menuFile.setFont(new Font("Dialog", 0, 12)); + + // [メニュー]->[ファイル(F)]->[設定...] + miSetting = new JMenuItem("設定..."); + miSetting.addActionListener(this); + miSetting.setFont(new Font("Dialog", 0, 12)); + menuFile.add(miSetting); + settingDialog = new SettingDialog(this, true, "config/sendmail.properties", logger); + + // [メニュー]->[ファイル(F)]->[登録データの保存(S)] + miSave = new JMenuItem("登録データの保存(S)"); + miSave.addActionListener(this); + miSave.setMnemonic('S'); + miSave.setFont(new Font("Dialog", 0, 12)); + menuFile.add(miSave); + + // [メニュー]->[ファイル(F)]->[------------] + menuFile.addSeparator(); + + // [メニュー]->[ファイル(F)]->[終了(X)] + miExit = new JMenuItem("終了(X)"); + miExit.addActionListener(this); + miExit.setMnemonic('X'); + miExit.setFont(new Font("Dialog", 0, 12)); + menuFile.add(miExit); + + // [メニュー]->[モード(M)] + + // [メニュー]->[ヘルプ(H)]->[GurdiX OEM monitor について...(A)] + miAbout = new JMenuItem("'" + PROGRAM_NAME + "'について...(A)"); + miAbout.addActionListener(this); + miAbout.setMnemonic('A'); + miAbout.setFont(new Font("Dialog", Font.PLAIN, 12)); + + // [メニュー]->[ヘルプ(H)] + menuHelp = new JMenu("ヘルプ(H)"); + menuHelp.setMnemonic('H'); + menuHelp.setFont(new Font("Dialog", Font.PLAIN, 12)); + menuHelp.add(miAbout); + + // [メニュー] + mainMenuBar = new JMenuBar(); + mainMenuBar.add(menuFile); + mainMenuBar.add(menuHelp); + getRootPane().setJMenuBar(mainMenuBar); + + //-------------------------------------------------------- + // 上部パネル + // モニターコンソール用のテキストエリア + //----------------------------------------------- + + // テキスト表示パネルを配置 + PictureMapper.textArea = new JTextArea(5, 30) { + /** + * + */ + private static final long serialVersionUID = 1L; + + @Override + public void append(String str) { + super.append(str); + textArea.setCaretPosition(textArea.getDocument().getLength()); + } + }; + PictureMapper.textArea.setEditable(false); + PictureMapper.textArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12)); + JScrollPane scrollPane = new JScrollPane(PictureMapper.textArea); + scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + scrollPane.setPreferredSize(new Dimension(500, 100)); + add(BorderLayout.NORTH, scrollPane); + + + //-------------------------------------------------------- + // 中央パネル + //----------------------------------------------- + + // 蒐集データを表示するテーブルパネルを配置 + tmodel = new DefaultTableModel(CollectData.columnNames, 0) { + @Override + public boolean isCellEditable(int row, int column) { + if ((column == 2) || (column == 3)) { + return true; + } + return false; + } + }; + recordTable = new JTable(tmodel); + recordTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + DefaultTableColumnModel columnModel = (DefaultTableColumnModel)recordTable.getColumnModel(); + columnModel.getColumn(0).setPreferredWidth(120); + columnModel.getColumn(1).setPreferredWidth(120); + columnModel.getColumn(2).setPreferredWidth(240); + columnModel.getColumn(3).setPreferredWidth(640 - 120 - 120 - 240); + + JScrollPane tablePanel = new JScrollPane(recordTable); + tablePanel.setPreferredSize(new Dimension(644, 240)); + add(BorderLayout.CENTER, tablePanel); + + //-------------------------------------------------------- + // 下部パネル + //----------------------------------------------- + + // 下部に「実行/停止」ボタンを配置 + openButton = new JToggleButton("実行"); + openButton.addActionListener(this); + openButton.setToolTipText("カード読取を開始します"); + JPanel southPanel = new JPanel(new FlowLayout()); + try { + southPanel.add(openButton); + southPanel.setSize(DeviceItem.LINE_WIDTH, DeviceItem.LINE_HEIGHT); + } + catch(Exception e) { + e.printStackTrace(); + PictureMapper.logger.warning(e.toString()); + } + getContentPane().add(BorderLayout.SOUTH, southPanel); + + pack(); + setLocationRelativeTo(null); + setVisible(true); + + //----------------------- + + taglistFile = new CsvFile((new File("config/taglist.csv")).getAbsolutePath()); + taglistFile.setCharsetName("utf8"); + taglistFile.load(); + if (PictureMapper.tagmenteMode) { + for (Iterator i = PictureMapper.taglistFile.iterator(); i.hasNext(); ) { + CsvRecord record = i.next(); + String idStr = (String)record.get(0); // ID + String addrStr = (String)record.get(1); // address + String nameStr = (String)record.get(2); // name + CollectData data = new CollectData(Calendar.getInstance().getTime(), idStr, addrStr, nameStr); + PictureMapper.tmodel.addRow(data.getRecordStrs()); + } + } + + //-------------------------- + // 自動起動 + //-- + if (PictureMapper.autoMode) { + doButtonAction(); + } + } + + public void addNotify() { + Dimension d = getSize(); + super.addNotify(); + if (fComponentsAdjusted) { + return; + } + setSize(getInsets().left + getInsets().right + d.width, getInsets().top + getInsets().bottom + d.height); + Component components[] = getComponents(); + for (int i = 0; i < components.length; i++) { + Point p = components[i].getLocation(); + p.translate(getInsets().left, getInsets().top); + components[i].setLocation(p); + } + + fComponentsAdjusted = true; + } + + TouchScreen screen = null; + + /** + * [実行/停止]ボタンがクリックされた時のアクション + */ + private void doButtonAction() { + openButton.setText("Requesting...."); + openButton.setEnabled(false); + if (openFlag) { + screen.screenMode = -1; + screen.setVisible(false); + screen.dispose(); + screen = null; + close(); + openFlag = false; + openButton.setText("実行"); + } + else { + open(); + try { + screen = new TouchScreen("カード登録"); + screen.init(); + //screen.setVisible(true); + } + catch (Exception e) { + e.printStackTrace(); + return; + } + openFlag = true; + openButton.setText("停止"); + } + openButton.setEnabled(true); + } + + /** + * 「実行」ボタンをクリックしたときの処理。 + * GuardiXデータコレクタとのシリアル通信ポートをオープンして、 + * シリアル通信ポートからのデータ受信処理スレッドを起動する。 + */ + public void open() { + PictureMapper.logger.info(PROGRAM_NAME + ".open()"); + + /* + * シリアルポートからのデータ読取処理を開始する。 + */ + + setVisible(true); + } + + /** + * GuardiXへの通信ポートとの送受信スレッドを停止して、 + * 通信ポートをクローズする。 + */ + public void close() { + PictureMapper.logger.info(PROGRAM_NAME + ".close()"); + System.gc(); + } + + + /** + * [メニュー]アクション:
+ * 各メニューのアクションを呼び出す。 + * @param event + */ + public void actionPerformed(ActionEvent event) { + Object object = event.getSource(); + if(object == miExit) { + miExit_Action(event); + } + else if (object == miSave) { + miSave_Action(event); + } + else if (object == miAbout) { + miAbout_Action(event); + } + else if (object == openButton) { + doButtonAction(); + } + } + + /** + * アクション: + * [メニュー]->[ヘルプ]->[このプログラムについて]
+ * このプログラムについて説明するダイアログウインドウを表示する。 + * @param event + */ + void miAbout_Action(java.awt.event.ActionEvent event){ + (new AboutDialog(this, true)).setVisible(true); + } + + /** + * アクション: + * [メニュー]->[ファイル]->[終了]
+ * 終了確認ダイアログウインドウを表示する。 + * @param event + */ + void miExit_Action(ActionEvent event) { + (new QuitDialog(this, true)).setVisible(true); + } + + /** + * アクション: + * [メニュー]->[ファイル]->[タグ名の保存(S)]
+ * 保存確認ダイアログウインドウを表示する。 + * + * @param event + */ + void miSave_Action(ActionEvent event) { + (new SaveDialog(this, true)).setVisible(true); + } + + /** + * [メニュー]->[モード(M)]変更 : アクション
+ * 「クイックモード」の値を反映させる。 + * @param evt + */ + public void propertyChange(PropertyChangeEvent evt) { + PictureMapper.logger.fine(PROGRAM_NAME + ".propertyChange()"); + } + + /** + * アクション:フレームウインドウがアクティブになった時の・オペレーション
+ * 何もしない。 + * @param arg0 イベント + */ + public void windowActivated(WindowEvent arg0) { + } + + /** + * アクション:フレームウインドウが閉じられた時の・オペレーション
+ * 何もしない。 + * @param arg0 イベント + */ + public void windowClosed(WindowEvent arg0) { + } + + /** + * アクション:フレームウインドウが閉じられる時の・オペレーション
+ * 何もしない。 + * @param arg0 イベント + */ + public void windowClosing(WindowEvent arg0) { + (new QuitDialog(this, true)).setVisible(true); + } + + /** + * アクション:フレームウインドウが非アクティブになった時の・オペレーション
+ * 何もしない。 + * @param arg0 イベント + */ + public void windowDeactivated(WindowEvent arg0) { + } + + /** + * アクション:フレームウインドウが最小化から戻った時の・オペレーション
+ * 何もしない。 + * @param arg0 イベント + */ + public void windowDeiconified(WindowEvent arg0) { + } + + /** + * アクション:フレームウインドウが最小化されたときの・オペレーション
+ * 何もしない。 + * @param arg0 イベント + */ + public void windowIconified(WindowEvent arg0) { + } + + /** + * アクション:ウインドウが開いた。
+ * 何もしない。 + * @param arg0 イベント + */ + public void windowOpened(WindowEvent arg0) { + } +} diff --git a/importPicture/src/hayashi/yuu/gpx/gui/QuitDialog.java b/importPicture/src/hayashi/yuu/gpx/gui/QuitDialog.java new file mode 100644 index 0000000..eaaad56 --- /dev/null +++ b/importPicture/src/hayashi/yuu/gpx/gui/QuitDialog.java @@ -0,0 +1,92 @@ +package hayashi.yuu.gpx.gui; + +import java.awt.Font; +import java.awt.Rectangle; +import java.awt.Toolkit; +import java.awt.Window; +import java.awt.event.WindowEvent; +import java.awt.event.WindowListener; + +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JFrame; +import javax.swing.JLabel; + +@SuppressWarnings("serial") +public class QuitDialog extends JDialog implements WindowListener +{ + JButton yesButton; + JButton noButton; + JLabel label1; + + public QuitDialog(JFrame parent, boolean modal) { + super(parent, modal); + addWindowListener((WindowListener) this); + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + + setLayout(null); + setSize(getInsets().left + getInsets().right + 337, getInsets().top + getInsets().bottom + 135); + + yesButton = new JButton(" 終了 "); + yesButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(new WindowEvent((Window)getParent(), 201)); + System.exit(0); + } + }); + yesButton.setBounds(getInsets().left + 72, getInsets().top + 80, 79, 22); + yesButton.setFont(new Font("Dialog", 1, 12)); + add(yesButton); + + noButton = new JButton("キャンセル"); + noButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(new WindowEvent(QuitDialog.this, WindowEvent.WINDOW_CLOSING)); + setVisible(false); + } + }); + noButton.setBounds(getInsets().left + 185, getInsets().top + 80, 99, 22); + noButton.setFont(new Font("Dialog", 1, 12)); + add(noButton); + + label1 = new JLabel("プログラムを終了します。", JLabel.CENTER); + label1.setBounds(78, 33, 180, 23); + add(label1); + setTitle("プログラムの終了"); + setResizable(false); + setVisible(true); + } + + public void setVisible(boolean b) { + if(b) { + Rectangle bounds = getParent().getBounds(); + Rectangle abounds = getBounds(); + setLocation(bounds.x + (bounds.width - abounds.width) / 2, bounds.y + (bounds.height - abounds.height) / 2); + } + super.setVisible(b); + } + + + public void windowActivated(WindowEvent e) { + } + + public void windowClosed(WindowEvent e) { + setVisible(false); + } + + public void windowClosing(WindowEvent e) { + setVisible(false); + } + + public void windowDeactivated(WindowEvent e) { + } + + public void windowDeiconified(WindowEvent e) { + } + + public void windowIconified(WindowEvent e) { + } + + public void windowOpened(WindowEvent e) { + } +} diff --git a/importPicture/src/hayashi/yuu/gpx/gui/SaveDialog.java b/importPicture/src/hayashi/yuu/gpx/gui/SaveDialog.java new file mode 100644 index 0000000..367f295 --- /dev/null +++ b/importPicture/src/hayashi/yuu/gpx/gui/SaveDialog.java @@ -0,0 +1,139 @@ +package hayashi.yuu.gpx.gui; +import java.awt.Rectangle; +import java.awt.Toolkit; +import java.awt.event.WindowEvent; +import java.awt.event.WindowListener; +import java.awt.BorderLayout; +import java.io.File; +import java.io.IOException; + +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.table.TableModel; + +import jp.co.areaweb.tools.csv.CsvFile; +import jp.co.areaweb.tools.csv.CsvRecord; + +@SuppressWarnings("serial") +public class SaveDialog extends JDialog implements WindowListener +{ + JLabel label1; + JButton okButton; + JLabel label2; + JFrame parent; + + public SaveDialog(JFrame parent, boolean modal) { + super(parent, modal); + addWindowListener(this); + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + + this.parent = parent; + setTitle("登録データの保存"); + getContentPane().setLayout(new BorderLayout()); + setSize(360,180); + + label1 = new JLabel("登録データの設定変更を保存します。", JLabel.CENTER); + label1.setBounds(10,10,340,20); + add(label1, BorderLayout.NORTH); + + File outfile = PictureMapper.taglistFile.getFile(); + label2 = new JLabel(outfile.getAbsolutePath(), JLabel.CENTER); + label2.setBounds(10,40,340,20); + add(label2, BorderLayout.CENTER); + + /* + * [OK]ボタン : このダイアログウインドウを閉じる + */ + okButton = new JButton("OK"); + okButton.setBounds(145,65,66,27); + okButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + // メインパネルに表示されているデータ内容をタグ定義ファイルに書き出す。 + TableModel model = PictureMapper.recordTable.getModel(); + int rowCnt = model.getRowCount(); + for (int i=0; i < rowCnt; i++) { + String idStr = (String)PictureMapper.recordTable.getValueAt(i, 1); + String addr = (String)PictureMapper.recordTable.getValueAt(i, 2); + String name = (String)PictureMapper.recordTable.getValueAt(i, 3); + CsvFile csvf = PictureMapper.taglistFile.find(0, idStr); + if (csvf.isEmpty()) { + // 新規タグ + CsvRecord line = new CsvRecord(); + line.add(idStr); + line.add(addr); + line.add(name); + PictureMapper.taglistFile.add(line); + } + else { + // 既存タグ + CsvRecord line = csvf.getFirst(); + if (!addr.equals(line.get(1))) { + line.set(1, addr); // アドレスの変更 + } + if (!name.equals(line.get(2))) { + line.set(2, name); // なまえの変更 + } + } + } + + try { + PictureMapper.taglistFile.save(); + } + catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + // このダイアログウインドウを閉じる + Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(new WindowEvent(SaveDialog.this, WindowEvent.WINDOW_CLOSING)); + setVisible(false); + } + }); + JPanel southPanel = new JPanel(); + southPanel.add(okButton); + add(southPanel, BorderLayout.SOUTH); + + setVisible(true); + } + + /** + * Shows or hides the component depending on the boolean flag b. + * @param b if true, show the component; otherwise, hide the component. + * @see java.awt.Component#isVisible + */ + public void setVisible(boolean b) { + if (b) { + Rectangle bounds = getParent().getBounds(); + Rectangle abounds = getBounds(); + setLocation(bounds.x + (bounds.width - abounds.width)/ 2, + bounds.y + (bounds.height - abounds.height)/2); + } + super.setVisible(b); + } + + public void windowClosed(WindowEvent e) { + setVisible(false); + } + + public void windowActivated(WindowEvent arg0) { + } + + public void windowClosing(WindowEvent arg0) { + setVisible(false); + } + + public void windowDeactivated(WindowEvent arg0) { + } + + public void windowDeiconified(WindowEvent arg0) { + } + + public void windowIconified(WindowEvent arg0) { + } + + public void windowOpened(WindowEvent arg0) { + } +} diff --git a/importPicture/src/hayashi/yuu/gpx/gui/StartModePanel.java b/importPicture/src/hayashi/yuu/gpx/gui/StartModePanel.java new file mode 100644 index 0000000..8eef1a2 --- /dev/null +++ b/importPicture/src/hayashi/yuu/gpx/gui/StartModePanel.java @@ -0,0 +1,66 @@ +package hayashi.yuu.gpx.gui; + +import javax.swing.ImageIcon; +import javax.swing.JLabel; + +import java.awt.Font; +import java.awt.GridLayout; + +@SuppressWarnings("serial") +public class StartModePanel extends MainPanel +{ + /** + * コンストラクタ + * @param touchScreen 親フレーム + */ + public StartModePanel(TouchScreen touchScreen) { + super(); + this.parent = touchScreen; + setParentFrame(touchScreen); + + this.setSize(800, 300); + this.setLayout(new GridLayout(2, 1)); + img = true; + imageon = new JLabel(new ImageIcon("lib/card.gif")); + imageoff = new JLabel(); + imageLabel = imageon; + this.add(imageLabel); + text = new JLabel("IDカードをかざしてください。", JLabel.CENTER); + text.setFont(new Font("MS PGothic", Font.BOLD, 18)); + this.add(text); + } + + public void run() { + while(true) { + if (img) { + //this.remove(imageon); + imageLabel = imageoff; + //this.remove(text); + parent.repaint(); + this.setVisible(true); + img = false; + try { + Thread.sleep(300); + } catch (InterruptedException e) {} + } + else { + // this.add(imageon); + imageLabel = imageon; + //this.add(text); + parent.repaint(); + imageon.setVisible(true); + img = true; + try { + Thread.sleep(1000); + } catch (InterruptedException e) {} + } + } + } + + TouchScreen parent; + JLabel imageLabel; + JLabel imageon; + JLabel imageoff; + JLabel text; + boolean img = false; +} diff --git a/importPicture/src/hayashi/yuu/gpx/gui/TitlePanel.java b/importPicture/src/hayashi/yuu/gpx/gui/TitlePanel.java new file mode 100644 index 0000000..d57c90f --- /dev/null +++ b/importPicture/src/hayashi/yuu/gpx/gui/TitlePanel.java @@ -0,0 +1,37 @@ +package hayashi.yuu.gpx.gui; + +import java.awt.FlowLayout; + +import javax.swing.ImageIcon; +import javax.swing.JLabel; +import javax.swing.JPanel; + +/** + * タッチパネルの上部に常時表示されるタイトルヘッダ + * + * 「proxSafe Commander3」のイメージ画像を表示する + *  filePath : ./lib/mainbanner2.jpg + * width: 800pix + * hight: 48pix + * + * @author hayashi + * + */ +@SuppressWarnings("serial") +public class TitlePanel extends JPanel { + static final String imagePath = "lib/mainbanner2.jpg"; + JLabel imageLabel; + JLabel terminalNameLabel; + + /** + * コンストラクタ + */ + public TitlePanel() { + super(); + this.setLayout(new FlowLayout()); + + imageLabel = new JLabel(); + imageLabel.setIcon(new ImageIcon(imagePath)); + add(imageLabel); + } +} diff --git a/importPicture/src/hayashi/yuu/gpx/gui/TouchScreen.java b/importPicture/src/hayashi/yuu/gpx/gui/TouchScreen.java new file mode 100644 index 0000000..e648ef6 --- /dev/null +++ b/importPicture/src/hayashi/yuu/gpx/gui/TouchScreen.java @@ -0,0 +1,189 @@ +package hayashi.yuu.gpx.gui; + +import java.awt.*; +import java.awt.event.*; + +import javax.swing.*; + + +/** + * 「タッチパネル画面」 + * + */ +@SuppressWarnings("serial") +public class TouchScreen extends JFrame implements Runnable +{ + MainPanel mainPanel; // キャビネット内のキータグ状況を表す + + /** + * コンストラクタ + * + * 画面サイズ: 800 x 600 + * + */ + public TouchScreen(String siteName) throws Exception { + super(); + this.setUndecorated(true); + + this.startModePanel = new StartModePanel(this); + + setLayout(new BorderLayout()); + this.setVisible(false); + this.setSize(800, 600); + + /* + * タイトルパネル + * 'proxSafe Commander3'のロゴイメージと、ターミナル名称 + * + * 画面サイズ: 800 x 600 + */ + TitlePanel titlePanel = new TitlePanel(); + add(BorderLayout.NORTH, titlePanel); + + /* + * メインパネル + * [ニュートラル表示]パネル + * + * 画面サイズ: 800 x ? + */ + printStartMessage(); + add(BorderLayout.CENTER, mainPanel); + + /* + * フッターパネル + * + */ + FooterPanel footerPanel = new FooterPanel(siteName); + add(BorderLayout.SOUTH, footerPanel); + setVisible(true); + + SymWindow aSymWindow = new SymWindow(); + addWindowListener(aSymWindow); + } + + + + ///////////////////////////////////////////////////////////////////////////////////////////////// + // + // Frame に関するメソッド + // + + public void init() { + setVisible(true); + //Thread threadA = new Thread(this); + //threadA.start(); + } + + public void setVisible(boolean b) { + if(b) { + // デスクトップ中央にJFrameを配置する + Dimension paneSize = this.getSize(); + Dimension screenSize = this.getToolkit().getScreenSize(); + this.setLocation((screenSize.width - paneSize.width) / 2, (screenSize.height - paneSize.height) / 2); + } + super.setVisible(b); + } + + public void addNotify() { + Dimension d = getSize(); + super.addNotify(); + setSize(getInsets().left + getInsets().right + d.width, getInsets().top + getInsets().bottom + d.height); + Component components[] = getComponents(); + for(int i = 0; i < components.length; i++) { + Point p = components[i].getLocation(); + p.translate(getInsets().left, getInsets().top); + components[i].setLocation(p); + } + } + + /** + * WindowClose 処理 + * @param event + */ + public void FrameClosing(WindowEvent event) { + // スレッドを停止する + setVisible(false); + dispose(); + } + + class SymWindow extends WindowAdapter + { + public void windowClosing(WindowEvent event) { + Object object = event.getSource(); + if(object == TouchScreen.this) { + FrameClosing(event); + } + } + } + + ///////////////////////////////////////////////////////////////////////////////////////////////// + // + // モード に関するメソッド + // + protected StartModePanel startModePanel; + /* + protected UnregisteredModePanel unregisteredModePanel; + protected BusyModePanel busyModePanel; + */ + + /* + * スクリーン遷移モード + */ + public int screenMode = START_MODE; // 現在のスクリーンモードを保持する + static final int START_MODE = 0; // ニュートラル + static final int USER_MODE = 1; // ユーザー認証済み(キー選択) + static final int UNREGISTERED_MODE = 2; // 未登録カードモード + static final int BUSY_MODE = 3; // データ更新処理中モード + static final int KEYTAG_MODE = 4; // キータグ返却モード(AUTO_RETURN) + + + /* + * 「ニュートラル」モード + * new ImageIcon("lib/card.gif"), "IDカードをかざしてください。" + * + */ + public void printStartMessage() { + this.screenMode = TouchScreen.START_MODE; + + // 表示パネルを切り替える + if (this.mainPanel != null) { + this.remove(this.mainPanel); + } + + this.mainPanel = this.startModePanel; + this.add(BorderLayout.CENTER, mainPanel); + this.setVisible(true); + this.repaint(); + } + + + @Override + public void run() { + while (this.screenMode == TouchScreen.START_MODE) { + // 表示パネルを切り替える + if (this.mainPanel != null) { + this.remove(this.mainPanel); + this.mainPanel = null; + + this.setVisible(true); + //this.repaint(); + + try { + Thread.sleep(300); + } catch (InterruptedException e) {} + } + else { + this.mainPanel = this.startModePanel; + this.add(BorderLayout.CENTER, mainPanel); + + this.setVisible(true); + //this.repaint(); + + try { + Thread.sleep(2000); + } catch (InterruptedException e) {} + } + } + } + +} \ No newline at end of file diff --git a/importPicture/src/osm/jp/gpx/ImportPicture.java b/importPicture/src/osm/jp/gpx/ImportPicture.java index c3ae229..de2dbd2 100644 --- a/importPicture/src/osm/jp/gpx/ImportPicture.java +++ b/importPicture/src/osm/jp/gpx/ImportPicture.java @@ -10,6 +10,8 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Locale; import java.util.Set; +import java.util.logging.LogManager; +import java.util.logging.Logger; import javax.xml.parsers.*; import javax.xml.transform.OutputKeys; @@ -25,6 +27,45 @@ import org.xml.sax.SAXException; public class ImportPicture { public static File gpxDir = new File("."); + + /** + * ログ設定プロパティファイルのファイル内容 + */ + protected static final String LOGGING_PROPERTIES_DATA + = "handlers=java.util.logging.ConsoleHandler\n" + + ".level=FINEST\n" + + "java.util.logging.ConsoleHandler.level=INFO\n" + + "java.util.logging.ConsoleHandler.formatter=hayashi.yuu.tools.logger.YuuLogFormatter"; + + /** + * static initializer によるログ設定の初期化 + */ + public static final Logger logger = Logger.getLogger("SampleLogging"); + static { + InputStream inStream = null; + try { + inStream = new ByteArrayInputStream(LOGGING_PROPERTIES_DATA.getBytes("UTF-8")); + try { + LogManager.getLogManager().readConfiguration(inStream); + logger.config("ログ設定: LogManagerを設定しました。"); + } + catch (IOException e) { + logger.warning("ログ設定: LogManager設定の際に例外が発生しました。:" + e.toString()); + } + } + catch (UnsupportedEncodingException e) { + logger.severe("ログ設定: UTF-8エンコーディングがサポートされていません。:" + e.toString()); + } + finally { + try { + if (inStream != null) { + inStream.close(); + } + } catch (IOException e) { + logger.warning("ログ設定: ログ設定プロパティファイルのストリームクローズ時に例外が発生しました。:"+ e.toString()); + } + } + } /** メイン * 画像ファイルをGPXファイルに取り込みます。