コード例 #1
0
 public void fillStrokeParameters(StrokeData sd) {
   byte type = (byte) mParamStyle.getSelected();
   int color = computeCurrentColor();
   float size = mParamSize.getValue();
   sd.mColor = color;
   sd.mRadius = size;
   sd.mType = type;
 }
コード例 #2
0
  @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();
  }