• R/O
  • HTTP
  • SSH
  • HTTPS

MeMoMa: Commit

Repository from CVS
https://osdn.net/cvs/view/gokigen/MeMoMa/


Commit MetaInfo

Révisionfdce5b50c5a4e06fbd63329365fe0d292a3d9a37 (tree)
l'heure2018-07-22 23:27:56
AuteurMRSa <mrsa@myad...>
CommiterMRSa

Message de Log

オブジェクトの削除以外の操作をヒストリに残すようにした。

Change Summary

Modification

--- a/app/src/main/java/jp/sourceforge/gokigen/memoma/Main.java
+++ b/app/src/main/java/jp/sourceforge/gokigen/memoma/Main.java
@@ -13,7 +13,7 @@ import android.view.Menu;
1313 import android.view.MenuItem;
1414 import android.view.Window;
1515
16-import jp.sourceforge.gokigen.memoma.fileio.MeMoMaDataInOutManager;
16+import jp.sourceforge.gokigen.memoma.io.MeMoMaDataInOutManager;
1717
1818 import static android.os.Build.VERSION_CODES.KITKAT;
1919
--- a/app/src/main/java/jp/sourceforge/gokigen/memoma/MeMoMaListener.java
+++ b/app/src/main/java/jp/sourceforge/gokigen/memoma/MeMoMaListener.java
@@ -30,9 +30,11 @@ import jp.sourceforge.gokigen.memoma.dialogs.ConfirmationDialog;
3030 import jp.sourceforge.gokigen.memoma.dialogs.CreditDialog;
3131 import jp.sourceforge.gokigen.memoma.dialogs.ItemSelectionDialog;
3232 import jp.sourceforge.gokigen.memoma.dialogs.TextEditDialog;
33+import jp.sourceforge.gokigen.memoma.drawers.GokigenSurfaceView;
3334 import jp.sourceforge.gokigen.memoma.drawers.MeMoMaCanvasDrawer;
3435 import jp.sourceforge.gokigen.memoma.extension.ExtensionActivity;
35-import jp.sourceforge.gokigen.memoma.fileio.MeMoMaDataInOutManager;
36+import jp.sourceforge.gokigen.memoma.holders.OperationHistoryHolder;
37+import jp.sourceforge.gokigen.memoma.io.MeMoMaDataInOutManager;
3638 import jp.sourceforge.gokigen.memoma.holders.LineStyleHolder;
3739 import jp.sourceforge.gokigen.memoma.holders.MeMoMaConnectLineHolder;
3840 import jp.sourceforge.gokigen.memoma.holders.MeMoMaObjectHolder;
@@ -51,1226 +53,1256 @@ import jp.sourceforge.gokigen.memoma.preference.Preference;
5153 */
5254 public class MeMoMaListener implements OnClickListener, OnTouchListener, OnKeyListener, IObjectSelectionReceiver, ConfirmationDialog.IResultReceiver, ObjectDataInputDialog.IResultReceiver, ItemSelectionDialog.ISelectionItemReceiver, TextEditDialog.ITextEditResultReceiver, ObjectAligner.IAlignCallback, SelectLineShapeDialog.IResultReceiver
5355 {
54- public static final int MENU_ID_PREFERENCES = (Menu.FIRST + 1); // 設定画面の表示
55- public static final int MENU_ID_ABOUT_GOKIGEN = (Menu.FIRST + 2); // アプリケーションの情報表示
56- public static final int MENU_ID_NEW = (Menu.FIRST + 3); // 新規作成
57- public static final int MENU_ID_EXTEND= (Menu.FIRST + 4); // 拡張機能
58- public static final int MENU_ID_ALIGN = (Menu.FIRST + 5); // オブジェクトの整列
59- public static final int MENU_ID_INSERT_PICTURE = (Menu.FIRST + 6); // 画像の指定
60- public static final int MENU_ID_OPERATION = (Menu.FIRST + 7); // 操作コマンド
61- public static final int MENU_ID_RENAME = (Menu.FIRST + 8); // リネーム
62- public static final int MENU_ID_CAPTURE = (Menu.FIRST + 9); // 画像のキャプチャ
63- public static final int MENU_ID_SHARE = (Menu.FIRST + 10); // 画像の共有
64-
65-
66- private AppCompatActivity parent = null; // 親分
67- private TextEditDialog editTextDialog = null; // テキスト編集用ダイアログ
68- private MeMoMaCanvasDrawer objectDrawer = null; // 画像の表示
69- private MeMoMaObjectHolder objectHolder = null; // オブジェクトの保持クラス
70- private MeMoMaConnectLineHolder lineHolder =null; // オブジェクト間の接続状態保持クラス
71- //private SelectFeatureListener featureListener = null; // 機能選択用のリスナ
72-
73- private MeMoMaDataInOutManager dataInOutManager = null;
74-
75- private OperationModeHolder drawModeHolder = null;
76- private LineStyleHolder lineStyleHolder = null;
77-
78- private ConfirmationDialog confirmationDialog = null;
79-
80- private ObjectDataInputDialog objectDataInputDialog = null;
81-
82- private SelectLineShapeDialog lineSelectionDialog = null;
83-
84- private ItemSelectionDialog itemSelectionDialog = null;
85- private ObjectOperationCommandHolder commandHolder = null;
86-
87- private boolean isEditing = false;
88- private Integer selectedObjectKey = 0;
89- private Integer objectKeyToDelete = 0;
90- private Integer selectedContextKey = 0;
91-
92- /**
93- * コンストラクタ
94- * @param argument
95- */
96- public MeMoMaListener(AppCompatActivity argument, MeMoMaDataInOutManager inoutManager)
97- {
98- parent = argument;
99- dataInOutManager = inoutManager;
100- lineHolder = new MeMoMaConnectLineHolder();
101- objectHolder = new MeMoMaObjectHolder(argument, lineHolder);
102- editTextDialog = new TextEditDialog(parent, R.drawable.icon);
103- //lineHolder = new MeMoMaConnectLineHolder();
104- //featureListener = new SelectFeatureListener(parent);
105- drawModeHolder = new OperationModeHolder(parent);
106-
107- lineStyleHolder = new LineStyleHolder(parent);
108- lineStyleHolder.prepare();
109-
110- // 新規作成時の確認ダイアログについて
111- confirmationDialog = new ConfirmationDialog(argument);
112- confirmationDialog.prepare(this, android.R.drawable.ic_dialog_alert, parent.getString(R.string.createnew_title), parent.getString(R.string.createnew_message));
113-
114- // オブジェクトのデータ入力ダイアログを生成
115- objectDataInputDialog = new ObjectDataInputDialog(argument, objectHolder);
116- objectDataInputDialog.setResultReceiver(this);
117-
118- // 接続線の形状と太さを選択するダイアログを生成
119- lineSelectionDialog = new SelectLineShapeDialog(argument, lineStyleHolder);
120- lineSelectionDialog.setResultReceiver(this);
121-
122- // アイテム選択ダイアログを生成
123- commandHolder = new ObjectOperationCommandHolder(argument);
124- itemSelectionDialog = new ItemSelectionDialog(argument);
125- itemSelectionDialog.prepare(this, commandHolder, parent.getString(R.string.object_operation));
126-
127- // 描画クラスの生成
128- objectDrawer = new MeMoMaCanvasDrawer(argument, objectHolder, lineStyleHolder, this);
129-
130- SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
131- String colorString = preferences.getString("backgroundColor", "0xff004000");
132- objectDrawer.setBackgroundColor(colorString);
133-
134- }
135-
136- /**
137- * がっつりこのクラスにイベントリスナを接続する
138- *
139- */
140- public void prepareListener()
141- {
142- SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
143-
144- // 表示位置リセットボタン
145- final ImageButton homeButton = (ImageButton) parent.findViewById(R.id.HomeButton);
146- homeButton.setOnClickListener(this);
147-
148- // 拡張ボタン
149- final ImageButton expandButton = (ImageButton) parent.findViewById(R.id.ExpandButton);
150- expandButton.setOnClickListener(this);
151-
152- // 作成ボタン
153- final ImageButton createObjectButton = (ImageButton) parent.findViewById(R.id.CreateObjectButton);
154- createObjectButton.setOnClickListener(this);
155-
156- final ImageButton deleteObjectButton = (ImageButton) parent.findViewById(R.id.DeleteObjectButton);
157- deleteObjectButton.setOnClickListener(this);
158-
159- // 線の形状切り替えボタン
160- final ImageButton lineStyleButton = (ImageButton) parent.findViewById(R.id.LineStyleButton);
161- lineStyleButton.setOnClickListener(this);
162-
163- // データ保存ボタン
164- final ImageButton saveButton = (ImageButton) parent.findViewById(R.id.SaveButton);
165- saveButton.setOnClickListener(this);
166-
167- // 画面描画クラス
168- final GokigenSurfaceView surfaceView = (GokigenSurfaceView) parent.findViewById(R.id.GraphicView);
169- surfaceView.setOnTouchListener(this);
170-
171- // スライドバーが動かされた時の処理
172- final SeekBar seekbar = (SeekBar) parent.findViewById(R.id.ZoomInOut);
173- seekbar.setOnSeekBarChangeListener(objectDrawer);
174- int progress = preferences.getInt("zoomProgress", 50);
175- seekbar.setProgress(progress);
176-
177- // 「実行中」の表示を消す
178- parent.setProgressBarIndeterminateVisibility(false);
179-
180- //// 起動時にデータを読み出す
181- prepareMeMoMaInfo();
182- }
183-
184- /**
185- * 終了準備
186- */
187- public void finishListener()
188- {
189- // 終了時に状態を保存する
190- saveData(true);
191- }
192-
193- /**
194- * スタート準備
195- */
196- public void prepareToStart()
197- {
198- // 設定に記録されているデータを画面に反映させる
199- SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
200-
201- // 描画オブジェクトの形状を設定する
202- //int objectStyle = Integer.parseInt(preferences.getString("drawStyle", "0"));
203-
204- // ラインの形状を取得し、設定する
205- setLineStyle();
206-
207- // 操作モードを画面に反映させる
208- updateButtons(Integer.parseInt(preferences.getString("operationMode", "0")));
209-
210- // 条件に合わせて、描画クラスを変更する
211- final GokigenSurfaceView surfaceView = (GokigenSurfaceView) parent.findViewById(R.id.GraphicView);
212- surfaceView.setCanvasDrawer(objectDrawer);
213-
214- // 背景画像(の名前)を設定しておく
215- String backgroundString = preferences.getString("backgroundUri", "");
216- objectDrawer.setBackgroundUri(backgroundString);
217- }
218-
219- /**
220- * 終了準備
221- */
222- public void shutdown()
223- {
224-
225- }
226-
227- /**
228- * 他画面から戻ってきたとき...
229- *
230- */
231- public void onActivityResult(int requestCode, int resultCode, Intent data)
232- {
233- if ((requestCode == MENU_ID_INSERT_PICTURE)&&(resultCode == Activity.RESULT_OK))
234- {
235- try
236- {
237- // 取得したuri を preferenceに記録する
238- SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
239- Uri backgroundUri = data.getData();
240- if (backgroundUri != null)
241- {
242- try
243- {
244- if (Build.VERSION.SDK_INT >= 19) {
245- final int takeFlags = data.getFlags() & (Intent.FLAG_GRANT_READ_URI_PERMISSION);
246- parent.getContentResolver().takePersistableUriPermission(backgroundUri, takeFlags);
247- }
248- SharedPreferences.Editor editor = preferences.edit();
249- editor.putString("backgroundUri", backgroundUri.toString());
250- editor.apply();
251- }
252- catch (Exception e)
253- {
254- e.printStackTrace();
56+ private static final int MENU_ID_PREFERENCES = (Menu.FIRST + 1); // 設定画面の表示
57+ private static final int MENU_ID_ABOUT_GOKIGEN = (Menu.FIRST + 2); // アプリケーションの情報表示
58+ private static final int MENU_ID_NEW = (Menu.FIRST + 3); // 新規作成
59+ private static final int MENU_ID_EXTEND= (Menu.FIRST + 4); // 拡張機能
60+ private static final int MENU_ID_ALIGN = (Menu.FIRST + 5); // オブジェクトの整列
61+ private static final int MENU_ID_INSERT_PICTURE = (Menu.FIRST + 6); // 画像の指定
62+ private static final int MENU_ID_OPERATION = (Menu.FIRST + 7); // 操作コマンド
63+ private static final int MENU_ID_RENAME = (Menu.FIRST + 8); // リネーム
64+ private static final int MENU_ID_CAPTURE = (Menu.FIRST + 9); // 画像のキャプチャ
65+ private static final int MENU_ID_SHARE = (Menu.FIRST + 10); // 画像の共有
66+ private static final int MENU_ID_UNDO = (Menu.FIRST + 11); // 処理の UNDO
67+
68+ private AppCompatActivity parent; // 親分
69+ private TextEditDialog editTextDialog; // テキスト編集用ダイアログ
70+ private MeMoMaCanvasDrawer objectDrawer; // 画像の表示
71+ private MeMoMaObjectHolder objectHolder; // オブジェクトの保持クラス
72+ private MeMoMaConnectLineHolder lineHolder; // オブジェクト間の接続状態保持クラス
73+ private OperationHistoryHolder historyHolder; // 操作履歴保持クラス
74+ //private SelectFeatureListener featureListener = null; // 機能選択用のリスナ
75+
76+ private MeMoMaDataInOutManager dataInOutManager;
77+
78+ private OperationModeHolder drawModeHolder;
79+ private LineStyleHolder lineStyleHolder;
80+
81+ private ConfirmationDialog confirmationDialog;
82+
83+ private ObjectDataInputDialog objectDataInputDialog;
84+
85+ private SelectLineShapeDialog lineSelectionDialog;
86+
87+ private ItemSelectionDialog itemSelectionDialog;
88+ private ObjectOperationCommandHolder commandHolder;
89+
90+ private boolean isEditing = false;
91+ private Integer selectedObjectKey = 0;
92+ private Integer objectKeyToDelete = 0;
93+ private Integer selectedContextKey = 0;
94+
95+ /**
96+ * コンストラクタ
97+ *
98+ */
99+ MeMoMaListener(AppCompatActivity argument, MeMoMaDataInOutManager inoutManager)
100+ {
101+ parent = argument;
102+ dataInOutManager = inoutManager;
103+ historyHolder = new OperationHistoryHolder();
104+ lineHolder = new MeMoMaConnectLineHolder(historyHolder);
105+ objectHolder = new MeMoMaObjectHolder(argument, lineHolder, historyHolder);
106+ editTextDialog = new TextEditDialog(parent, R.drawable.icon);
107+ //lineHolder = new MeMoMaConnectLineHolder();
108+ //featureListener = new SelectFeatureListener(parent);
109+ drawModeHolder = new OperationModeHolder(parent);
110+
111+ lineStyleHolder = new LineStyleHolder(parent);
112+ lineStyleHolder.prepare();
113+
114+ // 新規作成時の確認ダイアログについて
115+ confirmationDialog = new ConfirmationDialog(argument);
116+ confirmationDialog.prepare(this, android.R.drawable.ic_dialog_alert, parent.getString(R.string.createnew_title), parent.getString(R.string.createnew_message));
117+
118+ // オブジェクトのデータ入力ダイアログを生成
119+ objectDataInputDialog = new ObjectDataInputDialog(argument, objectHolder);
120+ objectDataInputDialog.setResultReceiver(this);
121+
122+ // 接続線の形状と太さを選択するダイアログを生成
123+ lineSelectionDialog = new SelectLineShapeDialog(argument, lineStyleHolder);
124+ lineSelectionDialog.setResultReceiver(this);
125+
126+ // アイテム選択ダイアログを生成
127+ commandHolder = new ObjectOperationCommandHolder(argument);
128+ itemSelectionDialog = new ItemSelectionDialog(argument);
129+ itemSelectionDialog.prepare(this, commandHolder, parent.getString(R.string.object_operation));
130+
131+ // 描画クラスの生成
132+ objectDrawer = new MeMoMaCanvasDrawer(argument, objectHolder, lineStyleHolder, this);
133+
134+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
135+ String colorString = preferences.getString("backgroundColor", "0xff004000");
136+ objectDrawer.setBackgroundColor(colorString);
137+
138+ }
139+
140+ /**
141+ * がっつりこのクラスにイベントリスナを接続する
142+ *
143+ */
144+ public void prepareListener()
145+ {
146+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
147+
148+ // 表示位置リセットボタン
149+ final ImageButton homeButton = parent.findViewById(R.id.HomeButton);
150+ homeButton.setOnClickListener(this);
151+
152+ // 拡張ボタン
153+ final ImageButton expandButton = parent.findViewById(R.id.ExpandButton);
154+ expandButton.setOnClickListener(this);
155+
156+ // 作成ボタン
157+ final ImageButton createObjectButton = parent.findViewById(R.id.CreateObjectButton);
158+ createObjectButton.setOnClickListener(this);
159+
160+ final ImageButton deleteObjectButton = parent.findViewById(R.id.DeleteObjectButton);
161+ deleteObjectButton.setOnClickListener(this);
162+
163+ // 線の形状切り替えボタン
164+ final ImageButton lineStyleButton = parent.findViewById(R.id.LineStyleButton);
165+ lineStyleButton.setOnClickListener(this);
166+
167+ // データ保存ボタン
168+ final ImageButton saveButton = parent.findViewById(R.id.SaveButton);
169+ saveButton.setOnClickListener(this);
170+
171+ // 画面描画クラス
172+ final GokigenSurfaceView surfaceView = parent.findViewById(R.id.GraphicView);
173+ surfaceView.setOnTouchListener(this);
174+
175+ // スライドバーが動かされた時の処理
176+ final SeekBar seekbar =parent.findViewById(R.id.ZoomInOut);
177+ seekbar.setOnSeekBarChangeListener(objectDrawer);
178+ int progress = preferences.getInt("zoomProgress", 50);
179+ seekbar.setProgress(progress);
180+
181+ // 「実行中」の表示を消す
182+ parent.setProgressBarIndeterminateVisibility(false);
183+
184+ //// 起動時にデータを読み出す
185+ prepareMeMoMaInfo();
186+ }
187+
188+ /**
189+ * 終了準備
190+ */
191+ public void finishListener()
192+ {
193+ // 終了時に状態を保存する
194+ saveData(true);
195+ }
196+
197+ /**
198+ * スタート準備
199+ */
200+ public void prepareToStart()
201+ {
202+ // 設定に記録されているデータを画面に反映させる
203+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
204+
205+ // 描画オブジェクトの形状を設定する
206+ //int objectStyle = Integer.parseInt(preferences.getString("drawStyle", "0"));
207+
208+ // ラインの形状を取得し、設定する
209+ setLineStyle();
210+
211+ // 操作モードを画面に反映させる
212+ updateButtons(Integer.parseInt(preferences.getString("operationMode", "0")));
213+
214+ // 条件に合わせて、描画クラスを変更する
215+ final GokigenSurfaceView surfaceView = parent.findViewById(R.id.GraphicView);
216+ surfaceView.setCanvasDrawer(objectDrawer);
217+
218+ // 背景画像(の名前)を設定しておく
219+ String backgroundString = preferences.getString("backgroundUri", "");
220+ objectDrawer.setBackgroundUri(backgroundString);
221+ }
222+
223+ /**
224+ * 終了準備
225+ */
226+ public void shutdown()
227+ {
228+
229+ }
230+
231+ /**
232+ * 他画面から戻ってきたとき...
233+ *
234+ */
235+ public void onActivityResult(int requestCode, int resultCode, Intent data)
236+ {
237+ if ((requestCode == MENU_ID_INSERT_PICTURE)&&(resultCode == Activity.RESULT_OK))
238+ {
239+ try
240+ {
241+ // 取得したuri を preferenceに記録する
242+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
243+ Uri backgroundUri = data.getData();
244+ if (backgroundUri != null)
245+ {
246+ try
247+ {
248+ if (Build.VERSION.SDK_INT >= 19) {
249+ final int takeFlags = data.getFlags() & (Intent.FLAG_GRANT_READ_URI_PERMISSION);
250+ parent.getContentResolver().takePersistableUriPermission(backgroundUri, takeFlags);
255251 }
256- // 背景画像イメージの更新処理
257- updateBackgroundImage(backgroundUri.toString());
258- }
259- System.gc();
260- }
261- catch (Exception ex)
262- {
263- Log.v(Main.APP_IDENTIFIER, "Ex:" + ex.toString() + " " + ex.getMessage());
264- }
265- return;
266- }
267- else if (requestCode == MENU_ID_PREFERENCES)
252+ SharedPreferences.Editor editor = preferences.edit();
253+ editor.putString("backgroundUri", backgroundUri.toString());
254+ editor.apply();
255+ }
256+ catch (Exception e)
257+ {
258+ e.printStackTrace();
259+ }
260+ // 背景画像イメージの更新処理
261+ updateBackgroundImage(backgroundUri.toString());
262+ }
263+ System.gc();
264+ }
265+ catch (Exception ex)
268266 {
269- // 背景色、背景画像の設定を行う。
270- SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
271- String colorString = preferences.getString("backgroundColor", "0xff004000");
272- objectDrawer.setBackgroundColor(colorString);
267+ Log.v(Main.APP_IDENTIFIER, "Ex:" + ex.toString() + " " + ex.getMessage());
268+ }
269+ return;
270+ }
271+ else if (requestCode == MENU_ID_PREFERENCES)
272+ {
273+ // 背景色、背景画像の設定を行う。
274+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
275+ String colorString = preferences.getString("backgroundColor", "0xff004000");
276+ objectDrawer.setBackgroundColor(colorString);
273277
274- // 背景画像イメージの更新処理
275- String backgroundString = preferences.getString("backgroundUri", "");
276- updateBackgroundImage(backgroundString);
278+ // 背景画像イメージの更新処理
279+ String backgroundString = preferences.getString("backgroundUri", "");
280+ updateBackgroundImage(backgroundString);
277281
278- Log.v(Main.APP_IDENTIFIER, "RETURENED PREFERENCES " + backgroundString);
282+ Log.v(Main.APP_IDENTIFIER, "RETURENED PREFERENCES " + backgroundString);
283+
284+ }
285+ else if (requestCode == MENU_ID_EXTEND)
286+ {
287+ // その他...今開いているファイルを読みなおす
288+ dataInOutManager.loadFile((String) parent.getTitle());
289+ }
290+ else
291+ {
292+ // 画面表示の準備を実行...
293+ //prepareToStart();
294+ return;
295+ }
296+ // 画面の再描画を指示する
297+ redrawSurfaceview();
298+ }
299+
300+ /**
301+ * 背景画像イメージの更新処理
302+ *
303+ */
304+ private void updateBackgroundImage(String uri)
305+ {
306+ // 背景画像イメージの更新処理
307+ GokigenSurfaceView graphView = parent.findViewById(R.id.GraphicView);
308+
309+ // ビットマップを設定する
310+ objectDrawer.updateBackgroundBitmap(uri, graphView.getWidth(), graphView.getHeight());
311+
312+ // 画面の再描画指示
313+ graphView.doDraw();
314+ }
315+
316+
317+ /**
318+ * クリックされたときの処理
319+ */
320+ public void onClick(View v)
321+ {
322+ int id = v.getId();
323+
324+ //Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::onClick() " + id);
325+ if (id == R.id.MeMoMaInfo)
326+ {
327+ // テキスト編集ダイアログを表示する
328+ showInfoMessageEditDialog();
329+ }
330+ else if (id == R.id.LineStyleButton)
331+ {
332+ // ライン形状を変えるダイアログで変更するように変更する
333+ selectLineShapeDialog();
334+ }
335+ else if (id == R.id.ExpandButton)
336+ {
337+ // 拡張メニューを呼び出す
338+ callExtendMenu();
339+ }
340+ else if ((id == R.id.DeleteObjectButton)||(id == R.id.CreateObjectButton))
341+ {
342+ // 削除ボタン or 作成ボタンが押された時の処理
343+ updateButtons(drawModeHolder.updateOperationMode(id));
344+ }
345+ else if (id == R.id.HomeButton)
346+ {
347+ // 表示位置をリセットする
348+ // 表示倍率と並行移動についてリセットする
349+ objectDrawer.resetScaleAndLocation((SeekBar) parent.findViewById(R.id.ZoomInOut));
279350
280- }
281- else if (requestCode == MENU_ID_EXTEND)
282- {
283- // その他...今開いているファイルを読みなおす
284- dataInOutManager.loadFile((String) parent.getTitle());
285- }
286- else
287- {
288- // 画面表示の準備を実行...
289- //prepareToStart();
290- return;
291- }
292351 // 画面の再描画を指示する
293- redrawSurfaceview();
294- }
295-
296- /**
297- * 背景画像イメージの更新処理
298- *
299- */
300- private void updateBackgroundImage(String uri)
301- {
302- // 背景画像イメージの更新処理
303- GokigenSurfaceView graphView = (GokigenSurfaceView) parent.findViewById(R.id.GraphicView);
304-
305- // ビットマップを設定する
306- objectDrawer.updateBackgroundBitmap(uri, graphView.getWidth(), graphView.getHeight());
307-
308- // 画面の再描画指示
309- graphView.doDraw();
310- }
311-
312-
313- /**
314- * クリックされたときの処理
315- */
316- public void onClick(View v)
317- {
318- int id = v.getId();
319-
320- //Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::onClick() " + id);
321- if (id == R.id.MeMoMaInfo)
322- {
323- // テキスト編集ダイアログを表示する
324- showInfoMessageEditDialog();
325- }
326- else if (id == R.id.LineStyleButton)
327- {
328- // ライン形状を変えるダイアログで変更するように変更する
329- selectLineShapeDialog();
330- }
331- else if (id == R.id.ExpandButton)
332- {
333- // 拡張メニューを呼び出す
334- callExtendMenu();
335- }
336- else if ((id == R.id.DeleteObjectButton)||(id == R.id.CreateObjectButton))
337- {
338- // 削除ボタン or 作成ボタンが押された時の処理
339- updateButtons(drawModeHolder.updateOperationMode(id));
340- }
341- else if (id == R.id.HomeButton)
342- {
343- /** 表示位置をリセットする **/
344- // 表示倍率と並行移動についてリセットする
345- objectDrawer.resetScaleAndLocation((SeekBar) parent.findViewById(R.id.ZoomInOut));
346-
347- // 画面の再描画を指示する
348- redrawSurfaceview();
349- }
350- else if (id == R.id.SaveButton)
351- {
352- // データ保存が指示された!
353- saveData(true);
354- }
355- }
356-
357- /**
358- * 触られたときの処理
359- *
360- */
361- public boolean onTouch(View v, MotionEvent event)
362- {
363- int id = v.getId();
364- // int action = event.getAction();
365-
366- //Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::onTouch() " + id);
367-
368- if (id == R.id.GraphicView)
369- {
370- // 画面をタッチした!
371- ((GokigenSurfaceView) v).onTouchEvent(event);
372- return (true);
373- }
374- return (false);
375- }
376-
377- /**
378- * キーを押したときの操作
379- */
380- public boolean onKey(View v, int keyCode, KeyEvent event)
381- {
382- int action = event.getAction();
383- if ((action == KeyEvent.ACTION_DOWN)&&(keyCode == KeyEvent.KEYCODE_DPAD_CENTER))
384- {
385- //
386- }
387-
388- Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::onKey() ");
389- return (false);
390- }
391-
392- /**
393- * メニューへのアイテム追加
394- * @param menu
395- * @return
396- */
397- public Menu onCreateOptionsMenu(Menu menu)
398- {
399- // 新規作成
400- MenuItem menuItem = menu.add(Menu.NONE, MENU_ID_NEW, Menu.NONE, parent.getString(R.string.createnew));
401- menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); /* for Android 3.1 */
402- menuItem.setIcon(android.R.drawable.ic_menu_add); // 丸プラス
403-
404- // 画像の共有
405- menuItem = menu.add(Menu.NONE, MENU_ID_SHARE, Menu.NONE, parent.getString(R.string.shareContent));
406- menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); /* for Android 3.1 */
407- menuItem.setIcon(android.R.drawable.ic_menu_share);
408-
409- // 画像のキャプチャ
410- menuItem = menu.add(Menu.NONE, MENU_ID_CAPTURE, Menu.NONE, parent.getString(R.string.capture_data));
411- menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); /* for Android 3.1 */
412- menuItem.setIcon(android.R.drawable.ic_menu_crop); // オブジェクトのキャプチャ
413-
414- // オブジェクトの整列
415- menuItem = menu.add(Menu.NONE, MENU_ID_ALIGN, Menu.NONE, parent.getString(R.string.align_data));
416- menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); /* for Android 3.1 */
417- menuItem.setIcon(android.R.drawable.ic_menu_rotate); // オブジェクトの整列
418-
419- // タイトルの変更
420- menuItem = menu.add(Menu.NONE, MENU_ID_RENAME, Menu.NONE, parent.getString(R.string.rename_title));
421- menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); /* for Android 3.1 */
422- menuItem.setIcon(android.R.drawable.ic_menu_edit); // タイトルの変更
423-
424- // 壁紙の選択
425- menuItem = menu.add(Menu.NONE, MENU_ID_INSERT_PICTURE, Menu.NONE, parent.getString(R.string.background_data));
426- menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); /* for Android 3.1 */
427- menuItem.setIcon(android.R.drawable.ic_menu_gallery); // 壁紙の選択
428-
429- // 拡張メニュー
430- menuItem = menu.add(Menu.NONE, MENU_ID_EXTEND, Menu.NONE, parent.getString(R.string.extend_menu));
431- menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); /* for Android 3.1 */
432- menuItem.setIcon(android.R.drawable.ic_menu_share); // 拡張メニュー...
433-
434- // 設定
435- menuItem = menu.add(Menu.NONE, MENU_ID_PREFERENCES, Menu.NONE, parent.getString(R.string.preference_name));
436- menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); /* for Android 3.1 */
437- menuItem.setIcon(android.R.drawable.ic_menu_preferences);
438-
439- // クレジット情報の表示
440- menuItem = menu.add(Menu.NONE, MENU_ID_ABOUT_GOKIGEN, Menu.NONE, parent.getString(R.string.about_gokigen));
441- menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); /* for Android 3.1 */
442- menuItem.setIcon(android.R.drawable.ic_menu_info_details);
443-
444- return (menu);
445- }
446-
447- /**
448- * メニュー表示前の処理
449- * @param menu
450- * @return
451- */
452- public void onPrepareOptionsMenu(Menu menu)
453- {
454- menu.findItem(MENU_ID_NEW).setVisible(true);
455- menu.findItem(MENU_ID_SHARE).setVisible(true);
456- menu.findItem(MENU_ID_CAPTURE).setVisible(true);
457- menu.findItem(MENU_ID_ALIGN).setVisible(true);
458- menu.findItem(MENU_ID_RENAME).setVisible(true);
459- menu.findItem(MENU_ID_INSERT_PICTURE).setVisible(true);
460- menu.findItem(MENU_ID_EXTEND).setVisible(true);
461- menu.findItem(MENU_ID_PREFERENCES).setVisible(true);
462- menu.findItem(MENU_ID_ABOUT_GOKIGEN).setVisible(true);
463- return;
464- }
465-
466- /**
467- * メニューのアイテムが選択されたときの処理
468- * @param item
469- * @return
470- */
471- public boolean onOptionsItemSelected(MenuItem item)
472- {
473- boolean result = false;
474- switch (item.getItemId())
475- {
476- case MENU_ID_PREFERENCES:
477- showPreference();
478- result = true;
479- break;
480-
481- case MENU_ID_ABOUT_GOKIGEN:
482- showAboutGokigen();
483- result = true;
484- break;
485-
486- case MENU_ID_NEW:
487- createNewScreen();
488- result = true;
489- break;
490-
491- case MENU_ID_EXTEND:
492- // 拡張メニューを呼び出す
493- callExtendMenu();
494- result = true;
495- break;
496-
497- case MENU_ID_ALIGN:
352+ redrawSurfaceview();
353+ }
354+ else if (id == R.id.SaveButton)
355+ {
356+ // データ保存が指示された!
357+ saveData(true);
358+ }
359+ }
360+
361+ /**
362+ * 触られたときの処理
363+ *
364+ */
365+ public boolean onTouch(View v, MotionEvent event)
366+ {
367+ int id = v.getId();
368+ // int action = event.getAction();
369+
370+ //Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::onTouch() " + id);
371+
372+ if (id == R.id.GraphicView)
373+ {
374+ // 画面をタッチした!
375+ v.onTouchEvent(event);
376+ return (true);
377+ }
378+ return (false);
379+ }
380+
381+ /**
382+ * キーを押したときの操作
383+ */
384+ public boolean onKey(View v, int keyCode, KeyEvent event)
385+ {
386+ int action = event.getAction();
387+ if ((action == KeyEvent.ACTION_DOWN)&&(keyCode == KeyEvent.KEYCODE_DPAD_CENTER))
388+ {
389+ //
390+ Log.v(Main.APP_IDENTIFIER, "KEY ENTER");
391+ }
392+
393+ Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::onKey() ");
394+ return (false);
395+ }
396+
397+ /**
398+ * メニューへのアイテム追加
399+ *
400+ */
401+ public Menu onCreateOptionsMenu(Menu menu)
402+ {
403+ // 新規作成
404+ MenuItem menuItem = menu.add(Menu.NONE, MENU_ID_NEW, Menu.NONE, parent.getString(R.string.createnew));
405+ menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); /* for Android 3.1 */
406+ menuItem.setIcon(android.R.drawable.ic_menu_add); // 丸プラス
407+
408+ // 画像の共有
409+ menuItem = menu.add(Menu.NONE, MENU_ID_SHARE, Menu.NONE, parent.getString(R.string.shareContent));
410+ menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); /* for Android 3.1 */
411+ menuItem.setIcon(android.R.drawable.ic_menu_share);
412+
413+ // 画像のキャプチャ
414+ menuItem = menu.add(Menu.NONE, MENU_ID_CAPTURE, Menu.NONE, parent.getString(R.string.capture_data));
415+ menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); /* for Android 3.1 */
416+ menuItem.setIcon(android.R.drawable.ic_menu_crop); // オブジェクトのキャプチャ
417+
418+ // 処理のUNDO
419+ menuItem = menu.add(Menu.NONE, MENU_ID_UNDO, Menu.NONE, parent.getString(R.string.undo_operation));
420+ menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); /* for Android 3.1 */
421+ menuItem.setIcon(android.R.drawable.ic_menu_revert);
422+
423+ // オブジェクトの整列
424+ menuItem = menu.add(Menu.NONE, MENU_ID_ALIGN, Menu.NONE, parent.getString(R.string.align_data));
425+ menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); /* for Android 3.1 */
426+ menuItem.setIcon(android.R.drawable.ic_menu_rotate); // オブジェクトの整列
427+
428+ // タイトルの変更
429+ menuItem = menu.add(Menu.NONE, MENU_ID_RENAME, Menu.NONE, parent.getString(R.string.rename_title));
430+ menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); /* for Android 3.1 */
431+ menuItem.setIcon(android.R.drawable.ic_menu_edit); // タイトルの変更
432+
433+ // 壁紙の選択
434+ menuItem = menu.add(Menu.NONE, MENU_ID_INSERT_PICTURE, Menu.NONE, parent.getString(R.string.background_data));
435+ menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); /* for Android 3.1 */
436+ menuItem.setIcon(android.R.drawable.ic_menu_gallery); // 壁紙の選択
437+
438+ // 拡張メニュー
439+ menuItem = menu.add(Menu.NONE, MENU_ID_EXTEND, Menu.NONE, parent.getString(R.string.extend_menu));
440+ menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); /* for Android 3.1 */
441+ menuItem.setIcon(android.R.drawable.ic_menu_share); // 拡張メニュー...
442+
443+ // 設定
444+ menuItem = menu.add(Menu.NONE, MENU_ID_PREFERENCES, Menu.NONE, parent.getString(R.string.preference_name));
445+ menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); /* for Android 3.1 */
446+ menuItem.setIcon(android.R.drawable.ic_menu_preferences);
447+
448+ // クレジット情報の表示
449+ menuItem = menu.add(Menu.NONE, MENU_ID_ABOUT_GOKIGEN, Menu.NONE, parent.getString(R.string.about_gokigen));
450+ menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); /* for Android 3.1 */
451+ menuItem.setIcon(android.R.drawable.ic_menu_info_details);
452+
453+ return (menu);
454+ }
455+
456+ /**
457+ * メニュー表示前の処理
458+ *
459+ *
460+ */
461+ public void onPrepareOptionsMenu(Menu menu)
462+ {
463+ menu.findItem(MENU_ID_NEW).setVisible(true);
464+ menu.findItem(MENU_ID_UNDO).setVisible(false);
465+ menu.findItem(MENU_ID_SHARE).setVisible(true);
466+ menu.findItem(MENU_ID_CAPTURE).setVisible(true);
467+ menu.findItem(MENU_ID_ALIGN).setVisible(true);
468+ menu.findItem(MENU_ID_RENAME).setVisible(true);
469+ menu.findItem(MENU_ID_INSERT_PICTURE).setVisible(true);
470+ menu.findItem(MENU_ID_EXTEND).setVisible(true);
471+ menu.findItem(MENU_ID_PREFERENCES).setVisible(true);
472+ menu.findItem(MENU_ID_ABOUT_GOKIGEN).setVisible(true);
473+ }
474+
475+ /**
476+ * メニューのアイテムが選択されたときの処理
477+ *
478+ *
479+ */
480+ public boolean onOptionsItemSelected(MenuItem item)
481+ {
482+ boolean result;
483+ switch (item.getItemId())
484+ {
485+ case MENU_ID_PREFERENCES:
486+ showPreference();
487+ result = true;
488+ break;
489+
490+ case MENU_ID_ABOUT_GOKIGEN:
491+ showAboutGokigen();
492+ result = true;
493+ break;
494+
495+ case MENU_ID_NEW:
496+ createNewScreen();
497+ result = true;
498+ break;
499+
500+ case MENU_ID_EXTEND:
501+ // 拡張メニューを呼び出す
502+ callExtendMenu();
503+ result = true;
504+ break;
505+
506+ case MENU_ID_ALIGN:
498507 // オブジェクトの整列を行う
499- alignData();
508+ alignData();
500509 result = true;
501- break;
502-
503- case MENU_ID_RENAME:
504- // タイトル名の変更 (テキスト編集ダイアログを表示する)
505- showInfoMessageEditDialog();
506- result = true;
507- break;
508-
509- case MENU_ID_INSERT_PICTURE:
510- // 背景画像の設定を行う
511- insertPicture();
512- result = true;
513- break;
514-
515- case MENU_ID_CAPTURE:
516- // 画面キャプチャを指示された場合...
517- doCapture(false);
518- result = true;
519- break;
520-
521- case MENU_ID_SHARE:
522- // 画面キャプチャ&共有を指示された場合...
523- doCapture(true);
524- result = true;
525- break;
526-
527- case android.R.id.home:
528- // アイコンが押された時の処理...
529- // テキスト編集ダイアログを表示する
530- showInfoMessageEditDialog();
531- result = true;
532- break;
533-
534- default:
535- result = false;
536- break;
537- }
538- return (result);
539- }
540-
541- /**
542- * 画像ファイルの挿入 (データファイルの更新)
543- *
544- */
545- private void insertPicture()
546- {
547- Intent intent;
548- if (Build.VERSION.SDK_INT >= 19) {
549- intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
550- intent.addCategory(Intent.CATEGORY_OPENABLE);
551- intent.setType("image/*");
552- //intent.setAction(Intent.ACTION_GET_CONTENT);
553- } else {
554- intent = new Intent();
555- intent.setType("image/*");
556- intent.setAction(Intent.ACTION_GET_CONTENT);
557- }
558- parent.startActivityForResult(intent, MENU_ID_INSERT_PICTURE);
559- }
560-
561- /**
562- * 画面キャプチャの実施
563- *
564- *
565- */
566- private void doCapture(boolean isShare)
567- {
568- // 画面のスクリーンショットをとる処理を実行する
569- dataInOutManager.doScreenCapture((String) parent.getTitle(), objectHolder, objectDrawer, isShare);
570-
571- // 画面を再描画する
572- redrawSurfaceview();
573- }
574-
575- /**
576- * アプリの情報を表示する
577- *
578- */
579- private void showAboutGokigen()
580- {
581- // アプリの情報(クレジット)を表示する!
582- parent.showDialog(R.id.info_about_gokigen);
583- }
584-
585- /**
586- * 拡張メニューを呼び出す
587- *
588- */
589- private void callExtendMenu()
590- {
591- // 現在表示中のデータをファイルに保存する
592- dataInOutManager.saveFile((String) parent.getTitle(), true);
593-
594- // 現在読み込んでいるファイルのファイル名を生成する
595- String fullPath = dataInOutManager.getDataFileFullPath((String) parent.getTitle(), ".xml");
596-
597- // ここで拡張メニューを呼び出す
598- // (渡すデータを作って Intentとする)
599- Intent intent = new Intent();
600-
601- intent.setAction(ExtensionActivity.MEMOMA_EXTENSION_LAUNCH_ACTIVITY);
602- intent.putExtra(ExtensionActivity.MEMOMA_EXTENSION_DATA_FULLPATH, fullPath);
603- intent.putExtra(ExtensionActivity.MEMOMA_EXTENSION_DATA_TITLE, (String) parent.getTitle());
604-
605- // データ表示用Activityを起動する
606- parent.startActivityForResult(intent, MENU_ID_EXTEND);
607- }
608-
609- /**
610- * データの読み込みを行う
611- *
612- */
613- private void prepareMeMoMaInfo()
614- {
615- // 設定に記録されているデータを画面のタイトルに反映させる
616- SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
617- String memomaInfo = preferences.getString("MeMoMaInfo", parent.getString(R.string.app_name));
618- parent.setTitle(memomaInfo);
619-
620- // アクションバーとファイル名の準備
621- android.support.v7.app.ActionBar bar = parent.getSupportActionBar();
622- if (bar != null)
623- {
624- dataInOutManager.prepare(objectHolder, bar, memomaInfo);
625- }
626-
627- //dataInOutManager.loadFile((String) parent.getTitle());
628- }
629-
630- /**
631- * データの保存を行う
632- *
633- *
634- * @param forceOverwrite trueの時は、ファイル名が確定していたときは(確認せずに)上書き保存を自動で行う。
635- *
636- */
637- private void saveData(boolean forceOverwrite)
638- {
639- dataInOutManager.saveFile((String) parent.getTitle(), forceOverwrite);
640- }
641-
642- /**
643- * データの整列を行う
644- *
645- */
646- private void alignData()
647- {
648- ObjectAligner aligner = new ObjectAligner(parent, this);
649- aligner.execute(objectHolder);
650- }
651-
652- /**
653- * メッセージ編集ダイアログを表示する
654- *
655- */
656- private void showInfoMessageEditDialog()
657- {
658- parent.showDialog(R.id.editTextArea);
659- }
660-
661- /**
662- * 新規作成が指示されたとき...全部クリアして作りなおして良いか確認する。
663- *
664- */
665- private void createNewScreen()
666- {
667- parent.showDialog(R.id.confirmation);
668- }
669-
670- /**
671- * 接続線の設定ダイアログを表示する
672- */
673- private void selectLineShapeDialog()
674- {
675- // 接続線の設定ダイアログを表示する...
676- parent.showDialog(R.id.selectline_dialog);
677- }
678-
679- /**
680- * メッセージ編集ダイアログの表示を準備する
681- *
682- */
683- private void prepareInfoMessageEditDialog(Dialog dialog)
684- {
685- String message = (String) parent.getTitle();
686- editTextDialog.prepare(dialog, this, parent.getString(R.string.dataTitle), message, true);
687- }
688-
689- /**
690- * メッセージ編集ダイアログの表示を準備する
691- *
692- */
693- private void prepareConfirmationDialog(Dialog dialog)
694- {
695- // Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::prepareConfirmationDialog() " );
696- }
697-
698- /**
699- * オブジェクト入力用ダイアログの表示を準備する
700- *
701- */
702- private void prepareObjectInputDialog(Dialog dialog)
703- {
704- Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::prepareObjectInputDialog(), key: " + selectedObjectKey);
705-
706- // ダイアログの準備を行う
707- objectDataInputDialog.prepareObjectInputDialog(dialog, selectedObjectKey);
708-
709- }
710-
711- /**
712- * アイテム選択ダイアログの表示を準備する
713- *
714- *
715- */
716- private void prepareItemSelectionDialog(Dialog dialog)
717- {
718- // アイテム選択ダイアログの表示設定
719- // (動的変更時。。。今回は固定なので何もしない)
720- }
721-
722- /**
723- * 接続線選択用ダイアログの表示を準備する
724- *
725- */
726- private void prepareLineSelectionDialog(Dialog dialog)
727- {
728- Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::prepareLineSelectionDialog(), key: " + selectedObjectKey);
729-
730- // ダイアログの準備を行う
731- lineSelectionDialog.prepareSelectLineShapeDialog(dialog, selectedObjectKey);
732- }
733-
734- /**
735- * 設定画面を表示する処理
736- */
737- private void showPreference()
738- {
739- try
740- {
741- // 設定画面を呼び出す
742- Intent prefIntent = new Intent(parent,Preference.class);
743- parent.startActivityForResult(prefIntent, MENU_ID_PREFERENCES);
744- }
745- catch (Exception e)
746- {
747- // 例外発生...なにもしない。
748- e.printStackTrace();
749- //updater.showMessage("ERROR", MainUpdater.SHOWMETHOD_DONTCARE);
750- }
751- }
752-
753- /**
754- * 接続線の形状を反映させる
755- *
756- */
757- private void setLineStyle()
758- {
759- int buttonId = LineStyleHolder.getLineShapeImageId(lineStyleHolder.getLineStyle(), lineStyleHolder.getLineShape());
760- final ImageButton lineStyleObj = (ImageButton) parent.findViewById(R.id.LineStyleButton);
761- lineStyleObj.setImageResource(buttonId);
762- }
763-
764- /**
765- * オブジェクトが生成された!
766- *
767- */
768- public void objectCreated()
769- {
770- // ここで動作モードを移動モードに戻す。
771- drawModeHolder.changeOperationMode(OperationModeHolder.OPERATIONMODE_MOVE);
772- updateButtons(OperationModeHolder.OPERATIONMODE_MOVE);
773-
774- // 画面を再描画する
775- redrawSurfaceview();
776- }
777-
778- /**
779- * 空き領域がタッチされた!
780- *
781- */
782- public int touchedVacantArea()
783- {
784- SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
785- return (Integer.parseInt(preferences.getString("operationMode", "0")));
786- }
787-
788- /**
789- * 空き領域でタッチが離された!
790- *
791- */
792- public int touchUppedVacantArea()
793- {
794- SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
795- return (Integer.parseInt(preferences.getString("operationMode", "0")));
796- }
797-
798- /**
799- * オブジェクトを本当に削除して良いか確認した後に、オブジェクトを削除する。
800- *
801- *
802- */
803- private void removeObject(Integer key)
804- {
805- // 本当に消して良いか、確認をするダイアログを表示して、OKが押されたら消す。
806- AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(parent);
807- alertDialogBuilder.setTitle(parent.getString(R.string.deleteconfirm_title));
808- alertDialogBuilder.setIcon(android.R.drawable.ic_dialog_alert);
809- alertDialogBuilder.setMessage(parent.getString(R.string.deleteconfirm_message));
810-
811- // 削除するオブジェクトのキーを覚えこむ。
812- objectKeyToDelete = key;
813-
814- // OKボタンの生成
815- alertDialogBuilder.setPositiveButton(parent.getString(R.string.confirmYes), new DialogInterface.OnClickListener()
816- {
817- public void onClick(DialogInterface dialog, int id)
818- {
819- // 削除モードの時... 確認後削除だけど、今は確認なしで削除を行う。
820- objectHolder.removePosition(objectKeyToDelete);
821-
822- // 削除するオブジェクトに接続されている線もすべて削除する
823- objectHolder.getConnectLineHolder().removeAllConnection(objectKeyToDelete);
824-
825- // ダイアログを閉じる
826- dialog.dismiss();
827-
828- // ここで動作モードを削除モードから移動モードに戻す。
829- drawModeHolder.changeOperationMode(OperationModeHolder.OPERATIONMODE_MOVE);
830- updateButtons(OperationModeHolder.OPERATIONMODE_MOVE);
831-
832-
833- // 画面を再描画する
834- redrawSurfaceview();
835- }
836- });
837-
838- // Cancelボタンの生成
839- alertDialogBuilder.setNegativeButton(parent.getString(R.string.confirmNo), new DialogInterface.OnClickListener()
840- {
841- public void onClick(DialogInterface dialog, int id)
842- {
843- dialog.cancel();
844- }
845- });
846-
847- // ダイアログはキャンセル可能に設定する
848- alertDialogBuilder.setCancelable(true);
849-
850- // ダイアログを表示する
851- AlertDialog alertDialog = alertDialogBuilder.create();
852- alertDialog.show();
853- }
854-
855- /**
856- * オブジェクトを複製する
857- *
858- *
859- */
860- private void duplicateObject(Integer key)
861- {
862- // 選択中オブジェクトを複製する
863- objectHolder.duplicatePosition(key);
864-
865- // 画面を再描画する
866- redrawSurfaceview();
867- }
868-
869- /**
870- * オブジェクトを拡大する
871- *
872- *
873- */
874- private void expandObject(Integer key)
875- {
876- // 選択中オブジェクトを拡大する
877- objectHolder.expandObjectSize(key);
878-
879- // 画面を再描画する
880- redrawSurfaceview();
881- }
882- /**
883- * オブジェクトを縮小する
884- *
885- *
886- */
887- private void shrinkObject(Integer key)
888- {
889- // 選択中オブジェクトを縮小する
890- objectHolder.shrinkObjectSize(key);
891-
892- // 画面を再描画する
893- redrawSurfaceview();
894- }
895-
896- private void setButtonBorder(ImageButton button, boolean isHighlight)
897- {
898- try
899- {
900- BitmapDrawable btnBackgroundShape = (BitmapDrawable)button.getBackground();
901- if (isHighlight)
902- {
903-// btnBackgroundShape.setColorFilter(Color.rgb(51, 181, 229), Mode.LIGHTEN);
904- btnBackgroundShape.setColorFilter(Color.BLUE, Mode.LIGHTEN);
905- }
906- else
907- {
908- btnBackgroundShape.setColorFilter(Color.BLACK, Mode.LIGHTEN);
909- }
910- }
911- catch (Exception ex)
912- {
913- //
914- Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::setButtonBorder(): " + ex.toString());
915- }
916- }
917-
918- /**
919- * ボタンを更新する
920- *
921- */
922- private void updateButtons(int mode)
923- {
924- final ImageButton createObjectButton = (ImageButton) parent.findViewById(R.id.CreateObjectButton);
925- final ImageButton deleteObjectButton = (ImageButton) parent.findViewById(R.id.DeleteObjectButton);
926-
927- if (mode == OperationModeHolder.OPERATIONMODE_DELETE)
928- {
929- setButtonBorder(createObjectButton, false);
930- setButtonBorder(deleteObjectButton, true);
931- }
932- else if (mode == OperationModeHolder.OPERATIONMODE_CREATE)
933- {
934- setButtonBorder(createObjectButton, true);
935- setButtonBorder(deleteObjectButton, false);
936- }
937- else // if (mode == OperationModeHolder.OPERATIONMODE_MOVE)
938- {
939- setButtonBorder(createObjectButton, false);
940- setButtonBorder(deleteObjectButton, false);
941- }
942- }
943-
944-
945- /**
946- * オブジェクトが選択された(長押しで!)
947- *
948- */
949- public void objectSelectedContext(Integer key)
950- {
951- Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::objectSelectedContext(), key:" + key);
952- selectedContextKey = key;
953-
954- // オブジェクトのアイテム選択ダイアログを表示する...
955- parent.showDialog(MENU_ID_OPERATION);
956-
957- }
958-
959-
960- /**
961- * オブジェクトが選択された!
962- *
963- */
964- public boolean objectSelected(Integer key)
965- {
966- SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
967- int operationMode = Integer.parseInt(preferences.getString("operationMode", "0"));
968- if (operationMode == OperationModeHolder.OPERATIONMODE_DELETE)
969- {
970- // オブジェクトを削除する
971- removeObject(key);
972-
973- return (true);
974- }
975- //if ((operationMode == OperationModeHolder.OPERATIONMODE_MOVE)||
976- // (operationMode == OperationModeHolder.OPERATIONMODE_CREATE))
977- {
978- // 選択されたオブジェクトを記憶する
979- selectedObjectKey = key;
980- Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::objectSelected() key : " + key);
981-
982- // オブジェクトの詳細設定ダイアログを表示する...
983- parent.showDialog(R.id.objectinput_dialog);
984- }
985- return (true);
986- }
987-
988- /**
989- * ダイアログの生成
990- *
991- */
992- public Dialog onCreateDialog(int id)
993- {
994- if (id == R.id.info_about_gokigen)
995- {
996- // クレジットダイアログを表示
997- CreditDialog dialog = new CreditDialog(parent);
998- return (dialog.getDialog());
999- }
1000- if (id == R.id.editTextArea)
1001- {
1002- // 変更するテキストを表示
1003- return (editTextDialog.getDialog());
1004- }
1005- if (id == R.id.confirmation)
1006- {
1007- // 確認するメッセージを表示する
1008- return (confirmationDialog.getDialog());
1009- }
1010- if (id == R.id.objectinput_dialog)
1011- {
1012- // オブジェクト入力のダイアログを表示する
1013- return (objectDataInputDialog.getDialog());
1014- }
1015- if (id == MENU_ID_OPERATION)
1016- {
1017- // アイテム選択ダイアログの準備を行う
1018- return (itemSelectionDialog.getDialog());
1019- }
1020- if (id == R.id.selectline_dialog)
1021- {
1022- // 接続線選択ダイアログの準備を行う
1023- return (lineSelectionDialog.getDialog());
1024- }
1025- return (null);
1026- }
1027-
1028- /**
1029- * ダイアログ表示の準備
1030- *
1031- */
1032- public void onPrepareDialog(int id, Dialog dialog)
1033- {
1034- if (id == R.id.editTextArea)
1035- {
1036- // 変更するデータを表示する
1037- prepareInfoMessageEditDialog(dialog);
1038- return;
1039- }
1040- if (id == R.id.confirmation)
510+ break;
511+
512+ case MENU_ID_RENAME:
513+ // タイトル名の変更 (テキスト編集ダイアログを表示する)
514+ showInfoMessageEditDialog();
515+ result = true;
516+ break;
517+
518+ case MENU_ID_INSERT_PICTURE:
519+ // 背景画像の設定を行う
520+ insertPicture();
521+ result = true;
522+ break;
523+
524+ case MENU_ID_CAPTURE:
525+ // 画面キャプチャを指示された場合...
526+ doCapture(false);
527+ result = true;
528+ break;
529+
530+ case MENU_ID_SHARE:
531+ // 画面キャプチャ&共有を指示された場合...
532+ doCapture(true);
533+ result = true;
534+ break;
535+
536+ case android.R.id.home:
537+ // アイコンが押された時の処理...
538+ // テキスト編集ダイアログを表示する
539+ showInfoMessageEditDialog();
540+ result = true;
541+ break;
542+
543+ case MENU_ID_UNDO:
544+ // UNDO処理...
545+ result = undoOperation();
546+ break;
547+
548+ default:
549+ result = false;
550+ break;
551+ }
552+ return (result);
553+ }
554+
555+
556+ /**
557+ * 操作を1つ戻す(Undo 処理)
558+ *
559+ */
560+ private boolean undoOperation()
561+ {
562+ return (false);
563+ }
564+
565+ /**
566+ * 画像ファイルの挿入 (データファイルの更新)
567+ *
568+ */
569+ private void insertPicture()
570+ {
571+ Intent intent;
572+ if (Build.VERSION.SDK_INT >= 19) {
573+ intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
574+ intent.addCategory(Intent.CATEGORY_OPENABLE);
575+ intent.setType("image/*");
576+ //intent.setAction(Intent.ACTION_GET_CONTENT);
577+ } else {
578+ intent = new Intent();
579+ intent.setType("image/*");
580+ intent.setAction(Intent.ACTION_GET_CONTENT);
581+ }
582+ parent.startActivityForResult(intent, MENU_ID_INSERT_PICTURE);
583+ }
584+
585+ /**
586+ * 画面キャプチャの実施
587+ *
588+ *
589+ */
590+ private void doCapture(boolean isShare)
591+ {
592+ // 画面のスクリーンショットをとる処理を実行する
593+ dataInOutManager.doScreenCapture((String) parent.getTitle(), objectHolder, objectDrawer, isShare);
594+
595+ // 画面を再描画する
596+ redrawSurfaceview();
597+ }
598+
599+ /**
600+ * アプリの情報を表示する
601+ *
602+ */
603+ private void showAboutGokigen()
604+ {
605+ // アプリの情報(クレジット)を表示する!
606+ parent.showDialog(R.id.info_about_gokigen);
607+ }
608+
609+ /**
610+ * 拡張メニューを呼び出す
611+ *
612+ */
613+ private void callExtendMenu()
614+ {
615+ // 現在表示中のデータをファイルに保存する
616+ dataInOutManager.saveFile((String) parent.getTitle(), true);
617+
618+ // 現在読み込んでいるファイルのファイル名を生成する
619+ String fullPath = dataInOutManager.getDataFileFullPath((String) parent.getTitle(), ".xml");
620+
621+ // ここで拡張メニューを呼び出す
622+ // (渡すデータを作って Intentとする)
623+ Intent intent = new Intent();
624+
625+ intent.setAction(ExtensionActivity.MEMOMA_EXTENSION_LAUNCH_ACTIVITY);
626+ intent.putExtra(ExtensionActivity.MEMOMA_EXTENSION_DATA_FULLPATH, fullPath);
627+ intent.putExtra(ExtensionActivity.MEMOMA_EXTENSION_DATA_TITLE, (String) parent.getTitle());
628+
629+ // データ表示用Activityを起動する
630+ parent.startActivityForResult(intent, MENU_ID_EXTEND);
631+ }
632+
633+ /**
634+ * データの読み込みを行う
635+ *
636+ */
637+ private void prepareMeMoMaInfo()
638+ {
639+ // 設定に記録されているデータを画面のタイトルに反映させる
640+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
641+ String memomaInfo = preferences.getString("MeMoMaInfo", parent.getString(R.string.app_name));
642+ parent.setTitle(memomaInfo);
643+
644+ // アクションバーとファイル名の準備
645+ android.support.v7.app.ActionBar bar = parent.getSupportActionBar();
646+ if (bar != null)
647+ {
648+ dataInOutManager.prepare(objectHolder, bar, memomaInfo);
649+ }
650+
651+ //dataInOutManager.loadFile((String) parent.getTitle());
652+ }
653+
654+ /**
655+ * データの保存を行う
656+ *
657+ *
658+ * @param forceOverwrite trueの時は、ファイル名が確定していたときは(確認せずに)上書き保存を自動で行う。
659+ *
660+ */
661+ private void saveData(boolean forceOverwrite)
662+ {
663+ dataInOutManager.saveFile((String) parent.getTitle(), forceOverwrite);
664+ }
665+
666+ /**
667+ * データの整列を行う
668+ *
669+ */
670+ private void alignData()
671+ {
672+ ObjectAligner aligner = new ObjectAligner(parent, this);
673+ aligner.execute(objectHolder);
674+ }
675+
676+ /**
677+ * メッセージ編集ダイアログを表示する
678+ *
679+ */
680+ private void showInfoMessageEditDialog()
681+ {
682+ parent.showDialog(R.id.editTextArea);
683+ }
684+
685+ /**
686+ * 新規作成が指示されたとき...全部クリアして作りなおして良いか確認する。
687+ *
688+ */
689+ private void createNewScreen()
690+ {
691+ parent.showDialog(R.id.confirmation);
692+ }
693+
694+ /**
695+ * 接続線の設定ダイアログを表示する
696+ */
697+ private void selectLineShapeDialog()
698+ {
699+ // 接続線の設定ダイアログを表示する...
700+ parent.showDialog(R.id.selectline_dialog);
701+ }
702+
703+ /**
704+ * メッセージ編集ダイアログの表示を準備する
705+ *
706+ */
707+ private void prepareInfoMessageEditDialog(Dialog dialog)
708+ {
709+ String message = (String) parent.getTitle();
710+ editTextDialog.prepare(dialog, this, parent.getString(R.string.dataTitle), message, true);
711+ }
712+
713+ /**
714+ * メッセージ編集ダイアログの表示を準備する
715+ *
716+ */
717+ private void prepareConfirmationDialog(Dialog dialog)
718+ {
719+ // Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::prepareConfirmationDialog() " );
720+ }
721+
722+ /**
723+ * オブジェクト入力用ダイアログの表示を準備する
724+ *
725+ */
726+ private void prepareObjectInputDialog(Dialog dialog)
727+ {
728+ Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::prepareObjectInputDialog(), key: " + selectedObjectKey);
729+
730+ // ダイアログの準備を行う
731+ objectDataInputDialog.prepareObjectInputDialog(dialog, selectedObjectKey);
732+
733+ }
734+
735+ /**
736+ * アイテム選択ダイアログの表示を準備する
737+ *
738+ *
739+ */
740+ private void prepareItemSelectionDialog(Dialog dialog)
741+ {
742+ // アイテム選択ダイアログの表示設定
743+ // (動的変更時。。。今回は固定なので何もしない)
744+ }
745+
746+ /**
747+ * 接続線選択用ダイアログの表示を準備する
748+ *
749+ */
750+ private void prepareLineSelectionDialog(Dialog dialog)
751+ {
752+ Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::prepareLineSelectionDialog(), key: " + selectedObjectKey);
753+
754+ // ダイアログの準備を行う
755+ lineSelectionDialog.prepareSelectLineShapeDialog(dialog, selectedObjectKey);
756+ }
757+
758+ /**
759+ * 設定画面を表示する処理
760+ */
761+ private void showPreference()
762+ {
763+ try
764+ {
765+ // 設定画面を呼び出す
766+ Intent prefIntent = new Intent(parent,Preference.class);
767+ parent.startActivityForResult(prefIntent, MENU_ID_PREFERENCES);
768+ }
769+ catch (Exception e)
770+ {
771+ // 例外発生...なにもしない。
772+ e.printStackTrace();
773+ //updater.showMessage("ERROR", MainUpdater.SHOWMETHOD_DONTCARE);
774+ }
775+ }
776+
777+ /**
778+ * 接続線の形状を反映させる
779+ *
780+ */
781+ private void setLineStyle()
782+ {
783+ int buttonId = LineStyleHolder.getLineShapeImageId(lineStyleHolder.getLineStyle(), lineStyleHolder.getLineShape());
784+ final ImageButton lineStyleObj = parent.findViewById(R.id.LineStyleButton);
785+ lineStyleObj.setImageResource(buttonId);
786+ }
787+
788+ /**
789+ * オブジェクトが生成された!
790+ *
791+ */
792+ public void objectCreated()
793+ {
794+ // ここで動作モードを移動モードに戻す。
795+ drawModeHolder.changeOperationMode(OperationModeHolder.OPERATIONMODE_MOVE);
796+ updateButtons(OperationModeHolder.OPERATIONMODE_MOVE);
797+
798+ // 画面を再描画する
799+ redrawSurfaceview();
800+ }
801+
802+ /**
803+ * 空き領域がタッチされた!
804+ *
805+ */
806+ public int touchedVacantArea()
807+ {
808+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
809+ return (Integer.parseInt(preferences.getString("operationMode", "0")));
810+ }
811+
812+ /**
813+ * 空き領域でタッチが離された!
814+ *
815+ */
816+ public int touchUppedVacantArea()
817+ {
818+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
819+ return (Integer.parseInt(preferences.getString("operationMode", "0")));
820+ }
821+
822+ /**
823+ * オブジェクトを本当に削除して良いか確認した後に、オブジェクトを削除する。
824+ *
825+ *
826+ */
827+ private void removeObject(Integer key)
828+ {
829+ // 本当に消して良いか、確認をするダイアログを表示して、OKが押されたら消す。
830+ AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(parent);
831+ alertDialogBuilder.setTitle(parent.getString(R.string.deleteconfirm_title));
832+ alertDialogBuilder.setIcon(android.R.drawable.ic_dialog_alert);
833+ alertDialogBuilder.setMessage(parent.getString(R.string.deleteconfirm_message));
834+
835+ // 削除するオブジェクトのキーを覚えこむ。
836+ objectKeyToDelete = key;
837+
838+ // OKボタンの生成
839+ alertDialogBuilder.setPositiveButton(parent.getString(R.string.confirmYes), new DialogInterface.OnClickListener()
840+ {
841+ public void onClick(DialogInterface dialog, int id)
1041842 {
1042- // 確認ダイアログを表示する。
1043- prepareConfirmationDialog(dialog);
1044- return;
843+ // 削除モードの時... 確認後削除だけど、今は確認なしで削除を行う。
844+ objectHolder.removePosition(objectKeyToDelete);
845+
846+ // 削除するオブジェクトに接続されている線もすべて削除する
847+ objectHolder.getConnectLineHolder().removeAllConnection(objectKeyToDelete);
848+
849+ // ダイアログを閉じる
850+ dialog.dismiss();
851+
852+ // ここで動作モードを削除モードから移動モードに戻す。
853+ drawModeHolder.changeOperationMode(OperationModeHolder.OPERATIONMODE_MOVE);
854+ updateButtons(OperationModeHolder.OPERATIONMODE_MOVE);
855+
856+
857+ // 画面を再描画する
858+ redrawSurfaceview();
1045859 }
1046- if (id == R.id.objectinput_dialog)
860+ });
861+
862+ // Cancelボタンの生成
863+ alertDialogBuilder.setNegativeButton(parent.getString(R.string.confirmNo), new DialogInterface.OnClickListener()
864+ {
865+ public void onClick(DialogInterface dialog, int id)
1047866 {
1048- // オブジェクト入力のダイアログを表示する
1049- prepareObjectInputDialog(dialog);
867+ dialog.cancel();
1050868 }
1051- if (id == MENU_ID_OPERATION)
869+ });
870+
871+ // ダイアログはキャンセル可能に設定する
872+ alertDialogBuilder.setCancelable(true);
873+
874+ // ダイアログを表示する
875+ AlertDialog alertDialog = alertDialogBuilder.create();
876+ alertDialog.show();
877+ }
878+
879+ /**
880+ * オブジェクトを複製する
881+ *
882+ *
883+ */
884+ private void duplicateObject(Integer key)
885+ {
886+ // 選択中オブジェクトを複製する
887+ objectHolder.duplicatePosition(key);
888+
889+ // 画面を再描画する
890+ redrawSurfaceview();
891+ }
892+
893+ /**
894+ * オブジェクトを拡大する
895+ *
896+ *
897+ */
898+ private void expandObject(Integer key)
899+ {
900+ // 選択中オブジェクトを拡大する
901+ objectHolder.expandObjectSize(key);
902+
903+ // 画面を再描画する
904+ redrawSurfaceview();
905+ }
906+ /**
907+ * オブジェクトを縮小する
908+ *
909+ *
910+ */
911+ private void shrinkObject(Integer key)
912+ {
913+ // 選択中オブジェクトを縮小する
914+ objectHolder.shrinkObjectSize(key);
915+
916+ // 画面を再描画する
917+ redrawSurfaceview();
918+ }
919+
920+ private void setButtonBorder(ImageButton button, boolean isHighlight)
921+ {
922+ try
923+ {
924+ BitmapDrawable btnBackgroundShape = (BitmapDrawable)button.getBackground();
925+ if (isHighlight)
1052926 {
1053- // オブジェクト操作選択のダイアログを表示する
1054- prepareItemSelectionDialog(dialog);
927+// btnBackgroundShape.setColorFilter(Color.rgb(51, 181, 229), Mode.LIGHTEN);
928+ btnBackgroundShape.setColorFilter(Color.BLUE, Mode.LIGHTEN);
1055929 }
1056- if (id == R.id.selectline_dialog)
930+ else
1057931 {
1058- // 接続線選択のダイアログを表示する
1059- prepareLineSelectionDialog(dialog);
932+ btnBackgroundShape.setColorFilter(Color.BLACK, Mode.LIGHTEN);
1060933 }
1061- }
1062-
1063- /**
1064- * 新規状態に変更する。
1065- *
1066- */
1067- public void acceptConfirmation()
934+ }
935+ catch (Exception ex)
1068936 {
1069937 //
1070- Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::acceptConfirmation()");
1071-
1072- // オブジェクトデータをクリアする。
1073- objectHolder.removeAllPositions(); // オブジェクトの保持クラス
1074- objectHolder.getConnectLineHolder().removeAllLines(); // オブジェクト間の接続状態保持クラス
1075-
1076- // 画面の倍率と表示位置を初期状態に戻す
1077- if (objectDrawer != null)
1078- {
1079- final SeekBar zoomBar = (SeekBar) parent.findViewById(R.id.ZoomInOut);
1080- objectDrawer.resetScaleAndLocation(zoomBar);
1081- }
1082-
1083- /**
1084- // 題名を "無題"に変更し、関係情報をクリアする
1085- String newName = parent.getString(R.string.no_name);
1086- parent.setTitle(newName);
1087- SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
1088- SharedPreferences.Editor editor = preferences.edit();
1089- editor.putString("MeMoMaInfo", newName);
1090- editor.commit();
1091- **/
1092-
1093- // 画面を再描画する
1094- redrawSurfaceview();
938+ Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::setButtonBorder(): " + ex.toString());
939+ }
940+ }
941+
942+ /**
943+ * ボタンを更新する
944+ *
945+ */
946+ private void updateButtons(int mode)
947+ {
948+ final ImageButton createObjectButton = parent.findViewById(R.id.CreateObjectButton);
949+ final ImageButton deleteObjectButton = parent.findViewById(R.id.DeleteObjectButton);
950+
951+ if (mode == OperationModeHolder.OPERATIONMODE_DELETE)
952+ {
953+ setButtonBorder(createObjectButton, false);
954+ setButtonBorder(deleteObjectButton, true);
955+ }
956+ else if (mode == OperationModeHolder.OPERATIONMODE_CREATE)
957+ {
958+ setButtonBorder(createObjectButton, true);
959+ setButtonBorder(deleteObjectButton, false);
960+ }
961+ else // if (mode == OperationModeHolder.OPERATIONMODE_MOVE)
962+ {
963+ setButtonBorder(createObjectButton, false);
964+ setButtonBorder(deleteObjectButton, false);
965+ }
966+ }
1095967
1096- // ファイル名選択ダイアログを開く
1097- showInfoMessageEditDialog();
1098968
969+ /**
970+ * オブジェクトが選択された(長押しで!)
971+ *
972+ */
973+ public void objectSelectedContext(Integer key)
974+ {
975+ Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::objectSelectedContext(), key:" + key);
976+ selectedContextKey = key;
977+
978+ // オブジェクトのアイテム選択ダイアログを表示する...
979+ parent.showDialog(MENU_ID_OPERATION);
980+
981+ }
982+
983+
984+ /**
985+ * オブジェクトが選択された!
986+ *
987+ */
988+ public boolean objectSelected(Integer key)
989+ {
990+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
991+ int operationMode = Integer.parseInt(preferences.getString("operationMode", "0"));
992+ if (operationMode == OperationModeHolder.OPERATIONMODE_DELETE)
993+ {
994+ // オブジェクトを削除する
995+ removeObject(key);
996+
997+ return (true);
1099998 }
999+ //if ((operationMode == OperationModeHolder.OPERATIONMODE_MOVE)||
1000+ // (operationMode == OperationModeHolder.OPERATIONMODE_CREATE))
1001+ {
1002+ // 選択されたオブジェクトを記憶する
1003+ selectedObjectKey = key;
1004+ Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::objectSelected() key : " + key);
11001005
1101- /**
1102- * 画面を再描画する
1103- *
1104- */
1105- private void redrawSurfaceview()
1006+ // オブジェクトの詳細設定ダイアログを表示する...
1007+ parent.showDialog(R.id.objectinput_dialog);
1008+ }
1009+ return (true);
1010+ }
1011+
1012+ /**
1013+ * ダイアログの生成
1014+ *
1015+ */
1016+ public Dialog onCreateDialog(int id)
1017+ {
1018+ if (id == R.id.info_about_gokigen)
11061019 {
1107- final GokigenSurfaceView surfaceview = (GokigenSurfaceView) parent.findViewById(R.id.GraphicView);
1108- surfaceview.doDraw();
1020+ // クレジットダイアログを表示
1021+ CreditDialog dialog = new CreditDialog(parent);
1022+ return (dialog.getDialog());
11091023 }
1110-
1111- /**
1112- * 不許可。何もしない。
1113- *
1114- */
1115- public void rejectConfirmation()
1024+ if (id == R.id.editTextArea)
11161025 {
1117- Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::rejectConfirmation()");
1026+ // 変更するテキストを表示
1027+ return (editTextDialog.getDialog());
11181028 }
1119-
1120- /**
1121- * オブジェクトが整列された時の処理
1122- *
1123- */
1124- public void objectAligned()
1029+ if (id == R.id.confirmation)
11251030 {
1126- // 画面の再描画を指示する
1127- redrawSurfaceview();
1031+ // 確認するメッセージを表示する
1032+ return (confirmationDialog.getDialog());
11281033 }
1129-
1130- /**
1131- * オブジェクト編集ダイアログが閉じられた時の処理
1132- *
1133- */
1134- public void finishObjectInput()
1034+ if (id == R.id.objectinput_dialog)
11351035 {
1136- // 画面の再描画を指示する
1137- redrawSurfaceview();
1036+ // オブジェクト入力のダイアログを表示する
1037+ return (objectDataInputDialog.getDialog());
11381038 }
1139-
1140- /**
1141- * オブジェクト編集ダイアログが閉じられた時の処理
1142- *
1143- */
1144- public void cancelObjectInput()
1039+ if (id == MENU_ID_OPERATION)
11451040 {
1146- // 何もしない
1041+ // アイテム選択ダイアログの準備を行う
1042+ return (itemSelectionDialog.getDialog());
11471043 }
1148-
1149-
1150- /**
1151- * 現在編集中かどうかを知る
1152- *
1153- * @return
1154- */
1155- public boolean isEditing()
1044+ if (id == R.id.selectline_dialog)
11561045 {
1157- return (isEditing);
1046+ // 接続線選択ダイアログの準備を行う
1047+ return (lineSelectionDialog.getDialog());
11581048 }
1159-
1160- /**
1161- * 現在編集中のフラグを更新する
1162- *
1163- * @param value
1164- */
1165- public void setIsEditing(boolean value)
1049+ return (null);
1050+ }
1051+
1052+ /**
1053+ * ダイアログ表示の準備
1054+ *
1055+ */
1056+ public void onPrepareDialog(int id, Dialog dialog)
1057+ {
1058+ if (id == R.id.editTextArea)
11661059 {
1167- isEditing = value;
1060+ // 変更するデータを表示する
1061+ prepareInfoMessageEditDialog(dialog);
1062+ return;
11681063 }
1169-
1170- /**
1171- * アイテムが選択された!
1172- *
1173- */
1174- public void itemSelected(int index, String itemValue)
1064+ if (id == R.id.confirmation)
11751065 {
1176- //
1177- Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::itemSelected() : " + itemValue + " [" + index + "]");
1178-
1179- if (index == ObjectOperationCommandHolder.OBJECTOPERATION_DELETE)
1180- {
1181- // オブジェクト削除の確認
1182- removeObject(selectedContextKey);
1183- }
1184- else if (index == ObjectOperationCommandHolder.OBJECTOPERATION_DUPLICATE)
1185- {
1186- // オブジェクトの複製
1187- duplicateObject(selectedContextKey);
1188- }
1189- else if (index == ObjectOperationCommandHolder.OBJECTOPERATION_SIZEBIGGER)
1190- {
1191- // オブジェクトの拡大
1192- expandObject(selectedContextKey);
1193- }
1194- else if (index == ObjectOperationCommandHolder.OBJECTOPERATION_SIZESMALLER)
1195- {
1196- // オブジェクトの縮小
1197- shrinkObject(selectedContextKey);
1198- }
1066+ // 確認ダイアログを表示する。
1067+ prepareConfirmationDialog(dialog);
1068+ return;
1069+ }
1070+ if (id == R.id.objectinput_dialog)
1071+ {
1072+ // オブジェクト入力のダイアログを表示する
1073+ prepareObjectInputDialog(dialog);
1074+ }
1075+ if (id == MENU_ID_OPERATION)
1076+ {
1077+ // オブジェクト操作選択のダイアログを表示する
1078+ prepareItemSelectionDialog(dialog);
1079+ }
1080+ if (id == R.id.selectline_dialog)
1081+ {
1082+ // 接続線選択のダイアログを表示する
1083+ prepareLineSelectionDialog(dialog);
1084+ }
1085+ }
1086+
1087+ /**
1088+ * 新規状態に変更する。
1089+ *
1090+ */
1091+ public void acceptConfirmation()
1092+ {
1093+ //
1094+ Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::acceptConfirmation()");
1095+
1096+ // オブジェクトデータをクリアする。
1097+ objectHolder.removeAllPositions(); // オブジェクトの保持クラス
1098+ objectHolder.getConnectLineHolder().removeAllLines(); // オブジェクト間の接続状態保持クラス
1099+
1100+ // 画面の倍率と表示位置を初期状態に戻す
1101+ if (objectDrawer != null)
1102+ {
1103+ final SeekBar zoomBar = (SeekBar) parent.findViewById(R.id.ZoomInOut);
1104+ objectDrawer.resetScaleAndLocation(zoomBar);
11991105 }
12001106
1201- /**
1202- * (今回未使用)
1203- *
1204- */
1205- public void itemSelectedMulti(String[] items, boolean[] status)
1107+ /*
1108+ // 題名を "無題"に変更し、関係情報をクリアする
1109+ String newName = parent.getString(R.string.no_name);
1110+ parent.setTitle(newName);
1111+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
1112+ SharedPreferences.Editor editor = preferences.edit();
1113+ editor.putString("MeMoMaInfo", newName);
1114+ editor.commit();
1115+ */
1116+
1117+ // 画面を再描画する
1118+ redrawSurfaceview();
1119+
1120+ // ファイル名選択ダイアログを開く
1121+ showInfoMessageEditDialog();
1122+
1123+ }
1124+
1125+ /**
1126+ * 画面を再描画する
1127+ *
1128+ */
1129+ private void redrawSurfaceview()
1130+ {
1131+ final GokigenSurfaceView surfaceview = parent.findViewById(R.id.GraphicView);
1132+ surfaceview.doDraw();
1133+ }
1134+
1135+ /**
1136+ * 不許可。何もしない。
1137+ *
1138+ */
1139+ public void rejectConfirmation()
1140+ {
1141+ Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::rejectConfirmation()");
1142+ }
1143+
1144+ /**
1145+ * オブジェクトが整列された時の処理
1146+ *
1147+ */
1148+ public void objectAligned()
1149+ {
1150+ // 画面の再描画を指示する
1151+ redrawSurfaceview();
1152+ }
1153+
1154+ /**
1155+ * オブジェクト編集ダイアログが閉じられた時の処理
1156+ *
1157+ */
1158+ public void finishObjectInput()
1159+ {
1160+ // 画面の再描画を指示する
1161+ redrawSurfaceview();
1162+ }
1163+
1164+ /**
1165+ * オブジェクト編集ダイアログが閉じられた時の処理
1166+ *
1167+ */
1168+ public void cancelObjectInput()
1169+ {
1170+ // 何もしない
1171+ }
1172+
1173+
1174+ /**
1175+ * 現在編集中かどうかを知る
1176+ *
1177+ *
1178+ */
1179+ public boolean isEditing()
1180+ {
1181+ return (isEditing);
1182+ }
1183+
1184+ /**
1185+ * 現在編集中のフラグを更新する
1186+ *
1187+ *
1188+ */
1189+ public void setIsEditing(boolean value)
1190+ {
1191+ isEditing = value;
1192+ }
1193+
1194+ /**
1195+ * アイテムが選択された!
1196+ *
1197+ */
1198+ public void itemSelected(int index, String itemValue)
1199+ {
1200+ //
1201+ Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::itemSelected() : " + itemValue + " [" + index + "]");
1202+
1203+ if (index == ObjectOperationCommandHolder.OBJECTOPERATION_DELETE)
12061204 {
1207-
1205+ // オブジェクト削除の確認
1206+ removeObject(selectedContextKey);
12081207 }
1209- public void canceledSelection()
1208+ else if (index == ObjectOperationCommandHolder.OBJECTOPERATION_DUPLICATE)
12101209 {
1211-
1210+ // オブジェクトの複製
1211+ duplicateObject(selectedContextKey);
12121212 }
1213-
1214- public void onSaveInstanceState(Bundle outState)
1213+ else if (index == ObjectOperationCommandHolder.OBJECTOPERATION_SIZEBIGGER)
12151214 {
1216- /* ここで状態を保存 */
1217- //Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::onSaveInstanceState()");
1215+ // オブジェクトの拡大
1216+ expandObject(selectedContextKey);
12181217 }
1219-
1220- public void onRestoreInstanceState(Bundle savedInstanceState)
1218+ else if (index == ObjectOperationCommandHolder.OBJECTOPERATION_SIZESMALLER)
12211219 {
1222- /* ここで状態を復元 */
1223- Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::onRestoreInstanceState()");
1220+ // オブジェクトの縮小
1221+ shrinkObject(selectedContextKey);
1222+ }
1223+ }
1224+
1225+ /**
1226+ * (今回未使用)
1227+ *
1228+ */
1229+ public void itemSelectedMulti(String[] items, boolean[] status)
1230+ {
1231+
1232+ }
1233+ public void canceledSelection()
1234+ {
1235+
1236+ }
1237+
1238+ public void onSaveInstanceState(Bundle outState)
1239+ {
1240+ /* ここで状態を保存 */
1241+ Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::onSaveInstanceState() : " + outState.toString() );
1242+ }
1243+
1244+ public void onRestoreInstanceState(Bundle savedInstanceState)
1245+ {
1246+ /* ここで状態を復元 */
1247+ Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::onRestoreInstanceState() : " + savedInstanceState.toString());
1248+ }
1249+
1250+ public boolean finishTextEditDialog(String message)
1251+ {
1252+ if ((message == null)||(message.length() == 0))
1253+ {
1254+ // データが入力されていなかったので、何もしない。
1255+ return (false);
12241256 }
12251257
1226- public boolean finishTextEditDialog(String message)
1258+ try
12271259 {
1228- if ((message == null)||(message.length() == 0))
1229- {
1230- // データが入力されていなかったので、何もしない。
1231- return (false);
1232- }
1233-
1234- // 文字列を記録
1235- SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
1260+ // 文字列を記録
1261+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
12361262 SharedPreferences.Editor editor = preferences.edit();
12371263 editor.putString("MeMoMaInfo", message);
1238- editor.commit();
1264+ editor.apply();
12391265
12401266 // タイトルに設定
12411267 parent.setTitle(message);
12421268
1243- // 保存シーケンスを一度走らせる
1269+ // 保存シーケンスを一度走らせる
12441270 saveData(true);
12451271
12461272 // ファイル選択リストの更新
12471273 dataInOutManager.updateFileList(message, parent.getSupportActionBar());
12481274
1249- return (true);
12501275 }
1251- public boolean cancelTextEditDialog()
1276+ catch (Exception e)
12521277 {
1253- return (false);
1278+ e.printStackTrace();
12541279 }
1280+ return (true);
1281+ }
1282+ public boolean cancelTextEditDialog()
1283+ {
1284+ return (false);
1285+ }
1286+
1287+ /**
1288+ * 接続線
1289+ *
1290+ */
1291+ public void finishSelectLineShape(int style, int shape, int thickness)
1292+ {
1293+ int buttonId = LineStyleHolder.getLineShapeImageId(style, shape);
1294+ final ImageButton lineStyleObj =parent.findViewById(R.id.LineStyleButton);
1295+ lineStyleObj.setImageResource(buttonId);
1296+ //Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::finishSelectLineShape() buttonId:" + buttonId);
1297+ }
1298+
1299+ /**
1300+ *
1301+ *
1302+ */
1303+ public void cancelSelectLineShape()
1304+ {
1305+
1306+ }
12551307
1256- /**
1257- * 接続線
1258- *
1259- */
1260- public void finishSelectLineShape(int style, int shape, int thickness)
1261- {
1262- int buttonId = LineStyleHolder.getLineShapeImageId(style, shape);
1263- final ImageButton lineStyleObj = (ImageButton) parent.findViewById(R.id.LineStyleButton);
1264- lineStyleObj.setImageResource(buttonId);
1265- //Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::finishSelectLineShape() buttonId:" + buttonId);
1266- }
1267-
1268- /**
1269- *
1270- *
1271- */
1272- public void cancelSelectLineShape()
1273- {
1274-
1275- }
12761308 }
--- a/app/src/main/java/jp/sourceforge/gokigen/memoma/dialogs/FileSelectionDialog.java
+++ b/app/src/main/java/jp/sourceforge/gokigen/memoma/dialogs/FileSelectionDialog.java
@@ -9,7 +9,7 @@ import android.view.View;
99 import android.widget.AdapterView;
1010 import android.widget.ListView;
1111
12-import jp.sourceforge.gokigen.memoma.fileio.ExternalStorageFileUtility;
12+import jp.sourceforge.gokigen.memoma.io.ExternalStorageFileUtility;
1313 import jp.sourceforge.gokigen.memoma.holders.MeMoMaDataFileHolder;
1414 import jp.sourceforge.gokigen.memoma.R;
1515
--- a/app/src/main/java/jp/sourceforge/gokigen/memoma/GokigenSurfaceView.java
+++ b/app/src/main/java/jp/sourceforge/gokigen/memoma/drawers/GokigenSurfaceView.java
@@ -1,4 +1,4 @@
1-package jp.sourceforge.gokigen.memoma;
1+package jp.sourceforge.gokigen.memoma.drawers;
22
33 import android.content.Context;
44 import android.graphics.Canvas;
@@ -8,6 +8,7 @@ import android.view.MotionEvent;
88 import android.view.SurfaceHolder;
99 import android.view.SurfaceView;
1010
11+import jp.sourceforge.gokigen.memoma.Main;
1112 import jp.sourceforge.gokigen.memoma.drawers.ICanvasDrawer;
1213
1314 /**
--- a/app/src/main/java/jp/sourceforge/gokigen/memoma/drawers/MeMoMaCanvasDrawer.java
+++ b/app/src/main/java/jp/sourceforge/gokigen/memoma/drawers/MeMoMaCanvasDrawer.java
@@ -19,9 +19,10 @@ import android.view.ScaleGestureDetector;
1919 import android.widget.SeekBar;
2020 import android.widget.TextView;
2121
22-import jp.sourceforge.gokigen.memoma.GokigenSurfaceView;
22+import jp.sourceforge.gokigen.memoma.holders.ObjectConnector;
23+import jp.sourceforge.gokigen.memoma.holders.PositionObject;
2324 import jp.sourceforge.gokigen.memoma.operations.IObjectSelectionReceiver;
24-import jp.sourceforge.gokigen.memoma.fileio.ImageLoader;
25+import jp.sourceforge.gokigen.memoma.io.ImageLoader;
2526 import jp.sourceforge.gokigen.memoma.Main;
2627 import jp.sourceforge.gokigen.memoma.R;
2728 import jp.sourceforge.gokigen.memoma.holders.LineStyleHolder;
@@ -43,7 +44,7 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes
4344 public static final int BACKGROUND_COLOR_DEFAULT = 0xff004000;
4445 private int backgroundColor = BACKGROUND_COLOR_DEFAULT;
4546
46- private MeMoMaObjectHolder.PositionObject selectedPosition = null;
47+ private PositionObject selectedPosition = null;
4748 private float tempPosX = Float.MIN_VALUE;
4849 private float tempPosY = Float.MIN_VALUE;
4950 private float downPosX = Float.MIN_VALUE;
@@ -52,7 +53,7 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes
5253 // 以下の値は、MeMoMaListenerで初期値を設定する
5354 private int objectStyle = MeMoMaObjectHolder.DRAWSTYLE_RECTANGLE;
5455
55- private LineStyleHolder lineStyleHolder = null;
56+ private LineStyleHolder lineStyleHolder;
5657
5758 private float drawScale = 1.0f; // 表示の倍率
5859 private float drawTransX = 0.0f; // 並行移動距離 (X)
@@ -70,14 +71,14 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes
7071 private String backgroundBitmapUri = null;
7172 private Bitmap backgroundBitmap = null;
7273
73- private MeMoMaObjectHolder objectHolder = null;
74- private MeMoMaConnectLineHolder lineHolder = null;
75- private IObjectSelectionReceiver selectionReceiver = null;
74+ private MeMoMaObjectHolder objectHolder;
75+ private MeMoMaConnectLineHolder lineHolder;
76+ private IObjectSelectionReceiver selectionReceiver;
7677
77- private GestureDetector gestureDetector = null;
78- private ScaleGestureDetector scaleGestureDetector = null;
78+ private GestureDetector gestureDetector;
79+ private ScaleGestureDetector scaleGestureDetector;
7980
80- private Activity parent = null;
81+ private Activity parent;
8182
8283 /**
8384 * コンストラクタ
@@ -103,7 +104,7 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes
103104 * オブジェクトの形状を変更する
104105 * (ここで指定された形状のチェックを行っておく。)
105106 *
106- * @param style
107+ *
107108 */
108109 public void setObjectStyle(int style)
109110 {
@@ -173,7 +174,7 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes
173174 /**
174175 * 背景画像を設定する
175176 *
176- * @param uri
177+ *
177178 */
178179 public void setBackgroundUri(String uri)
179180 {
@@ -183,7 +184,7 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes
183184 /**
184185 * 背景色を(文字列で)設定する
185186 *
186- * @param colorString
187+ *
187188 */
188189 public void setBackgroundColor(String colorString)
189190 {
@@ -264,8 +265,8 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes
264265 // オブジェクトをすべて表示
265266 drawObjects(canvas, 0.0f, 0.0f);
266267
267- /** 移動中かどうかのチェックを行う。 **/
268- if (isFlicking(canvas) == true)
268+ // 移動中かどうかのチェックを行う。
269+ if (isFlicking(canvas))
269270 {
270271 // 移動中の場合、フリック時の軌跡と現在位置を表示する
271272 drawTrackAndPositions(canvas);
@@ -325,7 +326,7 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes
325326 /**
326327 * オブジェクト間の接続線を表示する
327328 *
328- * @param canvas
329+ *
329330 */
330331 private void drawConnectionLines(Canvas canvas, float offsetX, float offsetY)
331332 {
@@ -345,8 +346,8 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes
345346 while (keys.hasMoreElements())
346347 {
347348 Integer key = keys.nextElement();
348- MeMoMaConnectLineHolder.ObjectConnector line = lineHolder.getLine(key);
349- if (line.key > 0)
349+ ObjectConnector line = lineHolder.getLine(key);
350+ if (line.getKey() > 0)
350351 {
351352 // 実際にラインを引く
352353 drawLine(canvas, paint, dashLinePaint, line, offsetX, offsetY);
@@ -362,11 +363,8 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes
362363 /**
363364 * 接続する線を引く
364365 *
365- * @param canvas
366- * @param paint
367- * @param line
368366 */
369- public void drawLine(Canvas canvas, Paint paint, Paint dashPaint, MeMoMaConnectLineHolder.ObjectConnector line, float offsetX, float offsetY)
367+ private void drawLine(Canvas canvas, Paint paint, Paint dashPaint, ObjectConnector line, float offsetX, float offsetY)
370368 {
371369 try
372370 {
@@ -376,8 +374,8 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes
376374 return;
377375 }
378376
379- MeMoMaObjectHolder.PositionObject from = objectHolder.getPosition(line.fromObjectKey);
380- MeMoMaObjectHolder.PositionObject to = objectHolder.getPosition(line.toObjectKey);
377+ PositionObject from = objectHolder.getPosition(line.getFromObjectKey());
378+ PositionObject to = objectHolder.getPosition(line.getToObjectKey());
381379 if ((from == null)||(to == null))
382380 {
383381 // なにもしない
@@ -385,66 +383,69 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes
385383 }
386384
387385 // ラインの太さを設定する。
388- paint.setStrokeWidth((float) line.lineThickness);
386+ paint.setStrokeWidth((float) line.getLineThickness());
389387
390388 // ラインの太さを設定する。
391- dashPaint.setStrokeWidth((float) line.lineThickness);
389+ dashPaint.setStrokeWidth((float) line.getLineThickness());
392390
393391 // ラインのスタイル(連続線 or 点線)を設定する
394- Paint linePaint = (line.lineShape == LineStyleHolder.LINESHAPE_DASH) ? dashPaint : paint;
392+ Paint linePaint = (line.getLineShape() == LineStyleHolder.LINESHAPE_DASH) ? dashPaint : paint;
395393
396394 // 初期値として、各オブジェクトの中心座標を設定する
397- float startX = from.rect.centerX() + offsetX;
398- float endX = to.rect.centerX() + offsetX;
399- float startY = from.rect.centerY() + offsetY;
400- float endY = to.rect.centerY() + offsetY;
395+ RectF fromRect = from.getRect();
396+ RectF toRect = to.getRect();
397+ float startX = fromRect.centerX() + offsetX;
398+ float endX = toRect.centerX() + offsetX;
399+ float startY = fromRect.centerY() + offsetY;
400+ float endY = toRect.centerY() + offsetY;
401401
402402 // Y座標の線の位置を補正する
403- if (from.rect.bottom < to.rect.top)
403+ if (fromRect.bottom < toRect.top)
404404 {
405- startY = from.rect.bottom + offsetY;
406- endY = to.rect.top + offsetY;
405+ startY = fromRect.bottom + offsetY;
406+ endY = toRect.top + offsetY;
407407 }
408- else if (from.rect.top > to.rect.bottom)
408+ else if (fromRect.top > toRect.bottom)
409409 {
410- startY = from.rect.top + offsetY;
411- endY = to.rect.bottom + offsetY;
410+ startY = fromRect.top + offsetY;
411+ endY = toRect.bottom + offsetY;
412412 }
413413
414414 // X座標の線の位置を補正する (Y座標が補正されていないとき)
415- if ((startY != (from.rect.top + offsetY))&&(startY != (from.rect.bottom + offsetY)))
415+ if ((startY != (fromRect.top + offsetY))&&(startY != (fromRect.bottom + offsetY)))
416416 {
417- if (from.rect.right < to.rect.left)
417+ if (fromRect.right < toRect.left)
418418 {
419- startX = from.rect.right + offsetX;
420- endX = to.rect.left + offsetX;
419+ startX = fromRect.right + offsetX;
420+ endX = toRect.left + offsetX;
421421 }
422- else if (from.rect.left > to.rect.right)
422+ else if (fromRect.left > toRect.right)
423423 {
424- startX = from.rect.left + offsetX;
425- endX = to.rect.right + offsetX;
424+ startX = fromRect.left + offsetX;
425+ endX = toRect.right + offsetX;
426426 }
427427 }
428428
429- if ((line.lineStyle == LineStyleHolder.LINESTYLE_TREESTYLE_NO_ARROW)||
430- (line.lineStyle == LineStyleHolder.LINESTYLE_TREESTYLE_L_ARROW)||
431- (line.lineStyle == LineStyleHolder.LINESTYLE_TREESTYLE_R_ARROW))
429+ int lineStyle = line.getLineStyle();
430+ if ((lineStyle == LineStyleHolder.LINESTYLE_TREESTYLE_NO_ARROW)||
431+ (lineStyle == LineStyleHolder.LINESTYLE_TREESTYLE_L_ARROW)||
432+ (lineStyle == LineStyleHolder.LINESTYLE_TREESTYLE_R_ARROW))
432433 {
433434 // ツリー形式のように接続する ...
434- if (startX == (from.rect.centerX() + offsetX))
435+ if (startX == (fromRect.centerX() + offsetX))
435436 {
436437 float middleY = (startY + endY) / 2;
437438 canvas.drawLine(startX, startY, startX, middleY, linePaint);
438439 canvas.drawLine(startX, middleY, endX, middleY, linePaint);
439440 canvas.drawLine(endX, middleY, endX, endY, linePaint);
440441
441- /** やじるしをつける処理 **/
442- if (line.lineStyle == LineStyleHolder.LINESTYLE_TREESTYLE_L_ARROW)
442+ // やじるしをつける処理
443+ if (lineStyle == LineStyleHolder.LINESTYLE_TREESTYLE_L_ARROW)
443444 {
444445 // 始点に矢印をつける
445446 ObjectShapeDrawer.drawArrowTree(canvas, paint, startX,startY, middleY, false);
446447 }
447- else if (line.lineStyle == LineStyleHolder.LINESTYLE_TREESTYLE_R_ARROW)
448+ else if (lineStyle == LineStyleHolder.LINESTYLE_TREESTYLE_R_ARROW)
448449 {
449450 // 終点に矢印をつける
450451 ObjectShapeDrawer.drawArrowTree(canvas, paint, endX, endY, middleY, false);
@@ -457,43 +458,41 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes
457458 canvas.drawLine(middleX, startY, middleX, endY, linePaint);
458459 canvas.drawLine(middleX, endY, endX, endY, linePaint);
459460
460- /** やじるし(三角形)をつける処理 **/
461- if (line.lineStyle == LineStyleHolder.LINESTYLE_TREESTYLE_L_ARROW)
461+ // やじるし(三角形)をつける処理
462+ if (lineStyle == LineStyleHolder.LINESTYLE_TREESTYLE_L_ARROW)
462463 {
463464 // 始点に矢印をつける
464465 ObjectShapeDrawer.drawArrowTree(canvas, paint, startX, startY, middleX, true);
465466 }
466- else if (line.lineStyle == LineStyleHolder.LINESTYLE_TREESTYLE_R_ARROW)
467+ else if (lineStyle == LineStyleHolder.LINESTYLE_TREESTYLE_R_ARROW)
467468 {
468469 // 終点に矢印をつける
469470 ObjectShapeDrawer.drawArrowTree(canvas, paint, endX,endY, middleX, true);
470471 }
471472 }
472473 }
473- else if ((line.lineStyle == LineStyleHolder.LINESTYLE_CURVESTYLE_NO_ARROW)||
474- (line.lineStyle == LineStyleHolder.LINESTYLE_CURVESTYLE_L_ARROW)||
475- (line.lineStyle == LineStyleHolder.LINESTYLE_CURVESTYLE_R_ARROW))
474+ else if ((lineStyle == LineStyleHolder.LINESTYLE_CURVESTYLE_NO_ARROW)||
475+ (lineStyle == LineStyleHolder.LINESTYLE_CURVESTYLE_L_ARROW)||
476+ (lineStyle == LineStyleHolder.LINESTYLE_CURVESTYLE_R_ARROW))
476477 {
477478 // 曲線で接続する
478479 float middleX = (startX + endX) / 2;
479480 float middleY = (startY + endY) / 2;
480481 float x1 = (startX + middleX) / 2;
481- float y1 = middleY;
482482 float x2 = (middleX + endX) / 2;
483- float y2 = middleY;
484483
485484 Path pathLine = new Path();
486485 pathLine.moveTo(startX, startY);
487- pathLine.cubicTo(x1, y1, x2, y2, endX, endY);
486+ pathLine.cubicTo(x1, middleY, x2, middleY, endX, endY);
488487 canvas.drawPath(pathLine, linePaint);
489488
490- /** やじるしをつける処理 **/
491- if (line.lineStyle == LineStyleHolder.LINESTYLE_CURVESTYLE_L_ARROW)
489+ // やじるしをつける処理
490+ if (lineStyle == LineStyleHolder.LINESTYLE_CURVESTYLE_L_ARROW)
492491 {
493492 // 始点に矢印をつける
494493 ObjectShapeDrawer.drawArrow(canvas, paint, startX, startY, endX, endY);
495494 }
496- else if (line.lineStyle == LineStyleHolder.LINESTYLE_CURVESTYLE_R_ARROW)
495+ else if (lineStyle == LineStyleHolder.LINESTYLE_CURVESTYLE_R_ARROW)
497496 {
498497 // 終点に矢印をつける
499498 ObjectShapeDrawer.drawArrow(canvas, paint, endX, endY, startX, startY);
@@ -504,13 +503,13 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes
504503 // 直線で接続する
505504 canvas.drawLine(startX, startY, endX, endY, linePaint);
506505
507- /** やじるしをつける処理 **/
508- if (line.lineStyle == LineStyleHolder.LINESTYLE_STRAIGHT_L_ARROW)
506+ // やじるしをつける処理
507+ if (lineStyle == LineStyleHolder.LINESTYLE_STRAIGHT_L_ARROW)
509508 {
510509 // 始点に矢印をつける
511510 ObjectShapeDrawer.drawArrow(canvas, paint, startX, startY, endX, endY);
512511 }
513- else if (line.lineStyle == LineStyleHolder.LINESTYLE_STRAIGHT_R_ARROW)
512+ else if (lineStyle == LineStyleHolder.LINESTYLE_STRAIGHT_R_ARROW)
514513 {
515514 // 終点に矢印をつける
516515 ObjectShapeDrawer.drawArrow(canvas, paint, endX, endY, startX, startY);
@@ -527,24 +526,18 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes
527526 /**
528527 * オブジェクトを動かしている最中かどうかの判定を行う。
529528 *
530- * @param canvas
529+ *
531530 * @return trueなら、動かしている最中
532531 */
533532 private boolean isFlicking(Canvas canvas)
534533 {
535- //int width = canvas.getWidth();
536- //int height = canvas.getHeight();
537- if ((tempPosX == Float.MIN_VALUE)||(tempPosY == Float.MIN_VALUE))
538- {
539- return (false);
540- }
541- return (true);
534+ return (!((tempPosX == Float.MIN_VALUE)||(tempPosY == Float.MIN_VALUE)));
542535 }
543536
544537 /**
545538 * フリック時の軌跡と現在地点を表示する
546539 *
547- * @param canvas
540+ *
548541 */
549542 private void drawTrackAndPositions(Canvas canvas)
550543 {
@@ -557,9 +550,10 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes
557550 paint.setColor(Color.GRAY);
558551 if (selectedPosition != null)
559552 {
560- float objX = (selectedPosition.rect.right - selectedPosition.rect.left) / 2;
561- float objY = (selectedPosition.rect.bottom - selectedPosition.rect.top) / 2;
562- canvas.drawLine(selectedPosition.rect.centerX(), selectedPosition.rect.centerY(), x, y, paint);
553+ RectF objRect = selectedPosition.getRect();
554+ float objX = (objRect.right - objRect.left) / 2;
555+ float objY = (objRect.bottom - objRect.top) / 2;
556+ canvas.drawLine(objRect.centerX(), objRect.centerY(), x, y, paint);
563557 canvas.drawRect((x - objX), (y - objY), (x + objX), (y + objY), paint);
564558
565559 // 現在地点の表示
@@ -579,7 +573,7 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes
579573 SharedPreferences.Editor editor = preferences.edit();
580574 editor.putFloat("drawTransX", drawTransX);
581575 editor.putFloat("drawTransY", drawTransY);
582- editor.commit();
576+ editor.apply();
583577 }
584578 else
585579 {
@@ -594,114 +588,115 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes
594588 * オブジェクト(1個)を表示する
595589 *
596590 */
597- private void drawObject(Canvas canvas, MeMoMaObjectHolder.PositionObject object, boolean isMoving, float offsetX, float offsetY)
591+ private void drawObject(Canvas canvas, PositionObject object, boolean isMoving, float offsetX, float offsetY)
598592 {
599593 float label_offsetX = OBJECTLABEL_MARGIN;
600594 float label_offsetY = 0.0f;
601595
602596 // オブジェクトの色と枠線を設定する
603597 Paint paint = new Paint();
604- if (isMoving == true)
598+ if (isMoving)
605599 {
606600 paint.setColor(Color.YELLOW);
607601 paint.setStyle(Paint.Style.STROKE);
608- paint.setStrokeWidth(object.strokeWidth);
602+ paint.setStrokeWidth(object.getstrokeWidth());
609603 }
610604 else
611605 {
612- paint.setColor(object.objectColor);
613- paint.setStyle(Paint.Style.valueOf(object.paintStyle));
614- paint.setStrokeWidth(object.strokeWidth);
606+ paint.setColor(object.getObjectColor());
607+ paint.setStyle(Paint.Style.valueOf(object.getPaintStyle()));
608+ paint.setStrokeWidth(object.getstrokeWidth());
615609 }
616610
617611 // 図形の形状に合わせて描画する
618- RectF objectShape = new RectF(object.rect);
612+ RectF objectShape = new RectF(object.getRect());
619613 objectShape.left = objectShape.left + offsetX;
620614 objectShape.right = objectShape.right + offsetX;
621615 objectShape.top = objectShape.top + offsetY;
622616 objectShape.bottom = objectShape.bottom + offsetY;
623-
624- if (object.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_OVAL)
617+
618+ int drawStyle = object.getDrawStyle();
619+ if (drawStyle == MeMoMaObjectHolder.DRAWSTYLE_OVAL)
625620 {
626621 // 楕円形の描画
627622 label_offsetY = ObjectShapeDrawer.drawObjectOval(canvas, objectShape, paint);
628623 }
629- else if (object.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_ROUNDRECT)
624+ else if (drawStyle == MeMoMaObjectHolder.DRAWSTYLE_ROUNDRECT)
630625 {
631626 // 丸角四角形の描画
632627 label_offsetY = ObjectShapeDrawer.drawObjectRoundRect(canvas, objectShape, paint);
633628 }
634- else if (object.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_DIAMOND)
629+ else if (drawStyle == MeMoMaObjectHolder.DRAWSTYLE_DIAMOND)
635630 {
636631 // 菱形の描画
637632 label_offsetY = ObjectShapeDrawer.drawObjectDiamond(canvas, objectShape, paint);
638633 label_offsetX = OBJECTLABEL_MARGIN;
639634 }
640- else if (object.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_KEYBOARD)
635+ else if (drawStyle == MeMoMaObjectHolder.DRAWSTYLE_KEYBOARD)
641636 {
642637 // 台形(キーボード型)の描画
643638 label_offsetY = ObjectShapeDrawer.drawObjectKeyboard(canvas, objectShape, paint);
644639 }
645- else if (object.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_PARALLELOGRAM)
640+ else if (drawStyle == MeMoMaObjectHolder.DRAWSTYLE_PARALLELOGRAM)
646641 {
647642 // 平行四辺形の描画
648643 label_offsetY = ObjectShapeDrawer.drawObjectParallelogram(canvas, objectShape, paint);
649644 }
650- else if (object.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_HEXAGONAL)
645+ else if (drawStyle == MeMoMaObjectHolder.DRAWSTYLE_HEXAGONAL)
651646 {
652647 // 六角形の描画
653648 label_offsetY = ObjectShapeDrawer.drawObjectHexagonal(canvas, objectShape, paint);
654649 }
655- else if (object.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_PAPER)
650+ else if (drawStyle == MeMoMaObjectHolder.DRAWSTYLE_PAPER)
656651 {
657652 // 書類の形の描画
658653 label_offsetY = ObjectShapeDrawer.drawObjectPaper(canvas, objectShape, paint);
659654 }
660- else if (object.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_DRUM)
655+ else if (drawStyle == MeMoMaObjectHolder.DRAWSTYLE_DRUM)
661656 {
662657 // 円柱の描画
663- label_offsetY = ObjectShapeDrawer.drawObjectDrum(canvas, objectShape, paint, Paint.Style.valueOf(object.paintStyle));
658+ label_offsetY = ObjectShapeDrawer.drawObjectDrum(canvas, objectShape, paint, Paint.Style.valueOf(object.getPaintStyle()));
664659 }
665- else if (object.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_CIRCLE)
660+ else if (drawStyle == MeMoMaObjectHolder.DRAWSTYLE_CIRCLE)
666661 {
667662 // 円を描画する
668663 label_offsetY = ObjectShapeDrawer.drawObjectCircle(canvas, objectShape, paint);
669664 }
670- else if (object.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_NO_REGION)
665+ else if (drawStyle == MeMoMaObjectHolder.DRAWSTYLE_NO_REGION)
671666 {
672667 // 枠なしを描画(?)する ... なにもしない
673- if (object.label.length() == 0)
668+ if (object.getLabel().length() == 0)
674669 {
675670 // 何も表示しないとわからないので、ラベルが無いときには枠を表示する
676671 ObjectShapeDrawer.drawObjectNoRegion(canvas, objectShape, paint);
677672 }
678673 }
679- else if (object.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_LOOP_START)
674+ else if (drawStyle == MeMoMaObjectHolder.DRAWSTYLE_LOOP_START)
680675 {
681676 // ループ開始図形の描画
682677 label_offsetY = ObjectShapeDrawer.drawObjectLoopStart(canvas, objectShape, paint);
683678 }
684- else if (object.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_LOOP_END)
679+ else if (drawStyle == MeMoMaObjectHolder.DRAWSTYLE_LOOP_END)
685680 {
686681 // ループ終了図形の描画
687682 label_offsetY = ObjectShapeDrawer.drawObjectLoopEnd(canvas, objectShape, paint);
688683 }
689- else if (object.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_LEFT_ARROW)
684+ else if (drawStyle == MeMoMaObjectHolder.DRAWSTYLE_LEFT_ARROW)
690685 {
691686 // 左側矢印図形の描画
692687 label_offsetY = ObjectShapeDrawer.drawObjectLeftArrow(canvas, objectShape, paint);
693688 }
694- else if (object.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_DOWN_ARROW)
689+ else if (drawStyle == MeMoMaObjectHolder.DRAWSTYLE_DOWN_ARROW)
695690 {
696691 // 下側矢印図形の描画
697692 label_offsetY = ObjectShapeDrawer.drawObjectDownArrow(canvas, objectShape, paint);
698693 }
699- else if (object.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_UP_ARROW)
694+ else if (drawStyle == MeMoMaObjectHolder.DRAWSTYLE_UP_ARROW)
700695 {
701696 // 上側矢印図形の描画
702697 label_offsetY = ObjectShapeDrawer.drawObjectUpArrow(canvas, objectShape, paint);
703698 }
704- else if (object.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_RIGHT_ARROW)
699+ else if (drawStyle == MeMoMaObjectHolder.DRAWSTYLE_RIGHT_ARROW)
705700 {
706701 // 右側矢印図形の描画
707702 label_offsetY = ObjectShapeDrawer.drawObjectRightArrow(canvas, objectShape, paint);
@@ -713,7 +708,7 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes
713708 }
714709
715710 // 文字サイズを設定する。
716- paint.setTextSize(object.fontSize);
711+ paint.setTextSize(object.getFontSize());
717712
718713 // 文字ラベルを表示する
719714 ObjectShapeDrawer.drawTextLabel(canvas, paint, object, objectShape, displayObjectInformation, label_offsetX, label_offsetY);
@@ -722,7 +717,7 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes
722717 /**
723718 * オブジェクトをすべて表示する
724719 *
725- * @param canvas
720+ *
726721 */
727722 private void drawObjects(Canvas canvas , float offsetX, float offsetY)
728723 {
@@ -731,15 +726,14 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes
731726 while (keys.hasMoreElements())
732727 {
733728 Integer key = keys.nextElement();
734- MeMoMaObjectHolder.PositionObject pos = objectHolder.getPosition(key);
729+ PositionObject pos = objectHolder.getPosition(key);
735730 drawObject(canvas, pos, false, offsetX, offsetY);
736731 }
737732 }
738733
739734 /**
740735 * タッチされたタイミングでの処理
741- * @param event
742- * @return
736+ *
743737 */
744738 private boolean onTouchDown(MotionEvent event)
745739 {
@@ -765,6 +759,7 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes
765759 // オブジェクトが生成されたことを通知する
766760 selectionReceiver.objectCreated();
767761 }
762+/*
768763 else if (data ==OperationModeHolder.OPERATIONMODE_MOVE)
769764 {
770765 // 移動モードのとき
@@ -773,19 +768,19 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes
773768 {
774769 // 削除モードのとき...何もしない
775770 }
771+*/
776772 }
777773 return (false);
778774 }
779775
780776 /**
781777 * タッチが離されたタイミングでの処理
782- * @param event
783- * @return
778+ *
784779 */
785780 private boolean onTouchUp(MotionEvent event)
786781 {
787782 boolean longPress = false;
788- if (onGestureProcessed == true)
783+ if (onGestureProcessed)
789784 {
790785 // ロングタッチ中だった場合...フラグを落とす
791786 onGestureProcessed = false;
@@ -827,24 +822,25 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes
827822 return (true);
828823 }
829824
830- if (selectedPosition.rect.contains(x, y) == true)
825+ RectF selectedRect = selectedPosition.getRect();
826+ if (selectedRect.contains(x, y))
831827 {
832828 // タッチが離された位置がタッチしたオブジェクトと同じ位置だった場合......
833829
834830 // タッチが離された位置を認識する
835831 float diffX = Math.abs(event.getX() - drawTransX - downPosX);
836- float diffY = Math.abs(event.getY() - drawTransY - downPosY);
832+ float diffY = Math.abs(event.getY() - drawTransY - downPosY);
837833
838834 // タッチが離された位置が動いていた場合、オブジェクト位置の微調整と判定する。
839- if (((diffX > 2.0f)||(diffY > 2.0f))||(longPress == true))
835+ if (((diffX > 2.0f)||(diffY > 2.0f))||(longPress))
840836 {
841837 // タッチが離された場所にはオブジェクトがなかった場合...オブジェクトをその位置に移動させる
842838 Log.v(Main.APP_IDENTIFIER, "MOVE OBJECT : (" + diffX + "," + diffY + ")");
843839 moveObjectPosition(x, y);
844840 return (true);
845841 }
846-
847- // タッチが押された位置と離された位置が同じ位置だった場合......アイテムが選択された、と認識する。
842+
843+ // タッチが押された位置と離された位置が同じ位置だった場合......アイテムが選択された、と認識する。
848844 Log.v(Main.APP_IDENTIFIER, " ITEM SELECTED :" + x + "," + y);
849845 if (selectionReceiver != null)
850846 {
@@ -859,8 +855,8 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes
859855 }
860856
861857 // タッチが離された位置にオブジェクトがいるかどうかのチェック
862- MeMoMaObjectHolder.PositionObject position = checkSelectedObject(x, y);
863- if ((position != null)&&(longPress == false))
858+ PositionObject position = checkSelectedObject(x, y);
859+ if ((position != null)&&(!longPress))
864860 {
865861 // 他のオブジェクトと重なるように操作した、この場合は、オブジェクト間を線をつなげる
866862 // (ただし、ボタンを長押ししていなかったとき。)
@@ -885,22 +881,19 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes
885881
886882 /**
887883 * オブジェクトの位置を移動させる
888- *
889- * @param x
890- * @param y
884+ *
891885 */
892886 private void moveObjectPosition(float x, float y)
893887 {
888+ RectF curRect = selectedPosition.getRect();
894889 tempPosX = Float.MIN_VALUE;
895890 tempPosY = Float.MIN_VALUE;
896- float sizeX = selectedPosition.rect.right - selectedPosition.rect.left;
897- float sizeY = selectedPosition.rect.bottom - selectedPosition.rect.top;
891+ float sizeX = curRect.right - curRect.left;
892+ float sizeY = curRect.bottom - curRect.top;
898893
899894 float positionX = alignPosition(x, (sizeX / 2) * (-1));
900895 float positionY = alignPosition(y, (sizeY / 2) * (-1));
901- selectedPosition.rect = new android.graphics.RectF(positionX, positionY, (positionX + sizeX), (positionY + sizeY));
902-
903- return;
896+ selectedPosition.setRect(new android.graphics.RectF(positionX, positionY, (positionX + sizeX), (positionY + sizeY)));
904897 }
905898
906899 /**
@@ -909,22 +902,22 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes
909902 */
910903 public boolean onTouchEvent(MotionEvent event)
911904 {
912- boolean isDraw = false;
905+ boolean isDraw;
913906
914- /** スケールジェスチャ(マルチタッチのジェスチャ)を拾う **/
915- isDraw = scaleGestureDetector.onTouchEvent(event);
916- if ((onScaling == true)||(scaleGestureDetector.isInProgress() == true))
907+ // スケールジェスチャ(マルチタッチのジェスチャ)を拾う
908+ // isDraw = scaleGestureDetector.onTouchEvent(event);
909+ if ((onScaling)||(scaleGestureDetector.isInProgress()))
917910 {
918911 // マルチタッチ操作中...
919912 return (true);
920913 }
921914
922- /** 先にジェスチャーを拾ってみよう... **/
915+ // 先にジェスチャーを拾ってみよう...
923916 isDraw = gestureDetector.onTouchEvent(event);
924- if (isDraw == true)
917+ if (isDraw)
925918 {
926919 Log.v(Main.APP_IDENTIFIER, "MeMoMaCanvasDrawer::onTouchEvent() : isDraw == true");
927- return (isDraw);
920+ return (true);
928921 }
929922
930923 int action = event.getAction();
@@ -953,8 +946,7 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes
953946
954947 /**
955948 * タテヨコ位置を合わせられるよう、調整する。
956- * @param pos
957- * @return
949+ *
958950 */
959951 private float alignPosition(float pos, float offset)
960952 {
@@ -965,21 +957,20 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes
965957 /**
966958 * 位置から判定し、選択したオブジェクトを応答する
967959 * (オブジェクトが選択されていない場合には、nullを応答する)
968- * @param x
969- * @param y
970- * @return
960+ *
971961 */
972- private MeMoMaObjectHolder.PositionObject checkSelectedObject(float x, float y)
962+ private PositionObject checkSelectedObject(float x, float y)
973963 {
974964 Enumeration<Integer> keys = objectHolder.getObjectKeys();
975965 //Log.v(Main.APP_IDENTIFIER, "CHECK POS " + x + "," + y);
976966 while (keys.hasMoreElements())
977967 {
978968 Integer key = keys.nextElement();
979- MeMoMaObjectHolder.PositionObject pos = objectHolder.getPosition(key);
980- if (pos.rect.contains(x, y) == true)
969+ PositionObject pos = objectHolder.getPosition(key);
970+ RectF posRect = pos.getRect();
971+ if (posRect.contains(x, y))
981972 {
982- Log.v(Main.APP_IDENTIFIER, "SELECTED :" + pos.rect.centerX() + "," + pos.rect.centerY() + " KEY :" + key);
973+ Log.v(Main.APP_IDENTIFIER, "SELECTED :" + posRect.centerX() + "," + posRect.centerY() + " KEY :" + key);
983974 return (pos);
984975 }
985976 //Log.v(Main.APP_IDENTIFIER, "NOT MATCH :" + pos.rect.centerX() + "," + pos.rect.centerY());
@@ -991,10 +982,6 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes
991982 /**
992983 * 線と交差するオブジェクト接続線をすべて削除する
993984 *
994- * @param startX
995- * @param startY
996- * @param endX
997- * @param endY
998985 */
999986 private void disconnectObjects(float startX, float startY, float endX, float endY)
1000987 {
@@ -1005,19 +992,19 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes
1005992 while (keys.hasMoreElements())
1006993 {
1007994 Integer key = keys.nextElement();
1008- MeMoMaConnectLineHolder.ObjectConnector line = lineHolder.getLine(key);
1009- if (line.key > 0)
995+ ObjectConnector line = lineHolder.getLine(key);
996+ if (line.getKey() > 0)
1010997 {
1011998 // 線の始点と終点を取り出す
1012- MeMoMaObjectHolder.PositionObject from = objectHolder.getPosition(line.fromObjectKey);
1013- MeMoMaObjectHolder.PositionObject to = objectHolder.getPosition(line.toObjectKey);
999+ RectF fromRect = objectHolder.getPosition(line.getFromObjectKey()).getRect();
1000+ RectF toRect = objectHolder.getPosition(line.getToObjectKey()).getRect();
10141001
10151002 // 線が交差しているかチェックする
1016- if (checkIntersection(startX, startY, endX, endY, from.rect.centerX(), from.rect.centerY(), to.rect.centerX(), to.rect.centerY()) == true)
1003+ if (checkIntersection(startX, startY, endX, endY, fromRect.centerX(), fromRect.centerY(), toRect.centerX(), toRect.centerY()))
10171004 {
10181005 // 線が交差していた! 線を切る!
10191006 //Log.v(Main.APP_IDENTIFIER, "CUT LINE [" + from.rect.centerX() + "," + from.rect.centerY() +"]-[" + to.rect.centerX() + "," + to.rect.centerY() + "]");
1020- lineHolder.disconnectLines(line.key);
1007+ lineHolder.disconnectLines(line.getKey());
10211008 }
10221009 }
10231010 }
@@ -1062,11 +1049,7 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes
10621049 //crossY = y1 + dR * (y2 - y1);
10631050
10641051 // 交点が線分内にあるかどうかをチェックする
1065- if ((dR >= 0)&&(dR <= 1)&&(dS >= 0)&&(dS <= 1))
1066- {
1067- return (true);
1068- }
1069- return (false);
1052+ return ((dR >= 0)&&(dR <= 1)&&(dS >= 0)&&(dS <= 1));
10701053 }
10711054
10721055 /**
@@ -1090,7 +1073,7 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes
10901073 /**
10911074 * スライドバーを変更された時の処理
10921075 */
1093- public void zoomScaleChanged(int progress)
1076+ private void zoomScaleChanged(int progress)
10941077 {
10951078 float val = ((float) progress - 50.0f) / 50.0f;
10961079
@@ -1100,8 +1083,9 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes
11001083
11011084 // 表示倍率を変更し、倍率を画面に表示する
11021085 drawScale = (float) Math.round(Math.pow(10.0, val) * 10.0) / 10.0f;
1103- TextView textview = (TextView) parent.findViewById(R.id.ZoomRate);
1104- textview.setText("x" + drawScale);
1086+ TextView textview = parent.findViewById(R.id.ZoomRate);
1087+ String showText = "x" + drawScale;
1088+ textview.setText(showText);
11051089
11061090 // 現在の表示領域サイズを取得
11071091 float showSizeWidth = screenWidth * drawScale;
@@ -1128,7 +1112,7 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes
11281112 editor.putFloat("drawTransX", drawTransX);
11291113 editor.putFloat("drawTransY", drawTransY);
11301114 editor.putInt("zoomProgress", progress);
1131- editor.commit();
1115+ editor.apply();
11321116 }
11331117
11341118 /**
@@ -1174,7 +1158,7 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes
11741158 float y = (event.getY() - drawTransY) / drawScale;
11751159
11761160 // タッチ位置にオブジェクトが存在するか確認する
1177- MeMoMaObjectHolder.PositionObject position = checkSelectedObject(x, y);
1161+ PositionObject position = checkSelectedObject(x, y);
11781162 if (position != null)
11791163 {
11801164 // 長押し処理を実施していることを記憶する
@@ -1221,7 +1205,7 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes
12211205 zoomScaleChanged(progress);
12221206
12231207 // 画面描画クラスに再描画を指示する
1224- final GokigenSurfaceView surfaceView = (GokigenSurfaceView) parent.findViewById(R.id.GraphicView);
1208+ final GokigenSurfaceView surfaceView = parent.findViewById(R.id.GraphicView);
12251209 surfaceView.doDraw();
12261210 }
12271211
@@ -1244,15 +1228,14 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes
12441228 /**
12451229 * (ScaleGestureDetector.OnScaleGestureListener の実装)
12461230 *
1247- * @param detector
1248- * @return
1231+ *
12491232 */
12501233 public boolean onScale(ScaleGestureDetector detector)
12511234 {
12521235 float scaleFactor = detector.getScaleFactor();
12531236 //Log.v(Main.APP_IDENTIFIER, "MeMoMaCanvasDrawer::onScale() : " + scaleFactor + " (" + currentScaleBar + ")");
12541237
1255- /** 画面表示の倍率が変更された! x < 1 : 縮小、 1 < x : 拡大 **/
1238+ // 画面表示の倍率が変更された! x < 1 : 縮小、 1 < x : 拡大
12561239 if (scaleFactor < 1.0f)
12571240 {
12581241 currentScaleBar = (currentScaleBar == 0) ? 0 : currentScaleBar - 1;
@@ -1290,7 +1273,7 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes
12901273 onScaling = false;
12911274
12921275 // シークバーを設定し、値を記憶する
1293- final SeekBar seekbar = (SeekBar) parent.findViewById(R.id.ZoomInOut);
1276+ final SeekBar seekbar = parent.findViewById(R.id.ZoomInOut);
12941277 seekbar.setProgress(currentScaleBar);
12951278 zoomScaleChanged(currentScaleBar);
12961279 }
--- a/app/src/main/java/jp/sourceforge/gokigen/memoma/drawers/ObjectShapeDrawer.java
+++ b/app/src/main/java/jp/sourceforge/gokigen/memoma/drawers/ObjectShapeDrawer.java
@@ -7,6 +7,7 @@ import android.graphics.Paint;
77 import android.graphics.Path;
88 import android.graphics.RectF;
99 import jp.sourceforge.gokigen.memoma.holders.MeMoMaObjectHolder;
10+import jp.sourceforge.gokigen.memoma.holders.PositionObject;
1011
1112 /**
1213 * めもまのオブジェクト・ライン・ラベルを描画するメソッド群
@@ -304,26 +305,26 @@ public class ObjectShapeDrawer
304305 * オブジェクトのラベルを表示する
305306 *
306307 */
307- public static void drawTextLabel(Canvas canvas, Paint paint, MeMoMaObjectHolder.PositionObject pos, RectF region, int displayObjectInformation, float offsetX, float offsetY)
308+ public static void drawTextLabel(Canvas canvas, Paint paint, PositionObject pos, RectF region, int displayObjectInformation, float offsetX, float offsetY)
308309 {
309310 // タイトルの先頭部分を表示する場合...
310- String labelToShow = pos.label;
311+ String labelToShow = pos.getLabel();
311312 if (displayObjectInformation == 0)
312313 {
313314 float width = region.width() - MeMoMaCanvasDrawer.OBJECTLABEL_MARGIN_WIDTH;
314- int textLen = paint.breakText(pos.label, true, width, null); // 省略文字を追加するから、そのぶん減らす
315+ int textLen = paint.breakText(pos.getLabel(), true, width, null); // 省略文字を追加するから、そのぶん減らす
315316 labelToShow = labelToShow.substring(0, textLen);
316- if (!labelToShow.equals(pos.label))
317+ if (!labelToShow.equals(pos.getLabel()))
317318 {
318319 // truncate した場合には、省略文字を出す。
319320 labelToShow = labelToShow + "...";
320321 }
321322 }
322323
323- if (Paint.Style.valueOf(pos.paintStyle) != Paint.Style.STROKE)
324+ if (Paint.Style.valueOf(pos.getPaintStyle()) != Paint.Style.STROKE)
324325 {
325326 // オブジェクトを塗りつぶすのときは、文字の色を設定する
326- paint.setColor(pos.labelColor);
327+ paint.setColor(pos.getLabelColor());
327328 }
328329
329330 // 文字をちょっと影付きにする
@@ -331,13 +332,13 @@ public class ObjectShapeDrawer
331332 paint.setShadowLayer(0.7f, 0.7f, 0.7f, Color.DKGRAY);
332333
333334 // ユーザチェックの描画
334- if (pos.userChecked)
335+ if (pos.getUserChecked())
335336 {
336337 canvas.drawText("*", region.centerX(), region.top + (MeMoMaCanvasDrawer.OBJECTLABEL_MARGIN * 2.0f), paint);
337338 }
338339
339340 // 強調表示
340- if (pos.strokeWidth != 0.0f)
341+ if (pos.getstrokeWidth() != 0.0f)
341342 {
342343 // そのまま表示すると、読めないので、太さを調整し、アンダーラインを引くことにする
343344 paint.setStrokeWidth(0.0f);
@@ -358,10 +359,10 @@ public class ObjectShapeDrawer
358359 float width = region.right - region.left - 12.0f; // 幅
359360
360361 int startChar = 0;
361- int endChar = pos.label.length();
362+ int endChar = pos.getLabel().length();
362363 do
363364 {
364- int textLen = paint.breakText(pos.label, startChar, endChar, true, width, null);
365+ int textLen = paint.breakText(pos.getLabel(), startChar, endChar, true, width, null);
365366 canvas.drawText(labelToShow, startChar, (startChar +textLen), posX, posY, paint);
366367
367368 posY = posY - tall;
--- a/app/src/main/java/jp/sourceforge/gokigen/memoma/extension/ExtensionActivityListener.java
+++ b/app/src/main/java/jp/sourceforge/gokigen/memoma/extension/ExtensionActivityListener.java
@@ -25,16 +25,18 @@ import android.widget.ListAdapter;
2525 import android.widget.ListView;
2626 import android.widget.Toast;
2727
28-import jp.sourceforge.gokigen.memoma.fileio.ExternalStorageFileUtility;
28+import jp.sourceforge.gokigen.memoma.holders.OperationHistoryHolder;
29+import jp.sourceforge.gokigen.memoma.holders.PositionObject;
30+import jp.sourceforge.gokigen.memoma.io.ExternalStorageFileUtility;
2931 import jp.sourceforge.gokigen.memoma.dialogs.FileSelectionDialog;
3032 import jp.sourceforge.gokigen.memoma.Main;
3133 import jp.sourceforge.gokigen.memoma.holders.MeMoMaConnectLineHolder;
32-import jp.sourceforge.gokigen.memoma.fileio.MeMoMaFileExportCsvProcess;
33-import jp.sourceforge.gokigen.memoma.fileio.MeMoMaFileImportCsvProcess;
34-import jp.sourceforge.gokigen.memoma.fileio.MeMoMaFileLoadingProcess;
34+import jp.sourceforge.gokigen.memoma.io.MeMoMaFileExportCsvProcess;
35+import jp.sourceforge.gokigen.memoma.io.MeMoMaFileImportCsvProcess;
36+import jp.sourceforge.gokigen.memoma.io.MeMoMaFileLoadingProcess;
3537 import jp.sourceforge.gokigen.memoma.holders.MeMoMaObjectHolder;
3638 import jp.sourceforge.gokigen.memoma.R;
37-import jp.sourceforge.gokigen.memoma.SharedIntentInvoker;
39+import jp.sourceforge.gokigen.memoma.io.SharedIntentInvoker;
3840 import jp.sourceforge.gokigen.memoma.listitem.SymbolListArrayAdapter;
3941 import jp.sourceforge.gokigen.memoma.listitem.SymbolListArrayItem;
4042
@@ -68,9 +70,10 @@ public class ExtensionActivityListener implements OnClickListener, MeMoMaFileLo
6870 */
6971 ExtensionActivityListener(Activity argument)
7072 {
73+ OperationHistoryHolder historyHolder = new OperationHistoryHolder();
7174 parent = argument;
7275 fileUtility = new ExternalStorageFileUtility(Main.APP_BASEDIR);
73- objectHolder = new MeMoMaObjectHolder(parent, new MeMoMaConnectLineHolder());
76+ objectHolder = new MeMoMaObjectHolder(parent, new MeMoMaConnectLineHolder(historyHolder), historyHolder);
7477 }
7578 /**
7679 * 起動時にデータを準備する
@@ -350,16 +353,16 @@ public class ExtensionActivityListener implements OnClickListener, MeMoMaFileLo
350353 while (keys.hasMoreElements())
351354 {
352355 Integer key = keys.nextElement();
353- MeMoMaObjectHolder.PositionObject pos = objectHolder.getPosition(key);
356+ PositionObject pos = objectHolder.getPosition(key);
354357
355358 // アイコンの決定
356- int objectStyleIcon = MeMoMaObjectHolder .getObjectDrawStyleIcon(pos.drawStyle);
359+ int objectStyleIcon = MeMoMaObjectHolder .getObjectDrawStyleIcon(pos.getDrawStyle());
357360
358361 // ユーザチェックの有無表示
359- int userCheckedIcon = (pos.userChecked) ? R.drawable.btn_checked : R.drawable.btn_notchecked;
362+ int userCheckedIcon = (pos.getUserChecked()) ? R.drawable.btn_checked : R.drawable.btn_notchecked;
360363
361364 // TODO: アイテム選択時の情報エリアは(ArrayItem側には)用意しているが未使用。
362- SymbolListArrayItem listItem = new SymbolListArrayItem(userCheckedIcon, pos.label, pos.detail, "", objectStyleIcon);
365+ SymbolListArrayItem listItem = new SymbolListArrayItem(userCheckedIcon, pos.getLabel(), pos.getDetail(), "", objectStyleIcon);
363366
364367 listItems.add(listItem);
365368 }
--- /dev/null
+++ b/app/src/main/java/jp/sourceforge/gokigen/memoma/holders/IOperationHistoryHolder.java
@@ -0,0 +1,31 @@
1+package jp.sourceforge.gokigen.memoma.holders;
2+
3+interface IOperationHistoryHolder
4+{
5+ enum ChangeKind
6+ {
7+ RECTANGLE,
8+ DRAW_STYLE,
9+ ICON,
10+ LABEL,
11+ DETAIL,
12+ USER_CHECKED,
13+ LABEL_COLOR,
14+ OBJECT_COLOR,
15+ PAINT_STYLE,
16+ STROKE_WIDTH,
17+ FONT_SIZE,
18+ NEW_OBJECT,
19+ NEW_CONNECT_LINE,
20+ CONNECT_LINE_FROM_KEY,
21+ CONNECT_LINE_TO_KEY,
22+ CONNECT_LINE_STYLE,
23+ CONNECT_LINE_SHAPE,
24+ CONNECT_LINE_THICKNESS,
25+ };
26+
27+
28+ void addHistory(int key, ChangeKind kind, Object object);
29+ void undo();
30+
31+}
--- a/app/src/main/java/jp/sourceforge/gokigen/memoma/holders/MeMoMaConnectLineHolder.java
+++ b/app/src/main/java/jp/sourceforge/gokigen/memoma/holders/MeMoMaConnectLineHolder.java
@@ -5,7 +5,6 @@ import java.util.Hashtable;
55 import android.util.Log;
66
77 import jp.sourceforge.gokigen.memoma.Main;
8-import jp.sourceforge.gokigen.memoma.holders.LineStyleHolder;
98
109
1110 /**
@@ -13,141 +12,96 @@ import jp.sourceforge.gokigen.memoma.holders.LineStyleHolder;
1312 *
1413 * @author MRSa
1514 *
16- */public class MeMoMaConnectLineHolder
15+ */
16+public class MeMoMaConnectLineHolder
1717 {
18- public static final int ID_NOTSPECIFY = -1;
19-
20- /**
21- * オブジェクト間を接続するクラス
22- *
23- * @author MRSa
24- *
25- */
26- public class ObjectConnector
27- {
28- public Integer key;
29- public Integer fromObjectKey;
30- public Integer toObjectKey;
31- public Integer lineStyle;
32- public Integer lineShape;
33- public Integer lineThickness;
34-/**
35- public int fromShape;
36- public int toShape;
37- public String fromString;
38- public String toString;
39-**/
40- };
41-
42- private Hashtable<Integer, ObjectConnector> connectLines = null;
43- private Integer serialNumber = 1;
44-
45- public MeMoMaConnectLineHolder()
46- {
47- connectLines = new Hashtable<Integer, ObjectConnector>();
48- connectLines.clear();
49- }
50-
51- public Enumeration<Integer> getLineKeys()
52- {
53- return (connectLines.keys());
54- }
55-
56- public ObjectConnector getLine(Integer key)
57- {
58- return (connectLines.get(key));
59- }
60-
61- public boolean disconnectLines(Integer key)
62- {
63- connectLines.remove(key);
64- Log.v(Main.APP_IDENTIFIER, "DISCONNECT LINES : " + key);
65- return (true);
66- }
67-
68- public void setSerialNumber(int id)
69- {
70- serialNumber = (id == ID_NOTSPECIFY) ? ++serialNumber : id;
71- }
72-
73- public int getSerialNumber()
74- {
75- return (serialNumber);
76- }
77-
78- public void removeAllLines()
79- {
80- connectLines.clear();
81- serialNumber = 1;
82- }
83-
84- public void dumpConnectLine(ObjectConnector conn)
85- {
86- if (conn == null)
87- {
88- return;
89- }
90- Log.v(Main.APP_IDENTIFIER, "LINE " + conn.key + " [" + conn.fromObjectKey + " -> " + conn.toObjectKey + "] ");
91- }
92-
93- /**
94- * keyToRemove で指定されたobjectの接続をすべて削除する
95- *
96- * @param keyToRemove
97- */
98- public void removeAllConnection(Integer keyToRemove)
99- {
100- Enumeration<Integer> keys = connectLines.keys();
101- while (keys.hasMoreElements())
102- {
103- Integer key = keys.nextElement();
104- ObjectConnector connector = connectLines.get(key);
105- if ((connector.fromObjectKey == keyToRemove)||(connector.toObjectKey == keyToRemove))
106- {
107- // 削除するキーが見つかった!
108- connector.key = -1; // 一応...大丈夫だとは思うけど
109- connectLines.remove(key);
110- }
111- }
112- }
113-
114- public ObjectConnector createLine(int id)
115- {
116- ObjectConnector connector = new ObjectConnector();
117- connector.key = id;
118- connector.fromObjectKey = 1;
119- connector.toObjectKey = 1;
120- connector.lineStyle = LineStyleHolder.LINESTYLE_STRAIGHT_NO_ARROW;
121- connector.lineShape = LineStyleHolder.LINESHAPE_NORMAL;
122- connector.lineThickness = LineStyleHolder.LINETHICKNESS_THIN;
123-
124-/**
125- connector.fromShape = 0;
126- connector.toShape = 0;
127- connector.fromString = "";
128- connector.toString = "";
129-**/
130- connectLines.put(id, connector);
131- return (connector);
132- }
133-
134- public ObjectConnector setLines(Integer fromKey, Integer toKey, LineStyleHolder lineHolder)
135- {
136- ObjectConnector connector = new ObjectConnector();
137- connector.key = serialNumber;
138- connector.fromObjectKey = fromKey;
139- connector.toObjectKey = toKey;
140- connector.lineStyle = lineHolder.getLineStyle();
141- connector.lineShape = lineHolder.getLineShape();
142- connector.lineThickness = lineHolder.getLineThickness();
143-/**
144- connector.fromShape = 0;
145- connector.toShape = 0;
146- connector.fromString = "";
147- connector.toString = "";
148-**/
149- connectLines.put(serialNumber, connector);
150- serialNumber++;
151- return (connector);
152- }
18+ private final IOperationHistoryHolder historyHolder;
19+ public static final int ID_NOTSPECIFY = -1;
20+ private Hashtable<Integer, ObjectConnector> connectLines;
21+ private Integer serialNumber = 1;
22+
23+ public MeMoMaConnectLineHolder(IOperationHistoryHolder historyHolder)
24+ {
25+ this.historyHolder = historyHolder;
26+ connectLines = new Hashtable<>();
27+ connectLines.clear();
28+ }
29+
30+ public Enumeration<Integer> getLineKeys()
31+ {
32+ return (connectLines.keys());
33+ }
34+
35+ public ObjectConnector getLine(Integer key)
36+ {
37+ return (connectLines.get(key));
38+ }
39+
40+ public boolean disconnectLines(Integer key)
41+ {
42+ connectLines.remove(key);
43+ Log.v(Main.APP_IDENTIFIER, "DISCONNECT LINES : " + key);
44+ return (true);
45+ }
46+
47+ public void setSerialNumber(int id)
48+ {
49+ serialNumber = (id == ID_NOTSPECIFY) ? ++serialNumber : id;
50+ }
51+
52+ public int getSerialNumber()
53+ {
54+ return (serialNumber);
55+ }
56+
57+ public void removeAllLines()
58+ {
59+ connectLines.clear();
60+ serialNumber = 1;
61+ }
62+
63+ public void dumpConnectLine(ObjectConnector conn)
64+ {
65+ if (conn == null)
66+ {
67+ return;
68+ }
69+ Log.v(Main.APP_IDENTIFIER, "LINE " + conn.getKey() + " [" + conn.getFromObjectKey() + " -> " + conn.getToObjectKey() + "] ");
70+ }
71+
72+ /**
73+ * keyToRemove で指定されたobjectの接続をすべて削除する
74+ *
75+ * @param keyToRemove\
76+ */
77+ public void removeAllConnection(Integer keyToRemove)
78+ {
79+ Enumeration<Integer> keys = connectLines.keys();
80+ while (keys.hasMoreElements())
81+ {
82+ Integer key = keys.nextElement();
83+ ObjectConnector connector = connectLines.get(key);
84+ if ((connector.getFromObjectKey() == keyToRemove)||(connector.getToObjectKey() == keyToRemove))
85+ {
86+ // 削除するキーが見つかった!
87+ connectLines.remove(key);
88+ }
89+ }
90+ }
91+
92+ public ObjectConnector createLine(int id)
93+ {
94+ ObjectConnector connector = new ObjectConnector(id, 1, 1, LineStyleHolder.LINESTYLE_STRAIGHT_NO_ARROW, LineStyleHolder.LINESHAPE_NORMAL, LineStyleHolder.LINETHICKNESS_THIN, historyHolder);
95+ connectLines.put(id, connector);
96+ return (connector);
97+ }
98+
99+ public ObjectConnector setLines(Integer fromKey, Integer toKey, LineStyleHolder lineHolder)
100+ {
101+ ObjectConnector connector = new ObjectConnector(serialNumber, fromKey, toKey, lineHolder.getLineStyle(), lineHolder.getLineShape(), lineHolder.getLineThickness(), historyHolder);
102+
103+ connectLines.put(serialNumber, connector);
104+ serialNumber++;
105+ return (connector);
106+ }
153107 }
--- a/app/src/main/java/jp/sourceforge/gokigen/memoma/holders/MeMoMaDataFileHolder.java
+++ b/app/src/main/java/jp/sourceforge/gokigen/memoma/holders/MeMoMaDataFileHolder.java
@@ -6,7 +6,7 @@ import java.io.FilenameFilter;
66 import android.content.Context;
77 import android.widget.ArrayAdapter;
88
9-import jp.sourceforge.gokigen.memoma.fileio.ExternalStorageFileUtility;
9+import jp.sourceforge.gokigen.memoma.io.ExternalStorageFileUtility;
1010
1111 /**
1212 * めもまのデータファイル名を保持するクラス (ArrayAdapterを拡張)
@@ -16,8 +16,8 @@ import jp.sourceforge.gokigen.memoma.fileio.ExternalStorageFileUtility;
1616 */
1717 public class MeMoMaDataFileHolder extends ArrayAdapter<String> implements FilenameFilter
1818 {
19- private ExternalStorageFileUtility fileUtility = null;
20- private String fileExtension = "";
19+ private ExternalStorageFileUtility fileUtility;
20+ private String fileExtension;
2121
2222 /**
2323 * コンストラクタ
@@ -49,7 +49,7 @@ public class MeMoMaDataFileHolder extends ArrayAdapter<String> implements Filena
4949 try {
5050 for (int index = 0; index < dirFileList.length; index++) {
5151 String fileName = dirFileList[index].substring(0, dirFileList[index].indexOf(fileExtension));
52- if (fileName.contentEquals(currentFileName) == true) // ファイル先頭にない場合は追加する。
52+ if (fileName.contentEquals(currentFileName)) // ファイル先頭にない場合は追加する。
5353 {
5454 // 選択したインデックスを設定する。
5555 outputIndex = index;
@@ -75,6 +75,6 @@ public class MeMoMaDataFileHolder extends ArrayAdapter<String> implements Filena
7575 */
7676 public boolean accept(File dir, String filename)
7777 {
78- return (filename.endsWith(fileExtension) ? true : false);
78+ return (filename.endsWith(fileExtension));
7979 }
8080 }
--- a/app/src/main/java/jp/sourceforge/gokigen/memoma/holders/MeMoMaObjectHolder.java
+++ b/app/src/main/java/jp/sourceforge/gokigen/memoma/holders/MeMoMaObjectHolder.java
@@ -65,76 +65,29 @@ public class MeMoMaObjectHolder
6565
6666 private MeMoMaConnectLineHolder connectLineHolder = null;
6767
68- /**
69- * オブジェクトの情報
70- *
71- * @author MRSa
72- *
73- */
74- public class PositionObject
75- {
76- private Integer key; // オブジェクト識別子 (変更不可)
77- public RectF rect; // オブジェクトの大きさ
78- public int drawStyle; // オブジェクトの形状
79-
80- public int icon; // オブジェクトのアイコン
81- public String label; // オブジェクトの表示ラベル
82- public String detail; // オブジェクトの説明
83- //public String backgroundUri; // オブジェクトの背景画像
84- //public String otherInfoUri; // 補足(写真とかへのURI)
85- //public String objectStatus; // オブジェクトの状態
86- public boolean userChecked; // ユーザチェックボックス
87-
88- public int labelColor; // オブジェクト内に表示する色
89- public int objectColor; // オブジェクトの色
90- public String paintStyle; // オブジェクトの表示方法 (枠線のみ、塗りつぶし、塗りつぶしと枠線)
91- public float strokeWidth; // 枠線の太さ
92- public float fontSize; // フォントサイズ
93-
94- /**
95- * コンストラクタ (キーを設定する)
96- * @param id
97- */
98- public PositionObject(int id)
99- {
100- key = id;
101- }
102-
103- /**
104- * オブジェクトのキーを取得する
105- * @return
106- */
107- public Integer getKey()
108- {
109- return (key);
110- }
111- };
112-
11368 private Hashtable<Integer, PositionObject> objectPoints = null;
11469 private Integer serialNumber = 1;
11570 private String dataTitle = "";
11671 private String background = "";
117- private Context parent = null;
72+ private Context parent;
73+ private final IOperationHistoryHolder historyHolder;
11874
119- public MeMoMaObjectHolder(Context context, MeMoMaConnectLineHolder lineHolder)
75+ public MeMoMaObjectHolder(Context context, MeMoMaConnectLineHolder lineHolder, IOperationHistoryHolder historyHolder)
12076 {
121- objectPoints = new Hashtable<Integer, PositionObject>();
77+ objectPoints = new Hashtable<>();
12278 connectLineHolder = lineHolder;
12379 parent = context;
80+ this.historyHolder = historyHolder;
12481 }
12582
12683 /**
12784 * データの有無を見る (true の場合、データはない。)
12885 *
129- * @return
86+ *
13087 */
13188 public boolean isEmpty()
132- {
133- if ((connectLineHolder == null)||(objectPoints == null))
134- {
135- return (true);
136- }
137- return (objectPoints.isEmpty());
89+ {
90+ return (((connectLineHolder == null)||(objectPoints == null))||(objectPoints.isEmpty()));
13891 }
13992
14093 public MeMoMaConnectLineHolder getConnectLineHolder()
@@ -206,15 +159,16 @@ public class MeMoMaObjectHolder
206159 {
207160 return;
208161 }
209- Log.v(Main.APP_IDENTIFIER, "[" + position.rect.left + "," + position.rect.top + "][" + position.rect.right + "," + position.rect.bottom + "] " + "label : " + position.label + " detail : " + position.detail);
162+ RectF posRect = position.getRect();
163+ Log.v(Main.APP_IDENTIFIER, "[" + posRect.left + "," + posRect.top + "][" + posRect.right + "," + posRect.bottom + "] " + "label : " + position.getLabel() + " detail : " + position.getDetail());
210164 }
211165
212166
213167 /**
214168 * オブジェクトを複製する。
215169 *
216- * @param key
217- * @return
170+ *
171+ *
218172 */
219173 public PositionObject duplicatePosition(int key)
220174 {
@@ -224,25 +178,20 @@ public class MeMoMaObjectHolder
224178 // 元のオブジェクトが見つからなかったので、何もせずに戻る
225179 return (null);
226180 }
227- PositionObject position = new PositionObject(serialNumber);
228- position.rect = new RectF();
229- position.rect.left = orgPosition.rect.left + DUPLICATEPOSITION_MARGIN;
230- position.rect.right = orgPosition.rect.right + DUPLICATEPOSITION_MARGIN;
231- position.rect.top = orgPosition.rect.top + DUPLICATEPOSITION_MARGIN;
232- position.rect.bottom = orgPosition.rect.bottom + DUPLICATEPOSITION_MARGIN;
233- position.drawStyle = orgPosition.drawStyle;
234- position.icon = orgPosition.icon;
235- position.label = orgPosition.label;
236- position.detail = orgPosition.detail;
237- //position.otherInfoUri = orgPosition.otherInfoUri;
238- //position.backgroundUri = orgPosition.backgroundUri;
239- //position.objectStatus = orgPosition.objectStatus;
240- position.userChecked = orgPosition.userChecked;
241- position.objectColor = orgPosition.objectColor;
242- position.labelColor = orgPosition.labelColor;
243- position.paintStyle = orgPosition.paintStyle;
244- position.strokeWidth = orgPosition.strokeWidth;
245- position.fontSize = orgPosition.fontSize;
181+ RectF orgRect = orgPosition.getRect();
182+ PositionObject position = new PositionObject(serialNumber,
183+ new RectF(orgRect.left + DUPLICATEPOSITION_MARGIN, orgRect.top + DUPLICATEPOSITION_MARGIN, orgRect.right + DUPLICATEPOSITION_MARGIN, orgRect.bottom + DUPLICATEPOSITION_MARGIN),
184+ orgPosition.getDrawStyle(),
185+ orgPosition.getIcon(),
186+ orgPosition.getLabel(),
187+ orgPosition.getDetail(),
188+ orgPosition.getUserChecked(),
189+ orgPosition.getLabelColor(),
190+ orgPosition.getObjectColor(),
191+ orgPosition.getPaintStyle(),
192+ orgPosition.getstrokeWidth(),
193+ orgPosition.getFontSize(),
194+ historyHolder);
246195 objectPoints.put(serialNumber, position);
247196 serialNumber++;
248197 return (position);
@@ -250,25 +199,19 @@ public class MeMoMaObjectHolder
250199
251200 public PositionObject createPosition(int id)
252201 {
253- PositionObject position = new PositionObject(id);
254- position.rect = new RectF();
255- position.rect.top = 0;
256- position.rect.bottom = OBJECTSIZE_DEFAULT_Y;
257- position.rect.left = 0;
258- position.rect.right = OBJECTSIZE_DEFAULT_X;
259- position.drawStyle = MeMoMaObjectHolder.DRAWSTYLE_RECTANGLE;
260- position.icon = 0;
261- position.label = "";
262- position.detail = "";
263- //position.otherInfoUri = "";
264- //position.backgroundUri = "";
265- //position.objectStatus = "";
266- position.userChecked = false;
267- position.objectColor = Color.WHITE;
268- position.labelColor = Color.WHITE;
269- position.paintStyle = Paint.Style.STROKE.toString();
270- position.strokeWidth = STOROKE_NORMAL_WIDTH;
271- position.fontSize = FONTSIZE_DEFAULT;
202+ PositionObject position = new PositionObject(id,
203+ new RectF(0, 0, OBJECTSIZE_DEFAULT_X, OBJECTSIZE_DEFAULT_Y),
204+ MeMoMaObjectHolder.DRAWSTYLE_RECTANGLE,
205+ 0,
206+ "",
207+ "",
208+ false,
209+ Color.WHITE,
210+ Color.WHITE,
211+ Paint.Style.STROKE.toString(),
212+ STOROKE_NORMAL_WIDTH,
213+ FONTSIZE_DEFAULT,
214+ historyHolder);
272215 objectPoints.put(id, position);
273216 return (position);
274217 }
@@ -276,11 +219,12 @@ public class MeMoMaObjectHolder
276219 public PositionObject createPosition(float x, float y, int drawStyle)
277220 {
278221 PositionObject position = createPosition(serialNumber);
279- position.rect.left = position.rect.left + x;
280- position.rect.right = position.rect.right + x;
281- position.rect.top = position.rect.top + y;
282- position.rect.bottom = position.rect.bottom + y;
283- position.drawStyle = drawStyle;
222+ RectF posRect = position.getRect();
223+ position.setRectLeft(posRect.left + x);
224+ position.setRectRight(posRect.right + x);
225+ position.setRectTop(posRect.top + y);
226+ position.setRectBottom(posRect.bottom + y);
227+ position.setDrawStyle(drawStyle);
284228 serialNumber++;
285229 return (position);
286230 }
@@ -297,8 +241,9 @@ public class MeMoMaObjectHolder
297241 // 元のオブジェクトが見つからなかったので、何もせずに戻る
298242 return;
299243 }
300- float width = position.rect.right - position.rect.left;
301- float height = position.rect.bottom - position.rect.top;
244+ RectF posRect = position.getRect();
245+ float width = posRect.right - posRect.left;
246+ float height = posRect.bottom - posRect.top;
302247 if (((width + (OBJECTSIZE_STEP_X * 2.0f)) > OBJECTSIZE_MAXIMUM_X)||((height + (OBJECTSIZE_STEP_Y * 2.0f)) > OBJECTSIZE_MAXIMUM_Y))
303248 {
304249 // 拡大リミットだった。。。拡大しない
@@ -306,16 +251,16 @@ public class MeMoMaObjectHolder
306251 Toast.makeText(parent, outputMessage, Toast.LENGTH_SHORT).show();
307252 return;
308253 }
309- position.rect.left = position.rect.left - OBJECTSIZE_STEP_X;
310- position.rect.right = position.rect.right + OBJECTSIZE_STEP_X;
311- position.rect.top = position.rect.top - OBJECTSIZE_STEP_Y;
312- position.rect.bottom = position.rect.bottom + OBJECTSIZE_STEP_Y;
254+ position.setRectLeft(posRect.left - OBJECTSIZE_STEP_X);
255+ position.setRectRight(posRect.right + OBJECTSIZE_STEP_X);
256+ position.setRectTop(posRect.top - OBJECTSIZE_STEP_Y);
257+ position.setRectBottom(posRect.bottom + OBJECTSIZE_STEP_Y);
313258 }
314259
315260 /**
316261 * オブジェクトのサイズを縮小する
317262 *
318- * @param key
263+ *
319264 */
320265 public void shrinkObjectSize(Integer key)
321266 {
@@ -325,8 +270,9 @@ public class MeMoMaObjectHolder
325270 // 元のオブジェクトが見つからなかったので、何もせずに戻る
326271 return;
327272 }
328- float width = position.rect.right - position.rect.left;
329- float height = position.rect.bottom - position.rect.top;
273+ RectF posRect = position.getRect();
274+ float width = posRect.right - posRect.left;
275+ float height = posRect.bottom - posRect.top;
330276 if (((width - (OBJECTSIZE_STEP_X * 2.0f)) < OBJECTSIZE_MINIMUM_X)||((height - (OBJECTSIZE_STEP_Y * 2.0f)) < OBJECTSIZE_MINIMUM_Y))
331277 {
332278 // 縮小リミットだった。。。縮小しない
@@ -334,10 +280,10 @@ public class MeMoMaObjectHolder
334280 Toast.makeText(parent, outputMessage, Toast.LENGTH_SHORT).show();
335281 return;
336282 }
337- position.rect.left = position.rect.left + OBJECTSIZE_STEP_X;
338- position.rect.right = position.rect.right - OBJECTSIZE_STEP_X;
339- position.rect.top = position.rect.top + OBJECTSIZE_STEP_Y;
340- position.rect.bottom = position.rect.bottom - OBJECTSIZE_STEP_Y;
283+ position.setRectLeft(posRect.left + OBJECTSIZE_STEP_X);
284+ position.setRectRight(posRect.right - OBJECTSIZE_STEP_X);
285+ position.setRectTop(posRect.top + OBJECTSIZE_STEP_Y);
286+ position.setRectBottom(posRect.bottom - OBJECTSIZE_STEP_Y);
341287 }
342288
343289 public MeMoMaConnectLineHolder getLineHolder()
@@ -418,5 +364,4 @@ public class MeMoMaObjectHolder
418364 }
419365 return (icon);
420366 }
421-
422367 }
--- /dev/null
+++ b/app/src/main/java/jp/sourceforge/gokigen/memoma/holders/ObjectConnector.java
@@ -0,0 +1,92 @@
1+package jp.sourceforge.gokigen.memoma.holders;
2+
3+import android.support.annotation.NonNull;
4+
5+/**
6+ * オブジェクト間を接続するクラス
7+ *
8+ * @author MRSa
9+ *
10+ */
11+public class ObjectConnector
12+{
13+ private final IOperationHistoryHolder historyHolder;
14+ private final Integer key;
15+ private Integer fromObjectKey;
16+ private Integer toObjectKey;
17+ private Integer lineStyle;
18+ private Integer lineShape;
19+ private Integer lineThickness;
20+
21+ ObjectConnector(int key, int fromObjectKey, int toObjectkey, int lineStyle, int lineShape, int lineThickness, @NonNull IOperationHistoryHolder historyHolder)
22+ {
23+ this.key = key;
24+ this.fromObjectKey = fromObjectKey;
25+ this.toObjectKey = toObjectkey;
26+ this.lineStyle = lineStyle;
27+ this.lineShape = lineShape;
28+ this.lineThickness = lineThickness;
29+ this.historyHolder = historyHolder;
30+ historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.NEW_CONNECT_LINE, this);
31+ }
32+
33+ public int getKey()
34+ {
35+ return (key);
36+ }
37+
38+ public int getFromObjectKey()
39+ {
40+ return (fromObjectKey);
41+ }
42+
43+ public int getToObjectKey()
44+ {
45+ return (toObjectKey);
46+ }
47+
48+ public int getLineStyle()
49+ {
50+ return (lineStyle);
51+ }
52+
53+ public int getLineShape()
54+ {
55+ return (lineShape);
56+ }
57+
58+ public int getLineThickness()
59+ {
60+ return (lineThickness);
61+ }
62+
63+ public void setFromObjectKey(int value)
64+ {
65+ historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.CONNECT_LINE_FROM_KEY, fromObjectKey);
66+ fromObjectKey = value;
67+ }
68+
69+ public void setToObjectKey(int value)
70+ {
71+ historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.CONNECT_LINE_TO_KEY, toObjectKey);
72+ toObjectKey = value;
73+ }
74+
75+ public void setLineStyle(int value)
76+ {
77+ historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.CONNECT_LINE_STYLE, lineStyle);
78+ lineStyle = value;
79+ }
80+
81+ public void setLineShape(int value)
82+ {
83+ historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.CONNECT_LINE_SHAPE, lineShape);
84+ lineShape = value;
85+ }
86+
87+ public void setLineThickness(int value)
88+ {
89+ historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.CONNECT_LINE_THICKNESS, lineThickness);
90+ lineThickness = value;
91+ }
92+}
--- /dev/null
+++ b/app/src/main/java/jp/sourceforge/gokigen/memoma/holders/OperationHistoryHolder.java
@@ -0,0 +1,25 @@
1+package jp.sourceforge.gokigen.memoma.holders;
2+
3+import android.content.Context;
4+import android.util.Log;
5+
6+public class OperationHistoryHolder implements IOperationHistoryHolder
7+{
8+ private final String TAG = toString();
9+
10+ public OperationHistoryHolder()
11+ {
12+
13+ }
14+
15+ public void addHistory(int key, ChangeKind kind, Object object)
16+ {
17+ Log.v(TAG, "addHistory() KEY : " + key + " KIND : " + kind.toString() + " OBJ : " + object.toString());
18+ }
19+
20+ public void undo()
21+ {
22+ Log.v(TAG, "undo() ");
23+
24+ }
25+}
--- /dev/null
+++ b/app/src/main/java/jp/sourceforge/gokigen/memoma/holders/PositionObject.java
@@ -0,0 +1,209 @@
1+package jp.sourceforge.gokigen.memoma.holders;
2+
3+import android.graphics.RectF;
4+import android.support.annotation.NonNull;
5+
6+public class PositionObject
7+{
8+ private final Integer key; // オブジェクト識別子 (変更不可)
9+ private final IOperationHistoryHolder historyHolder; // 履歴を保持するところ
10+
11+ private RectF rect; // オブジェクトの大きさ
12+ private int drawStyle; // オブジェクトの形状
13+
14+ private int icon; // オブジェクトのアイコン
15+ private String label; // オブジェクトの表示ラベル
16+ private String detail; // オブジェクトの説明
17+ //public String backgroundUri; // オブジェクトの背景画像
18+ //public String otherInfoUri; // 補足(写真とかへのURI)
19+ //public String objectStatus; // オブジェクトの状態
20+ private boolean userChecked; // ユーザチェックボックス
21+
22+ private int labelColor; // オブジェクト内に表示する色
23+ private int objectColor; // オブジェクトの色
24+ private String paintStyle; // オブジェクトの表示方法 (枠線のみ、塗りつぶし、塗りつぶしと枠線)
25+ private float strokeWidth; // 枠線の太さ
26+ private float fontSize; // フォントサイズ
27+
28+ /**
29+ * コンストラクタ (キーを設定する)
30+ *
31+ */
32+ public PositionObject(int id, RectF rect, int drawStyle, int icon, String label, String detail, boolean userChecked, int labelColor, int objectColor, String paintStyle, float strokeWidth, float fontSize, @NonNull IOperationHistoryHolder historyHolder)
33+ {
34+ key = id;
35+ this.rect = rect;
36+ this.drawStyle = drawStyle;
37+ this.icon = icon;
38+ this.label = label;
39+ this.detail = detail;
40+ this.userChecked = userChecked;
41+ this.labelColor = labelColor;
42+ this.objectColor = objectColor;
43+ this.paintStyle = paintStyle;
44+ this.strokeWidth = strokeWidth;
45+ this.fontSize = fontSize;
46+ this.historyHolder = historyHolder;
47+ historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.NEW_OBJECT, this);
48+ }
49+
50+ /**
51+ * オブジェクトのキーを取得する
52+ *
53+ */
54+ public Integer getKey()
55+ {
56+ return (key);
57+ }
58+
59+ public void setRect(RectF rectF)
60+ {
61+ historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.RECTANGLE, rect);
62+ rect = rectF;
63+ }
64+
65+ public void setRectTop(float value)
66+ {
67+ historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.RECTANGLE, rect);
68+ rect.top = value;
69+ }
70+
71+ public void setRectLeft(float value)
72+ {
73+ historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.RECTANGLE, rect);
74+ rect.left = value;
75+ }
76+
77+ public void setRectRight(float value)
78+ {
79+ historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.RECTANGLE, rect);
80+ rect.right = value;
81+ }
82+
83+ public void setRectBottom(float value)
84+ {
85+ historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.RECTANGLE, rect);
86+ rect.bottom = value;
87+ }
88+
89+ public void setDrawStyle(int value)
90+ {
91+ historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.DRAW_STYLE, drawStyle);
92+ drawStyle = value;
93+ }
94+
95+ public void setIcon(int value)
96+ {
97+ historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.ICON, icon);
98+ icon = value;
99+ }
100+
101+ public void setLabel(String value)
102+ {
103+ historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.LABEL, label);
104+ label = value;
105+ }
106+
107+ public void setDetail(String value)
108+ {
109+ historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.DETAIL, detail);
110+ detail = value;
111+ }
112+
113+ public void setUserChecked(boolean value)
114+ {
115+ historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.USER_CHECKED, userChecked);
116+ userChecked = value;
117+ }
118+
119+ public void setLabelColor(int value)
120+ {
121+ historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.LABEL_COLOR, labelColor);
122+ labelColor = value;
123+ }
124+
125+ public void setObjectColor(int value)
126+ {
127+ historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.OBJECT_COLOR, objectColor);
128+ objectColor = value;
129+ }
130+
131+ public void setPaintStyle(String value)
132+ {
133+ historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.PAINT_STYLE, paintStyle);
134+ paintStyle = value;
135+ }
136+
137+ public void setStrokeWidth(float value)
138+ {
139+ historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.STROKE_WIDTH, strokeWidth);
140+ strokeWidth = value;
141+ }
142+
143+ public void setFontSize(float value)
144+ {
145+ historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.FONT_SIZE, fontSize);
146+ fontSize = value;
147+ }
148+
149+ public void setRectOffsetTo(float newLeft, float newTop)
150+ {
151+ historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.RECTANGLE, rect);
152+ rect.offsetTo(newLeft, newTop);
153+ }
154+
155+ public RectF getRect()
156+ {
157+ return (rect);
158+ }
159+
160+ public int getDrawStyle()
161+ {
162+ return (drawStyle);
163+ }
164+
165+ public int getIcon()
166+ {
167+ return (icon);
168+ }
169+
170+ public String getLabel()
171+ {
172+ return (label);
173+ }
174+
175+ public String getDetail()
176+ {
177+ return (detail);
178+ }
179+
180+ public boolean getUserChecked()
181+ {
182+ return (userChecked);
183+ }
184+
185+ public int getLabelColor()
186+ {
187+ return (labelColor);
188+ }
189+
190+ public int getObjectColor()
191+ {
192+ return (objectColor);
193+ }
194+
195+ public String getPaintStyle()
196+ {
197+ return (paintStyle);
198+ }
199+
200+ public float getstrokeWidth()
201+ {
202+ return (strokeWidth);
203+ }
204+
205+ public float getFontSize()
206+ {
207+ return (fontSize);
208+ }
209+}
--- a/app/src/main/java/jp/sourceforge/gokigen/memoma/fileio/ExternalStorageFileUtility.java
+++ b/app/src/main/java/jp/sourceforge/gokigen/memoma/io/ExternalStorageFileUtility.java
@@ -1,4 +1,4 @@
1-package jp.sourceforge.gokigen.memoma.fileio;
1+package jp.sourceforge.gokigen.memoma.io;
22
33 import android.os.Environment;
44 import android.util.Log;
--- a/app/src/main/java/jp/sourceforge/gokigen/memoma/fileio/ImageLoader.java
+++ b/app/src/main/java/jp/sourceforge/gokigen/memoma/io/ImageLoader.java
@@ -1,4 +1,4 @@
1-package jp.sourceforge.gokigen.memoma.fileio;
1+package jp.sourceforge.gokigen.memoma.io;
22
33 import java.io.File;
44 import java.io.InputStream;
--- a/app/src/main/java/jp/sourceforge/gokigen/memoma/fileio/MeMoMaDataInOutManager.java
+++ b/app/src/main/java/jp/sourceforge/gokigen/memoma/io/MeMoMaDataInOutManager.java
@@ -1,4 +1,4 @@
1-package jp.sourceforge.gokigen.memoma.fileio;
1+package jp.sourceforge.gokigen.memoma.io;
22
33 import java.text.SimpleDateFormat;
44 import java.util.Calendar;
@@ -15,20 +15,18 @@ import android.preference.PreferenceManager;
1515 import android.util.Log;
1616 import android.widget.Toast;
1717
18-import jp.sourceforge.gokigen.memoma.GokigenSurfaceView;
18+import jp.sourceforge.gokigen.memoma.drawers.GokigenSurfaceView;
1919 import jp.sourceforge.gokigen.memoma.Main;
20-import jp.sourceforge.gokigen.memoma.MeMoMaListener;
2120 import jp.sourceforge.gokigen.memoma.R;
22-import jp.sourceforge.gokigen.memoma.SharedIntentInvoker;
2321 import jp.sourceforge.gokigen.memoma.drawers.MeMoMaCanvasDrawer;
2422 import jp.sourceforge.gokigen.memoma.holders.MeMoMaDataFileHolder;
2523 import jp.sourceforge.gokigen.memoma.holders.MeMoMaObjectHolder;
2624
2725 public class MeMoMaDataInOutManager implements MeMoMaFileSavingProcess.ISavingStatusHolder, MeMoMaFileSavingProcess.IResultReceiver, MeMoMaFileLoadingProcess.IResultReceiver, ActionBar.OnNavigationListener, ObjectLayoutCaptureExporter.ICaptureLayoutExporter
2826 {
29- private Activity parent = null;
27+ private Activity parent;
3028 private MeMoMaObjectHolder objectHolder = null;
31- private ExternalStorageFileUtility fileUtility = null;
29+ private ExternalStorageFileUtility fileUtility;
3230 private MeMoMaDataFileHolder dataFileHolder = null;
3331
3432 private boolean isSaving = false;
@@ -292,7 +290,7 @@ public class MeMoMaDataInOutManager implements MeMoMaFileSavingProcess.ISavingSt
292290 * ファイルのエクスポート結果を受け取る
293291 *
294292 */
295- public void onCaptureLayoutExportedResult(String exportedFileName, String detail)
293+ public void onCaptureLayoutExportedResult(String exportedFileName, String detail, int id)
296294 {
297295 Log.v(Main.APP_IDENTIFIER, "MeMoMaDataInOutManager::onCaptureExportedResult() '" + objectHolder.getDataTitle() +"' : " + detail);
298296
@@ -315,7 +313,7 @@ public class MeMoMaDataInOutManager implements MeMoMaFileSavingProcess.ISavingSt
315313 Uri insertedImage = resolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
316314 if (insertedImage != null)
317315 {
318- shareContent(insertedImage);
316+ shareContent(insertedImage, id);
319317 }
320318 }
321319 catch (Exception e)
@@ -331,7 +329,7 @@ public class MeMoMaDataInOutManager implements MeMoMaFileSavingProcess.ISavingSt
331329 * エクスポートしたファイルを共有する
332330 *
333331 */
334- private void shareContent(Uri imageName)
332+ private void shareContent(Uri imageName, int id)
335333 {
336334 String message = "";
337335 try
@@ -350,7 +348,7 @@ public class MeMoMaDataInOutManager implements MeMoMaFileSavingProcess.ISavingSt
350348 message = message + "number of objects : " + objectHolder.getCount() + "\n";
351349
352350 // Share Intentを発行する。
353- SharedIntentInvoker.shareContent(parent, MeMoMaListener.MENU_ID_SHARE, title, message, imageName, "image/png");
351+ SharedIntentInvoker.shareContent(parent, id, title, message, imageName, "image/png");
354352 }
355353 catch (Exception ex)
356354 {
--- a/app/src/main/java/jp/sourceforge/gokigen/memoma/fileio/MeMoMaFileExportCsvProcess.java
+++ b/app/src/main/java/jp/sourceforge/gokigen/memoma/io/MeMoMaFileExportCsvProcess.java
@@ -1,119 +1,121 @@
1-package jp.sourceforge.gokigen.memoma.fileio;
1+package jp.sourceforge.gokigen.memoma.io;
22
33 import java.io.File;
44 import java.io.FileWriter;
55 import java.text.SimpleDateFormat;
66 import java.util.Calendar;
77 import java.util.Enumeration;
8+import java.util.Locale;
89
910 import android.app.ProgressDialog;
1011 import android.content.Context;
12+import android.graphics.RectF;
1113 import android.os.AsyncTask;
1214 import android.util.Log;
1315
1416 import jp.sourceforge.gokigen.memoma.Main;
1517 import jp.sourceforge.gokigen.memoma.R;
1618 import jp.sourceforge.gokigen.memoma.holders.MeMoMaObjectHolder;
19+import jp.sourceforge.gokigen.memoma.holders.PositionObject;
1720
1821 /**
1922 * データをファイルに保存するとき用 アクセスラッパ (非同期処理を実行)
20- *
23+ *
2124 * AsyncTask
2225 * MeMoMaObjectHolder : 実行時に渡すクラス(Param)
2326 * Integer : 途中経過を伝えるクラス(Progress)
2427 * String : 処理結果を伝えるクラス(Result)
25- *
28+ *
2629 * @author MRSa
2730 *
2831 */
2932 public class MeMoMaFileExportCsvProcess extends AsyncTask<MeMoMaObjectHolder, Integer, String>
30-{
31- private IResultReceiver receiver = null;
32- private ExternalStorageFileUtility fileUtility = null;
33- private String exportedFileName = null;
34-
35- ProgressDialog savingDialog = null;
36-
37- /**
38- * コンストラクタ
39- */
33+{
34+ private IResultReceiver receiver;
35+ private ExternalStorageFileUtility fileUtility;
36+ private String exportedFileName = null;
37+
38+ private ProgressDialog savingDialog;
39+
40+ /**
41+ * コンストラクタ
42+ */
4043 public MeMoMaFileExportCsvProcess(Context context, ExternalStorageFileUtility utility, IResultReceiver resultReceiver)
4144 {
42- receiver = resultReceiver;
43- fileUtility = utility;
45+ receiver = resultReceiver;
46+ fileUtility = utility;
4447
4548 // プログレスダイアログ(「保存中...」)を表示する。
46- savingDialog = new ProgressDialog(context);
47- savingDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
48- savingDialog.setMessage(context.getString(R.string.dataSaving));
49- savingDialog.setIndeterminate(true);
50- savingDialog.setCancelable(false);
51- savingDialog.show();
52-
53- /** ファイルをバックアップするディレクトリを作成する **/
54- File dir = new File(fileUtility.getGokigenDirectory() + "/exported");
55- dir.mkdir();
56-
49+ savingDialog = new ProgressDialog(context);
50+ savingDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
51+ savingDialog.setMessage(context.getString(R.string.dataSaving));
52+ savingDialog.setIndeterminate(true);
53+ savingDialog.setCancelable(false);
54+ savingDialog.show();
55+
56+ // ファイルをバックアップするディレクトリを作成する
57+ File dir = new File(fileUtility.getGokigenDirectory() + "/exported");
58+ if (!dir.mkdir())
59+ {
60+ Log.v(toString(), "mkDir() fail. : " + dir.getAbsolutePath());
61+ }
5762 }
58-
63+
5964 /**
6065 * 非同期処理実施前の前処理
61- *
66+ *
6267 */
6368 @Override
6469 protected void onPreExecute()
6570 {
6671 }
67-
72+
6873 /**
6974 * データを(CSV形式で)保管する。
70- *
71- * @param fileName
72- * @param objectHolder
73- * @return
75+ *
7476 */
7577 private String exportToCsvFile(String fileName, MeMoMaObjectHolder objectHolder)
7678 {
77- String resultMessage = "";
79+ String resultMessage = "";
7880 try
7981 {
80- // エクスポートするファイル名を決定する
82+ // エクスポートするファイル名を決定する
8183 Calendar calendar = Calendar.getInstance();
82- SimpleDateFormat outFormat = new SimpleDateFormat("yyyyMMddHHmmss");
84+ SimpleDateFormat outFormat = new SimpleDateFormat("yyyyMMddHHmmss", Locale.US);
8385 exportedFileName = fileName + "_" + outFormat.format(calendar.getTime()) + ".csv";
84- FileWriter writer = new FileWriter(new File(exportedFileName));
85-
86- // データのタイトルを出力
87- String str = "";
88- str = "; label,detail,userChecked,shape,style,centerX,centerY,width,height,;!<_$ (';!<_$' is a record Separator)\r\n";
86+ FileWriter writer = new FileWriter(new File(exportedFileName));
87+
88+ // データのタイトルを出力
89+ String str = "; label,detail,userChecked,shape,style,centerX,centerY,width,height,;!<_$ (';!<_$' is a record Separator)\r\n";
8990 writer.write(str);
90-
91- // オブジェクトの出力 (保持しているものをすべて表示する)
92- Enumeration<Integer> keys = objectHolder.getObjectKeys();
91+
92+ // オブジェクトの出力 (保持しているものをすべて表示する)
93+ Enumeration<Integer> keys = objectHolder.getObjectKeys();
9394 while (keys.hasMoreElements())
9495 {
9596 Integer key = keys.nextElement();
96- MeMoMaObjectHolder.PositionObject pos = objectHolder.getPosition(key);
97+ PositionObject pos = objectHolder.getPosition(key);
98+ RectF posRect = pos.getRect();
9799
98100 // TODO: 絞り込み条件がある場合には、その条件に従ってしぼり込む必要あり。
99101
100102 str = "";
101- str = str + "\"" + pos.label + "\"";
102- str = str + ",\"" + pos.detail + "\"";
103- if (pos.userChecked == true)
103+ str = str + "\"" + pos.getLabel() + "\"";
104+ str = str + ",\"" + pos.getDetail() + "\"";
105+ if (pos.getUserChecked())
104106 {
105- str = str + ",True";
107+ str = str + ",True";
106108 }
107109 else
108110 {
109- str = str + ",False";
111+ str = str + ",False";
110112 }
111- str = str + "," + pos.drawStyle; // オブジェクトの形状
112- str = str + "," + pos.paintStyle; // オブジェクトの塗りつぶし状態
113- str = str + "," + (Math.round(pos.rect.centerX() * 100.0f) / 100.0f);
114- str = str + "," + (Math.round(pos.rect.centerY() * 100.0f) / 100.0f);
115- str = str + "," + (Math.round(pos.rect.width() * 100.0f) / 100.0f);
116- str = str + "," + (Math.round(pos.rect.height() * 100.0f) / 100.0f);
113+ str = str + "," + pos.getDrawStyle(); // オブジェクトの形状
114+ str = str + "," + pos.getPaintStyle(); // オブジェクトの塗りつぶし状態
115+ str = str + "," + (Math.round(posRect.centerX() * 100.0f) / 100.0f);
116+ str = str + "," + (Math.round(posRect.centerY() * 100.0f) / 100.0f);
117+ str = str + "," + (Math.round(posRect.width() * 100.0f) / 100.0f);
118+ str = str + "," + (Math.round(posRect.height() * 100.0f) / 100.0f);
117119 str = str + ",;!<_$\r\n";
118120 writer.write(str);
119121 }
@@ -122,41 +124,41 @@ public class MeMoMaFileExportCsvProcess extends AsyncTask<MeMoMaObjectHolder, In
122124 }
123125 catch (Exception e)
124126 {
125- resultMessage = " ERR>" + e.toString();
127+ resultMessage = " ERR>" + e.toString();
126128 Log.v(Main.APP_IDENTIFIER, resultMessage);
127129 e.printStackTrace();
128- }
130+ }
129131 return (resultMessage);
130132 }
131133
132134 /**
133135 * 非同期処理
134136 * (バックグラウンドで実行する(このメソッドは、UIスレッドと別のところで実行する))
135- *
137+ *
136138 */
137139 @Override
138140 protected String doInBackground(MeMoMaObjectHolder... datas)
139- {
141+ {
140142 // ファイル名の設定 ... (拡張子なし)
141- String fileName = fileUtility.getGokigenDirectory() + "/exported/" + datas[0].getDataTitle();
143+ String fileName = fileUtility.getGokigenDirectory() + "/exported/" + datas[0].getDataTitle();
142144
143- // データを保管する
145+ // データを保管する
144146 String result = exportToCsvFile(fileName, datas[0]);
145147
146148 System.gc();
147149
148- return (result);
150+ return (result);
149151 }
150152
151153 /**
152154 * 非同期処理の進捗状況の更新
153- *
155+ *
154156 */
155- @Override
156- protected void onProgressUpdate(Integer... values)
157- {
157+ @Override
158+ protected void onProgressUpdate(Integer... values)
159+ {
158160 // 今回は何もしない
159- }
161+ }
160162
161163 /**
162164 * 非同期処理の後処理
@@ -165,32 +167,30 @@ public class MeMoMaFileExportCsvProcess extends AsyncTask<MeMoMaObjectHolder, In
165167 @Override
166168 protected void onPostExecute(String result)
167169 {
168- try
169- {
170+ try
171+ {
170172 if (receiver != null)
171173 {
172- receiver.onExportedResult(exportedFileName, result);
174+ receiver.onExportedResult(exportedFileName, result);
173175 }
174- }
175- catch (Exception ex)
176- {
177- Log.v(Main.APP_IDENTIFIER, "MeMoMaFileExportCsvProcess::onPostExecute() : " + ex.toString());
178- }
179- // プログレスダイアログを消す
180- savingDialog.dismiss();
181-
182- return;
183- }
184-
176+ }
177+ catch (Exception ex)
178+ {
179+ Log.v(Main.APP_IDENTIFIER, "MeMoMaFileExportCsvProcess::onPostExecute() : " + ex.toString());
180+ }
181+ // プログレスダイアログを消す
182+ savingDialog.dismiss();
183+ }
184+
185185 /**
186186 * 結果報告用のインタフェース(積極的に使う予定はないけど...)
187- *
187+ *
188188 * @author MRSa
189189 *
190190 */
191191 public interface IResultReceiver
192192 {
193193 /** 保存結果の報告 **/
194- public abstract void onExportedResult(String exportedFileName, String detail);
194+ void onExportedResult(String exportedFileName, String detail);
195195 }
196196 }
--- a/app/src/main/java/jp/sourceforge/gokigen/memoma/fileio/MeMoMaFileImportCsvProcess.java
+++ b/app/src/main/java/jp/sourceforge/gokigen/memoma/io/MeMoMaFileImportCsvProcess.java
@@ -1,4 +1,4 @@
1-package jp.sourceforge.gokigen.memoma.fileio;
1+package jp.sourceforge.gokigen.memoma.io;
22
33 import java.io.BufferedReader;
44 import java.io.FileReader;
@@ -13,6 +13,7 @@ import android.util.Log;
1313 import jp.sourceforge.gokigen.memoma.Main;
1414 import jp.sourceforge.gokigen.memoma.R;
1515 import jp.sourceforge.gokigen.memoma.holders.MeMoMaObjectHolder;
16+import jp.sourceforge.gokigen.memoma.holders.PositionObject;
1617
1718 /**
1819 * データをファイルに保存するとき用 アクセスラッパ (非同期処理を実行)
@@ -167,18 +168,18 @@ public class MeMoMaFileImportCsvProcess extends AsyncTask<MeMoMaObjectHolder, In
167168 float top = centerY - (height / 2.0f);
168169
169170 // オブジェクトのデータを作成する
170- MeMoMaObjectHolder.PositionObject pos = objectHolder.createPosition(left, top, drawStyle);
171+ PositionObject pos = objectHolder.createPosition(left, top, drawStyle);
171172 if (pos == null)
172173 {
173174 Log.v(Main.APP_IDENTIFIER, "parseRecord() : object create failure.");
174175 return;
175176 }
176- pos.rect.right = left + width;
177- pos.rect.bottom = top + height;
178- pos.label = label;
179- pos.detail = detail;
180- pos.paintStyle = paintStyle;
181- pos.userChecked = userChecked;
177+ pos.setRectRight(left + width);
178+ pos.setRectBottom(top + height);
179+ pos.setLabel(label);
180+ pos.setDetail(detail);
181+ pos.setPaintStyle(paintStyle);
182+ pos.setUserChecked(userChecked);
182183 Log.v(Main.APP_IDENTIFIER, "OBJECT CREATED: " + label + "(" + left + "," + top + ") [" +drawStyle + "]");
183184 }
184185 catch (Exception ex)
--- a/app/src/main/java/jp/sourceforge/gokigen/memoma/fileio/MeMoMaFileLoadingProcess.java
+++ b/app/src/main/java/jp/sourceforge/gokigen/memoma/io/MeMoMaFileLoadingProcess.java
@@ -1,4 +1,4 @@
1-package jp.sourceforge.gokigen.memoma.fileio;
1+package jp.sourceforge.gokigen.memoma.io;
22
33 import java.io.File;
44 import java.io.FileReader;
@@ -7,6 +7,7 @@ import org.xmlpull.v1.XmlPullParser;
77
88 import android.content.Context;
99 import android.content.SharedPreferences;
10+import android.graphics.RectF;
1011 import android.os.AsyncTask;
1112 import android.preference.PreferenceManager;
1213 import android.util.Log;
@@ -15,6 +16,8 @@ import android.util.Xml;
1516 import jp.sourceforge.gokigen.memoma.Main;
1617 import jp.sourceforge.gokigen.memoma.holders.MeMoMaConnectLineHolder;
1718 import jp.sourceforge.gokigen.memoma.holders.MeMoMaObjectHolder;
19+import jp.sourceforge.gokigen.memoma.holders.ObjectConnector;
20+import jp.sourceforge.gokigen.memoma.holders.PositionObject;
1821
1922 /**
2023 * データをファイルに保存するとき用 アクセスラッパ (非同期処理を実行)
@@ -29,12 +32,12 @@ import jp.sourceforge.gokigen.memoma.holders.MeMoMaObjectHolder;
2932 */
3033 public class MeMoMaFileLoadingProcess extends AsyncTask<MeMoMaObjectHolder, Integer, String>
3134 {
32- private Context parent = null;
33- private IResultReceiver receiver = null;
34- private ExternalStorageFileUtility fileUtility = null;
35+ private Context parent;
36+ private IResultReceiver receiver;
37+ private ExternalStorageFileUtility fileUtility;
3538
36- private MeMoMaObjectHolder.PositionObject position = null;
37- private MeMoMaConnectLineHolder.ObjectConnector line = null;
39+ private PositionObject position = null;
40+ private ObjectConnector line = null;
3841
3942 private String backgroundUri = "";
4043 private String userCheckboxString = "";
@@ -66,37 +69,37 @@ public class MeMoMaFileLoadingProcess extends AsyncTask<MeMoMaObjectHolder, Inte
6669 //Log.v(Main.APP_IDENTIFIER, "parseStartTag() name = " + name);
6770 if ((name.equalsIgnoreCase("top"))&&(position != null))
6871 {
69- position.rect.top = Float.parseFloat(parser.nextText());
72+ position.setRectTop(Float.parseFloat(parser.nextText()));
7073 }
7174 else if ((name.equalsIgnoreCase("bottom"))&&(position != null))
7275 {
73- position.rect.bottom = Float.parseFloat(parser.nextText());
76+ position.setRectBottom(Float.parseFloat(parser.nextText()));
7477 }
7578 else if ((name.equalsIgnoreCase("left"))&&(position != null))
7679 {
77- position.rect.left = Float.parseFloat(parser.nextText());
80+ position.setRectLeft(Float.parseFloat(parser.nextText()));
7881 }
7982 else if ((name.equalsIgnoreCase("right"))&&(position != null))
8083 {
81- position.rect.right = Float.parseFloat(parser.nextText());
84+ position.setRectRight(Float.parseFloat(parser.nextText()));
8285 }
8386 else if ((name.equalsIgnoreCase("drawStyle"))&&(position != null))
8487 {
85- position.drawStyle = Integer.parseInt(parser.nextText());
88+ position.setDrawStyle(Integer.parseInt(parser.nextText()));
8689 }
8790 else if ((name.equalsIgnoreCase("icon"))&&(position != null))
8891 {
89- position.icon = Integer.parseInt(parser.nextText());
92+ position.setIcon(Integer.parseInt(parser.nextText()));
9093 }
9194 else if ((name.equalsIgnoreCase("label"))&&(position != null))
9295 {
93- position.label = parser.nextText();
96+ position.setLabel(parser.nextText());
9497 }
9598 else if ((name.equalsIgnoreCase("detail"))&&(position != null))
9699 {
97- position.detail = parser.nextText();
100+ position.setDetail(parser.nextText());
98101 }
99-/**
102+/*
100103 else if ((name.equalsIgnoreCase("backgroundUri"))&&(position != null))
101104 {
102105 position.backgroundUri = parser.nextText();
@@ -113,49 +116,49 @@ public class MeMoMaFileLoadingProcess extends AsyncTask<MeMoMaObjectHolder, Inte
113116 else if ((name.equalsIgnoreCase("userChecked"))&&(position != null))
114117 {
115118 String parseData = parser.nextText();
116- position.userChecked =(parseData.equalsIgnoreCase("true")) ? true : false;
119+ position.setUserChecked((parseData.equalsIgnoreCase("true")));
117120 }
118121 else if ((name.equalsIgnoreCase("labelColor"))&&(position != null))
119122 {
120- position.labelColor = Integer.parseInt(parser.nextText());
123+ position.setLabelColor(Integer.parseInt(parser.nextText()));
121124 }
122125 else if ((name.equalsIgnoreCase("objectColor"))&&(position != null))
123126 {
124- position.objectColor = Integer.parseInt(parser.nextText());
127+ position.setObjectColor(Integer.parseInt(parser.nextText()));
125128 }
126129 else if ((name.equalsIgnoreCase("paintStyle"))&&(position != null))
127130 {
128- position.paintStyle = parser.nextText();
131+ position.setPaintStyle(parser.nextText());
129132 }
130133 else if ((name.equalsIgnoreCase("strokeWidth"))&&(position != null))
131134 {
132- position.strokeWidth = Float.parseFloat(parser.nextText());
135+ position.setStrokeWidth(Float.parseFloat(parser.nextText()));
133136 }
134137 else if ((name.equalsIgnoreCase("fontSize"))&&(position != null))
135138 {
136- position.fontSize = Float.parseFloat(parser.nextText());
139+ position.setFontSize(Float.parseFloat(parser.nextText()));
137140 }
138141 else if ((name.equalsIgnoreCase("fromObjectKey"))&&(line != null))
139142 {
140- line.fromObjectKey = Integer.parseInt(parser.nextText());
143+ line.setFromObjectKey(Integer.parseInt(parser.nextText()));
141144 }
142145 else if ((name.equalsIgnoreCase("toObjectKey"))&&(line != null))
143146 {
144- line.toObjectKey = Integer.parseInt(parser.nextText());
147+ line.setToObjectKey(Integer.parseInt(parser.nextText()));
145148 }
146149 else if ((name.equalsIgnoreCase("lineStyle"))&&(line != null))
147150 {
148- line.lineStyle = Integer.parseInt(parser.nextText());
151+ line.setLineStyle(Integer.parseInt(parser.nextText()));
149152 }
150153 else if ((name.equalsIgnoreCase("lineShape"))&&(line != null))
151154 {
152- line.lineShape = Integer.parseInt(parser.nextText());
155+ line.setLineShape(Integer.parseInt(parser.nextText()));
153156 }
154157 else if ((name.equalsIgnoreCase("lineThickness"))&&(line != null))
155158 {
156- line.lineThickness = Integer.parseInt(parser.nextText());
159+ line.setLineThickness(Integer.parseInt(parser.nextText()));
157160 }
158-/**
161+/*
159162 else if ((name.equalsIgnoreCase("fromShape"))&&(line != null))
160163 {
161164 line.fromShape = Integer.parseInt(parser.nextText());
@@ -203,15 +206,20 @@ public class MeMoMaFileLoadingProcess extends AsyncTask<MeMoMaObjectHolder, Inte
203206 {
204207 int key = Integer.parseInt(parser.getAttributeValue(Main.APP_NAMESPACE, "key"));
205208 //Log.v(Main.APP_IDENTIFIER, "create object, key :" + key);
206- position = null;
207- position = objectHolder.createPosition(key);
209+ if (objectHolder != null)
210+ {
211+ position = objectHolder.createPosition(key);
212+ }
208213 }
209214 else if (name.equalsIgnoreCase("line"))
210215 {
211216 int key = Integer.parseInt(parser.getAttributeValue(Main.APP_NAMESPACE, "key"));
212217 //Log.v(Main.APP_IDENTIFIER, "create line, key :" + key);
213218 line = null;
214- line = objectHolder.getConnectLineHolder().createLine(key);
219+ if (objectHolder != null)
220+ {
221+ line = objectHolder.getConnectLineHolder().createLine(key);
222+ }
215223 }
216224 }
217225 catch (Exception e)
@@ -230,19 +238,22 @@ public class MeMoMaFileLoadingProcess extends AsyncTask<MeMoMaObjectHolder, Inte
230238 //objectHolder.dumpPositionObject(position);
231239
232240 // 領域サイズがおかしい場合には、オブジェクトサイズを補正する (ふつーありえないはずなんだけど...)
233- if ((position.rect.left > position.rect.right)||(position.rect.top > position.rect.bottom))
241+ RectF posRect = position.getRect();
242+ if ((posRect.left > posRect.right)||(posRect.top > posRect.bottom))
234243 {
235- Log.v(Main.APP_IDENTIFIER, "RECT IS ILLEGAL. : [" + position.rect.left + "," + position.rect.top + "-[" + position.rect.right + "," + position.rect.bottom + "]");
236- position.rect.right = position.rect.left + MeMoMaObjectHolder.OBJECTSIZE_DEFAULT_X;
237- position.rect.bottom = position.rect.top + MeMoMaObjectHolder.OBJECTSIZE_DEFAULT_Y;
244+ Log.v(Main.APP_IDENTIFIER, "RECT IS ILLEGAL. : [" + posRect.left + "," + posRect.top + "-[" + posRect.right + "," + posRect.bottom + "]");
245+ position.setRectRight(posRect.left + MeMoMaObjectHolder.OBJECTSIZE_DEFAULT_X);
246+ position.setRectBottom(posRect.top + MeMoMaObjectHolder.OBJECTSIZE_DEFAULT_Y);
238247 }
239-
240248 }
249+/*
241250 else if (name.equalsIgnoreCase("line"))
242251 {
252+ //
243253 //Log.v(Main.APP_IDENTIFIER, "parseEndTag() : LINE");
244254 //objectHolder.getConnectLineHolder().dumpConnectLine(line);
245255 }
256+*/
246257 }
247258 catch (Exception e)
248259 {
@@ -252,10 +263,7 @@ public class MeMoMaFileLoadingProcess extends AsyncTask<MeMoMaObjectHolder, Inte
252263
253264 /**
254265 * (XML形式の)データを読みだす。
255- *
256- * @param fileName
257- * @param objectHolder
258- * @return
266+ *
259267 */
260268 private String restoreToXmlFile(String fileName, MeMoMaObjectHolder objectHolder)
261269 {
@@ -270,7 +278,7 @@ public class MeMoMaFileLoadingProcess extends AsyncTask<MeMoMaObjectHolder, Inte
270278 try
271279 {
272280 File inputFile = new File(fileName);
273- if (inputFile.exists() == false)
281+ if (!inputFile.exists())
274282 {
275283 // ファイルがなかったときには、「ファイルなし」と報告する。
276284 resultMessage = "ERR>File not found.";
@@ -281,7 +289,6 @@ public class MeMoMaFileLoadingProcess extends AsyncTask<MeMoMaObjectHolder, Inte
281289 parser.setInput(reader);
282290
283291 int eventType = parser.getEventType();
284- boolean done = false;
285292
286293 // オブジェクトとラインをすべてクリアする
287294 objectHolder.removeAllPositions();
@@ -292,7 +299,7 @@ public class MeMoMaFileLoadingProcess extends AsyncTask<MeMoMaObjectHolder, Inte
292299 }
293300 lineHolder.removeAllLines();
294301
295- while ((eventType != XmlPullParser.END_DOCUMENT)&&(done != true))
302+ while ((eventType != XmlPullParser.END_DOCUMENT))
296303 {
297304 switch (eventType)
298305 {
@@ -366,14 +373,14 @@ public class MeMoMaFileLoadingProcess extends AsyncTask<MeMoMaObjectHolder, Inte
366373 {
367374 try
368375 {
369- if (result.isEmpty() == true)
376+ if (result.isEmpty())
370377 {
371378 // エラーが発生していない場合には、読みだしたデータをPreferenceに設定登録...
372379 SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
373380 SharedPreferences.Editor editor = preferences.edit();
374381 editor.putString("backgroundUri", backgroundUri);
375382 editor.putString("userCheckboxString", userCheckboxString);
376- editor.commit();
383+ editor.apply();
377384 }
378385
379386 if (receiver != null)
@@ -385,7 +392,6 @@ public class MeMoMaFileLoadingProcess extends AsyncTask<MeMoMaObjectHolder, Inte
385392 {
386393 Log.v(Main.APP_IDENTIFIER, "MeMoMaFileSavingProcess::onPostExecute() : " + ex.toString());
387394 }
388- return;
389395 }
390396
391397 /**
@@ -397,9 +403,9 @@ public class MeMoMaFileLoadingProcess extends AsyncTask<MeMoMaObjectHolder, Inte
397403 public interface IResultReceiver
398404 {
399405 /** 処理中の処理 **/
400- public abstract void onLoadingProcess();
406+ void onLoadingProcess();
401407
402408 /** 保存結果の報告 **/
403- public abstract void onLoadedResult(String detail);
409+ void onLoadedResult(String detail);
404410 }
405411 }
--- a/app/src/main/java/jp/sourceforge/gokigen/memoma/fileio/MeMoMaFileSavingEngine.java
+++ b/app/src/main/java/jp/sourceforge/gokigen/memoma/io/MeMoMaFileSavingEngine.java
@@ -1,4 +1,4 @@
1-package jp.sourceforge.gokigen.memoma.fileio;
1+package jp.sourceforge.gokigen.memoma.io;
22
33 import java.io.File;
44 import java.io.FileWriter;
@@ -6,12 +6,14 @@ import java.util.Enumeration;
66
77 import org.xmlpull.v1.XmlSerializer;
88
9+import android.graphics.RectF;
910 import android.util.Log;
1011 import android.util.Xml;
1112
1213 import jp.sourceforge.gokigen.memoma.Main;
13-import jp.sourceforge.gokigen.memoma.holders.MeMoMaConnectLineHolder;
1414 import jp.sourceforge.gokigen.memoma.holders.MeMoMaObjectHolder;
15+import jp.sourceforge.gokigen.memoma.holders.ObjectConnector;
16+import jp.sourceforge.gokigen.memoma.holders.PositionObject;
1517
1618 /**
1719 * データをファイルに保存するエンジン部分
@@ -28,12 +30,12 @@ public class MeMoMaFileSavingEngine
2830 /**
2931 * コンストラクタ
3032 */
31- public MeMoMaFileSavingEngine(ExternalStorageFileUtility utility, String bgUri, String checkBoxLabel)
33+ MeMoMaFileSavingEngine(ExternalStorageFileUtility utility, String bgUri, String checkBoxLabel)
3234 {
33- /** ファイルユーティリティを記憶する **/
35+ // ファイルユーティリティを記憶する
3436 fileUtility = utility;
3537
36- /** ファイルをバックアップするディレクトリを作成する **/
38+ // ファイルをバックアップするディレクトリを作成する
3739 File dir = new File(fileUtility.getGokigenDirectory() + "/backup");
3840 dir.mkdir();
3941
@@ -44,15 +46,13 @@ public class MeMoMaFileSavingEngine
4446
4547 /**
4648 * ファイルが存在したとき、リネームする
47- *
48- * @param targetFileName
49- * @param newFileName
49+ *
5050 */
5151 private boolean renameFile(String targetFileName, String newFileName)
5252 {
5353 boolean ret = true;
5454 File targetFile = new File(targetFileName);
55- if (targetFile.exists() == true)
55+ if (targetFile.exists())
5656 {
5757 // ファイルが存在した、、、ファイル名を1世代古いものに変更する
5858 ret = targetFile.renameTo(new File(newFileName));
@@ -63,7 +63,7 @@ public class MeMoMaFileSavingEngine
6363 /**
6464 * 保管データを複数世代保管する。
6565 *
66- * @param fileName
66+ *
6767 */
6868 private void backupFiles(String dirName, String backupFileName)
6969 {
@@ -73,7 +73,7 @@ public class MeMoMaFileSavingEngine
7373 {
7474 String fileName = dirName + "backup/" + backupFileName;
7575 File backFile = new File(fileName + ".xml.bak5");
76- if (backFile.exists() == true)
76+ if (backFile.exists())
7777 {
7878 // ファイルが存在した、、、削除する
7979 backFile.delete();
@@ -91,20 +91,16 @@ public class MeMoMaFileSavingEngine
9191 // 何か例外が発生した場合にはエラーと認識する。
9292 result = false;
9393 }
94- if (result == false)
94+ if (!result)
9595 {
9696 // バックアップファイルのコピー失敗をログに記述する
9797 Log.v(Main.APP_IDENTIFIER, "rename failure : " + dirName + backupFileName + ".xml");
9898 }
99- return;
10099 }
101100
102101 /**
103102 * データを(XML形式で)保管する。
104- *
105- * @param fileName
106- * @param objectHolder
107- * @return
103+ *
108104 */
109105 private String storeToXmlFile(String fileName, MeMoMaObjectHolder objectHolder)
110106 {
@@ -152,42 +148,43 @@ public class MeMoMaFileSavingEngine
152148 while (keys.hasMoreElements())
153149 {
154150 Integer key = keys.nextElement();
155- MeMoMaObjectHolder.PositionObject pos = objectHolder.getPosition(key);
151+ PositionObject pos = objectHolder.getPosition(key);
152+ RectF posRect = pos.getRect();
156153 serializer.startTag(Main.APP_NAMESPACE, "object");
157154
158155 serializer.attribute(Main.APP_NAMESPACE, "key", Integer.toString(key));
159156
160157 serializer.startTag(Main.APP_NAMESPACE, "rect");
161158 serializer.startTag(Main.APP_NAMESPACE, "top");
162- serializer.text(Float.toString(pos.rect.top));
159+ serializer.text(Float.toString(posRect.top));
163160 serializer. endTag(Main.APP_NAMESPACE, "top");
164161 serializer.startTag(Main.APP_NAMESPACE, "left");
165- serializer.text(Float.toString(pos.rect.left));
162+ serializer.text(Float.toString(posRect.left));
166163 serializer. endTag(Main.APP_NAMESPACE, "left");
167164 serializer.startTag(Main.APP_NAMESPACE, "right");
168- serializer.text(Float.toString(pos.rect.right));
165+ serializer.text(Float.toString(posRect.right));
169166 serializer. endTag(Main.APP_NAMESPACE, "right");
170167 serializer.startTag(Main.APP_NAMESPACE, "bottom");
171- serializer.text(Float.toString(pos.rect.bottom));
168+ serializer.text(Float.toString(posRect.bottom));
172169 serializer. endTag(Main.APP_NAMESPACE, "bottom");
173170 serializer. endTag(Main.APP_NAMESPACE, "rect");
174171
175172 serializer.startTag(Main.APP_NAMESPACE, "drawStyle");
176- serializer.text(Integer.toString(pos.drawStyle));
173+ serializer.text(Integer.toString(pos.getDrawStyle()));
177174 serializer. endTag(Main.APP_NAMESPACE, "drawStyle");
178175
179176 serializer.startTag(Main.APP_NAMESPACE, "icon");
180- serializer.text(Integer.toString(pos.icon));
177+ serializer.text(Integer.toString(pos.getIcon()));
181178 serializer. endTag(Main.APP_NAMESPACE, "icon");
182179
183180 serializer.startTag(Main.APP_NAMESPACE, "label");
184- serializer.text(pos.label);
181+ serializer.text(pos.getLabel());
185182 serializer. endTag(Main.APP_NAMESPACE, "label");
186183
187184 serializer.startTag(Main.APP_NAMESPACE, "detail");
188- serializer.text(pos.detail);
185+ serializer.text(pos.getDetail());
189186 serializer. endTag(Main.APP_NAMESPACE, "detail");
190-/**
187+/*
191188 serializer.startTag(Main.APP_NAMESPACE, "otherInfoUri");
192189 serializer.text(pos.otherInfoUri);
193190 serializer. endTag(Main.APP_NAMESPACE, "otherInfoUri");
@@ -199,29 +196,29 @@ public class MeMoMaFileSavingEngine
199196 serializer.startTag(Main.APP_NAMESPACE, "objectStatus");
200197 serializer.text(pos.objectStatus);
201198 serializer. endTag(Main.APP_NAMESPACE, "objectStatus");
202-**/
199+*/
203200 serializer.startTag(Main.APP_NAMESPACE, "userChecked");
204- serializer.text(Boolean.toString(pos.userChecked));
201+ serializer.text(Boolean.toString(pos.getUserChecked()));
205202 serializer. endTag(Main.APP_NAMESPACE, "userChecked");
206203
207204 serializer.startTag(Main.APP_NAMESPACE, "labelColor");
208- serializer.text(Integer.toString(pos.labelColor));
205+ serializer.text(Integer.toString(pos.getLabelColor()));
209206 serializer. endTag(Main.APP_NAMESPACE, "labelColor");
210207
211208 serializer.startTag(Main.APP_NAMESPACE, "objectColor");
212- serializer.text(Integer.toString(pos.objectColor));
209+ serializer.text(Integer.toString(pos.getObjectColor()));
213210 serializer. endTag(Main.APP_NAMESPACE, "objectColor");
214211
215212 serializer.startTag(Main.APP_NAMESPACE, "paintStyle");
216- serializer.text(pos.paintStyle);
213+ serializer.text(pos.getPaintStyle());
217214 serializer. endTag(Main.APP_NAMESPACE, "paintStyle");
218215
219216 serializer.startTag(Main.APP_NAMESPACE, "strokeWidth");
220- serializer.text(Float.toString(pos.strokeWidth));
217+ serializer.text(Float.toString(pos.getstrokeWidth()));
221218 serializer. endTag(Main.APP_NAMESPACE, "strokeWidth");
222219
223220 serializer.startTag(Main.APP_NAMESPACE, "fontSize");
224- serializer.text(Float.toString(pos.fontSize));
221+ serializer.text(Float.toString(pos.getFontSize()));
225222 serializer. endTag(Main.APP_NAMESPACE, "fontSize");
226223
227224 serializer.endTag(Main.APP_NAMESPACE, "object");
@@ -232,30 +229,30 @@ public class MeMoMaFileSavingEngine
232229 while (lineKeys.hasMoreElements())
233230 {
234231 Integer key = lineKeys.nextElement();
235- MeMoMaConnectLineHolder.ObjectConnector line = objectHolder.getConnectLineHolder().getLine(key);
232+ ObjectConnector line = objectHolder.getConnectLineHolder().getLine(key);
236233 serializer.startTag(Main.APP_NAMESPACE, "line");
237234 serializer.attribute(Main.APP_NAMESPACE, "key", Integer.toString(key));
238235
239236 serializer.startTag(Main.APP_NAMESPACE, "fromObjectKey");
240- serializer.text(Integer.toString(line.fromObjectKey));
237+ serializer.text(Integer.toString(line.getFromObjectKey()));
241238 serializer.endTag(Main.APP_NAMESPACE, "fromObjectKey");
242239
243240 serializer.startTag(Main.APP_NAMESPACE, "toObjectKey");
244- serializer.text(Integer.toString(line.toObjectKey));
241+ serializer.text(Integer.toString(line.getToObjectKey()));
245242 serializer.endTag(Main.APP_NAMESPACE, "toObjectKey");
246243
247244 serializer.startTag(Main.APP_NAMESPACE, "lineStyle");
248- serializer.text(Integer.toString(line.lineStyle));
245+ serializer.text(Integer.toString(line.getLineStyle()));
249246 serializer.endTag(Main.APP_NAMESPACE, "lineStyle");
250247
251248 serializer.startTag(Main.APP_NAMESPACE, "lineShape");
252- serializer.text(Integer.toString(line.lineShape));
249+ serializer.text(Integer.toString(line.getLineShape()));
253250 serializer.endTag(Main.APP_NAMESPACE, "lineShape");
254251
255252 serializer.startTag(Main.APP_NAMESPACE, "lineThickness");
256- serializer.text(Integer.toString(line.lineThickness));
253+ serializer.text(Integer.toString(line.getLineThickness()));
257254 serializer.endTag(Main.APP_NAMESPACE, "lineThickness");
258-/**
255+/*
259256 serializer.startTag(Main.APP_NAMESPACE, "fromShape");
260257 serializer.text(Integer.toString(line.fromShape));
261258 serializer.endTag(Main.APP_NAMESPACE, "fromShape");
@@ -271,7 +268,7 @@ public class MeMoMaFileSavingEngine
271268 serializer.startTag(Main.APP_NAMESPACE, "toString");
272269 serializer.text(line.toString);
273270 serializer.endTag(Main.APP_NAMESPACE, "toString");
274-**/
271+*/
275272 serializer.endTag(Main.APP_NAMESPACE, "line");
276273 }
277274
@@ -292,8 +289,7 @@ public class MeMoMaFileSavingEngine
292289 /**
293290 * オブジェクトを保存する
294291 *
295- * @param objectHolder
296- * @return
292+ *
297293 */
298294 public String saveObjects(MeMoMaObjectHolder objectHolder)
299295 {
@@ -312,8 +308,6 @@ public class MeMoMaFileSavingEngine
312308 String fileName = fileUtility.getGokigenDirectory() + "/" + objectHolder.getDataTitle();
313309
314310 // データを保管する
315- String result = storeToXmlFile(fileName, objectHolder);
316-
317- return (result);
311+ return (storeToXmlFile(fileName, objectHolder));
318312 }
319313 }
--- a/app/src/main/java/jp/sourceforge/gokigen/memoma/fileio/MeMoMaFileSavingProcess.java
+++ b/app/src/main/java/jp/sourceforge/gokigen/memoma/io/MeMoMaFileSavingProcess.java
@@ -1,4 +1,4 @@
1-package jp.sourceforge.gokigen.memoma.fileio;
1+package jp.sourceforge.gokigen.memoma.io;
22
33 import android.app.ProgressDialog;
44 import android.content.Context;
--- a/app/src/main/java/jp/sourceforge/gokigen/memoma/fileio/ObjectLayoutCaptureExporter.java
+++ b/app/src/main/java/jp/sourceforge/gokigen/memoma/io/ObjectLayoutCaptureExporter.java
@@ -1,4 +1,4 @@
1-package jp.sourceforge.gokigen.memoma.fileio;
1+package jp.sourceforge.gokigen.memoma.io;
22
33 import java.io.File;
44 import java.io.FileOutputStream;
@@ -14,6 +14,7 @@ import android.graphics.Bitmap;
1414 import android.graphics.Bitmap.CompressFormat;
1515 import android.graphics.Canvas;
1616 import android.graphics.Rect;
17+import android.graphics.RectF;
1718 import android.os.AsyncTask;
1819 import android.util.Log;
1920 import android.view.Display;
@@ -22,6 +23,7 @@ import jp.sourceforge.gokigen.memoma.Main;
2223 import jp.sourceforge.gokigen.memoma.R;
2324 import jp.sourceforge.gokigen.memoma.drawers.MeMoMaCanvasDrawer;
2425 import jp.sourceforge.gokigen.memoma.holders.MeMoMaObjectHolder;
26+import jp.sourceforge.gokigen.memoma.holders.PositionObject;
2527
2628 /**
2729 * データをファイルに保存するとき用 アクセスラッパ (非同期処理を実行)
@@ -38,6 +40,7 @@ import jp.sourceforge.gokigen.memoma.holders.MeMoMaObjectHolder;
3840 */
3941 public class ObjectLayoutCaptureExporter extends AsyncTask<String, Integer, String>
4042 {
43+ private static final int OUTPUT_EXPORT_SHARE_ID = 1000;
4144 private static final int OUTPUT_MARGIN = 8;
4245 private static final int OUTPUT_MARGIN_TOP = 50;
4346
@@ -146,22 +149,23 @@ public class ObjectLayoutCaptureExporter extends AsyncTask<String, Integer, Stri
146149 while (keys.hasMoreElements())
147150 {
148151 Integer key = keys.nextElement();
149- MeMoMaObjectHolder.PositionObject pos = objectHolder.getPosition(key);
150- if (canvasSize.left > pos.rect.left)
152+ PositionObject pos = objectHolder.getPosition(key);
153+ RectF posRect = pos.getRect();
154+ if (canvasSize.left > posRect.left)
151155 {
152- canvasSize.left = (int) pos.rect.left;
156+ canvasSize.left = (int) posRect.left;
153157 }
154- if (canvasSize.right < pos.rect.right)
158+ if (canvasSize.right < posRect.right)
155159 {
156- canvasSize.right = (int) pos.rect.right;
160+ canvasSize.right = (int) posRect.right;
157161 }
158- if (canvasSize.top > pos.rect.top)
162+ if (canvasSize.top > posRect.top)
159163 {
160- canvasSize.top = (int) pos.rect.top;
164+ canvasSize.top = (int) posRect.top;
161165 }
162- if (canvasSize.bottom < pos.rect.bottom)
166+ if (canvasSize.bottom < posRect.bottom)
163167 {
164- canvasSize.bottom = (int) pos.rect.bottom;
168+ canvasSize.bottom = (int) posRect.bottom;
165169 }
166170 }
167171
@@ -258,7 +262,7 @@ public class ObjectLayoutCaptureExporter extends AsyncTask<String, Integer, Stri
258262 {
259263 if (receiver != null)
260264 {
261- receiver.onCaptureLayoutExportedResult(exportedFileName, result);
265+ receiver.onCaptureLayoutExportedResult(exportedFileName, result, OUTPUT_EXPORT_SHARE_ID);
262266 }
263267 }
264268 catch (Exception ex)
@@ -281,6 +285,6 @@ public class ObjectLayoutCaptureExporter extends AsyncTask<String, Integer, Stri
281285 public interface ICaptureLayoutExporter
282286 {
283287 // 保存結果の報告
284- void onCaptureLayoutExportedResult(String exportedFileName, String detail);
288+ void onCaptureLayoutExportedResult(String exportedFileName, String detail, int id);
285289 }
286290 }
--- a/app/src/main/java/jp/sourceforge/gokigen/memoma/SharedIntentInvoker.java
+++ b/app/src/main/java/jp/sourceforge/gokigen/memoma/io/SharedIntentInvoker.java
@@ -1,4 +1,4 @@
1-package jp.sourceforge.gokigen.memoma;
1+package jp.sourceforge.gokigen.memoma.io;
22
33 import android.app.Activity;
44 import android.content.Intent;
--- a/app/src/main/java/jp/sourceforge/gokigen/memoma/fileio/ViewCaptureExporter.java
+++ b/app/src/main/java/jp/sourceforge/gokigen/memoma/io/ViewCaptureExporter.java
@@ -1,4 +1,4 @@
1-package jp.sourceforge.gokigen.memoma.fileio;
1+package jp.sourceforge.gokigen.memoma.io;
22
33 import java.io.File;
44 import java.io.FileOutputStream;
--- a/app/src/main/java/jp/sourceforge/gokigen/memoma/operations/ObjectAligner.java
+++ b/app/src/main/java/jp/sourceforge/gokigen/memoma/operations/ObjectAligner.java
@@ -5,12 +5,14 @@ import java.util.Enumeration;
55
66 import android.app.ProgressDialog;
77 import android.content.Context;
8+import android.graphics.RectF;
89 import android.os.AsyncTask;
910 import android.util.Log;
1011
1112 import jp.sourceforge.gokigen.memoma.Main;
1213 import jp.sourceforge.gokigen.memoma.R;
1314 import jp.sourceforge.gokigen.memoma.holders.MeMoMaObjectHolder;
15+import jp.sourceforge.gokigen.memoma.holders.PositionObject;
1416
1517 /**
1618 * オブジェクトの位置を整列するクラス (非同期処理を実行)
@@ -25,8 +27,8 @@ import jp.sourceforge.gokigen.memoma.holders.MeMoMaObjectHolder;
2527 */
2628 public class ObjectAligner extends AsyncTask<MeMoMaObjectHolder, Integer, String>
2729 {
28- ProgressDialog executingDialog = null;
29- IAlignCallback receiver = null;
30+ private ProgressDialog executingDialog;
31+ private IAlignCallback receiver;
3032 /**
3133 * コンストラクタ
3234 */
@@ -68,11 +70,11 @@ public class ObjectAligner extends AsyncTask<MeMoMaObjectHolder, Integer, String
6870 while (keys.hasMoreElements())
6971 {
7072 Integer key = keys.nextElement();
71- MeMoMaObjectHolder.PositionObject pos = objectHolder.getPosition(key);
72-
73- float newLeft = (float) Math.floor((pos.rect.left + 15.0f)/ 30.0) * 30.0f;
74- float newTop = (float) Math.floor((pos.rect.top + 15.0f)/ 30.0) * 30.0f;
75- pos.rect.offsetTo(newLeft, newTop);
73+ PositionObject pos = objectHolder.getPosition(key);
74+ RectF posRect = pos.getRect();
75+ float newLeft = (float) Math.floor((posRect.left + 15.0f)/ 30.0) * 30.0f;
76+ float newTop = (float) Math.floor((posRect.top + 15.0f)/ 30.0) * 30.0f;
77+ pos.setRectOffsetTo(newLeft, newTop);
7678 }
7779 System.gc();
7880
@@ -111,7 +113,6 @@ public class ObjectAligner extends AsyncTask<MeMoMaObjectHolder, Integer, String
111113
112114 // プログレスダイアログを消す
113115 executingDialog.dismiss();
114- return;
115116 }
116117
117118 /**
@@ -122,6 +123,6 @@ public class ObjectAligner extends AsyncTask<MeMoMaObjectHolder, Integer, String
122123 */
123124 public interface IAlignCallback
124125 {
125- public abstract void objectAligned();
126+ void objectAligned();
126127 }
127128 }
--- a/app/src/main/java/jp/sourceforge/gokigen/memoma/operations/ObjectDataInputDialog.java
+++ b/app/src/main/java/jp/sourceforge/gokigen/memoma/operations/ObjectDataInputDialog.java
@@ -8,6 +8,7 @@ import android.content.SharedPreferences;
88 import android.graphics.Color;
99 import android.graphics.Paint;
1010 import android.graphics.PorterDuff.Mode;
11+import android.graphics.RectF;
1112 import android.graphics.drawable.BitmapDrawable;
1213 import android.graphics.drawable.GradientDrawable;
1314 import android.preference.PreferenceManager;
@@ -26,6 +27,7 @@ import jp.sourceforge.gokigen.memoma.Main;
2627 import jp.sourceforge.gokigen.memoma.R;
2728 import jp.sourceforge.gokigen.memoma.drawers.MeMoMaCanvasDrawer;
2829 import jp.sourceforge.gokigen.memoma.holders.MeMoMaObjectHolder;
30+import jp.sourceforge.gokigen.memoma.holders.PositionObject;
2931
3032 /**
3133 * オブジェクトのデータを入力するダイアログを表示する
@@ -35,9 +37,9 @@ import jp.sourceforge.gokigen.memoma.holders.MeMoMaObjectHolder;
3537 */
3638 public class ObjectDataInputDialog implements SeekBar.OnSeekBarChangeListener, CompoundButton.OnCheckedChangeListener, ImageButton.OnClickListener
3739 {
38- private final float FONTSIZE_SMALL = 4.0f;
39- private final float FONTSIZE_MIDDLE = 6.0f;
40- private final float FONTSIZE_LARGE = 10.0f;
40+ private final float FONTSIZE_SMALL = 5.0f;
41+ private final float FONTSIZE_MIDDLE = 8.0f;
42+ private final float FONTSIZE_LARGE = 12.0f;
4143
4244 private Context context = null;
4345 private IResultReceiver resultReceiver = null;
@@ -66,7 +68,7 @@ public class ObjectDataInputDialog implements SeekBar.OnSeekBarChangeListener, C
6668
6769 /**
6870 * 確認ダイアログを応答する
69- * @return
71+ *
7072 */
7173 public Dialog getDialog()
7274 {
@@ -90,7 +92,7 @@ public class ObjectDataInputDialog implements SeekBar.OnSeekBarChangeListener, C
9092 backgroundColor = MeMoMaCanvasDrawer.BACKGROUND_COLOR_DEFAULT;
9193 }
9294
93- final TextView colorLabel = (TextView) layout.findViewById(R.id.setBorderColorLabel);
95+ final TextView colorLabel = layout.findViewById(R.id.setBorderColorLabel);
9496 backgroundShape = (GradientDrawable)colorLabel.getBackground();
9597
9698 // 入力文字列の色を設定する
@@ -100,59 +102,58 @@ public class ObjectDataInputDialog implements SeekBar.OnSeekBarChangeListener, C
100102 final EditText detail = (EditText) layout.findViewById(R.id.descriptionInputArea);
101103 //detail.setTextColor(Color.LTGRAY);
102104
103- borderColorView = (SeekBar) layout.findViewById(R.id.borderColorSelectionBar);
105+ borderColorView = layout.findViewById(R.id.borderColorSelectionBar);
104106 borderColorView.setOnSeekBarChangeListener(this);
105107
106- final CheckBox userCheckbox = (CheckBox) layout.findViewById(R.id.checkUserCheckbox);
107- final CheckBox boldText = (CheckBox) layout.findViewById(R.id.checkBoldText);
108- fillObjectView = (CheckBox) layout.findViewById(R.id.checkFillObject);
108+ final CheckBox userCheckbox = layout.findViewById(R.id.checkUserCheckbox);
109+ final CheckBox boldText = layout.findViewById(R.id.checkBoldText);
110+ fillObjectView = layout.findViewById(R.id.checkFillObject);
109111 fillObjectView.setOnCheckedChangeListener(this);
110112
111- colorBorderAreaView = (TextView) layout.findViewById(R.id.borderColorArea);
113+ colorBorderAreaView = layout.findViewById(R.id.borderColorArea);
112114 colorBorderAreaView.setOnClickListener(this);
113115
114- final ImageButton rect = (ImageButton) layout.findViewById(R.id.btnObjectRectangle);
116+ final ImageButton rect = layout.findViewById(R.id.btnObjectRectangle);
115117 rect.setOnClickListener(this);
116- final ImageButton roundRect = (ImageButton) layout.findViewById(R.id.btnObjectRoundRect);
118+ final ImageButton roundRect = layout.findViewById(R.id.btnObjectRoundRect);
117119 roundRect.setOnClickListener(this);
118- final ImageButton oval = (ImageButton) layout.findViewById(R.id.btnObjectOval);
120+ final ImageButton oval = layout.findViewById(R.id.btnObjectOval);
119121 oval.setOnClickListener(this);
120- final ImageButton diamond = (ImageButton) layout.findViewById(R.id.btnObjectDiamond);
122+ final ImageButton diamond = layout.findViewById(R.id.btnObjectDiamond);
121123 diamond.setOnClickListener(this);
122- final ImageButton hexagonal = (ImageButton) layout.findViewById(R.id.btnObjectHexagonal);
124+ final ImageButton hexagonal = layout.findViewById(R.id.btnObjectHexagonal);
123125 hexagonal.setOnClickListener(this);
124- final ImageButton parallelogram = (ImageButton) layout.findViewById(R.id.btnObjectParallelogram);
126+ final ImageButton parallelogram = layout.findViewById(R.id.btnObjectParallelogram);
125127 parallelogram.setOnClickListener(this);
126- final ImageButton keyboard = (ImageButton) layout.findViewById(R.id.btnObjectKeyboard);
128+ final ImageButton keyboard = layout.findViewById(R.id.btnObjectKeyboard);
127129 keyboard.setOnClickListener(this);
128- final ImageButton paper = (ImageButton) layout.findViewById(R.id.btnObjectPaper);
130+ final ImageButton paper = layout.findViewById(R.id.btnObjectPaper);
129131 paper.setOnClickListener(this);
130- final ImageButton drum = (ImageButton) layout.findViewById(R.id.btnObjectDrum);
132+ final ImageButton drum = layout.findViewById(R.id.btnObjectDrum);
131133 drum.setOnClickListener(this);
132- final ImageButton circle = (ImageButton) layout.findViewById(R.id.btnObjectCircle);
134+ final ImageButton circle = layout.findViewById(R.id.btnObjectCircle);
133135 circle.setOnClickListener(this);
134- final ImageButton noregion = (ImageButton) layout.findViewById(R.id.btnObjectNoRegion);
136+ final ImageButton noregion = layout.findViewById(R.id.btnObjectNoRegion);
135137 noregion.setOnClickListener(this);
136-
137- final ImageButton loopStart = (ImageButton) layout.findViewById(R.id.btnObjectLoopStart);
138+ final ImageButton loopStart = layout.findViewById(R.id.btnObjectLoopStart);
138139 loopStart.setOnClickListener(this);
139- final ImageButton loopEnd = (ImageButton) layout.findViewById(R.id.btnObjectLoopEnd);
140+ final ImageButton loopEnd = layout.findViewById(R.id.btnObjectLoopEnd);
140141 loopEnd.setOnClickListener(this);
141- final ImageButton leftArrow = (ImageButton) layout.findViewById(R.id.btnObjectLeftArrow);
142+ final ImageButton leftArrow = layout.findViewById(R.id.btnObjectLeftArrow);
142143 leftArrow.setOnClickListener(this);
143- final ImageButton downArrow = (ImageButton) layout.findViewById(R.id.btnObjectDownArrow);
144+ final ImageButton downArrow = layout.findViewById(R.id.btnObjectDownArrow);
144145 downArrow.setOnClickListener(this);
145- final ImageButton upArrow = (ImageButton) layout.findViewById(R.id.btnObjectUpArrow);
146+ final ImageButton upArrow = layout.findViewById(R.id.btnObjectUpArrow);
146147 upArrow.setOnClickListener(this);
147- final ImageButton rightArrow = (ImageButton) layout.findViewById(R.id.btnObjectRightArrow);
148+ final ImageButton rightArrow = layout.findViewById(R.id.btnObjectRightArrow);
148149 rightArrow.setOnClickListener(this);
149150
150151 // 背景の色を調整(塗りつぶしの時はオブジェクトの色とする。)
151152 int color = convertColor(borderColorView.getProgress());
152- colorBorderAreaView.setBackgroundColor((fillObjectView.isChecked() == true) ? color : backgroundColor);
153+ colorBorderAreaView.setBackgroundColor((fillObjectView.isChecked()) ? color : backgroundColor);
153154 //backgroundShape.setStroke(2, color);
154155
155- if (fillObjectView.isChecked() == true)
156+ if (fillObjectView.isChecked())
156157 {
157158 // 塗りつぶし時は文字の色を変える。
158159 color = (color ^ 0x00ffffff);
@@ -162,29 +163,29 @@ public class ObjectDataInputDialog implements SeekBar.OnSeekBarChangeListener, C
162163
163164 builder.setView(layout);
164165 builder.setCancelable(false);
166+
165167 builder.setPositiveButton(context.getString(R.string.confirmYes), new DialogInterface.OnClickListener()
166168 {
167169 public void onClick(DialogInterface dialog, int id)
168170 {
169- boolean ret = false;
170- boolean isUserCheck = false;
171- if (userCheckbox != null)
172- {
173- isUserCheck = userCheckbox.isChecked();
174- }
175- setObjectData(label.getText().toString(), detail.getText().toString(), borderColorView.getProgress(), boldText.isChecked(), fillObjectView.isChecked(), isUserCheck, currentObjectDrawStyle);
176- if (resultReceiver != null)
177- {
178- resultReceiver.finishObjectInput();
179- }
180- if (ret == true)
171+ try
181172 {
182- dialog.dismiss();
173+ boolean isUserCheck = false;
174+ if (userCheckbox != null)
175+ {
176+ isUserCheck = userCheckbox.isChecked();
177+ }
178+ setObjectData(label.getText().toString(), detail.getText().toString(), borderColorView.getProgress(), boldText.isChecked(), fillObjectView.isChecked(), isUserCheck, currentObjectDrawStyle);
179+ if (resultReceiver != null)
180+ {
181+ resultReceiver.finishObjectInput();
182+ }
183183 }
184- else
184+ catch (Exception e)
185185 {
186- dialog.cancel();
186+ e.printStackTrace();
187187 }
188+ dialog.dismiss();
188189 System.gc();
189190 }
190191 });
@@ -192,19 +193,18 @@ public class ObjectDataInputDialog implements SeekBar.OnSeekBarChangeListener, C
192193 {
193194 public void onClick(DialogInterface dialog, int id)
194195 {
195- boolean ret = false;
196- if (resultReceiver != null)
197- {
198- resultReceiver.cancelObjectInput();
199- }
200- if (ret == true)
196+ try
201197 {
202- dialog.dismiss();
198+ if (resultReceiver != null)
199+ {
200+ resultReceiver.cancelObjectInput();
201+ }
203202 }
204- else
203+ catch (Exception e)
205204 {
206- dialog.cancel();
205+ e.printStackTrace();
207206 }
207+ dialog.cancel();
208208 System.gc();
209209 }
210210 });
@@ -217,36 +217,36 @@ public class ObjectDataInputDialog implements SeekBar.OnSeekBarChangeListener, C
217217 */
218218 public void prepareObjectInputDialog(Dialog dialog, Integer objectKey)
219219 {
220- MeMoMaObjectHolder.PositionObject position = objectHolder.getPosition(objectKey);
220+ PositionObject position = objectHolder.getPosition(objectKey);
221221 key = objectKey;
222222 if (position != null)
223223 {
224224 // 色を設定する
225- final SeekBar borderColorProgess = (SeekBar) dialog.findViewById(R.id.borderColorSelectionBar);
226- borderColorProgess.setProgress(convertProgress(position.objectColor));
225+ final SeekBar borderColorProgess = dialog.findViewById(R.id.borderColorSelectionBar);
226+ borderColorProgess.setProgress(convertProgress(position.getObjectColor()));
227227
228- final CheckBox boldTextCheck = (CheckBox) dialog.findViewById(R.id.checkBoldText);
229- boldTextCheck.setChecked(position.strokeWidth == MeMoMaObjectHolder.STOROKE_BOLD_WIDTH);
228+ final CheckBox boldTextCheck = dialog.findViewById(R.id.checkBoldText);
229+ boldTextCheck.setChecked(position.getstrokeWidth() == MeMoMaObjectHolder.STOROKE_BOLD_WIDTH);
230230
231- final CheckBox fillObjectCheck = (CheckBox) dialog.findViewById(R.id.checkFillObject);
232- fillObjectCheck.setChecked(Paint.Style.valueOf(position.paintStyle) != Paint.Style.STROKE);
231+ final CheckBox fillObjectCheck = dialog.findViewById(R.id.checkFillObject);
232+ fillObjectCheck.setChecked(Paint.Style.valueOf(position.getPaintStyle()) != Paint.Style.STROKE);
233233
234234 // フォントサイズを設定する
235- textFontSize = position.fontSize / 2.0f;
235+ textFontSize = position.getFontSize() / 2.0f;
236236
237237 // 入力文字列を設定する
238- final EditText targetLabel = (EditText) dialog.findViewById(R.id.labelInputArea);
239- targetLabel.setText(position.label);
238+ final EditText targetLabel = dialog.findViewById(R.id.labelInputArea);
239+ targetLabel.setText(position.getLabel());
240240
241- final EditText targetDetail = (EditText) dialog.findViewById(R.id.descriptionInputArea);
242- targetDetail.setText(position.detail);
241+ final EditText targetDetail = dialog.findViewById(R.id.descriptionInputArea);
242+ targetDetail.setText(position.getDetail());
243243
244244 // 設定に記録されているデータを画面に反映させる
245245 SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
246246 String userCheckboxTitle = preferences.getString("userCheckboxString", "");
247247
248248 // 描画スタイルを設定する
249- currentObjectDrawStyle = position.drawStyle;
249+ currentObjectDrawStyle = position.getDrawStyle();
250250 updateObjectDrawStyleImageButton(currentObjectDrawStyle);
251251
252252 // 背景色を設定する
@@ -261,10 +261,10 @@ public class ObjectDataInputDialog implements SeekBar.OnSeekBarChangeListener, C
261261 }
262262 setTextColorSample(borderColorProgess.getProgress(), textFontSize, fillObjectView.isChecked());
263263
264- final CheckBox userCheckbox = (CheckBox) dialog.findViewById(R.id.checkUserCheckbox);
264+ final CheckBox userCheckbox = dialog.findViewById(R.id.checkUserCheckbox);
265265 userCheckbox.setEnabled(true);
266266 userCheckbox.setText(userCheckboxTitle);
267- userCheckbox.setChecked(position.userChecked);
267+ userCheckbox.setChecked(position.getUserChecked());
268268 }
269269 }
270270
@@ -272,23 +272,24 @@ public class ObjectDataInputDialog implements SeekBar.OnSeekBarChangeListener, C
272272 * オブジェクトにデータを設定する
273273 *
274274 */
275- public void setObjectData(String label, String detail, int progress, boolean boldText, boolean fillObject, boolean userCheck, int drawStyle)
275+ private void setObjectData(String label, String detail, int progress, boolean boldText, boolean fillObject, boolean userCheck, int drawStyle)
276276 {
277- MeMoMaObjectHolder.PositionObject positionObject = objectHolder.getPosition(key);
277+ PositionObject positionObject = objectHolder.getPosition(key);
278278 if (positionObject != null)
279279 {
280- positionObject.label = label;
281- positionObject.detail = detail;
280+ positionObject.setLabel(label);
281+ positionObject.setDetail(detail);
282282 int color = convertColor(progress);
283- positionObject.objectColor = color;
283+ positionObject.setObjectColor(color);
284284 color = (color ^ 0x00ffffff);
285- positionObject.fontSize = textFontSize * 2.0f;
286- positionObject.labelColor = color;
287- positionObject.strokeWidth = (boldText == true) ? MeMoMaObjectHolder.STOROKE_BOLD_WIDTH : MeMoMaObjectHolder.STOROKE_NORMAL_WIDTH;
288- positionObject.paintStyle = ((fillObject == true) ? Paint.Style.FILL : Paint.Style.STROKE).toString();
289- positionObject.userChecked = userCheck;
290-
291- if (positionObject.drawStyle != drawStyle)
285+ positionObject.setFontSize(textFontSize * 2.0f);
286+ positionObject.setLabelColor(color);
287+ positionObject.setStrokeWidth((boldText) ? MeMoMaObjectHolder.STOROKE_BOLD_WIDTH : MeMoMaObjectHolder.STOROKE_NORMAL_WIDTH);
288+ positionObject.setPaintStyle(((fillObject) ? Paint.Style.FILL : Paint.Style.STROKE).toString());
289+ positionObject.setUserChecked(userCheck);
290+
291+ int posDrawStyle = positionObject.getDrawStyle();
292+ if (posDrawStyle != drawStyle)
292293 {
293294 if ((drawStyle == MeMoMaObjectHolder.DRAWSTYLE_CIRCLE)||
294295 (drawStyle == MeMoMaObjectHolder. DRAWSTYLE_LEFT_ARROW)||
@@ -299,53 +300,54 @@ public class ObjectDataInputDialog implements SeekBar.OnSeekBarChangeListener, C
299300 // (長方形の形状から)正方形の形状にする場合...
300301 setRectToSquare(positionObject);
301302 }
302- else if ((positionObject.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_CIRCLE)||
303- (positionObject.drawStyle == MeMoMaObjectHolder. DRAWSTYLE_LEFT_ARROW)||
304- (positionObject.drawStyle == MeMoMaObjectHolder. DRAWSTYLE_DOWN_ARROW)||
305- (positionObject.drawStyle == MeMoMaObjectHolder. DRAWSTYLE_UP_ARROW)||
306- (positionObject.drawStyle == MeMoMaObjectHolder. DRAWSTYLE_RIGHT_ARROW))
303+ else if ((posDrawStyle == MeMoMaObjectHolder.DRAWSTYLE_CIRCLE)||
304+ (posDrawStyle == MeMoMaObjectHolder. DRAWSTYLE_LEFT_ARROW)||
305+ (posDrawStyle == MeMoMaObjectHolder. DRAWSTYLE_DOWN_ARROW)||
306+ (posDrawStyle == MeMoMaObjectHolder. DRAWSTYLE_UP_ARROW)||
307+ (posDrawStyle == MeMoMaObjectHolder. DRAWSTYLE_RIGHT_ARROW))
307308 {
308309 // 正方形の形状から、長方形の形状にする場合...
309310 setRectFromSquare(positionObject);
310311 }
311- positionObject.drawStyle = drawStyle;
312+ positionObject.setDrawStyle(drawStyle);
312313 }
313314 }
314- positionObject = null;
315315 }
316316
317317 /**
318318 * オブジェクトの領域を長方形から正方形にする
319319 */
320- private void setRectToSquare(MeMoMaObjectHolder.PositionObject positionObject)
320+ private void setRectToSquare(PositionObject positionObject)
321321 {
322- float bandWidth = ((positionObject.rect.right - positionObject.rect.left)) / 2.0f;
323- float center = positionObject.rect.centerY();
324-
325- positionObject.rect.top = center - bandWidth;
326- positionObject.rect.bottom = center + bandWidth;
322+ RectF posRect = positionObject.getRect();
323+ float bandWidth = ((posRect.right - posRect.left)) / 2.0f;
324+ float center = posRect.centerY();
325+
326+ positionObject.setRectTop(center - bandWidth);
327+ positionObject.setRectBottom(center + bandWidth);
327328 }
328329
329330 /**
330331 * オブジェクトの領域を正方形から長方形にする
331332 */
332- private void setRectFromSquare(MeMoMaObjectHolder.PositionObject positionObject)
333+ private void setRectFromSquare(PositionObject positionObject)
333334 {
334- float bandWidth = ((positionObject.rect.right - positionObject.rect.left) / 16.0f * 9.0f) / 2.0f;
335- float center = positionObject.rect.centerY();
336-
337- positionObject.rect.top = center - bandWidth;
338- positionObject.rect.bottom = center + bandWidth;
335+ RectF posRect = positionObject.getRect();
336+ float bandWidth = ((posRect.right - posRect.left) / 16.0f * 9.0f) / 2.0f;
337+ float center = posRect.centerY();
338+
339+ positionObject.setRectTop(center - bandWidth);
340+ positionObject.setRectBottom(center + bandWidth);
339341 }
340342
341343 private void setButtonBorder(int id, boolean isHighlight)
342344 {
343345 try
344346 {
345- ImageButton button = (ImageButton) dialogLayout.findViewById(id);
347+ ImageButton button = dialogLayout.findViewById(id);
346348 //GradientDrawable btnBackgroundShape = (GradientDrawable)button.getBackground();
347349 BitmapDrawable btnBackgroundShape = (BitmapDrawable)button.getBackground();
348- if (isHighlight == true)
350+ if (isHighlight)
349351 {
350352 // btnBackgroundShape.setColorFilter(Color.rgb(51, 181, 229), Mode.LIGHTEN);
351353 btnBackgroundShape.setColorFilter(Color.BLUE, Mode.LIGHTEN);
@@ -366,7 +368,7 @@ public class ObjectDataInputDialog implements SeekBar.OnSeekBarChangeListener, C
366368 /**
367369 * イメージボタンの選択状態を更新する
368370 *
369- * @param drawStyle
371+ *
370372 */
371373 private void updateObjectDrawStyleImageButton(int drawStyle)
372374 {
@@ -476,12 +478,11 @@ public class ObjectDataInputDialog implements SeekBar.OnSeekBarChangeListener, C
476478 /**
477479 * 0x00~0x3fの値(R, G, B, それぞれ2ビット)で色を変える
478480 *
479- * @param value
480- * @return
481+ *
481482 */
482483 private int convertColor(int value)
483484 {
484- int color = 0;
485+ int color;
485486 int r = ((value >> 4 ) & 0x03) * 85;
486487 int g = ((value >> 2) & 0x03) * 85;
487488 int b = (value & 0x03) * 85;
@@ -493,8 +494,7 @@ public class ObjectDataInputDialog implements SeekBar.OnSeekBarChangeListener, C
493494 /**
494495 * 色をプログレスバーの値に変換する
495496 *
496- * @param color
497- * @return
497+ *
498498 */
499499 private int convertProgress(int color)
500500 {
@@ -508,21 +508,19 @@ public class ObjectDataInputDialog implements SeekBar.OnSeekBarChangeListener, C
508508 /**
509509 * 背景色を設定する処理
510510 *
511- * @param progress
512- * @param fontSize
513- * @param value
511+ *
514512 */
515513 private void setTextColorSample(int progress, float fontSize, boolean value)
516514 {
517515 if (colorBorderAreaView != null)
518516 {
519517 int color = convertColor(progress);
520- int backColor = (value == true) ? color : backgroundColor;
518+ int backColor = (value) ? color : backgroundColor;
521519 colorBorderAreaView.setBackgroundColor(backColor);
522520
523521 backgroundShape.setStroke(2, color);
524522
525- if (value == true)
523+ if (value)
526524 {
527525 // 塗りつぶし時には色を変える
528526 color = (color ^ 0x00ffffff);
@@ -572,7 +570,7 @@ public class ObjectDataInputDialog implements SeekBar.OnSeekBarChangeListener, C
572570
573571 public interface IResultReceiver
574572 {
575- public abstract void finishObjectInput();
576- public abstract void cancelObjectInput();
573+ void finishObjectInput();
574+ void cancelObjectInput();
577575 }
578576 }
--- a/app/src/main/res/layout/extensionview.xml
+++ b/app/src/main/res/layout/extensionview.xml
@@ -54,7 +54,7 @@
5454 </ListView>
5555
5656 <!--
57-<jp.sourceforge.gokigen.memoma.GokigenSurfaceView
57+<jp.sourceforge.gokigen.memoma.drawers.GokigenSurfaceView
5858 android:id="@+id/ExtensionView"
5959 android:layout_width="fill_parent"
6060 android:layout_height="wrap_content"
--- a/app/src/main/res/layout/main.xml
+++ b/app/src/main/res/layout/main.xml
@@ -179,7 +179,7 @@
179179 android:max="100"
180180 android:progress="50" />
181181
182- <jp.sourceforge.gokigen.memoma.GokigenSurfaceView
182+ <jp.sourceforge.gokigen.memoma.drawers.GokigenSurfaceView
183183 android:id="@+id/GraphicView"
184184 android:layout_width="fill_parent"
185185 android:layout_height="wrap_content"
--- a/app/src/main/res/values-ja/strings.xml
+++ b/app/src/main/res/values-ja/strings.xml
@@ -71,4 +71,5 @@
7171 <string name="labelLineThickness">太さ</string>
7272 <string name="labelLineShapeSelection">形状</string>
7373 <string name="Title_SelectLineShape">接続線の設定</string>
74+ <string name="undo_operation">1つ戻す</string>
7475 </resources>
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -71,4 +71,5 @@
7171 <string name="labelLineThickness">Line Thickness</string>
7272 <string name="labelLineShapeSelection">Line Shape</string>
7373 <string name="Title_SelectLineShape">Select a line style</string>
74+ <string name="undo_operation">Undo</string>
7475 </resources>
Afficher sur ancien navigateur de dépôt.