Repository from CVS
https://osdn.net/cvs/view/gokigen/MeMoMa/
Révision | fdce5b50c5a4e06fbd63329365fe0d292a3d9a37 (tree) |
---|---|
l'heure | 2018-07-22 23:27:56 |
Auteur | MRSa <mrsa@myad...> |
Commiter | MRSa |
オブジェクトの削除以外の操作をヒストリに残すようにした。
@@ -13,7 +13,7 @@ import android.view.Menu; | ||
13 | 13 | import android.view.MenuItem; |
14 | 14 | import android.view.Window; |
15 | 15 | |
16 | -import jp.sourceforge.gokigen.memoma.fileio.MeMoMaDataInOutManager; | |
16 | +import jp.sourceforge.gokigen.memoma.io.MeMoMaDataInOutManager; | |
17 | 17 | |
18 | 18 | import static android.os.Build.VERSION_CODES.KITKAT; |
19 | 19 |
@@ -30,9 +30,11 @@ import jp.sourceforge.gokigen.memoma.dialogs.ConfirmationDialog; | ||
30 | 30 | import jp.sourceforge.gokigen.memoma.dialogs.CreditDialog; |
31 | 31 | import jp.sourceforge.gokigen.memoma.dialogs.ItemSelectionDialog; |
32 | 32 | import jp.sourceforge.gokigen.memoma.dialogs.TextEditDialog; |
33 | +import jp.sourceforge.gokigen.memoma.drawers.GokigenSurfaceView; | |
33 | 34 | import jp.sourceforge.gokigen.memoma.drawers.MeMoMaCanvasDrawer; |
34 | 35 | import jp.sourceforge.gokigen.memoma.extension.ExtensionActivity; |
35 | -import jp.sourceforge.gokigen.memoma.fileio.MeMoMaDataInOutManager; | |
36 | +import jp.sourceforge.gokigen.memoma.holders.OperationHistoryHolder; | |
37 | +import jp.sourceforge.gokigen.memoma.io.MeMoMaDataInOutManager; | |
36 | 38 | import jp.sourceforge.gokigen.memoma.holders.LineStyleHolder; |
37 | 39 | import jp.sourceforge.gokigen.memoma.holders.MeMoMaConnectLineHolder; |
38 | 40 | import jp.sourceforge.gokigen.memoma.holders.MeMoMaObjectHolder; |
@@ -51,1226 +53,1256 @@ import jp.sourceforge.gokigen.memoma.preference.Preference; | ||
51 | 53 | */ |
52 | 54 | public class MeMoMaListener implements OnClickListener, OnTouchListener, OnKeyListener, IObjectSelectionReceiver, ConfirmationDialog.IResultReceiver, ObjectDataInputDialog.IResultReceiver, ItemSelectionDialog.ISelectionItemReceiver, TextEditDialog.ITextEditResultReceiver, ObjectAligner.IAlignCallback, SelectLineShapeDialog.IResultReceiver |
53 | 55 | { |
54 | - public static final int MENU_ID_PREFERENCES = (Menu.FIRST + 1); // 設定画面の表示 | |
55 | - public static final int MENU_ID_ABOUT_GOKIGEN = (Menu.FIRST + 2); // アプリケーションの情報表示 | |
56 | - public static final int MENU_ID_NEW = (Menu.FIRST + 3); // 新規作成 | |
57 | - public static final int MENU_ID_EXTEND= (Menu.FIRST + 4); // 拡張機能 | |
58 | - public static final int MENU_ID_ALIGN = (Menu.FIRST + 5); // オブジェクトの整列 | |
59 | - public static final int MENU_ID_INSERT_PICTURE = (Menu.FIRST + 6); // 画像の指定 | |
60 | - public static final int MENU_ID_OPERATION = (Menu.FIRST + 7); // 操作コマンド | |
61 | - public static final int MENU_ID_RENAME = (Menu.FIRST + 8); // リネーム | |
62 | - public static final int MENU_ID_CAPTURE = (Menu.FIRST + 9); // 画像のキャプチャ | |
63 | - public static final int MENU_ID_SHARE = (Menu.FIRST + 10); // 画像の共有 | |
64 | - | |
65 | - | |
66 | - private AppCompatActivity parent = null; // 親分 | |
67 | - private TextEditDialog editTextDialog = null; // テキスト編集用ダイアログ | |
68 | - private MeMoMaCanvasDrawer objectDrawer = null; // 画像の表示 | |
69 | - private MeMoMaObjectHolder objectHolder = null; // オブジェクトの保持クラス | |
70 | - private MeMoMaConnectLineHolder lineHolder =null; // オブジェクト間の接続状態保持クラス | |
71 | - //private SelectFeatureListener featureListener = null; // 機能選択用のリスナ | |
72 | - | |
73 | - private MeMoMaDataInOutManager dataInOutManager = null; | |
74 | - | |
75 | - private OperationModeHolder drawModeHolder = null; | |
76 | - private LineStyleHolder lineStyleHolder = null; | |
77 | - | |
78 | - private ConfirmationDialog confirmationDialog = null; | |
79 | - | |
80 | - private ObjectDataInputDialog objectDataInputDialog = null; | |
81 | - | |
82 | - private SelectLineShapeDialog lineSelectionDialog = null; | |
83 | - | |
84 | - private ItemSelectionDialog itemSelectionDialog = null; | |
85 | - private ObjectOperationCommandHolder commandHolder = null; | |
86 | - | |
87 | - private boolean isEditing = false; | |
88 | - private Integer selectedObjectKey = 0; | |
89 | - private Integer objectKeyToDelete = 0; | |
90 | - private Integer selectedContextKey = 0; | |
91 | - | |
92 | - /** | |
93 | - * コンストラクタ | |
94 | - * @param argument | |
95 | - */ | |
96 | - public MeMoMaListener(AppCompatActivity argument, MeMoMaDataInOutManager inoutManager) | |
97 | - { | |
98 | - parent = argument; | |
99 | - dataInOutManager = inoutManager; | |
100 | - lineHolder = new MeMoMaConnectLineHolder(); | |
101 | - objectHolder = new MeMoMaObjectHolder(argument, lineHolder); | |
102 | - editTextDialog = new TextEditDialog(parent, R.drawable.icon); | |
103 | - //lineHolder = new MeMoMaConnectLineHolder(); | |
104 | - //featureListener = new SelectFeatureListener(parent); | |
105 | - drawModeHolder = new OperationModeHolder(parent); | |
106 | - | |
107 | - lineStyleHolder = new LineStyleHolder(parent); | |
108 | - lineStyleHolder.prepare(); | |
109 | - | |
110 | - // 新規作成時の確認ダイアログについて | |
111 | - confirmationDialog = new ConfirmationDialog(argument); | |
112 | - confirmationDialog.prepare(this, android.R.drawable.ic_dialog_alert, parent.getString(R.string.createnew_title), parent.getString(R.string.createnew_message)); | |
113 | - | |
114 | - // オブジェクトのデータ入力ダイアログを生成 | |
115 | - objectDataInputDialog = new ObjectDataInputDialog(argument, objectHolder); | |
116 | - objectDataInputDialog.setResultReceiver(this); | |
117 | - | |
118 | - // 接続線の形状と太さを選択するダイアログを生成 | |
119 | - lineSelectionDialog = new SelectLineShapeDialog(argument, lineStyleHolder); | |
120 | - lineSelectionDialog.setResultReceiver(this); | |
121 | - | |
122 | - // アイテム選択ダイアログを生成 | |
123 | - commandHolder = new ObjectOperationCommandHolder(argument); | |
124 | - itemSelectionDialog = new ItemSelectionDialog(argument); | |
125 | - itemSelectionDialog.prepare(this, commandHolder, parent.getString(R.string.object_operation)); | |
126 | - | |
127 | - // 描画クラスの生成 | |
128 | - objectDrawer = new MeMoMaCanvasDrawer(argument, objectHolder, lineStyleHolder, this); | |
129 | - | |
130 | - SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent); | |
131 | - String colorString = preferences.getString("backgroundColor", "0xff004000"); | |
132 | - objectDrawer.setBackgroundColor(colorString); | |
133 | - | |
134 | - } | |
135 | - | |
136 | - /** | |
137 | - * がっつりこのクラスにイベントリスナを接続する | |
138 | - * | |
139 | - */ | |
140 | - public void prepareListener() | |
141 | - { | |
142 | - SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent); | |
143 | - | |
144 | - // 表示位置リセットボタン | |
145 | - final ImageButton homeButton = (ImageButton) parent.findViewById(R.id.HomeButton); | |
146 | - homeButton.setOnClickListener(this); | |
147 | - | |
148 | - // 拡張ボタン | |
149 | - final ImageButton expandButton = (ImageButton) parent.findViewById(R.id.ExpandButton); | |
150 | - expandButton.setOnClickListener(this); | |
151 | - | |
152 | - // 作成ボタン | |
153 | - final ImageButton createObjectButton = (ImageButton) parent.findViewById(R.id.CreateObjectButton); | |
154 | - createObjectButton.setOnClickListener(this); | |
155 | - | |
156 | - final ImageButton deleteObjectButton = (ImageButton) parent.findViewById(R.id.DeleteObjectButton); | |
157 | - deleteObjectButton.setOnClickListener(this); | |
158 | - | |
159 | - // 線の形状切り替えボタン | |
160 | - final ImageButton lineStyleButton = (ImageButton) parent.findViewById(R.id.LineStyleButton); | |
161 | - lineStyleButton.setOnClickListener(this); | |
162 | - | |
163 | - // データ保存ボタン | |
164 | - final ImageButton saveButton = (ImageButton) parent.findViewById(R.id.SaveButton); | |
165 | - saveButton.setOnClickListener(this); | |
166 | - | |
167 | - // 画面描画クラス | |
168 | - final GokigenSurfaceView surfaceView = (GokigenSurfaceView) parent.findViewById(R.id.GraphicView); | |
169 | - surfaceView.setOnTouchListener(this); | |
170 | - | |
171 | - // スライドバーが動かされた時の処理 | |
172 | - final SeekBar seekbar = (SeekBar) parent.findViewById(R.id.ZoomInOut); | |
173 | - seekbar.setOnSeekBarChangeListener(objectDrawer); | |
174 | - int progress = preferences.getInt("zoomProgress", 50); | |
175 | - seekbar.setProgress(progress); | |
176 | - | |
177 | - // 「実行中」の表示を消す | |
178 | - parent.setProgressBarIndeterminateVisibility(false); | |
179 | - | |
180 | - //// 起動時にデータを読み出す | |
181 | - prepareMeMoMaInfo(); | |
182 | - } | |
183 | - | |
184 | - /** | |
185 | - * 終了準備 | |
186 | - */ | |
187 | - public void finishListener() | |
188 | - { | |
189 | - // 終了時に状態を保存する | |
190 | - saveData(true); | |
191 | - } | |
192 | - | |
193 | - /** | |
194 | - * スタート準備 | |
195 | - */ | |
196 | - public void prepareToStart() | |
197 | - { | |
198 | - // 設定に記録されているデータを画面に反映させる | |
199 | - SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent); | |
200 | - | |
201 | - // 描画オブジェクトの形状を設定する | |
202 | - //int objectStyle = Integer.parseInt(preferences.getString("drawStyle", "0")); | |
203 | - | |
204 | - // ラインの形状を取得し、設定する | |
205 | - setLineStyle(); | |
206 | - | |
207 | - // 操作モードを画面に反映させる | |
208 | - updateButtons(Integer.parseInt(preferences.getString("operationMode", "0"))); | |
209 | - | |
210 | - // 条件に合わせて、描画クラスを変更する | |
211 | - final GokigenSurfaceView surfaceView = (GokigenSurfaceView) parent.findViewById(R.id.GraphicView); | |
212 | - surfaceView.setCanvasDrawer(objectDrawer); | |
213 | - | |
214 | - // 背景画像(の名前)を設定しておく | |
215 | - String backgroundString = preferences.getString("backgroundUri", ""); | |
216 | - objectDrawer.setBackgroundUri(backgroundString); | |
217 | - } | |
218 | - | |
219 | - /** | |
220 | - * 終了準備 | |
221 | - */ | |
222 | - public void shutdown() | |
223 | - { | |
224 | - | |
225 | - } | |
226 | - | |
227 | - /** | |
228 | - * 他画面から戻ってきたとき... | |
229 | - * | |
230 | - */ | |
231 | - public void onActivityResult(int requestCode, int resultCode, Intent data) | |
232 | - { | |
233 | - if ((requestCode == MENU_ID_INSERT_PICTURE)&&(resultCode == Activity.RESULT_OK)) | |
234 | - { | |
235 | - try | |
236 | - { | |
237 | - // 取得したuri を preferenceに記録する | |
238 | - SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent); | |
239 | - Uri backgroundUri = data.getData(); | |
240 | - if (backgroundUri != null) | |
241 | - { | |
242 | - try | |
243 | - { | |
244 | - if (Build.VERSION.SDK_INT >= 19) { | |
245 | - final int takeFlags = data.getFlags() & (Intent.FLAG_GRANT_READ_URI_PERMISSION); | |
246 | - parent.getContentResolver().takePersistableUriPermission(backgroundUri, takeFlags); | |
247 | - } | |
248 | - SharedPreferences.Editor editor = preferences.edit(); | |
249 | - editor.putString("backgroundUri", backgroundUri.toString()); | |
250 | - editor.apply(); | |
251 | - } | |
252 | - catch (Exception e) | |
253 | - { | |
254 | - e.printStackTrace(); | |
56 | + private static final int MENU_ID_PREFERENCES = (Menu.FIRST + 1); // 設定画面の表示 | |
57 | + private static final int MENU_ID_ABOUT_GOKIGEN = (Menu.FIRST + 2); // アプリケーションの情報表示 | |
58 | + private static final int MENU_ID_NEW = (Menu.FIRST + 3); // 新規作成 | |
59 | + private static final int MENU_ID_EXTEND= (Menu.FIRST + 4); // 拡張機能 | |
60 | + private static final int MENU_ID_ALIGN = (Menu.FIRST + 5); // オブジェクトの整列 | |
61 | + private static final int MENU_ID_INSERT_PICTURE = (Menu.FIRST + 6); // 画像の指定 | |
62 | + private static final int MENU_ID_OPERATION = (Menu.FIRST + 7); // 操作コマンド | |
63 | + private static final int MENU_ID_RENAME = (Menu.FIRST + 8); // リネーム | |
64 | + private static final int MENU_ID_CAPTURE = (Menu.FIRST + 9); // 画像のキャプチャ | |
65 | + private static final int MENU_ID_SHARE = (Menu.FIRST + 10); // 画像の共有 | |
66 | + private static final int MENU_ID_UNDO = (Menu.FIRST + 11); // 処理の UNDO | |
67 | + | |
68 | + private AppCompatActivity parent; // 親分 | |
69 | + private TextEditDialog editTextDialog; // テキスト編集用ダイアログ | |
70 | + private MeMoMaCanvasDrawer objectDrawer; // 画像の表示 | |
71 | + private MeMoMaObjectHolder objectHolder; // オブジェクトの保持クラス | |
72 | + private MeMoMaConnectLineHolder lineHolder; // オブジェクト間の接続状態保持クラス | |
73 | + private OperationHistoryHolder historyHolder; // 操作履歴保持クラス | |
74 | + //private SelectFeatureListener featureListener = null; // 機能選択用のリスナ | |
75 | + | |
76 | + private MeMoMaDataInOutManager dataInOutManager; | |
77 | + | |
78 | + private OperationModeHolder drawModeHolder; | |
79 | + private LineStyleHolder lineStyleHolder; | |
80 | + | |
81 | + private ConfirmationDialog confirmationDialog; | |
82 | + | |
83 | + private ObjectDataInputDialog objectDataInputDialog; | |
84 | + | |
85 | + private SelectLineShapeDialog lineSelectionDialog; | |
86 | + | |
87 | + private ItemSelectionDialog itemSelectionDialog; | |
88 | + private ObjectOperationCommandHolder commandHolder; | |
89 | + | |
90 | + private boolean isEditing = false; | |
91 | + private Integer selectedObjectKey = 0; | |
92 | + private Integer objectKeyToDelete = 0; | |
93 | + private Integer selectedContextKey = 0; | |
94 | + | |
95 | + /** | |
96 | + * コンストラクタ | |
97 | + * | |
98 | + */ | |
99 | + MeMoMaListener(AppCompatActivity argument, MeMoMaDataInOutManager inoutManager) | |
100 | + { | |
101 | + parent = argument; | |
102 | + dataInOutManager = inoutManager; | |
103 | + historyHolder = new OperationHistoryHolder(); | |
104 | + lineHolder = new MeMoMaConnectLineHolder(historyHolder); | |
105 | + objectHolder = new MeMoMaObjectHolder(argument, lineHolder, historyHolder); | |
106 | + editTextDialog = new TextEditDialog(parent, R.drawable.icon); | |
107 | + //lineHolder = new MeMoMaConnectLineHolder(); | |
108 | + //featureListener = new SelectFeatureListener(parent); | |
109 | + drawModeHolder = new OperationModeHolder(parent); | |
110 | + | |
111 | + lineStyleHolder = new LineStyleHolder(parent); | |
112 | + lineStyleHolder.prepare(); | |
113 | + | |
114 | + // 新規作成時の確認ダイアログについて | |
115 | + confirmationDialog = new ConfirmationDialog(argument); | |
116 | + confirmationDialog.prepare(this, android.R.drawable.ic_dialog_alert, parent.getString(R.string.createnew_title), parent.getString(R.string.createnew_message)); | |
117 | + | |
118 | + // オブジェクトのデータ入力ダイアログを生成 | |
119 | + objectDataInputDialog = new ObjectDataInputDialog(argument, objectHolder); | |
120 | + objectDataInputDialog.setResultReceiver(this); | |
121 | + | |
122 | + // 接続線の形状と太さを選択するダイアログを生成 | |
123 | + lineSelectionDialog = new SelectLineShapeDialog(argument, lineStyleHolder); | |
124 | + lineSelectionDialog.setResultReceiver(this); | |
125 | + | |
126 | + // アイテム選択ダイアログを生成 | |
127 | + commandHolder = new ObjectOperationCommandHolder(argument); | |
128 | + itemSelectionDialog = new ItemSelectionDialog(argument); | |
129 | + itemSelectionDialog.prepare(this, commandHolder, parent.getString(R.string.object_operation)); | |
130 | + | |
131 | + // 描画クラスの生成 | |
132 | + objectDrawer = new MeMoMaCanvasDrawer(argument, objectHolder, lineStyleHolder, this); | |
133 | + | |
134 | + SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent); | |
135 | + String colorString = preferences.getString("backgroundColor", "0xff004000"); | |
136 | + objectDrawer.setBackgroundColor(colorString); | |
137 | + | |
138 | + } | |
139 | + | |
140 | + /** | |
141 | + * がっつりこのクラスにイベントリスナを接続する | |
142 | + * | |
143 | + */ | |
144 | + public void prepareListener() | |
145 | + { | |
146 | + SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent); | |
147 | + | |
148 | + // 表示位置リセットボタン | |
149 | + final ImageButton homeButton = parent.findViewById(R.id.HomeButton); | |
150 | + homeButton.setOnClickListener(this); | |
151 | + | |
152 | + // 拡張ボタン | |
153 | + final ImageButton expandButton = parent.findViewById(R.id.ExpandButton); | |
154 | + expandButton.setOnClickListener(this); | |
155 | + | |
156 | + // 作成ボタン | |
157 | + final ImageButton createObjectButton = parent.findViewById(R.id.CreateObjectButton); | |
158 | + createObjectButton.setOnClickListener(this); | |
159 | + | |
160 | + final ImageButton deleteObjectButton = parent.findViewById(R.id.DeleteObjectButton); | |
161 | + deleteObjectButton.setOnClickListener(this); | |
162 | + | |
163 | + // 線の形状切り替えボタン | |
164 | + final ImageButton lineStyleButton = parent.findViewById(R.id.LineStyleButton); | |
165 | + lineStyleButton.setOnClickListener(this); | |
166 | + | |
167 | + // データ保存ボタン | |
168 | + final ImageButton saveButton = parent.findViewById(R.id.SaveButton); | |
169 | + saveButton.setOnClickListener(this); | |
170 | + | |
171 | + // 画面描画クラス | |
172 | + final GokigenSurfaceView surfaceView = parent.findViewById(R.id.GraphicView); | |
173 | + surfaceView.setOnTouchListener(this); | |
174 | + | |
175 | + // スライドバーが動かされた時の処理 | |
176 | + final SeekBar seekbar =parent.findViewById(R.id.ZoomInOut); | |
177 | + seekbar.setOnSeekBarChangeListener(objectDrawer); | |
178 | + int progress = preferences.getInt("zoomProgress", 50); | |
179 | + seekbar.setProgress(progress); | |
180 | + | |
181 | + // 「実行中」の表示を消す | |
182 | + parent.setProgressBarIndeterminateVisibility(false); | |
183 | + | |
184 | + //// 起動時にデータを読み出す | |
185 | + prepareMeMoMaInfo(); | |
186 | + } | |
187 | + | |
188 | + /** | |
189 | + * 終了準備 | |
190 | + */ | |
191 | + public void finishListener() | |
192 | + { | |
193 | + // 終了時に状態を保存する | |
194 | + saveData(true); | |
195 | + } | |
196 | + | |
197 | + /** | |
198 | + * スタート準備 | |
199 | + */ | |
200 | + public void prepareToStart() | |
201 | + { | |
202 | + // 設定に記録されているデータを画面に反映させる | |
203 | + SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent); | |
204 | + | |
205 | + // 描画オブジェクトの形状を設定する | |
206 | + //int objectStyle = Integer.parseInt(preferences.getString("drawStyle", "0")); | |
207 | + | |
208 | + // ラインの形状を取得し、設定する | |
209 | + setLineStyle(); | |
210 | + | |
211 | + // 操作モードを画面に反映させる | |
212 | + updateButtons(Integer.parseInt(preferences.getString("operationMode", "0"))); | |
213 | + | |
214 | + // 条件に合わせて、描画クラスを変更する | |
215 | + final GokigenSurfaceView surfaceView = parent.findViewById(R.id.GraphicView); | |
216 | + surfaceView.setCanvasDrawer(objectDrawer); | |
217 | + | |
218 | + // 背景画像(の名前)を設定しておく | |
219 | + String backgroundString = preferences.getString("backgroundUri", ""); | |
220 | + objectDrawer.setBackgroundUri(backgroundString); | |
221 | + } | |
222 | + | |
223 | + /** | |
224 | + * 終了準備 | |
225 | + */ | |
226 | + public void shutdown() | |
227 | + { | |
228 | + | |
229 | + } | |
230 | + | |
231 | + /** | |
232 | + * 他画面から戻ってきたとき... | |
233 | + * | |
234 | + */ | |
235 | + public void onActivityResult(int requestCode, int resultCode, Intent data) | |
236 | + { | |
237 | + if ((requestCode == MENU_ID_INSERT_PICTURE)&&(resultCode == Activity.RESULT_OK)) | |
238 | + { | |
239 | + try | |
240 | + { | |
241 | + // 取得したuri を preferenceに記録する | |
242 | + SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent); | |
243 | + Uri backgroundUri = data.getData(); | |
244 | + if (backgroundUri != null) | |
245 | + { | |
246 | + try | |
247 | + { | |
248 | + if (Build.VERSION.SDK_INT >= 19) { | |
249 | + final int takeFlags = data.getFlags() & (Intent.FLAG_GRANT_READ_URI_PERMISSION); | |
250 | + parent.getContentResolver().takePersistableUriPermission(backgroundUri, takeFlags); | |
255 | 251 | } |
256 | - // 背景画像イメージの更新処理 | |
257 | - updateBackgroundImage(backgroundUri.toString()); | |
258 | - } | |
259 | - System.gc(); | |
260 | - } | |
261 | - catch (Exception ex) | |
262 | - { | |
263 | - Log.v(Main.APP_IDENTIFIER, "Ex:" + ex.toString() + " " + ex.getMessage()); | |
264 | - } | |
265 | - return; | |
266 | - } | |
267 | - else if (requestCode == MENU_ID_PREFERENCES) | |
252 | + SharedPreferences.Editor editor = preferences.edit(); | |
253 | + editor.putString("backgroundUri", backgroundUri.toString()); | |
254 | + editor.apply(); | |
255 | + } | |
256 | + catch (Exception e) | |
257 | + { | |
258 | + e.printStackTrace(); | |
259 | + } | |
260 | + // 背景画像イメージの更新処理 | |
261 | + updateBackgroundImage(backgroundUri.toString()); | |
262 | + } | |
263 | + System.gc(); | |
264 | + } | |
265 | + catch (Exception ex) | |
268 | 266 | { |
269 | - // 背景色、背景画像の設定を行う。 | |
270 | - SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent); | |
271 | - String colorString = preferences.getString("backgroundColor", "0xff004000"); | |
272 | - objectDrawer.setBackgroundColor(colorString); | |
267 | + Log.v(Main.APP_IDENTIFIER, "Ex:" + ex.toString() + " " + ex.getMessage()); | |
268 | + } | |
269 | + return; | |
270 | + } | |
271 | + else if (requestCode == MENU_ID_PREFERENCES) | |
272 | + { | |
273 | + // 背景色、背景画像の設定を行う。 | |
274 | + SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent); | |
275 | + String colorString = preferences.getString("backgroundColor", "0xff004000"); | |
276 | + objectDrawer.setBackgroundColor(colorString); | |
273 | 277 | |
274 | - // 背景画像イメージの更新処理 | |
275 | - String backgroundString = preferences.getString("backgroundUri", ""); | |
276 | - updateBackgroundImage(backgroundString); | |
278 | + // 背景画像イメージの更新処理 | |
279 | + String backgroundString = preferences.getString("backgroundUri", ""); | |
280 | + updateBackgroundImage(backgroundString); | |
277 | 281 | |
278 | - Log.v(Main.APP_IDENTIFIER, "RETURENED PREFERENCES " + backgroundString); | |
282 | + Log.v(Main.APP_IDENTIFIER, "RETURENED PREFERENCES " + backgroundString); | |
283 | + | |
284 | + } | |
285 | + else if (requestCode == MENU_ID_EXTEND) | |
286 | + { | |
287 | + // その他...今開いているファイルを読みなおす | |
288 | + dataInOutManager.loadFile((String) parent.getTitle()); | |
289 | + } | |
290 | + else | |
291 | + { | |
292 | + // 画面表示の準備を実行... | |
293 | + //prepareToStart(); | |
294 | + return; | |
295 | + } | |
296 | + // 画面の再描画を指示する | |
297 | + redrawSurfaceview(); | |
298 | + } | |
299 | + | |
300 | + /** | |
301 | + * 背景画像イメージの更新処理 | |
302 | + * | |
303 | + */ | |
304 | + private void updateBackgroundImage(String uri) | |
305 | + { | |
306 | + // 背景画像イメージの更新処理 | |
307 | + GokigenSurfaceView graphView = parent.findViewById(R.id.GraphicView); | |
308 | + | |
309 | + // ビットマップを設定する | |
310 | + objectDrawer.updateBackgroundBitmap(uri, graphView.getWidth(), graphView.getHeight()); | |
311 | + | |
312 | + // 画面の再描画指示 | |
313 | + graphView.doDraw(); | |
314 | + } | |
315 | + | |
316 | + | |
317 | + /** | |
318 | + * クリックされたときの処理 | |
319 | + */ | |
320 | + public void onClick(View v) | |
321 | + { | |
322 | + int id = v.getId(); | |
323 | + | |
324 | + //Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::onClick() " + id); | |
325 | + if (id == R.id.MeMoMaInfo) | |
326 | + { | |
327 | + // テキスト編集ダイアログを表示する | |
328 | + showInfoMessageEditDialog(); | |
329 | + } | |
330 | + else if (id == R.id.LineStyleButton) | |
331 | + { | |
332 | + // ライン形状を変えるダイアログで変更するように変更する | |
333 | + selectLineShapeDialog(); | |
334 | + } | |
335 | + else if (id == R.id.ExpandButton) | |
336 | + { | |
337 | + // 拡張メニューを呼び出す | |
338 | + callExtendMenu(); | |
339 | + } | |
340 | + else if ((id == R.id.DeleteObjectButton)||(id == R.id.CreateObjectButton)) | |
341 | + { | |
342 | + // 削除ボタン or 作成ボタンが押された時の処理 | |
343 | + updateButtons(drawModeHolder.updateOperationMode(id)); | |
344 | + } | |
345 | + else if (id == R.id.HomeButton) | |
346 | + { | |
347 | + // 表示位置をリセットする | |
348 | + // 表示倍率と並行移動についてリセットする | |
349 | + objectDrawer.resetScaleAndLocation((SeekBar) parent.findViewById(R.id.ZoomInOut)); | |
279 | 350 | |
280 | - } | |
281 | - else if (requestCode == MENU_ID_EXTEND) | |
282 | - { | |
283 | - // その他...今開いているファイルを読みなおす | |
284 | - dataInOutManager.loadFile((String) parent.getTitle()); | |
285 | - } | |
286 | - else | |
287 | - { | |
288 | - // 画面表示の準備を実行... | |
289 | - //prepareToStart(); | |
290 | - return; | |
291 | - } | |
292 | 351 | // 画面の再描画を指示する |
293 | - redrawSurfaceview(); | |
294 | - } | |
295 | - | |
296 | - /** | |
297 | - * 背景画像イメージの更新処理 | |
298 | - * | |
299 | - */ | |
300 | - private void updateBackgroundImage(String uri) | |
301 | - { | |
302 | - // 背景画像イメージの更新処理 | |
303 | - GokigenSurfaceView graphView = (GokigenSurfaceView) parent.findViewById(R.id.GraphicView); | |
304 | - | |
305 | - // ビットマップを設定する | |
306 | - objectDrawer.updateBackgroundBitmap(uri, graphView.getWidth(), graphView.getHeight()); | |
307 | - | |
308 | - // 画面の再描画指示 | |
309 | - graphView.doDraw(); | |
310 | - } | |
311 | - | |
312 | - | |
313 | - /** | |
314 | - * クリックされたときの処理 | |
315 | - */ | |
316 | - public void onClick(View v) | |
317 | - { | |
318 | - int id = v.getId(); | |
319 | - | |
320 | - //Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::onClick() " + id); | |
321 | - if (id == R.id.MeMoMaInfo) | |
322 | - { | |
323 | - // テキスト編集ダイアログを表示する | |
324 | - showInfoMessageEditDialog(); | |
325 | - } | |
326 | - else if (id == R.id.LineStyleButton) | |
327 | - { | |
328 | - // ライン形状を変えるダイアログで変更するように変更する | |
329 | - selectLineShapeDialog(); | |
330 | - } | |
331 | - else if (id == R.id.ExpandButton) | |
332 | - { | |
333 | - // 拡張メニューを呼び出す | |
334 | - callExtendMenu(); | |
335 | - } | |
336 | - else if ((id == R.id.DeleteObjectButton)||(id == R.id.CreateObjectButton)) | |
337 | - { | |
338 | - // 削除ボタン or 作成ボタンが押された時の処理 | |
339 | - updateButtons(drawModeHolder.updateOperationMode(id)); | |
340 | - } | |
341 | - else if (id == R.id.HomeButton) | |
342 | - { | |
343 | - /** 表示位置をリセットする **/ | |
344 | - // 表示倍率と並行移動についてリセットする | |
345 | - objectDrawer.resetScaleAndLocation((SeekBar) parent.findViewById(R.id.ZoomInOut)); | |
346 | - | |
347 | - // 画面の再描画を指示する | |
348 | - redrawSurfaceview(); | |
349 | - } | |
350 | - else if (id == R.id.SaveButton) | |
351 | - { | |
352 | - // データ保存が指示された! | |
353 | - saveData(true); | |
354 | - } | |
355 | - } | |
356 | - | |
357 | - /** | |
358 | - * 触られたときの処理 | |
359 | - * | |
360 | - */ | |
361 | - public boolean onTouch(View v, MotionEvent event) | |
362 | - { | |
363 | - int id = v.getId(); | |
364 | - // int action = event.getAction(); | |
365 | - | |
366 | - //Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::onTouch() " + id); | |
367 | - | |
368 | - if (id == R.id.GraphicView) | |
369 | - { | |
370 | - // 画面をタッチした! | |
371 | - ((GokigenSurfaceView) v).onTouchEvent(event); | |
372 | - return (true); | |
373 | - } | |
374 | - return (false); | |
375 | - } | |
376 | - | |
377 | - /** | |
378 | - * キーを押したときの操作 | |
379 | - */ | |
380 | - public boolean onKey(View v, int keyCode, KeyEvent event) | |
381 | - { | |
382 | - int action = event.getAction(); | |
383 | - if ((action == KeyEvent.ACTION_DOWN)&&(keyCode == KeyEvent.KEYCODE_DPAD_CENTER)) | |
384 | - { | |
385 | - // | |
386 | - } | |
387 | - | |
388 | - Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::onKey() "); | |
389 | - return (false); | |
390 | - } | |
391 | - | |
392 | - /** | |
393 | - * メニューへのアイテム追加 | |
394 | - * @param menu | |
395 | - * @return | |
396 | - */ | |
397 | - public Menu onCreateOptionsMenu(Menu menu) | |
398 | - { | |
399 | - // 新規作成 | |
400 | - MenuItem menuItem = menu.add(Menu.NONE, MENU_ID_NEW, Menu.NONE, parent.getString(R.string.createnew)); | |
401 | - menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); /* for Android 3.1 */ | |
402 | - menuItem.setIcon(android.R.drawable.ic_menu_add); // 丸プラス | |
403 | - | |
404 | - // 画像の共有 | |
405 | - menuItem = menu.add(Menu.NONE, MENU_ID_SHARE, Menu.NONE, parent.getString(R.string.shareContent)); | |
406 | - menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); /* for Android 3.1 */ | |
407 | - menuItem.setIcon(android.R.drawable.ic_menu_share); | |
408 | - | |
409 | - // 画像のキャプチャ | |
410 | - menuItem = menu.add(Menu.NONE, MENU_ID_CAPTURE, Menu.NONE, parent.getString(R.string.capture_data)); | |
411 | - menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); /* for Android 3.1 */ | |
412 | - menuItem.setIcon(android.R.drawable.ic_menu_crop); // オブジェクトのキャプチャ | |
413 | - | |
414 | - // オブジェクトの整列 | |
415 | - menuItem = menu.add(Menu.NONE, MENU_ID_ALIGN, Menu.NONE, parent.getString(R.string.align_data)); | |
416 | - menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); /* for Android 3.1 */ | |
417 | - menuItem.setIcon(android.R.drawable.ic_menu_rotate); // オブジェクトの整列 | |
418 | - | |
419 | - // タイトルの変更 | |
420 | - menuItem = menu.add(Menu.NONE, MENU_ID_RENAME, Menu.NONE, parent.getString(R.string.rename_title)); | |
421 | - menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); /* for Android 3.1 */ | |
422 | - menuItem.setIcon(android.R.drawable.ic_menu_edit); // タイトルの変更 | |
423 | - | |
424 | - // 壁紙の選択 | |
425 | - menuItem = menu.add(Menu.NONE, MENU_ID_INSERT_PICTURE, Menu.NONE, parent.getString(R.string.background_data)); | |
426 | - menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); /* for Android 3.1 */ | |
427 | - menuItem.setIcon(android.R.drawable.ic_menu_gallery); // 壁紙の選択 | |
428 | - | |
429 | - // 拡張メニュー | |
430 | - menuItem = menu.add(Menu.NONE, MENU_ID_EXTEND, Menu.NONE, parent.getString(R.string.extend_menu)); | |
431 | - menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); /* for Android 3.1 */ | |
432 | - menuItem.setIcon(android.R.drawable.ic_menu_share); // 拡張メニュー... | |
433 | - | |
434 | - // 設定 | |
435 | - menuItem = menu.add(Menu.NONE, MENU_ID_PREFERENCES, Menu.NONE, parent.getString(R.string.preference_name)); | |
436 | - menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); /* for Android 3.1 */ | |
437 | - menuItem.setIcon(android.R.drawable.ic_menu_preferences); | |
438 | - | |
439 | - // クレジット情報の表示 | |
440 | - menuItem = menu.add(Menu.NONE, MENU_ID_ABOUT_GOKIGEN, Menu.NONE, parent.getString(R.string.about_gokigen)); | |
441 | - menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); /* for Android 3.1 */ | |
442 | - menuItem.setIcon(android.R.drawable.ic_menu_info_details); | |
443 | - | |
444 | - return (menu); | |
445 | - } | |
446 | - | |
447 | - /** | |
448 | - * メニュー表示前の処理 | |
449 | - * @param menu | |
450 | - * @return | |
451 | - */ | |
452 | - public void onPrepareOptionsMenu(Menu menu) | |
453 | - { | |
454 | - menu.findItem(MENU_ID_NEW).setVisible(true); | |
455 | - menu.findItem(MENU_ID_SHARE).setVisible(true); | |
456 | - menu.findItem(MENU_ID_CAPTURE).setVisible(true); | |
457 | - menu.findItem(MENU_ID_ALIGN).setVisible(true); | |
458 | - menu.findItem(MENU_ID_RENAME).setVisible(true); | |
459 | - menu.findItem(MENU_ID_INSERT_PICTURE).setVisible(true); | |
460 | - menu.findItem(MENU_ID_EXTEND).setVisible(true); | |
461 | - menu.findItem(MENU_ID_PREFERENCES).setVisible(true); | |
462 | - menu.findItem(MENU_ID_ABOUT_GOKIGEN).setVisible(true); | |
463 | - return; | |
464 | - } | |
465 | - | |
466 | - /** | |
467 | - * メニューのアイテムが選択されたときの処理 | |
468 | - * @param item | |
469 | - * @return | |
470 | - */ | |
471 | - public boolean onOptionsItemSelected(MenuItem item) | |
472 | - { | |
473 | - boolean result = false; | |
474 | - switch (item.getItemId()) | |
475 | - { | |
476 | - case MENU_ID_PREFERENCES: | |
477 | - showPreference(); | |
478 | - result = true; | |
479 | - break; | |
480 | - | |
481 | - case MENU_ID_ABOUT_GOKIGEN: | |
482 | - showAboutGokigen(); | |
483 | - result = true; | |
484 | - break; | |
485 | - | |
486 | - case MENU_ID_NEW: | |
487 | - createNewScreen(); | |
488 | - result = true; | |
489 | - break; | |
490 | - | |
491 | - case MENU_ID_EXTEND: | |
492 | - // 拡張メニューを呼び出す | |
493 | - callExtendMenu(); | |
494 | - result = true; | |
495 | - break; | |
496 | - | |
497 | - case MENU_ID_ALIGN: | |
352 | + redrawSurfaceview(); | |
353 | + } | |
354 | + else if (id == R.id.SaveButton) | |
355 | + { | |
356 | + // データ保存が指示された! | |
357 | + saveData(true); | |
358 | + } | |
359 | + } | |
360 | + | |
361 | + /** | |
362 | + * 触られたときの処理 | |
363 | + * | |
364 | + */ | |
365 | + public boolean onTouch(View v, MotionEvent event) | |
366 | + { | |
367 | + int id = v.getId(); | |
368 | + // int action = event.getAction(); | |
369 | + | |
370 | + //Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::onTouch() " + id); | |
371 | + | |
372 | + if (id == R.id.GraphicView) | |
373 | + { | |
374 | + // 画面をタッチした! | |
375 | + v.onTouchEvent(event); | |
376 | + return (true); | |
377 | + } | |
378 | + return (false); | |
379 | + } | |
380 | + | |
381 | + /** | |
382 | + * キーを押したときの操作 | |
383 | + */ | |
384 | + public boolean onKey(View v, int keyCode, KeyEvent event) | |
385 | + { | |
386 | + int action = event.getAction(); | |
387 | + if ((action == KeyEvent.ACTION_DOWN)&&(keyCode == KeyEvent.KEYCODE_DPAD_CENTER)) | |
388 | + { | |
389 | + // | |
390 | + Log.v(Main.APP_IDENTIFIER, "KEY ENTER"); | |
391 | + } | |
392 | + | |
393 | + Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::onKey() "); | |
394 | + return (false); | |
395 | + } | |
396 | + | |
397 | + /** | |
398 | + * メニューへのアイテム追加 | |
399 | + * | |
400 | + */ | |
401 | + public Menu onCreateOptionsMenu(Menu menu) | |
402 | + { | |
403 | + // 新規作成 | |
404 | + MenuItem menuItem = menu.add(Menu.NONE, MENU_ID_NEW, Menu.NONE, parent.getString(R.string.createnew)); | |
405 | + menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); /* for Android 3.1 */ | |
406 | + menuItem.setIcon(android.R.drawable.ic_menu_add); // 丸プラス | |
407 | + | |
408 | + // 画像の共有 | |
409 | + menuItem = menu.add(Menu.NONE, MENU_ID_SHARE, Menu.NONE, parent.getString(R.string.shareContent)); | |
410 | + menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); /* for Android 3.1 */ | |
411 | + menuItem.setIcon(android.R.drawable.ic_menu_share); | |
412 | + | |
413 | + // 画像のキャプチャ | |
414 | + menuItem = menu.add(Menu.NONE, MENU_ID_CAPTURE, Menu.NONE, parent.getString(R.string.capture_data)); | |
415 | + menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); /* for Android 3.1 */ | |
416 | + menuItem.setIcon(android.R.drawable.ic_menu_crop); // オブジェクトのキャプチャ | |
417 | + | |
418 | + // 処理のUNDO | |
419 | + menuItem = menu.add(Menu.NONE, MENU_ID_UNDO, Menu.NONE, parent.getString(R.string.undo_operation)); | |
420 | + menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); /* for Android 3.1 */ | |
421 | + menuItem.setIcon(android.R.drawable.ic_menu_revert); | |
422 | + | |
423 | + // オブジェクトの整列 | |
424 | + menuItem = menu.add(Menu.NONE, MENU_ID_ALIGN, Menu.NONE, parent.getString(R.string.align_data)); | |
425 | + menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); /* for Android 3.1 */ | |
426 | + menuItem.setIcon(android.R.drawable.ic_menu_rotate); // オブジェクトの整列 | |
427 | + | |
428 | + // タイトルの変更 | |
429 | + menuItem = menu.add(Menu.NONE, MENU_ID_RENAME, Menu.NONE, parent.getString(R.string.rename_title)); | |
430 | + menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); /* for Android 3.1 */ | |
431 | + menuItem.setIcon(android.R.drawable.ic_menu_edit); // タイトルの変更 | |
432 | + | |
433 | + // 壁紙の選択 | |
434 | + menuItem = menu.add(Menu.NONE, MENU_ID_INSERT_PICTURE, Menu.NONE, parent.getString(R.string.background_data)); | |
435 | + menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); /* for Android 3.1 */ | |
436 | + menuItem.setIcon(android.R.drawable.ic_menu_gallery); // 壁紙の選択 | |
437 | + | |
438 | + // 拡張メニュー | |
439 | + menuItem = menu.add(Menu.NONE, MENU_ID_EXTEND, Menu.NONE, parent.getString(R.string.extend_menu)); | |
440 | + menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); /* for Android 3.1 */ | |
441 | + menuItem.setIcon(android.R.drawable.ic_menu_share); // 拡張メニュー... | |
442 | + | |
443 | + // 設定 | |
444 | + menuItem = menu.add(Menu.NONE, MENU_ID_PREFERENCES, Menu.NONE, parent.getString(R.string.preference_name)); | |
445 | + menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); /* for Android 3.1 */ | |
446 | + menuItem.setIcon(android.R.drawable.ic_menu_preferences); | |
447 | + | |
448 | + // クレジット情報の表示 | |
449 | + menuItem = menu.add(Menu.NONE, MENU_ID_ABOUT_GOKIGEN, Menu.NONE, parent.getString(R.string.about_gokigen)); | |
450 | + menuItem.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); /* for Android 3.1 */ | |
451 | + menuItem.setIcon(android.R.drawable.ic_menu_info_details); | |
452 | + | |
453 | + return (menu); | |
454 | + } | |
455 | + | |
456 | + /** | |
457 | + * メニュー表示前の処理 | |
458 | + * | |
459 | + * | |
460 | + */ | |
461 | + public void onPrepareOptionsMenu(Menu menu) | |
462 | + { | |
463 | + menu.findItem(MENU_ID_NEW).setVisible(true); | |
464 | + menu.findItem(MENU_ID_UNDO).setVisible(false); | |
465 | + menu.findItem(MENU_ID_SHARE).setVisible(true); | |
466 | + menu.findItem(MENU_ID_CAPTURE).setVisible(true); | |
467 | + menu.findItem(MENU_ID_ALIGN).setVisible(true); | |
468 | + menu.findItem(MENU_ID_RENAME).setVisible(true); | |
469 | + menu.findItem(MENU_ID_INSERT_PICTURE).setVisible(true); | |
470 | + menu.findItem(MENU_ID_EXTEND).setVisible(true); | |
471 | + menu.findItem(MENU_ID_PREFERENCES).setVisible(true); | |
472 | + menu.findItem(MENU_ID_ABOUT_GOKIGEN).setVisible(true); | |
473 | + } | |
474 | + | |
475 | + /** | |
476 | + * メニューのアイテムが選択されたときの処理 | |
477 | + * | |
478 | + * | |
479 | + */ | |
480 | + public boolean onOptionsItemSelected(MenuItem item) | |
481 | + { | |
482 | + boolean result; | |
483 | + switch (item.getItemId()) | |
484 | + { | |
485 | + case MENU_ID_PREFERENCES: | |
486 | + showPreference(); | |
487 | + result = true; | |
488 | + break; | |
489 | + | |
490 | + case MENU_ID_ABOUT_GOKIGEN: | |
491 | + showAboutGokigen(); | |
492 | + result = true; | |
493 | + break; | |
494 | + | |
495 | + case MENU_ID_NEW: | |
496 | + createNewScreen(); | |
497 | + result = true; | |
498 | + break; | |
499 | + | |
500 | + case MENU_ID_EXTEND: | |
501 | + // 拡張メニューを呼び出す | |
502 | + callExtendMenu(); | |
503 | + result = true; | |
504 | + break; | |
505 | + | |
506 | + case MENU_ID_ALIGN: | |
498 | 507 | // オブジェクトの整列を行う |
499 | - alignData(); | |
508 | + alignData(); | |
500 | 509 | result = true; |
501 | - break; | |
502 | - | |
503 | - case MENU_ID_RENAME: | |
504 | - // タイトル名の変更 (テキスト編集ダイアログを表示する) | |
505 | - showInfoMessageEditDialog(); | |
506 | - result = true; | |
507 | - break; | |
508 | - | |
509 | - case MENU_ID_INSERT_PICTURE: | |
510 | - // 背景画像の設定を行う | |
511 | - insertPicture(); | |
512 | - result = true; | |
513 | - break; | |
514 | - | |
515 | - case MENU_ID_CAPTURE: | |
516 | - // 画面キャプチャを指示された場合... | |
517 | - doCapture(false); | |
518 | - result = true; | |
519 | - break; | |
520 | - | |
521 | - case MENU_ID_SHARE: | |
522 | - // 画面キャプチャ&共有を指示された場合... | |
523 | - doCapture(true); | |
524 | - result = true; | |
525 | - break; | |
526 | - | |
527 | - case android.R.id.home: | |
528 | - // アイコンが押された時の処理... | |
529 | - // テキスト編集ダイアログを表示する | |
530 | - showInfoMessageEditDialog(); | |
531 | - result = true; | |
532 | - break; | |
533 | - | |
534 | - default: | |
535 | - result = false; | |
536 | - break; | |
537 | - } | |
538 | - return (result); | |
539 | - } | |
540 | - | |
541 | - /** | |
542 | - * 画像ファイルの挿入 (データファイルの更新) | |
543 | - * | |
544 | - */ | |
545 | - private void insertPicture() | |
546 | - { | |
547 | - Intent intent; | |
548 | - if (Build.VERSION.SDK_INT >= 19) { | |
549 | - intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); | |
550 | - intent.addCategory(Intent.CATEGORY_OPENABLE); | |
551 | - intent.setType("image/*"); | |
552 | - //intent.setAction(Intent.ACTION_GET_CONTENT); | |
553 | - } else { | |
554 | - intent = new Intent(); | |
555 | - intent.setType("image/*"); | |
556 | - intent.setAction(Intent.ACTION_GET_CONTENT); | |
557 | - } | |
558 | - parent.startActivityForResult(intent, MENU_ID_INSERT_PICTURE); | |
559 | - } | |
560 | - | |
561 | - /** | |
562 | - * 画面キャプチャの実施 | |
563 | - * | |
564 | - * | |
565 | - */ | |
566 | - private void doCapture(boolean isShare) | |
567 | - { | |
568 | - // 画面のスクリーンショットをとる処理を実行する | |
569 | - dataInOutManager.doScreenCapture((String) parent.getTitle(), objectHolder, objectDrawer, isShare); | |
570 | - | |
571 | - // 画面を再描画する | |
572 | - redrawSurfaceview(); | |
573 | - } | |
574 | - | |
575 | - /** | |
576 | - * アプリの情報を表示する | |
577 | - * | |
578 | - */ | |
579 | - private void showAboutGokigen() | |
580 | - { | |
581 | - // アプリの情報(クレジット)を表示する! | |
582 | - parent.showDialog(R.id.info_about_gokigen); | |
583 | - } | |
584 | - | |
585 | - /** | |
586 | - * 拡張メニューを呼び出す | |
587 | - * | |
588 | - */ | |
589 | - private void callExtendMenu() | |
590 | - { | |
591 | - // 現在表示中のデータをファイルに保存する | |
592 | - dataInOutManager.saveFile((String) parent.getTitle(), true); | |
593 | - | |
594 | - // 現在読み込んでいるファイルのファイル名を生成する | |
595 | - String fullPath = dataInOutManager.getDataFileFullPath((String) parent.getTitle(), ".xml"); | |
596 | - | |
597 | - // ここで拡張メニューを呼び出す | |
598 | - // (渡すデータを作って Intentとする) | |
599 | - Intent intent = new Intent(); | |
600 | - | |
601 | - intent.setAction(ExtensionActivity.MEMOMA_EXTENSION_LAUNCH_ACTIVITY); | |
602 | - intent.putExtra(ExtensionActivity.MEMOMA_EXTENSION_DATA_FULLPATH, fullPath); | |
603 | - intent.putExtra(ExtensionActivity.MEMOMA_EXTENSION_DATA_TITLE, (String) parent.getTitle()); | |
604 | - | |
605 | - // データ表示用Activityを起動する | |
606 | - parent.startActivityForResult(intent, MENU_ID_EXTEND); | |
607 | - } | |
608 | - | |
609 | - /** | |
610 | - * データの読み込みを行う | |
611 | - * | |
612 | - */ | |
613 | - private void prepareMeMoMaInfo() | |
614 | - { | |
615 | - // 設定に記録されているデータを画面のタイトルに反映させる | |
616 | - SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent); | |
617 | - String memomaInfo = preferences.getString("MeMoMaInfo", parent.getString(R.string.app_name)); | |
618 | - parent.setTitle(memomaInfo); | |
619 | - | |
620 | - // アクションバーとファイル名の準備 | |
621 | - android.support.v7.app.ActionBar bar = parent.getSupportActionBar(); | |
622 | - if (bar != null) | |
623 | - { | |
624 | - dataInOutManager.prepare(objectHolder, bar, memomaInfo); | |
625 | - } | |
626 | - | |
627 | - //dataInOutManager.loadFile((String) parent.getTitle()); | |
628 | - } | |
629 | - | |
630 | - /** | |
631 | - * データの保存を行う | |
632 | - * | |
633 | - * | |
634 | - * @param forceOverwrite trueの時は、ファイル名が確定していたときは(確認せずに)上書き保存を自動で行う。 | |
635 | - * | |
636 | - */ | |
637 | - private void saveData(boolean forceOverwrite) | |
638 | - { | |
639 | - dataInOutManager.saveFile((String) parent.getTitle(), forceOverwrite); | |
640 | - } | |
641 | - | |
642 | - /** | |
643 | - * データの整列を行う | |
644 | - * | |
645 | - */ | |
646 | - private void alignData() | |
647 | - { | |
648 | - ObjectAligner aligner = new ObjectAligner(parent, this); | |
649 | - aligner.execute(objectHolder); | |
650 | - } | |
651 | - | |
652 | - /** | |
653 | - * メッセージ編集ダイアログを表示する | |
654 | - * | |
655 | - */ | |
656 | - private void showInfoMessageEditDialog() | |
657 | - { | |
658 | - parent.showDialog(R.id.editTextArea); | |
659 | - } | |
660 | - | |
661 | - /** | |
662 | - * 新規作成が指示されたとき...全部クリアして作りなおして良いか確認する。 | |
663 | - * | |
664 | - */ | |
665 | - private void createNewScreen() | |
666 | - { | |
667 | - parent.showDialog(R.id.confirmation); | |
668 | - } | |
669 | - | |
670 | - /** | |
671 | - * 接続線の設定ダイアログを表示する | |
672 | - */ | |
673 | - private void selectLineShapeDialog() | |
674 | - { | |
675 | - // 接続線の設定ダイアログを表示する... | |
676 | - parent.showDialog(R.id.selectline_dialog); | |
677 | - } | |
678 | - | |
679 | - /** | |
680 | - * メッセージ編集ダイアログの表示を準備する | |
681 | - * | |
682 | - */ | |
683 | - private void prepareInfoMessageEditDialog(Dialog dialog) | |
684 | - { | |
685 | - String message = (String) parent.getTitle(); | |
686 | - editTextDialog.prepare(dialog, this, parent.getString(R.string.dataTitle), message, true); | |
687 | - } | |
688 | - | |
689 | - /** | |
690 | - * メッセージ編集ダイアログの表示を準備する | |
691 | - * | |
692 | - */ | |
693 | - private void prepareConfirmationDialog(Dialog dialog) | |
694 | - { | |
695 | - // Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::prepareConfirmationDialog() " ); | |
696 | - } | |
697 | - | |
698 | - /** | |
699 | - * オブジェクト入力用ダイアログの表示を準備する | |
700 | - * | |
701 | - */ | |
702 | - private void prepareObjectInputDialog(Dialog dialog) | |
703 | - { | |
704 | - Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::prepareObjectInputDialog(), key: " + selectedObjectKey); | |
705 | - | |
706 | - // ダイアログの準備を行う | |
707 | - objectDataInputDialog.prepareObjectInputDialog(dialog, selectedObjectKey); | |
708 | - | |
709 | - } | |
710 | - | |
711 | - /** | |
712 | - * アイテム選択ダイアログの表示を準備する | |
713 | - * | |
714 | - * | |
715 | - */ | |
716 | - private void prepareItemSelectionDialog(Dialog dialog) | |
717 | - { | |
718 | - // アイテム選択ダイアログの表示設定 | |
719 | - // (動的変更時。。。今回は固定なので何もしない) | |
720 | - } | |
721 | - | |
722 | - /** | |
723 | - * 接続線選択用ダイアログの表示を準備する | |
724 | - * | |
725 | - */ | |
726 | - private void prepareLineSelectionDialog(Dialog dialog) | |
727 | - { | |
728 | - Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::prepareLineSelectionDialog(), key: " + selectedObjectKey); | |
729 | - | |
730 | - // ダイアログの準備を行う | |
731 | - lineSelectionDialog.prepareSelectLineShapeDialog(dialog, selectedObjectKey); | |
732 | - } | |
733 | - | |
734 | - /** | |
735 | - * 設定画面を表示する処理 | |
736 | - */ | |
737 | - private void showPreference() | |
738 | - { | |
739 | - try | |
740 | - { | |
741 | - // 設定画面を呼び出す | |
742 | - Intent prefIntent = new Intent(parent,Preference.class); | |
743 | - parent.startActivityForResult(prefIntent, MENU_ID_PREFERENCES); | |
744 | - } | |
745 | - catch (Exception e) | |
746 | - { | |
747 | - // 例外発生...なにもしない。 | |
748 | - e.printStackTrace(); | |
749 | - //updater.showMessage("ERROR", MainUpdater.SHOWMETHOD_DONTCARE); | |
750 | - } | |
751 | - } | |
752 | - | |
753 | - /** | |
754 | - * 接続線の形状を反映させる | |
755 | - * | |
756 | - */ | |
757 | - private void setLineStyle() | |
758 | - { | |
759 | - int buttonId = LineStyleHolder.getLineShapeImageId(lineStyleHolder.getLineStyle(), lineStyleHolder.getLineShape()); | |
760 | - final ImageButton lineStyleObj = (ImageButton) parent.findViewById(R.id.LineStyleButton); | |
761 | - lineStyleObj.setImageResource(buttonId); | |
762 | - } | |
763 | - | |
764 | - /** | |
765 | - * オブジェクトが生成された! | |
766 | - * | |
767 | - */ | |
768 | - public void objectCreated() | |
769 | - { | |
770 | - // ここで動作モードを移動モードに戻す。 | |
771 | - drawModeHolder.changeOperationMode(OperationModeHolder.OPERATIONMODE_MOVE); | |
772 | - updateButtons(OperationModeHolder.OPERATIONMODE_MOVE); | |
773 | - | |
774 | - // 画面を再描画する | |
775 | - redrawSurfaceview(); | |
776 | - } | |
777 | - | |
778 | - /** | |
779 | - * 空き領域がタッチされた! | |
780 | - * | |
781 | - */ | |
782 | - public int touchedVacantArea() | |
783 | - { | |
784 | - SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent); | |
785 | - return (Integer.parseInt(preferences.getString("operationMode", "0"))); | |
786 | - } | |
787 | - | |
788 | - /** | |
789 | - * 空き領域でタッチが離された! | |
790 | - * | |
791 | - */ | |
792 | - public int touchUppedVacantArea() | |
793 | - { | |
794 | - SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent); | |
795 | - return (Integer.parseInt(preferences.getString("operationMode", "0"))); | |
796 | - } | |
797 | - | |
798 | - /** | |
799 | - * オブジェクトを本当に削除して良いか確認した後に、オブジェクトを削除する。 | |
800 | - * | |
801 | - * | |
802 | - */ | |
803 | - private void removeObject(Integer key) | |
804 | - { | |
805 | - // 本当に消して良いか、確認をするダイアログを表示して、OKが押されたら消す。 | |
806 | - AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(parent); | |
807 | - alertDialogBuilder.setTitle(parent.getString(R.string.deleteconfirm_title)); | |
808 | - alertDialogBuilder.setIcon(android.R.drawable.ic_dialog_alert); | |
809 | - alertDialogBuilder.setMessage(parent.getString(R.string.deleteconfirm_message)); | |
810 | - | |
811 | - // 削除するオブジェクトのキーを覚えこむ。 | |
812 | - objectKeyToDelete = key; | |
813 | - | |
814 | - // OKボタンの生成 | |
815 | - alertDialogBuilder.setPositiveButton(parent.getString(R.string.confirmYes), new DialogInterface.OnClickListener() | |
816 | - { | |
817 | - public void onClick(DialogInterface dialog, int id) | |
818 | - { | |
819 | - // 削除モードの時... 確認後削除だけど、今は確認なしで削除を行う。 | |
820 | - objectHolder.removePosition(objectKeyToDelete); | |
821 | - | |
822 | - // 削除するオブジェクトに接続されている線もすべて削除する | |
823 | - objectHolder.getConnectLineHolder().removeAllConnection(objectKeyToDelete); | |
824 | - | |
825 | - // ダイアログを閉じる | |
826 | - dialog.dismiss(); | |
827 | - | |
828 | - // ここで動作モードを削除モードから移動モードに戻す。 | |
829 | - drawModeHolder.changeOperationMode(OperationModeHolder.OPERATIONMODE_MOVE); | |
830 | - updateButtons(OperationModeHolder.OPERATIONMODE_MOVE); | |
831 | - | |
832 | - | |
833 | - // 画面を再描画する | |
834 | - redrawSurfaceview(); | |
835 | - } | |
836 | - }); | |
837 | - | |
838 | - // Cancelボタンの生成 | |
839 | - alertDialogBuilder.setNegativeButton(parent.getString(R.string.confirmNo), new DialogInterface.OnClickListener() | |
840 | - { | |
841 | - public void onClick(DialogInterface dialog, int id) | |
842 | - { | |
843 | - dialog.cancel(); | |
844 | - } | |
845 | - }); | |
846 | - | |
847 | - // ダイアログはキャンセル可能に設定する | |
848 | - alertDialogBuilder.setCancelable(true); | |
849 | - | |
850 | - // ダイアログを表示する | |
851 | - AlertDialog alertDialog = alertDialogBuilder.create(); | |
852 | - alertDialog.show(); | |
853 | - } | |
854 | - | |
855 | - /** | |
856 | - * オブジェクトを複製する | |
857 | - * | |
858 | - * | |
859 | - */ | |
860 | - private void duplicateObject(Integer key) | |
861 | - { | |
862 | - // 選択中オブジェクトを複製する | |
863 | - objectHolder.duplicatePosition(key); | |
864 | - | |
865 | - // 画面を再描画する | |
866 | - redrawSurfaceview(); | |
867 | - } | |
868 | - | |
869 | - /** | |
870 | - * オブジェクトを拡大する | |
871 | - * | |
872 | - * | |
873 | - */ | |
874 | - private void expandObject(Integer key) | |
875 | - { | |
876 | - // 選択中オブジェクトを拡大する | |
877 | - objectHolder.expandObjectSize(key); | |
878 | - | |
879 | - // 画面を再描画する | |
880 | - redrawSurfaceview(); | |
881 | - } | |
882 | - /** | |
883 | - * オブジェクトを縮小する | |
884 | - * | |
885 | - * | |
886 | - */ | |
887 | - private void shrinkObject(Integer key) | |
888 | - { | |
889 | - // 選択中オブジェクトを縮小する | |
890 | - objectHolder.shrinkObjectSize(key); | |
891 | - | |
892 | - // 画面を再描画する | |
893 | - redrawSurfaceview(); | |
894 | - } | |
895 | - | |
896 | - private void setButtonBorder(ImageButton button, boolean isHighlight) | |
897 | - { | |
898 | - try | |
899 | - { | |
900 | - BitmapDrawable btnBackgroundShape = (BitmapDrawable)button.getBackground(); | |
901 | - if (isHighlight) | |
902 | - { | |
903 | -// btnBackgroundShape.setColorFilter(Color.rgb(51, 181, 229), Mode.LIGHTEN); | |
904 | - btnBackgroundShape.setColorFilter(Color.BLUE, Mode.LIGHTEN); | |
905 | - } | |
906 | - else | |
907 | - { | |
908 | - btnBackgroundShape.setColorFilter(Color.BLACK, Mode.LIGHTEN); | |
909 | - } | |
910 | - } | |
911 | - catch (Exception ex) | |
912 | - { | |
913 | - // | |
914 | - Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::setButtonBorder(): " + ex.toString()); | |
915 | - } | |
916 | - } | |
917 | - | |
918 | - /** | |
919 | - * ボタンを更新する | |
920 | - * | |
921 | - */ | |
922 | - private void updateButtons(int mode) | |
923 | - { | |
924 | - final ImageButton createObjectButton = (ImageButton) parent.findViewById(R.id.CreateObjectButton); | |
925 | - final ImageButton deleteObjectButton = (ImageButton) parent.findViewById(R.id.DeleteObjectButton); | |
926 | - | |
927 | - if (mode == OperationModeHolder.OPERATIONMODE_DELETE) | |
928 | - { | |
929 | - setButtonBorder(createObjectButton, false); | |
930 | - setButtonBorder(deleteObjectButton, true); | |
931 | - } | |
932 | - else if (mode == OperationModeHolder.OPERATIONMODE_CREATE) | |
933 | - { | |
934 | - setButtonBorder(createObjectButton, true); | |
935 | - setButtonBorder(deleteObjectButton, false); | |
936 | - } | |
937 | - else // if (mode == OperationModeHolder.OPERATIONMODE_MOVE) | |
938 | - { | |
939 | - setButtonBorder(createObjectButton, false); | |
940 | - setButtonBorder(deleteObjectButton, false); | |
941 | - } | |
942 | - } | |
943 | - | |
944 | - | |
945 | - /** | |
946 | - * オブジェクトが選択された(長押しで!) | |
947 | - * | |
948 | - */ | |
949 | - public void objectSelectedContext(Integer key) | |
950 | - { | |
951 | - Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::objectSelectedContext(), key:" + key); | |
952 | - selectedContextKey = key; | |
953 | - | |
954 | - // オブジェクトのアイテム選択ダイアログを表示する... | |
955 | - parent.showDialog(MENU_ID_OPERATION); | |
956 | - | |
957 | - } | |
958 | - | |
959 | - | |
960 | - /** | |
961 | - * オブジェクトが選択された! | |
962 | - * | |
963 | - */ | |
964 | - public boolean objectSelected(Integer key) | |
965 | - { | |
966 | - SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent); | |
967 | - int operationMode = Integer.parseInt(preferences.getString("operationMode", "0")); | |
968 | - if (operationMode == OperationModeHolder.OPERATIONMODE_DELETE) | |
969 | - { | |
970 | - // オブジェクトを削除する | |
971 | - removeObject(key); | |
972 | - | |
973 | - return (true); | |
974 | - } | |
975 | - //if ((operationMode == OperationModeHolder.OPERATIONMODE_MOVE)|| | |
976 | - // (operationMode == OperationModeHolder.OPERATIONMODE_CREATE)) | |
977 | - { | |
978 | - // 選択されたオブジェクトを記憶する | |
979 | - selectedObjectKey = key; | |
980 | - Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::objectSelected() key : " + key); | |
981 | - | |
982 | - // オブジェクトの詳細設定ダイアログを表示する... | |
983 | - parent.showDialog(R.id.objectinput_dialog); | |
984 | - } | |
985 | - return (true); | |
986 | - } | |
987 | - | |
988 | - /** | |
989 | - * ダイアログの生成 | |
990 | - * | |
991 | - */ | |
992 | - public Dialog onCreateDialog(int id) | |
993 | - { | |
994 | - if (id == R.id.info_about_gokigen) | |
995 | - { | |
996 | - // クレジットダイアログを表示 | |
997 | - CreditDialog dialog = new CreditDialog(parent); | |
998 | - return (dialog.getDialog()); | |
999 | - } | |
1000 | - if (id == R.id.editTextArea) | |
1001 | - { | |
1002 | - // 変更するテキストを表示 | |
1003 | - return (editTextDialog.getDialog()); | |
1004 | - } | |
1005 | - if (id == R.id.confirmation) | |
1006 | - { | |
1007 | - // 確認するメッセージを表示する | |
1008 | - return (confirmationDialog.getDialog()); | |
1009 | - } | |
1010 | - if (id == R.id.objectinput_dialog) | |
1011 | - { | |
1012 | - // オブジェクト入力のダイアログを表示する | |
1013 | - return (objectDataInputDialog.getDialog()); | |
1014 | - } | |
1015 | - if (id == MENU_ID_OPERATION) | |
1016 | - { | |
1017 | - // アイテム選択ダイアログの準備を行う | |
1018 | - return (itemSelectionDialog.getDialog()); | |
1019 | - } | |
1020 | - if (id == R.id.selectline_dialog) | |
1021 | - { | |
1022 | - // 接続線選択ダイアログの準備を行う | |
1023 | - return (lineSelectionDialog.getDialog()); | |
1024 | - } | |
1025 | - return (null); | |
1026 | - } | |
1027 | - | |
1028 | - /** | |
1029 | - * ダイアログ表示の準備 | |
1030 | - * | |
1031 | - */ | |
1032 | - public void onPrepareDialog(int id, Dialog dialog) | |
1033 | - { | |
1034 | - if (id == R.id.editTextArea) | |
1035 | - { | |
1036 | - // 変更するデータを表示する | |
1037 | - prepareInfoMessageEditDialog(dialog); | |
1038 | - return; | |
1039 | - } | |
1040 | - if (id == R.id.confirmation) | |
510 | + break; | |
511 | + | |
512 | + case MENU_ID_RENAME: | |
513 | + // タイトル名の変更 (テキスト編集ダイアログを表示する) | |
514 | + showInfoMessageEditDialog(); | |
515 | + result = true; | |
516 | + break; | |
517 | + | |
518 | + case MENU_ID_INSERT_PICTURE: | |
519 | + // 背景画像の設定を行う | |
520 | + insertPicture(); | |
521 | + result = true; | |
522 | + break; | |
523 | + | |
524 | + case MENU_ID_CAPTURE: | |
525 | + // 画面キャプチャを指示された場合... | |
526 | + doCapture(false); | |
527 | + result = true; | |
528 | + break; | |
529 | + | |
530 | + case MENU_ID_SHARE: | |
531 | + // 画面キャプチャ&共有を指示された場合... | |
532 | + doCapture(true); | |
533 | + result = true; | |
534 | + break; | |
535 | + | |
536 | + case android.R.id.home: | |
537 | + // アイコンが押された時の処理... | |
538 | + // テキスト編集ダイアログを表示する | |
539 | + showInfoMessageEditDialog(); | |
540 | + result = true; | |
541 | + break; | |
542 | + | |
543 | + case MENU_ID_UNDO: | |
544 | + // UNDO処理... | |
545 | + result = undoOperation(); | |
546 | + break; | |
547 | + | |
548 | + default: | |
549 | + result = false; | |
550 | + break; | |
551 | + } | |
552 | + return (result); | |
553 | + } | |
554 | + | |
555 | + | |
556 | + /** | |
557 | + * 操作を1つ戻す(Undo 処理) | |
558 | + * | |
559 | + */ | |
560 | + private boolean undoOperation() | |
561 | + { | |
562 | + return (false); | |
563 | + } | |
564 | + | |
565 | + /** | |
566 | + * 画像ファイルの挿入 (データファイルの更新) | |
567 | + * | |
568 | + */ | |
569 | + private void insertPicture() | |
570 | + { | |
571 | + Intent intent; | |
572 | + if (Build.VERSION.SDK_INT >= 19) { | |
573 | + intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); | |
574 | + intent.addCategory(Intent.CATEGORY_OPENABLE); | |
575 | + intent.setType("image/*"); | |
576 | + //intent.setAction(Intent.ACTION_GET_CONTENT); | |
577 | + } else { | |
578 | + intent = new Intent(); | |
579 | + intent.setType("image/*"); | |
580 | + intent.setAction(Intent.ACTION_GET_CONTENT); | |
581 | + } | |
582 | + parent.startActivityForResult(intent, MENU_ID_INSERT_PICTURE); | |
583 | + } | |
584 | + | |
585 | + /** | |
586 | + * 画面キャプチャの実施 | |
587 | + * | |
588 | + * | |
589 | + */ | |
590 | + private void doCapture(boolean isShare) | |
591 | + { | |
592 | + // 画面のスクリーンショットをとる処理を実行する | |
593 | + dataInOutManager.doScreenCapture((String) parent.getTitle(), objectHolder, objectDrawer, isShare); | |
594 | + | |
595 | + // 画面を再描画する | |
596 | + redrawSurfaceview(); | |
597 | + } | |
598 | + | |
599 | + /** | |
600 | + * アプリの情報を表示する | |
601 | + * | |
602 | + */ | |
603 | + private void showAboutGokigen() | |
604 | + { | |
605 | + // アプリの情報(クレジット)を表示する! | |
606 | + parent.showDialog(R.id.info_about_gokigen); | |
607 | + } | |
608 | + | |
609 | + /** | |
610 | + * 拡張メニューを呼び出す | |
611 | + * | |
612 | + */ | |
613 | + private void callExtendMenu() | |
614 | + { | |
615 | + // 現在表示中のデータをファイルに保存する | |
616 | + dataInOutManager.saveFile((String) parent.getTitle(), true); | |
617 | + | |
618 | + // 現在読み込んでいるファイルのファイル名を生成する | |
619 | + String fullPath = dataInOutManager.getDataFileFullPath((String) parent.getTitle(), ".xml"); | |
620 | + | |
621 | + // ここで拡張メニューを呼び出す | |
622 | + // (渡すデータを作って Intentとする) | |
623 | + Intent intent = new Intent(); | |
624 | + | |
625 | + intent.setAction(ExtensionActivity.MEMOMA_EXTENSION_LAUNCH_ACTIVITY); | |
626 | + intent.putExtra(ExtensionActivity.MEMOMA_EXTENSION_DATA_FULLPATH, fullPath); | |
627 | + intent.putExtra(ExtensionActivity.MEMOMA_EXTENSION_DATA_TITLE, (String) parent.getTitle()); | |
628 | + | |
629 | + // データ表示用Activityを起動する | |
630 | + parent.startActivityForResult(intent, MENU_ID_EXTEND); | |
631 | + } | |
632 | + | |
633 | + /** | |
634 | + * データの読み込みを行う | |
635 | + * | |
636 | + */ | |
637 | + private void prepareMeMoMaInfo() | |
638 | + { | |
639 | + // 設定に記録されているデータを画面のタイトルに反映させる | |
640 | + SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent); | |
641 | + String memomaInfo = preferences.getString("MeMoMaInfo", parent.getString(R.string.app_name)); | |
642 | + parent.setTitle(memomaInfo); | |
643 | + | |
644 | + // アクションバーとファイル名の準備 | |
645 | + android.support.v7.app.ActionBar bar = parent.getSupportActionBar(); | |
646 | + if (bar != null) | |
647 | + { | |
648 | + dataInOutManager.prepare(objectHolder, bar, memomaInfo); | |
649 | + } | |
650 | + | |
651 | + //dataInOutManager.loadFile((String) parent.getTitle()); | |
652 | + } | |
653 | + | |
654 | + /** | |
655 | + * データの保存を行う | |
656 | + * | |
657 | + * | |
658 | + * @param forceOverwrite trueの時は、ファイル名が確定していたときは(確認せずに)上書き保存を自動で行う。 | |
659 | + * | |
660 | + */ | |
661 | + private void saveData(boolean forceOverwrite) | |
662 | + { | |
663 | + dataInOutManager.saveFile((String) parent.getTitle(), forceOverwrite); | |
664 | + } | |
665 | + | |
666 | + /** | |
667 | + * データの整列を行う | |
668 | + * | |
669 | + */ | |
670 | + private void alignData() | |
671 | + { | |
672 | + ObjectAligner aligner = new ObjectAligner(parent, this); | |
673 | + aligner.execute(objectHolder); | |
674 | + } | |
675 | + | |
676 | + /** | |
677 | + * メッセージ編集ダイアログを表示する | |
678 | + * | |
679 | + */ | |
680 | + private void showInfoMessageEditDialog() | |
681 | + { | |
682 | + parent.showDialog(R.id.editTextArea); | |
683 | + } | |
684 | + | |
685 | + /** | |
686 | + * 新規作成が指示されたとき...全部クリアして作りなおして良いか確認する。 | |
687 | + * | |
688 | + */ | |
689 | + private void createNewScreen() | |
690 | + { | |
691 | + parent.showDialog(R.id.confirmation); | |
692 | + } | |
693 | + | |
694 | + /** | |
695 | + * 接続線の設定ダイアログを表示する | |
696 | + */ | |
697 | + private void selectLineShapeDialog() | |
698 | + { | |
699 | + // 接続線の設定ダイアログを表示する... | |
700 | + parent.showDialog(R.id.selectline_dialog); | |
701 | + } | |
702 | + | |
703 | + /** | |
704 | + * メッセージ編集ダイアログの表示を準備する | |
705 | + * | |
706 | + */ | |
707 | + private void prepareInfoMessageEditDialog(Dialog dialog) | |
708 | + { | |
709 | + String message = (String) parent.getTitle(); | |
710 | + editTextDialog.prepare(dialog, this, parent.getString(R.string.dataTitle), message, true); | |
711 | + } | |
712 | + | |
713 | + /** | |
714 | + * メッセージ編集ダイアログの表示を準備する | |
715 | + * | |
716 | + */ | |
717 | + private void prepareConfirmationDialog(Dialog dialog) | |
718 | + { | |
719 | + // Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::prepareConfirmationDialog() " ); | |
720 | + } | |
721 | + | |
722 | + /** | |
723 | + * オブジェクト入力用ダイアログの表示を準備する | |
724 | + * | |
725 | + */ | |
726 | + private void prepareObjectInputDialog(Dialog dialog) | |
727 | + { | |
728 | + Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::prepareObjectInputDialog(), key: " + selectedObjectKey); | |
729 | + | |
730 | + // ダイアログの準備を行う | |
731 | + objectDataInputDialog.prepareObjectInputDialog(dialog, selectedObjectKey); | |
732 | + | |
733 | + } | |
734 | + | |
735 | + /** | |
736 | + * アイテム選択ダイアログの表示を準備する | |
737 | + * | |
738 | + * | |
739 | + */ | |
740 | + private void prepareItemSelectionDialog(Dialog dialog) | |
741 | + { | |
742 | + // アイテム選択ダイアログの表示設定 | |
743 | + // (動的変更時。。。今回は固定なので何もしない) | |
744 | + } | |
745 | + | |
746 | + /** | |
747 | + * 接続線選択用ダイアログの表示を準備する | |
748 | + * | |
749 | + */ | |
750 | + private void prepareLineSelectionDialog(Dialog dialog) | |
751 | + { | |
752 | + Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::prepareLineSelectionDialog(), key: " + selectedObjectKey); | |
753 | + | |
754 | + // ダイアログの準備を行う | |
755 | + lineSelectionDialog.prepareSelectLineShapeDialog(dialog, selectedObjectKey); | |
756 | + } | |
757 | + | |
758 | + /** | |
759 | + * 設定画面を表示する処理 | |
760 | + */ | |
761 | + private void showPreference() | |
762 | + { | |
763 | + try | |
764 | + { | |
765 | + // 設定画面を呼び出す | |
766 | + Intent prefIntent = new Intent(parent,Preference.class); | |
767 | + parent.startActivityForResult(prefIntent, MENU_ID_PREFERENCES); | |
768 | + } | |
769 | + catch (Exception e) | |
770 | + { | |
771 | + // 例外発生...なにもしない。 | |
772 | + e.printStackTrace(); | |
773 | + //updater.showMessage("ERROR", MainUpdater.SHOWMETHOD_DONTCARE); | |
774 | + } | |
775 | + } | |
776 | + | |
777 | + /** | |
778 | + * 接続線の形状を反映させる | |
779 | + * | |
780 | + */ | |
781 | + private void setLineStyle() | |
782 | + { | |
783 | + int buttonId = LineStyleHolder.getLineShapeImageId(lineStyleHolder.getLineStyle(), lineStyleHolder.getLineShape()); | |
784 | + final ImageButton lineStyleObj = parent.findViewById(R.id.LineStyleButton); | |
785 | + lineStyleObj.setImageResource(buttonId); | |
786 | + } | |
787 | + | |
788 | + /** | |
789 | + * オブジェクトが生成された! | |
790 | + * | |
791 | + */ | |
792 | + public void objectCreated() | |
793 | + { | |
794 | + // ここで動作モードを移動モードに戻す。 | |
795 | + drawModeHolder.changeOperationMode(OperationModeHolder.OPERATIONMODE_MOVE); | |
796 | + updateButtons(OperationModeHolder.OPERATIONMODE_MOVE); | |
797 | + | |
798 | + // 画面を再描画する | |
799 | + redrawSurfaceview(); | |
800 | + } | |
801 | + | |
802 | + /** | |
803 | + * 空き領域がタッチされた! | |
804 | + * | |
805 | + */ | |
806 | + public int touchedVacantArea() | |
807 | + { | |
808 | + SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent); | |
809 | + return (Integer.parseInt(preferences.getString("operationMode", "0"))); | |
810 | + } | |
811 | + | |
812 | + /** | |
813 | + * 空き領域でタッチが離された! | |
814 | + * | |
815 | + */ | |
816 | + public int touchUppedVacantArea() | |
817 | + { | |
818 | + SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent); | |
819 | + return (Integer.parseInt(preferences.getString("operationMode", "0"))); | |
820 | + } | |
821 | + | |
822 | + /** | |
823 | + * オブジェクトを本当に削除して良いか確認した後に、オブジェクトを削除する。 | |
824 | + * | |
825 | + * | |
826 | + */ | |
827 | + private void removeObject(Integer key) | |
828 | + { | |
829 | + // 本当に消して良いか、確認をするダイアログを表示して、OKが押されたら消す。 | |
830 | + AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(parent); | |
831 | + alertDialogBuilder.setTitle(parent.getString(R.string.deleteconfirm_title)); | |
832 | + alertDialogBuilder.setIcon(android.R.drawable.ic_dialog_alert); | |
833 | + alertDialogBuilder.setMessage(parent.getString(R.string.deleteconfirm_message)); | |
834 | + | |
835 | + // 削除するオブジェクトのキーを覚えこむ。 | |
836 | + objectKeyToDelete = key; | |
837 | + | |
838 | + // OKボタンの生成 | |
839 | + alertDialogBuilder.setPositiveButton(parent.getString(R.string.confirmYes), new DialogInterface.OnClickListener() | |
840 | + { | |
841 | + public void onClick(DialogInterface dialog, int id) | |
1041 | 842 | { |
1042 | - // 確認ダイアログを表示する。 | |
1043 | - prepareConfirmationDialog(dialog); | |
1044 | - return; | |
843 | + // 削除モードの時... 確認後削除だけど、今は確認なしで削除を行う。 | |
844 | + objectHolder.removePosition(objectKeyToDelete); | |
845 | + | |
846 | + // 削除するオブジェクトに接続されている線もすべて削除する | |
847 | + objectHolder.getConnectLineHolder().removeAllConnection(objectKeyToDelete); | |
848 | + | |
849 | + // ダイアログを閉じる | |
850 | + dialog.dismiss(); | |
851 | + | |
852 | + // ここで動作モードを削除モードから移動モードに戻す。 | |
853 | + drawModeHolder.changeOperationMode(OperationModeHolder.OPERATIONMODE_MOVE); | |
854 | + updateButtons(OperationModeHolder.OPERATIONMODE_MOVE); | |
855 | + | |
856 | + | |
857 | + // 画面を再描画する | |
858 | + redrawSurfaceview(); | |
1045 | 859 | } |
1046 | - if (id == R.id.objectinput_dialog) | |
860 | + }); | |
861 | + | |
862 | + // Cancelボタンの生成 | |
863 | + alertDialogBuilder.setNegativeButton(parent.getString(R.string.confirmNo), new DialogInterface.OnClickListener() | |
864 | + { | |
865 | + public void onClick(DialogInterface dialog, int id) | |
1047 | 866 | { |
1048 | - // オブジェクト入力のダイアログを表示する | |
1049 | - prepareObjectInputDialog(dialog); | |
867 | + dialog.cancel(); | |
1050 | 868 | } |
1051 | - if (id == MENU_ID_OPERATION) | |
869 | + }); | |
870 | + | |
871 | + // ダイアログはキャンセル可能に設定する | |
872 | + alertDialogBuilder.setCancelable(true); | |
873 | + | |
874 | + // ダイアログを表示する | |
875 | + AlertDialog alertDialog = alertDialogBuilder.create(); | |
876 | + alertDialog.show(); | |
877 | + } | |
878 | + | |
879 | + /** | |
880 | + * オブジェクトを複製する | |
881 | + * | |
882 | + * | |
883 | + */ | |
884 | + private void duplicateObject(Integer key) | |
885 | + { | |
886 | + // 選択中オブジェクトを複製する | |
887 | + objectHolder.duplicatePosition(key); | |
888 | + | |
889 | + // 画面を再描画する | |
890 | + redrawSurfaceview(); | |
891 | + } | |
892 | + | |
893 | + /** | |
894 | + * オブジェクトを拡大する | |
895 | + * | |
896 | + * | |
897 | + */ | |
898 | + private void expandObject(Integer key) | |
899 | + { | |
900 | + // 選択中オブジェクトを拡大する | |
901 | + objectHolder.expandObjectSize(key); | |
902 | + | |
903 | + // 画面を再描画する | |
904 | + redrawSurfaceview(); | |
905 | + } | |
906 | + /** | |
907 | + * オブジェクトを縮小する | |
908 | + * | |
909 | + * | |
910 | + */ | |
911 | + private void shrinkObject(Integer key) | |
912 | + { | |
913 | + // 選択中オブジェクトを縮小する | |
914 | + objectHolder.shrinkObjectSize(key); | |
915 | + | |
916 | + // 画面を再描画する | |
917 | + redrawSurfaceview(); | |
918 | + } | |
919 | + | |
920 | + private void setButtonBorder(ImageButton button, boolean isHighlight) | |
921 | + { | |
922 | + try | |
923 | + { | |
924 | + BitmapDrawable btnBackgroundShape = (BitmapDrawable)button.getBackground(); | |
925 | + if (isHighlight) | |
1052 | 926 | { |
1053 | - // オブジェクト操作選択のダイアログを表示する | |
1054 | - prepareItemSelectionDialog(dialog); | |
927 | +// btnBackgroundShape.setColorFilter(Color.rgb(51, 181, 229), Mode.LIGHTEN); | |
928 | + btnBackgroundShape.setColorFilter(Color.BLUE, Mode.LIGHTEN); | |
1055 | 929 | } |
1056 | - if (id == R.id.selectline_dialog) | |
930 | + else | |
1057 | 931 | { |
1058 | - // 接続線選択のダイアログを表示する | |
1059 | - prepareLineSelectionDialog(dialog); | |
932 | + btnBackgroundShape.setColorFilter(Color.BLACK, Mode.LIGHTEN); | |
1060 | 933 | } |
1061 | - } | |
1062 | - | |
1063 | - /** | |
1064 | - * 新規状態に変更する。 | |
1065 | - * | |
1066 | - */ | |
1067 | - public void acceptConfirmation() | |
934 | + } | |
935 | + catch (Exception ex) | |
1068 | 936 | { |
1069 | 937 | // |
1070 | - Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::acceptConfirmation()"); | |
1071 | - | |
1072 | - // オブジェクトデータをクリアする。 | |
1073 | - objectHolder.removeAllPositions(); // オブジェクトの保持クラス | |
1074 | - objectHolder.getConnectLineHolder().removeAllLines(); // オブジェクト間の接続状態保持クラス | |
1075 | - | |
1076 | - // 画面の倍率と表示位置を初期状態に戻す | |
1077 | - if (objectDrawer != null) | |
1078 | - { | |
1079 | - final SeekBar zoomBar = (SeekBar) parent.findViewById(R.id.ZoomInOut); | |
1080 | - objectDrawer.resetScaleAndLocation(zoomBar); | |
1081 | - } | |
1082 | - | |
1083 | - /** | |
1084 | - // 題名を "無題"に変更し、関係情報をクリアする | |
1085 | - String newName = parent.getString(R.string.no_name); | |
1086 | - parent.setTitle(newName); | |
1087 | - SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent); | |
1088 | - SharedPreferences.Editor editor = preferences.edit(); | |
1089 | - editor.putString("MeMoMaInfo", newName); | |
1090 | - editor.commit(); | |
1091 | - **/ | |
1092 | - | |
1093 | - // 画面を再描画する | |
1094 | - redrawSurfaceview(); | |
938 | + Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::setButtonBorder(): " + ex.toString()); | |
939 | + } | |
940 | + } | |
941 | + | |
942 | + /** | |
943 | + * ボタンを更新する | |
944 | + * | |
945 | + */ | |
946 | + private void updateButtons(int mode) | |
947 | + { | |
948 | + final ImageButton createObjectButton = parent.findViewById(R.id.CreateObjectButton); | |
949 | + final ImageButton deleteObjectButton = parent.findViewById(R.id.DeleteObjectButton); | |
950 | + | |
951 | + if (mode == OperationModeHolder.OPERATIONMODE_DELETE) | |
952 | + { | |
953 | + setButtonBorder(createObjectButton, false); | |
954 | + setButtonBorder(deleteObjectButton, true); | |
955 | + } | |
956 | + else if (mode == OperationModeHolder.OPERATIONMODE_CREATE) | |
957 | + { | |
958 | + setButtonBorder(createObjectButton, true); | |
959 | + setButtonBorder(deleteObjectButton, false); | |
960 | + } | |
961 | + else // if (mode == OperationModeHolder.OPERATIONMODE_MOVE) | |
962 | + { | |
963 | + setButtonBorder(createObjectButton, false); | |
964 | + setButtonBorder(deleteObjectButton, false); | |
965 | + } | |
966 | + } | |
1095 | 967 | |
1096 | - // ファイル名選択ダイアログを開く | |
1097 | - showInfoMessageEditDialog(); | |
1098 | 968 | |
969 | + /** | |
970 | + * オブジェクトが選択された(長押しで!) | |
971 | + * | |
972 | + */ | |
973 | + public void objectSelectedContext(Integer key) | |
974 | + { | |
975 | + Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::objectSelectedContext(), key:" + key); | |
976 | + selectedContextKey = key; | |
977 | + | |
978 | + // オブジェクトのアイテム選択ダイアログを表示する... | |
979 | + parent.showDialog(MENU_ID_OPERATION); | |
980 | + | |
981 | + } | |
982 | + | |
983 | + | |
984 | + /** | |
985 | + * オブジェクトが選択された! | |
986 | + * | |
987 | + */ | |
988 | + public boolean objectSelected(Integer key) | |
989 | + { | |
990 | + SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent); | |
991 | + int operationMode = Integer.parseInt(preferences.getString("operationMode", "0")); | |
992 | + if (operationMode == OperationModeHolder.OPERATIONMODE_DELETE) | |
993 | + { | |
994 | + // オブジェクトを削除する | |
995 | + removeObject(key); | |
996 | + | |
997 | + return (true); | |
1099 | 998 | } |
999 | + //if ((operationMode == OperationModeHolder.OPERATIONMODE_MOVE)|| | |
1000 | + // (operationMode == OperationModeHolder.OPERATIONMODE_CREATE)) | |
1001 | + { | |
1002 | + // 選択されたオブジェクトを記憶する | |
1003 | + selectedObjectKey = key; | |
1004 | + Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::objectSelected() key : " + key); | |
1100 | 1005 | |
1101 | - /** | |
1102 | - * 画面を再描画する | |
1103 | - * | |
1104 | - */ | |
1105 | - private void redrawSurfaceview() | |
1006 | + // オブジェクトの詳細設定ダイアログを表示する... | |
1007 | + parent.showDialog(R.id.objectinput_dialog); | |
1008 | + } | |
1009 | + return (true); | |
1010 | + } | |
1011 | + | |
1012 | + /** | |
1013 | + * ダイアログの生成 | |
1014 | + * | |
1015 | + */ | |
1016 | + public Dialog onCreateDialog(int id) | |
1017 | + { | |
1018 | + if (id == R.id.info_about_gokigen) | |
1106 | 1019 | { |
1107 | - final GokigenSurfaceView surfaceview = (GokigenSurfaceView) parent.findViewById(R.id.GraphicView); | |
1108 | - surfaceview.doDraw(); | |
1020 | + // クレジットダイアログを表示 | |
1021 | + CreditDialog dialog = new CreditDialog(parent); | |
1022 | + return (dialog.getDialog()); | |
1109 | 1023 | } |
1110 | - | |
1111 | - /** | |
1112 | - * 不許可。何もしない。 | |
1113 | - * | |
1114 | - */ | |
1115 | - public void rejectConfirmation() | |
1024 | + if (id == R.id.editTextArea) | |
1116 | 1025 | { |
1117 | - Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::rejectConfirmation()"); | |
1026 | + // 変更するテキストを表示 | |
1027 | + return (editTextDialog.getDialog()); | |
1118 | 1028 | } |
1119 | - | |
1120 | - /** | |
1121 | - * オブジェクトが整列された時の処理 | |
1122 | - * | |
1123 | - */ | |
1124 | - public void objectAligned() | |
1029 | + if (id == R.id.confirmation) | |
1125 | 1030 | { |
1126 | - // 画面の再描画を指示する | |
1127 | - redrawSurfaceview(); | |
1031 | + // 確認するメッセージを表示する | |
1032 | + return (confirmationDialog.getDialog()); | |
1128 | 1033 | } |
1129 | - | |
1130 | - /** | |
1131 | - * オブジェクト編集ダイアログが閉じられた時の処理 | |
1132 | - * | |
1133 | - */ | |
1134 | - public void finishObjectInput() | |
1034 | + if (id == R.id.objectinput_dialog) | |
1135 | 1035 | { |
1136 | - // 画面の再描画を指示する | |
1137 | - redrawSurfaceview(); | |
1036 | + // オブジェクト入力のダイアログを表示する | |
1037 | + return (objectDataInputDialog.getDialog()); | |
1138 | 1038 | } |
1139 | - | |
1140 | - /** | |
1141 | - * オブジェクト編集ダイアログが閉じられた時の処理 | |
1142 | - * | |
1143 | - */ | |
1144 | - public void cancelObjectInput() | |
1039 | + if (id == MENU_ID_OPERATION) | |
1145 | 1040 | { |
1146 | - // 何もしない | |
1041 | + // アイテム選択ダイアログの準備を行う | |
1042 | + return (itemSelectionDialog.getDialog()); | |
1147 | 1043 | } |
1148 | - | |
1149 | - | |
1150 | - /** | |
1151 | - * 現在編集中かどうかを知る | |
1152 | - * | |
1153 | - * @return | |
1154 | - */ | |
1155 | - public boolean isEditing() | |
1044 | + if (id == R.id.selectline_dialog) | |
1156 | 1045 | { |
1157 | - return (isEditing); | |
1046 | + // 接続線選択ダイアログの準備を行う | |
1047 | + return (lineSelectionDialog.getDialog()); | |
1158 | 1048 | } |
1159 | - | |
1160 | - /** | |
1161 | - * 現在編集中のフラグを更新する | |
1162 | - * | |
1163 | - * @param value | |
1164 | - */ | |
1165 | - public void setIsEditing(boolean value) | |
1049 | + return (null); | |
1050 | + } | |
1051 | + | |
1052 | + /** | |
1053 | + * ダイアログ表示の準備 | |
1054 | + * | |
1055 | + */ | |
1056 | + public void onPrepareDialog(int id, Dialog dialog) | |
1057 | + { | |
1058 | + if (id == R.id.editTextArea) | |
1166 | 1059 | { |
1167 | - isEditing = value; | |
1060 | + // 変更するデータを表示する | |
1061 | + prepareInfoMessageEditDialog(dialog); | |
1062 | + return; | |
1168 | 1063 | } |
1169 | - | |
1170 | - /** | |
1171 | - * アイテムが選択された! | |
1172 | - * | |
1173 | - */ | |
1174 | - public void itemSelected(int index, String itemValue) | |
1064 | + if (id == R.id.confirmation) | |
1175 | 1065 | { |
1176 | - // | |
1177 | - Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::itemSelected() : " + itemValue + " [" + index + "]"); | |
1178 | - | |
1179 | - if (index == ObjectOperationCommandHolder.OBJECTOPERATION_DELETE) | |
1180 | - { | |
1181 | - // オブジェクト削除の確認 | |
1182 | - removeObject(selectedContextKey); | |
1183 | - } | |
1184 | - else if (index == ObjectOperationCommandHolder.OBJECTOPERATION_DUPLICATE) | |
1185 | - { | |
1186 | - // オブジェクトの複製 | |
1187 | - duplicateObject(selectedContextKey); | |
1188 | - } | |
1189 | - else if (index == ObjectOperationCommandHolder.OBJECTOPERATION_SIZEBIGGER) | |
1190 | - { | |
1191 | - // オブジェクトの拡大 | |
1192 | - expandObject(selectedContextKey); | |
1193 | - } | |
1194 | - else if (index == ObjectOperationCommandHolder.OBJECTOPERATION_SIZESMALLER) | |
1195 | - { | |
1196 | - // オブジェクトの縮小 | |
1197 | - shrinkObject(selectedContextKey); | |
1198 | - } | |
1066 | + // 確認ダイアログを表示する。 | |
1067 | + prepareConfirmationDialog(dialog); | |
1068 | + return; | |
1069 | + } | |
1070 | + if (id == R.id.objectinput_dialog) | |
1071 | + { | |
1072 | + // オブジェクト入力のダイアログを表示する | |
1073 | + prepareObjectInputDialog(dialog); | |
1074 | + } | |
1075 | + if (id == MENU_ID_OPERATION) | |
1076 | + { | |
1077 | + // オブジェクト操作選択のダイアログを表示する | |
1078 | + prepareItemSelectionDialog(dialog); | |
1079 | + } | |
1080 | + if (id == R.id.selectline_dialog) | |
1081 | + { | |
1082 | + // 接続線選択のダイアログを表示する | |
1083 | + prepareLineSelectionDialog(dialog); | |
1084 | + } | |
1085 | + } | |
1086 | + | |
1087 | + /** | |
1088 | + * 新規状態に変更する。 | |
1089 | + * | |
1090 | + */ | |
1091 | + public void acceptConfirmation() | |
1092 | + { | |
1093 | + // | |
1094 | + Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::acceptConfirmation()"); | |
1095 | + | |
1096 | + // オブジェクトデータをクリアする。 | |
1097 | + objectHolder.removeAllPositions(); // オブジェクトの保持クラス | |
1098 | + objectHolder.getConnectLineHolder().removeAllLines(); // オブジェクト間の接続状態保持クラス | |
1099 | + | |
1100 | + // 画面の倍率と表示位置を初期状態に戻す | |
1101 | + if (objectDrawer != null) | |
1102 | + { | |
1103 | + final SeekBar zoomBar = (SeekBar) parent.findViewById(R.id.ZoomInOut); | |
1104 | + objectDrawer.resetScaleAndLocation(zoomBar); | |
1199 | 1105 | } |
1200 | 1106 | |
1201 | - /** | |
1202 | - * (今回未使用) | |
1203 | - * | |
1204 | - */ | |
1205 | - public void itemSelectedMulti(String[] items, boolean[] status) | |
1107 | + /* | |
1108 | + // 題名を "無題"に変更し、関係情報をクリアする | |
1109 | + String newName = parent.getString(R.string.no_name); | |
1110 | + parent.setTitle(newName); | |
1111 | + SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent); | |
1112 | + SharedPreferences.Editor editor = preferences.edit(); | |
1113 | + editor.putString("MeMoMaInfo", newName); | |
1114 | + editor.commit(); | |
1115 | + */ | |
1116 | + | |
1117 | + // 画面を再描画する | |
1118 | + redrawSurfaceview(); | |
1119 | + | |
1120 | + // ファイル名選択ダイアログを開く | |
1121 | + showInfoMessageEditDialog(); | |
1122 | + | |
1123 | + } | |
1124 | + | |
1125 | + /** | |
1126 | + * 画面を再描画する | |
1127 | + * | |
1128 | + */ | |
1129 | + private void redrawSurfaceview() | |
1130 | + { | |
1131 | + final GokigenSurfaceView surfaceview = parent.findViewById(R.id.GraphicView); | |
1132 | + surfaceview.doDraw(); | |
1133 | + } | |
1134 | + | |
1135 | + /** | |
1136 | + * 不許可。何もしない。 | |
1137 | + * | |
1138 | + */ | |
1139 | + public void rejectConfirmation() | |
1140 | + { | |
1141 | + Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::rejectConfirmation()"); | |
1142 | + } | |
1143 | + | |
1144 | + /** | |
1145 | + * オブジェクトが整列された時の処理 | |
1146 | + * | |
1147 | + */ | |
1148 | + public void objectAligned() | |
1149 | + { | |
1150 | + // 画面の再描画を指示する | |
1151 | + redrawSurfaceview(); | |
1152 | + } | |
1153 | + | |
1154 | + /** | |
1155 | + * オブジェクト編集ダイアログが閉じられた時の処理 | |
1156 | + * | |
1157 | + */ | |
1158 | + public void finishObjectInput() | |
1159 | + { | |
1160 | + // 画面の再描画を指示する | |
1161 | + redrawSurfaceview(); | |
1162 | + } | |
1163 | + | |
1164 | + /** | |
1165 | + * オブジェクト編集ダイアログが閉じられた時の処理 | |
1166 | + * | |
1167 | + */ | |
1168 | + public void cancelObjectInput() | |
1169 | + { | |
1170 | + // 何もしない | |
1171 | + } | |
1172 | + | |
1173 | + | |
1174 | + /** | |
1175 | + * 現在編集中かどうかを知る | |
1176 | + * | |
1177 | + * | |
1178 | + */ | |
1179 | + public boolean isEditing() | |
1180 | + { | |
1181 | + return (isEditing); | |
1182 | + } | |
1183 | + | |
1184 | + /** | |
1185 | + * 現在編集中のフラグを更新する | |
1186 | + * | |
1187 | + * | |
1188 | + */ | |
1189 | + public void setIsEditing(boolean value) | |
1190 | + { | |
1191 | + isEditing = value; | |
1192 | + } | |
1193 | + | |
1194 | + /** | |
1195 | + * アイテムが選択された! | |
1196 | + * | |
1197 | + */ | |
1198 | + public void itemSelected(int index, String itemValue) | |
1199 | + { | |
1200 | + // | |
1201 | + Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::itemSelected() : " + itemValue + " [" + index + "]"); | |
1202 | + | |
1203 | + if (index == ObjectOperationCommandHolder.OBJECTOPERATION_DELETE) | |
1206 | 1204 | { |
1207 | - | |
1205 | + // オブジェクト削除の確認 | |
1206 | + removeObject(selectedContextKey); | |
1208 | 1207 | } |
1209 | - public void canceledSelection() | |
1208 | + else if (index == ObjectOperationCommandHolder.OBJECTOPERATION_DUPLICATE) | |
1210 | 1209 | { |
1211 | - | |
1210 | + // オブジェクトの複製 | |
1211 | + duplicateObject(selectedContextKey); | |
1212 | 1212 | } |
1213 | - | |
1214 | - public void onSaveInstanceState(Bundle outState) | |
1213 | + else if (index == ObjectOperationCommandHolder.OBJECTOPERATION_SIZEBIGGER) | |
1215 | 1214 | { |
1216 | - /* ここで状態を保存 */ | |
1217 | - //Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::onSaveInstanceState()"); | |
1215 | + // オブジェクトの拡大 | |
1216 | + expandObject(selectedContextKey); | |
1218 | 1217 | } |
1219 | - | |
1220 | - public void onRestoreInstanceState(Bundle savedInstanceState) | |
1218 | + else if (index == ObjectOperationCommandHolder.OBJECTOPERATION_SIZESMALLER) | |
1221 | 1219 | { |
1222 | - /* ここで状態を復元 */ | |
1223 | - Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::onRestoreInstanceState()"); | |
1220 | + // オブジェクトの縮小 | |
1221 | + shrinkObject(selectedContextKey); | |
1222 | + } | |
1223 | + } | |
1224 | + | |
1225 | + /** | |
1226 | + * (今回未使用) | |
1227 | + * | |
1228 | + */ | |
1229 | + public void itemSelectedMulti(String[] items, boolean[] status) | |
1230 | + { | |
1231 | + | |
1232 | + } | |
1233 | + public void canceledSelection() | |
1234 | + { | |
1235 | + | |
1236 | + } | |
1237 | + | |
1238 | + public void onSaveInstanceState(Bundle outState) | |
1239 | + { | |
1240 | + /* ここで状態を保存 */ | |
1241 | + Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::onSaveInstanceState() : " + outState.toString() ); | |
1242 | + } | |
1243 | + | |
1244 | + public void onRestoreInstanceState(Bundle savedInstanceState) | |
1245 | + { | |
1246 | + /* ここで状態を復元 */ | |
1247 | + Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::onRestoreInstanceState() : " + savedInstanceState.toString()); | |
1248 | + } | |
1249 | + | |
1250 | + public boolean finishTextEditDialog(String message) | |
1251 | + { | |
1252 | + if ((message == null)||(message.length() == 0)) | |
1253 | + { | |
1254 | + // データが入力されていなかったので、何もしない。 | |
1255 | + return (false); | |
1224 | 1256 | } |
1225 | 1257 | |
1226 | - public boolean finishTextEditDialog(String message) | |
1258 | + try | |
1227 | 1259 | { |
1228 | - if ((message == null)||(message.length() == 0)) | |
1229 | - { | |
1230 | - // データが入力されていなかったので、何もしない。 | |
1231 | - return (false); | |
1232 | - } | |
1233 | - | |
1234 | - // 文字列を記録 | |
1235 | - SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent); | |
1260 | + // 文字列を記録 | |
1261 | + SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent); | |
1236 | 1262 | SharedPreferences.Editor editor = preferences.edit(); |
1237 | 1263 | editor.putString("MeMoMaInfo", message); |
1238 | - editor.commit(); | |
1264 | + editor.apply(); | |
1239 | 1265 | |
1240 | 1266 | // タイトルに設定 |
1241 | 1267 | parent.setTitle(message); |
1242 | 1268 | |
1243 | - // 保存シーケンスを一度走らせる | |
1269 | + // 保存シーケンスを一度走らせる | |
1244 | 1270 | saveData(true); |
1245 | 1271 | |
1246 | 1272 | // ファイル選択リストの更新 |
1247 | 1273 | dataInOutManager.updateFileList(message, parent.getSupportActionBar()); |
1248 | 1274 | |
1249 | - return (true); | |
1250 | 1275 | } |
1251 | - public boolean cancelTextEditDialog() | |
1276 | + catch (Exception e) | |
1252 | 1277 | { |
1253 | - return (false); | |
1278 | + e.printStackTrace(); | |
1254 | 1279 | } |
1280 | + return (true); | |
1281 | + } | |
1282 | + public boolean cancelTextEditDialog() | |
1283 | + { | |
1284 | + return (false); | |
1285 | + } | |
1286 | + | |
1287 | + /** | |
1288 | + * 接続線 | |
1289 | + * | |
1290 | + */ | |
1291 | + public void finishSelectLineShape(int style, int shape, int thickness) | |
1292 | + { | |
1293 | + int buttonId = LineStyleHolder.getLineShapeImageId(style, shape); | |
1294 | + final ImageButton lineStyleObj =parent.findViewById(R.id.LineStyleButton); | |
1295 | + lineStyleObj.setImageResource(buttonId); | |
1296 | + //Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::finishSelectLineShape() buttonId:" + buttonId); | |
1297 | + } | |
1298 | + | |
1299 | + /** | |
1300 | + * | |
1301 | + * | |
1302 | + */ | |
1303 | + public void cancelSelectLineShape() | |
1304 | + { | |
1305 | + | |
1306 | + } | |
1255 | 1307 | |
1256 | - /** | |
1257 | - * 接続線 | |
1258 | - * | |
1259 | - */ | |
1260 | - public void finishSelectLineShape(int style, int shape, int thickness) | |
1261 | - { | |
1262 | - int buttonId = LineStyleHolder.getLineShapeImageId(style, shape); | |
1263 | - final ImageButton lineStyleObj = (ImageButton) parent.findViewById(R.id.LineStyleButton); | |
1264 | - lineStyleObj.setImageResource(buttonId); | |
1265 | - //Log.v(Main.APP_IDENTIFIER, "MeMoMaListener::finishSelectLineShape() buttonId:" + buttonId); | |
1266 | - } | |
1267 | - | |
1268 | - /** | |
1269 | - * | |
1270 | - * | |
1271 | - */ | |
1272 | - public void cancelSelectLineShape() | |
1273 | - { | |
1274 | - | |
1275 | - } | |
1276 | 1308 | } |
@@ -9,7 +9,7 @@ import android.view.View; | ||
9 | 9 | import android.widget.AdapterView; |
10 | 10 | import android.widget.ListView; |
11 | 11 | |
12 | -import jp.sourceforge.gokigen.memoma.fileio.ExternalStorageFileUtility; | |
12 | +import jp.sourceforge.gokigen.memoma.io.ExternalStorageFileUtility; | |
13 | 13 | import jp.sourceforge.gokigen.memoma.holders.MeMoMaDataFileHolder; |
14 | 14 | import jp.sourceforge.gokigen.memoma.R; |
15 | 15 |
@@ -1,4 +1,4 @@ | ||
1 | -package jp.sourceforge.gokigen.memoma; | |
1 | +package jp.sourceforge.gokigen.memoma.drawers; | |
2 | 2 | |
3 | 3 | import android.content.Context; |
4 | 4 | import android.graphics.Canvas; |
@@ -8,6 +8,7 @@ import android.view.MotionEvent; | ||
8 | 8 | import android.view.SurfaceHolder; |
9 | 9 | import android.view.SurfaceView; |
10 | 10 | |
11 | +import jp.sourceforge.gokigen.memoma.Main; | |
11 | 12 | import jp.sourceforge.gokigen.memoma.drawers.ICanvasDrawer; |
12 | 13 | |
13 | 14 | /** |
@@ -19,9 +19,10 @@ import android.view.ScaleGestureDetector; | ||
19 | 19 | import android.widget.SeekBar; |
20 | 20 | import android.widget.TextView; |
21 | 21 | |
22 | -import jp.sourceforge.gokigen.memoma.GokigenSurfaceView; | |
22 | +import jp.sourceforge.gokigen.memoma.holders.ObjectConnector; | |
23 | +import jp.sourceforge.gokigen.memoma.holders.PositionObject; | |
23 | 24 | import jp.sourceforge.gokigen.memoma.operations.IObjectSelectionReceiver; |
24 | -import jp.sourceforge.gokigen.memoma.fileio.ImageLoader; | |
25 | +import jp.sourceforge.gokigen.memoma.io.ImageLoader; | |
25 | 26 | import jp.sourceforge.gokigen.memoma.Main; |
26 | 27 | import jp.sourceforge.gokigen.memoma.R; |
27 | 28 | import jp.sourceforge.gokigen.memoma.holders.LineStyleHolder; |
@@ -43,7 +44,7 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes | ||
43 | 44 | public static final int BACKGROUND_COLOR_DEFAULT = 0xff004000; |
44 | 45 | private int backgroundColor = BACKGROUND_COLOR_DEFAULT; |
45 | 46 | |
46 | - private MeMoMaObjectHolder.PositionObject selectedPosition = null; | |
47 | + private PositionObject selectedPosition = null; | |
47 | 48 | private float tempPosX = Float.MIN_VALUE; |
48 | 49 | private float tempPosY = Float.MIN_VALUE; |
49 | 50 | private float downPosX = Float.MIN_VALUE; |
@@ -52,7 +53,7 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes | ||
52 | 53 | // 以下の値は、MeMoMaListenerで初期値を設定する |
53 | 54 | private int objectStyle = MeMoMaObjectHolder.DRAWSTYLE_RECTANGLE; |
54 | 55 | |
55 | - private LineStyleHolder lineStyleHolder = null; | |
56 | + private LineStyleHolder lineStyleHolder; | |
56 | 57 | |
57 | 58 | private float drawScale = 1.0f; // 表示の倍率 |
58 | 59 | private float drawTransX = 0.0f; // 並行移動距離 (X) |
@@ -70,14 +71,14 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes | ||
70 | 71 | private String backgroundBitmapUri = null; |
71 | 72 | private Bitmap backgroundBitmap = null; |
72 | 73 | |
73 | - private MeMoMaObjectHolder objectHolder = null; | |
74 | - private MeMoMaConnectLineHolder lineHolder = null; | |
75 | - private IObjectSelectionReceiver selectionReceiver = null; | |
74 | + private MeMoMaObjectHolder objectHolder; | |
75 | + private MeMoMaConnectLineHolder lineHolder; | |
76 | + private IObjectSelectionReceiver selectionReceiver; | |
76 | 77 | |
77 | - private GestureDetector gestureDetector = null; | |
78 | - private ScaleGestureDetector scaleGestureDetector = null; | |
78 | + private GestureDetector gestureDetector; | |
79 | + private ScaleGestureDetector scaleGestureDetector; | |
79 | 80 | |
80 | - private Activity parent = null; | |
81 | + private Activity parent; | |
81 | 82 | |
82 | 83 | /** |
83 | 84 | * コンストラクタ |
@@ -103,7 +104,7 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes | ||
103 | 104 | * オブジェクトの形状を変更する |
104 | 105 | * (ここで指定された形状のチェックを行っておく。) |
105 | 106 | * |
106 | - * @param style | |
107 | + * | |
107 | 108 | */ |
108 | 109 | public void setObjectStyle(int style) |
109 | 110 | { |
@@ -173,7 +174,7 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes | ||
173 | 174 | /** |
174 | 175 | * 背景画像を設定する |
175 | 176 | * |
176 | - * @param uri | |
177 | + * | |
177 | 178 | */ |
178 | 179 | public void setBackgroundUri(String uri) |
179 | 180 | { |
@@ -183,7 +184,7 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes | ||
183 | 184 | /** |
184 | 185 | * 背景色を(文字列で)設定する |
185 | 186 | * |
186 | - * @param colorString | |
187 | + * | |
187 | 188 | */ |
188 | 189 | public void setBackgroundColor(String colorString) |
189 | 190 | { |
@@ -264,8 +265,8 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes | ||
264 | 265 | // オブジェクトをすべて表示 |
265 | 266 | drawObjects(canvas, 0.0f, 0.0f); |
266 | 267 | |
267 | - /** 移動中かどうかのチェックを行う。 **/ | |
268 | - if (isFlicking(canvas) == true) | |
268 | + // 移動中かどうかのチェックを行う。 | |
269 | + if (isFlicking(canvas)) | |
269 | 270 | { |
270 | 271 | // 移動中の場合、フリック時の軌跡と現在位置を表示する |
271 | 272 | drawTrackAndPositions(canvas); |
@@ -325,7 +326,7 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes | ||
325 | 326 | /** |
326 | 327 | * オブジェクト間の接続線を表示する |
327 | 328 | * |
328 | - * @param canvas | |
329 | + * | |
329 | 330 | */ |
330 | 331 | private void drawConnectionLines(Canvas canvas, float offsetX, float offsetY) |
331 | 332 | { |
@@ -345,8 +346,8 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes | ||
345 | 346 | while (keys.hasMoreElements()) |
346 | 347 | { |
347 | 348 | Integer key = keys.nextElement(); |
348 | - MeMoMaConnectLineHolder.ObjectConnector line = lineHolder.getLine(key); | |
349 | - if (line.key > 0) | |
349 | + ObjectConnector line = lineHolder.getLine(key); | |
350 | + if (line.getKey() > 0) | |
350 | 351 | { |
351 | 352 | // 実際にラインを引く |
352 | 353 | drawLine(canvas, paint, dashLinePaint, line, offsetX, offsetY); |
@@ -362,11 +363,8 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes | ||
362 | 363 | /** |
363 | 364 | * 接続する線を引く |
364 | 365 | * |
365 | - * @param canvas | |
366 | - * @param paint | |
367 | - * @param line | |
368 | 366 | */ |
369 | - public void drawLine(Canvas canvas, Paint paint, Paint dashPaint, MeMoMaConnectLineHolder.ObjectConnector line, float offsetX, float offsetY) | |
367 | + private void drawLine(Canvas canvas, Paint paint, Paint dashPaint, ObjectConnector line, float offsetX, float offsetY) | |
370 | 368 | { |
371 | 369 | try |
372 | 370 | { |
@@ -376,8 +374,8 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes | ||
376 | 374 | return; |
377 | 375 | } |
378 | 376 | |
379 | - MeMoMaObjectHolder.PositionObject from = objectHolder.getPosition(line.fromObjectKey); | |
380 | - MeMoMaObjectHolder.PositionObject to = objectHolder.getPosition(line.toObjectKey); | |
377 | + PositionObject from = objectHolder.getPosition(line.getFromObjectKey()); | |
378 | + PositionObject to = objectHolder.getPosition(line.getToObjectKey()); | |
381 | 379 | if ((from == null)||(to == null)) |
382 | 380 | { |
383 | 381 | // なにもしない |
@@ -385,66 +383,69 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes | ||
385 | 383 | } |
386 | 384 | |
387 | 385 | // ラインの太さを設定する。 |
388 | - paint.setStrokeWidth((float) line.lineThickness); | |
386 | + paint.setStrokeWidth((float) line.getLineThickness()); | |
389 | 387 | |
390 | 388 | // ラインの太さを設定する。 |
391 | - dashPaint.setStrokeWidth((float) line.lineThickness); | |
389 | + dashPaint.setStrokeWidth((float) line.getLineThickness()); | |
392 | 390 | |
393 | 391 | // ラインのスタイル(連続線 or 点線)を設定する |
394 | - Paint linePaint = (line.lineShape == LineStyleHolder.LINESHAPE_DASH) ? dashPaint : paint; | |
392 | + Paint linePaint = (line.getLineShape() == LineStyleHolder.LINESHAPE_DASH) ? dashPaint : paint; | |
395 | 393 | |
396 | 394 | // 初期値として、各オブジェクトの中心座標を設定する |
397 | - float startX = from.rect.centerX() + offsetX; | |
398 | - float endX = to.rect.centerX() + offsetX; | |
399 | - float startY = from.rect.centerY() + offsetY; | |
400 | - float endY = to.rect.centerY() + offsetY; | |
395 | + RectF fromRect = from.getRect(); | |
396 | + RectF toRect = to.getRect(); | |
397 | + float startX = fromRect.centerX() + offsetX; | |
398 | + float endX = toRect.centerX() + offsetX; | |
399 | + float startY = fromRect.centerY() + offsetY; | |
400 | + float endY = toRect.centerY() + offsetY; | |
401 | 401 | |
402 | 402 | // Y座標の線の位置を補正する |
403 | - if (from.rect.bottom < to.rect.top) | |
403 | + if (fromRect.bottom < toRect.top) | |
404 | 404 | { |
405 | - startY = from.rect.bottom + offsetY; | |
406 | - endY = to.rect.top + offsetY; | |
405 | + startY = fromRect.bottom + offsetY; | |
406 | + endY = toRect.top + offsetY; | |
407 | 407 | } |
408 | - else if (from.rect.top > to.rect.bottom) | |
408 | + else if (fromRect.top > toRect.bottom) | |
409 | 409 | { |
410 | - startY = from.rect.top + offsetY; | |
411 | - endY = to.rect.bottom + offsetY; | |
410 | + startY = fromRect.top + offsetY; | |
411 | + endY = toRect.bottom + offsetY; | |
412 | 412 | } |
413 | 413 | |
414 | 414 | // X座標の線の位置を補正する (Y座標が補正されていないとき) |
415 | - if ((startY != (from.rect.top + offsetY))&&(startY != (from.rect.bottom + offsetY))) | |
415 | + if ((startY != (fromRect.top + offsetY))&&(startY != (fromRect.bottom + offsetY))) | |
416 | 416 | { |
417 | - if (from.rect.right < to.rect.left) | |
417 | + if (fromRect.right < toRect.left) | |
418 | 418 | { |
419 | - startX = from.rect.right + offsetX; | |
420 | - endX = to.rect.left + offsetX; | |
419 | + startX = fromRect.right + offsetX; | |
420 | + endX = toRect.left + offsetX; | |
421 | 421 | } |
422 | - else if (from.rect.left > to.rect.right) | |
422 | + else if (fromRect.left > toRect.right) | |
423 | 423 | { |
424 | - startX = from.rect.left + offsetX; | |
425 | - endX = to.rect.right + offsetX; | |
424 | + startX = fromRect.left + offsetX; | |
425 | + endX = toRect.right + offsetX; | |
426 | 426 | } |
427 | 427 | } |
428 | 428 | |
429 | - if ((line.lineStyle == LineStyleHolder.LINESTYLE_TREESTYLE_NO_ARROW)|| | |
430 | - (line.lineStyle == LineStyleHolder.LINESTYLE_TREESTYLE_L_ARROW)|| | |
431 | - (line.lineStyle == LineStyleHolder.LINESTYLE_TREESTYLE_R_ARROW)) | |
429 | + int lineStyle = line.getLineStyle(); | |
430 | + if ((lineStyle == LineStyleHolder.LINESTYLE_TREESTYLE_NO_ARROW)|| | |
431 | + (lineStyle == LineStyleHolder.LINESTYLE_TREESTYLE_L_ARROW)|| | |
432 | + (lineStyle == LineStyleHolder.LINESTYLE_TREESTYLE_R_ARROW)) | |
432 | 433 | { |
433 | 434 | // ツリー形式のように接続する ... |
434 | - if (startX == (from.rect.centerX() + offsetX)) | |
435 | + if (startX == (fromRect.centerX() + offsetX)) | |
435 | 436 | { |
436 | 437 | float middleY = (startY + endY) / 2; |
437 | 438 | canvas.drawLine(startX, startY, startX, middleY, linePaint); |
438 | 439 | canvas.drawLine(startX, middleY, endX, middleY, linePaint); |
439 | 440 | canvas.drawLine(endX, middleY, endX, endY, linePaint); |
440 | 441 | |
441 | - /** やじるしをつける処理 **/ | |
442 | - if (line.lineStyle == LineStyleHolder.LINESTYLE_TREESTYLE_L_ARROW) | |
442 | + // やじるしをつける処理 | |
443 | + if (lineStyle == LineStyleHolder.LINESTYLE_TREESTYLE_L_ARROW) | |
443 | 444 | { |
444 | 445 | // 始点に矢印をつける |
445 | 446 | ObjectShapeDrawer.drawArrowTree(canvas, paint, startX,startY, middleY, false); |
446 | 447 | } |
447 | - else if (line.lineStyle == LineStyleHolder.LINESTYLE_TREESTYLE_R_ARROW) | |
448 | + else if (lineStyle == LineStyleHolder.LINESTYLE_TREESTYLE_R_ARROW) | |
448 | 449 | { |
449 | 450 | // 終点に矢印をつける |
450 | 451 | ObjectShapeDrawer.drawArrowTree(canvas, paint, endX, endY, middleY, false); |
@@ -457,43 +458,41 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes | ||
457 | 458 | canvas.drawLine(middleX, startY, middleX, endY, linePaint); |
458 | 459 | canvas.drawLine(middleX, endY, endX, endY, linePaint); |
459 | 460 | |
460 | - /** やじるし(三角形)をつける処理 **/ | |
461 | - if (line.lineStyle == LineStyleHolder.LINESTYLE_TREESTYLE_L_ARROW) | |
461 | + // やじるし(三角形)をつける処理 | |
462 | + if (lineStyle == LineStyleHolder.LINESTYLE_TREESTYLE_L_ARROW) | |
462 | 463 | { |
463 | 464 | // 始点に矢印をつける |
464 | 465 | ObjectShapeDrawer.drawArrowTree(canvas, paint, startX, startY, middleX, true); |
465 | 466 | } |
466 | - else if (line.lineStyle == LineStyleHolder.LINESTYLE_TREESTYLE_R_ARROW) | |
467 | + else if (lineStyle == LineStyleHolder.LINESTYLE_TREESTYLE_R_ARROW) | |
467 | 468 | { |
468 | 469 | // 終点に矢印をつける |
469 | 470 | ObjectShapeDrawer.drawArrowTree(canvas, paint, endX,endY, middleX, true); |
470 | 471 | } |
471 | 472 | } |
472 | 473 | } |
473 | - else if ((line.lineStyle == LineStyleHolder.LINESTYLE_CURVESTYLE_NO_ARROW)|| | |
474 | - (line.lineStyle == LineStyleHolder.LINESTYLE_CURVESTYLE_L_ARROW)|| | |
475 | - (line.lineStyle == LineStyleHolder.LINESTYLE_CURVESTYLE_R_ARROW)) | |
474 | + else if ((lineStyle == LineStyleHolder.LINESTYLE_CURVESTYLE_NO_ARROW)|| | |
475 | + (lineStyle == LineStyleHolder.LINESTYLE_CURVESTYLE_L_ARROW)|| | |
476 | + (lineStyle == LineStyleHolder.LINESTYLE_CURVESTYLE_R_ARROW)) | |
476 | 477 | { |
477 | 478 | // 曲線で接続する |
478 | 479 | float middleX = (startX + endX) / 2; |
479 | 480 | float middleY = (startY + endY) / 2; |
480 | 481 | float x1 = (startX + middleX) / 2; |
481 | - float y1 = middleY; | |
482 | 482 | float x2 = (middleX + endX) / 2; |
483 | - float y2 = middleY; | |
484 | 483 | |
485 | 484 | Path pathLine = new Path(); |
486 | 485 | pathLine.moveTo(startX, startY); |
487 | - pathLine.cubicTo(x1, y1, x2, y2, endX, endY); | |
486 | + pathLine.cubicTo(x1, middleY, x2, middleY, endX, endY); | |
488 | 487 | canvas.drawPath(pathLine, linePaint); |
489 | 488 | |
490 | - /** やじるしをつける処理 **/ | |
491 | - if (line.lineStyle == LineStyleHolder.LINESTYLE_CURVESTYLE_L_ARROW) | |
489 | + // やじるしをつける処理 | |
490 | + if (lineStyle == LineStyleHolder.LINESTYLE_CURVESTYLE_L_ARROW) | |
492 | 491 | { |
493 | 492 | // 始点に矢印をつける |
494 | 493 | ObjectShapeDrawer.drawArrow(canvas, paint, startX, startY, endX, endY); |
495 | 494 | } |
496 | - else if (line.lineStyle == LineStyleHolder.LINESTYLE_CURVESTYLE_R_ARROW) | |
495 | + else if (lineStyle == LineStyleHolder.LINESTYLE_CURVESTYLE_R_ARROW) | |
497 | 496 | { |
498 | 497 | // 終点に矢印をつける |
499 | 498 | ObjectShapeDrawer.drawArrow(canvas, paint, endX, endY, startX, startY); |
@@ -504,13 +503,13 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes | ||
504 | 503 | // 直線で接続する |
505 | 504 | canvas.drawLine(startX, startY, endX, endY, linePaint); |
506 | 505 | |
507 | - /** やじるしをつける処理 **/ | |
508 | - if (line.lineStyle == LineStyleHolder.LINESTYLE_STRAIGHT_L_ARROW) | |
506 | + // やじるしをつける処理 | |
507 | + if (lineStyle == LineStyleHolder.LINESTYLE_STRAIGHT_L_ARROW) | |
509 | 508 | { |
510 | 509 | // 始点に矢印をつける |
511 | 510 | ObjectShapeDrawer.drawArrow(canvas, paint, startX, startY, endX, endY); |
512 | 511 | } |
513 | - else if (line.lineStyle == LineStyleHolder.LINESTYLE_STRAIGHT_R_ARROW) | |
512 | + else if (lineStyle == LineStyleHolder.LINESTYLE_STRAIGHT_R_ARROW) | |
514 | 513 | { |
515 | 514 | // 終点に矢印をつける |
516 | 515 | ObjectShapeDrawer.drawArrow(canvas, paint, endX, endY, startX, startY); |
@@ -527,24 +526,18 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes | ||
527 | 526 | /** |
528 | 527 | * オブジェクトを動かしている最中かどうかの判定を行う。 |
529 | 528 | * |
530 | - * @param canvas | |
529 | + * | |
531 | 530 | * @return trueなら、動かしている最中 |
532 | 531 | */ |
533 | 532 | private boolean isFlicking(Canvas canvas) |
534 | 533 | { |
535 | - //int width = canvas.getWidth(); | |
536 | - //int height = canvas.getHeight(); | |
537 | - if ((tempPosX == Float.MIN_VALUE)||(tempPosY == Float.MIN_VALUE)) | |
538 | - { | |
539 | - return (false); | |
540 | - } | |
541 | - return (true); | |
534 | + return (!((tempPosX == Float.MIN_VALUE)||(tempPosY == Float.MIN_VALUE))); | |
542 | 535 | } |
543 | 536 | |
544 | 537 | /** |
545 | 538 | * フリック時の軌跡と現在地点を表示する |
546 | 539 | * |
547 | - * @param canvas | |
540 | + * | |
548 | 541 | */ |
549 | 542 | private void drawTrackAndPositions(Canvas canvas) |
550 | 543 | { |
@@ -557,9 +550,10 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes | ||
557 | 550 | paint.setColor(Color.GRAY); |
558 | 551 | if (selectedPosition != null) |
559 | 552 | { |
560 | - float objX = (selectedPosition.rect.right - selectedPosition.rect.left) / 2; | |
561 | - float objY = (selectedPosition.rect.bottom - selectedPosition.rect.top) / 2; | |
562 | - canvas.drawLine(selectedPosition.rect.centerX(), selectedPosition.rect.centerY(), x, y, paint); | |
553 | + RectF objRect = selectedPosition.getRect(); | |
554 | + float objX = (objRect.right - objRect.left) / 2; | |
555 | + float objY = (objRect.bottom - objRect.top) / 2; | |
556 | + canvas.drawLine(objRect.centerX(), objRect.centerY(), x, y, paint); | |
563 | 557 | canvas.drawRect((x - objX), (y - objY), (x + objX), (y + objY), paint); |
564 | 558 | |
565 | 559 | // 現在地点の表示 |
@@ -579,7 +573,7 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes | ||
579 | 573 | SharedPreferences.Editor editor = preferences.edit(); |
580 | 574 | editor.putFloat("drawTransX", drawTransX); |
581 | 575 | editor.putFloat("drawTransY", drawTransY); |
582 | - editor.commit(); | |
576 | + editor.apply(); | |
583 | 577 | } |
584 | 578 | else |
585 | 579 | { |
@@ -594,114 +588,115 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes | ||
594 | 588 | * オブジェクト(1個)を表示する |
595 | 589 | * |
596 | 590 | */ |
597 | - private void drawObject(Canvas canvas, MeMoMaObjectHolder.PositionObject object, boolean isMoving, float offsetX, float offsetY) | |
591 | + private void drawObject(Canvas canvas, PositionObject object, boolean isMoving, float offsetX, float offsetY) | |
598 | 592 | { |
599 | 593 | float label_offsetX = OBJECTLABEL_MARGIN; |
600 | 594 | float label_offsetY = 0.0f; |
601 | 595 | |
602 | 596 | // オブジェクトの色と枠線を設定する |
603 | 597 | Paint paint = new Paint(); |
604 | - if (isMoving == true) | |
598 | + if (isMoving) | |
605 | 599 | { |
606 | 600 | paint.setColor(Color.YELLOW); |
607 | 601 | paint.setStyle(Paint.Style.STROKE); |
608 | - paint.setStrokeWidth(object.strokeWidth); | |
602 | + paint.setStrokeWidth(object.getstrokeWidth()); | |
609 | 603 | } |
610 | 604 | else |
611 | 605 | { |
612 | - paint.setColor(object.objectColor); | |
613 | - paint.setStyle(Paint.Style.valueOf(object.paintStyle)); | |
614 | - paint.setStrokeWidth(object.strokeWidth); | |
606 | + paint.setColor(object.getObjectColor()); | |
607 | + paint.setStyle(Paint.Style.valueOf(object.getPaintStyle())); | |
608 | + paint.setStrokeWidth(object.getstrokeWidth()); | |
615 | 609 | } |
616 | 610 | |
617 | 611 | // 図形の形状に合わせて描画する |
618 | - RectF objectShape = new RectF(object.rect); | |
612 | + RectF objectShape = new RectF(object.getRect()); | |
619 | 613 | objectShape.left = objectShape.left + offsetX; |
620 | 614 | objectShape.right = objectShape.right + offsetX; |
621 | 615 | objectShape.top = objectShape.top + offsetY; |
622 | 616 | objectShape.bottom = objectShape.bottom + offsetY; |
623 | - | |
624 | - if (object.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_OVAL) | |
617 | + | |
618 | + int drawStyle = object.getDrawStyle(); | |
619 | + if (drawStyle == MeMoMaObjectHolder.DRAWSTYLE_OVAL) | |
625 | 620 | { |
626 | 621 | // 楕円形の描画 |
627 | 622 | label_offsetY = ObjectShapeDrawer.drawObjectOval(canvas, objectShape, paint); |
628 | 623 | } |
629 | - else if (object.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_ROUNDRECT) | |
624 | + else if (drawStyle == MeMoMaObjectHolder.DRAWSTYLE_ROUNDRECT) | |
630 | 625 | { |
631 | 626 | // 丸角四角形の描画 |
632 | 627 | label_offsetY = ObjectShapeDrawer.drawObjectRoundRect(canvas, objectShape, paint); |
633 | 628 | } |
634 | - else if (object.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_DIAMOND) | |
629 | + else if (drawStyle == MeMoMaObjectHolder.DRAWSTYLE_DIAMOND) | |
635 | 630 | { |
636 | 631 | // 菱形の描画 |
637 | 632 | label_offsetY = ObjectShapeDrawer.drawObjectDiamond(canvas, objectShape, paint); |
638 | 633 | label_offsetX = OBJECTLABEL_MARGIN; |
639 | 634 | } |
640 | - else if (object.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_KEYBOARD) | |
635 | + else if (drawStyle == MeMoMaObjectHolder.DRAWSTYLE_KEYBOARD) | |
641 | 636 | { |
642 | 637 | // 台形(キーボード型)の描画 |
643 | 638 | label_offsetY = ObjectShapeDrawer.drawObjectKeyboard(canvas, objectShape, paint); |
644 | 639 | } |
645 | - else if (object.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_PARALLELOGRAM) | |
640 | + else if (drawStyle == MeMoMaObjectHolder.DRAWSTYLE_PARALLELOGRAM) | |
646 | 641 | { |
647 | 642 | // 平行四辺形の描画 |
648 | 643 | label_offsetY = ObjectShapeDrawer.drawObjectParallelogram(canvas, objectShape, paint); |
649 | 644 | } |
650 | - else if (object.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_HEXAGONAL) | |
645 | + else if (drawStyle == MeMoMaObjectHolder.DRAWSTYLE_HEXAGONAL) | |
651 | 646 | { |
652 | 647 | // 六角形の描画 |
653 | 648 | label_offsetY = ObjectShapeDrawer.drawObjectHexagonal(canvas, objectShape, paint); |
654 | 649 | } |
655 | - else if (object.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_PAPER) | |
650 | + else if (drawStyle == MeMoMaObjectHolder.DRAWSTYLE_PAPER) | |
656 | 651 | { |
657 | 652 | // 書類の形の描画 |
658 | 653 | label_offsetY = ObjectShapeDrawer.drawObjectPaper(canvas, objectShape, paint); |
659 | 654 | } |
660 | - else if (object.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_DRUM) | |
655 | + else if (drawStyle == MeMoMaObjectHolder.DRAWSTYLE_DRUM) | |
661 | 656 | { |
662 | 657 | // 円柱の描画 |
663 | - label_offsetY = ObjectShapeDrawer.drawObjectDrum(canvas, objectShape, paint, Paint.Style.valueOf(object.paintStyle)); | |
658 | + label_offsetY = ObjectShapeDrawer.drawObjectDrum(canvas, objectShape, paint, Paint.Style.valueOf(object.getPaintStyle())); | |
664 | 659 | } |
665 | - else if (object.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_CIRCLE) | |
660 | + else if (drawStyle == MeMoMaObjectHolder.DRAWSTYLE_CIRCLE) | |
666 | 661 | { |
667 | 662 | // 円を描画する |
668 | 663 | label_offsetY = ObjectShapeDrawer.drawObjectCircle(canvas, objectShape, paint); |
669 | 664 | } |
670 | - else if (object.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_NO_REGION) | |
665 | + else if (drawStyle == MeMoMaObjectHolder.DRAWSTYLE_NO_REGION) | |
671 | 666 | { |
672 | 667 | // 枠なしを描画(?)する ... なにもしない |
673 | - if (object.label.length() == 0) | |
668 | + if (object.getLabel().length() == 0) | |
674 | 669 | { |
675 | 670 | // 何も表示しないとわからないので、ラベルが無いときには枠を表示する |
676 | 671 | ObjectShapeDrawer.drawObjectNoRegion(canvas, objectShape, paint); |
677 | 672 | } |
678 | 673 | } |
679 | - else if (object.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_LOOP_START) | |
674 | + else if (drawStyle == MeMoMaObjectHolder.DRAWSTYLE_LOOP_START) | |
680 | 675 | { |
681 | 676 | // ループ開始図形の描画 |
682 | 677 | label_offsetY = ObjectShapeDrawer.drawObjectLoopStart(canvas, objectShape, paint); |
683 | 678 | } |
684 | - else if (object.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_LOOP_END) | |
679 | + else if (drawStyle == MeMoMaObjectHolder.DRAWSTYLE_LOOP_END) | |
685 | 680 | { |
686 | 681 | // ループ終了図形の描画 |
687 | 682 | label_offsetY = ObjectShapeDrawer.drawObjectLoopEnd(canvas, objectShape, paint); |
688 | 683 | } |
689 | - else if (object.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_LEFT_ARROW) | |
684 | + else if (drawStyle == MeMoMaObjectHolder.DRAWSTYLE_LEFT_ARROW) | |
690 | 685 | { |
691 | 686 | // 左側矢印図形の描画 |
692 | 687 | label_offsetY = ObjectShapeDrawer.drawObjectLeftArrow(canvas, objectShape, paint); |
693 | 688 | } |
694 | - else if (object.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_DOWN_ARROW) | |
689 | + else if (drawStyle == MeMoMaObjectHolder.DRAWSTYLE_DOWN_ARROW) | |
695 | 690 | { |
696 | 691 | // 下側矢印図形の描画 |
697 | 692 | label_offsetY = ObjectShapeDrawer.drawObjectDownArrow(canvas, objectShape, paint); |
698 | 693 | } |
699 | - else if (object.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_UP_ARROW) | |
694 | + else if (drawStyle == MeMoMaObjectHolder.DRAWSTYLE_UP_ARROW) | |
700 | 695 | { |
701 | 696 | // 上側矢印図形の描画 |
702 | 697 | label_offsetY = ObjectShapeDrawer.drawObjectUpArrow(canvas, objectShape, paint); |
703 | 698 | } |
704 | - else if (object.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_RIGHT_ARROW) | |
699 | + else if (drawStyle == MeMoMaObjectHolder.DRAWSTYLE_RIGHT_ARROW) | |
705 | 700 | { |
706 | 701 | // 右側矢印図形の描画 |
707 | 702 | label_offsetY = ObjectShapeDrawer.drawObjectRightArrow(canvas, objectShape, paint); |
@@ -713,7 +708,7 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes | ||
713 | 708 | } |
714 | 709 | |
715 | 710 | // 文字サイズを設定する。 |
716 | - paint.setTextSize(object.fontSize); | |
711 | + paint.setTextSize(object.getFontSize()); | |
717 | 712 | |
718 | 713 | // 文字ラベルを表示する |
719 | 714 | ObjectShapeDrawer.drawTextLabel(canvas, paint, object, objectShape, displayObjectInformation, label_offsetX, label_offsetY); |
@@ -722,7 +717,7 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes | ||
722 | 717 | /** |
723 | 718 | * オブジェクトをすべて表示する |
724 | 719 | * |
725 | - * @param canvas | |
720 | + * | |
726 | 721 | */ |
727 | 722 | private void drawObjects(Canvas canvas , float offsetX, float offsetY) |
728 | 723 | { |
@@ -731,15 +726,14 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes | ||
731 | 726 | while (keys.hasMoreElements()) |
732 | 727 | { |
733 | 728 | Integer key = keys.nextElement(); |
734 | - MeMoMaObjectHolder.PositionObject pos = objectHolder.getPosition(key); | |
729 | + PositionObject pos = objectHolder.getPosition(key); | |
735 | 730 | drawObject(canvas, pos, false, offsetX, offsetY); |
736 | 731 | } |
737 | 732 | } |
738 | 733 | |
739 | 734 | /** |
740 | 735 | * タッチされたタイミングでの処理 |
741 | - * @param event | |
742 | - * @return | |
736 | + * | |
743 | 737 | */ |
744 | 738 | private boolean onTouchDown(MotionEvent event) |
745 | 739 | { |
@@ -765,6 +759,7 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes | ||
765 | 759 | // オブジェクトが生成されたことを通知する |
766 | 760 | selectionReceiver.objectCreated(); |
767 | 761 | } |
762 | +/* | |
768 | 763 | else if (data ==OperationModeHolder.OPERATIONMODE_MOVE) |
769 | 764 | { |
770 | 765 | // 移動モードのとき |
@@ -773,19 +768,19 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes | ||
773 | 768 | { |
774 | 769 | // 削除モードのとき...何もしない |
775 | 770 | } |
771 | +*/ | |
776 | 772 | } |
777 | 773 | return (false); |
778 | 774 | } |
779 | 775 | |
780 | 776 | /** |
781 | 777 | * タッチが離されたタイミングでの処理 |
782 | - * @param event | |
783 | - * @return | |
778 | + * | |
784 | 779 | */ |
785 | 780 | private boolean onTouchUp(MotionEvent event) |
786 | 781 | { |
787 | 782 | boolean longPress = false; |
788 | - if (onGestureProcessed == true) | |
783 | + if (onGestureProcessed) | |
789 | 784 | { |
790 | 785 | // ロングタッチ中だった場合...フラグを落とす |
791 | 786 | onGestureProcessed = false; |
@@ -827,24 +822,25 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes | ||
827 | 822 | return (true); |
828 | 823 | } |
829 | 824 | |
830 | - if (selectedPosition.rect.contains(x, y) == true) | |
825 | + RectF selectedRect = selectedPosition.getRect(); | |
826 | + if (selectedRect.contains(x, y)) | |
831 | 827 | { |
832 | 828 | // タッチが離された位置がタッチしたオブジェクトと同じ位置だった場合...... |
833 | 829 | |
834 | 830 | // タッチが離された位置を認識する |
835 | 831 | float diffX = Math.abs(event.getX() - drawTransX - downPosX); |
836 | - float diffY = Math.abs(event.getY() - drawTransY - downPosY); | |
832 | + float diffY = Math.abs(event.getY() - drawTransY - downPosY); | |
837 | 833 | |
838 | 834 | // タッチが離された位置が動いていた場合、オブジェクト位置の微調整と判定する。 |
839 | - if (((diffX > 2.0f)||(diffY > 2.0f))||(longPress == true)) | |
835 | + if (((diffX > 2.0f)||(diffY > 2.0f))||(longPress)) | |
840 | 836 | { |
841 | 837 | // タッチが離された場所にはオブジェクトがなかった場合...オブジェクトをその位置に移動させる |
842 | 838 | Log.v(Main.APP_IDENTIFIER, "MOVE OBJECT : (" + diffX + "," + diffY + ")"); |
843 | 839 | moveObjectPosition(x, y); |
844 | 840 | return (true); |
845 | 841 | } |
846 | - | |
847 | - // タッチが押された位置と離された位置が同じ位置だった場合......アイテムが選択された、と認識する。 | |
842 | + | |
843 | + // タッチが押された位置と離された位置が同じ位置だった場合......アイテムが選択された、と認識する。 | |
848 | 844 | Log.v(Main.APP_IDENTIFIER, " ITEM SELECTED :" + x + "," + y); |
849 | 845 | if (selectionReceiver != null) |
850 | 846 | { |
@@ -859,8 +855,8 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes | ||
859 | 855 | } |
860 | 856 | |
861 | 857 | // タッチが離された位置にオブジェクトがいるかどうかのチェック |
862 | - MeMoMaObjectHolder.PositionObject position = checkSelectedObject(x, y); | |
863 | - if ((position != null)&&(longPress == false)) | |
858 | + PositionObject position = checkSelectedObject(x, y); | |
859 | + if ((position != null)&&(!longPress)) | |
864 | 860 | { |
865 | 861 | // 他のオブジェクトと重なるように操作した、この場合は、オブジェクト間を線をつなげる |
866 | 862 | // (ただし、ボタンを長押ししていなかったとき。) |
@@ -885,22 +881,19 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes | ||
885 | 881 | |
886 | 882 | /** |
887 | 883 | * オブジェクトの位置を移動させる |
888 | - * | |
889 | - * @param x | |
890 | - * @param y | |
884 | + * | |
891 | 885 | */ |
892 | 886 | private void moveObjectPosition(float x, float y) |
893 | 887 | { |
888 | + RectF curRect = selectedPosition.getRect(); | |
894 | 889 | tempPosX = Float.MIN_VALUE; |
895 | 890 | tempPosY = Float.MIN_VALUE; |
896 | - float sizeX = selectedPosition.rect.right - selectedPosition.rect.left; | |
897 | - float sizeY = selectedPosition.rect.bottom - selectedPosition.rect.top; | |
891 | + float sizeX = curRect.right - curRect.left; | |
892 | + float sizeY = curRect.bottom - curRect.top; | |
898 | 893 | |
899 | 894 | float positionX = alignPosition(x, (sizeX / 2) * (-1)); |
900 | 895 | float positionY = alignPosition(y, (sizeY / 2) * (-1)); |
901 | - selectedPosition.rect = new android.graphics.RectF(positionX, positionY, (positionX + sizeX), (positionY + sizeY)); | |
902 | - | |
903 | - return; | |
896 | + selectedPosition.setRect(new android.graphics.RectF(positionX, positionY, (positionX + sizeX), (positionY + sizeY))); | |
904 | 897 | } |
905 | 898 | |
906 | 899 | /** |
@@ -909,22 +902,22 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes | ||
909 | 902 | */ |
910 | 903 | public boolean onTouchEvent(MotionEvent event) |
911 | 904 | { |
912 | - boolean isDraw = false; | |
905 | + boolean isDraw; | |
913 | 906 | |
914 | - /** スケールジェスチャ(マルチタッチのジェスチャ)を拾う **/ | |
915 | - isDraw = scaleGestureDetector.onTouchEvent(event); | |
916 | - if ((onScaling == true)||(scaleGestureDetector.isInProgress() == true)) | |
907 | + // スケールジェスチャ(マルチタッチのジェスチャ)を拾う | |
908 | + // isDraw = scaleGestureDetector.onTouchEvent(event); | |
909 | + if ((onScaling)||(scaleGestureDetector.isInProgress())) | |
917 | 910 | { |
918 | 911 | // マルチタッチ操作中... |
919 | 912 | return (true); |
920 | 913 | } |
921 | 914 | |
922 | - /** 先にジェスチャーを拾ってみよう... **/ | |
915 | + // 先にジェスチャーを拾ってみよう... | |
923 | 916 | isDraw = gestureDetector.onTouchEvent(event); |
924 | - if (isDraw == true) | |
917 | + if (isDraw) | |
925 | 918 | { |
926 | 919 | Log.v(Main.APP_IDENTIFIER, "MeMoMaCanvasDrawer::onTouchEvent() : isDraw == true"); |
927 | - return (isDraw); | |
920 | + return (true); | |
928 | 921 | } |
929 | 922 | |
930 | 923 | int action = event.getAction(); |
@@ -953,8 +946,7 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes | ||
953 | 946 | |
954 | 947 | /** |
955 | 948 | * タテヨコ位置を合わせられるよう、調整する。 |
956 | - * @param pos | |
957 | - * @return | |
949 | + * | |
958 | 950 | */ |
959 | 951 | private float alignPosition(float pos, float offset) |
960 | 952 | { |
@@ -965,21 +957,20 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes | ||
965 | 957 | /** |
966 | 958 | * 位置から判定し、選択したオブジェクトを応答する |
967 | 959 | * (オブジェクトが選択されていない場合には、nullを応答する) |
968 | - * @param x | |
969 | - * @param y | |
970 | - * @return | |
960 | + * | |
971 | 961 | */ |
972 | - private MeMoMaObjectHolder.PositionObject checkSelectedObject(float x, float y) | |
962 | + private PositionObject checkSelectedObject(float x, float y) | |
973 | 963 | { |
974 | 964 | Enumeration<Integer> keys = objectHolder.getObjectKeys(); |
975 | 965 | //Log.v(Main.APP_IDENTIFIER, "CHECK POS " + x + "," + y); |
976 | 966 | while (keys.hasMoreElements()) |
977 | 967 | { |
978 | 968 | Integer key = keys.nextElement(); |
979 | - MeMoMaObjectHolder.PositionObject pos = objectHolder.getPosition(key); | |
980 | - if (pos.rect.contains(x, y) == true) | |
969 | + PositionObject pos = objectHolder.getPosition(key); | |
970 | + RectF posRect = pos.getRect(); | |
971 | + if (posRect.contains(x, y)) | |
981 | 972 | { |
982 | - Log.v(Main.APP_IDENTIFIER, "SELECTED :" + pos.rect.centerX() + "," + pos.rect.centerY() + " KEY :" + key); | |
973 | + Log.v(Main.APP_IDENTIFIER, "SELECTED :" + posRect.centerX() + "," + posRect.centerY() + " KEY :" + key); | |
983 | 974 | return (pos); |
984 | 975 | } |
985 | 976 | //Log.v(Main.APP_IDENTIFIER, "NOT MATCH :" + pos.rect.centerX() + "," + pos.rect.centerY()); |
@@ -991,10 +982,6 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes | ||
991 | 982 | /** |
992 | 983 | * 線と交差するオブジェクト接続線をすべて削除する |
993 | 984 | * |
994 | - * @param startX | |
995 | - * @param startY | |
996 | - * @param endX | |
997 | - * @param endY | |
998 | 985 | */ |
999 | 986 | private void disconnectObjects(float startX, float startY, float endX, float endY) |
1000 | 987 | { |
@@ -1005,19 +992,19 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes | ||
1005 | 992 | while (keys.hasMoreElements()) |
1006 | 993 | { |
1007 | 994 | Integer key = keys.nextElement(); |
1008 | - MeMoMaConnectLineHolder.ObjectConnector line = lineHolder.getLine(key); | |
1009 | - if (line.key > 0) | |
995 | + ObjectConnector line = lineHolder.getLine(key); | |
996 | + if (line.getKey() > 0) | |
1010 | 997 | { |
1011 | 998 | // 線の始点と終点を取り出す |
1012 | - MeMoMaObjectHolder.PositionObject from = objectHolder.getPosition(line.fromObjectKey); | |
1013 | - MeMoMaObjectHolder.PositionObject to = objectHolder.getPosition(line.toObjectKey); | |
999 | + RectF fromRect = objectHolder.getPosition(line.getFromObjectKey()).getRect(); | |
1000 | + RectF toRect = objectHolder.getPosition(line.getToObjectKey()).getRect(); | |
1014 | 1001 | |
1015 | 1002 | // 線が交差しているかチェックする |
1016 | - if (checkIntersection(startX, startY, endX, endY, from.rect.centerX(), from.rect.centerY(), to.rect.centerX(), to.rect.centerY()) == true) | |
1003 | + if (checkIntersection(startX, startY, endX, endY, fromRect.centerX(), fromRect.centerY(), toRect.centerX(), toRect.centerY())) | |
1017 | 1004 | { |
1018 | 1005 | // 線が交差していた! 線を切る! |
1019 | 1006 | //Log.v(Main.APP_IDENTIFIER, "CUT LINE [" + from.rect.centerX() + "," + from.rect.centerY() +"]-[" + to.rect.centerX() + "," + to.rect.centerY() + "]"); |
1020 | - lineHolder.disconnectLines(line.key); | |
1007 | + lineHolder.disconnectLines(line.getKey()); | |
1021 | 1008 | } |
1022 | 1009 | } |
1023 | 1010 | } |
@@ -1062,11 +1049,7 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes | ||
1062 | 1049 | //crossY = y1 + dR * (y2 - y1); |
1063 | 1050 | |
1064 | 1051 | // 交点が線分内にあるかどうかをチェックする |
1065 | - if ((dR >= 0)&&(dR <= 1)&&(dS >= 0)&&(dS <= 1)) | |
1066 | - { | |
1067 | - return (true); | |
1068 | - } | |
1069 | - return (false); | |
1052 | + return ((dR >= 0)&&(dR <= 1)&&(dS >= 0)&&(dS <= 1)); | |
1070 | 1053 | } |
1071 | 1054 | |
1072 | 1055 | /** |
@@ -1090,7 +1073,7 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes | ||
1090 | 1073 | /** |
1091 | 1074 | * スライドバーを変更された時の処理 |
1092 | 1075 | */ |
1093 | - public void zoomScaleChanged(int progress) | |
1076 | + private void zoomScaleChanged(int progress) | |
1094 | 1077 | { |
1095 | 1078 | float val = ((float) progress - 50.0f) / 50.0f; |
1096 | 1079 |
@@ -1100,8 +1083,9 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes | ||
1100 | 1083 | |
1101 | 1084 | // 表示倍率を変更し、倍率を画面に表示する |
1102 | 1085 | drawScale = (float) Math.round(Math.pow(10.0, val) * 10.0) / 10.0f; |
1103 | - TextView textview = (TextView) parent.findViewById(R.id.ZoomRate); | |
1104 | - textview.setText("x" + drawScale); | |
1086 | + TextView textview = parent.findViewById(R.id.ZoomRate); | |
1087 | + String showText = "x" + drawScale; | |
1088 | + textview.setText(showText); | |
1105 | 1089 | |
1106 | 1090 | // 現在の表示領域サイズを取得 |
1107 | 1091 | float showSizeWidth = screenWidth * drawScale; |
@@ -1128,7 +1112,7 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes | ||
1128 | 1112 | editor.putFloat("drawTransX", drawTransX); |
1129 | 1113 | editor.putFloat("drawTransY", drawTransY); |
1130 | 1114 | editor.putInt("zoomProgress", progress); |
1131 | - editor.commit(); | |
1115 | + editor.apply(); | |
1132 | 1116 | } |
1133 | 1117 | |
1134 | 1118 | /** |
@@ -1174,7 +1158,7 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes | ||
1174 | 1158 | float y = (event.getY() - drawTransY) / drawScale; |
1175 | 1159 | |
1176 | 1160 | // タッチ位置にオブジェクトが存在するか確認する |
1177 | - MeMoMaObjectHolder.PositionObject position = checkSelectedObject(x, y); | |
1161 | + PositionObject position = checkSelectedObject(x, y); | |
1178 | 1162 | if (position != null) |
1179 | 1163 | { |
1180 | 1164 | // 長押し処理を実施していることを記憶する |
@@ -1221,7 +1205,7 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes | ||
1221 | 1205 | zoomScaleChanged(progress); |
1222 | 1206 | |
1223 | 1207 | // 画面描画クラスに再描画を指示する |
1224 | - final GokigenSurfaceView surfaceView = (GokigenSurfaceView) parent.findViewById(R.id.GraphicView); | |
1208 | + final GokigenSurfaceView surfaceView = parent.findViewById(R.id.GraphicView); | |
1225 | 1209 | surfaceView.doDraw(); |
1226 | 1210 | } |
1227 | 1211 |
@@ -1244,15 +1228,14 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes | ||
1244 | 1228 | /** |
1245 | 1229 | * (ScaleGestureDetector.OnScaleGestureListener の実装) |
1246 | 1230 | * |
1247 | - * @param detector | |
1248 | - * @return | |
1231 | + * | |
1249 | 1232 | */ |
1250 | 1233 | public boolean onScale(ScaleGestureDetector detector) |
1251 | 1234 | { |
1252 | 1235 | float scaleFactor = detector.getScaleFactor(); |
1253 | 1236 | //Log.v(Main.APP_IDENTIFIER, "MeMoMaCanvasDrawer::onScale() : " + scaleFactor + " (" + currentScaleBar + ")"); |
1254 | 1237 | |
1255 | - /** 画面表示の倍率が変更された! x < 1 : 縮小、 1 < x : 拡大 **/ | |
1238 | + // 画面表示の倍率が変更された! x < 1 : 縮小、 1 < x : 拡大 | |
1256 | 1239 | if (scaleFactor < 1.0f) |
1257 | 1240 | { |
1258 | 1241 | currentScaleBar = (currentScaleBar == 0) ? 0 : currentScaleBar - 1; |
@@ -1290,7 +1273,7 @@ public class MeMoMaCanvasDrawer implements ICanvasDrawer, GestureDetector.OnGes | ||
1290 | 1273 | onScaling = false; |
1291 | 1274 | |
1292 | 1275 | // シークバーを設定し、値を記憶する |
1293 | - final SeekBar seekbar = (SeekBar) parent.findViewById(R.id.ZoomInOut); | |
1276 | + final SeekBar seekbar = parent.findViewById(R.id.ZoomInOut); | |
1294 | 1277 | seekbar.setProgress(currentScaleBar); |
1295 | 1278 | zoomScaleChanged(currentScaleBar); |
1296 | 1279 | } |
@@ -7,6 +7,7 @@ import android.graphics.Paint; | ||
7 | 7 | import android.graphics.Path; |
8 | 8 | import android.graphics.RectF; |
9 | 9 | import jp.sourceforge.gokigen.memoma.holders.MeMoMaObjectHolder; |
10 | +import jp.sourceforge.gokigen.memoma.holders.PositionObject; | |
10 | 11 | |
11 | 12 | /** |
12 | 13 | * めもまのオブジェクト・ライン・ラベルを描画するメソッド群 |
@@ -304,26 +305,26 @@ public class ObjectShapeDrawer | ||
304 | 305 | * オブジェクトのラベルを表示する |
305 | 306 | * |
306 | 307 | */ |
307 | - public static void drawTextLabel(Canvas canvas, Paint paint, MeMoMaObjectHolder.PositionObject pos, RectF region, int displayObjectInformation, float offsetX, float offsetY) | |
308 | + public static void drawTextLabel(Canvas canvas, Paint paint, PositionObject pos, RectF region, int displayObjectInformation, float offsetX, float offsetY) | |
308 | 309 | { |
309 | 310 | // タイトルの先頭部分を表示する場合... |
310 | - String labelToShow = pos.label; | |
311 | + String labelToShow = pos.getLabel(); | |
311 | 312 | if (displayObjectInformation == 0) |
312 | 313 | { |
313 | 314 | float width = region.width() - MeMoMaCanvasDrawer.OBJECTLABEL_MARGIN_WIDTH; |
314 | - int textLen = paint.breakText(pos.label, true, width, null); // 省略文字を追加するから、そのぶん減らす | |
315 | + int textLen = paint.breakText(pos.getLabel(), true, width, null); // 省略文字を追加するから、そのぶん減らす | |
315 | 316 | labelToShow = labelToShow.substring(0, textLen); |
316 | - if (!labelToShow.equals(pos.label)) | |
317 | + if (!labelToShow.equals(pos.getLabel())) | |
317 | 318 | { |
318 | 319 | // truncate した場合には、省略文字を出す。 |
319 | 320 | labelToShow = labelToShow + "..."; |
320 | 321 | } |
321 | 322 | } |
322 | 323 | |
323 | - if (Paint.Style.valueOf(pos.paintStyle) != Paint.Style.STROKE) | |
324 | + if (Paint.Style.valueOf(pos.getPaintStyle()) != Paint.Style.STROKE) | |
324 | 325 | { |
325 | 326 | // オブジェクトを塗りつぶすのときは、文字の色を設定する |
326 | - paint.setColor(pos.labelColor); | |
327 | + paint.setColor(pos.getLabelColor()); | |
327 | 328 | } |
328 | 329 | |
329 | 330 | // 文字をちょっと影付きにする |
@@ -331,13 +332,13 @@ public class ObjectShapeDrawer | ||
331 | 332 | paint.setShadowLayer(0.7f, 0.7f, 0.7f, Color.DKGRAY); |
332 | 333 | |
333 | 334 | // ユーザチェックの描画 |
334 | - if (pos.userChecked) | |
335 | + if (pos.getUserChecked()) | |
335 | 336 | { |
336 | 337 | canvas.drawText("*", region.centerX(), region.top + (MeMoMaCanvasDrawer.OBJECTLABEL_MARGIN * 2.0f), paint); |
337 | 338 | } |
338 | 339 | |
339 | 340 | // 強調表示 |
340 | - if (pos.strokeWidth != 0.0f) | |
341 | + if (pos.getstrokeWidth() != 0.0f) | |
341 | 342 | { |
342 | 343 | // そのまま表示すると、読めないので、太さを調整し、アンダーラインを引くことにする |
343 | 344 | paint.setStrokeWidth(0.0f); |
@@ -358,10 +359,10 @@ public class ObjectShapeDrawer | ||
358 | 359 | float width = region.right - region.left - 12.0f; // 幅 |
359 | 360 | |
360 | 361 | int startChar = 0; |
361 | - int endChar = pos.label.length(); | |
362 | + int endChar = pos.getLabel().length(); | |
362 | 363 | do |
363 | 364 | { |
364 | - int textLen = paint.breakText(pos.label, startChar, endChar, true, width, null); | |
365 | + int textLen = paint.breakText(pos.getLabel(), startChar, endChar, true, width, null); | |
365 | 366 | canvas.drawText(labelToShow, startChar, (startChar +textLen), posX, posY, paint); |
366 | 367 | |
367 | 368 | posY = posY - tall; |
@@ -25,16 +25,18 @@ import android.widget.ListAdapter; | ||
25 | 25 | import android.widget.ListView; |
26 | 26 | import android.widget.Toast; |
27 | 27 | |
28 | -import jp.sourceforge.gokigen.memoma.fileio.ExternalStorageFileUtility; | |
28 | +import jp.sourceforge.gokigen.memoma.holders.OperationHistoryHolder; | |
29 | +import jp.sourceforge.gokigen.memoma.holders.PositionObject; | |
30 | +import jp.sourceforge.gokigen.memoma.io.ExternalStorageFileUtility; | |
29 | 31 | import jp.sourceforge.gokigen.memoma.dialogs.FileSelectionDialog; |
30 | 32 | import jp.sourceforge.gokigen.memoma.Main; |
31 | 33 | import jp.sourceforge.gokigen.memoma.holders.MeMoMaConnectLineHolder; |
32 | -import jp.sourceforge.gokigen.memoma.fileio.MeMoMaFileExportCsvProcess; | |
33 | -import jp.sourceforge.gokigen.memoma.fileio.MeMoMaFileImportCsvProcess; | |
34 | -import jp.sourceforge.gokigen.memoma.fileio.MeMoMaFileLoadingProcess; | |
34 | +import jp.sourceforge.gokigen.memoma.io.MeMoMaFileExportCsvProcess; | |
35 | +import jp.sourceforge.gokigen.memoma.io.MeMoMaFileImportCsvProcess; | |
36 | +import jp.sourceforge.gokigen.memoma.io.MeMoMaFileLoadingProcess; | |
35 | 37 | import jp.sourceforge.gokigen.memoma.holders.MeMoMaObjectHolder; |
36 | 38 | import jp.sourceforge.gokigen.memoma.R; |
37 | -import jp.sourceforge.gokigen.memoma.SharedIntentInvoker; | |
39 | +import jp.sourceforge.gokigen.memoma.io.SharedIntentInvoker; | |
38 | 40 | import jp.sourceforge.gokigen.memoma.listitem.SymbolListArrayAdapter; |
39 | 41 | import jp.sourceforge.gokigen.memoma.listitem.SymbolListArrayItem; |
40 | 42 |
@@ -68,9 +70,10 @@ public class ExtensionActivityListener implements OnClickListener, MeMoMaFileLo | ||
68 | 70 | */ |
69 | 71 | ExtensionActivityListener(Activity argument) |
70 | 72 | { |
73 | + OperationHistoryHolder historyHolder = new OperationHistoryHolder(); | |
71 | 74 | parent = argument; |
72 | 75 | fileUtility = new ExternalStorageFileUtility(Main.APP_BASEDIR); |
73 | - objectHolder = new MeMoMaObjectHolder(parent, new MeMoMaConnectLineHolder()); | |
76 | + objectHolder = new MeMoMaObjectHolder(parent, new MeMoMaConnectLineHolder(historyHolder), historyHolder); | |
74 | 77 | } |
75 | 78 | /** |
76 | 79 | * 起動時にデータを準備する |
@@ -350,16 +353,16 @@ public class ExtensionActivityListener implements OnClickListener, MeMoMaFileLo | ||
350 | 353 | while (keys.hasMoreElements()) |
351 | 354 | { |
352 | 355 | Integer key = keys.nextElement(); |
353 | - MeMoMaObjectHolder.PositionObject pos = objectHolder.getPosition(key); | |
356 | + PositionObject pos = objectHolder.getPosition(key); | |
354 | 357 | |
355 | 358 | // アイコンの決定 |
356 | - int objectStyleIcon = MeMoMaObjectHolder .getObjectDrawStyleIcon(pos.drawStyle); | |
359 | + int objectStyleIcon = MeMoMaObjectHolder .getObjectDrawStyleIcon(pos.getDrawStyle()); | |
357 | 360 | |
358 | 361 | // ユーザチェックの有無表示 |
359 | - int userCheckedIcon = (pos.userChecked) ? R.drawable.btn_checked : R.drawable.btn_notchecked; | |
362 | + int userCheckedIcon = (pos.getUserChecked()) ? R.drawable.btn_checked : R.drawable.btn_notchecked; | |
360 | 363 | |
361 | 364 | // TODO: アイテム選択時の情報エリアは(ArrayItem側には)用意しているが未使用。 |
362 | - SymbolListArrayItem listItem = new SymbolListArrayItem(userCheckedIcon, pos.label, pos.detail, "", objectStyleIcon); | |
365 | + SymbolListArrayItem listItem = new SymbolListArrayItem(userCheckedIcon, pos.getLabel(), pos.getDetail(), "", objectStyleIcon); | |
363 | 366 | |
364 | 367 | listItems.add(listItem); |
365 | 368 | } |
@@ -0,0 +1,31 @@ | ||
1 | +package jp.sourceforge.gokigen.memoma.holders; | |
2 | + | |
3 | +interface IOperationHistoryHolder | |
4 | +{ | |
5 | + enum ChangeKind | |
6 | + { | |
7 | + RECTANGLE, | |
8 | + DRAW_STYLE, | |
9 | + ICON, | |
10 | + LABEL, | |
11 | + DETAIL, | |
12 | + USER_CHECKED, | |
13 | + LABEL_COLOR, | |
14 | + OBJECT_COLOR, | |
15 | + PAINT_STYLE, | |
16 | + STROKE_WIDTH, | |
17 | + FONT_SIZE, | |
18 | + NEW_OBJECT, | |
19 | + NEW_CONNECT_LINE, | |
20 | + CONNECT_LINE_FROM_KEY, | |
21 | + CONNECT_LINE_TO_KEY, | |
22 | + CONNECT_LINE_STYLE, | |
23 | + CONNECT_LINE_SHAPE, | |
24 | + CONNECT_LINE_THICKNESS, | |
25 | + }; | |
26 | + | |
27 | + | |
28 | + void addHistory(int key, ChangeKind kind, Object object); | |
29 | + void undo(); | |
30 | + | |
31 | +} |
@@ -5,7 +5,6 @@ import java.util.Hashtable; | ||
5 | 5 | import android.util.Log; |
6 | 6 | |
7 | 7 | import jp.sourceforge.gokigen.memoma.Main; |
8 | -import jp.sourceforge.gokigen.memoma.holders.LineStyleHolder; | |
9 | 8 | |
10 | 9 | |
11 | 10 | /** |
@@ -13,141 +12,96 @@ import jp.sourceforge.gokigen.memoma.holders.LineStyleHolder; | ||
13 | 12 | * |
14 | 13 | * @author MRSa |
15 | 14 | * |
16 | - */public class MeMoMaConnectLineHolder | |
15 | + */ | |
16 | +public class MeMoMaConnectLineHolder | |
17 | 17 | { |
18 | - public static final int ID_NOTSPECIFY = -1; | |
19 | - | |
20 | - /** | |
21 | - * オブジェクト間を接続するクラス | |
22 | - * | |
23 | - * @author MRSa | |
24 | - * | |
25 | - */ | |
26 | - public class ObjectConnector | |
27 | - { | |
28 | - public Integer key; | |
29 | - public Integer fromObjectKey; | |
30 | - public Integer toObjectKey; | |
31 | - public Integer lineStyle; | |
32 | - public Integer lineShape; | |
33 | - public Integer lineThickness; | |
34 | -/** | |
35 | - public int fromShape; | |
36 | - public int toShape; | |
37 | - public String fromString; | |
38 | - public String toString; | |
39 | -**/ | |
40 | - }; | |
41 | - | |
42 | - private Hashtable<Integer, ObjectConnector> connectLines = null; | |
43 | - private Integer serialNumber = 1; | |
44 | - | |
45 | - public MeMoMaConnectLineHolder() | |
46 | - { | |
47 | - connectLines = new Hashtable<Integer, ObjectConnector>(); | |
48 | - connectLines.clear(); | |
49 | - } | |
50 | - | |
51 | - public Enumeration<Integer> getLineKeys() | |
52 | - { | |
53 | - return (connectLines.keys()); | |
54 | - } | |
55 | - | |
56 | - public ObjectConnector getLine(Integer key) | |
57 | - { | |
58 | - return (connectLines.get(key)); | |
59 | - } | |
60 | - | |
61 | - public boolean disconnectLines(Integer key) | |
62 | - { | |
63 | - connectLines.remove(key); | |
64 | - Log.v(Main.APP_IDENTIFIER, "DISCONNECT LINES : " + key); | |
65 | - return (true); | |
66 | - } | |
67 | - | |
68 | - public void setSerialNumber(int id) | |
69 | - { | |
70 | - serialNumber = (id == ID_NOTSPECIFY) ? ++serialNumber : id; | |
71 | - } | |
72 | - | |
73 | - public int getSerialNumber() | |
74 | - { | |
75 | - return (serialNumber); | |
76 | - } | |
77 | - | |
78 | - public void removeAllLines() | |
79 | - { | |
80 | - connectLines.clear(); | |
81 | - serialNumber = 1; | |
82 | - } | |
83 | - | |
84 | - public void dumpConnectLine(ObjectConnector conn) | |
85 | - { | |
86 | - if (conn == null) | |
87 | - { | |
88 | - return; | |
89 | - } | |
90 | - Log.v(Main.APP_IDENTIFIER, "LINE " + conn.key + " [" + conn.fromObjectKey + " -> " + conn.toObjectKey + "] "); | |
91 | - } | |
92 | - | |
93 | - /** | |
94 | - * keyToRemove で指定されたobjectの接続をすべて削除する | |
95 | - * | |
96 | - * @param keyToRemove | |
97 | - */ | |
98 | - public void removeAllConnection(Integer keyToRemove) | |
99 | - { | |
100 | - Enumeration<Integer> keys = connectLines.keys(); | |
101 | - while (keys.hasMoreElements()) | |
102 | - { | |
103 | - Integer key = keys.nextElement(); | |
104 | - ObjectConnector connector = connectLines.get(key); | |
105 | - if ((connector.fromObjectKey == keyToRemove)||(connector.toObjectKey == keyToRemove)) | |
106 | - { | |
107 | - // 削除するキーが見つかった! | |
108 | - connector.key = -1; // 一応...大丈夫だとは思うけど | |
109 | - connectLines.remove(key); | |
110 | - } | |
111 | - } | |
112 | - } | |
113 | - | |
114 | - public ObjectConnector createLine(int id) | |
115 | - { | |
116 | - ObjectConnector connector = new ObjectConnector(); | |
117 | - connector.key = id; | |
118 | - connector.fromObjectKey = 1; | |
119 | - connector.toObjectKey = 1; | |
120 | - connector.lineStyle = LineStyleHolder.LINESTYLE_STRAIGHT_NO_ARROW; | |
121 | - connector.lineShape = LineStyleHolder.LINESHAPE_NORMAL; | |
122 | - connector.lineThickness = LineStyleHolder.LINETHICKNESS_THIN; | |
123 | - | |
124 | -/** | |
125 | - connector.fromShape = 0; | |
126 | - connector.toShape = 0; | |
127 | - connector.fromString = ""; | |
128 | - connector.toString = ""; | |
129 | -**/ | |
130 | - connectLines.put(id, connector); | |
131 | - return (connector); | |
132 | - } | |
133 | - | |
134 | - public ObjectConnector setLines(Integer fromKey, Integer toKey, LineStyleHolder lineHolder) | |
135 | - { | |
136 | - ObjectConnector connector = new ObjectConnector(); | |
137 | - connector.key = serialNumber; | |
138 | - connector.fromObjectKey = fromKey; | |
139 | - connector.toObjectKey = toKey; | |
140 | - connector.lineStyle = lineHolder.getLineStyle(); | |
141 | - connector.lineShape = lineHolder.getLineShape(); | |
142 | - connector.lineThickness = lineHolder.getLineThickness(); | |
143 | -/** | |
144 | - connector.fromShape = 0; | |
145 | - connector.toShape = 0; | |
146 | - connector.fromString = ""; | |
147 | - connector.toString = ""; | |
148 | -**/ | |
149 | - connectLines.put(serialNumber, connector); | |
150 | - serialNumber++; | |
151 | - return (connector); | |
152 | - } | |
18 | + private final IOperationHistoryHolder historyHolder; | |
19 | + public static final int ID_NOTSPECIFY = -1; | |
20 | + private Hashtable<Integer, ObjectConnector> connectLines; | |
21 | + private Integer serialNumber = 1; | |
22 | + | |
23 | + public MeMoMaConnectLineHolder(IOperationHistoryHolder historyHolder) | |
24 | + { | |
25 | + this.historyHolder = historyHolder; | |
26 | + connectLines = new Hashtable<>(); | |
27 | + connectLines.clear(); | |
28 | + } | |
29 | + | |
30 | + public Enumeration<Integer> getLineKeys() | |
31 | + { | |
32 | + return (connectLines.keys()); | |
33 | + } | |
34 | + | |
35 | + public ObjectConnector getLine(Integer key) | |
36 | + { | |
37 | + return (connectLines.get(key)); | |
38 | + } | |
39 | + | |
40 | + public boolean disconnectLines(Integer key) | |
41 | + { | |
42 | + connectLines.remove(key); | |
43 | + Log.v(Main.APP_IDENTIFIER, "DISCONNECT LINES : " + key); | |
44 | + return (true); | |
45 | + } | |
46 | + | |
47 | + public void setSerialNumber(int id) | |
48 | + { | |
49 | + serialNumber = (id == ID_NOTSPECIFY) ? ++serialNumber : id; | |
50 | + } | |
51 | + | |
52 | + public int getSerialNumber() | |
53 | + { | |
54 | + return (serialNumber); | |
55 | + } | |
56 | + | |
57 | + public void removeAllLines() | |
58 | + { | |
59 | + connectLines.clear(); | |
60 | + serialNumber = 1; | |
61 | + } | |
62 | + | |
63 | + public void dumpConnectLine(ObjectConnector conn) | |
64 | + { | |
65 | + if (conn == null) | |
66 | + { | |
67 | + return; | |
68 | + } | |
69 | + Log.v(Main.APP_IDENTIFIER, "LINE " + conn.getKey() + " [" + conn.getFromObjectKey() + " -> " + conn.getToObjectKey() + "] "); | |
70 | + } | |
71 | + | |
72 | + /** | |
73 | + * keyToRemove で指定されたobjectの接続をすべて削除する | |
74 | + * | |
75 | + * @param keyToRemove\ | |
76 | + */ | |
77 | + public void removeAllConnection(Integer keyToRemove) | |
78 | + { | |
79 | + Enumeration<Integer> keys = connectLines.keys(); | |
80 | + while (keys.hasMoreElements()) | |
81 | + { | |
82 | + Integer key = keys.nextElement(); | |
83 | + ObjectConnector connector = connectLines.get(key); | |
84 | + if ((connector.getFromObjectKey() == keyToRemove)||(connector.getToObjectKey() == keyToRemove)) | |
85 | + { | |
86 | + // 削除するキーが見つかった! | |
87 | + connectLines.remove(key); | |
88 | + } | |
89 | + } | |
90 | + } | |
91 | + | |
92 | + public ObjectConnector createLine(int id) | |
93 | + { | |
94 | + ObjectConnector connector = new ObjectConnector(id, 1, 1, LineStyleHolder.LINESTYLE_STRAIGHT_NO_ARROW, LineStyleHolder.LINESHAPE_NORMAL, LineStyleHolder.LINETHICKNESS_THIN, historyHolder); | |
95 | + connectLines.put(id, connector); | |
96 | + return (connector); | |
97 | + } | |
98 | + | |
99 | + public ObjectConnector setLines(Integer fromKey, Integer toKey, LineStyleHolder lineHolder) | |
100 | + { | |
101 | + ObjectConnector connector = new ObjectConnector(serialNumber, fromKey, toKey, lineHolder.getLineStyle(), lineHolder.getLineShape(), lineHolder.getLineThickness(), historyHolder); | |
102 | + | |
103 | + connectLines.put(serialNumber, connector); | |
104 | + serialNumber++; | |
105 | + return (connector); | |
106 | + } | |
153 | 107 | } |
@@ -6,7 +6,7 @@ import java.io.FilenameFilter; | ||
6 | 6 | import android.content.Context; |
7 | 7 | import android.widget.ArrayAdapter; |
8 | 8 | |
9 | -import jp.sourceforge.gokigen.memoma.fileio.ExternalStorageFileUtility; | |
9 | +import jp.sourceforge.gokigen.memoma.io.ExternalStorageFileUtility; | |
10 | 10 | |
11 | 11 | /** |
12 | 12 | * めもまのデータファイル名を保持するクラス (ArrayAdapterを拡張) |
@@ -16,8 +16,8 @@ import jp.sourceforge.gokigen.memoma.fileio.ExternalStorageFileUtility; | ||
16 | 16 | */ |
17 | 17 | public class MeMoMaDataFileHolder extends ArrayAdapter<String> implements FilenameFilter |
18 | 18 | { |
19 | - private ExternalStorageFileUtility fileUtility = null; | |
20 | - private String fileExtension = ""; | |
19 | + private ExternalStorageFileUtility fileUtility; | |
20 | + private String fileExtension; | |
21 | 21 | |
22 | 22 | /** |
23 | 23 | * コンストラクタ |
@@ -49,7 +49,7 @@ public class MeMoMaDataFileHolder extends ArrayAdapter<String> implements Filena | ||
49 | 49 | try { |
50 | 50 | for (int index = 0; index < dirFileList.length; index++) { |
51 | 51 | String fileName = dirFileList[index].substring(0, dirFileList[index].indexOf(fileExtension)); |
52 | - if (fileName.contentEquals(currentFileName) == true) // ファイル先頭にない場合は追加する。 | |
52 | + if (fileName.contentEquals(currentFileName)) // ファイル先頭にない場合は追加する。 | |
53 | 53 | { |
54 | 54 | // 選択したインデックスを設定する。 |
55 | 55 | outputIndex = index; |
@@ -75,6 +75,6 @@ public class MeMoMaDataFileHolder extends ArrayAdapter<String> implements Filena | ||
75 | 75 | */ |
76 | 76 | public boolean accept(File dir, String filename) |
77 | 77 | { |
78 | - return (filename.endsWith(fileExtension) ? true : false); | |
78 | + return (filename.endsWith(fileExtension)); | |
79 | 79 | } |
80 | 80 | } |
@@ -65,76 +65,29 @@ public class MeMoMaObjectHolder | ||
65 | 65 | |
66 | 66 | private MeMoMaConnectLineHolder connectLineHolder = null; |
67 | 67 | |
68 | - /** | |
69 | - * オブジェクトの情報 | |
70 | - * | |
71 | - * @author MRSa | |
72 | - * | |
73 | - */ | |
74 | - public class PositionObject | |
75 | - { | |
76 | - private Integer key; // オブジェクト識別子 (変更不可) | |
77 | - public RectF rect; // オブジェクトの大きさ | |
78 | - public int drawStyle; // オブジェクトの形状 | |
79 | - | |
80 | - public int icon; // オブジェクトのアイコン | |
81 | - public String label; // オブジェクトの表示ラベル | |
82 | - public String detail; // オブジェクトの説明 | |
83 | - //public String backgroundUri; // オブジェクトの背景画像 | |
84 | - //public String otherInfoUri; // 補足(写真とかへのURI) | |
85 | - //public String objectStatus; // オブジェクトの状態 | |
86 | - public boolean userChecked; // ユーザチェックボックス | |
87 | - | |
88 | - public int labelColor; // オブジェクト内に表示する色 | |
89 | - public int objectColor; // オブジェクトの色 | |
90 | - public String paintStyle; // オブジェクトの表示方法 (枠線のみ、塗りつぶし、塗りつぶしと枠線) | |
91 | - public float strokeWidth; // 枠線の太さ | |
92 | - public float fontSize; // フォントサイズ | |
93 | - | |
94 | - /** | |
95 | - * コンストラクタ (キーを設定する) | |
96 | - * @param id | |
97 | - */ | |
98 | - public PositionObject(int id) | |
99 | - { | |
100 | - key = id; | |
101 | - } | |
102 | - | |
103 | - /** | |
104 | - * オブジェクトのキーを取得する | |
105 | - * @return | |
106 | - */ | |
107 | - public Integer getKey() | |
108 | - { | |
109 | - return (key); | |
110 | - } | |
111 | - }; | |
112 | - | |
113 | 68 | private Hashtable<Integer, PositionObject> objectPoints = null; |
114 | 69 | private Integer serialNumber = 1; |
115 | 70 | private String dataTitle = ""; |
116 | 71 | private String background = ""; |
117 | - private Context parent = null; | |
72 | + private Context parent; | |
73 | + private final IOperationHistoryHolder historyHolder; | |
118 | 74 | |
119 | - public MeMoMaObjectHolder(Context context, MeMoMaConnectLineHolder lineHolder) | |
75 | + public MeMoMaObjectHolder(Context context, MeMoMaConnectLineHolder lineHolder, IOperationHistoryHolder historyHolder) | |
120 | 76 | { |
121 | - objectPoints = new Hashtable<Integer, PositionObject>(); | |
77 | + objectPoints = new Hashtable<>(); | |
122 | 78 | connectLineHolder = lineHolder; |
123 | 79 | parent = context; |
80 | + this.historyHolder = historyHolder; | |
124 | 81 | } |
125 | 82 | |
126 | 83 | /** |
127 | 84 | * データの有無を見る (true の場合、データはない。) |
128 | 85 | * |
129 | - * @return | |
86 | + * | |
130 | 87 | */ |
131 | 88 | public boolean isEmpty() |
132 | - { | |
133 | - if ((connectLineHolder == null)||(objectPoints == null)) | |
134 | - { | |
135 | - return (true); | |
136 | - } | |
137 | - return (objectPoints.isEmpty()); | |
89 | + { | |
90 | + return (((connectLineHolder == null)||(objectPoints == null))||(objectPoints.isEmpty())); | |
138 | 91 | } |
139 | 92 | |
140 | 93 | public MeMoMaConnectLineHolder getConnectLineHolder() |
@@ -206,15 +159,16 @@ public class MeMoMaObjectHolder | ||
206 | 159 | { |
207 | 160 | return; |
208 | 161 | } |
209 | - Log.v(Main.APP_IDENTIFIER, "[" + position.rect.left + "," + position.rect.top + "][" + position.rect.right + "," + position.rect.bottom + "] " + "label : " + position.label + " detail : " + position.detail); | |
162 | + RectF posRect = position.getRect(); | |
163 | + Log.v(Main.APP_IDENTIFIER, "[" + posRect.left + "," + posRect.top + "][" + posRect.right + "," + posRect.bottom + "] " + "label : " + position.getLabel() + " detail : " + position.getDetail()); | |
210 | 164 | } |
211 | 165 | |
212 | 166 | |
213 | 167 | /** |
214 | 168 | * オブジェクトを複製する。 |
215 | 169 | * |
216 | - * @param key | |
217 | - * @return | |
170 | + * | |
171 | + * | |
218 | 172 | */ |
219 | 173 | public PositionObject duplicatePosition(int key) |
220 | 174 | { |
@@ -224,25 +178,20 @@ public class MeMoMaObjectHolder | ||
224 | 178 | // 元のオブジェクトが見つからなかったので、何もせずに戻る |
225 | 179 | return (null); |
226 | 180 | } |
227 | - PositionObject position = new PositionObject(serialNumber); | |
228 | - position.rect = new RectF(); | |
229 | - position.rect.left = orgPosition.rect.left + DUPLICATEPOSITION_MARGIN; | |
230 | - position.rect.right = orgPosition.rect.right + DUPLICATEPOSITION_MARGIN; | |
231 | - position.rect.top = orgPosition.rect.top + DUPLICATEPOSITION_MARGIN; | |
232 | - position.rect.bottom = orgPosition.rect.bottom + DUPLICATEPOSITION_MARGIN; | |
233 | - position.drawStyle = orgPosition.drawStyle; | |
234 | - position.icon = orgPosition.icon; | |
235 | - position.label = orgPosition.label; | |
236 | - position.detail = orgPosition.detail; | |
237 | - //position.otherInfoUri = orgPosition.otherInfoUri; | |
238 | - //position.backgroundUri = orgPosition.backgroundUri; | |
239 | - //position.objectStatus = orgPosition.objectStatus; | |
240 | - position.userChecked = orgPosition.userChecked; | |
241 | - position.objectColor = orgPosition.objectColor; | |
242 | - position.labelColor = orgPosition.labelColor; | |
243 | - position.paintStyle = orgPosition.paintStyle; | |
244 | - position.strokeWidth = orgPosition.strokeWidth; | |
245 | - position.fontSize = orgPosition.fontSize; | |
181 | + RectF orgRect = orgPosition.getRect(); | |
182 | + PositionObject position = new PositionObject(serialNumber, | |
183 | + new RectF(orgRect.left + DUPLICATEPOSITION_MARGIN, orgRect.top + DUPLICATEPOSITION_MARGIN, orgRect.right + DUPLICATEPOSITION_MARGIN, orgRect.bottom + DUPLICATEPOSITION_MARGIN), | |
184 | + orgPosition.getDrawStyle(), | |
185 | + orgPosition.getIcon(), | |
186 | + orgPosition.getLabel(), | |
187 | + orgPosition.getDetail(), | |
188 | + orgPosition.getUserChecked(), | |
189 | + orgPosition.getLabelColor(), | |
190 | + orgPosition.getObjectColor(), | |
191 | + orgPosition.getPaintStyle(), | |
192 | + orgPosition.getstrokeWidth(), | |
193 | + orgPosition.getFontSize(), | |
194 | + historyHolder); | |
246 | 195 | objectPoints.put(serialNumber, position); |
247 | 196 | serialNumber++; |
248 | 197 | return (position); |
@@ -250,25 +199,19 @@ public class MeMoMaObjectHolder | ||
250 | 199 | |
251 | 200 | public PositionObject createPosition(int id) |
252 | 201 | { |
253 | - PositionObject position = new PositionObject(id); | |
254 | - position.rect = new RectF(); | |
255 | - position.rect.top = 0; | |
256 | - position.rect.bottom = OBJECTSIZE_DEFAULT_Y; | |
257 | - position.rect.left = 0; | |
258 | - position.rect.right = OBJECTSIZE_DEFAULT_X; | |
259 | - position.drawStyle = MeMoMaObjectHolder.DRAWSTYLE_RECTANGLE; | |
260 | - position.icon = 0; | |
261 | - position.label = ""; | |
262 | - position.detail = ""; | |
263 | - //position.otherInfoUri = ""; | |
264 | - //position.backgroundUri = ""; | |
265 | - //position.objectStatus = ""; | |
266 | - position.userChecked = false; | |
267 | - position.objectColor = Color.WHITE; | |
268 | - position.labelColor = Color.WHITE; | |
269 | - position.paintStyle = Paint.Style.STROKE.toString(); | |
270 | - position.strokeWidth = STOROKE_NORMAL_WIDTH; | |
271 | - position.fontSize = FONTSIZE_DEFAULT; | |
202 | + PositionObject position = new PositionObject(id, | |
203 | + new RectF(0, 0, OBJECTSIZE_DEFAULT_X, OBJECTSIZE_DEFAULT_Y), | |
204 | + MeMoMaObjectHolder.DRAWSTYLE_RECTANGLE, | |
205 | + 0, | |
206 | + "", | |
207 | + "", | |
208 | + false, | |
209 | + Color.WHITE, | |
210 | + Color.WHITE, | |
211 | + Paint.Style.STROKE.toString(), | |
212 | + STOROKE_NORMAL_WIDTH, | |
213 | + FONTSIZE_DEFAULT, | |
214 | + historyHolder); | |
272 | 215 | objectPoints.put(id, position); |
273 | 216 | return (position); |
274 | 217 | } |
@@ -276,11 +219,12 @@ public class MeMoMaObjectHolder | ||
276 | 219 | public PositionObject createPosition(float x, float y, int drawStyle) |
277 | 220 | { |
278 | 221 | PositionObject position = createPosition(serialNumber); |
279 | - position.rect.left = position.rect.left + x; | |
280 | - position.rect.right = position.rect.right + x; | |
281 | - position.rect.top = position.rect.top + y; | |
282 | - position.rect.bottom = position.rect.bottom + y; | |
283 | - position.drawStyle = drawStyle; | |
222 | + RectF posRect = position.getRect(); | |
223 | + position.setRectLeft(posRect.left + x); | |
224 | + position.setRectRight(posRect.right + x); | |
225 | + position.setRectTop(posRect.top + y); | |
226 | + position.setRectBottom(posRect.bottom + y); | |
227 | + position.setDrawStyle(drawStyle); | |
284 | 228 | serialNumber++; |
285 | 229 | return (position); |
286 | 230 | } |
@@ -297,8 +241,9 @@ public class MeMoMaObjectHolder | ||
297 | 241 | // 元のオブジェクトが見つからなかったので、何もせずに戻る |
298 | 242 | return; |
299 | 243 | } |
300 | - float width = position.rect.right - position.rect.left; | |
301 | - float height = position.rect.bottom - position.rect.top; | |
244 | + RectF posRect = position.getRect(); | |
245 | + float width = posRect.right - posRect.left; | |
246 | + float height = posRect.bottom - posRect.top; | |
302 | 247 | if (((width + (OBJECTSIZE_STEP_X * 2.0f)) > OBJECTSIZE_MAXIMUM_X)||((height + (OBJECTSIZE_STEP_Y * 2.0f)) > OBJECTSIZE_MAXIMUM_Y)) |
303 | 248 | { |
304 | 249 | // 拡大リミットだった。。。拡大しない |
@@ -306,16 +251,16 @@ public class MeMoMaObjectHolder | ||
306 | 251 | Toast.makeText(parent, outputMessage, Toast.LENGTH_SHORT).show(); |
307 | 252 | return; |
308 | 253 | } |
309 | - position.rect.left = position.rect.left - OBJECTSIZE_STEP_X; | |
310 | - position.rect.right = position.rect.right + OBJECTSIZE_STEP_X; | |
311 | - position.rect.top = position.rect.top - OBJECTSIZE_STEP_Y; | |
312 | - position.rect.bottom = position.rect.bottom + OBJECTSIZE_STEP_Y; | |
254 | + position.setRectLeft(posRect.left - OBJECTSIZE_STEP_X); | |
255 | + position.setRectRight(posRect.right + OBJECTSIZE_STEP_X); | |
256 | + position.setRectTop(posRect.top - OBJECTSIZE_STEP_Y); | |
257 | + position.setRectBottom(posRect.bottom + OBJECTSIZE_STEP_Y); | |
313 | 258 | } |
314 | 259 | |
315 | 260 | /** |
316 | 261 | * オブジェクトのサイズを縮小する |
317 | 262 | * |
318 | - * @param key | |
263 | + * | |
319 | 264 | */ |
320 | 265 | public void shrinkObjectSize(Integer key) |
321 | 266 | { |
@@ -325,8 +270,9 @@ public class MeMoMaObjectHolder | ||
325 | 270 | // 元のオブジェクトが見つからなかったので、何もせずに戻る |
326 | 271 | return; |
327 | 272 | } |
328 | - float width = position.rect.right - position.rect.left; | |
329 | - float height = position.rect.bottom - position.rect.top; | |
273 | + RectF posRect = position.getRect(); | |
274 | + float width = posRect.right - posRect.left; | |
275 | + float height = posRect.bottom - posRect.top; | |
330 | 276 | if (((width - (OBJECTSIZE_STEP_X * 2.0f)) < OBJECTSIZE_MINIMUM_X)||((height - (OBJECTSIZE_STEP_Y * 2.0f)) < OBJECTSIZE_MINIMUM_Y)) |
331 | 277 | { |
332 | 278 | // 縮小リミットだった。。。縮小しない |
@@ -334,10 +280,10 @@ public class MeMoMaObjectHolder | ||
334 | 280 | Toast.makeText(parent, outputMessage, Toast.LENGTH_SHORT).show(); |
335 | 281 | return; |
336 | 282 | } |
337 | - position.rect.left = position.rect.left + OBJECTSIZE_STEP_X; | |
338 | - position.rect.right = position.rect.right - OBJECTSIZE_STEP_X; | |
339 | - position.rect.top = position.rect.top + OBJECTSIZE_STEP_Y; | |
340 | - position.rect.bottom = position.rect.bottom - OBJECTSIZE_STEP_Y; | |
283 | + position.setRectLeft(posRect.left + OBJECTSIZE_STEP_X); | |
284 | + position.setRectRight(posRect.right - OBJECTSIZE_STEP_X); | |
285 | + position.setRectTop(posRect.top + OBJECTSIZE_STEP_Y); | |
286 | + position.setRectBottom(posRect.bottom - OBJECTSIZE_STEP_Y); | |
341 | 287 | } |
342 | 288 | |
343 | 289 | public MeMoMaConnectLineHolder getLineHolder() |
@@ -418,5 +364,4 @@ public class MeMoMaObjectHolder | ||
418 | 364 | } |
419 | 365 | return (icon); |
420 | 366 | } |
421 | - | |
422 | 367 | } |
@@ -0,0 +1,92 @@ | ||
1 | +package jp.sourceforge.gokigen.memoma.holders; | |
2 | + | |
3 | +import android.support.annotation.NonNull; | |
4 | + | |
5 | +/** | |
6 | + * オブジェクト間を接続するクラス | |
7 | + * | |
8 | + * @author MRSa | |
9 | + * | |
10 | + */ | |
11 | +public class ObjectConnector | |
12 | +{ | |
13 | + private final IOperationHistoryHolder historyHolder; | |
14 | + private final Integer key; | |
15 | + private Integer fromObjectKey; | |
16 | + private Integer toObjectKey; | |
17 | + private Integer lineStyle; | |
18 | + private Integer lineShape; | |
19 | + private Integer lineThickness; | |
20 | + | |
21 | + ObjectConnector(int key, int fromObjectKey, int toObjectkey, int lineStyle, int lineShape, int lineThickness, @NonNull IOperationHistoryHolder historyHolder) | |
22 | + { | |
23 | + this.key = key; | |
24 | + this.fromObjectKey = fromObjectKey; | |
25 | + this.toObjectKey = toObjectkey; | |
26 | + this.lineStyle = lineStyle; | |
27 | + this.lineShape = lineShape; | |
28 | + this.lineThickness = lineThickness; | |
29 | + this.historyHolder = historyHolder; | |
30 | + historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.NEW_CONNECT_LINE, this); | |
31 | + } | |
32 | + | |
33 | + public int getKey() | |
34 | + { | |
35 | + return (key); | |
36 | + } | |
37 | + | |
38 | + public int getFromObjectKey() | |
39 | + { | |
40 | + return (fromObjectKey); | |
41 | + } | |
42 | + | |
43 | + public int getToObjectKey() | |
44 | + { | |
45 | + return (toObjectKey); | |
46 | + } | |
47 | + | |
48 | + public int getLineStyle() | |
49 | + { | |
50 | + return (lineStyle); | |
51 | + } | |
52 | + | |
53 | + public int getLineShape() | |
54 | + { | |
55 | + return (lineShape); | |
56 | + } | |
57 | + | |
58 | + public int getLineThickness() | |
59 | + { | |
60 | + return (lineThickness); | |
61 | + } | |
62 | + | |
63 | + public void setFromObjectKey(int value) | |
64 | + { | |
65 | + historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.CONNECT_LINE_FROM_KEY, fromObjectKey); | |
66 | + fromObjectKey = value; | |
67 | + } | |
68 | + | |
69 | + public void setToObjectKey(int value) | |
70 | + { | |
71 | + historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.CONNECT_LINE_TO_KEY, toObjectKey); | |
72 | + toObjectKey = value; | |
73 | + } | |
74 | + | |
75 | + public void setLineStyle(int value) | |
76 | + { | |
77 | + historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.CONNECT_LINE_STYLE, lineStyle); | |
78 | + lineStyle = value; | |
79 | + } | |
80 | + | |
81 | + public void setLineShape(int value) | |
82 | + { | |
83 | + historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.CONNECT_LINE_SHAPE, lineShape); | |
84 | + lineShape = value; | |
85 | + } | |
86 | + | |
87 | + public void setLineThickness(int value) | |
88 | + { | |
89 | + historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.CONNECT_LINE_THICKNESS, lineThickness); | |
90 | + lineThickness = value; | |
91 | + } | |
92 | +} |
@@ -0,0 +1,25 @@ | ||
1 | +package jp.sourceforge.gokigen.memoma.holders; | |
2 | + | |
3 | +import android.content.Context; | |
4 | +import android.util.Log; | |
5 | + | |
6 | +public class OperationHistoryHolder implements IOperationHistoryHolder | |
7 | +{ | |
8 | + private final String TAG = toString(); | |
9 | + | |
10 | + public OperationHistoryHolder() | |
11 | + { | |
12 | + | |
13 | + } | |
14 | + | |
15 | + public void addHistory(int key, ChangeKind kind, Object object) | |
16 | + { | |
17 | + Log.v(TAG, "addHistory() KEY : " + key + " KIND : " + kind.toString() + " OBJ : " + object.toString()); | |
18 | + } | |
19 | + | |
20 | + public void undo() | |
21 | + { | |
22 | + Log.v(TAG, "undo() "); | |
23 | + | |
24 | + } | |
25 | +} |
@@ -0,0 +1,209 @@ | ||
1 | +package jp.sourceforge.gokigen.memoma.holders; | |
2 | + | |
3 | +import android.graphics.RectF; | |
4 | +import android.support.annotation.NonNull; | |
5 | + | |
6 | +public class PositionObject | |
7 | +{ | |
8 | + private final Integer key; // オブジェクト識別子 (変更不可) | |
9 | + private final IOperationHistoryHolder historyHolder; // 履歴を保持するところ | |
10 | + | |
11 | + private RectF rect; // オブジェクトの大きさ | |
12 | + private int drawStyle; // オブジェクトの形状 | |
13 | + | |
14 | + private int icon; // オブジェクトのアイコン | |
15 | + private String label; // オブジェクトの表示ラベル | |
16 | + private String detail; // オブジェクトの説明 | |
17 | + //public String backgroundUri; // オブジェクトの背景画像 | |
18 | + //public String otherInfoUri; // 補足(写真とかへのURI) | |
19 | + //public String objectStatus; // オブジェクトの状態 | |
20 | + private boolean userChecked; // ユーザチェックボックス | |
21 | + | |
22 | + private int labelColor; // オブジェクト内に表示する色 | |
23 | + private int objectColor; // オブジェクトの色 | |
24 | + private String paintStyle; // オブジェクトの表示方法 (枠線のみ、塗りつぶし、塗りつぶしと枠線) | |
25 | + private float strokeWidth; // 枠線の太さ | |
26 | + private float fontSize; // フォントサイズ | |
27 | + | |
28 | + /** | |
29 | + * コンストラクタ (キーを設定する) | |
30 | + * | |
31 | + */ | |
32 | + public PositionObject(int id, RectF rect, int drawStyle, int icon, String label, String detail, boolean userChecked, int labelColor, int objectColor, String paintStyle, float strokeWidth, float fontSize, @NonNull IOperationHistoryHolder historyHolder) | |
33 | + { | |
34 | + key = id; | |
35 | + this.rect = rect; | |
36 | + this.drawStyle = drawStyle; | |
37 | + this.icon = icon; | |
38 | + this.label = label; | |
39 | + this.detail = detail; | |
40 | + this.userChecked = userChecked; | |
41 | + this.labelColor = labelColor; | |
42 | + this.objectColor = objectColor; | |
43 | + this.paintStyle = paintStyle; | |
44 | + this.strokeWidth = strokeWidth; | |
45 | + this.fontSize = fontSize; | |
46 | + this.historyHolder = historyHolder; | |
47 | + historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.NEW_OBJECT, this); | |
48 | + } | |
49 | + | |
50 | + /** | |
51 | + * オブジェクトのキーを取得する | |
52 | + * | |
53 | + */ | |
54 | + public Integer getKey() | |
55 | + { | |
56 | + return (key); | |
57 | + } | |
58 | + | |
59 | + public void setRect(RectF rectF) | |
60 | + { | |
61 | + historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.RECTANGLE, rect); | |
62 | + rect = rectF; | |
63 | + } | |
64 | + | |
65 | + public void setRectTop(float value) | |
66 | + { | |
67 | + historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.RECTANGLE, rect); | |
68 | + rect.top = value; | |
69 | + } | |
70 | + | |
71 | + public void setRectLeft(float value) | |
72 | + { | |
73 | + historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.RECTANGLE, rect); | |
74 | + rect.left = value; | |
75 | + } | |
76 | + | |
77 | + public void setRectRight(float value) | |
78 | + { | |
79 | + historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.RECTANGLE, rect); | |
80 | + rect.right = value; | |
81 | + } | |
82 | + | |
83 | + public void setRectBottom(float value) | |
84 | + { | |
85 | + historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.RECTANGLE, rect); | |
86 | + rect.bottom = value; | |
87 | + } | |
88 | + | |
89 | + public void setDrawStyle(int value) | |
90 | + { | |
91 | + historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.DRAW_STYLE, drawStyle); | |
92 | + drawStyle = value; | |
93 | + } | |
94 | + | |
95 | + public void setIcon(int value) | |
96 | + { | |
97 | + historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.ICON, icon); | |
98 | + icon = value; | |
99 | + } | |
100 | + | |
101 | + public void setLabel(String value) | |
102 | + { | |
103 | + historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.LABEL, label); | |
104 | + label = value; | |
105 | + } | |
106 | + | |
107 | + public void setDetail(String value) | |
108 | + { | |
109 | + historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.DETAIL, detail); | |
110 | + detail = value; | |
111 | + } | |
112 | + | |
113 | + public void setUserChecked(boolean value) | |
114 | + { | |
115 | + historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.USER_CHECKED, userChecked); | |
116 | + userChecked = value; | |
117 | + } | |
118 | + | |
119 | + public void setLabelColor(int value) | |
120 | + { | |
121 | + historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.LABEL_COLOR, labelColor); | |
122 | + labelColor = value; | |
123 | + } | |
124 | + | |
125 | + public void setObjectColor(int value) | |
126 | + { | |
127 | + historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.OBJECT_COLOR, objectColor); | |
128 | + objectColor = value; | |
129 | + } | |
130 | + | |
131 | + public void setPaintStyle(String value) | |
132 | + { | |
133 | + historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.PAINT_STYLE, paintStyle); | |
134 | + paintStyle = value; | |
135 | + } | |
136 | + | |
137 | + public void setStrokeWidth(float value) | |
138 | + { | |
139 | + historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.STROKE_WIDTH, strokeWidth); | |
140 | + strokeWidth = value; | |
141 | + } | |
142 | + | |
143 | + public void setFontSize(float value) | |
144 | + { | |
145 | + historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.FONT_SIZE, fontSize); | |
146 | + fontSize = value; | |
147 | + } | |
148 | + | |
149 | + public void setRectOffsetTo(float newLeft, float newTop) | |
150 | + { | |
151 | + historyHolder.addHistory(key, IOperationHistoryHolder.ChangeKind.RECTANGLE, rect); | |
152 | + rect.offsetTo(newLeft, newTop); | |
153 | + } | |
154 | + | |
155 | + public RectF getRect() | |
156 | + { | |
157 | + return (rect); | |
158 | + } | |
159 | + | |
160 | + public int getDrawStyle() | |
161 | + { | |
162 | + return (drawStyle); | |
163 | + } | |
164 | + | |
165 | + public int getIcon() | |
166 | + { | |
167 | + return (icon); | |
168 | + } | |
169 | + | |
170 | + public String getLabel() | |
171 | + { | |
172 | + return (label); | |
173 | + } | |
174 | + | |
175 | + public String getDetail() | |
176 | + { | |
177 | + return (detail); | |
178 | + } | |
179 | + | |
180 | + public boolean getUserChecked() | |
181 | + { | |
182 | + return (userChecked); | |
183 | + } | |
184 | + | |
185 | + public int getLabelColor() | |
186 | + { | |
187 | + return (labelColor); | |
188 | + } | |
189 | + | |
190 | + public int getObjectColor() | |
191 | + { | |
192 | + return (objectColor); | |
193 | + } | |
194 | + | |
195 | + public String getPaintStyle() | |
196 | + { | |
197 | + return (paintStyle); | |
198 | + } | |
199 | + | |
200 | + public float getstrokeWidth() | |
201 | + { | |
202 | + return (strokeWidth); | |
203 | + } | |
204 | + | |
205 | + public float getFontSize() | |
206 | + { | |
207 | + return (fontSize); | |
208 | + } | |
209 | +} |
@@ -1,4 +1,4 @@ | ||
1 | -package jp.sourceforge.gokigen.memoma.fileio; | |
1 | +package jp.sourceforge.gokigen.memoma.io; | |
2 | 2 | |
3 | 3 | import android.os.Environment; |
4 | 4 | import android.util.Log; |
@@ -1,4 +1,4 @@ | ||
1 | -package jp.sourceforge.gokigen.memoma.fileio; | |
1 | +package jp.sourceforge.gokigen.memoma.io; | |
2 | 2 | |
3 | 3 | import java.io.File; |
4 | 4 | import java.io.InputStream; |
@@ -1,4 +1,4 @@ | ||
1 | -package jp.sourceforge.gokigen.memoma.fileio; | |
1 | +package jp.sourceforge.gokigen.memoma.io; | |
2 | 2 | |
3 | 3 | import java.text.SimpleDateFormat; |
4 | 4 | import java.util.Calendar; |
@@ -15,20 +15,18 @@ import android.preference.PreferenceManager; | ||
15 | 15 | import android.util.Log; |
16 | 16 | import android.widget.Toast; |
17 | 17 | |
18 | -import jp.sourceforge.gokigen.memoma.GokigenSurfaceView; | |
18 | +import jp.sourceforge.gokigen.memoma.drawers.GokigenSurfaceView; | |
19 | 19 | import jp.sourceforge.gokigen.memoma.Main; |
20 | -import jp.sourceforge.gokigen.memoma.MeMoMaListener; | |
21 | 20 | import jp.sourceforge.gokigen.memoma.R; |
22 | -import jp.sourceforge.gokigen.memoma.SharedIntentInvoker; | |
23 | 21 | import jp.sourceforge.gokigen.memoma.drawers.MeMoMaCanvasDrawer; |
24 | 22 | import jp.sourceforge.gokigen.memoma.holders.MeMoMaDataFileHolder; |
25 | 23 | import jp.sourceforge.gokigen.memoma.holders.MeMoMaObjectHolder; |
26 | 24 | |
27 | 25 | public class MeMoMaDataInOutManager implements MeMoMaFileSavingProcess.ISavingStatusHolder, MeMoMaFileSavingProcess.IResultReceiver, MeMoMaFileLoadingProcess.IResultReceiver, ActionBar.OnNavigationListener, ObjectLayoutCaptureExporter.ICaptureLayoutExporter |
28 | 26 | { |
29 | - private Activity parent = null; | |
27 | + private Activity parent; | |
30 | 28 | private MeMoMaObjectHolder objectHolder = null; |
31 | - private ExternalStorageFileUtility fileUtility = null; | |
29 | + private ExternalStorageFileUtility fileUtility; | |
32 | 30 | private MeMoMaDataFileHolder dataFileHolder = null; |
33 | 31 | |
34 | 32 | private boolean isSaving = false; |
@@ -292,7 +290,7 @@ public class MeMoMaDataInOutManager implements MeMoMaFileSavingProcess.ISavingSt | ||
292 | 290 | * ファイルのエクスポート結果を受け取る |
293 | 291 | * |
294 | 292 | */ |
295 | - public void onCaptureLayoutExportedResult(String exportedFileName, String detail) | |
293 | + public void onCaptureLayoutExportedResult(String exportedFileName, String detail, int id) | |
296 | 294 | { |
297 | 295 | Log.v(Main.APP_IDENTIFIER, "MeMoMaDataInOutManager::onCaptureExportedResult() '" + objectHolder.getDataTitle() +"' : " + detail); |
298 | 296 |
@@ -315,7 +313,7 @@ public class MeMoMaDataInOutManager implements MeMoMaFileSavingProcess.ISavingSt | ||
315 | 313 | Uri insertedImage = resolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); |
316 | 314 | if (insertedImage != null) |
317 | 315 | { |
318 | - shareContent(insertedImage); | |
316 | + shareContent(insertedImage, id); | |
319 | 317 | } |
320 | 318 | } |
321 | 319 | catch (Exception e) |
@@ -331,7 +329,7 @@ public class MeMoMaDataInOutManager implements MeMoMaFileSavingProcess.ISavingSt | ||
331 | 329 | * エクスポートしたファイルを共有する |
332 | 330 | * |
333 | 331 | */ |
334 | - private void shareContent(Uri imageName) | |
332 | + private void shareContent(Uri imageName, int id) | |
335 | 333 | { |
336 | 334 | String message = ""; |
337 | 335 | try |
@@ -350,7 +348,7 @@ public class MeMoMaDataInOutManager implements MeMoMaFileSavingProcess.ISavingSt | ||
350 | 348 | message = message + "number of objects : " + objectHolder.getCount() + "\n"; |
351 | 349 | |
352 | 350 | // Share Intentを発行する。 |
353 | - SharedIntentInvoker.shareContent(parent, MeMoMaListener.MENU_ID_SHARE, title, message, imageName, "image/png"); | |
351 | + SharedIntentInvoker.shareContent(parent, id, title, message, imageName, "image/png"); | |
354 | 352 | } |
355 | 353 | catch (Exception ex) |
356 | 354 | { |
@@ -1,119 +1,121 @@ | ||
1 | -package jp.sourceforge.gokigen.memoma.fileio; | |
1 | +package jp.sourceforge.gokigen.memoma.io; | |
2 | 2 | |
3 | 3 | import java.io.File; |
4 | 4 | import java.io.FileWriter; |
5 | 5 | import java.text.SimpleDateFormat; |
6 | 6 | import java.util.Calendar; |
7 | 7 | import java.util.Enumeration; |
8 | +import java.util.Locale; | |
8 | 9 | |
9 | 10 | import android.app.ProgressDialog; |
10 | 11 | import android.content.Context; |
12 | +import android.graphics.RectF; | |
11 | 13 | import android.os.AsyncTask; |
12 | 14 | import android.util.Log; |
13 | 15 | |
14 | 16 | import jp.sourceforge.gokigen.memoma.Main; |
15 | 17 | import jp.sourceforge.gokigen.memoma.R; |
16 | 18 | import jp.sourceforge.gokigen.memoma.holders.MeMoMaObjectHolder; |
19 | +import jp.sourceforge.gokigen.memoma.holders.PositionObject; | |
17 | 20 | |
18 | 21 | /** |
19 | 22 | * データをファイルに保存するとき用 アクセスラッパ (非同期処理を実行) |
20 | - * | |
23 | + * | |
21 | 24 | * AsyncTask |
22 | 25 | * MeMoMaObjectHolder : 実行時に渡すクラス(Param) |
23 | 26 | * Integer : 途中経過を伝えるクラス(Progress) |
24 | 27 | * String : 処理結果を伝えるクラス(Result) |
25 | - * | |
28 | + * | |
26 | 29 | * @author MRSa |
27 | 30 | * |
28 | 31 | */ |
29 | 32 | public class MeMoMaFileExportCsvProcess extends AsyncTask<MeMoMaObjectHolder, Integer, String> |
30 | -{ | |
31 | - private IResultReceiver receiver = null; | |
32 | - private ExternalStorageFileUtility fileUtility = null; | |
33 | - private String exportedFileName = null; | |
34 | - | |
35 | - ProgressDialog savingDialog = null; | |
36 | - | |
37 | - /** | |
38 | - * コンストラクタ | |
39 | - */ | |
33 | +{ | |
34 | + private IResultReceiver receiver; | |
35 | + private ExternalStorageFileUtility fileUtility; | |
36 | + private String exportedFileName = null; | |
37 | + | |
38 | + private ProgressDialog savingDialog; | |
39 | + | |
40 | + /** | |
41 | + * コンストラクタ | |
42 | + */ | |
40 | 43 | public MeMoMaFileExportCsvProcess(Context context, ExternalStorageFileUtility utility, IResultReceiver resultReceiver) |
41 | 44 | { |
42 | - receiver = resultReceiver; | |
43 | - fileUtility = utility; | |
45 | + receiver = resultReceiver; | |
46 | + fileUtility = utility; | |
44 | 47 | |
45 | 48 | // プログレスダイアログ(「保存中...」)を表示する。 |
46 | - savingDialog = new ProgressDialog(context); | |
47 | - savingDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); | |
48 | - savingDialog.setMessage(context.getString(R.string.dataSaving)); | |
49 | - savingDialog.setIndeterminate(true); | |
50 | - savingDialog.setCancelable(false); | |
51 | - savingDialog.show(); | |
52 | - | |
53 | - /** ファイルをバックアップするディレクトリを作成する **/ | |
54 | - File dir = new File(fileUtility.getGokigenDirectory() + "/exported"); | |
55 | - dir.mkdir(); | |
56 | - | |
49 | + savingDialog = new ProgressDialog(context); | |
50 | + savingDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); | |
51 | + savingDialog.setMessage(context.getString(R.string.dataSaving)); | |
52 | + savingDialog.setIndeterminate(true); | |
53 | + savingDialog.setCancelable(false); | |
54 | + savingDialog.show(); | |
55 | + | |
56 | + // ファイルをバックアップするディレクトリを作成する | |
57 | + File dir = new File(fileUtility.getGokigenDirectory() + "/exported"); | |
58 | + if (!dir.mkdir()) | |
59 | + { | |
60 | + Log.v(toString(), "mkDir() fail. : " + dir.getAbsolutePath()); | |
61 | + } | |
57 | 62 | } |
58 | - | |
63 | + | |
59 | 64 | /** |
60 | 65 | * 非同期処理実施前の前処理 |
61 | - * | |
66 | + * | |
62 | 67 | */ |
63 | 68 | @Override |
64 | 69 | protected void onPreExecute() |
65 | 70 | { |
66 | 71 | } |
67 | - | |
72 | + | |
68 | 73 | /** |
69 | 74 | * データを(CSV形式で)保管する。 |
70 | - * | |
71 | - * @param fileName | |
72 | - * @param objectHolder | |
73 | - * @return | |
75 | + * | |
74 | 76 | */ |
75 | 77 | private String exportToCsvFile(String fileName, MeMoMaObjectHolder objectHolder) |
76 | 78 | { |
77 | - String resultMessage = ""; | |
79 | + String resultMessage = ""; | |
78 | 80 | try |
79 | 81 | { |
80 | - // エクスポートするファイル名を決定する | |
82 | + // エクスポートするファイル名を決定する | |
81 | 83 | Calendar calendar = Calendar.getInstance(); |
82 | - SimpleDateFormat outFormat = new SimpleDateFormat("yyyyMMddHHmmss"); | |
84 | + SimpleDateFormat outFormat = new SimpleDateFormat("yyyyMMddHHmmss", Locale.US); | |
83 | 85 | exportedFileName = fileName + "_" + outFormat.format(calendar.getTime()) + ".csv"; |
84 | - FileWriter writer = new FileWriter(new File(exportedFileName)); | |
85 | - | |
86 | - // データのタイトルを出力 | |
87 | - String str = ""; | |
88 | - str = "; label,detail,userChecked,shape,style,centerX,centerY,width,height,;!<_$ (';!<_$' is a record Separator)\r\n"; | |
86 | + FileWriter writer = new FileWriter(new File(exportedFileName)); | |
87 | + | |
88 | + // データのタイトルを出力 | |
89 | + String str = "; label,detail,userChecked,shape,style,centerX,centerY,width,height,;!<_$ (';!<_$' is a record Separator)\r\n"; | |
89 | 90 | writer.write(str); |
90 | - | |
91 | - // オブジェクトの出力 (保持しているものをすべて表示する) | |
92 | - Enumeration<Integer> keys = objectHolder.getObjectKeys(); | |
91 | + | |
92 | + // オブジェクトの出力 (保持しているものをすべて表示する) | |
93 | + Enumeration<Integer> keys = objectHolder.getObjectKeys(); | |
93 | 94 | while (keys.hasMoreElements()) |
94 | 95 | { |
95 | 96 | Integer key = keys.nextElement(); |
96 | - MeMoMaObjectHolder.PositionObject pos = objectHolder.getPosition(key); | |
97 | + PositionObject pos = objectHolder.getPosition(key); | |
98 | + RectF posRect = pos.getRect(); | |
97 | 99 | |
98 | 100 | // TODO: 絞り込み条件がある場合には、その条件に従ってしぼり込む必要あり。 |
99 | 101 | |
100 | 102 | str = ""; |
101 | - str = str + "\"" + pos.label + "\""; | |
102 | - str = str + ",\"" + pos.detail + "\""; | |
103 | - if (pos.userChecked == true) | |
103 | + str = str + "\"" + pos.getLabel() + "\""; | |
104 | + str = str + ",\"" + pos.getDetail() + "\""; | |
105 | + if (pos.getUserChecked()) | |
104 | 106 | { |
105 | - str = str + ",True"; | |
107 | + str = str + ",True"; | |
106 | 108 | } |
107 | 109 | else |
108 | 110 | { |
109 | - str = str + ",False"; | |
111 | + str = str + ",False"; | |
110 | 112 | } |
111 | - str = str + "," + pos.drawStyle; // オブジェクトの形状 | |
112 | - str = str + "," + pos.paintStyle; // オブジェクトの塗りつぶし状態 | |
113 | - str = str + "," + (Math.round(pos.rect.centerX() * 100.0f) / 100.0f); | |
114 | - str = str + "," + (Math.round(pos.rect.centerY() * 100.0f) / 100.0f); | |
115 | - str = str + "," + (Math.round(pos.rect.width() * 100.0f) / 100.0f); | |
116 | - str = str + "," + (Math.round(pos.rect.height() * 100.0f) / 100.0f); | |
113 | + str = str + "," + pos.getDrawStyle(); // オブジェクトの形状 | |
114 | + str = str + "," + pos.getPaintStyle(); // オブジェクトの塗りつぶし状態 | |
115 | + str = str + "," + (Math.round(posRect.centerX() * 100.0f) / 100.0f); | |
116 | + str = str + "," + (Math.round(posRect.centerY() * 100.0f) / 100.0f); | |
117 | + str = str + "," + (Math.round(posRect.width() * 100.0f) / 100.0f); | |
118 | + str = str + "," + (Math.round(posRect.height() * 100.0f) / 100.0f); | |
117 | 119 | str = str + ",;!<_$\r\n"; |
118 | 120 | writer.write(str); |
119 | 121 | } |
@@ -122,41 +124,41 @@ public class MeMoMaFileExportCsvProcess extends AsyncTask<MeMoMaObjectHolder, In | ||
122 | 124 | } |
123 | 125 | catch (Exception e) |
124 | 126 | { |
125 | - resultMessage = " ERR>" + e.toString(); | |
127 | + resultMessage = " ERR>" + e.toString(); | |
126 | 128 | Log.v(Main.APP_IDENTIFIER, resultMessage); |
127 | 129 | e.printStackTrace(); |
128 | - } | |
130 | + } | |
129 | 131 | return (resultMessage); |
130 | 132 | } |
131 | 133 | |
132 | 134 | /** |
133 | 135 | * 非同期処理 |
134 | 136 | * (バックグラウンドで実行する(このメソッドは、UIスレッドと別のところで実行する)) |
135 | - * | |
137 | + * | |
136 | 138 | */ |
137 | 139 | @Override |
138 | 140 | protected String doInBackground(MeMoMaObjectHolder... datas) |
139 | - { | |
141 | + { | |
140 | 142 | // ファイル名の設定 ... (拡張子なし) |
141 | - String fileName = fileUtility.getGokigenDirectory() + "/exported/" + datas[0].getDataTitle(); | |
143 | + String fileName = fileUtility.getGokigenDirectory() + "/exported/" + datas[0].getDataTitle(); | |
142 | 144 | |
143 | - // データを保管する | |
145 | + // データを保管する | |
144 | 146 | String result = exportToCsvFile(fileName, datas[0]); |
145 | 147 | |
146 | 148 | System.gc(); |
147 | 149 | |
148 | - return (result); | |
150 | + return (result); | |
149 | 151 | } |
150 | 152 | |
151 | 153 | /** |
152 | 154 | * 非同期処理の進捗状況の更新 |
153 | - * | |
155 | + * | |
154 | 156 | */ |
155 | - @Override | |
156 | - protected void onProgressUpdate(Integer... values) | |
157 | - { | |
157 | + @Override | |
158 | + protected void onProgressUpdate(Integer... values) | |
159 | + { | |
158 | 160 | // 今回は何もしない |
159 | - } | |
161 | + } | |
160 | 162 | |
161 | 163 | /** |
162 | 164 | * 非同期処理の後処理 |
@@ -165,32 +167,30 @@ public class MeMoMaFileExportCsvProcess extends AsyncTask<MeMoMaObjectHolder, In | ||
165 | 167 | @Override |
166 | 168 | protected void onPostExecute(String result) |
167 | 169 | { |
168 | - try | |
169 | - { | |
170 | + try | |
171 | + { | |
170 | 172 | if (receiver != null) |
171 | 173 | { |
172 | - receiver.onExportedResult(exportedFileName, result); | |
174 | + receiver.onExportedResult(exportedFileName, result); | |
173 | 175 | } |
174 | - } | |
175 | - catch (Exception ex) | |
176 | - { | |
177 | - Log.v(Main.APP_IDENTIFIER, "MeMoMaFileExportCsvProcess::onPostExecute() : " + ex.toString()); | |
178 | - } | |
179 | - // プログレスダイアログを消す | |
180 | - savingDialog.dismiss(); | |
181 | - | |
182 | - return; | |
183 | - } | |
184 | - | |
176 | + } | |
177 | + catch (Exception ex) | |
178 | + { | |
179 | + Log.v(Main.APP_IDENTIFIER, "MeMoMaFileExportCsvProcess::onPostExecute() : " + ex.toString()); | |
180 | + } | |
181 | + // プログレスダイアログを消す | |
182 | + savingDialog.dismiss(); | |
183 | + } | |
184 | + | |
185 | 185 | /** |
186 | 186 | * 結果報告用のインタフェース(積極的に使う予定はないけど...) |
187 | - * | |
187 | + * | |
188 | 188 | * @author MRSa |
189 | 189 | * |
190 | 190 | */ |
191 | 191 | public interface IResultReceiver |
192 | 192 | { |
193 | 193 | /** 保存結果の報告 **/ |
194 | - public abstract void onExportedResult(String exportedFileName, String detail); | |
194 | + void onExportedResult(String exportedFileName, String detail); | |
195 | 195 | } |
196 | 196 | } |
@@ -1,4 +1,4 @@ | ||
1 | -package jp.sourceforge.gokigen.memoma.fileio; | |
1 | +package jp.sourceforge.gokigen.memoma.io; | |
2 | 2 | |
3 | 3 | import java.io.BufferedReader; |
4 | 4 | import java.io.FileReader; |
@@ -13,6 +13,7 @@ import android.util.Log; | ||
13 | 13 | import jp.sourceforge.gokigen.memoma.Main; |
14 | 14 | import jp.sourceforge.gokigen.memoma.R; |
15 | 15 | import jp.sourceforge.gokigen.memoma.holders.MeMoMaObjectHolder; |
16 | +import jp.sourceforge.gokigen.memoma.holders.PositionObject; | |
16 | 17 | |
17 | 18 | /** |
18 | 19 | * データをファイルに保存するとき用 アクセスラッパ (非同期処理を実行) |
@@ -167,18 +168,18 @@ public class MeMoMaFileImportCsvProcess extends AsyncTask<MeMoMaObjectHolder, In | ||
167 | 168 | float top = centerY - (height / 2.0f); |
168 | 169 | |
169 | 170 | // オブジェクトのデータを作成する |
170 | - MeMoMaObjectHolder.PositionObject pos = objectHolder.createPosition(left, top, drawStyle); | |
171 | + PositionObject pos = objectHolder.createPosition(left, top, drawStyle); | |
171 | 172 | if (pos == null) |
172 | 173 | { |
173 | 174 | Log.v(Main.APP_IDENTIFIER, "parseRecord() : object create failure."); |
174 | 175 | return; |
175 | 176 | } |
176 | - pos.rect.right = left + width; | |
177 | - pos.rect.bottom = top + height; | |
178 | - pos.label = label; | |
179 | - pos.detail = detail; | |
180 | - pos.paintStyle = paintStyle; | |
181 | - pos.userChecked = userChecked; | |
177 | + pos.setRectRight(left + width); | |
178 | + pos.setRectBottom(top + height); | |
179 | + pos.setLabel(label); | |
180 | + pos.setDetail(detail); | |
181 | + pos.setPaintStyle(paintStyle); | |
182 | + pos.setUserChecked(userChecked); | |
182 | 183 | Log.v(Main.APP_IDENTIFIER, "OBJECT CREATED: " + label + "(" + left + "," + top + ") [" +drawStyle + "]"); |
183 | 184 | } |
184 | 185 | catch (Exception ex) |
@@ -1,4 +1,4 @@ | ||
1 | -package jp.sourceforge.gokigen.memoma.fileio; | |
1 | +package jp.sourceforge.gokigen.memoma.io; | |
2 | 2 | |
3 | 3 | import java.io.File; |
4 | 4 | import java.io.FileReader; |
@@ -7,6 +7,7 @@ import org.xmlpull.v1.XmlPullParser; | ||
7 | 7 | |
8 | 8 | import android.content.Context; |
9 | 9 | import android.content.SharedPreferences; |
10 | +import android.graphics.RectF; | |
10 | 11 | import android.os.AsyncTask; |
11 | 12 | import android.preference.PreferenceManager; |
12 | 13 | import android.util.Log; |
@@ -15,6 +16,8 @@ import android.util.Xml; | ||
15 | 16 | import jp.sourceforge.gokigen.memoma.Main; |
16 | 17 | import jp.sourceforge.gokigen.memoma.holders.MeMoMaConnectLineHolder; |
17 | 18 | import jp.sourceforge.gokigen.memoma.holders.MeMoMaObjectHolder; |
19 | +import jp.sourceforge.gokigen.memoma.holders.ObjectConnector; | |
20 | +import jp.sourceforge.gokigen.memoma.holders.PositionObject; | |
18 | 21 | |
19 | 22 | /** |
20 | 23 | * データをファイルに保存するとき用 アクセスラッパ (非同期処理を実行) |
@@ -29,12 +32,12 @@ import jp.sourceforge.gokigen.memoma.holders.MeMoMaObjectHolder; | ||
29 | 32 | */ |
30 | 33 | public class MeMoMaFileLoadingProcess extends AsyncTask<MeMoMaObjectHolder, Integer, String> |
31 | 34 | { |
32 | - private Context parent = null; | |
33 | - private IResultReceiver receiver = null; | |
34 | - private ExternalStorageFileUtility fileUtility = null; | |
35 | + private Context parent; | |
36 | + private IResultReceiver receiver; | |
37 | + private ExternalStorageFileUtility fileUtility; | |
35 | 38 | |
36 | - private MeMoMaObjectHolder.PositionObject position = null; | |
37 | - private MeMoMaConnectLineHolder.ObjectConnector line = null; | |
39 | + private PositionObject position = null; | |
40 | + private ObjectConnector line = null; | |
38 | 41 | |
39 | 42 | private String backgroundUri = ""; |
40 | 43 | private String userCheckboxString = ""; |
@@ -66,37 +69,37 @@ public class MeMoMaFileLoadingProcess extends AsyncTask<MeMoMaObjectHolder, Inte | ||
66 | 69 | //Log.v(Main.APP_IDENTIFIER, "parseStartTag() name = " + name); |
67 | 70 | if ((name.equalsIgnoreCase("top"))&&(position != null)) |
68 | 71 | { |
69 | - position.rect.top = Float.parseFloat(parser.nextText()); | |
72 | + position.setRectTop(Float.parseFloat(parser.nextText())); | |
70 | 73 | } |
71 | 74 | else if ((name.equalsIgnoreCase("bottom"))&&(position != null)) |
72 | 75 | { |
73 | - position.rect.bottom = Float.parseFloat(parser.nextText()); | |
76 | + position.setRectBottom(Float.parseFloat(parser.nextText())); | |
74 | 77 | } |
75 | 78 | else if ((name.equalsIgnoreCase("left"))&&(position != null)) |
76 | 79 | { |
77 | - position.rect.left = Float.parseFloat(parser.nextText()); | |
80 | + position.setRectLeft(Float.parseFloat(parser.nextText())); | |
78 | 81 | } |
79 | 82 | else if ((name.equalsIgnoreCase("right"))&&(position != null)) |
80 | 83 | { |
81 | - position.rect.right = Float.parseFloat(parser.nextText()); | |
84 | + position.setRectRight(Float.parseFloat(parser.nextText())); | |
82 | 85 | } |
83 | 86 | else if ((name.equalsIgnoreCase("drawStyle"))&&(position != null)) |
84 | 87 | { |
85 | - position.drawStyle = Integer.parseInt(parser.nextText()); | |
88 | + position.setDrawStyle(Integer.parseInt(parser.nextText())); | |
86 | 89 | } |
87 | 90 | else if ((name.equalsIgnoreCase("icon"))&&(position != null)) |
88 | 91 | { |
89 | - position.icon = Integer.parseInt(parser.nextText()); | |
92 | + position.setIcon(Integer.parseInt(parser.nextText())); | |
90 | 93 | } |
91 | 94 | else if ((name.equalsIgnoreCase("label"))&&(position != null)) |
92 | 95 | { |
93 | - position.label = parser.nextText(); | |
96 | + position.setLabel(parser.nextText()); | |
94 | 97 | } |
95 | 98 | else if ((name.equalsIgnoreCase("detail"))&&(position != null)) |
96 | 99 | { |
97 | - position.detail = parser.nextText(); | |
100 | + position.setDetail(parser.nextText()); | |
98 | 101 | } |
99 | -/** | |
102 | +/* | |
100 | 103 | else if ((name.equalsIgnoreCase("backgroundUri"))&&(position != null)) |
101 | 104 | { |
102 | 105 | position.backgroundUri = parser.nextText(); |
@@ -113,49 +116,49 @@ public class MeMoMaFileLoadingProcess extends AsyncTask<MeMoMaObjectHolder, Inte | ||
113 | 116 | else if ((name.equalsIgnoreCase("userChecked"))&&(position != null)) |
114 | 117 | { |
115 | 118 | String parseData = parser.nextText(); |
116 | - position.userChecked =(parseData.equalsIgnoreCase("true")) ? true : false; | |
119 | + position.setUserChecked((parseData.equalsIgnoreCase("true"))); | |
117 | 120 | } |
118 | 121 | else if ((name.equalsIgnoreCase("labelColor"))&&(position != null)) |
119 | 122 | { |
120 | - position.labelColor = Integer.parseInt(parser.nextText()); | |
123 | + position.setLabelColor(Integer.parseInt(parser.nextText())); | |
121 | 124 | } |
122 | 125 | else if ((name.equalsIgnoreCase("objectColor"))&&(position != null)) |
123 | 126 | { |
124 | - position.objectColor = Integer.parseInt(parser.nextText()); | |
127 | + position.setObjectColor(Integer.parseInt(parser.nextText())); | |
125 | 128 | } |
126 | 129 | else if ((name.equalsIgnoreCase("paintStyle"))&&(position != null)) |
127 | 130 | { |
128 | - position.paintStyle = parser.nextText(); | |
131 | + position.setPaintStyle(parser.nextText()); | |
129 | 132 | } |
130 | 133 | else if ((name.equalsIgnoreCase("strokeWidth"))&&(position != null)) |
131 | 134 | { |
132 | - position.strokeWidth = Float.parseFloat(parser.nextText()); | |
135 | + position.setStrokeWidth(Float.parseFloat(parser.nextText())); | |
133 | 136 | } |
134 | 137 | else if ((name.equalsIgnoreCase("fontSize"))&&(position != null)) |
135 | 138 | { |
136 | - position.fontSize = Float.parseFloat(parser.nextText()); | |
139 | + position.setFontSize(Float.parseFloat(parser.nextText())); | |
137 | 140 | } |
138 | 141 | else if ((name.equalsIgnoreCase("fromObjectKey"))&&(line != null)) |
139 | 142 | { |
140 | - line.fromObjectKey = Integer.parseInt(parser.nextText()); | |
143 | + line.setFromObjectKey(Integer.parseInt(parser.nextText())); | |
141 | 144 | } |
142 | 145 | else if ((name.equalsIgnoreCase("toObjectKey"))&&(line != null)) |
143 | 146 | { |
144 | - line.toObjectKey = Integer.parseInt(parser.nextText()); | |
147 | + line.setToObjectKey(Integer.parseInt(parser.nextText())); | |
145 | 148 | } |
146 | 149 | else if ((name.equalsIgnoreCase("lineStyle"))&&(line != null)) |
147 | 150 | { |
148 | - line.lineStyle = Integer.parseInt(parser.nextText()); | |
151 | + line.setLineStyle(Integer.parseInt(parser.nextText())); | |
149 | 152 | } |
150 | 153 | else if ((name.equalsIgnoreCase("lineShape"))&&(line != null)) |
151 | 154 | { |
152 | - line.lineShape = Integer.parseInt(parser.nextText()); | |
155 | + line.setLineShape(Integer.parseInt(parser.nextText())); | |
153 | 156 | } |
154 | 157 | else if ((name.equalsIgnoreCase("lineThickness"))&&(line != null)) |
155 | 158 | { |
156 | - line.lineThickness = Integer.parseInt(parser.nextText()); | |
159 | + line.setLineThickness(Integer.parseInt(parser.nextText())); | |
157 | 160 | } |
158 | -/** | |
161 | +/* | |
159 | 162 | else if ((name.equalsIgnoreCase("fromShape"))&&(line != null)) |
160 | 163 | { |
161 | 164 | line.fromShape = Integer.parseInt(parser.nextText()); |
@@ -203,15 +206,20 @@ public class MeMoMaFileLoadingProcess extends AsyncTask<MeMoMaObjectHolder, Inte | ||
203 | 206 | { |
204 | 207 | int key = Integer.parseInt(parser.getAttributeValue(Main.APP_NAMESPACE, "key")); |
205 | 208 | //Log.v(Main.APP_IDENTIFIER, "create object, key :" + key); |
206 | - position = null; | |
207 | - position = objectHolder.createPosition(key); | |
209 | + if (objectHolder != null) | |
210 | + { | |
211 | + position = objectHolder.createPosition(key); | |
212 | + } | |
208 | 213 | } |
209 | 214 | else if (name.equalsIgnoreCase("line")) |
210 | 215 | { |
211 | 216 | int key = Integer.parseInt(parser.getAttributeValue(Main.APP_NAMESPACE, "key")); |
212 | 217 | //Log.v(Main.APP_IDENTIFIER, "create line, key :" + key); |
213 | 218 | line = null; |
214 | - line = objectHolder.getConnectLineHolder().createLine(key); | |
219 | + if (objectHolder != null) | |
220 | + { | |
221 | + line = objectHolder.getConnectLineHolder().createLine(key); | |
222 | + } | |
215 | 223 | } |
216 | 224 | } |
217 | 225 | catch (Exception e) |
@@ -230,19 +238,22 @@ public class MeMoMaFileLoadingProcess extends AsyncTask<MeMoMaObjectHolder, Inte | ||
230 | 238 | //objectHolder.dumpPositionObject(position); |
231 | 239 | |
232 | 240 | // 領域サイズがおかしい場合には、オブジェクトサイズを補正する (ふつーありえないはずなんだけど...) |
233 | - if ((position.rect.left > position.rect.right)||(position.rect.top > position.rect.bottom)) | |
241 | + RectF posRect = position.getRect(); | |
242 | + if ((posRect.left > posRect.right)||(posRect.top > posRect.bottom)) | |
234 | 243 | { |
235 | - Log.v(Main.APP_IDENTIFIER, "RECT IS ILLEGAL. : [" + position.rect.left + "," + position.rect.top + "-[" + position.rect.right + "," + position.rect.bottom + "]"); | |
236 | - position.rect.right = position.rect.left + MeMoMaObjectHolder.OBJECTSIZE_DEFAULT_X; | |
237 | - position.rect.bottom = position.rect.top + MeMoMaObjectHolder.OBJECTSIZE_DEFAULT_Y; | |
244 | + Log.v(Main.APP_IDENTIFIER, "RECT IS ILLEGAL. : [" + posRect.left + "," + posRect.top + "-[" + posRect.right + "," + posRect.bottom + "]"); | |
245 | + position.setRectRight(posRect.left + MeMoMaObjectHolder.OBJECTSIZE_DEFAULT_X); | |
246 | + position.setRectBottom(posRect.top + MeMoMaObjectHolder.OBJECTSIZE_DEFAULT_Y); | |
238 | 247 | } |
239 | - | |
240 | 248 | } |
249 | +/* | |
241 | 250 | else if (name.equalsIgnoreCase("line")) |
242 | 251 | { |
252 | + // | |
243 | 253 | //Log.v(Main.APP_IDENTIFIER, "parseEndTag() : LINE"); |
244 | 254 | //objectHolder.getConnectLineHolder().dumpConnectLine(line); |
245 | 255 | } |
256 | +*/ | |
246 | 257 | } |
247 | 258 | catch (Exception e) |
248 | 259 | { |
@@ -252,10 +263,7 @@ public class MeMoMaFileLoadingProcess extends AsyncTask<MeMoMaObjectHolder, Inte | ||
252 | 263 | |
253 | 264 | /** |
254 | 265 | * (XML形式の)データを読みだす。 |
255 | - * | |
256 | - * @param fileName | |
257 | - * @param objectHolder | |
258 | - * @return | |
266 | + * | |
259 | 267 | */ |
260 | 268 | private String restoreToXmlFile(String fileName, MeMoMaObjectHolder objectHolder) |
261 | 269 | { |
@@ -270,7 +278,7 @@ public class MeMoMaFileLoadingProcess extends AsyncTask<MeMoMaObjectHolder, Inte | ||
270 | 278 | try |
271 | 279 | { |
272 | 280 | File inputFile = new File(fileName); |
273 | - if (inputFile.exists() == false) | |
281 | + if (!inputFile.exists()) | |
274 | 282 | { |
275 | 283 | // ファイルがなかったときには、「ファイルなし」と報告する。 |
276 | 284 | resultMessage = "ERR>File not found."; |
@@ -281,7 +289,6 @@ public class MeMoMaFileLoadingProcess extends AsyncTask<MeMoMaObjectHolder, Inte | ||
281 | 289 | parser.setInput(reader); |
282 | 290 | |
283 | 291 | int eventType = parser.getEventType(); |
284 | - boolean done = false; | |
285 | 292 | |
286 | 293 | // オブジェクトとラインをすべてクリアする |
287 | 294 | objectHolder.removeAllPositions(); |
@@ -292,7 +299,7 @@ public class MeMoMaFileLoadingProcess extends AsyncTask<MeMoMaObjectHolder, Inte | ||
292 | 299 | } |
293 | 300 | lineHolder.removeAllLines(); |
294 | 301 | |
295 | - while ((eventType != XmlPullParser.END_DOCUMENT)&&(done != true)) | |
302 | + while ((eventType != XmlPullParser.END_DOCUMENT)) | |
296 | 303 | { |
297 | 304 | switch (eventType) |
298 | 305 | { |
@@ -366,14 +373,14 @@ public class MeMoMaFileLoadingProcess extends AsyncTask<MeMoMaObjectHolder, Inte | ||
366 | 373 | { |
367 | 374 | try |
368 | 375 | { |
369 | - if (result.isEmpty() == true) | |
376 | + if (result.isEmpty()) | |
370 | 377 | { |
371 | 378 | // エラーが発生していない場合には、読みだしたデータをPreferenceに設定登録... |
372 | 379 | SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(parent); |
373 | 380 | SharedPreferences.Editor editor = preferences.edit(); |
374 | 381 | editor.putString("backgroundUri", backgroundUri); |
375 | 382 | editor.putString("userCheckboxString", userCheckboxString); |
376 | - editor.commit(); | |
383 | + editor.apply(); | |
377 | 384 | } |
378 | 385 | |
379 | 386 | if (receiver != null) |
@@ -385,7 +392,6 @@ public class MeMoMaFileLoadingProcess extends AsyncTask<MeMoMaObjectHolder, Inte | ||
385 | 392 | { |
386 | 393 | Log.v(Main.APP_IDENTIFIER, "MeMoMaFileSavingProcess::onPostExecute() : " + ex.toString()); |
387 | 394 | } |
388 | - return; | |
389 | 395 | } |
390 | 396 | |
391 | 397 | /** |
@@ -397,9 +403,9 @@ public class MeMoMaFileLoadingProcess extends AsyncTask<MeMoMaObjectHolder, Inte | ||
397 | 403 | public interface IResultReceiver |
398 | 404 | { |
399 | 405 | /** 処理中の処理 **/ |
400 | - public abstract void onLoadingProcess(); | |
406 | + void onLoadingProcess(); | |
401 | 407 | |
402 | 408 | /** 保存結果の報告 **/ |
403 | - public abstract void onLoadedResult(String detail); | |
409 | + void onLoadedResult(String detail); | |
404 | 410 | } |
405 | 411 | } |
@@ -1,4 +1,4 @@ | ||
1 | -package jp.sourceforge.gokigen.memoma.fileio; | |
1 | +package jp.sourceforge.gokigen.memoma.io; | |
2 | 2 | |
3 | 3 | import java.io.File; |
4 | 4 | import java.io.FileWriter; |
@@ -6,12 +6,14 @@ import java.util.Enumeration; | ||
6 | 6 | |
7 | 7 | import org.xmlpull.v1.XmlSerializer; |
8 | 8 | |
9 | +import android.graphics.RectF; | |
9 | 10 | import android.util.Log; |
10 | 11 | import android.util.Xml; |
11 | 12 | |
12 | 13 | import jp.sourceforge.gokigen.memoma.Main; |
13 | -import jp.sourceforge.gokigen.memoma.holders.MeMoMaConnectLineHolder; | |
14 | 14 | import jp.sourceforge.gokigen.memoma.holders.MeMoMaObjectHolder; |
15 | +import jp.sourceforge.gokigen.memoma.holders.ObjectConnector; | |
16 | +import jp.sourceforge.gokigen.memoma.holders.PositionObject; | |
15 | 17 | |
16 | 18 | /** |
17 | 19 | * データをファイルに保存するエンジン部分 |
@@ -28,12 +30,12 @@ public class MeMoMaFileSavingEngine | ||
28 | 30 | /** |
29 | 31 | * コンストラクタ |
30 | 32 | */ |
31 | - public MeMoMaFileSavingEngine(ExternalStorageFileUtility utility, String bgUri, String checkBoxLabel) | |
33 | + MeMoMaFileSavingEngine(ExternalStorageFileUtility utility, String bgUri, String checkBoxLabel) | |
32 | 34 | { |
33 | - /** ファイルユーティリティを記憶する **/ | |
35 | + // ファイルユーティリティを記憶する | |
34 | 36 | fileUtility = utility; |
35 | 37 | |
36 | - /** ファイルをバックアップするディレクトリを作成する **/ | |
38 | + // ファイルをバックアップするディレクトリを作成する | |
37 | 39 | File dir = new File(fileUtility.getGokigenDirectory() + "/backup"); |
38 | 40 | dir.mkdir(); |
39 | 41 |
@@ -44,15 +46,13 @@ public class MeMoMaFileSavingEngine | ||
44 | 46 | |
45 | 47 | /** |
46 | 48 | * ファイルが存在したとき、リネームする |
47 | - * | |
48 | - * @param targetFileName | |
49 | - * @param newFileName | |
49 | + * | |
50 | 50 | */ |
51 | 51 | private boolean renameFile(String targetFileName, String newFileName) |
52 | 52 | { |
53 | 53 | boolean ret = true; |
54 | 54 | File targetFile = new File(targetFileName); |
55 | - if (targetFile.exists() == true) | |
55 | + if (targetFile.exists()) | |
56 | 56 | { |
57 | 57 | // ファイルが存在した、、、ファイル名を1世代古いものに変更する |
58 | 58 | ret = targetFile.renameTo(new File(newFileName)); |
@@ -63,7 +63,7 @@ public class MeMoMaFileSavingEngine | ||
63 | 63 | /** |
64 | 64 | * 保管データを複数世代保管する。 |
65 | 65 | * |
66 | - * @param fileName | |
66 | + * | |
67 | 67 | */ |
68 | 68 | private void backupFiles(String dirName, String backupFileName) |
69 | 69 | { |
@@ -73,7 +73,7 @@ public class MeMoMaFileSavingEngine | ||
73 | 73 | { |
74 | 74 | String fileName = dirName + "backup/" + backupFileName; |
75 | 75 | File backFile = new File(fileName + ".xml.bak5"); |
76 | - if (backFile.exists() == true) | |
76 | + if (backFile.exists()) | |
77 | 77 | { |
78 | 78 | // ファイルが存在した、、、削除する |
79 | 79 | backFile.delete(); |
@@ -91,20 +91,16 @@ public class MeMoMaFileSavingEngine | ||
91 | 91 | // 何か例外が発生した場合にはエラーと認識する。 |
92 | 92 | result = false; |
93 | 93 | } |
94 | - if (result == false) | |
94 | + if (!result) | |
95 | 95 | { |
96 | 96 | // バックアップファイルのコピー失敗をログに記述する |
97 | 97 | Log.v(Main.APP_IDENTIFIER, "rename failure : " + dirName + backupFileName + ".xml"); |
98 | 98 | } |
99 | - return; | |
100 | 99 | } |
101 | 100 | |
102 | 101 | /** |
103 | 102 | * データを(XML形式で)保管する。 |
104 | - * | |
105 | - * @param fileName | |
106 | - * @param objectHolder | |
107 | - * @return | |
103 | + * | |
108 | 104 | */ |
109 | 105 | private String storeToXmlFile(String fileName, MeMoMaObjectHolder objectHolder) |
110 | 106 | { |
@@ -152,42 +148,43 @@ public class MeMoMaFileSavingEngine | ||
152 | 148 | while (keys.hasMoreElements()) |
153 | 149 | { |
154 | 150 | Integer key = keys.nextElement(); |
155 | - MeMoMaObjectHolder.PositionObject pos = objectHolder.getPosition(key); | |
151 | + PositionObject pos = objectHolder.getPosition(key); | |
152 | + RectF posRect = pos.getRect(); | |
156 | 153 | serializer.startTag(Main.APP_NAMESPACE, "object"); |
157 | 154 | |
158 | 155 | serializer.attribute(Main.APP_NAMESPACE, "key", Integer.toString(key)); |
159 | 156 | |
160 | 157 | serializer.startTag(Main.APP_NAMESPACE, "rect"); |
161 | 158 | serializer.startTag(Main.APP_NAMESPACE, "top"); |
162 | - serializer.text(Float.toString(pos.rect.top)); | |
159 | + serializer.text(Float.toString(posRect.top)); | |
163 | 160 | serializer. endTag(Main.APP_NAMESPACE, "top"); |
164 | 161 | serializer.startTag(Main.APP_NAMESPACE, "left"); |
165 | - serializer.text(Float.toString(pos.rect.left)); | |
162 | + serializer.text(Float.toString(posRect.left)); | |
166 | 163 | serializer. endTag(Main.APP_NAMESPACE, "left"); |
167 | 164 | serializer.startTag(Main.APP_NAMESPACE, "right"); |
168 | - serializer.text(Float.toString(pos.rect.right)); | |
165 | + serializer.text(Float.toString(posRect.right)); | |
169 | 166 | serializer. endTag(Main.APP_NAMESPACE, "right"); |
170 | 167 | serializer.startTag(Main.APP_NAMESPACE, "bottom"); |
171 | - serializer.text(Float.toString(pos.rect.bottom)); | |
168 | + serializer.text(Float.toString(posRect.bottom)); | |
172 | 169 | serializer. endTag(Main.APP_NAMESPACE, "bottom"); |
173 | 170 | serializer. endTag(Main.APP_NAMESPACE, "rect"); |
174 | 171 | |
175 | 172 | serializer.startTag(Main.APP_NAMESPACE, "drawStyle"); |
176 | - serializer.text(Integer.toString(pos.drawStyle)); | |
173 | + serializer.text(Integer.toString(pos.getDrawStyle())); | |
177 | 174 | serializer. endTag(Main.APP_NAMESPACE, "drawStyle"); |
178 | 175 | |
179 | 176 | serializer.startTag(Main.APP_NAMESPACE, "icon"); |
180 | - serializer.text(Integer.toString(pos.icon)); | |
177 | + serializer.text(Integer.toString(pos.getIcon())); | |
181 | 178 | serializer. endTag(Main.APP_NAMESPACE, "icon"); |
182 | 179 | |
183 | 180 | serializer.startTag(Main.APP_NAMESPACE, "label"); |
184 | - serializer.text(pos.label); | |
181 | + serializer.text(pos.getLabel()); | |
185 | 182 | serializer. endTag(Main.APP_NAMESPACE, "label"); |
186 | 183 | |
187 | 184 | serializer.startTag(Main.APP_NAMESPACE, "detail"); |
188 | - serializer.text(pos.detail); | |
185 | + serializer.text(pos.getDetail()); | |
189 | 186 | serializer. endTag(Main.APP_NAMESPACE, "detail"); |
190 | -/** | |
187 | +/* | |
191 | 188 | serializer.startTag(Main.APP_NAMESPACE, "otherInfoUri"); |
192 | 189 | serializer.text(pos.otherInfoUri); |
193 | 190 | serializer. endTag(Main.APP_NAMESPACE, "otherInfoUri"); |
@@ -199,29 +196,29 @@ public class MeMoMaFileSavingEngine | ||
199 | 196 | serializer.startTag(Main.APP_NAMESPACE, "objectStatus"); |
200 | 197 | serializer.text(pos.objectStatus); |
201 | 198 | serializer. endTag(Main.APP_NAMESPACE, "objectStatus"); |
202 | -**/ | |
199 | +*/ | |
203 | 200 | serializer.startTag(Main.APP_NAMESPACE, "userChecked"); |
204 | - serializer.text(Boolean.toString(pos.userChecked)); | |
201 | + serializer.text(Boolean.toString(pos.getUserChecked())); | |
205 | 202 | serializer. endTag(Main.APP_NAMESPACE, "userChecked"); |
206 | 203 | |
207 | 204 | serializer.startTag(Main.APP_NAMESPACE, "labelColor"); |
208 | - serializer.text(Integer.toString(pos.labelColor)); | |
205 | + serializer.text(Integer.toString(pos.getLabelColor())); | |
209 | 206 | serializer. endTag(Main.APP_NAMESPACE, "labelColor"); |
210 | 207 | |
211 | 208 | serializer.startTag(Main.APP_NAMESPACE, "objectColor"); |
212 | - serializer.text(Integer.toString(pos.objectColor)); | |
209 | + serializer.text(Integer.toString(pos.getObjectColor())); | |
213 | 210 | serializer. endTag(Main.APP_NAMESPACE, "objectColor"); |
214 | 211 | |
215 | 212 | serializer.startTag(Main.APP_NAMESPACE, "paintStyle"); |
216 | - serializer.text(pos.paintStyle); | |
213 | + serializer.text(pos.getPaintStyle()); | |
217 | 214 | serializer. endTag(Main.APP_NAMESPACE, "paintStyle"); |
218 | 215 | |
219 | 216 | serializer.startTag(Main.APP_NAMESPACE, "strokeWidth"); |
220 | - serializer.text(Float.toString(pos.strokeWidth)); | |
217 | + serializer.text(Float.toString(pos.getstrokeWidth())); | |
221 | 218 | serializer. endTag(Main.APP_NAMESPACE, "strokeWidth"); |
222 | 219 | |
223 | 220 | serializer.startTag(Main.APP_NAMESPACE, "fontSize"); |
224 | - serializer.text(Float.toString(pos.fontSize)); | |
221 | + serializer.text(Float.toString(pos.getFontSize())); | |
225 | 222 | serializer. endTag(Main.APP_NAMESPACE, "fontSize"); |
226 | 223 | |
227 | 224 | serializer.endTag(Main.APP_NAMESPACE, "object"); |
@@ -232,30 +229,30 @@ public class MeMoMaFileSavingEngine | ||
232 | 229 | while (lineKeys.hasMoreElements()) |
233 | 230 | { |
234 | 231 | Integer key = lineKeys.nextElement(); |
235 | - MeMoMaConnectLineHolder.ObjectConnector line = objectHolder.getConnectLineHolder().getLine(key); | |
232 | + ObjectConnector line = objectHolder.getConnectLineHolder().getLine(key); | |
236 | 233 | serializer.startTag(Main.APP_NAMESPACE, "line"); |
237 | 234 | serializer.attribute(Main.APP_NAMESPACE, "key", Integer.toString(key)); |
238 | 235 | |
239 | 236 | serializer.startTag(Main.APP_NAMESPACE, "fromObjectKey"); |
240 | - serializer.text(Integer.toString(line.fromObjectKey)); | |
237 | + serializer.text(Integer.toString(line.getFromObjectKey())); | |
241 | 238 | serializer.endTag(Main.APP_NAMESPACE, "fromObjectKey"); |
242 | 239 | |
243 | 240 | serializer.startTag(Main.APP_NAMESPACE, "toObjectKey"); |
244 | - serializer.text(Integer.toString(line.toObjectKey)); | |
241 | + serializer.text(Integer.toString(line.getToObjectKey())); | |
245 | 242 | serializer.endTag(Main.APP_NAMESPACE, "toObjectKey"); |
246 | 243 | |
247 | 244 | serializer.startTag(Main.APP_NAMESPACE, "lineStyle"); |
248 | - serializer.text(Integer.toString(line.lineStyle)); | |
245 | + serializer.text(Integer.toString(line.getLineStyle())); | |
249 | 246 | serializer.endTag(Main.APP_NAMESPACE, "lineStyle"); |
250 | 247 | |
251 | 248 | serializer.startTag(Main.APP_NAMESPACE, "lineShape"); |
252 | - serializer.text(Integer.toString(line.lineShape)); | |
249 | + serializer.text(Integer.toString(line.getLineShape())); | |
253 | 250 | serializer.endTag(Main.APP_NAMESPACE, "lineShape"); |
254 | 251 | |
255 | 252 | serializer.startTag(Main.APP_NAMESPACE, "lineThickness"); |
256 | - serializer.text(Integer.toString(line.lineThickness)); | |
253 | + serializer.text(Integer.toString(line.getLineThickness())); | |
257 | 254 | serializer.endTag(Main.APP_NAMESPACE, "lineThickness"); |
258 | -/** | |
255 | +/* | |
259 | 256 | serializer.startTag(Main.APP_NAMESPACE, "fromShape"); |
260 | 257 | serializer.text(Integer.toString(line.fromShape)); |
261 | 258 | serializer.endTag(Main.APP_NAMESPACE, "fromShape"); |
@@ -271,7 +268,7 @@ public class MeMoMaFileSavingEngine | ||
271 | 268 | serializer.startTag(Main.APP_NAMESPACE, "toString"); |
272 | 269 | serializer.text(line.toString); |
273 | 270 | serializer.endTag(Main.APP_NAMESPACE, "toString"); |
274 | -**/ | |
271 | +*/ | |
275 | 272 | serializer.endTag(Main.APP_NAMESPACE, "line"); |
276 | 273 | } |
277 | 274 |
@@ -292,8 +289,7 @@ public class MeMoMaFileSavingEngine | ||
292 | 289 | /** |
293 | 290 | * オブジェクトを保存する |
294 | 291 | * |
295 | - * @param objectHolder | |
296 | - * @return | |
292 | + * | |
297 | 293 | */ |
298 | 294 | public String saveObjects(MeMoMaObjectHolder objectHolder) |
299 | 295 | { |
@@ -312,8 +308,6 @@ public class MeMoMaFileSavingEngine | ||
312 | 308 | String fileName = fileUtility.getGokigenDirectory() + "/" + objectHolder.getDataTitle(); |
313 | 309 | |
314 | 310 | // データを保管する |
315 | - String result = storeToXmlFile(fileName, objectHolder); | |
316 | - | |
317 | - return (result); | |
311 | + return (storeToXmlFile(fileName, objectHolder)); | |
318 | 312 | } |
319 | 313 | } |
@@ -1,4 +1,4 @@ | ||
1 | -package jp.sourceforge.gokigen.memoma.fileio; | |
1 | +package jp.sourceforge.gokigen.memoma.io; | |
2 | 2 | |
3 | 3 | import android.app.ProgressDialog; |
4 | 4 | import android.content.Context; |
@@ -1,4 +1,4 @@ | ||
1 | -package jp.sourceforge.gokigen.memoma.fileio; | |
1 | +package jp.sourceforge.gokigen.memoma.io; | |
2 | 2 | |
3 | 3 | import java.io.File; |
4 | 4 | import java.io.FileOutputStream; |
@@ -14,6 +14,7 @@ import android.graphics.Bitmap; | ||
14 | 14 | import android.graphics.Bitmap.CompressFormat; |
15 | 15 | import android.graphics.Canvas; |
16 | 16 | import android.graphics.Rect; |
17 | +import android.graphics.RectF; | |
17 | 18 | import android.os.AsyncTask; |
18 | 19 | import android.util.Log; |
19 | 20 | import android.view.Display; |
@@ -22,6 +23,7 @@ import jp.sourceforge.gokigen.memoma.Main; | ||
22 | 23 | import jp.sourceforge.gokigen.memoma.R; |
23 | 24 | import jp.sourceforge.gokigen.memoma.drawers.MeMoMaCanvasDrawer; |
24 | 25 | import jp.sourceforge.gokigen.memoma.holders.MeMoMaObjectHolder; |
26 | +import jp.sourceforge.gokigen.memoma.holders.PositionObject; | |
25 | 27 | |
26 | 28 | /** |
27 | 29 | * データをファイルに保存するとき用 アクセスラッパ (非同期処理を実行) |
@@ -38,6 +40,7 @@ import jp.sourceforge.gokigen.memoma.holders.MeMoMaObjectHolder; | ||
38 | 40 | */ |
39 | 41 | public class ObjectLayoutCaptureExporter extends AsyncTask<String, Integer, String> |
40 | 42 | { |
43 | + private static final int OUTPUT_EXPORT_SHARE_ID = 1000; | |
41 | 44 | private static final int OUTPUT_MARGIN = 8; |
42 | 45 | private static final int OUTPUT_MARGIN_TOP = 50; |
43 | 46 |
@@ -146,22 +149,23 @@ public class ObjectLayoutCaptureExporter extends AsyncTask<String, Integer, Stri | ||
146 | 149 | while (keys.hasMoreElements()) |
147 | 150 | { |
148 | 151 | Integer key = keys.nextElement(); |
149 | - MeMoMaObjectHolder.PositionObject pos = objectHolder.getPosition(key); | |
150 | - if (canvasSize.left > pos.rect.left) | |
152 | + PositionObject pos = objectHolder.getPosition(key); | |
153 | + RectF posRect = pos.getRect(); | |
154 | + if (canvasSize.left > posRect.left) | |
151 | 155 | { |
152 | - canvasSize.left = (int) pos.rect.left; | |
156 | + canvasSize.left = (int) posRect.left; | |
153 | 157 | } |
154 | - if (canvasSize.right < pos.rect.right) | |
158 | + if (canvasSize.right < posRect.right) | |
155 | 159 | { |
156 | - canvasSize.right = (int) pos.rect.right; | |
160 | + canvasSize.right = (int) posRect.right; | |
157 | 161 | } |
158 | - if (canvasSize.top > pos.rect.top) | |
162 | + if (canvasSize.top > posRect.top) | |
159 | 163 | { |
160 | - canvasSize.top = (int) pos.rect.top; | |
164 | + canvasSize.top = (int) posRect.top; | |
161 | 165 | } |
162 | - if (canvasSize.bottom < pos.rect.bottom) | |
166 | + if (canvasSize.bottom < posRect.bottom) | |
163 | 167 | { |
164 | - canvasSize.bottom = (int) pos.rect.bottom; | |
168 | + canvasSize.bottom = (int) posRect.bottom; | |
165 | 169 | } |
166 | 170 | } |
167 | 171 |
@@ -258,7 +262,7 @@ public class ObjectLayoutCaptureExporter extends AsyncTask<String, Integer, Stri | ||
258 | 262 | { |
259 | 263 | if (receiver != null) |
260 | 264 | { |
261 | - receiver.onCaptureLayoutExportedResult(exportedFileName, result); | |
265 | + receiver.onCaptureLayoutExportedResult(exportedFileName, result, OUTPUT_EXPORT_SHARE_ID); | |
262 | 266 | } |
263 | 267 | } |
264 | 268 | catch (Exception ex) |
@@ -281,6 +285,6 @@ public class ObjectLayoutCaptureExporter extends AsyncTask<String, Integer, Stri | ||
281 | 285 | public interface ICaptureLayoutExporter |
282 | 286 | { |
283 | 287 | // 保存結果の報告 |
284 | - void onCaptureLayoutExportedResult(String exportedFileName, String detail); | |
288 | + void onCaptureLayoutExportedResult(String exportedFileName, String detail, int id); | |
285 | 289 | } |
286 | 290 | } |
@@ -1,4 +1,4 @@ | ||
1 | -package jp.sourceforge.gokigen.memoma; | |
1 | +package jp.sourceforge.gokigen.memoma.io; | |
2 | 2 | |
3 | 3 | import android.app.Activity; |
4 | 4 | import android.content.Intent; |
@@ -1,4 +1,4 @@ | ||
1 | -package jp.sourceforge.gokigen.memoma.fileio; | |
1 | +package jp.sourceforge.gokigen.memoma.io; | |
2 | 2 | |
3 | 3 | import java.io.File; |
4 | 4 | import java.io.FileOutputStream; |
@@ -5,12 +5,14 @@ import java.util.Enumeration; | ||
5 | 5 | |
6 | 6 | import android.app.ProgressDialog; |
7 | 7 | import android.content.Context; |
8 | +import android.graphics.RectF; | |
8 | 9 | import android.os.AsyncTask; |
9 | 10 | import android.util.Log; |
10 | 11 | |
11 | 12 | import jp.sourceforge.gokigen.memoma.Main; |
12 | 13 | import jp.sourceforge.gokigen.memoma.R; |
13 | 14 | import jp.sourceforge.gokigen.memoma.holders.MeMoMaObjectHolder; |
15 | +import jp.sourceforge.gokigen.memoma.holders.PositionObject; | |
14 | 16 | |
15 | 17 | /** |
16 | 18 | * オブジェクトの位置を整列するクラス (非同期処理を実行) |
@@ -25,8 +27,8 @@ import jp.sourceforge.gokigen.memoma.holders.MeMoMaObjectHolder; | ||
25 | 27 | */ |
26 | 28 | public class ObjectAligner extends AsyncTask<MeMoMaObjectHolder, Integer, String> |
27 | 29 | { |
28 | - ProgressDialog executingDialog = null; | |
29 | - IAlignCallback receiver = null; | |
30 | + private ProgressDialog executingDialog; | |
31 | + private IAlignCallback receiver; | |
30 | 32 | /** |
31 | 33 | * コンストラクタ |
32 | 34 | */ |
@@ -68,11 +70,11 @@ public class ObjectAligner extends AsyncTask<MeMoMaObjectHolder, Integer, String | ||
68 | 70 | while (keys.hasMoreElements()) |
69 | 71 | { |
70 | 72 | Integer key = keys.nextElement(); |
71 | - MeMoMaObjectHolder.PositionObject pos = objectHolder.getPosition(key); | |
72 | - | |
73 | - float newLeft = (float) Math.floor((pos.rect.left + 15.0f)/ 30.0) * 30.0f; | |
74 | - float newTop = (float) Math.floor((pos.rect.top + 15.0f)/ 30.0) * 30.0f; | |
75 | - pos.rect.offsetTo(newLeft, newTop); | |
73 | + PositionObject pos = objectHolder.getPosition(key); | |
74 | + RectF posRect = pos.getRect(); | |
75 | + float newLeft = (float) Math.floor((posRect.left + 15.0f)/ 30.0) * 30.0f; | |
76 | + float newTop = (float) Math.floor((posRect.top + 15.0f)/ 30.0) * 30.0f; | |
77 | + pos.setRectOffsetTo(newLeft, newTop); | |
76 | 78 | } |
77 | 79 | System.gc(); |
78 | 80 |
@@ -111,7 +113,6 @@ public class ObjectAligner extends AsyncTask<MeMoMaObjectHolder, Integer, String | ||
111 | 113 | |
112 | 114 | // プログレスダイアログを消す |
113 | 115 | executingDialog.dismiss(); |
114 | - return; | |
115 | 116 | } |
116 | 117 | |
117 | 118 | /** |
@@ -122,6 +123,6 @@ public class ObjectAligner extends AsyncTask<MeMoMaObjectHolder, Integer, String | ||
122 | 123 | */ |
123 | 124 | public interface IAlignCallback |
124 | 125 | { |
125 | - public abstract void objectAligned(); | |
126 | + void objectAligned(); | |
126 | 127 | } |
127 | 128 | } |
@@ -8,6 +8,7 @@ import android.content.SharedPreferences; | ||
8 | 8 | import android.graphics.Color; |
9 | 9 | import android.graphics.Paint; |
10 | 10 | import android.graphics.PorterDuff.Mode; |
11 | +import android.graphics.RectF; | |
11 | 12 | import android.graphics.drawable.BitmapDrawable; |
12 | 13 | import android.graphics.drawable.GradientDrawable; |
13 | 14 | import android.preference.PreferenceManager; |
@@ -26,6 +27,7 @@ import jp.sourceforge.gokigen.memoma.Main; | ||
26 | 27 | import jp.sourceforge.gokigen.memoma.R; |
27 | 28 | import jp.sourceforge.gokigen.memoma.drawers.MeMoMaCanvasDrawer; |
28 | 29 | import jp.sourceforge.gokigen.memoma.holders.MeMoMaObjectHolder; |
30 | +import jp.sourceforge.gokigen.memoma.holders.PositionObject; | |
29 | 31 | |
30 | 32 | /** |
31 | 33 | * オブジェクトのデータを入力するダイアログを表示する |
@@ -35,9 +37,9 @@ import jp.sourceforge.gokigen.memoma.holders.MeMoMaObjectHolder; | ||
35 | 37 | */ |
36 | 38 | public class ObjectDataInputDialog implements SeekBar.OnSeekBarChangeListener, CompoundButton.OnCheckedChangeListener, ImageButton.OnClickListener |
37 | 39 | { |
38 | - private final float FONTSIZE_SMALL = 4.0f; | |
39 | - private final float FONTSIZE_MIDDLE = 6.0f; | |
40 | - private final float FONTSIZE_LARGE = 10.0f; | |
40 | + private final float FONTSIZE_SMALL = 5.0f; | |
41 | + private final float FONTSIZE_MIDDLE = 8.0f; | |
42 | + private final float FONTSIZE_LARGE = 12.0f; | |
41 | 43 | |
42 | 44 | private Context context = null; |
43 | 45 | private IResultReceiver resultReceiver = null; |
@@ -66,7 +68,7 @@ public class ObjectDataInputDialog implements SeekBar.OnSeekBarChangeListener, C | ||
66 | 68 | |
67 | 69 | /** |
68 | 70 | * 確認ダイアログを応答する |
69 | - * @return | |
71 | + * | |
70 | 72 | */ |
71 | 73 | public Dialog getDialog() |
72 | 74 | { |
@@ -90,7 +92,7 @@ public class ObjectDataInputDialog implements SeekBar.OnSeekBarChangeListener, C | ||
90 | 92 | backgroundColor = MeMoMaCanvasDrawer.BACKGROUND_COLOR_DEFAULT; |
91 | 93 | } |
92 | 94 | |
93 | - final TextView colorLabel = (TextView) layout.findViewById(R.id.setBorderColorLabel); | |
95 | + final TextView colorLabel = layout.findViewById(R.id.setBorderColorLabel); | |
94 | 96 | backgroundShape = (GradientDrawable)colorLabel.getBackground(); |
95 | 97 | |
96 | 98 | // 入力文字列の色を設定する |
@@ -100,59 +102,58 @@ public class ObjectDataInputDialog implements SeekBar.OnSeekBarChangeListener, C | ||
100 | 102 | final EditText detail = (EditText) layout.findViewById(R.id.descriptionInputArea); |
101 | 103 | //detail.setTextColor(Color.LTGRAY); |
102 | 104 | |
103 | - borderColorView = (SeekBar) layout.findViewById(R.id.borderColorSelectionBar); | |
105 | + borderColorView = layout.findViewById(R.id.borderColorSelectionBar); | |
104 | 106 | borderColorView.setOnSeekBarChangeListener(this); |
105 | 107 | |
106 | - final CheckBox userCheckbox = (CheckBox) layout.findViewById(R.id.checkUserCheckbox); | |
107 | - final CheckBox boldText = (CheckBox) layout.findViewById(R.id.checkBoldText); | |
108 | - fillObjectView = (CheckBox) layout.findViewById(R.id.checkFillObject); | |
108 | + final CheckBox userCheckbox = layout.findViewById(R.id.checkUserCheckbox); | |
109 | + final CheckBox boldText = layout.findViewById(R.id.checkBoldText); | |
110 | + fillObjectView = layout.findViewById(R.id.checkFillObject); | |
109 | 111 | fillObjectView.setOnCheckedChangeListener(this); |
110 | 112 | |
111 | - colorBorderAreaView = (TextView) layout.findViewById(R.id.borderColorArea); | |
113 | + colorBorderAreaView = layout.findViewById(R.id.borderColorArea); | |
112 | 114 | colorBorderAreaView.setOnClickListener(this); |
113 | 115 | |
114 | - final ImageButton rect = (ImageButton) layout.findViewById(R.id.btnObjectRectangle); | |
116 | + final ImageButton rect = layout.findViewById(R.id.btnObjectRectangle); | |
115 | 117 | rect.setOnClickListener(this); |
116 | - final ImageButton roundRect = (ImageButton) layout.findViewById(R.id.btnObjectRoundRect); | |
118 | + final ImageButton roundRect = layout.findViewById(R.id.btnObjectRoundRect); | |
117 | 119 | roundRect.setOnClickListener(this); |
118 | - final ImageButton oval = (ImageButton) layout.findViewById(R.id.btnObjectOval); | |
120 | + final ImageButton oval = layout.findViewById(R.id.btnObjectOval); | |
119 | 121 | oval.setOnClickListener(this); |
120 | - final ImageButton diamond = (ImageButton) layout.findViewById(R.id.btnObjectDiamond); | |
122 | + final ImageButton diamond = layout.findViewById(R.id.btnObjectDiamond); | |
121 | 123 | diamond.setOnClickListener(this); |
122 | - final ImageButton hexagonal = (ImageButton) layout.findViewById(R.id.btnObjectHexagonal); | |
124 | + final ImageButton hexagonal = layout.findViewById(R.id.btnObjectHexagonal); | |
123 | 125 | hexagonal.setOnClickListener(this); |
124 | - final ImageButton parallelogram = (ImageButton) layout.findViewById(R.id.btnObjectParallelogram); | |
126 | + final ImageButton parallelogram = layout.findViewById(R.id.btnObjectParallelogram); | |
125 | 127 | parallelogram.setOnClickListener(this); |
126 | - final ImageButton keyboard = (ImageButton) layout.findViewById(R.id.btnObjectKeyboard); | |
128 | + final ImageButton keyboard = layout.findViewById(R.id.btnObjectKeyboard); | |
127 | 129 | keyboard.setOnClickListener(this); |
128 | - final ImageButton paper = (ImageButton) layout.findViewById(R.id.btnObjectPaper); | |
130 | + final ImageButton paper = layout.findViewById(R.id.btnObjectPaper); | |
129 | 131 | paper.setOnClickListener(this); |
130 | - final ImageButton drum = (ImageButton) layout.findViewById(R.id.btnObjectDrum); | |
132 | + final ImageButton drum = layout.findViewById(R.id.btnObjectDrum); | |
131 | 133 | drum.setOnClickListener(this); |
132 | - final ImageButton circle = (ImageButton) layout.findViewById(R.id.btnObjectCircle); | |
134 | + final ImageButton circle = layout.findViewById(R.id.btnObjectCircle); | |
133 | 135 | circle.setOnClickListener(this); |
134 | - final ImageButton noregion = (ImageButton) layout.findViewById(R.id.btnObjectNoRegion); | |
136 | + final ImageButton noregion = layout.findViewById(R.id.btnObjectNoRegion); | |
135 | 137 | noregion.setOnClickListener(this); |
136 | - | |
137 | - final ImageButton loopStart = (ImageButton) layout.findViewById(R.id.btnObjectLoopStart); | |
138 | + final ImageButton loopStart = layout.findViewById(R.id.btnObjectLoopStart); | |
138 | 139 | loopStart.setOnClickListener(this); |
139 | - final ImageButton loopEnd = (ImageButton) layout.findViewById(R.id.btnObjectLoopEnd); | |
140 | + final ImageButton loopEnd = layout.findViewById(R.id.btnObjectLoopEnd); | |
140 | 141 | loopEnd.setOnClickListener(this); |
141 | - final ImageButton leftArrow = (ImageButton) layout.findViewById(R.id.btnObjectLeftArrow); | |
142 | + final ImageButton leftArrow = layout.findViewById(R.id.btnObjectLeftArrow); | |
142 | 143 | leftArrow.setOnClickListener(this); |
143 | - final ImageButton downArrow = (ImageButton) layout.findViewById(R.id.btnObjectDownArrow); | |
144 | + final ImageButton downArrow = layout.findViewById(R.id.btnObjectDownArrow); | |
144 | 145 | downArrow.setOnClickListener(this); |
145 | - final ImageButton upArrow = (ImageButton) layout.findViewById(R.id.btnObjectUpArrow); | |
146 | + final ImageButton upArrow = layout.findViewById(R.id.btnObjectUpArrow); | |
146 | 147 | upArrow.setOnClickListener(this); |
147 | - final ImageButton rightArrow = (ImageButton) layout.findViewById(R.id.btnObjectRightArrow); | |
148 | + final ImageButton rightArrow = layout.findViewById(R.id.btnObjectRightArrow); | |
148 | 149 | rightArrow.setOnClickListener(this); |
149 | 150 | |
150 | 151 | // 背景の色を調整(塗りつぶしの時はオブジェクトの色とする。) |
151 | 152 | int color = convertColor(borderColorView.getProgress()); |
152 | - colorBorderAreaView.setBackgroundColor((fillObjectView.isChecked() == true) ? color : backgroundColor); | |
153 | + colorBorderAreaView.setBackgroundColor((fillObjectView.isChecked()) ? color : backgroundColor); | |
153 | 154 | //backgroundShape.setStroke(2, color); |
154 | 155 | |
155 | - if (fillObjectView.isChecked() == true) | |
156 | + if (fillObjectView.isChecked()) | |
156 | 157 | { |
157 | 158 | // 塗りつぶし時は文字の色を変える。 |
158 | 159 | color = (color ^ 0x00ffffff); |
@@ -162,29 +163,29 @@ public class ObjectDataInputDialog implements SeekBar.OnSeekBarChangeListener, C | ||
162 | 163 | |
163 | 164 | builder.setView(layout); |
164 | 165 | builder.setCancelable(false); |
166 | + | |
165 | 167 | builder.setPositiveButton(context.getString(R.string.confirmYes), new DialogInterface.OnClickListener() |
166 | 168 | { |
167 | 169 | public void onClick(DialogInterface dialog, int id) |
168 | 170 | { |
169 | - boolean ret = false; | |
170 | - boolean isUserCheck = false; | |
171 | - if (userCheckbox != null) | |
172 | - { | |
173 | - isUserCheck = userCheckbox.isChecked(); | |
174 | - } | |
175 | - setObjectData(label.getText().toString(), detail.getText().toString(), borderColorView.getProgress(), boldText.isChecked(), fillObjectView.isChecked(), isUserCheck, currentObjectDrawStyle); | |
176 | - if (resultReceiver != null) | |
177 | - { | |
178 | - resultReceiver.finishObjectInput(); | |
179 | - } | |
180 | - if (ret == true) | |
171 | + try | |
181 | 172 | { |
182 | - dialog.dismiss(); | |
173 | + boolean isUserCheck = false; | |
174 | + if (userCheckbox != null) | |
175 | + { | |
176 | + isUserCheck = userCheckbox.isChecked(); | |
177 | + } | |
178 | + setObjectData(label.getText().toString(), detail.getText().toString(), borderColorView.getProgress(), boldText.isChecked(), fillObjectView.isChecked(), isUserCheck, currentObjectDrawStyle); | |
179 | + if (resultReceiver != null) | |
180 | + { | |
181 | + resultReceiver.finishObjectInput(); | |
182 | + } | |
183 | 183 | } |
184 | - else | |
184 | + catch (Exception e) | |
185 | 185 | { |
186 | - dialog.cancel(); | |
186 | + e.printStackTrace(); | |
187 | 187 | } |
188 | + dialog.dismiss(); | |
188 | 189 | System.gc(); |
189 | 190 | } |
190 | 191 | }); |
@@ -192,19 +193,18 @@ public class ObjectDataInputDialog implements SeekBar.OnSeekBarChangeListener, C | ||
192 | 193 | { |
193 | 194 | public void onClick(DialogInterface dialog, int id) |
194 | 195 | { |
195 | - boolean ret = false; | |
196 | - if (resultReceiver != null) | |
197 | - { | |
198 | - resultReceiver.cancelObjectInput(); | |
199 | - } | |
200 | - if (ret == true) | |
196 | + try | |
201 | 197 | { |
202 | - dialog.dismiss(); | |
198 | + if (resultReceiver != null) | |
199 | + { | |
200 | + resultReceiver.cancelObjectInput(); | |
201 | + } | |
203 | 202 | } |
204 | - else | |
203 | + catch (Exception e) | |
205 | 204 | { |
206 | - dialog.cancel(); | |
205 | + e.printStackTrace(); | |
207 | 206 | } |
207 | + dialog.cancel(); | |
208 | 208 | System.gc(); |
209 | 209 | } |
210 | 210 | }); |
@@ -217,36 +217,36 @@ public class ObjectDataInputDialog implements SeekBar.OnSeekBarChangeListener, C | ||
217 | 217 | */ |
218 | 218 | public void prepareObjectInputDialog(Dialog dialog, Integer objectKey) |
219 | 219 | { |
220 | - MeMoMaObjectHolder.PositionObject position = objectHolder.getPosition(objectKey); | |
220 | + PositionObject position = objectHolder.getPosition(objectKey); | |
221 | 221 | key = objectKey; |
222 | 222 | if (position != null) |
223 | 223 | { |
224 | 224 | // 色を設定する |
225 | - final SeekBar borderColorProgess = (SeekBar) dialog.findViewById(R.id.borderColorSelectionBar); | |
226 | - borderColorProgess.setProgress(convertProgress(position.objectColor)); | |
225 | + final SeekBar borderColorProgess = dialog.findViewById(R.id.borderColorSelectionBar); | |
226 | + borderColorProgess.setProgress(convertProgress(position.getObjectColor())); | |
227 | 227 | |
228 | - final CheckBox boldTextCheck = (CheckBox) dialog.findViewById(R.id.checkBoldText); | |
229 | - boldTextCheck.setChecked(position.strokeWidth == MeMoMaObjectHolder.STOROKE_BOLD_WIDTH); | |
228 | + final CheckBox boldTextCheck = dialog.findViewById(R.id.checkBoldText); | |
229 | + boldTextCheck.setChecked(position.getstrokeWidth() == MeMoMaObjectHolder.STOROKE_BOLD_WIDTH); | |
230 | 230 | |
231 | - final CheckBox fillObjectCheck = (CheckBox) dialog.findViewById(R.id.checkFillObject); | |
232 | - fillObjectCheck.setChecked(Paint.Style.valueOf(position.paintStyle) != Paint.Style.STROKE); | |
231 | + final CheckBox fillObjectCheck = dialog.findViewById(R.id.checkFillObject); | |
232 | + fillObjectCheck.setChecked(Paint.Style.valueOf(position.getPaintStyle()) != Paint.Style.STROKE); | |
233 | 233 | |
234 | 234 | // フォントサイズを設定する |
235 | - textFontSize = position.fontSize / 2.0f; | |
235 | + textFontSize = position.getFontSize() / 2.0f; | |
236 | 236 | |
237 | 237 | // 入力文字列を設定する |
238 | - final EditText targetLabel = (EditText) dialog.findViewById(R.id.labelInputArea); | |
239 | - targetLabel.setText(position.label); | |
238 | + final EditText targetLabel = dialog.findViewById(R.id.labelInputArea); | |
239 | + targetLabel.setText(position.getLabel()); | |
240 | 240 | |
241 | - final EditText targetDetail = (EditText) dialog.findViewById(R.id.descriptionInputArea); | |
242 | - targetDetail.setText(position.detail); | |
241 | + final EditText targetDetail = dialog.findViewById(R.id.descriptionInputArea); | |
242 | + targetDetail.setText(position.getDetail()); | |
243 | 243 | |
244 | 244 | // 設定に記録されているデータを画面に反映させる |
245 | 245 | SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); |
246 | 246 | String userCheckboxTitle = preferences.getString("userCheckboxString", ""); |
247 | 247 | |
248 | 248 | // 描画スタイルを設定する |
249 | - currentObjectDrawStyle = position.drawStyle; | |
249 | + currentObjectDrawStyle = position.getDrawStyle(); | |
250 | 250 | updateObjectDrawStyleImageButton(currentObjectDrawStyle); |
251 | 251 | |
252 | 252 | // 背景色を設定する |
@@ -261,10 +261,10 @@ public class ObjectDataInputDialog implements SeekBar.OnSeekBarChangeListener, C | ||
261 | 261 | } |
262 | 262 | setTextColorSample(borderColorProgess.getProgress(), textFontSize, fillObjectView.isChecked()); |
263 | 263 | |
264 | - final CheckBox userCheckbox = (CheckBox) dialog.findViewById(R.id.checkUserCheckbox); | |
264 | + final CheckBox userCheckbox = dialog.findViewById(R.id.checkUserCheckbox); | |
265 | 265 | userCheckbox.setEnabled(true); |
266 | 266 | userCheckbox.setText(userCheckboxTitle); |
267 | - userCheckbox.setChecked(position.userChecked); | |
267 | + userCheckbox.setChecked(position.getUserChecked()); | |
268 | 268 | } |
269 | 269 | } |
270 | 270 |
@@ -272,23 +272,24 @@ public class ObjectDataInputDialog implements SeekBar.OnSeekBarChangeListener, C | ||
272 | 272 | * オブジェクトにデータを設定する |
273 | 273 | * |
274 | 274 | */ |
275 | - public void setObjectData(String label, String detail, int progress, boolean boldText, boolean fillObject, boolean userCheck, int drawStyle) | |
275 | + private void setObjectData(String label, String detail, int progress, boolean boldText, boolean fillObject, boolean userCheck, int drawStyle) | |
276 | 276 | { |
277 | - MeMoMaObjectHolder.PositionObject positionObject = objectHolder.getPosition(key); | |
277 | + PositionObject positionObject = objectHolder.getPosition(key); | |
278 | 278 | if (positionObject != null) |
279 | 279 | { |
280 | - positionObject.label = label; | |
281 | - positionObject.detail = detail; | |
280 | + positionObject.setLabel(label); | |
281 | + positionObject.setDetail(detail); | |
282 | 282 | int color = convertColor(progress); |
283 | - positionObject.objectColor = color; | |
283 | + positionObject.setObjectColor(color); | |
284 | 284 | color = (color ^ 0x00ffffff); |
285 | - positionObject.fontSize = textFontSize * 2.0f; | |
286 | - positionObject.labelColor = color; | |
287 | - positionObject.strokeWidth = (boldText == true) ? MeMoMaObjectHolder.STOROKE_BOLD_WIDTH : MeMoMaObjectHolder.STOROKE_NORMAL_WIDTH; | |
288 | - positionObject.paintStyle = ((fillObject == true) ? Paint.Style.FILL : Paint.Style.STROKE).toString(); | |
289 | - positionObject.userChecked = userCheck; | |
290 | - | |
291 | - if (positionObject.drawStyle != drawStyle) | |
285 | + positionObject.setFontSize(textFontSize * 2.0f); | |
286 | + positionObject.setLabelColor(color); | |
287 | + positionObject.setStrokeWidth((boldText) ? MeMoMaObjectHolder.STOROKE_BOLD_WIDTH : MeMoMaObjectHolder.STOROKE_NORMAL_WIDTH); | |
288 | + positionObject.setPaintStyle(((fillObject) ? Paint.Style.FILL : Paint.Style.STROKE).toString()); | |
289 | + positionObject.setUserChecked(userCheck); | |
290 | + | |
291 | + int posDrawStyle = positionObject.getDrawStyle(); | |
292 | + if (posDrawStyle != drawStyle) | |
292 | 293 | { |
293 | 294 | if ((drawStyle == MeMoMaObjectHolder.DRAWSTYLE_CIRCLE)|| |
294 | 295 | (drawStyle == MeMoMaObjectHolder. DRAWSTYLE_LEFT_ARROW)|| |
@@ -299,53 +300,54 @@ public class ObjectDataInputDialog implements SeekBar.OnSeekBarChangeListener, C | ||
299 | 300 | // (長方形の形状から)正方形の形状にする場合... |
300 | 301 | setRectToSquare(positionObject); |
301 | 302 | } |
302 | - else if ((positionObject.drawStyle == MeMoMaObjectHolder.DRAWSTYLE_CIRCLE)|| | |
303 | - (positionObject.drawStyle == MeMoMaObjectHolder. DRAWSTYLE_LEFT_ARROW)|| | |
304 | - (positionObject.drawStyle == MeMoMaObjectHolder. DRAWSTYLE_DOWN_ARROW)|| | |
305 | - (positionObject.drawStyle == MeMoMaObjectHolder. DRAWSTYLE_UP_ARROW)|| | |
306 | - (positionObject.drawStyle == MeMoMaObjectHolder. DRAWSTYLE_RIGHT_ARROW)) | |
303 | + else if ((posDrawStyle == MeMoMaObjectHolder.DRAWSTYLE_CIRCLE)|| | |
304 | + (posDrawStyle == MeMoMaObjectHolder. DRAWSTYLE_LEFT_ARROW)|| | |
305 | + (posDrawStyle == MeMoMaObjectHolder. DRAWSTYLE_DOWN_ARROW)|| | |
306 | + (posDrawStyle == MeMoMaObjectHolder. DRAWSTYLE_UP_ARROW)|| | |
307 | + (posDrawStyle == MeMoMaObjectHolder. DRAWSTYLE_RIGHT_ARROW)) | |
307 | 308 | { |
308 | 309 | // 正方形の形状から、長方形の形状にする場合... |
309 | 310 | setRectFromSquare(positionObject); |
310 | 311 | } |
311 | - positionObject.drawStyle = drawStyle; | |
312 | + positionObject.setDrawStyle(drawStyle); | |
312 | 313 | } |
313 | 314 | } |
314 | - positionObject = null; | |
315 | 315 | } |
316 | 316 | |
317 | 317 | /** |
318 | 318 | * オブジェクトの領域を長方形から正方形にする |
319 | 319 | */ |
320 | - private void setRectToSquare(MeMoMaObjectHolder.PositionObject positionObject) | |
320 | + private void setRectToSquare(PositionObject positionObject) | |
321 | 321 | { |
322 | - float bandWidth = ((positionObject.rect.right - positionObject.rect.left)) / 2.0f; | |
323 | - float center = positionObject.rect.centerY(); | |
324 | - | |
325 | - positionObject.rect.top = center - bandWidth; | |
326 | - positionObject.rect.bottom = center + bandWidth; | |
322 | + RectF posRect = positionObject.getRect(); | |
323 | + float bandWidth = ((posRect.right - posRect.left)) / 2.0f; | |
324 | + float center = posRect.centerY(); | |
325 | + | |
326 | + positionObject.setRectTop(center - bandWidth); | |
327 | + positionObject.setRectBottom(center + bandWidth); | |
327 | 328 | } |
328 | 329 | |
329 | 330 | /** |
330 | 331 | * オブジェクトの領域を正方形から長方形にする |
331 | 332 | */ |
332 | - private void setRectFromSquare(MeMoMaObjectHolder.PositionObject positionObject) | |
333 | + private void setRectFromSquare(PositionObject positionObject) | |
333 | 334 | { |
334 | - float bandWidth = ((positionObject.rect.right - positionObject.rect.left) / 16.0f * 9.0f) / 2.0f; | |
335 | - float center = positionObject.rect.centerY(); | |
336 | - | |
337 | - positionObject.rect.top = center - bandWidth; | |
338 | - positionObject.rect.bottom = center + bandWidth; | |
335 | + RectF posRect = positionObject.getRect(); | |
336 | + float bandWidth = ((posRect.right - posRect.left) / 16.0f * 9.0f) / 2.0f; | |
337 | + float center = posRect.centerY(); | |
338 | + | |
339 | + positionObject.setRectTop(center - bandWidth); | |
340 | + positionObject.setRectBottom(center + bandWidth); | |
339 | 341 | } |
340 | 342 | |
341 | 343 | private void setButtonBorder(int id, boolean isHighlight) |
342 | 344 | { |
343 | 345 | try |
344 | 346 | { |
345 | - ImageButton button = (ImageButton) dialogLayout.findViewById(id); | |
347 | + ImageButton button = dialogLayout.findViewById(id); | |
346 | 348 | //GradientDrawable btnBackgroundShape = (GradientDrawable)button.getBackground(); |
347 | 349 | BitmapDrawable btnBackgroundShape = (BitmapDrawable)button.getBackground(); |
348 | - if (isHighlight == true) | |
350 | + if (isHighlight) | |
349 | 351 | { |
350 | 352 | // btnBackgroundShape.setColorFilter(Color.rgb(51, 181, 229), Mode.LIGHTEN); |
351 | 353 | btnBackgroundShape.setColorFilter(Color.BLUE, Mode.LIGHTEN); |
@@ -366,7 +368,7 @@ public class ObjectDataInputDialog implements SeekBar.OnSeekBarChangeListener, C | ||
366 | 368 | /** |
367 | 369 | * イメージボタンの選択状態を更新する |
368 | 370 | * |
369 | - * @param drawStyle | |
371 | + * | |
370 | 372 | */ |
371 | 373 | private void updateObjectDrawStyleImageButton(int drawStyle) |
372 | 374 | { |
@@ -476,12 +478,11 @@ public class ObjectDataInputDialog implements SeekBar.OnSeekBarChangeListener, C | ||
476 | 478 | /** |
477 | 479 | * 0x00~0x3fの値(R, G, B, それぞれ2ビット)で色を変える |
478 | 480 | * |
479 | - * @param value | |
480 | - * @return | |
481 | + * | |
481 | 482 | */ |
482 | 483 | private int convertColor(int value) |
483 | 484 | { |
484 | - int color = 0; | |
485 | + int color; | |
485 | 486 | int r = ((value >> 4 ) & 0x03) * 85; |
486 | 487 | int g = ((value >> 2) & 0x03) * 85; |
487 | 488 | int b = (value & 0x03) * 85; |
@@ -493,8 +494,7 @@ public class ObjectDataInputDialog implements SeekBar.OnSeekBarChangeListener, C | ||
493 | 494 | /** |
494 | 495 | * 色をプログレスバーの値に変換する |
495 | 496 | * |
496 | - * @param color | |
497 | - * @return | |
497 | + * | |
498 | 498 | */ |
499 | 499 | private int convertProgress(int color) |
500 | 500 | { |
@@ -508,21 +508,19 @@ public class ObjectDataInputDialog implements SeekBar.OnSeekBarChangeListener, C | ||
508 | 508 | /** |
509 | 509 | * 背景色を設定する処理 |
510 | 510 | * |
511 | - * @param progress | |
512 | - * @param fontSize | |
513 | - * @param value | |
511 | + * | |
514 | 512 | */ |
515 | 513 | private void setTextColorSample(int progress, float fontSize, boolean value) |
516 | 514 | { |
517 | 515 | if (colorBorderAreaView != null) |
518 | 516 | { |
519 | 517 | int color = convertColor(progress); |
520 | - int backColor = (value == true) ? color : backgroundColor; | |
518 | + int backColor = (value) ? color : backgroundColor; | |
521 | 519 | colorBorderAreaView.setBackgroundColor(backColor); |
522 | 520 | |
523 | 521 | backgroundShape.setStroke(2, color); |
524 | 522 | |
525 | - if (value == true) | |
523 | + if (value) | |
526 | 524 | { |
527 | 525 | // 塗りつぶし時には色を変える |
528 | 526 | color = (color ^ 0x00ffffff); |
@@ -572,7 +570,7 @@ public class ObjectDataInputDialog implements SeekBar.OnSeekBarChangeListener, C | ||
572 | 570 | |
573 | 571 | public interface IResultReceiver |
574 | 572 | { |
575 | - public abstract void finishObjectInput(); | |
576 | - public abstract void cancelObjectInput(); | |
573 | + void finishObjectInput(); | |
574 | + void cancelObjectInput(); | |
577 | 575 | } |
578 | 576 | } |
@@ -54,7 +54,7 @@ | ||
54 | 54 | </ListView> |
55 | 55 | |
56 | 56 | <!-- |
57 | -<jp.sourceforge.gokigen.memoma.GokigenSurfaceView | |
57 | +<jp.sourceforge.gokigen.memoma.drawers.GokigenSurfaceView | |
58 | 58 | android:id="@+id/ExtensionView" |
59 | 59 | android:layout_width="fill_parent" |
60 | 60 | android:layout_height="wrap_content" |
@@ -179,7 +179,7 @@ | ||
179 | 179 | android:max="100" |
180 | 180 | android:progress="50" /> |
181 | 181 | |
182 | - <jp.sourceforge.gokigen.memoma.GokigenSurfaceView | |
182 | + <jp.sourceforge.gokigen.memoma.drawers.GokigenSurfaceView | |
183 | 183 | android:id="@+id/GraphicView" |
184 | 184 | android:layout_width="fill_parent" |
185 | 185 | android:layout_height="wrap_content" |
@@ -71,4 +71,5 @@ | ||
71 | 71 | <string name="labelLineThickness">太さ</string> |
72 | 72 | <string name="labelLineShapeSelection">形状</string> |
73 | 73 | <string name="Title_SelectLineShape">接続線の設定</string> |
74 | + <string name="undo_operation">1つ戻す</string> | |
74 | 75 | </resources> |
@@ -71,4 +71,5 @@ | ||
71 | 71 | <string name="labelLineThickness">Line Thickness</string> |
72 | 72 | <string name="labelLineShapeSelection">Line Shape</string> |
73 | 73 | <string name="Title_SelectLineShape">Select a line style</string> |
74 | + <string name="undo_operation">Undo</string> | |
74 | 75 | </resources> |