Esempio n. 1
0
  @Override
  public boolean equals(FilterRepresentation representation) {
    if (!super.equals(representation)) {
      return false;
    }
    if (representation instanceof FilterDrawRepresentation) {
      FilterDrawRepresentation fdRep = (FilterDrawRepresentation) representation;
      if (fdRep.mDrawing.size() != mDrawing.size()) return false;
      if (fdRep.mCurrent == null ^ (mCurrent == null || mCurrent.mPath == null)) {
        return false;
      }

      if (fdRep.mCurrent != null && mCurrent != null && mCurrent.mPath != null) {
        if (fdRep.mCurrent.noPoints == mCurrent.noPoints) {
          return true;
        }
        return false;
      }

      int n = mDrawing.size();
      for (int i = 0; i < n; i++) {
        StrokeData a = mDrawing.get(i);
        StrokeData b = mDrawing.get(i);
        if (!a.equals(b)) {
          return false;
        }
      }
      return true;
    }
    return false;
  }
Esempio n. 2
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;
 }
Esempio n. 3
0
 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;
 }
Esempio n. 4
0
 public void addPoint(float x, float y) {
   int len = mCurrent.noPoints * 2;
   mCurrent.mPath.lineTo(x, y);
   if ((len + 2) > mCurrent.mPoints.length) {
     mCurrent.mPoints = Arrays.copyOf(mCurrent.mPoints, mCurrent.mPoints.length * 2);
   }
   mCurrent.mPoints[len] = x;
   mCurrent.mPoints[len + 1] = y;
   mCurrent.noPoints++;
 }
Esempio n. 5
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();
  }