public void ReDoORUndo(boolean flag) { if (!IsShowing) { ReDoOrUnDoFlag = true; try { if (flag) { Log.e("redo", ""); ReDoNodes.add(pathNode.getTheLastNote()); pathNode.deleteTheLastNote(); preview(pathNode.getPathList()); invalidate(); // ReDoOrUnDoFlag = true; // if(!isShowing()) // preview(pathNode.getPathList()); } else { Log.e("undo", ""); pathNode.addNode(ReDoNodes.get(ReDoNodes.size() - 1)); ReDoNodes.remove(ReDoNodes.size() - 1); preview(pathNode.getPathList()); // ReDoOrUnDoFlag = true; // if(!isShowing()) // preview(pathNode.getPathList()); } } catch (ArrayIndexOutOfBoundsException e) { e.printStackTrace(); showCustomToast("无法操作=-="); } } }
/** * @author [email protected] * @param file Pictures' file */ public void BitmapToPicture(File file) { FileOutputStream fileOutputStream; try { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss"); Date now = new Date(); File tempfile = new File(file + "/" + formatter.format(now) + ".jpg"); fileOutputStream = new FileOutputStream(tempfile); Bitmap mBitmapbg = BitmapFactory.decodeResource(context.getResources(), mBitmapBackGround) .copy(Bitmap.Config.ARGB_8888, false); mBitmapbg = Bitmap.createScaledBitmap(mBitmapbg, width, height, false); if (mBitmapInit != null) { mBitmapbg = toConformBitmap(mBitmapbg, mBitmapInit); mBitmapbg = toConformBitmap(mBitmapbg, mBitmap); } else { mBitmapbg = toConformBitmap(mBitmapbg, mBitmap); } mBitmapbg.compress(Bitmap.CompressFormat.JPEG, 100, fileOutputStream); showCustomToast(tempfile.getName() + "已保存"); } catch (FileNotFoundException e) { e.printStackTrace(); } }
public void PathNodeToJson(PathNode pathNode, File file) { ArrayList<PathNode.Node> arrayList = pathNode.getPathList(); String json = "["; for (int i = 0; i < arrayList.size(); i++) { PathNode.Node node = arrayList.get(i); json += "{" + "\"" + "x" + "\"" + ":" + node.x + "," + "\"" + "y" + "\"" + ":" + node.y + "," + "\"" + "PenColor" + "\"" + ":" + node.PenColor + "," + "\"" + "PenWidth" + "\"" + ":" + node.PenWidth + "," + "\"" + "EraserWidth" + "\"" + ":" + node.EraserWidth + "," + "\"" + "TouchEvent" + "\"" + ":" + node.TouchEvent + "," + "\"" + "IsPaint" + "\"" + ":" + "\"" + node.IsPaint + "\"" + "," + "\"" + "time" + "\"" + ":" + node.time + "},"; } json = json.substring(0, json.length() - 1); json += "]"; try { json = enCrypto(json, "*****@*****.**"); } catch (InvalidKeySpecException | InvalidKeyException | IllegalBlockSizeException | BadPaddingException | NoSuchPaddingException e) { e.printStackTrace(); } SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss"); Date now = new Date(); File tempfile = new File(file + "/" + formatter.format(now) + ".lfk"); try { FileOutputStream fileOutputStream = new FileOutputStream(tempfile); byte[] bytes = json.getBytes(); fileOutputStream.write(bytes); fileOutputStream.close(); showCustomToast(tempfile.getName() + "已保存"); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
public void Paint() { showCustomToast("切换为铅笔"); IsPaint = true; Init_Paint(UserInfo.PaintColor, UserInfo.PaintWidth); }
// switch eraser/paint public void Eraser() { showCustomToast("切换为橡皮"); IsPaint = false; Init_Eraser(UserInfo.EraserWidth); }
public void setmEraserPaint(int width) { showCustomToast("设定橡皮粗为:" + width); mEraserPaint.setStrokeWidth(width); }
public void setPenWidth(int width) { showCustomToast("设定笔粗为:" + width); mPaint.setStrokeWidth(width); }
public void setColor(int color) { showCustomToast("已选择颜色" + colorToHexString(color)); mPaint.setColor(color); }