コード例 #1
0
  public int addBand(Rect rect) {
    mBands.add(0, mCurrentBand = new Band(rect.centerX(), rect.centerY()));
    mCurrentBand.mask = false;
    int x = (mCurrentBand.xPos1 + mCurrentBand.xPos2) / 2;
    int y = (mCurrentBand.yPos1 + mCurrentBand.yPos2) / 2;
    double addDelta = ADD_MIN_DIST * Math.max(rect.width(), rect.height());
    boolean moved = true;
    int count = 0;
    int toMove = mBands.indexOf(mCurrentBand);

    while (moved) {
      moved = false;
      count++;
      if (count > 14) {
        break;
      }

      for (Band point : mBands) {
        if (point.mask) {
          break;
        }
      }

      for (Band point : mBands) {
        if (point.mask) {
          break;
        }
        int index = mBands.indexOf(point);

        if (toMove != index) {
          double dist = Math.hypot(point.xPos1 - x, point.yPos1 - y);
          if (dist < addDelta) {
            moved = true;
            mCurrentBand.xPos1 += addDelta;
            mCurrentBand.yPos1 += addDelta;
            mCurrentBand.xPos2 += addDelta;
            mCurrentBand.yPos2 += addDelta;
            x = (mCurrentBand.xPos1 + mCurrentBand.xPos2) / 2;
            y = (mCurrentBand.yPos1 + mCurrentBand.yPos2) / 2;

            if (mCurrentBand.yPos1 > rect.bottom) {
              mCurrentBand.yPos1 = (int) (rect.top + addDelta);
            }
            if (mCurrentBand.xPos1 > rect.right) {
              mCurrentBand.xPos1 = (int) (rect.left + addDelta);
            }
          }
        }
      }
    }
    trimVector();
    return 0;
  }
コード例 #2
0
 private void creatExample() {
   Band p = new Band();
   p.mask = false;
   p.xPos1 = -1;
   p.yPos1 = 100;
   p.xPos2 = -1;
   p.yPos2 = 100;
   p.brightness = -50;
   p.contrast = 0;
   p.saturation = 0;
   mBands.add(0, p);
   mCurrentBand = p;
   trimVector();
 }
コード例 #3
0
 public void setParameter(int type, int value) {
   mCurrentBand.mask = false;
   switch (type) {
     case PARAM_BRIGHTNESS:
       mCurrentBand.brightness = value;
       break;
     case PARAM_SATURATION:
       mCurrentBand.saturation = value;
       break;
     case PARAM_CONTRAST:
       mCurrentBand.contrast = value;
       break;
     default:
       throw new IllegalArgumentException("no such type " + type);
   }
 }
コード例 #4
0
  @Override
  public void deSerializeRepresentation(JsonReader sreader) throws IOException {
    sreader.beginObject();
    Vector<Band> points = new Vector<Band>();

    while (sreader.hasNext()) {
      String name = sreader.nextName();
      if (name.startsWith(LINE_NAME)) {
        int pointNo = Integer.parseInt(name.substring(LINE_NAME.length()));
        sreader.beginArray();
        Band p = new Band();
        p.mask = false;
        sreader.hasNext();
        p.xPos1 = sreader.nextInt();
        sreader.hasNext();
        p.yPos1 = sreader.nextInt();
        sreader.hasNext();
        p.xPos2 = sreader.nextInt();
        sreader.hasNext();
        p.yPos2 = sreader.nextInt();
        sreader.hasNext();
        p.brightness = sreader.nextInt();
        sreader.hasNext();
        p.contrast = sreader.nextInt();
        sreader.hasNext();
        p.saturation = sreader.nextInt();
        sreader.hasNext();
        sreader.endArray();
        points.add(p);

      } else {
        sreader.skipValue();
      }
    }
    mBands = points;
    trimVector();
    mCurrentBand = mBands.get(0);
    sreader.endObject();
  }