private char consumeCommand() throws ParseException { advanceToNextToken(); if (mCurrentToken != TOKEN_RELATIVE_COMMAND && mCurrentToken != TOKEN_ABSOLUTE_COMMAND) { throw new ParseException("Expected command", mIndex); } return mPathString.charAt(mIndex++); }
private void consumeAndTransformPoint(PointF out, boolean relative) throws ParseException { out.x = transformX(consumeValue()); out.y = transformY(consumeValue()); if (relative) { out.x += mCurrentPoint.x; out.y += mCurrentPoint.y; } }
char command = consumeCommand(); boolean relative = (mCurrentToken == TOKEN_RELATIVE_COMMAND); switch (command) { while (advanceToNextToken() == TOKEN_VALUE) { consumeAndTransformPoint(tempPoint1, relative && mCurrentPoint.x != Float.NaN); if (firstPoint) { p.moveTo(tempPoint1.x, tempPoint1.y); while (advanceToNextToken() == TOKEN_VALUE) { consumeAndTransformPoint(tempPoint1, relative); consumeAndTransformPoint(tempPoint2, relative); consumeAndTransformPoint(tempPoint3, relative); p.cubicTo(tempPoint1.x, tempPoint1.y, tempPoint2.x, tempPoint2.y, tempPoint3.x, tempPoint3.y); while (advanceToNextToken() == TOKEN_VALUE) { consumeAndTransformPoint(tempPoint1, relative); p.lineTo(tempPoint1.x, tempPoint1.y); while (advanceToNextToken() == TOKEN_VALUE) { float x = transformX(consumeValue()); if (relative) { x += mCurrentPoint.x; while (advanceToNextToken() == TOKEN_VALUE) { float y = transformY(consumeValue()); if (relative) { y += mCurrentPoint.y;
private void buildPathData() { SvgPathParser parser = getPathParser(); pathData = new PathData(); try { pathData.path = parser.parsePath(svgPath); } catch (ParseException e) { pathData.path = new Path(); } PathMeasure pm = new PathMeasure(pathData.path, true); while (true) { pathData.length = Math.max(pathData.length, pm.getLength()); if (!pm.nextContour()) { break; } } }
private float consumeValue() throws ParseException { advanceToNextToken(); if (mCurrentToken != TOKEN_VALUE) { throw new ParseException("Expected value", mIndex);