public void startNewSection(float x, float y) { mCurrent = new StrokeData(); fillStrokeParameters(mCurrent); mCurrent.mPath = new Path(); mCurrent.mPath.moveTo(x, y); mCurrent.mPoints[0] = x; mCurrent.mPoints[1] = y; mCurrent.noPoints = 1; }
@Override public void deSerializeRepresentation(JsonReader sreader) throws IOException { sreader.beginObject(); Vector<StrokeData> strokes = new Vector<StrokeData>(); while (sreader.hasNext()) { sreader.nextName(); sreader.beginObject(); StrokeData stroke = new StrokeData(); while (sreader.hasNext()) { String name = sreader.nextName(); if (name.equals(SERIAL_COLOR)) { stroke.mColor = sreader.nextInt(); } else if (name.equals(SERIAL_RADIUS)) { stroke.mRadius = (float) sreader.nextDouble(); } else if (name.equals(SERIAL_TYPE)) { stroke.mType = (byte) sreader.nextInt(); } else if (name.equals(SERIAL_POINTS_COUNT)) { stroke.noPoints = sreader.nextInt(); } else if (name.equals(SERIAL_POINTS)) { int count = 0; sreader.beginArray(); while (sreader.hasNext()) { if ((count + 1) > stroke.mPoints.length) { stroke.mPoints = Arrays.copyOf(stroke.mPoints, count * 2); } stroke.mPoints[count++] = (float) sreader.nextDouble(); } stroke.mPath = new Path(); stroke.mPath.moveTo(stroke.mPoints[0], stroke.mPoints[1]); for (int i = 0; i < count; i += 2) { stroke.mPath.lineTo(stroke.mPoints[i], stroke.mPoints[i + 1]); } sreader.endArray(); strokes.add(stroke); } else { sreader.skipValue(); } } sreader.endObject(); } mDrawing = strokes; sreader.endObject(); }