import android.view.MenuItem;
import android.view.Window;
-import jp.sourceforge.gokigen.memoma.fileio.MeMoMaDataInOutManager;
+import jp.sourceforge.gokigen.memoma.io.MeMoMaDataInOutManager;
import static android.os.Build.VERSION_CODES.KITKAT;
import jp.sourceforge.gokigen.memoma.dialogs.CreditDialog;
import jp.sourceforge.gokigen.memoma.dialogs.ItemSelectionDialog;
import jp.sourceforge.gokigen.memoma.dialogs.TextEditDialog;
+import jp.sourceforge.gokigen.memoma.drawers.GokigenSurfaceView;
import jp.sourceforge.gokigen.memoma.drawers.MeMoMaCanvasDrawer;
import jp.sourceforge.gokigen.memoma.extension.ExtensionActivity;
-import jp.sourceforge.gokigen.memoma.fileio.MeMoMaDataInOutManager;
+import jp.sourceforge.gokigen.memoma.holders.OperationHistoryHolder;
+import jp.sourceforge.gokigen.memoma.io.MeMoMaDataInOutManager;
import jp.sourceforge.gokigen.memoma.holders.LineStyleHolder;
import jp.sourceforge.gokigen.memoma.holders.MeMoMaConnectLineHolder;
import jp.sourceforge.gokigen.memoma.holders.MeMoMaObjectHolder;
*/
public class MeMoMaListener implements OnClickListener, OnTouchListener, OnKeyListener, IObjectSelectionReceiver, ConfirmationDialog.IResultReceiver, ObjectDataInputDialog.IResultReceiver, ItemSelectionDialog.ISelectionItemReceiver, TextEditDialog.ITextEditResultReceiver, ObjectAligner.IAlignCallback, SelectLineShapeDialog.IResultReceiver
{
- public static final int MENU_ID_PREFERENCES = (Menu.FIRST + 1); // 設定画面の表示
- public static final int MENU_ID_ABOUT_GOKIGEN = (Menu.FIRST + 2); // アプリケーションの情報表示
- public static final int MENU_ID_NEW = (Menu.FIRST + 3); // 新規作成
- public static final int MENU_ID_EXTEND= (Menu.FIRST + 4); // 拡張機能
- public static final int MENU_ID_ALIGN = (Menu.FIRST + 5); // オブジェクトの整列
- public static final int MENU_ID_INSERT_PICTURE = (Menu.FIRST + 6); // 画像の指定
- public static final int MENU_ID_OPERATION = (Menu.FIRST + 7); // 操作コマンド
- public static final int MENU_ID_RENAME = (Menu.FIRST + 8); // リネーム
- public static final int MENU_ID_CAPTURE = (Menu.FIRST + 9); // 画像のキャプチャ
- public static final int MENU_ID_SHARE = (Menu.FIRST + 10); // 画像の共有
-
-
- private AppCompatActivity parent = null; // 親分
- private TextEditDialog editTextDialog = null; // テキスト編集用ダイアログ
- private MeMoMaCanvasDrawer objectDrawer = null; // 画像の表示
- private MeMoMaObjectHolder objectHolder = null; // オブジェクトの保持クラス
- private MeMoMaConnectLineHolder lineHolder =null; // オブジェクト間の接続状態保持クラス
- //private SelectFeatureListener featureListener = null; // 機能選択用のリスナ
-
- private MeMoMaDataInOutManager dataInOutManager = null;
-
- private OperationModeHolder drawModeHolder = null;
- private LineStyleHolder lineStyleHolder = null;
-
- private ConfirmationDialog confirmationDialog = null;
-
- private ObjectDataInputDialog objectDataInputDialog = null;
-
- private SelectLineShapeDialog lineSelectionDialog = null;
-
- private ItemSelectionDialog itemSelectionDialog = null;
- private ObjectOperationCommandHolder commandHolder = null;
-
- private boolean isEditing = false;
- private Integer selectedObjectKey = 0;
- private Integer objectKeyToDelete = 0;
- private Integer selectedContextKey = 0;
-
- /**
- * コンストラクタ
- * @param argument
- */
- public MeMoMaListener(AppCompatActivity argument, MeMoMaDataInOutManager inoutManager)
- {
- parent = argument;
- dataInOutManager = inoutManager;
- lineHolder = new MeMoMaConnectLineHolder();
- objectHolder = new MeMoMaObjectHolder(argument, lineHolder);
- editTextDialog = new TextEditDialog(parent, R.drawable.icon);
- //lineHolder = new MeMoMaConnectLineHolder();
- //featureListener = new SelectFeatureListener(parent);
- drawModeHolder = new OperationModeHolder(parent);
-
- lineStyleHolder = new LineStyleHolder(parent);
- lineStyleHolder.prepare();
-
- // 新規作成時の確認ダイアログについて
- confirmationDialog = new ConfirmationDialog(argument);
- confirmationDialog.prepare(this, android.R.drawable.ic_dialog_alert, parent.getString(R.string.createnew_title), parent.getString(R.string.createnew_message));
-
- // オブジェクトのデータ入力ダイアログを生成
- objectDataInputDialog = new ObjectDataInputDialog(argument, objectHolder);
- objectDataInputDialog.setResultReceiver(this);
-
- // 接続線の形状と太さを選択するダイアログを生成
- lineSelectionDialog = new SelectLineShapeDialog(argument, lineStyleHolder);
- lineSelectionDialog.setResultReceiver(this);
-
- // アイテム選択ダイアログを生成
- commandHolder = new ObjectOperationCommandHolder(argument);
- itemSelectionDialog = new ItemSelectionDialog(argument);
- itemSelectionDialog.prepare(this, commandHolder, parent.getString(R.string.object_operation));
-
- // 描画クラスの生成
- objectDrawer = new MeMoMaCanvasDrawer(argument, objectHolder, lineStyleHolder, this);
-
- SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
- String colorString = preferences.getString("backgroundColor", "0xff004000");
- objectDrawer.setBackgroundColor(colorString);
-
- }
-
- /**
- * がっつりこのクラスにイベントリスナを接続する
- *
- */
- public void prepareListener()
- {
- SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
-
- // 表示位置リセットボタン
- final ImageButton homeButton = (ImageButton) parent.findViewById(R.id.HomeButton);
- homeButton.setOnClickListener(this);
-
- // 拡張ボタン
- final ImageButton expandButton = (ImageButton) parent.findViewById(R.id.ExpandButton);
- expandButton.setOnClickListener(this);
-
- // 作成ボタン
- final ImageButton createObjectButton = (ImageButton) parent.findViewById(R.id.CreateObjectButton);
- createObjectButton.setOnClickListener(this);
-
- final ImageButton deleteObjectButton = (ImageButton) parent.findViewById(R.id.DeleteObjectButton);
- deleteObjectButton.setOnClickListener(this);
-
- // 線の形状切り替えボタン
- final ImageButton lineStyleButton = (ImageButton) parent.findViewById(R.id.LineStyleButton);
- lineStyleButton.setOnClickListener(this);
-
- // データ保存ボタン
- final ImageButton saveButton = (ImageButton) parent.findViewById(R.id.SaveButton);
- saveButton.setOnClickListener(this);
-
- // 画面描画クラス
- final GokigenSurfaceView surfaceView = (GokigenSurfaceView) parent.findViewById(R.id.GraphicView);
- surfaceView.setOnTouchListener(this);
-
- // スライドバーが動かされた時の処理
- final SeekBar seekbar = (SeekBar) parent.findViewById(R.id.ZoomInOut);
- seekbar.setOnSeekBarChangeListener(objectDrawer);
- int progress = preferences.getInt("zoomProgress", 50);
- seekbar.setProgress(progress);
-
- // 「実行中」の表示を消す
- parent.setProgressBarIndeterminateVisibility(false);
-
- //// 起動時にデータを読み出す
- prepareMeMoMaInfo();
- }
-
- /**
- * 終了準備
- */
- public void finishListener()
- {
- // 終了時に状態を保存する
- saveData(true);
- }
-
- /**
- * スタート準備
- */
- public void prepareToStart()
- {
- // 設定に記録されているデータを画面に反映させる
- SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
-
- // 描画オブジェクトの形状を設定する
- //int objectStyle = Integer.parseInt(preferences.getString("drawStyle", "0"));
-
- // ラインの形状を取得し、設定する
- setLineStyle();
-
- // 操作モードを画面に反映させる
- updateButtons(Integer.parseInt(preferences.getString("operationMode", "0")));
-
- // 条件に合わせて、描画クラスを変更する
- final GokigenSurfaceView surfaceView = (GokigenSurfaceView) parent.findViewById(R.id.GraphicView);
- surfaceView.setCanvasDrawer(objectDrawer);
-
- // 背景画像(の名前)を設定しておく
- String backgroundString = preferences.getString("backgroundUri", "");
- objectDrawer.setBackgroundUri(backgroundString);
- }
-
- /**
- * 終了準備
- */
- public void shutdown()
- {
-
- }
-
- /**
- * 他画面から戻ってきたとき...
- *
- */
- public void onActivityResult(int requestCode, int resultCode, Intent data)
- {
- if ((requestCode == MENU_ID_INSERT_PICTURE)&&(resultCode == Activity.RESULT_OK))
- {
- try
- {
- // 取得したuri を preferenceに記録する
- SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
- Uri backgroundUri = data.getData();
- if (backgroundUri != null)
- {
- try
- {
- if (Build.VERSION.SDK_INT >= 19) {
- final int takeFlags = data.getFlags() & (Intent.FLAG_GRANT_READ_URI_PERMISSION);
- parent.getContentResolver().takePersistableUriPermission(backgroundUri, takeFlags);
- }
- SharedPreferences.Editor editor = preferences.edit();
- editor.putString("backgroundUri", backgroundUri.toString());
- editor.apply();
- }
- catch (Exception e)
- {
- e.printStackTrace();
+ private static final int MENU_ID_PREFERENCES = (Menu.FIRST + 1); // 設定画面の表示
+ private static final int MENU_ID_ABOUT_GOKIGEN = (Menu.FIRST + 2); // アプリケーションの情報表示
+ private static final int MENU_ID_NEW = (Menu.FIRST + 3); // 新規作成
+ private static final int MENU_ID_EXTEND= (Menu.FIRST + 4); // 拡張機能
+ private static final int MENU_ID_ALIGN = (Menu.FIRST + 5); // オブジェクトの整列
+ private static final int MENU_ID_INSERT_PICTURE = (Menu.FIRST + 6); // 画像の指定
+ private static final int MENU_ID_OPERATION = (Menu.FIRST + 7); // 操作コマンド
+ private static final int MENU_ID_RENAME = (Menu.FIRST + 8); // リネーム
+ private static final int MENU_ID_CAPTURE = (Menu.FIRST + 9); // 画像のキャプチャ
+ private static final int MENU_ID_SHARE = (Menu.FIRST + 10); // 画像の共有
+ private static final int MENU_ID_UNDO = (Menu.FIRST + 11); // 処理の UNDO
+
+ private AppCompatActivity parent; // 親分
+ private TextEditDialog editTextDialog; // テキスト編集用ダイアログ
+ private MeMoMaCanvasDrawer objectDrawer; // 画像の表示
+ private MeMoMaObjectHolder objectHolder; // オブジェクトの保持クラス
+ private MeMoMaConnectLineHolder lineHolder; // オブジェクト間の接続状態保持クラス
+ private OperationHistoryHolder historyHolder; // 操作履歴保持クラス
+ //private SelectFeatureListener featureListener = null; // 機能選択用のリスナ
+
+ private MeMoMaDataInOutManager dataInOutManager;
+
+ private OperationModeHolder drawModeHolder;
+ private LineStyleHolder lineStyleHolder;
+
+ private ConfirmationDialog confirmationDialog;
+
+ private ObjectDataInputDialog objectDataInputDialog;
+
+ private SelectLineShapeDialog lineSelectionDialog;
+
+ private ItemSelectionDialog itemSelectionDialog;
+ private ObjectOperationCommandHolder commandHolder;
+
+ private boolean isEditing = false;
+ private Integer selectedObjectKey = 0;
+ private Integer objectKeyToDelete = 0;
+ private Integer selectedContextKey = 0;
+
+ /**
+ * コンストラクタ
+ *
+ */
+ MeMoMaListener(AppCompatActivity argument, MeMoMaDataInOutManager inoutManager)
+ {
+ parent = argument;
+ dataInOutManager = inoutManager;
+ historyHolder = new OperationHistoryHolder();
+ lineHolder = new MeMoMaConnectLineHolder(historyHolder);
+ objectHolder = new MeMoMaObjectHolder(argument, lineHolder, historyHolder);
+ editTextDialog = new TextEditDialog(parent, R.drawable.icon);
+ //lineHolder = new MeMoMaConnectLineHolder();
+ //featureListener = new SelectFeatureListener(parent);
+ drawModeHolder = new OperationModeHolder(parent);
+
+ lineStyleHolder = new LineStyleHolder(parent);
+ lineStyleHolder.prepare();
+
+ // 新規作成時の確認ダイアログについて
+ confirmationDialog = new ConfirmationDialog(argument);
+ confirmationDialog.prepare(this, android.R.drawable.ic_dialog_alert, parent.getString(R.string.createnew_title), parent.getString(R.string.createnew_message));
+
+ // オブジェクトのデータ入力ダイアログを生成
+ objectDataInputDialog = new ObjectDataInputDialog(argument, objectHolder);
+ objectDataInputDialog.setResultReceiver(this);
+
+ // 接続線の形状と太さを選択するダイアログを生成
+ lineSelectionDialog = new SelectLineShapeDialog(argument, lineStyleHolder);
+ lineSelectionDialog.setResultReceiver(this);
+
+ // アイテム選択ダイアログを生成
+ commandHolder = new ObjectOperationCommandHolder(argument);
+ itemSelectionDialog = new ItemSelectionDialog(argument);
+ itemSelectionDialog.prepare(this, commandHolder, parent.getString(R.string.object_operation));
+
+ // 描画クラスの生成
+ objectDrawer = new MeMoMaCanvasDrawer(argument, objectHolder, lineStyleHolder, this);
+
+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
+ String colorString = preferences.getString("backgroundColor", "0xff004000");
+ objectDrawer.setBackgroundColor(colorString);
+
+ }
+
+ /**
+ * がっつりこのクラスにイベントリスナを接続する
+ *
+ */
+ public void prepareListener()
+ {
+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
+
+ // 表示位置リセットボタン
+ final ImageButton homeButton = parent.findViewById(R.id.HomeButton);
+ homeButton.setOnClickListener(this);
+
+ // 拡張ボタン
+ final ImageButton expandButton = parent.findViewById(R.id.ExpandButton);
+ expandButton.setOnClickListener(this);
+
+ // 作成ボタン
+ final ImageButton createObjectButton = parent.findViewById(R.id.CreateObjectButton);
+ createObjectButton.setOnClickListener(this);
+
+ final ImageButton deleteObjectButton = parent.findViewById(R.id.DeleteObjectButton);
+ deleteObjectButton.setOnClickListener(this);
+
+ // 線の形状切り替えボタン
+ final ImageButton lineStyleButton = parent.findViewById(R.id.LineStyleButton);
+ lineStyleButton.setOnClickListener(this);
+
+ // データ保存ボタン
+ final ImageButton saveButton = parent.findViewById(R.id.SaveButton);
+ saveButton.setOnClickListener(this);
+
+ // 画面描画クラス
+ final GokigenSurfaceView surfaceView = parent.findViewById(R.id.GraphicView);
+ surfaceView.setOnTouchListener(this);
+
+ // スライドバーが動かされた時の処理
+ final SeekBar seekbar =parent.findViewById(R.id.ZoomInOut);
+ seekbar.setOnSeekBarChangeListener(objectDrawer);
+ int progress = preferences.getInt("zoomProgress", 50);
+ seekbar.setProgress(progress);
+
+ // 「実行中」の表示を消す
+ parent.setProgressBarIndeterminateVisibility(false);
+
+ //// 起動時にデータを読み出す
+ prepareMeMoMaInfo();
+ }
+
+ /**
+ * 終了準備
+ */
+ public void finishListener()
+ {
+ // 終了時に状態を保存する
+ saveData(true);
+ }
+
+ /**
+ * スタート準備
+ */
+ public void prepareToStart()
+ {
+ // 設定に記録されているデータを画面に反映させる
+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
+
+ // 描画オブジェクトの形状を設定する
+ //int objectStyle = Integer.parseInt(preferences.getString("drawStyle", "0"));
+
+ // ラインの形状を取得し、設定する
+ setLineStyle();
+
+ // 操作モードを画面に反映させる
+ updateButtons(Integer.parseInt(preferences.getString("operationMode", "0")));
+
+ // 条件に合わせて、描画クラスを変更する
+ final GokigenSurfaceView surfaceView = parent.findViewById(R.id.GraphicView);
+ surfaceView.setCanvasDrawer(objectDrawer);
+
+ // 背景画像(の名前)を設定しておく
+ String backgroundString = preferences.getString("backgroundUri", "");
+ objectDrawer.setBackgroundUri(backgroundString);
+ }
+
+ /**
+ * 終了準備
+ */
+ public void shutdown()
+ {
+
+ }
+
+ /**
+ * 他画面から戻ってきたとき...
+ *
+ */
+ public void onActivityResult(int requestCode, int resultCode, Intent data)
+ {
+ if ((requestCode == MENU_ID_INSERT_PICTURE)&&(resultCode == Activity.RESULT_OK))
+ {
+ try
+ {
+ // 取得したuri を preferenceに記録する
+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
+ Uri backgroundUri = data.getData();
+ if (backgroundUri != null)
+ {
+ try
+ {
+ if (Build.VERSION.SDK_INT >= 19) {
+ final int takeFlags = data.getFlags() & (Intent.FLAG_GRANT_READ_URI_PERMISSION);
+ parent.getContentResolver().takePersistableUriPermission(backgroundUri, takeFlags);
}
- // 背景画像イメージの更新処理
- updateBackgroundImage(backgroundUri.toString());
- }
- System.gc();
- }
- catch (Exception ex)
- {
- Log.v(Main.APP_IDENTIFIER, "Ex:" + ex.toString() + " " + ex.getMessage());
- }
- return;
- }
- else if (requestCode == MENU_ID_PREFERENCES)
+ SharedPreferences.Editor editor = preferences.edit();
+ editor.putString("backgroundUri", backgroundUri.toString());
+ editor.apply();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ // 背景画像イメージの更新処理
+ updateBackgroundImage(backgroundUri.toString());
+ }
+ System.gc();
+ }
+ catch (Exception ex)
{
- // 背景色、背景画像の設定を行う。
- SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
- String colorString = preferences.getString("backgroundColor", "0xff004000");
- objectDrawer.setBackgroundColor(colorString);
+ Log.v(Main.APP_IDENTIFIER, "Ex:" + ex.toString() + " " + ex.getMessage());
+ }
+ return;
+ }
+ else if (requestCode == MENU_ID_PREFERENCES)
+ {
+ // 背景色、背景画像の設定を行う。
+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
+ String colorString = preferences.getString("backgroundColor", "0xff004000");
+ objectDrawer.setBackgroundColor(colorString);
- // 背景画像イメージの更新処理
- String backgroundString = preferences.getString("backgroundUri", "");
- updateBackgroundImage(backgroundString);
+ // 背景画像イメージの更新処理
+ String backgroundString = preferences.getString("backgroundUri", "");
+ updateBackgroundImage(backgroundString);
- Log.v(Main.APP_IDENTIFIER, "RETURENED PREFERENCES " + backgroundString);
+ Log.v(Main.APP_IDENTIFIER, "RETURENED PREFERENCES " + backgroundString);
+
+ }
+ else if (requestCode == MENU_ID_EXTEND)
+ {
+ // その他...今開いているファイルを読みなおす
+ dataInOutManager.loadFile((String) parent.getTitle());
+ }
+ else
+ {
+ // 画面表示の準備を実行...
+ //prepareToStart();
+ return;
+ }
+ // 画面の再描画を指示する
+ redrawSurfaceview();
+ }
+
+ /**
+ * 背景画像イメージの更新処理
+ *
+ */
+ private void updateBackgroundImage(String uri)
+ {
+ // 背景画像イメージの更新処理
+ GokigenSurfaceView graphView = parent.findViewById(R.id.GraphicView);
+
+ // ビットマップを設定する
+ objectDrawer.updateBackgroundBitmap(uri, graphView.getWidth(), graphView.getHeight());
+
+ // 画面の再描画指示
+ graphView.doDraw();
+ }
+
+
+ /**
+ * クリックされたときの処理
+ */
+ public void onClick(View v)
+ {
+ int id = v.getId();
+
+ //Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::onClick() " + id);
+ if (id == R.id.MeMoMaInfo)
+ {
+ // テキスト編集ダイアログを表示する
+ showInfoMessageEditDialog();
+ }
+ else if (id == R.id.LineStyleButton)
+ {
+ // ライン形状を変えるダイアログで変更するように変更する
+ selectLineShapeDialog();
+ }
+ else if (id == R.id.ExpandButton)
+ {
+ // 拡張メニューを呼び出す
+ callExtendMenu();
+ }
+ else if ((id == R.id.DeleteObjectButton)||(id == R.id.CreateObjectButton))
+ {
+ // 削除ボタン or 作成ボタンが押された時の処理
+ updateButtons(drawModeHolder.updateOperationMode(id));
+ }
+ else if (id == R.id.HomeButton)
+ {
+ // 表示位置をリセットする
+ // 表示倍率と並行移動についてリセットする
+ objectDrawer.resetScaleAndLocation((SeekBar) parent.findViewById(R.id.ZoomInOut));
- }
- else if (requestCode == MENU_ID_EXTEND)
- {
- // その他...今開いているファイルを読みなおす
- dataInOutManager.loadFile((String) parent.getTitle());
- }
- else
- {
- // 画面表示の準備を実行...
- //prepareToStart();
- return;
- }
// 画面の再描画を指示する
- redrawSurfaceview();
- }
-
- /**
- * 背景画像イメージの更新処理
- *
- */
- private void updateBackgroundImage(String uri)
- {
- // 背景画像イメージの更新処理
- GokigenSurfaceView graphView = (GokigenSurfaceView) parent.findViewById(R.id.GraphicView);
-
- // ビットマップを設定する
- objectDrawer.updateBackgroundBitmap(uri, graphView.getWidth(), graphView.getHeight());
-
- // 画面の再描画指示
- graphView.doDraw();
- }
-
-
- /**
- * クリックされたときの処理
- */
- public void onClick(View v)
- {
- int id = v.getId();
-
- //Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::onClick() " + id);
- if (id == R.id.MeMoMaInfo)
- {
- // テキスト編集ダイアログを表示する
- showInfoMessageEditDialog();
- }
- else if (id == R.id.LineStyleButton)
- {
- // ライン形状を変えるダイアログで変更するように変更する
- selectLineShapeDialog();
- }
- else if (id == R.id.ExpandButton)
- {
- // 拡張メニューを呼び出す
- callExtendMenu();
- }
- else if ((id == R.id.DeleteObjectButton)||(id == R.id.CreateObjectButton))
- {
- // 削除ボタン or 作成ボタンが押された時の処理
- updateButtons(drawModeHolder.updateOperationMode(id));
- }
- else if (id == R.id.HomeButton)
- {
- /** 表示位置をリセットする **/
- // 表示倍率と並行移動についてリセットする
- objectDrawer.resetScaleAndLocation((SeekBar) parent.findViewById(R.id.ZoomInOut));
-
- // 画面の再描画を指示する
- redrawSurfaceview();
- }
- else if (id == R.id.SaveButton)
- {
- // データ保存が指示された!
- saveData(true);
- }
- }
-
- /**
- * 触られたときの処理
- *
- */
- public boolean onTouch(View v, MotionEvent event)
- {
- int id = v.getId();
- // int action = event.getAction();
-
- //Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::onTouch() " + id);
-
- if (id == R.id.GraphicView)
- {
- // 画面をタッチした!
- ((GokigenSurfaceView) v).onTouchEvent(event);
- return (true);
- }
- return (false);
- }
-
- /**
- * キーを押したときの操作
- */
- public boolean onKey(View v, int keyCode, KeyEvent event)
- {
- int action = event.getAction();
- if ((action == KeyEvent.ACTION_DOWN)&&(keyCode == KeyEvent.KEYCODE_DPAD_CENTER))
- {
- //
- }
-
- Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::onKey() ");
- return (false);
- }
-
- /**
- * メニューへのアイテム追加
- * @param menu
- * @return
- */
- public Menu onCreateOptionsMenu(Menu menu)
- {
- // 新規作成
- MenuItem menuItem = menu.add(Menu.NONE, MENU_ID_NEW, Menu.NONE, parent.getString(R.string.createnew));
- menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); /* for Android 3.1 */
- menuItem.setIcon(android.R.drawable.ic_menu_add); // 丸プラス
-
- // 画像の共有
- menuItem = menu.add(Menu.NONE, MENU_ID_SHARE, Menu.NONE, parent.getString(R.string.shareContent));
- menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); /* for Android 3.1 */
- menuItem.setIcon(android.R.drawable.ic_menu_share);
-
- // 画像のキャプチャ
- menuItem = menu.add(Menu.NONE, MENU_ID_CAPTURE, Menu.NONE, parent.getString(R.string.capture_data));
- menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); /* for Android 3.1 */
- menuItem.setIcon(android.R.drawable.ic_menu_crop); // オブジェクトのキャプチャ
-
- // オブジェクトの整列
- menuItem = menu.add(Menu.NONE, MENU_ID_ALIGN, Menu.NONE, parent.getString(R.string.align_data));
- menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); /* for Android 3.1 */
- menuItem.setIcon(android.R.drawable.ic_menu_rotate); // オブジェクトの整列
-
- // タイトルの変更
- menuItem = menu.add(Menu.NONE, MENU_ID_RENAME, Menu.NONE, parent.getString(R.string.rename_title));
- menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); /* for Android 3.1 */
- menuItem.setIcon(android.R.drawable.ic_menu_edit); // タイトルの変更
-
- // 壁紙の選択
- menuItem = menu.add(Menu.NONE, MENU_ID_INSERT_PICTURE, Menu.NONE, parent.getString(R.string.background_data));
- menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); /* for Android 3.1 */
- menuItem.setIcon(android.R.drawable.ic_menu_gallery); // 壁紙の選択
-
- // 拡張メニュー
- menuItem = menu.add(Menu.NONE, MENU_ID_EXTEND, Menu.NONE, parent.getString(R.string.extend_menu));
- menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); /* for Android 3.1 */
- menuItem.setIcon(android.R.drawable.ic_menu_share); // 拡張メニュー...
-
- // 設定
- menuItem = menu.add(Menu.NONE, MENU_ID_PREFERENCES, Menu.NONE, parent.getString(R.string.preference_name));
- menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); /* for Android 3.1 */
- menuItem.setIcon(android.R.drawable.ic_menu_preferences);
-
- // クレジット情報の表示
- menuItem = menu.add(Menu.NONE, MENU_ID_ABOUT_GOKIGEN, Menu.NONE, parent.getString(R.string.about_gokigen));
- menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); /* for Android 3.1 */
- menuItem.setIcon(android.R.drawable.ic_menu_info_details);
-
- return (menu);
- }
-
- /**
- * メニュー表示前の処理
- * @param menu
- * @return
- */
- public void onPrepareOptionsMenu(Menu menu)
- {
- menu.findItem(MENU_ID_NEW).setVisible(true);
- menu.findItem(MENU_ID_SHARE).setVisible(true);
- menu.findItem(MENU_ID_CAPTURE).setVisible(true);
- menu.findItem(MENU_ID_ALIGN).setVisible(true);
- menu.findItem(MENU_ID_RENAME).setVisible(true);
- menu.findItem(MENU_ID_INSERT_PICTURE).setVisible(true);
- menu.findItem(MENU_ID_EXTEND).setVisible(true);
- menu.findItem(MENU_ID_PREFERENCES).setVisible(true);
- menu.findItem(MENU_ID_ABOUT_GOKIGEN).setVisible(true);
- return;
- }
-
- /**
- * メニューのアイテムが選択されたときの処理
- * @param item
- * @return
- */
- public boolean onOptionsItemSelected(MenuItem item)
- {
- boolean result = false;
- switch (item.getItemId())
- {
- case MENU_ID_PREFERENCES:
- showPreference();
- result = true;
- break;
-
- case MENU_ID_ABOUT_GOKIGEN:
- showAboutGokigen();
- result = true;
- break;
-
- case MENU_ID_NEW:
- createNewScreen();
- result = true;
- break;
-
- case MENU_ID_EXTEND:
- // 拡張メニューを呼び出す
- callExtendMenu();
- result = true;
- break;
-
- case MENU_ID_ALIGN:
+ redrawSurfaceview();
+ }
+ else if (id == R.id.SaveButton)
+ {
+ // データ保存が指示された!
+ saveData(true);
+ }
+ }
+
+ /**
+ * 触られたときの処理
+ *
+ */
+ public boolean onTouch(View v, MotionEvent event)
+ {
+ int id = v.getId();
+ // int action = event.getAction();
+
+ //Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::onTouch() " + id);
+
+ if (id == R.id.GraphicView)
+ {
+ // 画面をタッチした!
+ v.onTouchEvent(event);
+ return (true);
+ }
+ return (false);
+ }
+
+ /**
+ * キーを押したときの操作
+ */
+ public boolean onKey(View v, int keyCode, KeyEvent event)
+ {
+ int action = event.getAction();
+ if ((action == KeyEvent.ACTION_DOWN)&&(keyCode == KeyEvent.KEYCODE_DPAD_CENTER))
+ {
+ //
+ Log.v(Main.APP_IDENTIFIER, "KEY ENTER");
+ }
+
+ Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::onKey() ");
+ return (false);
+ }
+
+ /**
+ * メニューへのアイテム追加
+ *
+ */
+ public Menu onCreateOptionsMenu(Menu menu)
+ {
+ // 新規作成
+ MenuItem menuItem = menu.add(Menu.NONE, MENU_ID_NEW, Menu.NONE, parent.getString(R.string.createnew));
+ menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); /* for Android 3.1 */
+ menuItem.setIcon(android.R.drawable.ic_menu_add); // 丸プラス
+
+ // 画像の共有
+ menuItem = menu.add(Menu.NONE, MENU_ID_SHARE, Menu.NONE, parent.getString(R.string.shareContent));
+ menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); /* for Android 3.1 */
+ menuItem.setIcon(android.R.drawable.ic_menu_share);
+
+ // 画像のキャプチャ
+ menuItem = menu.add(Menu.NONE, MENU_ID_CAPTURE, Menu.NONE, parent.getString(R.string.capture_data));
+ menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); /* for Android 3.1 */
+ menuItem.setIcon(android.R.drawable.ic_menu_crop); // オブジェクトのキャプチャ
+
+ // 処理のUNDO
+ menuItem = menu.add(Menu.NONE, MENU_ID_UNDO, Menu.NONE, parent.getString(R.string.undo_operation));
+ menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); /* for Android 3.1 */
+ menuItem.setIcon(android.R.drawable.ic_menu_revert);
+
+ // オブジェクトの整列
+ menuItem = menu.add(Menu.NONE, MENU_ID_ALIGN, Menu.NONE, parent.getString(R.string.align_data));
+ menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); /* for Android 3.1 */
+ menuItem.setIcon(android.R.drawable.ic_menu_rotate); // オブジェクトの整列
+
+ // タイトルの変更
+ menuItem = menu.add(Menu.NONE, MENU_ID_RENAME, Menu.NONE, parent.getString(R.string.rename_title));
+ menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); /* for Android 3.1 */
+ menuItem.setIcon(android.R.drawable.ic_menu_edit); // タイトルの変更
+
+ // 壁紙の選択
+ menuItem = menu.add(Menu.NONE, MENU_ID_INSERT_PICTURE, Menu.NONE, parent.getString(R.string.background_data));
+ menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); /* for Android 3.1 */
+ menuItem.setIcon(android.R.drawable.ic_menu_gallery); // 壁紙の選択
+
+ // 拡張メニュー
+ menuItem = menu.add(Menu.NONE, MENU_ID_EXTEND, Menu.NONE, parent.getString(R.string.extend_menu));
+ menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); /* for Android 3.1 */
+ menuItem.setIcon(android.R.drawable.ic_menu_share); // 拡張メニュー...
+
+ // 設定
+ menuItem = menu.add(Menu.NONE, MENU_ID_PREFERENCES, Menu.NONE, parent.getString(R.string.preference_name));
+ menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); /* for Android 3.1 */
+ menuItem.setIcon(android.R.drawable.ic_menu_preferences);
+
+ // クレジット情報の表示
+ menuItem = menu.add(Menu.NONE, MENU_ID_ABOUT_GOKIGEN, Menu.NONE, parent.getString(R.string.about_gokigen));
+ menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); /* for Android 3.1 */
+ menuItem.setIcon(android.R.drawable.ic_menu_info_details);
+
+ return (menu);
+ }
+
+ /**
+ * メニュー表示前の処理
+ *
+ *
+ */
+ public void onPrepareOptionsMenu(Menu menu)
+ {
+ menu.findItem(MENU_ID_NEW).setVisible(true);
+ menu.findItem(MENU_ID_UNDO).setVisible(false);
+ menu.findItem(MENU_ID_SHARE).setVisible(true);
+ menu.findItem(MENU_ID_CAPTURE).setVisible(true);
+ menu.findItem(MENU_ID_ALIGN).setVisible(true);
+ menu.findItem(MENU_ID_RENAME).setVisible(true);
+ menu.findItem(MENU_ID_INSERT_PICTURE).setVisible(true);
+ menu.findItem(MENU_ID_EXTEND).setVisible(true);
+ menu.findItem(MENU_ID_PREFERENCES).setVisible(true);
+ menu.findItem(MENU_ID_ABOUT_GOKIGEN).setVisible(true);
+ }
+
+ /**
+ * メニューのアイテムが選択されたときの処理
+ *
+ *
+ */
+ public boolean onOptionsItemSelected(MenuItem item)
+ {
+ boolean result;
+ switch (item.getItemId())
+ {
+ case MENU_ID_PREFERENCES:
+ showPreference();
+ result = true;
+ break;
+
+ case MENU_ID_ABOUT_GOKIGEN:
+ showAboutGokigen();
+ result = true;
+ break;
+
+ case MENU_ID_NEW:
+ createNewScreen();
+ result = true;
+ break;
+
+ case MENU_ID_EXTEND:
+ // 拡張メニューを呼び出す
+ callExtendMenu();
+ result = true;
+ break;
+
+ case MENU_ID_ALIGN:
// オブジェクトの整列を行う
- alignData();
+ alignData();
result = true;
- break;
-
- case MENU_ID_RENAME:
- // タイトル名の変更 (テキスト編集ダイアログを表示する)
- showInfoMessageEditDialog();
- result = true;
- break;
-
- case MENU_ID_INSERT_PICTURE:
- // 背景画像の設定を行う
- insertPicture();
- result = true;
- break;
-
- case MENU_ID_CAPTURE:
- // 画面キャプチャを指示された場合...
- doCapture(false);
- result = true;
- break;
-
- case MENU_ID_SHARE:
- // 画面キャプチャ&共有を指示された場合...
- doCapture(true);
- result = true;
- break;
-
- case android.R.id.home:
- // アイコンが押された時の処理...
- // テキスト編集ダイアログを表示する
- showInfoMessageEditDialog();
- result = true;
- break;
-
- default:
- result = false;
- break;
- }
- return (result);
- }
-
- /**
- * 画像ファイルの挿入 (データファイルの更新)
- *
- */
- private void insertPicture()
- {
- Intent intent;
- if (Build.VERSION.SDK_INT >= 19) {
- intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
- intent.addCategory(Intent.CATEGORY_OPENABLE);
- intent.setType("image/*");
- //intent.setAction(Intent.ACTION_GET_CONTENT);
- } else {
- intent = new Intent();
- intent.setType("image/*");
- intent.setAction(Intent.ACTION_GET_CONTENT);
- }
- parent.startActivityForResult(intent, MENU_ID_INSERT_PICTURE);
- }
-
- /**
- * 画面キャプチャの実施
- *
- *
- */
- private void doCapture(boolean isShare)
- {
- // 画面のスクリーンショットをとる処理を実行する
- dataInOutManager.doScreenCapture((String) parent.getTitle(), objectHolder, objectDrawer, isShare);
-
- // 画面を再描画する
- redrawSurfaceview();
- }
-
- /**
- * アプリの情報を表示する
- *
- */
- private void showAboutGokigen()
- {
- // アプリの情報(クレジット)を表示する!
- parent.showDialog(R.id.info_about_gokigen);
- }
-
- /**
- * 拡張メニューを呼び出す
- *
- */
- private void callExtendMenu()
- {
- // 現在表示中のデータをファイルに保存する
- dataInOutManager.saveFile((String) parent.getTitle(), true);
-
- // 現在読み込んでいるファイルのファイル名を生成する
- String fullPath = dataInOutManager.getDataFileFullPath((String) parent.getTitle(), ".xml");
-
- // ここで拡張メニューを呼び出す
- // (渡すデータを作って Intentとする)
- Intent intent = new Intent();
-
- intent.setAction(ExtensionActivity.MEMOMA_EXTENSION_LAUNCH_ACTIVITY);
- intent.putExtra(ExtensionActivity.MEMOMA_EXTENSION_DATA_FULLPATH, fullPath);
- intent.putExtra(ExtensionActivity.MEMOMA_EXTENSION_DATA_TITLE, (String) parent.getTitle());
-
- // データ表示用Activityを起動する
- parent.startActivityForResult(intent, MENU_ID_EXTEND);
- }
-
- /**
- * データの読み込みを行う
- *
- */
- private void prepareMeMoMaInfo()
- {
- // 設定に記録されているデータを画面のタイトルに反映させる
- SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
- String memomaInfo = preferences.getString("MeMoMaInfo", parent.getString(R.string.app_name));
- parent.setTitle(memomaInfo);
-
- // アクションバーとファイル名の準備
- android.support.v7.app.ActionBar bar = parent.getSupportActionBar();
- if (bar != null)
- {
- dataInOutManager.prepare(objectHolder, bar, memomaInfo);
- }
-
- //dataInOutManager.loadFile((String) parent.getTitle());
- }
-
- /**
- * データの保存を行う
- *
- *
- * @param forceOverwrite trueの時は、ファイル名が確定していたときは(確認せずに)上書き保存を自動で行う。
- *
- */
- private void saveData(boolean forceOverwrite)
- {
- dataInOutManager.saveFile((String) parent.getTitle(), forceOverwrite);
- }
-
- /**
- * データの整列を行う
- *
- */
- private void alignData()
- {
- ObjectAligner aligner = new ObjectAligner(parent, this);
- aligner.execute(objectHolder);
- }
-
- /**
- * メッセージ編集ダイアログを表示する
- *
- */
- private void showInfoMessageEditDialog()
- {
- parent.showDialog(R.id.editTextArea);
- }
-
- /**
- * 新規作成が指示されたとき...全部クリアして作りなおして良いか確認する。
- *
- */
- private void createNewScreen()
- {
- parent.showDialog(R.id.confirmation);
- }
-
- /**
- * 接続線の設定ダイアログを表示する
- */
- private void selectLineShapeDialog()
- {
- // 接続線の設定ダイアログを表示する...
- parent.showDialog(R.id.selectline_dialog);
- }
-
- /**
- * メッセージ編集ダイアログの表示を準備する
- *
- */
- private void prepareInfoMessageEditDialog(Dialog dialog)
- {
- String message = (String) parent.getTitle();
- editTextDialog.prepare(dialog, this, parent.getString(R.string.dataTitle), message, true);
- }
-
- /**
- * メッセージ編集ダイアログの表示を準備する
- *
- */
- private void prepareConfirmationDialog(Dialog dialog)
- {
- // Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::prepareConfirmationDialog() " );
- }
-
- /**
- * オブジェクト入力用ダイアログの表示を準備する
- *
- */
- private void prepareObjectInputDialog(Dialog dialog)
- {
- Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::prepareObjectInputDialog(), key: " + selectedObjectKey);
-
- // ダイアログの準備を行う
- objectDataInputDialog.prepareObjectInputDialog(dialog, selectedObjectKey);
-
- }
-
- /**
- * アイテム選択ダイアログの表示を準備する
- *
- *
- */
- private void prepareItemSelectionDialog(Dialog dialog)
- {
- // アイテム選択ダイアログの表示設定
- // (動的変更時。。。今回は固定なので何もしない)
- }
-
- /**
- * 接続線選択用ダイアログの表示を準備する
- *
- */
- private void prepareLineSelectionDialog(Dialog dialog)
- {
- Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::prepareLineSelectionDialog(), key: " + selectedObjectKey);
-
- // ダイアログの準備を行う
- lineSelectionDialog.prepareSelectLineShapeDialog(dialog, selectedObjectKey);
- }
-
- /**
- * 設定画面を表示する処理
- */
- private void showPreference()
- {
- try
- {
- // 設定画面を呼び出す
- Intent prefIntent = new Intent(parent,Preference.class);
- parent.startActivityForResult(prefIntent, MENU_ID_PREFERENCES);
- }
- catch (Exception e)
- {
- // 例外発生...なにもしない。
- e.printStackTrace();
- //updater.showMessage("ERROR", MainUpdater.SHOWMETHOD_DONTCARE);
- }
- }
-
- /**
- * 接続線の形状を反映させる
- *
- */
- private void setLineStyle()
- {
- int buttonId = LineStyleHolder.getLineShapeImageId(lineStyleHolder.getLineStyle(), lineStyleHolder.getLineShape());
- final ImageButton lineStyleObj = (ImageButton) parent.findViewById(R.id.LineStyleButton);
- lineStyleObj.setImageResource(buttonId);
- }
-
- /**
- * オブジェクトが生成された!
- *
- */
- public void objectCreated()
- {
- // ここで動作モードを移動モードに戻す。
- drawModeHolder.changeOperationMode(OperationModeHolder.OPERATIONMODE_MOVE);
- updateButtons(OperationModeHolder.OPERATIONMODE_MOVE);
-
- // 画面を再描画する
- redrawSurfaceview();
- }
-
- /**
- * 空き領域がタッチされた!
- *
- */
- public int touchedVacantArea()
- {
- SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
- return (Integer.parseInt(preferences.getString("operationMode", "0")));
- }
-
- /**
- * 空き領域でタッチが離された!
- *
- */
- public int touchUppedVacantArea()
- {
- SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
- return (Integer.parseInt(preferences.getString("operationMode", "0")));
- }
-
- /**
- * オブジェクトを本当に削除して良いか確認した後に、オブジェクトを削除する。
- *
- *
- */
- private void removeObject(Integer key)
- {
- // 本当に消して良いか、確認をするダイアログを表示して、OKが押されたら消す。
- AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(parent);
- alertDialogBuilder.setTitle(parent.getString(R.string.deleteconfirm_title));
- alertDialogBuilder.setIcon(android.R.drawable.ic_dialog_alert);
- alertDialogBuilder.setMessage(parent.getString(R.string.deleteconfirm_message));
-
- // 削除するオブジェクトのキーを覚えこむ。
- objectKeyToDelete = key;
-
- // OKボタンの生成
- alertDialogBuilder.setPositiveButton(parent.getString(R.string.confirmYes), new DialogInterface.OnClickListener()
- {
- public void onClick(DialogInterface dialog, int id)
- {
- // 削除モードの時... 確認後削除だけど、今は確認なしで削除を行う。
- objectHolder.removePosition(objectKeyToDelete);
-
- // 削除するオブジェクトに接続されている線もすべて削除する
- objectHolder.getConnectLineHolder().removeAllConnection(objectKeyToDelete);
-
- // ダイアログを閉じる
- dialog.dismiss();
-
- // ここで動作モードを削除モードから移動モードに戻す。
- drawModeHolder.changeOperationMode(OperationModeHolder.OPERATIONMODE_MOVE);
- updateButtons(OperationModeHolder.OPERATIONMODE_MOVE);
-
-
- // 画面を再描画する
- redrawSurfaceview();
- }
- });
-
- // Cancelボタンの生成
- alertDialogBuilder.setNegativeButton(parent.getString(R.string.confirmNo), new DialogInterface.OnClickListener()
- {
- public void onClick(DialogInterface dialog, int id)
- {
- dialog.cancel();
- }
- });
-
- // ダイアログはキャンセル可能に設定する
- alertDialogBuilder.setCancelable(true);
-
- // ダイアログを表示する
- AlertDialog alertDialog = alertDialogBuilder.create();
- alertDialog.show();
- }
-
- /**
- * オブジェクトを複製する
- *
- *
- */
- private void duplicateObject(Integer key)
- {
- // 選択中オブジェクトを複製する
- objectHolder.duplicatePosition(key);
-
- // 画面を再描画する
- redrawSurfaceview();
- }
-
- /**
- * オブジェクトを拡大する
- *
- *
- */
- private void expandObject(Integer key)
- {
- // 選択中オブジェクトを拡大する
- objectHolder.expandObjectSize(key);
-
- // 画面を再描画する
- redrawSurfaceview();
- }
- /**
- * オブジェクトを縮小する
- *
- *
- */
- private void shrinkObject(Integer key)
- {
- // 選択中オブジェクトを縮小する
- objectHolder.shrinkObjectSize(key);
-
- // 画面を再描画する
- redrawSurfaceview();
- }
-
- private void setButtonBorder(ImageButton button, boolean isHighlight)
- {
- try
- {
- BitmapDrawable btnBackgroundShape = (BitmapDrawable)button.getBackground();
- if (isHighlight)
- {
-// btnBackgroundShape.setColorFilter(Color.rgb(51, 181, 229), Mode.LIGHTEN);
- btnBackgroundShape.setColorFilter(Color.BLUE, Mode.LIGHTEN);
- }
- else
- {
- btnBackgroundShape.setColorFilter(Color.BLACK, Mode.LIGHTEN);
- }
- }
- catch (Exception ex)
- {
- //
- Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::setButtonBorder(): " + ex.toString());
- }
- }
-
- /**
- * ボタンを更新する
- *
- */
- private void updateButtons(int mode)
- {
- final ImageButton createObjectButton = (ImageButton) parent.findViewById(R.id.CreateObjectButton);
- final ImageButton deleteObjectButton = (ImageButton) parent.findViewById(R.id.DeleteObjectButton);
-
- if (mode == OperationModeHolder.OPERATIONMODE_DELETE)
- {
- setButtonBorder(createObjectButton, false);
- setButtonBorder(deleteObjectButton, true);
- }
- else if (mode == OperationModeHolder.OPERATIONMODE_CREATE)
- {
- setButtonBorder(createObjectButton, true);
- setButtonBorder(deleteObjectButton, false);
- }
- else // if (mode == OperationModeHolder.OPERATIONMODE_MOVE)
- {
- setButtonBorder(createObjectButton, false);
- setButtonBorder(deleteObjectButton, false);
- }
- }
-
-
- /**
- * オブジェクトが選択された(長押しで!)
- *
- */
- public void objectSelectedContext(Integer key)
- {
- Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::objectSelectedContext(), key:" + key);
- selectedContextKey = key;
-
- // オブジェクトのアイテム選択ダイアログを表示する...
- parent.showDialog(MENU_ID_OPERATION);
-
- }
-
-
- /**
- * オブジェクトが選択された!
- *
- */
- public boolean objectSelected(Integer key)
- {
- SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
- int operationMode = Integer.parseInt(preferences.getString("operationMode", "0"));
- if (operationMode == OperationModeHolder.OPERATIONMODE_DELETE)
- {
- // オブジェクトを削除する
- removeObject(key);
-
- return (true);
- }
- //if ((operationMode == OperationModeHolder.OPERATIONMODE_MOVE)||
- // (operationMode == OperationModeHolder.OPERATIONMODE_CREATE))
- {
- // 選択されたオブジェクトを記憶する
- selectedObjectKey = key;
- Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::objectSelected() key : " + key);
-
- // オブジェクトの詳細設定ダイアログを表示する...
- parent.showDialog(R.id.objectinput_dialog);
- }
- return (true);
- }
-
- /**
- * ダイアログの生成
- *
- */
- public Dialog onCreateDialog(int id)
- {
- if (id == R.id.info_about_gokigen)
- {
- // クレジットダイアログを表示
- CreditDialog dialog = new CreditDialog(parent);
- return (dialog.getDialog());
- }
- if (id == R.id.editTextArea)
- {
- // 変更するテキストを表示
- return (editTextDialog.getDialog());
- }
- if (id == R.id.confirmation)
- {
- // 確認するメッセージを表示する
- return (confirmationDialog.getDialog());
- }
- if (id == R.id.objectinput_dialog)
- {
- // オブジェクト入力のダイアログを表示する
- return (objectDataInputDialog.getDialog());
- }
- if (id == MENU_ID_OPERATION)
- {
- // アイテム選択ダイアログの準備を行う
- return (itemSelectionDialog.getDialog());
- }
- if (id == R.id.selectline_dialog)
- {
- // 接続線選択ダイアログの準備を行う
- return (lineSelectionDialog.getDialog());
- }
- return (null);
- }
-
- /**
- * ダイアログ表示の準備
- *
- */
- public void onPrepareDialog(int id, Dialog dialog)
- {
- if (id == R.id.editTextArea)
- {
- // 変更するデータを表示する
- prepareInfoMessageEditDialog(dialog);
- return;
- }
- if (id == R.id.confirmation)
+ break;
+
+ case MENU_ID_RENAME:
+ // タイトル名の変更 (テキスト編集ダイアログを表示する)
+ showInfoMessageEditDialog();
+ result = true;
+ break;
+
+ case MENU_ID_INSERT_PICTURE:
+ // 背景画像の設定を行う
+ insertPicture();
+ result = true;
+ break;
+
+ case MENU_ID_CAPTURE:
+ // 画面キャプチャを指示された場合...
+ doCapture(false);
+ result = true;
+ break;
+
+ case MENU_ID_SHARE:
+ // 画面キャプチャ&共有を指示された場合...
+ doCapture(true);
+ result = true;
+ break;
+
+ case android.R.id.home:
+ // アイコンが押された時の処理...
+ // テキスト編集ダイアログを表示する
+ showInfoMessageEditDialog();
+ result = true;
+ break;
+
+ case MENU_ID_UNDO:
+ // UNDO処理...
+ result = undoOperation();
+ break;
+
+ default:
+ result = false;
+ break;
+ }
+ return (result);
+ }
+
+
+ /**
+ * 操作を1つ戻す(Undo 処理)
+ *
+ */
+ private boolean undoOperation()
+ {
+ return (false);
+ }
+
+ /**
+ * 画像ファイルの挿入 (データファイルの更新)
+ *
+ */
+ private void insertPicture()
+ {
+ Intent intent;
+ if (Build.VERSION.SDK_INT >= 19) {
+ intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
+ intent.addCategory(Intent.CATEGORY_OPENABLE);
+ intent.setType("image/*");
+ //intent.setAction(Intent.ACTION_GET_CONTENT);
+ } else {
+ intent = new Intent();
+ intent.setType("image/*");
+ intent.setAction(Intent.ACTION_GET_CONTENT);
+ }
+ parent.startActivityForResult(intent, MENU_ID_INSERT_PICTURE);
+ }
+
+ /**
+ * 画面キャプチャの実施
+ *
+ *
+ */
+ private void doCapture(boolean isShare)
+ {
+ // 画面のスクリーンショットをとる処理を実行する
+ dataInOutManager.doScreenCapture((String) parent.getTitle(), objectHolder, objectDrawer, isShare);
+
+ // 画面を再描画する
+ redrawSurfaceview();
+ }
+
+ /**
+ * アプリの情報を表示する
+ *
+ */
+ private void showAboutGokigen()
+ {
+ // アプリの情報(クレジット)を表示する!
+ parent.showDialog(R.id.info_about_gokigen);
+ }
+
+ /**
+ * 拡張メニューを呼び出す
+ *
+ */
+ private void callExtendMenu()
+ {
+ // 現在表示中のデータをファイルに保存する
+ dataInOutManager.saveFile((String) parent.getTitle(), true);
+
+ // 現在読み込んでいるファイルのファイル名を生成する
+ String fullPath = dataInOutManager.getDataFileFullPath((String) parent.getTitle(), ".xml");
+
+ // ここで拡張メニューを呼び出す
+ // (渡すデータを作って Intentとする)
+ Intent intent = new Intent();
+
+ intent.setAction(ExtensionActivity.MEMOMA_EXTENSION_LAUNCH_ACTIVITY);
+ intent.putExtra(ExtensionActivity.MEMOMA_EXTENSION_DATA_FULLPATH, fullPath);
+ intent.putExtra(ExtensionActivity.MEMOMA_EXTENSION_DATA_TITLE, (String) parent.getTitle());
+
+ // データ表示用Activityを起動する
+ parent.startActivityForResult(intent, MENU_ID_EXTEND);
+ }
+
+ /**
+ * データの読み込みを行う
+ *
+ */
+ private void prepareMeMoMaInfo()
+ {
+ // 設定に記録されているデータを画面のタイトルに反映させる
+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
+ String memomaInfo = preferences.getString("MeMoMaInfo", parent.getString(R.string.app_name));
+ parent.setTitle(memomaInfo);
+
+ // アクションバーとファイル名の準備
+ android.support.v7.app.ActionBar bar = parent.getSupportActionBar();
+ if (bar != null)
+ {
+ dataInOutManager.prepare(objectHolder, bar, memomaInfo);
+ }
+
+ //dataInOutManager.loadFile((String) parent.getTitle());
+ }
+
+ /**
+ * データの保存を行う
+ *
+ *
+ * @param forceOverwrite trueの時は、ファイル名が確定していたときは(確認せずに)上書き保存を自動で行う。
+ *
+ */
+ private void saveData(boolean forceOverwrite)
+ {
+ dataInOutManager.saveFile((String) parent.getTitle(), forceOverwrite);
+ }
+
+ /**
+ * データの整列を行う
+ *
+ */
+ private void alignData()
+ {
+ ObjectAligner aligner = new ObjectAligner(parent, this);
+ aligner.execute(objectHolder);
+ }
+
+ /**
+ * メッセージ編集ダイアログを表示する
+ *
+ */
+ private void showInfoMessageEditDialog()
+ {
+ parent.showDialog(R.id.editTextArea);
+ }
+
+ /**
+ * 新規作成が指示されたとき...全部クリアして作りなおして良いか確認する。
+ *
+ */
+ private void createNewScreen()
+ {
+ parent.showDialog(R.id.confirmation);
+ }
+
+ /**
+ * 接続線の設定ダイアログを表示する
+ */
+ private void selectLineShapeDialog()
+ {
+ // 接続線の設定ダイアログを表示する...
+ parent.showDialog(R.id.selectline_dialog);
+ }
+
+ /**
+ * メッセージ編集ダイアログの表示を準備する
+ *
+ */
+ private void prepareInfoMessageEditDialog(Dialog dialog)
+ {
+ String message = (String) parent.getTitle();
+ editTextDialog.prepare(dialog, this, parent.getString(R.string.dataTitle), message, true);
+ }
+
+ /**
+ * メッセージ編集ダイアログの表示を準備する
+ *
+ */
+ private void prepareConfirmationDialog(Dialog dialog)
+ {
+ // Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::prepareConfirmationDialog() " );
+ }
+
+ /**
+ * オブジェクト入力用ダイアログの表示を準備する
+ *
+ */
+ private void prepareObjectInputDialog(Dialog dialog)
+ {
+ Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::prepareObjectInputDialog(), key: " + selectedObjectKey);
+
+ // ダイアログの準備を行う
+ objectDataInputDialog.prepareObjectInputDialog(dialog, selectedObjectKey);
+
+ }
+
+ /**
+ * アイテム選択ダイアログの表示を準備する
+ *
+ *
+ */
+ private void prepareItemSelectionDialog(Dialog dialog)
+ {
+ // アイテム選択ダイアログの表示設定
+ // (動的変更時。。。今回は固定なので何もしない)
+ }
+
+ /**
+ * 接続線選択用ダイアログの表示を準備する
+ *
+ */
+ private void prepareLineSelectionDialog(Dialog dialog)
+ {
+ Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::prepareLineSelectionDialog(), key: " + selectedObjectKey);
+
+ // ダイアログの準備を行う
+ lineSelectionDialog.prepareSelectLineShapeDialog(dialog, selectedObjectKey);
+ }
+
+ /**
+ * 設定画面を表示する処理
+ */
+ private void showPreference()
+ {
+ try
+ {
+ // 設定画面を呼び出す
+ Intent prefIntent = new Intent(parent,Preference.class);
+ parent.startActivityForResult(prefIntent, MENU_ID_PREFERENCES);
+ }
+ catch (Exception e)
+ {
+ // 例外発生...なにもしない。
+ e.printStackTrace();
+ //updater.showMessage("ERROR", MainUpdater.SHOWMETHOD_DONTCARE);
+ }
+ }
+
+ /**
+ * 接続線の形状を反映させる
+ *
+ */
+ private void setLineStyle()
+ {
+ int buttonId = LineStyleHolder.getLineShapeImageId(lineStyleHolder.getLineStyle(), lineStyleHolder.getLineShape());
+ final ImageButton lineStyleObj = parent.findViewById(R.id.LineStyleButton);
+ lineStyleObj.setImageResource(buttonId);
+ }
+
+ /**
+ * オブジェクトが生成された!
+ *
+ */
+ public void objectCreated()
+ {
+ // ここで動作モードを移動モードに戻す。
+ drawModeHolder.changeOperationMode(OperationModeHolder.OPERATIONMODE_MOVE);
+ updateButtons(OperationModeHolder.OPERATIONMODE_MOVE);
+
+ // 画面を再描画する
+ redrawSurfaceview();
+ }
+
+ /**
+ * 空き領域がタッチされた!
+ *
+ */
+ public int touchedVacantArea()
+ {
+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
+ return (Integer.parseInt(preferences.getString("operationMode", "0")));
+ }
+
+ /**
+ * 空き領域でタッチが離された!
+ *
+ */
+ public int touchUppedVacantArea()
+ {
+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
+ return (Integer.parseInt(preferences.getString("operationMode", "0")));
+ }
+
+ /**
+ * オブジェクトを本当に削除して良いか確認した後に、オブジェクトを削除する。
+ *
+ *
+ */
+ private void removeObject(Integer key)
+ {
+ // 本当に消して良いか、確認をするダイアログを表示して、OKが押されたら消す。
+ AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(parent);
+ alertDialogBuilder.setTitle(parent.getString(R.string.deleteconfirm_title));
+ alertDialogBuilder.setIcon(android.R.drawable.ic_dialog_alert);
+ alertDialogBuilder.setMessage(parent.getString(R.string.deleteconfirm_message));
+
+ // 削除するオブジェクトのキーを覚えこむ。
+ objectKeyToDelete = key;
+
+ // OKボタンの生成
+ alertDialogBuilder.setPositiveButton(parent.getString(R.string.confirmYes), new DialogInterface.OnClickListener()
+ {
+ public void onClick(DialogInterface dialog, int id)
{
- // 確認ダイアログを表示する。
- prepareConfirmationDialog(dialog);
- return;
+ // 削除モードの時... 確認後削除だけど、今は確認なしで削除を行う。
+ objectHolder.removePosition(objectKeyToDelete);
+
+ // 削除するオブジェクトに接続されている線もすべて削除する
+ objectHolder.getConnectLineHolder().removeAllConnection(objectKeyToDelete);
+
+ // ダイアログを閉じる
+ dialog.dismiss();
+
+ // ここで動作モードを削除モードから移動モードに戻す。
+ drawModeHolder.changeOperationMode(OperationModeHolder.OPERATIONMODE_MOVE);
+ updateButtons(OperationModeHolder.OPERATIONMODE_MOVE);
+
+
+ // 画面を再描画する
+ redrawSurfaceview();
}
- if (id == R.id.objectinput_dialog)
+ });
+
+ // Cancelボタンの生成
+ alertDialogBuilder.setNegativeButton(parent.getString(R.string.confirmNo), new DialogInterface.OnClickListener()
+ {
+ public void onClick(DialogInterface dialog, int id)
{
- // オブジェクト入力のダイアログを表示する
- prepareObjectInputDialog(dialog);
+ dialog.cancel();
}
- if (id == MENU_ID_OPERATION)
+ });
+
+ // ダイアログはキャンセル可能に設定する
+ alertDialogBuilder.setCancelable(true);
+
+ // ダイアログを表示する
+ AlertDialog alertDialog = alertDialogBuilder.create();
+ alertDialog.show();
+ }
+
+ /**
+ * オブジェクトを複製する
+ *
+ *
+ */
+ private void duplicateObject(Integer key)
+ {
+ // 選択中オブジェクトを複製する
+ objectHolder.duplicatePosition(key);
+
+ // 画面を再描画する
+ redrawSurfaceview();
+ }
+
+ /**
+ * オブジェクトを拡大する
+ *
+ *
+ */
+ private void expandObject(Integer key)
+ {
+ // 選択中オブジェクトを拡大する
+ objectHolder.expandObjectSize(key);
+
+ // 画面を再描画する
+ redrawSurfaceview();
+ }
+ /**
+ * オブジェクトを縮小する
+ *
+ *
+ */
+ private void shrinkObject(Integer key)
+ {
+ // 選択中オブジェクトを縮小する
+ objectHolder.shrinkObjectSize(key);
+
+ // 画面を再描画する
+ redrawSurfaceview();
+ }
+
+ private void setButtonBorder(ImageButton button, boolean isHighlight)
+ {
+ try
+ {
+ BitmapDrawable btnBackgroundShape = (BitmapDrawable)button.getBackground();
+ if (isHighlight)
{
- // オブジェクト操作選択のダイアログを表示する
- prepareItemSelectionDialog(dialog);
+// btnBackgroundShape.setColorFilter(Color.rgb(51, 181, 229), Mode.LIGHTEN);
+ btnBackgroundShape.setColorFilter(Color.BLUE, Mode.LIGHTEN);
}
- if (id == R.id.selectline_dialog)
+ else
{
- // 接続線選択のダイアログを表示する
- prepareLineSelectionDialog(dialog);
+ btnBackgroundShape.setColorFilter(Color.BLACK, Mode.LIGHTEN);
}
- }
-
- /**
- * 新規状態に変更する。
- *
- */
- public void acceptConfirmation()
+ }
+ catch (Exception ex)
{
//
- Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::acceptConfirmation()");
-
- // オブジェクトデータをクリアする。
- objectHolder.removeAllPositions(); // オブジェクトの保持クラス
- objectHolder.getConnectLineHolder().removeAllLines(); // オブジェクト間の接続状態保持クラス
-
- // 画面の倍率と表示位置を初期状態に戻す
- if (objectDrawer != null)
- {
- final SeekBar zoomBar = (SeekBar) parent.findViewById(R.id.ZoomInOut);
- objectDrawer.resetScaleAndLocation(zoomBar);
- }
-
- /**
- // 題名を "無題"に変更し、関係情報をクリアする
- String newName = parent.getString(R.string.no_name);
- parent.setTitle(newName);
- SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
- SharedPreferences.Editor editor = preferences.edit();
- editor.putString("MeMoMaInfo", newName);
- editor.commit();
- **/
-
- // 画面を再描画する
- redrawSurfaceview();
+ Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::setButtonBorder(): " + ex.toString());
+ }
+ }
+
+ /**
+ * ボタンを更新する
+ *
+ */
+ private void updateButtons(int mode)
+ {
+ final ImageButton createObjectButton = parent.findViewById(R.id.CreateObjectButton);
+ final ImageButton deleteObjectButton = parent.findViewById(R.id.DeleteObjectButton);
+
+ if (mode == OperationModeHolder.OPERATIONMODE_DELETE)
+ {
+ setButtonBorder(createObjectButton, false);
+ setButtonBorder(deleteObjectButton, true);
+ }
+ else if (mode == OperationModeHolder.OPERATIONMODE_CREATE)
+ {
+ setButtonBorder(createObjectButton, true);
+ setButtonBorder(deleteObjectButton, false);
+ }
+ else // if (mode == OperationModeHolder.OPERATIONMODE_MOVE)
+ {
+ setButtonBorder(createObjectButton, false);
+ setButtonBorder(deleteObjectButton, false);
+ }
+ }
- // ファイル名選択ダイアログを開く
- showInfoMessageEditDialog();
+ /**
+ * オブジェクトが選択された(長押しで!)
+ *
+ */
+ public void objectSelectedContext(Integer key)
+ {
+ Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::objectSelectedContext(), key:" + key);
+ selectedContextKey = key;
+
+ // オブジェクトのアイテム選択ダイアログを表示する...
+ parent.showDialog(MENU_ID_OPERATION);
+
+ }
+
+
+ /**
+ * オブジェクトが選択された!
+ *
+ */
+ public boolean objectSelected(Integer key)
+ {
+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
+ int operationMode = Integer.parseInt(preferences.getString("operationMode", "0"));
+ if (operationMode == OperationModeHolder.OPERATIONMODE_DELETE)
+ {
+ // オブジェクトを削除する
+ removeObject(key);
+
+ return (true);
}
+ //if ((operationMode == OperationModeHolder.OPERATIONMODE_MOVE)||
+ // (operationMode == OperationModeHolder.OPERATIONMODE_CREATE))
+ {
+ // 選択されたオブジェクトを記憶する
+ selectedObjectKey = key;
+ Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::objectSelected() key : " + key);
- /**
- * 画面を再描画する
- *
- */
- private void redrawSurfaceview()
+ // オブジェクトの詳細設定ダイアログを表示する...
+ parent.showDialog(R.id.objectinput_dialog);
+ }
+ return (true);
+ }
+
+ /**
+ * ダイアログの生成
+ *
+ */
+ public Dialog onCreateDialog(int id)
+ {
+ if (id == R.id.info_about_gokigen)
{
- final GokigenSurfaceView surfaceview = (GokigenSurfaceView) parent.findViewById(R.id.GraphicView);
- surfaceview.doDraw();
+ // クレジットダイアログを表示
+ CreditDialog dialog = new CreditDialog(parent);
+ return (dialog.getDialog());
}
-
- /**
- * 不許可。何もしない。
- *
- */
- public void rejectConfirmation()
+ if (id == R.id.editTextArea)
{
- Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::rejectConfirmation()");
+ // 変更するテキストを表示
+ return (editTextDialog.getDialog());
}
-
- /**
- * オブジェクトが整列された時の処理
- *
- */
- public void objectAligned()
+ if (id == R.id.confirmation)
{
- // ç\94»é\9d¢ã\81®å\86\8dæ\8f\8fç\94»ã\82\92æ\8c\87示する
- redrawSurfaceview();
+ // 確èª\8dã\81\99ã\82\8bã\83¡ã\83\83ã\82»ã\83¼ã\82¸ã\82\92表示する
+ return (confirmationDialog.getDialog());
}
-
- /**
- * オブジェクト編集ダイアログが閉じられた時の処理
- *
- */
- public void finishObjectInput()
+ if (id == R.id.objectinput_dialog)
{
- // 画面の再描画を指示する
- redrawSurfaceview();
+ // オブジェクト入力のダイアログを表示する
+ return (objectDataInputDialog.getDialog());
}
-
- /**
- * オブジェクト編集ダイアログが閉じられた時の処理
- *
- */
- public void cancelObjectInput()
+ if (id == MENU_ID_OPERATION)
{
- // 何もしない
+ // アイテム選択ダイアログの準備を行う
+ return (itemSelectionDialog.getDialog());
}
-
-
- /**
- * 現在編集中かどうかを知る
- *
- * @return
- */
- public boolean isEditing()
+ if (id == R.id.selectline_dialog)
{
- return (isEditing);
+ // 接続線選択ダイアログの準備を行う
+ return (lineSelectionDialog.getDialog());
}
-
- /**
- * 現在編集中のフラグを更新する
- *
- * @param value
- */
- public void setIsEditing(boolean value)
+ return (null);
+ }
+
+ /**
+ * ダイアログ表示の準備
+ *
+ */
+ public void onPrepareDialog(int id, Dialog dialog)
+ {
+ if (id == R.id.editTextArea)
{
- isEditing = value;
+ // 変更するデータを表示する
+ prepareInfoMessageEditDialog(dialog);
+ return;
}
-
- /**
- * アイテムが選択された!
- *
- */
- public void itemSelected(int index, String itemValue)
+ if (id == R.id.confirmation)
{
- //
- Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::itemSelected() : " + itemValue + " [" + index + "]");
-
- if (index == ObjectOperationCommandHolder.OBJECTOPERATION_DELETE)
- {
- // オブジェクト削除の確認
- removeObject(selectedContextKey);
- }
- else if (index == ObjectOperationCommandHolder.OBJECTOPERATION_DUPLICATE)
- {
- // オブジェクトの複製
- duplicateObject(selectedContextKey);
- }
- else if (index == ObjectOperationCommandHolder.OBJECTOPERATION_SIZEBIGGER)
- {
- // オブジェクトの拡大
- expandObject(selectedContextKey);
- }
- else if (index == ObjectOperationCommandHolder.OBJECTOPERATION_SIZESMALLER)
- {
- // オブジェクトの縮小
- shrinkObject(selectedContextKey);
- }
+ // 確認ダイアログを表示する。
+ prepareConfirmationDialog(dialog);
+ return;
+ }
+ if (id == R.id.objectinput_dialog)
+ {
+ // オブジェクト入力のダイアログを表示する
+ prepareObjectInputDialog(dialog);
+ }
+ if (id == MENU_ID_OPERATION)
+ {
+ // オブジェクト操作選択のダイアログを表示する
+ prepareItemSelectionDialog(dialog);
+ }
+ if (id == R.id.selectline_dialog)
+ {
+ // 接続線選択のダイアログを表示する
+ prepareLineSelectionDialog(dialog);
+ }
+ }
+
+ /**
+ * 新規状態に変更する。
+ *
+ */
+ public void acceptConfirmation()
+ {
+ //
+ Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::acceptConfirmation()");
+
+ // オブジェクトデータをクリアする。
+ objectHolder.removeAllPositions(); // オブジェクトの保持クラス
+ objectHolder.getConnectLineHolder().removeAllLines(); // オブジェクト間の接続状態保持クラス
+
+ // 画面の倍率と表示位置を初期状態に戻す
+ if (objectDrawer != null)
+ {
+ final SeekBar zoomBar = (SeekBar) parent.findViewById(R.id.ZoomInOut);
+ objectDrawer.resetScaleAndLocation(zoomBar);
}
- /**
- * (今回未使用)
- *
- */
- public void itemSelectedMulti(String[] items, boolean[] status)
+ /*
+ // 題名を "無題"に変更し、関係情報をクリアする
+ String newName = parent.getString(R.string.no_name);
+ parent.setTitle(newName);
+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
+ SharedPreferences.Editor editor = preferences.edit();
+ editor.putString("MeMoMaInfo", newName);
+ editor.commit();
+ */
+
+ // 画面を再描画する
+ redrawSurfaceview();
+
+ // ファイル名選択ダイアログを開く
+ showInfoMessageEditDialog();
+
+ }
+
+ /**
+ * 画面を再描画する
+ *
+ */
+ private void redrawSurfaceview()
+ {
+ final GokigenSurfaceView surfaceview = parent.findViewById(R.id.GraphicView);
+ surfaceview.doDraw();
+ }
+
+ /**
+ * 不許可。何もしない。
+ *
+ */
+ public void rejectConfirmation()
+ {
+ Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::rejectConfirmation()");
+ }
+
+ /**
+ * オブジェクトが整列された時の処理
+ *
+ */
+ public void objectAligned()
+ {
+ // 画面の再描画を指示する
+ redrawSurfaceview();
+ }
+
+ /**
+ * オブジェクト編集ダイアログが閉じられた時の処理
+ *
+ */
+ public void finishObjectInput()
+ {
+ // 画面の再描画を指示する
+ redrawSurfaceview();
+ }
+
+ /**
+ * オブジェクト編集ダイアログが閉じられた時の処理
+ *
+ */
+ public void cancelObjectInput()
+ {
+ // 何もしない
+ }
+
+
+ /**
+ * 現在編集中かどうかを知る
+ *
+ *
+ */
+ public boolean isEditing()
+ {
+ return (isEditing);
+ }
+
+ /**
+ * 現在編集中のフラグを更新する
+ *
+ *
+ */
+ public void setIsEditing(boolean value)
+ {
+ isEditing = value;
+ }
+
+ /**
+ * アイテムが選択された!
+ *
+ */
+ public void itemSelected(int index, String itemValue)
+ {
+ //
+ Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::itemSelected() : " + itemValue + " [" + index + "]");
+
+ if (index == ObjectOperationCommandHolder.OBJECTOPERATION_DELETE)
{
-
+ // オブジェクト削除の確認
+ removeObject(selectedContextKey);
}
- public void canceledSelection()
+ else if (index == ObjectOperationCommandHolder.OBJECTOPERATION_DUPLICATE)
{
-
+ // オブジェクトの複製
+ duplicateObject(selectedContextKey);
}
-
- public void onSaveInstanceState(Bundle outState)
+ else if (index == ObjectOperationCommandHolder.OBJECTOPERATION_SIZEBIGGER)
{
- /* ここで状態を保存 */
- //Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::onSaveInstanceState()");
+ // オブジェクトの拡大
+ expandObject(selectedContextKey);
}
-
- public void onRestoreInstanceState(Bundle savedInstanceState)
+ else if (index == ObjectOperationCommandHolder.OBJECTOPERATION_SIZESMALLER)
{
- /* ここで状態を復元 */
- Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::onRestoreInstanceState()");
+ // オブジェクトの縮小
+ shrinkObject(selectedContextKey);
+ }
+ }
+
+ /**
+ * (今回未使用)
+ *
+ */
+ public void itemSelectedMulti(String[] items, boolean[] status)
+ {
+
+ }
+ public void canceledSelection()
+ {
+
+ }
+
+ public void onSaveInstanceState(Bundle outState)
+ {
+ /* ここで状態を保存 */
+ Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::onSaveInstanceState() : " + outState.toString() );
+ }
+
+ public void onRestoreInstanceState(Bundle savedInstanceState)
+ {
+ /* ここで状態を復元 */
+ Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::onRestoreInstanceState() : " + savedInstanceState.toString());
+ }
+
+ public boolean finishTextEditDialog(String message)
+ {
+ if ((message == null)||(message.length() == 0))
+ {
+ // データが入力されていなかったので、何もしない。
+ return (false);
}
- public boolean finishTextEditDialog(String message)
+ try
{
- if ((message == null)||(message.length() == 0))
- {
- // データが入力されていなかったので、何もしない。
- return (false);
- }
-
- // 文字列を記録
- SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
+ // 文字列を記録
+ SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
SharedPreferences.Editor editor = preferences.edit();
editor.putString("MeMoMaInfo", message);
- editor.commit();
+ editor.apply();
// タイトルに設定
parent.setTitle(message);
- // 保存シーケンスを一度走らせる
+ // 保存シーケンスを一度走らせる
saveData(true);
// ファイル選択リストの更新
dataInOutManager.updateFileList(message, parent.getSupportActionBar());
- return (true);
}
- public boolean cancelTextEditDialog()
+ catch (Exception e)
{
- return (false);
+ e.printStackTrace();
}
+ return (true);
+ }
+ public boolean cancelTextEditDialog()
+ {
+ return (false);
+ }
+
+ /**
+ * 接続線
+ *
+ */
+ public void finishSelectLineShape(int style, int shape, int thickness)
+ {
+ int buttonId = LineStyleHolder.getLineShapeImageId(style, shape);
+ final ImageButton lineStyleObj =parent.findViewById(R.id.LineStyleButton);
+ lineStyleObj.setImageResource(buttonId);
+ //Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::finishSelectLineShape() buttonId:" + buttonId);
+ }
+
+ /**
+ *
+ *
+ */
+ public void cancelSelectLineShape()
+ {
+
+ }
- /**
- * 接続線
- *
- */
- public void finishSelectLineShape(int style, int shape, int thickness)
- {
- int buttonId = LineStyleHolder.getLineShapeImageId(style, shape);
- final ImageButton lineStyleObj = (ImageButton) parent.findViewById(R.id.LineStyleButton);
- lineStyleObj.setImageResource(buttonId);
- //Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::finishSelectLineShape() buttonId:" + buttonId);
- }
-
- /**
- *
- *
- */
- public void cancelSelectLineShape()
- {
-
- }
}
import android.widget.AdapterView;
import android.widget.ListView;
-import jp.sourceforge.gokigen.memoma.fileio.ExternalStorageFileUtility;
+import jp.sourceforge.gokigen.memoma.io.ExternalStorageFileUtility;
import jp.sourceforge.gokigen.memoma.holders.MeMoMaDataFileHolder;
import jp.sourceforge.gokigen.memoma.R;
-package jp.sourceforge.gokigen.memoma;
+package jp.sourceforge.gokigen.memoma.drawers;
import android.content.Context;
import android.graphics.Canvas;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
+import jp.sourceforge.gokigen.memoma.Main;
import jp.sourceforge.gokigen.memoma.drawers.ICanvasDrawer;
/**
import android.widget.SeekBar;
import android.widget.TextView;
-import jp.sourceforge.gokigen.memoma.GokigenSurfaceView;
+import jp.sourceforge.gokigen.memoma.holders.ObjectConnector;
+import jp.sourceforge.gokigen.memoma.holders.PositionObject;
import jp.sourceforge.gokigen.memoma.operations.IObjectSelectionReceiver;
-import jp.sourceforge.gokigen.memoma.fileio.ImageLoader;
+import jp.sourceforge.gokigen.memoma.io.ImageLoader;
import jp.sourceforge.gokigen.memoma.Main;
import jp.sourceforge.gokigen.memoma.R;
import jp.sourceforge.gokigen.memoma.holders.LineStyleHolder;
public static final int BACKGROUND_COLOR_DEFAULT = 0xff004000;
private int backgroundColor = BACKGROUND_COLOR_DEFAULT;
- private MeMoMaObjectHolder.PositionObject selectedPosition = null;
+ private PositionObject selectedPosition = null;
private float tempPosX = Float.MIN_VALUE;
private float tempPosY = Float.MIN_VALUE;
private float downPosX = Float.MIN_VALUE;
// 以下の値は、MeMoMaListenerで初期値を設定する
private int objectStyle = MeMoMaObjectHolder.DRAWSTYLE_RECTANGLE;
- private LineStyleHolder lineStyleHolder = null;
+ private LineStyleHolder lineStyleHolder;
private float drawScale = 1.0f; // 表示の倍率
private float drawTransX = 0.0f; // 並行移動距離 (X)
private String backgroundBitmapUri = null;
private Bitmap backgroundBitmap = null;
- private MeMoMaObjectHolder objectHolder = null;
- private MeMoMaConnectLineHolder lineHolder = null;
- private IObjectSelectionReceiver selectionReceiver = null;
+ private MeMoMaObjectHolder objectHolder;
+ private MeMoMaConnectLineHolder lineHolder;
+ private IObjectSelectionReceiver selectionReceiver;
- private GestureDetector gestureDetector = null;
- private ScaleGestureDetector scaleGestureDetector = null;
+ private GestureDetector gestureDetector;
+ private ScaleGestureDetector scaleGestureDetector;
- private Activity parent = null;
+ private Activity parent;
/**
* コンストラクタ
* オブジェクトの形状を変更する
* (ここで指定された形状のチェックを行っておく。)
*
- * @param style
+ *
*/
public void setObjectStyle(int style)
{
/**
* 背景画像を設定する
*
- * @param uri
+ *
*/
public void setBackgroundUri(String uri)
{
/**
* 背景色を(文字列で)設定する
*
- * @param colorString
+ *
*/
public void setBackgroundColor(String colorString)
{
// オブジェクトをすべて表示
drawObjects(canvas, 0.0f, 0.0f);
- /** 移動中かどうかのチェックを行う。 **/
- if (isFlicking(canvas) == true)
+ // 移動中かどうかのチェックを行う。
+ if (isFlicking(canvas))
{
// 移動中の場合、フリック時の軌跡と現在位置を表示する
drawTrackAndPositions(canvas);
/**
* オブジェクト間の接続線を表示する
*
- * @param canvas
+ *
*/
private void drawConnectionLines(Canvas canvas, float offsetX, float offsetY)
{
while (keys.hasMoreElements())
{
Integer key = keys.nextElement();
- MeMoMaConnectLineHolder.ObjectConnector line = lineHolder.getLine(key);
- if (line.key > 0)
+ ObjectConnector line = lineHolder.getLine(key);
+ if (line.getKey() > 0)
{
// 実際にラインを引く
drawLine(canvas, paint, dashLinePaint, line, offsetX, offsetY);
/**
* 接続する線を引く
*
- * @param canvas
- * @param paint
- * @param line
*/
- public void drawLine(Canvas canvas, Paint paint, Paint dashPaint, MeMoMaConnectLineHolder.ObjectConnector line, float offsetX, float offsetY)
+ private void drawLine(Canvas canvas, Paint paint, Paint dashPaint, ObjectConnector line, float offsetX, float offsetY)
{
try
{
return;
}
- MeMoMaObjectHolder.PositionObject from = objectHolder.getPosition(line.fromObjectKey);
- MeMoMaObjectHolder.PositionObject to = objectHolder.getPosition(line.toObjectKey);
+ PositionObject from = objectHolder.getPosition(line.getFromObjectKey());
+ PositionObject to = objectHolder.getPosition(line.getToObjectKey());
if ((from == null)||(to == null))
{
// なにもしない
}
// ラインの太さを設定する。
- paint.setStrokeWidth((float) line.lineThickness);
+ paint.setStrokeWidth((float) line.getLineThickness());
// ラインの太さを設定する。
- dashPaint.setStrokeWidth((float) line.lineThickness);
+ dashPaint.setStrokeWidth((float) line.getLineThickness());
// ラインのスタイル(連続線 or 点線)を設定する
- Paint linePaint = (line.lineShape == LineStyleHolder.LINESHAPE_DASH) ? dashPaint : paint;
+ Paint linePaint = (line.getLineShape() == LineStyleHolder.LINESHAPE_DASH) ? dashPaint : paint;
// 初期値として、各オブジェクトの中心座標を設定する
- float startX = from.rect.centerX() + offsetX;
- float endX = to.rect.centerX() + offsetX;
- float startY = from.rect.centerY() + offsetY;
- float endY = to.rect.centerY() + offsetY;
+ RectF fromRect = from.getRect();
+ RectF toRect = to.getRect();
+ float startX = fromRect.centerX() + offsetX;
+ float endX = toRect.centerX() + offsetX;
+ float startY = fromRect.centerY() + offsetY;
+ float endY = toRect.centerY() + offsetY;
// Y座標の線の位置を補正する
- if (from.rect.bottom < to.rect.top)
+ if (fromRect.bottom < toRect.top)
{
- startY = from.rect.bottom + offsetY;
- endY = to.rect.top + offsetY;
+ startY = fromRect.bottom + offsetY;
+ endY = toRect.top + offsetY;
}
- else if (from.rect.top > to.rect.bottom)
+ else if (fromRect.top > toRect.bottom)
{
- startY = from.rect.top + offsetY;
- endY = to.rect.bottom + offsetY;
+ startY = fromRect.top + offsetY;
+ endY = toRect.bottom + offsetY;
}
// X座標の線の位置を補正する (Y座標が補正されていないとき)
- if ((startY != (from.rect.top + offsetY))&&(startY != (from.rect.bottom + offsetY)))
+ if ((startY != (fromRect.top + offsetY))&&(startY != (fromRect.bottom + offsetY)))
{
- if (from.rect.right < to.rect.left)
+ if (fromRect.right < toRect.left)
{
- startX = from.rect.right + offsetX;
- endX = to.rect.left + offsetX;
+ startX = fromRect.right + offsetX;
+ endX = toRect.left + offsetX;
}
- else if (from.rect.left > to.rect.right)
+ else if (fromRect.left > toRect.right)
{
- startX = from.rect.left + offsetX;
- endX = to.rect.right + offsetX;
+ startX = fromRect.left + offsetX;
+ endX = toRect.right + offsetX;
}
}
- if ((line.lineStyle == LineStyleHolder.LINESTYLE_TREESTYLE_NO_ARROW)||
- (line.lineStyle == LineStyleHolder.LINESTYLE_TREESTYLE_L_ARROW)||
- (line.lineStyle == LineStyleHolder.LINESTYLE_TREESTYLE_R_ARROW))
+ int lineStyle = line.getLineStyle();
+ if ((lineStyle == LineStyleHolder.LINESTYLE_TREESTYLE_NO_ARROW)||
+ (lineStyle == LineStyleHolder.LINESTYLE_TREESTYLE_L_ARROW)||
+ (lineStyle == LineStyleHolder.LINESTYLE_TREESTYLE_R_ARROW))
{
// ツリー形式のように接続する ...
- if (startX == (from.rect.centerX() + offsetX))
+ if (startX == (fromRect.centerX() + offsetX))
{
float middleY = (startY + endY) / 2;
canvas.drawLine(startX, startY, startX, middleY, linePaint);
canvas.drawLine(startX, middleY, endX, middleY, linePaint);
canvas.drawLine(endX, middleY, endX, endY, linePaint);
- /** やじるしをつける処理 **/
- if (line.lineStyle == LineStyleHolder.LINESTYLE_TREESTYLE_L_ARROW)
+ // やじるしをつける処理
+ if (lineStyle == LineStyleHolder.LINESTYLE_TREESTYLE_L_ARROW)
{
// 始点に矢印をつける
ObjectShapeDrawer.drawArrowTree(canvas, paint, startX,startY, middleY, false);
}
- else if (line.lineStyle == LineStyleHolder.LINESTYLE_TREESTYLE_R_ARROW)
+ else if (lineStyle == LineStyleHolder.LINESTYLE_TREESTYLE_R_ARROW)
{
// 終点に矢印をつける
ObjectShapeDrawer.drawArrowTree(canvas, paint, endX, endY, middleY, false);
canvas.drawLine(middleX, startY, middleX, endY, linePaint);
canvas.drawLine(middleX, endY, endX, endY, linePaint);
- /** やじるし(三角形)をつける処理 **/
- if (line.lineStyle == LineStyleHolder.LINESTYLE_TREESTYLE_L_ARROW)
+ // やじるし(三角形)をつける処理
+ if (lineStyle == LineStyleHolder.LINESTYLE_TREESTYLE_L_ARROW)
{
// 始点に矢印をつける
ObjectShapeDrawer.drawArrowTree(canvas, paint, startX, startY, middleX, true);
}
- else if (line.lineStyle == LineStyleHolder.LINESTYLE_TREESTYLE_R_ARROW)
+ else if (lineStyle == LineStyleHolder.LINESTYLE_TREESTYLE_R_ARROW)
{
// 終点に矢印をつける
ObjectShapeDrawer.drawArrowTree(canvas, paint, endX,endY, middleX, true);
}
}
}
- else if ((line.lineStyle == LineStyleHolder.LINESTYLE_CURVESTYLE_NO_ARROW)||
- (line.lineStyle == LineStyleHolder.LINESTYLE_CURVESTYLE_L_ARROW)||
- (line.lineStyle == LineStyleHolder.LINESTYLE_CURVESTYLE_R_ARROW))
+ else if ((lineStyle == LineStyleHolder.LINESTYLE_CURVESTYLE_NO_ARROW)||
+ (lineStyle == LineStyleHolder.LINESTYLE_CURVESTYLE_L_ARROW)||
+ (lineStyle == LineStyleHolder.LINESTYLE_CURVESTYLE_R_ARROW))
{
// 曲線で接続する
float middleX = (startX + endX) / 2;
float middleY = (startY + endY) / 2;
float x1 = (startX + middleX) / 2;
- float y1 = middleY;
float x2 = (middleX + endX) / 2;
- float y2 = middleY;
Path pathLine = new Path();
pathLine.moveTo(startX, startY);
- pathLine.cubicTo(x1, y1, x2, y2, endX, endY);
+ pathLine.cubicTo(x1, middleY, x2, middleY, endX, endY);
canvas.drawPath(pathLine, linePaint);
- /** やじるしをつける処理 **/
- if (line.lineStyle == LineStyleHolder.LINESTYLE_CURVESTYLE_L_ARROW)
+ // やじるしをつける処理
+ if (lineStyle == LineStyleHolder.LINESTYLE_CURVESTYLE_L_ARROW)
{
// 始点に矢印をつける
ObjectShapeDrawer.drawArrow(canvas, paint, startX, startY, endX, endY);
}
- else if (line.lineStyle == LineStyleHolder.LINESTYLE_CURVESTYLE_R_ARROW)
+ else if (lineStyle == LineStyleHolder.LINESTYLE_CURVESTYLE_R_ARROW)
{
// 終点に矢印をつける
ObjectShapeDrawer.drawArrow(canvas, paint, endX, endY, startX, startY);
// 直線で接続する
canvas.drawLine(startX, startY, endX, endY, linePaint);
- /** やじるしをつける処理 **/
- if (line.lineStyle == LineStyleHolder.LINESTYLE_STRAIGHT_L_ARROW)
+ // やじるしをつける処理
+ if (lineStyle == LineStyleHolder.LINESTYLE_STRAIGHT_L_ARROW)
{
// 始点に矢印をつける
ObjectShapeDrawer.drawArrow(canvas, paint, startX, startY, endX, endY);
}
- else if (line.lineStyle == LineStyleHolder.LINESTYLE_STRAIGHT_R_ARROW)
+ else if (lineStyle == LineStyleHolder.LINESTYLE_STRAIGHT_R_ARROW)
{
// 終点に矢印をつける
ObjectShapeDrawer.drawArrow(canvas, paint, endX, endY, startX, startY);
/**
* オブジェクトを動かしている最中かどうかの判定を行う。
*
- * @param canvas
+ *
* @return trueなら、動かしている最中
*/
private boolean isFlicking(Canvas canvas)
{
- //int width = canvas.getWidth();
- //int height = canvas.getHeight();
- if ((tempPosX == Float.MIN_VALUE)||(tempPosY == Float.MIN_VALUE))
- {
- return (false);
- }
- return (true);
+ return (!((tempPosX == Float.MIN_VALUE)||(tempPosY == Float.MIN_VALUE)));
}
/**
* フリック時の軌跡と現在地点を表示する
*
- * @param canvas
+ *
*/
private void drawTrackAndPositions(Canvas canvas)
{
paint.setColor(Color.GRAY);
if (selectedPosition != null)
{
- float objX = (selectedPosition.rect.right - selectedPosition.rect.left) / 2;
- float objY = (selectedPosition.rect.bottom - selectedPosition.rect.top) / 2;
- canvas.drawLine(selectedPosition.rect.centerX(), selectedPosition.rect.centerY(), x, y, paint);
+ RectF objRect = selectedPosition.getRect();
+ float objX = (objRect.right - objRect.left) / 2;
+ float objY = (objRect.bottom - objRect.top) / 2;
+ canvas.drawLine(objRect.centerX(), objRect.centerY(), x, y, paint);
canvas.drawRect((x - objX), (y - objY), (x + objX), (y + objY), paint);
// 現在地点の表示
SharedPreferences.Editor editor = preferences.edit();
editor.putFloat("drawTransX", drawTransX);
editor.putFloat("drawTransY", drawTransY);
- editor.commit();
+ editor.apply();
}
else
{
* オブジェクト(1個)を表示する
*
*/
- private void drawObject(Canvas canvas, MeMoMaObjectHolder.PositionObject object, boolean isMoving, float offsetX, float offsetY)
+ private void drawObject(Canvas canvas, PositionObject object, boolean isMoving, float offsetX, float offsetY)
{
float label_offsetX = OBJECTLABEL_MARGIN;
float label_offsetY = 0.0f;
// オブジェクトの色と枠線を設定する
Paint paint = new Paint();
- if (isMoving == true)
+ if (isMoving)
{
paint.setColor(Color.YELLOW);
paint.setStyle(Paint.Style.STROKE);
- paint.setStrokeWidth(object.strokeWidth);
+ paint.setStrokeWidth(object.getstrokeWidth());
}
else
{
- paint.setColor(object.objectColor);
- paint.setStyle(Paint.Style.valueOf(object.paintStyle));
- paint.setStrokeWidth(object.strokeWidth);
+ paint.setColor(object.getObjectColor());
+ paint.setStyle(Paint.Style.valueOf(object.getPaintStyle()));
+ paint.setStrokeWidth(object.getstrokeWidth());
}
// 図形の形状に合わせて描画する
- RectF objectShape = new RectF(object.rect);
+ RectF objectShape = new RectF(object.getRect());
objectShape.left = objectShape.left + offsetX;
objectShape.right = objectShape.right + offsetX;
objectShape.top = objectShape.top + offsetY;
objectShape.bottom = objectShape.bottom + offsetY;
-
- if (object.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_OVAL)
+
+ int drawStyle = object.getDrawStyle();
+ if (drawStyle == MeMoMaObjectHolder.DRAWSTYLE_OVAL)
{
// 楕円形の描画
label_offsetY = ObjectShapeDrawer.drawObjectOval(canvas, objectShape, paint);
}
- else if (object.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_ROUNDRECT)
+ else if (drawStyle == MeMoMaObjectHolder.DRAWSTYLE_ROUNDRECT)
{
// 丸角四角形の描画
label_offsetY = ObjectShapeDrawer.drawObjectRoundRect(canvas, objectShape, paint);
}
- else if (object.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_DIAMOND)
+ else if (drawStyle == MeMoMaObjectHolder.DRAWSTYLE_DIAMOND)
{
// 菱形の描画
label_offsetY = ObjectShapeDrawer.drawObjectDiamond(canvas, objectShape, paint);
label_offsetX = OBJECTLABEL_MARGIN;
}
- else if (object.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_KEYBOARD)
+ else if (drawStyle == MeMoMaObjectHolder.DRAWSTYLE_KEYBOARD)
{
// 台形(キーボード型)の描画
label_offsetY = ObjectShapeDrawer.drawObjectKeyboard(canvas, objectShape, paint);
}
- else if (object.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_PARALLELOGRAM)
+ else if (drawStyle == MeMoMaObjectHolder.DRAWSTYLE_PARALLELOGRAM)
{
// 平行四辺形の描画
label_offsetY = ObjectShapeDrawer.drawObjectParallelogram(canvas, objectShape, paint);
}
- else if (object.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_HEXAGONAL)
+ else if (drawStyle == MeMoMaObjectHolder.DRAWSTYLE_HEXAGONAL)
{
// 六角形の描画
label_offsetY = ObjectShapeDrawer.drawObjectHexagonal(canvas, objectShape, paint);
}
- else if (object.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_PAPER)
+ else if (drawStyle == MeMoMaObjectHolder.DRAWSTYLE_PAPER)
{
// 書類の形の描画
label_offsetY = ObjectShapeDrawer.drawObjectPaper(canvas, objectShape, paint);
}
- else if (object.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_DRUM)
+ else if (drawStyle == MeMoMaObjectHolder.DRAWSTYLE_DRUM)
{
// 円柱の描画
- label_offsetY = ObjectShapeDrawer.drawObjectDrum(canvas, objectShape, paint, Paint.Style.valueOf(object.paintStyle));
+ label_offsetY = ObjectShapeDrawer.drawObjectDrum(canvas, objectShape, paint, Paint.Style.valueOf(object.getPaintStyle()));
}
- else if (object.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_CIRCLE)
+ else if (drawStyle == MeMoMaObjectHolder.DRAWSTYLE_CIRCLE)
{
// 円を描画する
label_offsetY = ObjectShapeDrawer.drawObjectCircle(canvas, objectShape, paint);
}
- else if (object.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_NO_REGION)
+ else if (drawStyle == MeMoMaObjectHolder.DRAWSTYLE_NO_REGION)
{
// 枠なしを描画(?)する ... なにもしない
- if (object.label.length() == 0)
+ if (object.getLabel().length() == 0)
{
// 何も表示しないとわからないので、ラベルが無いときには枠を表示する
ObjectShapeDrawer.drawObjectNoRegion(canvas, objectShape, paint);
}
}
- else if (object.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_LOOP_START)
+ else if (drawStyle == MeMoMaObjectHolder.DRAWSTYLE_LOOP_START)
{
// ループ開始図形の描画
label_offsetY = ObjectShapeDrawer.drawObjectLoopStart(canvas, objectShape, paint);
}
- else if (object.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_LOOP_END)
+ else if (drawStyle == MeMoMaObjectHolder.DRAWSTYLE_LOOP_END)
{
// ループ終了図形の描画
label_offsetY = ObjectShapeDrawer.drawObjectLoopEnd(canvas, objectShape, paint);
}
- else if (object.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_LEFT_ARROW)
+ else if (drawStyle == MeMoMaObjectHolder.DRAWSTYLE_LEFT_ARROW)
{
// 左側矢印図形の描画
label_offsetY = ObjectShapeDrawer.drawObjectLeftArrow(canvas, objectShape, paint);
}
- else if (object.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_DOWN_ARROW)
+ else if (drawStyle == MeMoMaObjectHolder.DRAWSTYLE_DOWN_ARROW)
{
// 下側矢印図形の描画
label_offsetY = ObjectShapeDrawer.drawObjectDownArrow(canvas, objectShape, paint);
}
- else if (object.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_UP_ARROW)
+ else if (drawStyle == MeMoMaObjectHolder.DRAWSTYLE_UP_ARROW)
{
// 上側矢印図形の描画
label_offsetY = ObjectShapeDrawer.drawObjectUpArrow(canvas, objectShape, paint);
}
- else if (object.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_RIGHT_ARROW)
+ else if (drawStyle == MeMoMaObjectHolder.DRAWSTYLE_RIGHT_ARROW)
{
// 右側矢印図形の描画
label_offsetY = ObjectShapeDrawer.drawObjectRightArrow(canvas, objectShape, paint);
}
// 文字サイズを設定する。
- paint.setTextSize(object.fontSize);
+ paint.setTextSize(object.getFontSize());
// 文字ラベルを表示する
ObjectShapeDrawer.drawTextLabel(canvas, paint, object, objectShape, displayObjectInformation, label_offsetX, label_offsetY);
/**
* オブジェクトをすべて表示する
*
- * @param canvas
+ *
*/
private void drawObjects(Canvas canvas , float offsetX, float offsetY)
{
while (keys.hasMoreElements())
{
Integer key = keys.nextElement();
- MeMoMaObjectHolder.PositionObject pos = objectHolder.getPosition(key);
+ PositionObject pos = objectHolder.getPosition(key);
drawObject(canvas, pos, false, offsetX, offsetY);
}
}
/**
* タッチされたタイミングでの処理
- * @param event
- * @return
+ *
*/
private boolean onTouchDown(MotionEvent event)
{
// オブジェクトが生成されたことを通知する
selectionReceiver.objectCreated();
}
+/*
else if (data ==OperationModeHolder.OPERATIONMODE_MOVE)
{
// 移動モードのとき
{
// 削除モードのとき...何もしない
}
+*/
}
return (false);
}
/**
* タッチが離されたタイミングでの処理
- * @param event
- * @return
+ *
*/
private boolean onTouchUp(MotionEvent event)
{
boolean longPress = false;
- if (onGestureProcessed == true)
+ if (onGestureProcessed)
{
// ロングタッチ中だった場合...フラグを落とす
onGestureProcessed = false;
return (true);
}
- if (selectedPosition.rect.contains(x, y) == true)
+ RectF selectedRect = selectedPosition.getRect();
+ if (selectedRect.contains(x, y))
{
// タッチが離された位置がタッチしたオブジェクトと同じ位置だった場合......
// タッチが離された位置を認識する
float diffX = Math.abs(event.getX() - drawTransX - downPosX);
- float diffY = Math.abs(event.getY() - drawTransY - downPosY);
+ float diffY = Math.abs(event.getY() - drawTransY - downPosY);
// タッチが離された位置が動いていた場合、オブジェクト位置の微調整と判定する。
- if (((diffX > 2.0f)||(diffY > 2.0f))||(longPress == true))
+ if (((diffX > 2.0f)||(diffY > 2.0f))||(longPress))
{
// タッチが離された場所にはオブジェクトがなかった場合...オブジェクトをその位置に移動させる
Log.v(Main.APP_IDENTIFIER, "MOVE OBJECT : (" + diffX + "," + diffY + ")");
moveObjectPosition(x, y);
return (true);
}
-
- // タッチが押された位置と離された位置が同じ位置だった場合......アイテムが選択された、と認識する。
+
+ // タッチが押された位置と離された位置が同じ位置だった場合......アイテムが選択された、と認識する。
Log.v(Main.APP_IDENTIFIER, " ITEM SELECTED :" + x + "," + y);
if (selectionReceiver != null)
{
}
// タッチが離された位置にオブジェクトがいるかどうかのチェック
- MeMoMaObjectHolder.PositionObject position = checkSelectedObject(x, y);
- if ((position != null)&&(longPress == false))
+ PositionObject position = checkSelectedObject(x, y);
+ if ((position != null)&&(!longPress))
{
// 他のオブジェクトと重なるように操作した、この場合は、オブジェクト間を線をつなげる
// (ただし、ボタンを長押ししていなかったとき。)
/**
* オブジェクトの位置を移動させる
- *
- * @param x
- * @param y
+ *
*/
private void moveObjectPosition(float x, float y)
{
+ RectF curRect = selectedPosition.getRect();
tempPosX = Float.MIN_VALUE;
tempPosY = Float.MIN_VALUE;
- float sizeX = selectedPosition.rect.right - selectedPosition.rect.left;
- float sizeY = selectedPosition.rect.bottom - selectedPosition.rect.top;
+ float sizeX = curRect.right - curRect.left;
+ float sizeY = curRect.bottom - curRect.top;
float positionX = alignPosition(x, (sizeX / 2) * (-1));
float positionY = alignPosition(y, (sizeY / 2) * (-1));
- selectedPosition.rect = new android.graphics.RectF(positionX, positionY, (positionX + sizeX), (positionY + sizeY));
-
- return;
+ selectedPosition.setRect(new android.graphics.RectF(positionX, positionY, (positionX + sizeX), (positionY + sizeY)));
}
/**
*/
public boolean onTouchEvent(MotionEvent event)
{
- boolean isDraw = false;
+ boolean isDraw;
- /** スケールジェスチャ(マルチタッチのジェスチャ)を拾う **/
- isDraw = scaleGestureDetector.onTouchEvent(event);
- if ((onScaling == true)||(scaleGestureDetector.isInProgress() == true))
+ // スケールジェスチャ(マルチタッチのジェスチャ)を拾う
+ // isDraw = scaleGestureDetector.onTouchEvent(event);
+ if ((onScaling)||(scaleGestureDetector.isInProgress()))
{
// マルチタッチ操作中...
return (true);
}
- /** 先にジェスチャーを拾ってみよう... **/
+ // 先にジェスチャーを拾ってみよう...
isDraw = gestureDetector.onTouchEvent(event);
- if (isDraw == true)
+ if (isDraw)
{
Log.v(Main.APP_IDENTIFIER, "MeMoMaCanvasDrawer::onTouchEvent() : isDraw == true");
- return (isDraw);
+ return (true);
}
int action = event.getAction();
/**
* タテヨコ位置を合わせられるよう、調整する。
- * @param pos
- * @return
+ *
*/
private float alignPosition(float pos, float offset)
{
/**
* 位置から判定し、選択したオブジェクトを応答する
* (オブジェクトが選択されていない場合には、nullを応答する)
- * @param x
- * @param y
- * @return
+ *
*/
- private MeMoMaObjectHolder.PositionObject checkSelectedObject(float x, float y)
+ private PositionObject checkSelectedObject(float x, float y)
{
Enumeration<Integer> keys = objectHolder.getObjectKeys();
//Log.v(Main.APP_IDENTIFIER, "CHECK POS " + x + "," + y);
while (keys.hasMoreElements())
{
Integer key = keys.nextElement();
- MeMoMaObjectHolder.PositionObject pos = objectHolder.getPosition(key);
- if (pos.rect.contains(x, y) == true)
+ PositionObject pos = objectHolder.getPosition(key);
+ RectF posRect = pos.getRect();
+ if (posRect.contains(x, y))
{
- Log.v(Main.APP_IDENTIFIER, "SELECTED :" + pos.rect.centerX() + "," + pos.rect.centerY() + " KEY :" + key);
+ Log.v(Main.APP_IDENTIFIER, "SELECTED :" + posRect.centerX() + "," + posRect.centerY() + " KEY :" + key);
return (pos);
}
//Log.v(Main.APP_IDENTIFIER, "NOT MATCH :" + pos.rect.centerX() + "," + pos.rect.centerY());
/**
* 線と交差するオブジェクト接続線をすべて削除する
*
- * @param startX
- * @param startY
- * @param endX
- * @param endY
*/
private void disconnectObjects(float startX, float startY, float endX, float endY)
{
while (keys.hasMoreElements())
{
Integer key = keys.nextElement();
- MeMoMaConnectLineHolder.ObjectConnector line = lineHolder.getLine(key);
- if (line.key > 0)
+ ObjectConnector line = lineHolder.getLine(key);
+ if (line.getKey() > 0)
{
// 線の始点と終点を取り出す
- MeMoMaObjectHolder.PositionObject from = objectHolder.getPosition(line.fromObjectKey);
- MeMoMaObjectHolder.PositionObject to = objectHolder.getPosition(line.toObjectKey);
+ RectF fromRect = objectHolder.getPosition(line.getFromObjectKey()).getRect();
+ RectF toRect = objectHolder.getPosition(line.getToObjectKey()).getRect();
// 線が交差しているかチェックする
- if (checkIntersection(startX, startY, endX, endY, from.rect.centerX(), from.rect.centerY(), to.rect.centerX(), to.rect.centerY()) == true)
+ if (checkIntersection(startX, startY, endX, endY, fromRect.centerX(), fromRect.centerY(), toRect.centerX(), toRect.centerY()))
{
// 線が交差していた! 線を切る!
//Log.v(Main.APP_IDENTIFIER, "CUT LINE [" + from.rect.centerX() + "," + from.rect.centerY() +"]-[" + to.rect.centerX() + "," + to.rect.centerY() + "]");
- lineHolder.disconnectLines(line.key);
+ lineHolder.disconnectLines(line.getKey());
}
}
}
//crossY = y1 + dR * (y2 - y1);
// 交点が線分内にあるかどうかをチェックする
- if ((dR >= 0)&&(dR <= 1)&&(dS >= 0)&&(dS <= 1))
- {
- return (true);
- }
- return (false);
+ return ((dR >= 0)&&(dR <= 1)&&(dS >= 0)&&(dS <= 1));
}
/**
/**
* スライドバーを変更された時の処理
*/
- public void zoomScaleChanged(int progress)
+ private void zoomScaleChanged(int progress)
{
float val = ((float) progress - 50.0f) / 50.0f;
// 表示倍率を変更し、倍率を画面に表示する
drawScale = (float) Math.round(Math.pow(10.0, val) * 10.0) / 10.0f;
- TextView textview = (TextView) parent.findViewById(R.id.ZoomRate);
- textview.setText("x" + drawScale);
+ TextView textview = parent.findViewById(R.id.ZoomRate);
+ String showText = "x" + drawScale;
+ textview.setText(showText);
// 現在の表示領域サイズを取得
float showSizeWidth = screenWidth * drawScale;
editor.putFloat("drawTransX", drawTransX);
editor.putFloat("drawTransY", drawTransY);
editor.putInt("zoomProgress", progress);
- editor.commit();
+ editor.apply();
}
/**
float y = (event.getY() - drawTransY) / drawScale;
// タッチ位置にオブジェクトが存在するか確認する
- MeMoMaObjectHolder.PositionObject position = checkSelectedObject(x, y);
+ PositionObject position = checkSelectedObject(x, y);
if (position != null)
{
// 長押し処理を実施していることを記憶する
zoomScaleChanged(progress);
// 画面描画クラスに再描画を指示する
- final GokigenSurfaceView surfaceView = (GokigenSurfaceView) parent.findViewById(R.id.GraphicView);
+ final GokigenSurfaceView surfaceView = parent.findViewById(R.id.GraphicView);
surfaceView.doDraw();
}
/**
* (ScaleGestureDetector.OnScaleGestureListener の実装)
*
- * @param detector
- * @return
+ *
*/
public boolean onScale(ScaleGestureDetector detector)
{
float scaleFactor = detector.getScaleFactor();
//Log.v(Main.APP_IDENTIFIER, "MeMoMaCanvasDrawer::onScale() : " + scaleFactor + " (" + currentScaleBar + ")");
- /** 画面表示の倍率が変更された! x < 1 : 縮小、 1 < x : 拡大 **/
+ // 画面表示の倍率が変更された! x < 1 : 縮小、 1 < x : 拡大
if (scaleFactor < 1.0f)
{
currentScaleBar = (currentScaleBar == 0) ? 0 : currentScaleBar - 1;
onScaling = false;
// シークバーを設定し、値を記憶する
- final SeekBar seekbar = (SeekBar) parent.findViewById(R.id.ZoomInOut);
+ final SeekBar seekbar = parent.findViewById(R.id.ZoomInOut);
seekbar.setProgress(currentScaleBar);
zoomScaleChanged(currentScaleBar);
}
import android.graphics.Path;
import android.graphics.RectF;
import jp.sourceforge.gokigen.memoma.holders.MeMoMaObjectHolder;
+import jp.sourceforge.gokigen.memoma.holders.PositionObject;
/**
* めもまのオブジェクト・ライン・ラベルを描画するメソッド群
* オブジェクトのラベルを表示する
*
*/
- public static void drawTextLabel(Canvas canvas, Paint paint, MeMoMaObjectHolder.PositionObject pos, RectF region, int displayObjectInformation, float offsetX, float offsetY)
+ public static void drawTextLabel(Canvas canvas, Paint paint, PositionObject pos, RectF region, int displayObjectInformation, float offsetX, float offsetY)
{
// タイトルの先頭部分を表示する場合...
- String labelToShow = pos.label;
+ String labelToShow = pos.getLabel();
if (displayObjectInformation == 0)
{
float width = region.width() - MeMoMaCanvasDrawer.OBJECTLABEL_MARGIN_WIDTH;
- int textLen = paint.breakText(pos.label, true, width, null); // 省略文字を追加するから、そのぶん減らす
+ int textLen = paint.breakText(pos.getLabel(), true, width, null); // 省略文字を追加するから、そのぶん減らす
labelToShow = labelToShow.substring(0, textLen);
- if (!labelToShow.equals(pos.label))
+ if (!labelToShow.equals(pos.getLabel()))
{
// truncate した場合には、省略文字を出す。
labelToShow = labelToShow + "...";
}
}
- if (Paint.Style.valueOf(pos.paintStyle) != Paint.Style.STROKE)
+ if (Paint.Style.valueOf(pos.getPaintStyle()) != Paint.Style.STROKE)
{
// オブジェクトを塗りつぶすのときは、文字の色を設定する
- paint.setColor(pos.labelColor);
+ paint.setColor(pos.getLabelColor());
}
// 文字をちょっと影付きにする
paint.setShadowLayer(0.7f, 0.7f, 0.7f, Color.DKGRAY);
// ユーザチェックの描画
- if (pos.userChecked)
+ if (pos.getUserChecked())
{
canvas.drawText("*", region.centerX(), region.top + (MeMoMaCanvasDrawer.OBJECTLABEL_MARGIN * 2.0f), paint);
}
// 強調表示
- if (pos.strokeWidth != 0.0f)
+ if (pos.getstrokeWidth() != 0.0f)
{
// そのまま表示すると、読めないので、太さを調整し、アンダーラインを引くことにする
paint.setStrokeWidth(0.0f);
float width = region.right - region.left - 12.0f; // 幅
int startChar = 0;
- int endChar = pos.label.length();
+ int endChar = pos.getLabel().length();
do
{
- int textLen = paint.breakText(pos.label, startChar, endChar, true, width, null);
+ int textLen = paint.breakText(pos.getLabel(), startChar, endChar, true, width, null);
canvas.drawText(labelToShow, startChar, (startChar +textLen), posX, posY, paint);
posY = posY - tall;
import android.widget.ListView;
import android.widget.Toast;
-import jp.sourceforge.gokigen.memoma.fileio.ExternalStorageFileUtility;
+import jp.sourceforge.gokigen.memoma.holders.OperationHistoryHolder;
+import jp.sourceforge.gokigen.memoma.holders.PositionObject;
+import jp.sourceforge.gokigen.memoma.io.ExternalStorageFileUtility;
import jp.sourceforge.gokigen.memoma.dialogs.FileSelectionDialog;
import jp.sourceforge.gokigen.memoma.Main;
import jp.sourceforge.gokigen.memoma.holders.MeMoMaConnectLineHolder;
-import jp.sourceforge.gokigen.memoma.fileio.MeMoMaFileExportCsvProcess;
-import jp.sourceforge.gokigen.memoma.fileio.MeMoMaFileImportCsvProcess;
-import jp.sourceforge.gokigen.memoma.fileio.MeMoMaFileLoadingProcess;
+import jp.sourceforge.gokigen.memoma.io.MeMoMaFileExportCsvProcess;
+import jp.sourceforge.gokigen.memoma.io.MeMoMaFileImportCsvProcess;
+import jp.sourceforge.gokigen.memoma.io.MeMoMaFileLoadingProcess;
import jp.sourceforge.gokigen.memoma.holders.MeMoMaObjectHolder;
import jp.sourceforge.gokigen.memoma.R;
-import jp.sourceforge.gokigen.memoma.SharedIntentInvoker;
+import jp.sourceforge.gokigen.memoma.io.SharedIntentInvoker;
import jp.sourceforge.gokigen.memoma.listitem.SymbolListArrayAdapter;
import jp.sourceforge.gokigen.memoma.listitem.SymbolListArrayItem;
*/
ExtensionActivityListener(Activity argument)
{
+ OperationHistoryHolder historyHolder = new OperationHistoryHolder();
parent = argument;
fileUtility = new ExternalStorageFileUtility(Main.APP_BASEDIR);
- objectHolder = new MeMoMaObjectHolder(parent, new MeMoMaConnectLineHolder());
+ objectHolder = new MeMoMaObjectHolder(parent, new MeMoMaConnectLineHolder(historyHolder), historyHolder);
}
/**
* 起動時にデータを準備する
while (keys.hasMoreElements())
{
Integer key = keys.nextElement();
- MeMoMaObjectHolder.PositionObject pos = objectHolder.getPosition(key);
+ PositionObject pos = objectHolder.getPosition(key);
// アイコンの決定
- int objectStyleIcon = MeMoMaObjectHolder .getObjectDrawStyleIcon(pos.drawStyle);
+ int objectStyleIcon = MeMoMaObjectHolder .getObjectDrawStyleIcon(pos.getDrawStyle());
// ユーザチェックの有無表示
- int userCheckedIcon = (pos.userChecked) ? R.drawable.btn_checked : R.drawable.btn_notchecked;
+ int userCheckedIcon = (pos.getUserChecked()) ? R.drawable.btn_checked : R.drawable.btn_notchecked;
// TODO: アイテム選択時の情報エリアは(ArrayItem側には)用意しているが未使用。
- SymbolListArrayItem listItem = new SymbolListArrayItem(userCheckedIcon, pos.label, pos.detail, "", objectStyleIcon);
+ SymbolListArrayItem listItem = new SymbolListArrayItem(userCheckedIcon, pos.getLabel(), pos.getDetail(), "", objectStyleIcon);
listItems.add(listItem);
}
--- /dev/null
+package jp.sourceforge.gokigen.memoma.holders;
+
+interface IOperationHistoryHolder
+{
+ enum ChangeKind
+ {
+ RECTANGLE,
+ DRAW_STYLE,
+ ICON,
+ LABEL,
+ DETAIL,
+ USER_CHECKED,
+ LABEL_COLOR,
+ OBJECT_COLOR,
+ PAINT_STYLE,
+ STROKE_WIDTH,
+ FONT_SIZE,
+ NEW_OBJECT,
+ NEW_CONNECT_LINE,
+ CONNECT_LINE_FROM_KEY,
+ CONNECT_LINE_TO_KEY,
+ CONNECT_LINE_STYLE,
+ CONNECT_LINE_SHAPE,
+ CONNECT_LINE_THICKNESS,
+ };
+
+
+ void addHistory(int key, ChangeKind kind, Object object);
+ void undo();
+
+}
import android.util.Log;
import jp.sourceforge.gokigen.memoma.Main;
-import jp.sourceforge.gokigen.memoma.holders.LineStyleHolder;
/**
*
* @author MRSa
*
- */public class MeMoMaConnectLineHolder
+ */
+public class MeMoMaConnectLineHolder
{
- public static final int ID_NOTSPECIFY = -1;
-
- /**
- * オブジェクト間を接続するクラス
- *
- * @author MRSa
- *
- */
- public class ObjectConnector
- {
- public Integer key;
- public Integer fromObjectKey;
- public Integer toObjectKey;
- public Integer lineStyle;
- public Integer lineShape;
- public Integer lineThickness;
-/**
- public int fromShape;
- public int toShape;
- public String fromString;
- public String toString;
-**/
- };
-
- private Hashtable<Integer, ObjectConnector> connectLines = null;
- private Integer serialNumber = 1;
-
- public MeMoMaConnectLineHolder()
- {
- connectLines = new Hashtable<Integer, ObjectConnector>();
- connectLines.clear();
- }
-
- public Enumeration<Integer> getLineKeys()
- {
- return (connectLines.keys());
- }
-
- public ObjectConnector getLine(Integer key)
- {
- return (connectLines.get(key));
- }
-
- public boolean disconnectLines(Integer key)
- {
- connectLines.remove(key);
- Log.v(Main.APP_IDENTIFIER, "DISCONNECT LINES : " + key);
- return (true);
- }
-
- public void setSerialNumber(int id)
- {
- serialNumber = (id == ID_NOTSPECIFY) ? ++serialNumber : id;
- }
-
- public int getSerialNumber()
- {
- return (serialNumber);
- }
-
- public void removeAllLines()
- {
- connectLines.clear();
- serialNumber = 1;
- }
-
- public void dumpConnectLine(ObjectConnector conn)
- {
- if (conn == null)
- {
- return;
- }
- Log.v(Main.APP_IDENTIFIER, "LINE " + conn.key + " [" + conn.fromObjectKey + " -> " + conn.toObjectKey + "] ");
- }
-
- /**
- * keyToRemove で指定されたobjectの接続をすべて削除する
- *
- * @param keyToRemove
- */
- public void removeAllConnection(Integer keyToRemove)
- {
- Enumeration<Integer> keys = connectLines.keys();
- while (keys.hasMoreElements())
- {
- Integer key = keys.nextElement();
- ObjectConnector connector = connectLines.get(key);
- if ((connector.fromObjectKey == keyToRemove)||(connector.toObjectKey == keyToRemove))
- {
- // 削除するキーが見つかった!
- connector.key = -1; // 一応...大丈夫だとは思うけど
- connectLines.remove(key);
- }
- }
- }
-
- public ObjectConnector createLine(int id)
- {
- ObjectConnector connector = new ObjectConnector();
- connector.key = id;
- connector.fromObjectKey = 1;
- connector.toObjectKey = 1;
- connector.lineStyle = LineStyleHolder.LINESTYLE_STRAIGHT_NO_ARROW;
- connector.lineShape = LineStyleHolder.LINESHAPE_NORMAL;
- connector.lineThickness = LineStyleHolder.LINETHICKNESS_THIN;
-
-/**
- connector.fromShape = 0;
- connector.toShape = 0;
- connector.fromString = "";
- connector.toString = "";
-**/
- connectLines.put(id, connector);
- return (connector);
- }
-
- public ObjectConnector setLines(Integer fromKey, Integer toKey, LineStyleHolder lineHolder)
- {
- ObjectConnector connector = new ObjectConnector();
- connector.key = serialNumber;
- connector.fromObjectKey = fromKey;
- connector.toObjectKey = toKey;
- connector.lineStyle = lineHolder.getLineStyle();
- connector.lineShape = lineHolder.getLineShape();
- connector.lineThickness = lineHolder.getLineThickness();
-/**
- connector.fromShape = 0;
- connector.toShape = 0;
- connector.fromString = "";
- connector.toString = "";
-**/
- connectLines.put(serialNumber, connector);
- serialNumber++;
- return (connector);
- }
+ private final IOperationHistoryHolder historyHolder;
+ public static final int ID_NOTSPECIFY = -1;
+ private Hashtable<Integer, ObjectConnector> connectLines;
+ private Integer serialNumber = 1;
+
+ public MeMoMaConnectLineHolder(IOperationHistoryHolder historyHolder)
+ {
+ this.historyHolder = historyHolder;
+ connectLines = new Hashtable<>();
+ connectLines.clear();
+ }
+
+ public Enumeration<Integer> getLineKeys()
+ {
+ return (connectLines.keys());
+ }
+
+ public ObjectConnector getLine(Integer key)
+ {
+ return (connectLines.get(key));
+ }
+
+ public boolean disconnectLines(Integer key)
+ {
+ connectLines.remove(key);
+ Log.v(Main.APP_IDENTIFIER, "DISCONNECT LINES : " + key);
+ return (true);
+ }
+
+ public void setSerialNumber(int id)
+ {
+ serialNumber = (id == ID_NOTSPECIFY) ? ++serialNumber : id;
+ }
+
+ public int getSerialNumber()
+ {
+ return (serialNumber);
+ }
+
+ public void removeAllLines()
+ {
+ connectLines.clear();
+ serialNumber = 1;
+ }
+
+ public void dumpConnectLine(ObjectConnector conn)
+ {
+ if (conn == null)
+ {
+ return;
+ }
+ Log.v(Main.APP_IDENTIFIER, "LINE " + conn.getKey() + " [" + conn.getFromObjectKey() + " -> " + conn.getToObjectKey() + "] ");
+ }
+
+ /**
+ * keyToRemove で指定されたobjectの接続をすべて削除する
+ *
+ * @param keyToRemove\
+ */
+ public void removeAllConnection(Integer keyToRemove)
+ {
+ Enumeration<Integer> keys = connectLines.keys();
+ while (keys.hasMoreElements())
+ {
+ Integer key = keys.nextElement();
+ ObjectConnector connector = connectLines.get(key);
+ if ((connector.getFromObjectKey() == keyToRemove)||(connector.getToObjectKey() == keyToRemove))
+ {
+ // 削除するキーが見つかった!
+ connectLines.remove(key);
+ }
+ }
+ }
+
+ public ObjectConnector createLine(int id)
+ {
+ ObjectConnector connector = new ObjectConnector(id, 1, 1, LineStyleHolder.LINESTYLE_STRAIGHT_NO_ARROW, LineStyleHolder.LINESHAPE_NORMAL, LineStyleHolder.LINETHICKNESS_THIN, historyHolder);
+ connectLines.put(id, connector);
+ return (connector);
+ }
+
+ public ObjectConnector setLines(Integer fromKey, Integer toKey, LineStyleHolder lineHolder)
+ {
+ ObjectConnector connector = new ObjectConnector(serialNumber, fromKey, toKey, lineHolder.getLineStyle(), lineHolder.getLineShape(), lineHolder.getLineThickness(), historyHolder);
+
+ connectLines.put(serialNumber, connector);
+ serialNumber++;
+ return (connector);
+ }
}
import android.content.Context;
import android.widget.ArrayAdapter;
-import jp.sourceforge.gokigen.memoma.fileio.ExternalStorageFileUtility;
+import jp.sourceforge.gokigen.memoma.io.ExternalStorageFileUtility;
/**
* めもまのデータファイル名を保持するクラス (ArrayAdapterを拡張)
*/
public class MeMoMaDataFileHolder extends ArrayAdapter<String> implements FilenameFilter
{
- private ExternalStorageFileUtility fileUtility = null;
- private String fileExtension = "";
+ private ExternalStorageFileUtility fileUtility;
+ private String fileExtension;
/**
* コンストラクタ
try {
for (int index = 0; index < dirFileList.length; index++) {
String fileName = dirFileList[index].substring(0, dirFileList[index].indexOf(fileExtension));
- if (fileName.contentEquals(currentFileName) == true) // ファイル先頭にない場合は追加する。
+ if (fileName.contentEquals(currentFileName)) // ファイル先頭にない場合は追加する。
{
// 選択したインデックスを設定する。
outputIndex = index;
*/
public boolean accept(File dir, String filename)
{
- return (filename.endsWith(fileExtension) ? true : false);
+ return (filename.endsWith(fileExtension));
}
}
private MeMoMaConnectLineHolder connectLineHolder = null;
- /**
- * オブジェクトの情報
- *
- * @author MRSa
- *
- */
- public class PositionObject
- {
- private Integer key; // オブジェクト識別子 (変更不可)
- public RectF rect; // オブジェクトの大きさ
- public int drawStyle; // オブジェクトの形状
-
- public int icon; // オブジェクトのアイコン
- public String label; // オブジェクトの表示ラベル
- public String detail; // オブジェクトの説明
- //public String backgroundUri; // オブジェクトの背景画像
- //public String otherInfoUri; // 補足(写真とかへのURI)
- //public String objectStatus; // オブジェクトの状態
- public boolean userChecked; // ユーザチェックボックス
-
- public int labelColor; // オブジェクト内に表示する色
- public int objectColor; // オブジェクトの色
- public String paintStyle; // オブジェクトの表示方法 (枠線のみ、塗りつぶし、塗りつぶしと枠線)
- public float strokeWidth; // 枠線の太さ
- public float fontSize; // フォントサイズ
-
- /**
- * コンストラクタ (キーを設定する)
- * @param id
- */
- public PositionObject(int id)
- {
- key = id;
- }
-
- /**
- * オブジェクトのキーを取得する
- * @return
- */
- public Integer getKey()
- {
- return (key);
- }
- };
-
private Hashtable<Integer, PositionObject> objectPoints = null;
private Integer serialNumber = 1;
private String dataTitle = "";
private String background = "";
- private Context parent = null;
+ private Context parent;
+ private final IOperationHistoryHolder historyHolder;
- public MeMoMaObjectHolder(Context context, MeMoMaConnectLineHolder lineHolder)
+ public MeMoMaObjectHolder(Context context, MeMoMaConnectLineHolder lineHolder, IOperationHistoryHolder historyHolder)
{
- objectPoints = new Hashtable<Integer, PositionObject>();
+ objectPoints = new Hashtable<>();
connectLineHolder = lineHolder;
parent = context;
+ this.historyHolder = historyHolder;
}
/**
* データの有無を見る (true の場合、データはない。)
*
- * @return
+ *
*/
public boolean isEmpty()
- {
- if ((connectLineHolder == null)||(objectPoints == null))
- {
- return (true);
- }
- return (objectPoints.isEmpty());
+ {
+ return (((connectLineHolder == null)||(objectPoints == null))||(objectPoints.isEmpty()));
}
public MeMoMaConnectLineHolder getConnectLineHolder()
{
return;
}
- Log.v(Main.APP_IDENTIFIER, "[" + position.rect.left + "," + position.rect.top + "][" + position.rect.right + "," + position.rect.bottom + "] " + "label : " + position.label + " detail : " + position.detail);
+ RectF posRect = position.getRect();
+ Log.v(Main.APP_IDENTIFIER, "[" + posRect.left + "," + posRect.top + "][" + posRect.right + "," + posRect.bottom + "] " + "label : " + position.getLabel() + " detail : " + position.getDetail());
}
/**
* オブジェクトを複製する。
*
- * @param key
- * @return
+ *
+ *
*/
public PositionObject duplicatePosition(int key)
{
// 元のオブジェクトが見つからなかったので、何もせずに戻る
return (null);
}
- PositionObject position = new PositionObject(serialNumber);
- position.rect = new RectF();
- position.rect.left = orgPosition.rect.left + DUPLICATEPOSITION_MARGIN;
- position.rect.right = orgPosition.rect.right + DUPLICATEPOSITION_MARGIN;
- position.rect.top = orgPosition.rect.top + DUPLICATEPOSITION_MARGIN;
- position.rect.bottom = orgPosition.rect.bottom + DUPLICATEPOSITION_MARGIN;
- position.drawStyle = orgPosition.drawStyle;
- position.icon = orgPosition.icon;
- position.label = orgPosition.label;
- position.detail = orgPosition.detail;
- //position.otherInfoUri = orgPosition.otherInfoUri;
- //position.backgroundUri = orgPosition.backgroundUri;
- //position.objectStatus = orgPosition.objectStatus;
- position.userChecked = orgPosition.userChecked;
- position.objectColor = orgPosition.objectColor;
- position.labelColor = orgPosition.labelColor;
- position.paintStyle = orgPosition.paintStyle;
- position.strokeWidth = orgPosition.strokeWidth;
- position.fontSize = orgPosition.fontSize;
+ RectF orgRect = orgPosition.getRect();
+ PositionObject position = new PositionObject(serialNumber,
+ new RectF(orgRect.left + DUPLICATEPOSITION_MARGIN, orgRect.top + DUPLICATEPOSITION_MARGIN, orgRect.right + DUPLICATEPOSITION_MARGIN, orgRect.bottom + DUPLICATEPOSITION_MARGIN),
+ orgPosition.getDrawStyle(),
+ orgPosition.getIcon(),
+ orgPosition.getLabel(),
+ orgPosition.getDetail(),
+ orgPosition.getUserChecked(),
+ orgPosition.getLabelColor(),
+ orgPosition.getObjectColor(),
+ orgPosition.getPaintStyle(),
+ orgPosition.getstrokeWidth(),
+ orgPosition.getFontSize(),
+ historyHolder);
objectPoints.put(serialNumber, position);
serialNumber++;
return (position);
public PositionObject createPosition(int id)
{
- PositionObject position = new PositionObject(id);
- position.rect = new RectF();
- position.rect.top = 0;
- position.rect.bottom = OBJECTSIZE_DEFAULT_Y;
- position.rect.left = 0;
- position.rect.right = OBJECTSIZE_DEFAULT_X;
- position.drawStyle = MeMoMaObjectHolder.DRAWSTYLE_RECTANGLE;
- position.icon = 0;
- position.label = "";
- position.detail = "";
- //position.otherInfoUri = "";
- //position.backgroundUri = "";
- //position.objectStatus = "";
- position.userChecked = false;
- position.objectColor = Color.WHITE;
- position.labelColor = Color.WHITE;
- position.paintStyle = Paint.Style.STROKE.toString();
- position.strokeWidth = STOROKE_NORMAL_WIDTH;
- position.fontSize = FONTSIZE_DEFAULT;
+ PositionObject position = new PositionObject(id,
+ new RectF(0, 0, OBJECTSIZE_DEFAULT_X, OBJECTSIZE_DEFAULT_Y),
+ MeMoMaObjectHolder.DRAWSTYLE_RECTANGLE,
+ 0,
+ "",
+ "",
+ false,
+ Color.WHITE,
+ Color.WHITE,
+ Paint.Style.STROKE.toString(),
+ STOROKE_NORMAL_WIDTH,
+ FONTSIZE_DEFAULT,
+ historyHolder);
objectPoints.put(id, position);
return (position);
}
public PositionObject createPosition(float x, float y, int drawStyle)
{
PositionObject position = createPosition(serialNumber);
- position.rect.left = position.rect.left + x;
- position.rect.right = position.rect.right + x;
- position.rect.top = position.rect.top + y;
- position.rect.bottom = position.rect.bottom + y;
- position.drawStyle = drawStyle;
+ RectF posRect = position.getRect();
+ position.setRectLeft(posRect.left + x);
+ position.setRectRight(posRect.right + x);
+ position.setRectTop(posRect.top + y);
+ position.setRectBottom(posRect.bottom + y);
+ position.setDrawStyle(drawStyle);
serialNumber++;
return (position);
}
// 元のオブジェクトが見つからなかったので、何もせずに戻る
return;
}
- float width = position.rect.right - position.rect.left;
- float height = position.rect.bottom - position.rect.top;
+ RectF posRect = position.getRect();
+ float width = posRect.right - posRect.left;
+ float height = posRect.bottom - posRect.top;
if (((width + (OBJECTSIZE_STEP_X * 2.0f)) > OBJECTSIZE_MAXIMUM_X)||((height + (OBJECTSIZE_STEP_Y * 2.0f)) > OBJECTSIZE_MAXIMUM_Y))
{
// 拡大リミットだった。。。拡大しない
Toast.makeText(parent, outputMessage, Toast.LENGTH_SHORT).show();
return;
}
- position.rect.left = position.rect.left - OBJECTSIZE_STEP_X;
- position.rect.right = position.rect.right + OBJECTSIZE_STEP_X;
- position.rect.top = position.rect.top - OBJECTSIZE_STEP_Y;
- position.rect.bottom = position.rect.bottom + OBJECTSIZE_STEP_Y;
+ position.setRectLeft(posRect.left - OBJECTSIZE_STEP_X);
+ position.setRectRight(posRect.right + OBJECTSIZE_STEP_X);
+ position.setRectTop(posRect.top - OBJECTSIZE_STEP_Y);
+ position.setRectBottom(posRect.bottom + OBJECTSIZE_STEP_Y);
}
/**
* オブジェクトのサイズを縮小する
*
- * @param key
+ *
*/
public void shrinkObjectSize(Integer key)
{
// 元のオブジェクトが見つからなかったので、何もせずに戻る
return;
}
- float width = position.rect.right - position.rect.left;
- float height = position.rect.bottom - position.rect.top;
+ RectF posRect = position.getRect();
+ float width = posRect.right - posRect.left;
+ float height = posRect.bottom - posRect.top;
if (((width - (OBJECTSIZE_STEP_X * 2.0f)) < OBJECTSIZE_MINIMUM_X)||((height - (OBJECTSIZE_STEP_Y * 2.0f)) < OBJECTSIZE_MINIMUM_Y))
{
// 縮小リミットだった。。。縮小しない
Toast.makeText(parent, outputMessage, Toast.LENGTH_SHORT).show();
return;
}
- position.rect.left = position.rect.left + OBJECTSIZE_STEP_X;
- position.rect.right = position.rect.right - OBJECTSIZE_STEP_X;
- position.rect.top = position.rect.top + OBJECTSIZE_STEP_Y;
- position.rect.bottom = position.rect.bottom - OBJECTSIZE_STEP_Y;
+ position.setRectLeft(posRect.left + OBJECTSIZE_STEP_X);
+ position.setRectRight(posRect.right - OBJECTSIZE_STEP_X);
+ position.setRectTop(posRect.top + OBJECTSIZE_STEP_Y);
+ position.setRectBottom(posRect.bottom - OBJECTSIZE_STEP_Y);
}
public MeMoMaConnectLineHolder getLineHolder()
}
return (icon);
}
-
}
--- /dev/null
+package jp.sourceforge.gokigen.memoma.holders;
+
+import android.support.annotation.NonNull;
+
+/**
+ * オブジェクト間を接続するクラス
+ *
+ * @author MRSa
+ *
+ */
+public class ObjectConnector
+{
+ private final IOperationHistoryHolder historyHolder;
+ private final Integer key;
+ private Integer fromObjectKey;
+ private Integer toObjectKey;
+ private Integer lineStyle;
+ private Integer lineShape;
+ private Integer lineThickness;
+
+ ObjectConnector(int key, int fromObjectKey, int toObjectkey, int lineStyle, int lineShape, int lineThickness, @NonNull IOperationHistoryHolder historyHolder)
+ {
+ this.key = key;
+ this.fromObjectKey = fromObjectKey;
+ this.toObjectKey = toObjectkey;
+ this.lineStyle = lineStyle;
+ this.lineShape = lineShape;
+ this.lineThickness = lineThickness;
+ this.historyHolder = historyHolder;
+ historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.NEW_CONNECT_LINE, this);
+ }
+
+ public int getKey()
+ {
+ return (key);
+ }
+
+ public int getFromObjectKey()
+ {
+ return (fromObjectKey);
+ }
+
+ public int getToObjectKey()
+ {
+ return (toObjectKey);
+ }
+
+ public int getLineStyle()
+ {
+ return (lineStyle);
+ }
+
+ public int getLineShape()
+ {
+ return (lineShape);
+ }
+
+ public int getLineThickness()
+ {
+ return (lineThickness);
+ }
+
+ public void setFromObjectKey(int value)
+ {
+ historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.CONNECT_LINE_FROM_KEY, fromObjectKey);
+ fromObjectKey = value;
+ }
+
+ public void setToObjectKey(int value)
+ {
+ historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.CONNECT_LINE_TO_KEY, toObjectKey);
+ toObjectKey = value;
+ }
+
+ public void setLineStyle(int value)
+ {
+ historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.CONNECT_LINE_STYLE, lineStyle);
+ lineStyle = value;
+ }
+
+ public void setLineShape(int value)
+ {
+ historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.CONNECT_LINE_SHAPE, lineShape);
+ lineShape = value;
+ }
+
+ public void setLineThickness(int value)
+ {
+ historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.CONNECT_LINE_THICKNESS, lineThickness);
+ lineThickness = value;
+ }
+}
--- /dev/null
+package jp.sourceforge.gokigen.memoma.holders;
+
+import android.content.Context;
+import android.util.Log;
+
+public class OperationHistoryHolder implements IOperationHistoryHolder
+{
+ private final String TAG = toString();
+
+ public OperationHistoryHolder()
+ {
+
+ }
+
+ public void addHistory(int key, ChangeKind kind, Object object)
+ {
+ Log.v(TAG, "addHistory() KEY : " + key + " KIND : " + kind.toString() + " OBJ : " + object.toString());
+ }
+
+ public void undo()
+ {
+ Log.v(TAG, "undo() ");
+
+ }
+}
--- /dev/null
+package jp.sourceforge.gokigen.memoma.holders;
+
+import android.graphics.RectF;
+import android.support.annotation.NonNull;
+
+public class PositionObject
+{
+ private final Integer key; // オブジェクト識別子 (変更不可)
+ private final IOperationHistoryHolder historyHolder; // 履歴を保持するところ
+
+ private RectF rect; // オブジェクトの大きさ
+ private int drawStyle; // オブジェクトの形状
+
+ private int icon; // オブジェクトのアイコン
+ private String label; // オブジェクトの表示ラベル
+ private String detail; // オブジェクトの説明
+ //public String backgroundUri; // オブジェクトの背景画像
+ //public String otherInfoUri; // 補足(写真とかへのURI)
+ //public String objectStatus; // オブジェクトの状態
+ private boolean userChecked; // ユーザチェックボックス
+
+ private int labelColor; // オブジェクト内に表示する色
+ private int objectColor; // オブジェクトの色
+ private String paintStyle; // オブジェクトの表示方法 (枠線のみ、塗りつぶし、塗りつぶしと枠線)
+ private float strokeWidth; // 枠線の太さ
+ private float fontSize; // フォントサイズ
+
+ /**
+ * コンストラクタ (キーを設定する)
+ *
+ */
+ 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)
+ {
+ key = id;
+ this.rect = rect;
+ this.drawStyle = drawStyle;
+ this.icon = icon;
+ this.label = label;
+ this.detail = detail;
+ this.userChecked = userChecked;
+ this.labelColor = labelColor;
+ this.objectColor = objectColor;
+ this.paintStyle = paintStyle;
+ this.strokeWidth = strokeWidth;
+ this.fontSize = fontSize;
+ this.historyHolder = historyHolder;
+ historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.NEW_OBJECT, this);
+ }
+
+ /**
+ * オブジェクトのキーを取得する
+ *
+ */
+ public Integer getKey()
+ {
+ return (key);
+ }
+
+ public void setRect(RectF rectF)
+ {
+ historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.RECTANGLE, rect);
+ rect = rectF;
+ }
+
+ public void setRectTop(float value)
+ {
+ historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.RECTANGLE, rect);
+ rect.top = value;
+ }
+
+ public void setRectLeft(float value)
+ {
+ historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.RECTANGLE, rect);
+ rect.left = value;
+ }
+
+ public void setRectRight(float value)
+ {
+ historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.RECTANGLE, rect);
+ rect.right = value;
+ }
+
+ public void setRectBottom(float value)
+ {
+ historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.RECTANGLE, rect);
+ rect.bottom = value;
+ }
+
+ public void setDrawStyle(int value)
+ {
+ historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.DRAW_STYLE, drawStyle);
+ drawStyle = value;
+ }
+
+ public void setIcon(int value)
+ {
+ historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.ICON, icon);
+ icon = value;
+ }
+
+ public void setLabel(String value)
+ {
+ historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.LABEL, label);
+ label = value;
+ }
+
+ public void setDetail(String value)
+ {
+ historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.DETAIL, detail);
+ detail = value;
+ }
+
+ public void setUserChecked(boolean value)
+ {
+ historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.USER_CHECKED, userChecked);
+ userChecked = value;
+ }
+
+ public void setLabelColor(int value)
+ {
+ historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.LABEL_COLOR, labelColor);
+ labelColor = value;
+ }
+
+ public void setObjectColor(int value)
+ {
+ historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.OBJECT_COLOR, objectColor);
+ objectColor = value;
+ }
+
+ public void setPaintStyle(String value)
+ {
+ historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.PAINT_STYLE, paintStyle);
+ paintStyle = value;
+ }
+
+ public void setStrokeWidth(float value)
+ {
+ historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.STROKE_WIDTH, strokeWidth);
+ strokeWidth = value;
+ }
+
+ public void setFontSize(float value)
+ {
+ historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.FONT_SIZE, fontSize);
+ fontSize = value;
+ }
+
+ public void setRectOffsetTo(float newLeft, float newTop)
+ {
+ historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.RECTANGLE, rect);
+ rect.offsetTo(newLeft, newTop);
+ }
+
+ public RectF getRect()
+ {
+ return (rect);
+ }
+
+ public int getDrawStyle()
+ {
+ return (drawStyle);
+ }
+
+ public int getIcon()
+ {
+ return (icon);
+ }
+
+ public String getLabel()
+ {
+ return (label);
+ }
+
+ public String getDetail()
+ {
+ return (detail);
+ }
+
+ public boolean getUserChecked()
+ {
+ return (userChecked);
+ }
+
+ public int getLabelColor()
+ {
+ return (labelColor);
+ }
+
+ public int getObjectColor()
+ {
+ return (objectColor);
+ }
+
+ public String getPaintStyle()
+ {
+ return (paintStyle);
+ }
+
+ public float getstrokeWidth()
+ {
+ return (strokeWidth);
+ }
+
+ public float getFontSize()
+ {
+ return (fontSize);
+ }
+}
-package jp.sourceforge.gokigen.memoma.fileio;
+package jp.sourceforge.gokigen.memoma.io;
import android.os.Environment;
import android.util.Log;
-package jp.sourceforge.gokigen.memoma.fileio;
+package jp.sourceforge.gokigen.memoma.io;
import java.io.File;
import java.io.InputStream;
-package jp.sourceforge.gokigen.memoma.fileio;
+package jp.sourceforge.gokigen.memoma.io;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import android.util.Log;
import android.widget.Toast;
-import jp.sourceforge.gokigen.memoma.GokigenSurfaceView;
+import jp.sourceforge.gokigen.memoma.drawers.GokigenSurfaceView;
import jp.sourceforge.gokigen.memoma.Main;
-import jp.sourceforge.gokigen.memoma.MeMoMaListener;
import jp.sourceforge.gokigen.memoma.R;
-import jp.sourceforge.gokigen.memoma.SharedIntentInvoker;
import jp.sourceforge.gokigen.memoma.drawers.MeMoMaCanvasDrawer;
import jp.sourceforge.gokigen.memoma.holders.MeMoMaDataFileHolder;
import jp.sourceforge.gokigen.memoma.holders.MeMoMaObjectHolder;
public class MeMoMaDataInOutManager implements MeMoMaFileSavingProcess.ISavingStatusHolder, MeMoMaFileSavingProcess.IResultReceiver, MeMoMaFileLoadingProcess.IResultReceiver, ActionBar.OnNavigationListener, ObjectLayoutCaptureExporter.ICaptureLayoutExporter
{
- private Activity parent = null;
+ private Activity parent;
private MeMoMaObjectHolder objectHolder = null;
- private ExternalStorageFileUtility fileUtility = null;
+ private ExternalStorageFileUtility fileUtility;
private MeMoMaDataFileHolder dataFileHolder = null;
private boolean isSaving = false;
* ファイルのエクスポート結果を受け取る
*
*/
- public void onCaptureLayoutExportedResult(String exportedFileName, String detail)
+ public void onCaptureLayoutExportedResult(String exportedFileName, String detail, int id)
{
Log.v(Main.APP_IDENTIFIER, "MeMoMaDataInOutManager::onCaptureExportedResult() '" + objectHolder.getDataTitle() +"' : " + detail);
Uri insertedImage = resolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
if (insertedImage != null)
{
- shareContent(insertedImage);
+ shareContent(insertedImage, id);
}
}
catch (Exception e)
* エクスポートしたファイルを共有する
*
*/
- private void shareContent(Uri imageName)
+ private void shareContent(Uri imageName, int id)
{
String message = "";
try
message = message + "number of objects : " + objectHolder.getCount() + "\n";
// Share Intentを発行する。
- SharedIntentInvoker.shareContent(parent, MeMoMaListener.MENU_ID_SHARE, title, message, imageName, "image/png");
+ SharedIntentInvoker.shareContent(parent, id, title, message, imageName, "image/png");
}
catch (Exception ex)
{
-package jp.sourceforge.gokigen.memoma.fileio;
+package jp.sourceforge.gokigen.memoma.io;
import java.io.File;
import java.io.FileWriter;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Enumeration;
+import java.util.Locale;
import android.app.ProgressDialog;
import android.content.Context;
+import android.graphics.RectF;
import android.os.AsyncTask;
import android.util.Log;
import jp.sourceforge.gokigen.memoma.Main;
import jp.sourceforge.gokigen.memoma.R;
import jp.sourceforge.gokigen.memoma.holders.MeMoMaObjectHolder;
+import jp.sourceforge.gokigen.memoma.holders.PositionObject;
/**
* データをファイルに保存するとき用 アクセスラッパ (非同期処理を実行)
- *
+ *
* AsyncTask
* MeMoMaObjectHolder : 実行時に渡すクラス(Param)
* Integer : 途中経過を伝えるクラス(Progress)
* String : 処理結果を伝えるクラス(Result)
- *
+ *
* @author MRSa
*
*/
public class MeMoMaFileExportCsvProcess extends AsyncTask<MeMoMaObjectHolder, Integer, String>
-{
- private IResultReceiver receiver = null;
- private ExternalStorageFileUtility fileUtility = null;
- private String exportedFileName = null;
-
- ProgressDialog savingDialog = null;
-
- /**
- * コンストラクタ
- */
+{
+ private IResultReceiver receiver;
+ private ExternalStorageFileUtility fileUtility;
+ private String exportedFileName = null;
+
+ private ProgressDialog savingDialog;
+
+ /**
+ * コンストラクタ
+ */
public MeMoMaFileExportCsvProcess(Context context, ExternalStorageFileUtility utility, IResultReceiver resultReceiver)
{
- receiver = resultReceiver;
- fileUtility = utility;
+ receiver = resultReceiver;
+ fileUtility = utility;
// プログレスダイアログ(「保存中...」)を表示する。
- savingDialog = new ProgressDialog(context);
- savingDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
- savingDialog.setMessage(context.getString(R.string.dataSaving));
- savingDialog.setIndeterminate(true);
- savingDialog.setCancelable(false);
- savingDialog.show();
-
- /** ファイルをバックアップするディレクトリを作成する **/
- File dir = new File(fileUtility.getGokigenDirectory() + "/exported");
- dir.mkdir();
-
+ savingDialog = new ProgressDialog(context);
+ savingDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
+ savingDialog.setMessage(context.getString(R.string.dataSaving));
+ savingDialog.setIndeterminate(true);
+ savingDialog.setCancelable(false);
+ savingDialog.show();
+
+ // ファイルをバックアップするディレクトリを作成する
+ File dir = new File(fileUtility.getGokigenDirectory() + "/exported");
+ if (!dir.mkdir())
+ {
+ Log.v(toString(), "mkDir() fail. : " + dir.getAbsolutePath());
+ }
}
-
+
/**
* 非同期処理実施前の前処理
- *
+ *
*/
@Override
protected void onPreExecute()
{
}
-
+
/**
* データを(CSV形式で)保管する。
- *
- * @param fileName
- * @param objectHolder
- * @return
+ *
*/
private String exportToCsvFile(String fileName, MeMoMaObjectHolder objectHolder)
{
- String resultMessage = "";
+ String resultMessage = "";
try
{
- // エクスポートするファイル名を決定する
+ // エクスポートするファイル名を決定する
Calendar calendar = Calendar.getInstance();
- SimpleDateFormat outFormat = new SimpleDateFormat("yyyyMMddHHmmss");
+ SimpleDateFormat outFormat = new SimpleDateFormat("yyyyMMddHHmmss", Locale.US);
exportedFileName = fileName + "_" + outFormat.format(calendar.getTime()) + ".csv";
- FileWriter writer = new FileWriter(new File(exportedFileName));
-
- // データのタイトルを出力
- String str = "";
- str = "; label,detail,userChecked,shape,style,centerX,centerY,width,height,;!<_$ (';!<_$' is a record Separator)\r\n";
+ FileWriter writer = new FileWriter(new File(exportedFileName));
+
+ // データのタイトルを出力
+ String str = "; label,detail,userChecked,shape,style,centerX,centerY,width,height,;!<_$ (';!<_$' is a record Separator)\r\n";
writer.write(str);
-
- // オブジェクトの出力 (保持しているものをすべて表示する)
- Enumeration<Integer> keys = objectHolder.getObjectKeys();
+
+ // オブジェクトの出力 (保持しているものをすべて表示する)
+ Enumeration<Integer> keys = objectHolder.getObjectKeys();
while (keys.hasMoreElements())
{
Integer key = keys.nextElement();
- MeMoMaObjectHolder.PositionObject pos = objectHolder.getPosition(key);
+ PositionObject pos = objectHolder.getPosition(key);
+ RectF posRect = pos.getRect();
// TODO: 絞り込み条件がある場合には、その条件に従ってしぼり込む必要あり。
str = "";
- str = str + "\"" + pos.label + "\"";
- str = str + ",\"" + pos.detail + "\"";
- if (pos.userChecked == true)
+ str = str + "\"" + pos.getLabel() + "\"";
+ str = str + ",\"" + pos.getDetail() + "\"";
+ if (pos.getUserChecked())
{
- str = str + ",True";
+ str = str + ",True";
}
else
{
- str = str + ",False";
+ str = str + ",False";
}
- str = str + "," + pos.drawStyle; // オブジェクトの形状
- str = str + "," + pos.paintStyle; // オブジェクトの塗りつぶし状態
- str = str + "," + (Math.round(pos.rect.centerX() * 100.0f) / 100.0f);
- str = str + "," + (Math.round(pos.rect.centerY() * 100.0f) / 100.0f);
- str = str + "," + (Math.round(pos.rect.width() * 100.0f) / 100.0f);
- str = str + "," + (Math.round(pos.rect.height() * 100.0f) / 100.0f);
+ str = str + "," + pos.getDrawStyle(); // オブジェクトの形状
+ str = str + "," + pos.getPaintStyle(); // オブジェクトの塗りつぶし状態
+ str = str + "," + (Math.round(posRect.centerX() * 100.0f) / 100.0f);
+ str = str + "," + (Math.round(posRect.centerY() * 100.0f) / 100.0f);
+ str = str + "," + (Math.round(posRect.width() * 100.0f) / 100.0f);
+ str = str + "," + (Math.round(posRect.height() * 100.0f) / 100.0f);
str = str + ",;!<_$\r\n";
writer.write(str);
}
}
catch (Exception e)
{
- resultMessage = " ERR>" + e.toString();
+ resultMessage = " ERR>" + e.toString();
Log.v(Main.APP_IDENTIFIER, resultMessage);
e.printStackTrace();
- }
+ }
return (resultMessage);
}
/**
* 非同期処理
* (バックグラウンドで実行する(このメソッドは、UIスレッドと別のところで実行する))
- *
+ *
*/
@Override
protected String doInBackground(MeMoMaObjectHolder... datas)
- {
+ {
// ファイル名の設定 ... (拡張子なし)
- String fileName = fileUtility.getGokigenDirectory() + "/exported/" + datas[0].getDataTitle();
+ String fileName = fileUtility.getGokigenDirectory() + "/exported/" + datas[0].getDataTitle();
- // データを保管する
+ // データを保管する
String result = exportToCsvFile(fileName, datas[0]);
System.gc();
- return (result);
+ return (result);
}
/**
* 非同期処理の進捗状況の更新
- *
+ *
*/
- @Override
- protected void onProgressUpdate(Integer... values)
- {
+ @Override
+ protected void onProgressUpdate(Integer... values)
+ {
// 今回は何もしない
- }
+ }
/**
* 非同期処理の後処理
@Override
protected void onPostExecute(String result)
{
- try
- {
+ try
+ {
if (receiver != null)
{
- receiver.onExportedResult(exportedFileName, result);
+ receiver.onExportedResult(exportedFileName, result);
}
- }
- catch (Exception ex)
- {
- Log.v(Main.APP_IDENTIFIER, "MeMoMaFileExportCsvProcess::onPostExecute() : " + ex.toString());
- }
- // プログレスダイアログを消す
- savingDialog.dismiss();
-
- return;
- }
-
+ }
+ catch (Exception ex)
+ {
+ Log.v(Main.APP_IDENTIFIER, "MeMoMaFileExportCsvProcess::onPostExecute() : " + ex.toString());
+ }
+ // プログレスダイアログを消す
+ savingDialog.dismiss();
+ }
+
/**
* 結果報告用のインタフェース(積極的に使う予定はないけど...)
- *
+ *
* @author MRSa
*
*/
public interface IResultReceiver
{
/** 保存結果の報告 **/
- public abstract void onExportedResult(String exportedFileName, String detail);
+ void onExportedResult(String exportedFileName, String detail);
}
}
-package jp.sourceforge.gokigen.memoma.fileio;
+package jp.sourceforge.gokigen.memoma.io;
import java.io.BufferedReader;
import java.io.FileReader;
import jp.sourceforge.gokigen.memoma.Main;
import jp.sourceforge.gokigen.memoma.R;
import jp.sourceforge.gokigen.memoma.holders.MeMoMaObjectHolder;
+import jp.sourceforge.gokigen.memoma.holders.PositionObject;
/**
* データをファイルに保存するとき用 アクセスラッパ (非同期処理を実行)
float top = centerY - (height / 2.0f);
// オブジェクトのデータを作成する
- MeMoMaObjectHolder.PositionObject pos = objectHolder.createPosition(left, top, drawStyle);
+ PositionObject pos = objectHolder.createPosition(left, top, drawStyle);
if (pos == null)
{
Log.v(Main.APP_IDENTIFIER, "parseRecord() : object create failure.");
return;
}
- pos.rect.right = left + width;
- pos.rect.bottom = top + height;
- pos.label = label;
- pos.detail = detail;
- pos.paintStyle = paintStyle;
- pos.userChecked = userChecked;
+ pos.setRectRight(left + width);
+ pos.setRectBottom(top + height);
+ pos.setLabel(label);
+ pos.setDetail(detail);
+ pos.setPaintStyle(paintStyle);
+ pos.setUserChecked(userChecked);
Log.v(Main.APP_IDENTIFIER, "OBJECT CREATED: " + label + "(" + left + "," + top + ") [" +drawStyle + "]");
}
catch (Exception ex)
-package jp.sourceforge.gokigen.memoma.fileio;
+package jp.sourceforge.gokigen.memoma.io;
import java.io.File;
import java.io.FileReader;
import android.content.Context;
import android.content.SharedPreferences;
+import android.graphics.RectF;
import android.os.AsyncTask;
import android.preference.PreferenceManager;
import android.util.Log;
import jp.sourceforge.gokigen.memoma.Main;
import jp.sourceforge.gokigen.memoma.holders.MeMoMaConnectLineHolder;
import jp.sourceforge.gokigen.memoma.holders.MeMoMaObjectHolder;
+import jp.sourceforge.gokigen.memoma.holders.ObjectConnector;
+import jp.sourceforge.gokigen.memoma.holders.PositionObject;
/**
* データをファイルに保存するとき用 アクセスラッパ (非同期処理を実行)
*/
public class MeMoMaFileLoadingProcess extends AsyncTask<MeMoMaObjectHolder, Integer, String>
{
- private Context parent = null;
- private IResultReceiver receiver = null;
- private ExternalStorageFileUtility fileUtility = null;
+ private Context parent;
+ private IResultReceiver receiver;
+ private ExternalStorageFileUtility fileUtility;
- private MeMoMaObjectHolder.PositionObject position = null;
- private MeMoMaConnectLineHolder.ObjectConnector line = null;
+ private PositionObject position = null;
+ private ObjectConnector line = null;
private String backgroundUri = "";
private String userCheckboxString = "";
//Log.v(Main.APP_IDENTIFIER, "parseStartTag() name = " + name);
if ((name.equalsIgnoreCase("top"))&&(position != null))
{
- position.rect.top = Float.parseFloat(parser.nextText());
+ position.setRectTop(Float.parseFloat(parser.nextText()));
}
else if ((name.equalsIgnoreCase("bottom"))&&(position != null))
{
- position.rect.bottom = Float.parseFloat(parser.nextText());
+ position.setRectBottom(Float.parseFloat(parser.nextText()));
}
else if ((name.equalsIgnoreCase("left"))&&(position != null))
{
- position.rect.left = Float.parseFloat(parser.nextText());
+ position.setRectLeft(Float.parseFloat(parser.nextText()));
}
else if ((name.equalsIgnoreCase("right"))&&(position != null))
{
- position.rect.right = Float.parseFloat(parser.nextText());
+ position.setRectRight(Float.parseFloat(parser.nextText()));
}
else if ((name.equalsIgnoreCase("drawStyle"))&&(position != null))
{
- position.drawStyle = Integer.parseInt(parser.nextText());
+ position.setDrawStyle(Integer.parseInt(parser.nextText()));
}
else if ((name.equalsIgnoreCase("icon"))&&(position != null))
{
- position.icon = Integer.parseInt(parser.nextText());
+ position.setIcon(Integer.parseInt(parser.nextText()));
}
else if ((name.equalsIgnoreCase("label"))&&(position != null))
{
- position.label = parser.nextText();
+ position.setLabel(parser.nextText());
}
else if ((name.equalsIgnoreCase("detail"))&&(position != null))
{
- position.detail = parser.nextText();
+ position.setDetail(parser.nextText());
}
-/**
+/*
else if ((name.equalsIgnoreCase("backgroundUri"))&&(position != null))
{
position.backgroundUri = parser.nextText();
else if ((name.equalsIgnoreCase("userChecked"))&&(position != null))
{
String parseData = parser.nextText();
- position.userChecked =(parseData.equalsIgnoreCase("true")) ? true : false;
+ position.setUserChecked((parseData.equalsIgnoreCase("true")));
}
else if ((name.equalsIgnoreCase("labelColor"))&&(position != null))
{
- position.labelColor = Integer.parseInt(parser.nextText());
+ position.setLabelColor(Integer.parseInt(parser.nextText()));
}
else if ((name.equalsIgnoreCase("objectColor"))&&(position != null))
{
- position.objectColor = Integer.parseInt(parser.nextText());
+ position.setObjectColor(Integer.parseInt(parser.nextText()));
}
else if ((name.equalsIgnoreCase("paintStyle"))&&(position != null))
{
- position.paintStyle = parser.nextText();
+ position.setPaintStyle(parser.nextText());
}
else if ((name.equalsIgnoreCase("strokeWidth"))&&(position != null))
{
- position.strokeWidth = Float.parseFloat(parser.nextText());
+ position.setStrokeWidth(Float.parseFloat(parser.nextText()));
}
else if ((name.equalsIgnoreCase("fontSize"))&&(position != null))
{
- position.fontSize = Float.parseFloat(parser.nextText());
+ position.setFontSize(Float.parseFloat(parser.nextText()));
}
else if ((name.equalsIgnoreCase("fromObjectKey"))&&(line != null))
{
- line.fromObjectKey = Integer.parseInt(parser.nextText());
+ line.setFromObjectKey(Integer.parseInt(parser.nextText()));
}
else if ((name.equalsIgnoreCase("toObjectKey"))&&(line != null))
{
- line.toObjectKey = Integer.parseInt(parser.nextText());
+ line.setToObjectKey(Integer.parseInt(parser.nextText()));
}
else if ((name.equalsIgnoreCase("lineStyle"))&&(line != null))
{
- line.lineStyle = Integer.parseInt(parser.nextText());
+ line.setLineStyle(Integer.parseInt(parser.nextText()));
}
else if ((name.equalsIgnoreCase("lineShape"))&&(line != null))
{
- line.lineShape = Integer.parseInt(parser.nextText());
+ line.setLineShape(Integer.parseInt(parser.nextText()));
}
else if ((name.equalsIgnoreCase("lineThickness"))&&(line != null))
{
- line.lineThickness = Integer.parseInt(parser.nextText());
+ line.setLineThickness(Integer.parseInt(parser.nextText()));
}
-/**
+/*
else if ((name.equalsIgnoreCase("fromShape"))&&(line != null))
{
line.fromShape = Integer.parseInt(parser.nextText());
{
int key = Integer.parseInt(parser.getAttributeValue(Main.APP_NAMESPACE, "key"));
//Log.v(Main.APP_IDENTIFIER, "create object, key :" + key);
- position = null;
- position = objectHolder.createPosition(key);
+ if (objectHolder != null)
+ {
+ position = objectHolder.createPosition(key);
+ }
}
else if (name.equalsIgnoreCase("line"))
{
int key = Integer.parseInt(parser.getAttributeValue(Main.APP_NAMESPACE, "key"));
//Log.v(Main.APP_IDENTIFIER, "create line, key :" + key);
line = null;
- line = objectHolder.getConnectLineHolder().createLine(key);
+ if (objectHolder != null)
+ {
+ line = objectHolder.getConnectLineHolder().createLine(key);
+ }
}
}
catch (Exception e)
//objectHolder.dumpPositionObject(position);
// 領域サイズがおかしい場合には、オブジェクトサイズを補正する (ふつーありえないはずなんだけど...)
- if ((position.rect.left > position.rect.right)||(position.rect.top > position.rect.bottom))
+ RectF posRect = position.getRect();
+ if ((posRect.left > posRect.right)||(posRect.top > posRect.bottom))
{
- Log.v(Main.APP_IDENTIFIER, "RECT IS ILLEGAL. : [" + position.rect.left + "," + position.rect.top + "-[" + position.rect.right + "," + position.rect.bottom + "]");
- position.rect.right = position.rect.left + MeMoMaObjectHolder.OBJECTSIZE_DEFAULT_X;
- position.rect.bottom = position.rect.top + MeMoMaObjectHolder.OBJECTSIZE_DEFAULT_Y;
+ Log.v(Main.APP_IDENTIFIER, "RECT IS ILLEGAL. : [" + posRect.left + "," + posRect.top + "-[" + posRect.right + "," + posRect.bottom + "]");
+ position.setRectRight(posRect.left + MeMoMaObjectHolder.OBJECTSIZE_DEFAULT_X);
+ position.setRectBottom(posRect.top + MeMoMaObjectHolder.OBJECTSIZE_DEFAULT_Y);
}
-
}
+/*
else if (name.equalsIgnoreCase("line"))
{
+ //
//Log.v(Main.APP_IDENTIFIER, "parseEndTag() : LINE");
//objectHolder.getConnectLineHolder().dumpConnectLine(line);
}
+*/
}
catch (Exception e)
{
/**
* (XML形式の)データを読みだす。
- *
- * @param fileName
- * @param objectHolder
- * @return
+ *
*/
private String restoreToXmlFile(String fileName, MeMoMaObjectHolder objectHolder)
{
try
{
File inputFile = new File(fileName);
- if (inputFile.exists() == false)
+ if (!inputFile.exists())
{
// ファイルがなかったときには、「ファイルなし」と報告する。
resultMessage = "ERR>File not found.";
parser.setInput(reader);
int eventType = parser.getEventType();
- boolean done = false;
// オブジェクトとラインをすべてクリアする
objectHolder.removeAllPositions();
}
lineHolder.removeAllLines();
- while ((eventType != XmlPullParser.END_DOCUMENT)&&(done != true))
+ while ((eventType != XmlPullParser.END_DOCUMENT))
{
switch (eventType)
{
{
try
{
- if (result.isEmpty() == true)
+ if (result.isEmpty())
{
// エラーが発生していない場合には、読みだしたデータをPreferenceに設定登録...
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent);
SharedPreferences.Editor editor = preferences.edit();
editor.putString("backgroundUri", backgroundUri);
editor.putString("userCheckboxString", userCheckboxString);
- editor.commit();
+ editor.apply();
}
if (receiver != null)
{
Log.v(Main.APP_IDENTIFIER, "MeMoMaFileSavingProcess::onPostExecute() : " + ex.toString());
}
- return;
}
/**
public interface IResultReceiver
{
/** 処理中の処理 **/
- public abstract void onLoadingProcess();
+ void onLoadingProcess();
/** 保存結果の報告 **/
- public abstract void onLoadedResult(String detail);
+ void onLoadedResult(String detail);
}
}
-package jp.sourceforge.gokigen.memoma.fileio;
+package jp.sourceforge.gokigen.memoma.io;
import java.io.File;
import java.io.FileWriter;
import org.xmlpull.v1.XmlSerializer;
+import android.graphics.RectF;
import android.util.Log;
import android.util.Xml;
import jp.sourceforge.gokigen.memoma.Main;
-import jp.sourceforge.gokigen.memoma.holders.MeMoMaConnectLineHolder;
import jp.sourceforge.gokigen.memoma.holders.MeMoMaObjectHolder;
+import jp.sourceforge.gokigen.memoma.holders.ObjectConnector;
+import jp.sourceforge.gokigen.memoma.holders.PositionObject;
/**
* データをファイルに保存するエンジン部分
/**
* コンストラクタ
*/
- public MeMoMaFileSavingEngine(ExternalStorageFileUtility utility, String bgUri, String checkBoxLabel)
+ MeMoMaFileSavingEngine(ExternalStorageFileUtility utility, String bgUri, String checkBoxLabel)
{
- /** ファイルユーティリティを記憶する **/
+ // ファイルユーティリティを記憶する
fileUtility = utility;
- /** ファイルをバックアップするディレクトリを作成する **/
+ // ファイルをバックアップするディレクトリを作成する
File dir = new File(fileUtility.getGokigenDirectory() + "/backup");
dir.mkdir();
/**
* ファイルが存在したとき、リネームする
- *
- * @param targetFileName
- * @param newFileName
+ *
*/
private boolean renameFile(String targetFileName, String newFileName)
{
boolean ret = true;
File targetFile = new File(targetFileName);
- if (targetFile.exists() == true)
+ if (targetFile.exists())
{
// ファイルが存在した、、、ファイル名を1世代古いものに変更する
ret = targetFile.renameTo(new File(newFileName));
/**
* 保管データを複数世代保管する。
*
- * @param fileName
+ *
*/
private void backupFiles(String dirName, String backupFileName)
{
{
String fileName = dirName + "backup/" + backupFileName;
File backFile = new File(fileName + ".xml.bak5");
- if (backFile.exists() == true)
+ if (backFile.exists())
{
// ファイルが存在した、、、削除する
backFile.delete();
// 何か例外が発生した場合にはエラーと認識する。
result = false;
}
- if (result == false)
+ if (!result)
{
// バックアップファイルのコピー失敗をログに記述する
Log.v(Main.APP_IDENTIFIER, "rename failure : " + dirName + backupFileName + ".xml");
}
- return;
}
/**
* データを(XML形式で)保管する。
- *
- * @param fileName
- * @param objectHolder
- * @return
+ *
*/
private String storeToXmlFile(String fileName, MeMoMaObjectHolder objectHolder)
{
while (keys.hasMoreElements())
{
Integer key = keys.nextElement();
- MeMoMaObjectHolder.PositionObject pos = objectHolder.getPosition(key);
+ PositionObject pos = objectHolder.getPosition(key);
+ RectF posRect = pos.getRect();
serializer.startTag(Main.APP_NAMESPACE, "object");
serializer.attribute(Main.APP_NAMESPACE, "key", Integer.toString(key));
serializer.startTag(Main.APP_NAMESPACE, "rect");
serializer.startTag(Main.APP_NAMESPACE, "top");
- serializer.text(Float.toString(pos.rect.top));
+ serializer.text(Float.toString(posRect.top));
serializer. endTag(Main.APP_NAMESPACE, "top");
serializer.startTag(Main.APP_NAMESPACE, "left");
- serializer.text(Float.toString(pos.rect.left));
+ serializer.text(Float.toString(posRect.left));
serializer. endTag(Main.APP_NAMESPACE, "left");
serializer.startTag(Main.APP_NAMESPACE, "right");
- serializer.text(Float.toString(pos.rect.right));
+ serializer.text(Float.toString(posRect.right));
serializer. endTag(Main.APP_NAMESPACE, "right");
serializer.startTag(Main.APP_NAMESPACE, "bottom");
- serializer.text(Float.toString(pos.rect.bottom));
+ serializer.text(Float.toString(posRect.bottom));
serializer. endTag(Main.APP_NAMESPACE, "bottom");
serializer. endTag(Main.APP_NAMESPACE, "rect");
serializer.startTag(Main.APP_NAMESPACE, "drawStyle");
- serializer.text(Integer.toString(pos.drawStyle));
+ serializer.text(Integer.toString(pos.getDrawStyle()));
serializer. endTag(Main.APP_NAMESPACE, "drawStyle");
serializer.startTag(Main.APP_NAMESPACE, "icon");
- serializer.text(Integer.toString(pos.icon));
+ serializer.text(Integer.toString(pos.getIcon()));
serializer. endTag(Main.APP_NAMESPACE, "icon");
serializer.startTag(Main.APP_NAMESPACE, "label");
- serializer.text(pos.label);
+ serializer.text(pos.getLabel());
serializer. endTag(Main.APP_NAMESPACE, "label");
serializer.startTag(Main.APP_NAMESPACE, "detail");
- serializer.text(pos.detail);
+ serializer.text(pos.getDetail());
serializer. endTag(Main.APP_NAMESPACE, "detail");
-/**
+/*
serializer.startTag(Main.APP_NAMESPACE, "otherInfoUri");
serializer.text(pos.otherInfoUri);
serializer. endTag(Main.APP_NAMESPACE, "otherInfoUri");
serializer.startTag(Main.APP_NAMESPACE, "objectStatus");
serializer.text(pos.objectStatus);
serializer. endTag(Main.APP_NAMESPACE, "objectStatus");
-**/
+*/
serializer.startTag(Main.APP_NAMESPACE, "userChecked");
- serializer.text(Boolean.toString(pos.userChecked));
+ serializer.text(Boolean.toString(pos.getUserChecked()));
serializer. endTag(Main.APP_NAMESPACE, "userChecked");
serializer.startTag(Main.APP_NAMESPACE, "labelColor");
- serializer.text(Integer.toString(pos.labelColor));
+ serializer.text(Integer.toString(pos.getLabelColor()));
serializer. endTag(Main.APP_NAMESPACE, "labelColor");
serializer.startTag(Main.APP_NAMESPACE, "objectColor");
- serializer.text(Integer.toString(pos.objectColor));
+ serializer.text(Integer.toString(pos.getObjectColor()));
serializer. endTag(Main.APP_NAMESPACE, "objectColor");
serializer.startTag(Main.APP_NAMESPACE, "paintStyle");
- serializer.text(pos.paintStyle);
+ serializer.text(pos.getPaintStyle());
serializer. endTag(Main.APP_NAMESPACE, "paintStyle");
serializer.startTag(Main.APP_NAMESPACE, "strokeWidth");
- serializer.text(Float.toString(pos.strokeWidth));
+ serializer.text(Float.toString(pos.getstrokeWidth()));
serializer. endTag(Main.APP_NAMESPACE, "strokeWidth");
serializer.startTag(Main.APP_NAMESPACE, "fontSize");
- serializer.text(Float.toString(pos.fontSize));
+ serializer.text(Float.toString(pos.getFontSize()));
serializer. endTag(Main.APP_NAMESPACE, "fontSize");
serializer.endTag(Main.APP_NAMESPACE, "object");
while (lineKeys.hasMoreElements())
{
Integer key = lineKeys.nextElement();
- MeMoMaConnectLineHolder.ObjectConnector line = objectHolder.getConnectLineHolder().getLine(key);
+ ObjectConnector line = objectHolder.getConnectLineHolder().getLine(key);
serializer.startTag(Main.APP_NAMESPACE, "line");
serializer.attribute(Main.APP_NAMESPACE, "key", Integer.toString(key));
serializer.startTag(Main.APP_NAMESPACE, "fromObjectKey");
- serializer.text(Integer.toString(line.fromObjectKey));
+ serializer.text(Integer.toString(line.getFromObjectKey()));
serializer.endTag(Main.APP_NAMESPACE, "fromObjectKey");
serializer.startTag(Main.APP_NAMESPACE, "toObjectKey");
- serializer.text(Integer.toString(line.toObjectKey));
+ serializer.text(Integer.toString(line.getToObjectKey()));
serializer.endTag(Main.APP_NAMESPACE, "toObjectKey");
serializer.startTag(Main.APP_NAMESPACE, "lineStyle");
- serializer.text(Integer.toString(line.lineStyle));
+ serializer.text(Integer.toString(line.getLineStyle()));
serializer.endTag(Main.APP_NAMESPACE, "lineStyle");
serializer.startTag(Main.APP_NAMESPACE, "lineShape");
- serializer.text(Integer.toString(line.lineShape));
+ serializer.text(Integer.toString(line.getLineShape()));
serializer.endTag(Main.APP_NAMESPACE, "lineShape");
serializer.startTag(Main.APP_NAMESPACE, "lineThickness");
- serializer.text(Integer.toString(line.lineThickness));
+ serializer.text(Integer.toString(line.getLineThickness()));
serializer.endTag(Main.APP_NAMESPACE, "lineThickness");
-/**
+/*
serializer.startTag(Main.APP_NAMESPACE, "fromShape");
serializer.text(Integer.toString(line.fromShape));
serializer.endTag(Main.APP_NAMESPACE, "fromShape");
serializer.startTag(Main.APP_NAMESPACE, "toString");
serializer.text(line.toString);
serializer.endTag(Main.APP_NAMESPACE, "toString");
-**/
+*/
serializer.endTag(Main.APP_NAMESPACE, "line");
}
/**
* オブジェクトを保存する
*
- * @param objectHolder
- * @return
+ *
*/
public String saveObjects(MeMoMaObjectHolder objectHolder)
{
String fileName = fileUtility.getGokigenDirectory() + "/" + objectHolder.getDataTitle();
// データを保管する
- String result = storeToXmlFile(fileName, objectHolder);
-
- return (result);
+ return (storeToXmlFile(fileName, objectHolder));
}
}
-package jp.sourceforge.gokigen.memoma.fileio;
+package jp.sourceforge.gokigen.memoma.io;
import android.app.ProgressDialog;
import android.content.Context;
-package jp.sourceforge.gokigen.memoma.fileio;
+package jp.sourceforge.gokigen.memoma.io;
import java.io.File;
import java.io.FileOutputStream;
import android.graphics.Bitmap.CompressFormat;
import android.graphics.Canvas;
import android.graphics.Rect;
+import android.graphics.RectF;
import android.os.AsyncTask;
import android.util.Log;
import android.view.Display;
import jp.sourceforge.gokigen.memoma.R;
import jp.sourceforge.gokigen.memoma.drawers.MeMoMaCanvasDrawer;
import jp.sourceforge.gokigen.memoma.holders.MeMoMaObjectHolder;
+import jp.sourceforge.gokigen.memoma.holders.PositionObject;
/**
* データをファイルに保存するとき用 アクセスラッパ (非同期処理を実行)
*/
public class ObjectLayoutCaptureExporter extends AsyncTask<String, Integer, String>
{
+ private static final int OUTPUT_EXPORT_SHARE_ID = 1000;
private static final int OUTPUT_MARGIN = 8;
private static final int OUTPUT_MARGIN_TOP = 50;
while (keys.hasMoreElements())
{
Integer key = keys.nextElement();
- MeMoMaObjectHolder.PositionObject pos = objectHolder.getPosition(key);
- if (canvasSize.left > pos.rect.left)
+ PositionObject pos = objectHolder.getPosition(key);
+ RectF posRect = pos.getRect();
+ if (canvasSize.left > posRect.left)
{
- canvasSize.left = (int) pos.rect.left;
+ canvasSize.left = (int) posRect.left;
}
- if (canvasSize.right < pos.rect.right)
+ if (canvasSize.right < posRect.right)
{
- canvasSize.right = (int) pos.rect.right;
+ canvasSize.right = (int) posRect.right;
}
- if (canvasSize.top > pos.rect.top)
+ if (canvasSize.top > posRect.top)
{
- canvasSize.top = (int) pos.rect.top;
+ canvasSize.top = (int) posRect.top;
}
- if (canvasSize.bottom < pos.rect.bottom)
+ if (canvasSize.bottom < posRect.bottom)
{
- canvasSize.bottom = (int) pos.rect.bottom;
+ canvasSize.bottom = (int) posRect.bottom;
}
}
{
if (receiver != null)
{
- receiver.onCaptureLayoutExportedResult(exportedFileName, result);
+ receiver.onCaptureLayoutExportedResult(exportedFileName, result, OUTPUT_EXPORT_SHARE_ID);
}
}
catch (Exception ex)
public interface ICaptureLayoutExporter
{
// 保存結果の報告
- void onCaptureLayoutExportedResult(String exportedFileName, String detail);
+ void onCaptureLayoutExportedResult(String exportedFileName, String detail, int id);
}
}
-package jp.sourceforge.gokigen.memoma;
+package jp.sourceforge.gokigen.memoma.io;
import android.app.Activity;
import android.content.Intent;
-package jp.sourceforge.gokigen.memoma.fileio;
+package jp.sourceforge.gokigen.memoma.io;
import java.io.File;
import java.io.FileOutputStream;
import android.app.ProgressDialog;
import android.content.Context;
+import android.graphics.RectF;
import android.os.AsyncTask;
import android.util.Log;
import jp.sourceforge.gokigen.memoma.Main;
import jp.sourceforge.gokigen.memoma.R;
import jp.sourceforge.gokigen.memoma.holders.MeMoMaObjectHolder;
+import jp.sourceforge.gokigen.memoma.holders.PositionObject;
/**
* オブジェクトの位置を整列するクラス (非同期処理を実行)
*/
public class ObjectAligner extends AsyncTask<MeMoMaObjectHolder, Integer, String>
{
- ProgressDialog executingDialog = null;
- IAlignCallback receiver = null;
+ private ProgressDialog executingDialog;
+ private IAlignCallback receiver;
/**
* コンストラクタ
*/
while (keys.hasMoreElements())
{
Integer key = keys.nextElement();
- MeMoMaObjectHolder.PositionObject pos = objectHolder.getPosition(key);
-
- float newLeft = (float) Math.floor((pos.rect.left + 15.0f)/ 30.0) * 30.0f;
- float newTop = (float) Math.floor((pos.rect.top + 15.0f)/ 30.0) * 30.0f;
- pos.rect.offsetTo(newLeft, newTop);
+ PositionObject pos = objectHolder.getPosition(key);
+ RectF posRect = pos.getRect();
+ float newLeft = (float) Math.floor((posRect.left + 15.0f)/ 30.0) * 30.0f;
+ float newTop = (float) Math.floor((posRect.top + 15.0f)/ 30.0) * 30.0f;
+ pos.setRectOffsetTo(newLeft, newTop);
}
System.gc();
// プログレスダイアログを消す
executingDialog.dismiss();
- return;
}
/**
*/
public interface IAlignCallback
{
- public abstract void objectAligned();
+ void objectAligned();
}
}
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PorterDuff.Mode;
+import android.graphics.RectF;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.GradientDrawable;
import android.preference.PreferenceManager;
import jp.sourceforge.gokigen.memoma.R;
import jp.sourceforge.gokigen.memoma.drawers.MeMoMaCanvasDrawer;
import jp.sourceforge.gokigen.memoma.holders.MeMoMaObjectHolder;
+import jp.sourceforge.gokigen.memoma.holders.PositionObject;
/**
* オブジェクトのデータを入力するダイアログを表示する
*/
public class ObjectDataInputDialog implements SeekBar.OnSeekBarChangeListener, CompoundButton.OnCheckedChangeListener, ImageButton.OnClickListener
{
- private final float FONTSIZE_SMALL = 4.0f;
- private final float FONTSIZE_MIDDLE = 6.0f;
- private final float FONTSIZE_LARGE = 10.0f;
+ private final float FONTSIZE_SMALL = 5.0f;
+ private final float FONTSIZE_MIDDLE = 8.0f;
+ private final float FONTSIZE_LARGE = 12.0f;
private Context context = null;
private IResultReceiver resultReceiver = null;
/**
* 確認ダイアログを応答する
- * @return
+ *
*/
public Dialog getDialog()
{
backgroundColor = MeMoMaCanvasDrawer.BACKGROUND_COLOR_DEFAULT;
}
- final TextView colorLabel = (TextView) layout.findViewById(R.id.setBorderColorLabel);
+ final TextView colorLabel = layout.findViewById(R.id.setBorderColorLabel);
backgroundShape = (GradientDrawable)colorLabel.getBackground();
// 入力文字列の色を設定する
final EditText detail = (EditText) layout.findViewById(R.id.descriptionInputArea);
//detail.setTextColor(Color.LTGRAY);
- borderColorView = (SeekBar) layout.findViewById(R.id.borderColorSelectionBar);
+ borderColorView = layout.findViewById(R.id.borderColorSelectionBar);
borderColorView.setOnSeekBarChangeListener(this);
- final CheckBox userCheckbox = (CheckBox) layout.findViewById(R.id.checkUserCheckbox);
- final CheckBox boldText = (CheckBox) layout.findViewById(R.id.checkBoldText);
- fillObjectView = (CheckBox) layout.findViewById(R.id.checkFillObject);
+ final CheckBox userCheckbox = layout.findViewById(R.id.checkUserCheckbox);
+ final CheckBox boldText = layout.findViewById(R.id.checkBoldText);
+ fillObjectView = layout.findViewById(R.id.checkFillObject);
fillObjectView.setOnCheckedChangeListener(this);
- colorBorderAreaView = (TextView) layout.findViewById(R.id.borderColorArea);
+ colorBorderAreaView = layout.findViewById(R.id.borderColorArea);
colorBorderAreaView.setOnClickListener(this);
- final ImageButton rect = (ImageButton) layout.findViewById(R.id.btnObjectRectangle);
+ final ImageButton rect = layout.findViewById(R.id.btnObjectRectangle);
rect.setOnClickListener(this);
- final ImageButton roundRect = (ImageButton) layout.findViewById(R.id.btnObjectRoundRect);
+ final ImageButton roundRect = layout.findViewById(R.id.btnObjectRoundRect);
roundRect.setOnClickListener(this);
- final ImageButton oval = (ImageButton) layout.findViewById(R.id.btnObjectOval);
+ final ImageButton oval = layout.findViewById(R.id.btnObjectOval);
oval.setOnClickListener(this);
- final ImageButton diamond = (ImageButton) layout.findViewById(R.id.btnObjectDiamond);
+ final ImageButton diamond = layout.findViewById(R.id.btnObjectDiamond);
diamond.setOnClickListener(this);
- final ImageButton hexagonal = (ImageButton) layout.findViewById(R.id.btnObjectHexagonal);
+ final ImageButton hexagonal = layout.findViewById(R.id.btnObjectHexagonal);
hexagonal.setOnClickListener(this);
- final ImageButton parallelogram = (ImageButton) layout.findViewById(R.id.btnObjectParallelogram);
+ final ImageButton parallelogram = layout.findViewById(R.id.btnObjectParallelogram);
parallelogram.setOnClickListener(this);
- final ImageButton keyboard = (ImageButton) layout.findViewById(R.id.btnObjectKeyboard);
+ final ImageButton keyboard = layout.findViewById(R.id.btnObjectKeyboard);
keyboard.setOnClickListener(this);
- final ImageButton paper = (ImageButton) layout.findViewById(R.id.btnObjectPaper);
+ final ImageButton paper = layout.findViewById(R.id.btnObjectPaper);
paper.setOnClickListener(this);
- final ImageButton drum = (ImageButton) layout.findViewById(R.id.btnObjectDrum);
+ final ImageButton drum = layout.findViewById(R.id.btnObjectDrum);
drum.setOnClickListener(this);
- final ImageButton circle = (ImageButton) layout.findViewById(R.id.btnObjectCircle);
+ final ImageButton circle = layout.findViewById(R.id.btnObjectCircle);
circle.setOnClickListener(this);
- final ImageButton noregion = (ImageButton) layout.findViewById(R.id.btnObjectNoRegion);
+ final ImageButton noregion = layout.findViewById(R.id.btnObjectNoRegion);
noregion.setOnClickListener(this);
-
- final ImageButton loopStart = (ImageButton) layout.findViewById(R.id.btnObjectLoopStart);
+ final ImageButton loopStart = layout.findViewById(R.id.btnObjectLoopStart);
loopStart.setOnClickListener(this);
- final ImageButton loopEnd = (ImageButton) layout.findViewById(R.id.btnObjectLoopEnd);
+ final ImageButton loopEnd = layout.findViewById(R.id.btnObjectLoopEnd);
loopEnd.setOnClickListener(this);
- final ImageButton leftArrow = (ImageButton) layout.findViewById(R.id.btnObjectLeftArrow);
+ final ImageButton leftArrow = layout.findViewById(R.id.btnObjectLeftArrow);
leftArrow.setOnClickListener(this);
- final ImageButton downArrow = (ImageButton) layout.findViewById(R.id.btnObjectDownArrow);
+ final ImageButton downArrow = layout.findViewById(R.id.btnObjectDownArrow);
downArrow.setOnClickListener(this);
- final ImageButton upArrow = (ImageButton) layout.findViewById(R.id.btnObjectUpArrow);
+ final ImageButton upArrow = layout.findViewById(R.id.btnObjectUpArrow);
upArrow.setOnClickListener(this);
- final ImageButton rightArrow = (ImageButton) layout.findViewById(R.id.btnObjectRightArrow);
+ final ImageButton rightArrow = layout.findViewById(R.id.btnObjectRightArrow);
rightArrow.setOnClickListener(this);
// 背景の色を調整(塗りつぶしの時はオブジェクトの色とする。)
int color = convertColor(borderColorView.getProgress());
- colorBorderAreaView.setBackgroundColor((fillObjectView.isChecked() == true) ? color : backgroundColor);
+ colorBorderAreaView.setBackgroundColor((fillObjectView.isChecked()) ? color : backgroundColor);
//backgroundShape.setStroke(2, color);
- if (fillObjectView.isChecked() == true)
+ if (fillObjectView.isChecked())
{
// 塗りつぶし時は文字の色を変える。
color = (color ^ 0x00ffffff);
builder.setView(layout);
builder.setCancelable(false);
+
builder.setPositiveButton(context.getString(R.string.confirmYes), new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int id)
{
- boolean ret = false;
- boolean isUserCheck = false;
- if (userCheckbox != null)
- {
- isUserCheck = userCheckbox.isChecked();
- }
- setObjectData(label.getText().toString(), detail.getText().toString(), borderColorView.getProgress(), boldText.isChecked(), fillObjectView.isChecked(), isUserCheck, currentObjectDrawStyle);
- if (resultReceiver != null)
- {
- resultReceiver.finishObjectInput();
- }
- if (ret == true)
+ try
{
- dialog.dismiss();
+ boolean isUserCheck = false;
+ if (userCheckbox != null)
+ {
+ isUserCheck = userCheckbox.isChecked();
+ }
+ setObjectData(label.getText().toString(), detail.getText().toString(), borderColorView.getProgress(), boldText.isChecked(), fillObjectView.isChecked(), isUserCheck, currentObjectDrawStyle);
+ if (resultReceiver != null)
+ {
+ resultReceiver.finishObjectInput();
+ }
}
- else
+ catch (Exception e)
{
- dialog.cancel();
+ e.printStackTrace();
}
+ dialog.dismiss();
System.gc();
}
});
{
public void onClick(DialogInterface dialog, int id)
{
- boolean ret = false;
- if (resultReceiver != null)
- {
- resultReceiver.cancelObjectInput();
- }
- if (ret == true)
+ try
{
- dialog.dismiss();
+ if (resultReceiver != null)
+ {
+ resultReceiver.cancelObjectInput();
+ }
}
- else
+ catch (Exception e)
{
- dialog.cancel();
+ e.printStackTrace();
}
+ dialog.cancel();
System.gc();
}
});
*/
public void prepareObjectInputDialog(Dialog dialog, Integer objectKey)
{
- MeMoMaObjectHolder.PositionObject position = objectHolder.getPosition(objectKey);
+ PositionObject position = objectHolder.getPosition(objectKey);
key = objectKey;
if (position != null)
{
// 色を設定する
- final SeekBar borderColorProgess = (SeekBar) dialog.findViewById(R.id.borderColorSelectionBar);
- borderColorProgess.setProgress(convertProgress(position.objectColor));
+ final SeekBar borderColorProgess = dialog.findViewById(R.id.borderColorSelectionBar);
+ borderColorProgess.setProgress(convertProgress(position.getObjectColor()));
- final CheckBox boldTextCheck = (CheckBox) dialog.findViewById(R.id.checkBoldText);
- boldTextCheck.setChecked(position.strokeWidth == MeMoMaObjectHolder.STOROKE_BOLD_WIDTH);
+ final CheckBox boldTextCheck = dialog.findViewById(R.id.checkBoldText);
+ boldTextCheck.setChecked(position.getstrokeWidth() == MeMoMaObjectHolder.STOROKE_BOLD_WIDTH);
- final CheckBox fillObjectCheck = (CheckBox) dialog.findViewById(R.id.checkFillObject);
- fillObjectCheck.setChecked(Paint.Style.valueOf(position.paintStyle) != Paint.Style.STROKE);
+ final CheckBox fillObjectCheck = dialog.findViewById(R.id.checkFillObject);
+ fillObjectCheck.setChecked(Paint.Style.valueOf(position.getPaintStyle()) != Paint.Style.STROKE);
// フォントサイズを設定する
- textFontSize = position.fontSize / 2.0f;
+ textFontSize = position.getFontSize() / 2.0f;
// 入力文字列を設定する
- final EditText targetLabel = (EditText) dialog.findViewById(R.id.labelInputArea);
- targetLabel.setText(position.label);
+ final EditText targetLabel = dialog.findViewById(R.id.labelInputArea);
+ targetLabel.setText(position.getLabel());
- final EditText targetDetail = (EditText) dialog.findViewById(R.id.descriptionInputArea);
- targetDetail.setText(position.detail);
+ final EditText targetDetail = dialog.findViewById(R.id.descriptionInputArea);
+ targetDetail.setText(position.getDetail());
// 設定に記録されているデータを画面に反映させる
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
String userCheckboxTitle = preferences.getString("userCheckboxString", "");
// 描画スタイルを設定する
- currentObjectDrawStyle = position.drawStyle;
+ currentObjectDrawStyle = position.getDrawStyle();
updateObjectDrawStyleImageButton(currentObjectDrawStyle);
// 背景色を設定する
}
setTextColorSample(borderColorProgess.getProgress(), textFontSize, fillObjectView.isChecked());
- final CheckBox userCheckbox = (CheckBox) dialog.findViewById(R.id.checkUserCheckbox);
+ final CheckBox userCheckbox = dialog.findViewById(R.id.checkUserCheckbox);
userCheckbox.setEnabled(true);
userCheckbox.setText(userCheckboxTitle);
- userCheckbox.setChecked(position.userChecked);
+ userCheckbox.setChecked(position.getUserChecked());
}
}
* オブジェクトにデータを設定する
*
*/
- public void setObjectData(String label, String detail, int progress, boolean boldText, boolean fillObject, boolean userCheck, int drawStyle)
+ private void setObjectData(String label, String detail, int progress, boolean boldText, boolean fillObject, boolean userCheck, int drawStyle)
{
- MeMoMaObjectHolder.PositionObject positionObject = objectHolder.getPosition(key);
+ PositionObject positionObject = objectHolder.getPosition(key);
if (positionObject != null)
{
- positionObject.label = label;
- positionObject.detail = detail;
+ positionObject.setLabel(label);
+ positionObject.setDetail(detail);
int color = convertColor(progress);
- positionObject.objectColor = color;
+ positionObject.setObjectColor(color);
color = (color ^ 0x00ffffff);
- positionObject.fontSize = textFontSize * 2.0f;
- positionObject.labelColor = color;
- positionObject.strokeWidth = (boldText == true) ? MeMoMaObjectHolder.STOROKE_BOLD_WIDTH : MeMoMaObjectHolder.STOROKE_NORMAL_WIDTH;
- positionObject.paintStyle = ((fillObject == true) ? Paint.Style.FILL : Paint.Style.STROKE).toString();
- positionObject.userChecked = userCheck;
-
- if (positionObject.drawStyle != drawStyle)
+ positionObject.setFontSize(textFontSize * 2.0f);
+ positionObject.setLabelColor(color);
+ positionObject.setStrokeWidth((boldText) ? MeMoMaObjectHolder.STOROKE_BOLD_WIDTH : MeMoMaObjectHolder.STOROKE_NORMAL_WIDTH);
+ positionObject.setPaintStyle(((fillObject) ? Paint.Style.FILL : Paint.Style.STROKE).toString());
+ positionObject.setUserChecked(userCheck);
+
+ int posDrawStyle = positionObject.getDrawStyle();
+ if (posDrawStyle != drawStyle)
{
if ((drawStyle == MeMoMaObjectHolder.DRAWSTYLE_CIRCLE)||
(drawStyle == MeMoMaObjectHolder. DRAWSTYLE_LEFT_ARROW)||
// (長方形の形状から)正方形の形状にする場合...
setRectToSquare(positionObject);
}
- else if ((positionObject.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_CIRCLE)||
- (positionObject.drawStyle == MeMoMaObjectHolder. DRAWSTYLE_LEFT_ARROW)||
- (positionObject.drawStyle == MeMoMaObjectHolder. DRAWSTYLE_DOWN_ARROW)||
- (positionObject.drawStyle == MeMoMaObjectHolder. DRAWSTYLE_UP_ARROW)||
- (positionObject.drawStyle == MeMoMaObjectHolder. DRAWSTYLE_RIGHT_ARROW))
+ else if ((posDrawStyle == MeMoMaObjectHolder.DRAWSTYLE_CIRCLE)||
+ (posDrawStyle == MeMoMaObjectHolder. DRAWSTYLE_LEFT_ARROW)||
+ (posDrawStyle == MeMoMaObjectHolder. DRAWSTYLE_DOWN_ARROW)||
+ (posDrawStyle == MeMoMaObjectHolder. DRAWSTYLE_UP_ARROW)||
+ (posDrawStyle == MeMoMaObjectHolder. DRAWSTYLE_RIGHT_ARROW))
{
// 正方形の形状から、長方形の形状にする場合...
setRectFromSquare(positionObject);
}
- positionObject.drawStyle = drawStyle;
+ positionObject.setDrawStyle(drawStyle);
}
}
- positionObject = null;
}
/**
* オブジェクトの領域を長方形から正方形にする
*/
- private void setRectToSquare(MeMoMaObjectHolder.PositionObject positionObject)
+ private void setRectToSquare(PositionObject positionObject)
{
- float bandWidth = ((positionObject.rect.right - positionObject.rect.left)) / 2.0f;
- float center = positionObject.rect.centerY();
-
- positionObject.rect.top = center - bandWidth;
- positionObject.rect.bottom = center + bandWidth;
+ RectF posRect = positionObject.getRect();
+ float bandWidth = ((posRect.right - posRect.left)) / 2.0f;
+ float center = posRect.centerY();
+
+ positionObject.setRectTop(center - bandWidth);
+ positionObject.setRectBottom(center + bandWidth);
}
/**
* オブジェクトの領域を正方形から長方形にする
*/
- private void setRectFromSquare(MeMoMaObjectHolder.PositionObject positionObject)
+ private void setRectFromSquare(PositionObject positionObject)
{
- float bandWidth = ((positionObject.rect.right - positionObject.rect.left) / 16.0f * 9.0f) / 2.0f;
- float center = positionObject.rect.centerY();
-
- positionObject.rect.top = center - bandWidth;
- positionObject.rect.bottom = center + bandWidth;
+ RectF posRect = positionObject.getRect();
+ float bandWidth = ((posRect.right - posRect.left) / 16.0f * 9.0f) / 2.0f;
+ float center = posRect.centerY();
+
+ positionObject.setRectTop(center - bandWidth);
+ positionObject.setRectBottom(center + bandWidth);
}
private void setButtonBorder(int id, boolean isHighlight)
{
try
{
- ImageButton button = (ImageButton) dialogLayout.findViewById(id);
+ ImageButton button = dialogLayout.findViewById(id);
//GradientDrawable btnBackgroundShape = (GradientDrawable)button.getBackground();
BitmapDrawable btnBackgroundShape = (BitmapDrawable)button.getBackground();
- if (isHighlight == true)
+ if (isHighlight)
{
// btnBackgroundShape.setColorFilter(Color.rgb(51, 181, 229), Mode.LIGHTEN);
btnBackgroundShape.setColorFilter(Color.BLUE, Mode.LIGHTEN);
/**
* イメージボタンの選択状態を更新する
*
- * @param drawStyle
+ *
*/
private void updateObjectDrawStyleImageButton(int drawStyle)
{
/**
* 0x00~0x3fの値(R, G, B, それぞれ2ビット)で色を変える
*
- * @param value
- * @return
+ *
*/
private int convertColor(int value)
{
- int color = 0;
+ int color;
int r = ((value >> 4 ) & 0x03) * 85;
int g = ((value >> 2) & 0x03) * 85;
int b = (value & 0x03) * 85;
/**
* 色をプログレスバーの値に変換する
*
- * @param color
- * @return
+ *
*/
private int convertProgress(int color)
{
/**
* 背景色を設定する処理
*
- * @param progress
- * @param fontSize
- * @param value
+ *
*/
private void setTextColorSample(int progress, float fontSize, boolean value)
{
if (colorBorderAreaView != null)
{
int color = convertColor(progress);
- int backColor = (value == true) ? color : backgroundColor;
+ int backColor = (value) ? color : backgroundColor;
colorBorderAreaView.setBackgroundColor(backColor);
backgroundShape.setStroke(2, color);
- if (value == true)
+ if (value)
{
// 塗りつぶし時には色を変える
color = (color ^ 0x00ffffff);
public interface IResultReceiver
{
- public abstract void finishObjectInput();
- public abstract void cancelObjectInput();
+ void finishObjectInput();
+ void cancelObjectInput();
}
}
</ListView>
<!--
-<jp.sourceforge.gokigen.memoma.GokigenSurfaceView
+<jp.sourceforge.gokigen.memoma.drawers.GokigenSurfaceView
android:id="@+id/ExtensionView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:max="100"
android:progress="50" />
- <jp.sourceforge.gokigen.memoma.GokigenSurfaceView
+ <jp.sourceforge.gokigen.memoma.drawers.GokigenSurfaceView
android:id="@+id/GraphicView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
<string name="labelLineThickness">太さ</string>
<string name="labelLineShapeSelection">形状</string>
<string name="Title_SelectLineShape">接続線の設定</string>
+ <string name="undo_operation">1つ戻す</string>
</resources>
<string name="labelLineThickness">Line Thickness</string>
<string name="labelLineShapeSelection">Line Shape</string>
<string name="Title_SelectLineShape">Select a line style</string>
+ <string name="undo_operation">Undo</string>
</resources>