Ejemplo n.º 1
0
  public double[] getInterval(int key) {
    double[] output = new double[2];
    RangeHolder holder = new RangeHolder(key, key + 1);
    int pos = VectorUtil.binarySearch(ranges, holder, rangeComparator, true) - 1;
    // System.err.println("ranges = "+ranges);
    if (ranges.size() == 0) {
      output[0] = Double.NEGATIVE_INFINITY;
      output[1] = Double.POSITIVE_INFINITY;
      return output;
    }

    if (pos < 0) {
      output[0] = Double.NEGATIVE_INFINITY;
      output[1] = (double) ((Range) ranges.elementAt(0)).getLow() - 1;
      return output;
    }

    if (pos >= ranges.size()) {
      output[0] = (double) ((Range) ranges.elementAt(ranges.size() - 1)).getHigh() + 1;
      output[1] = Double.POSITIVE_INFINITY;
      return output;
    }

    Range rh = (Range) ranges.elementAt(pos);
    if (contains(rh, key)) {
      output[0] = (double) rh.getLow();
      output[1] = (double) rh.getHigh();
    } else {
      output[0] = (double) rh.getHigh() + 1;
      if (pos < ranges.size() - 1) output[1] = ((Range) ranges.elementAt(pos + 1)).getLow() - 1;
      else output[1] = Double.POSITIVE_INFINITY;
    }

    return output;
  }
Ejemplo n.º 2
0
  public Vector put(Range holder, Object value) {
    int pos = VectorUtil.binarySearch(ranges, holder, rangeComparator, true);
    if (pos == -1) {
      pos = 0;
    }
    Vector output = new Vector();

    int posHigh =
        VectorUtil.binarySearch(
            ranges, new RangeHolder(holder.getHigh(), holder.getHigh()), rangeComparator, true);

    Vector purged = new Vector();
    boolean positionRemoved = false;
    for (int i = (pos - 1 >= 0 ? pos - 1 : 0); i < posHigh && i < ranges.size(); i++) {
      Range clobberMe = (Range) ranges.elementAt(i);
      if (overlaps(clobberMe, holder)) {
        if (i == pos - 1) positionRemoved = true;
        output.addElement(data.remove(clobberMe));
        purged.addElement(clobberMe);
      }
    }
    for (int i = 0; i < purged.size(); i++) ranges.removeElement(purged.elementAt(i));

    if (positionRemoved) pos = pos - 1;

    ranges.insertElementAt(holder, pos);
    data.put(holder, value);
    return output;
  }
Ejemplo n.º 3
0
  /**
   * Calculate set of the difference ranges of given two ranges (as current (A, B] and rhs is (C,
   * D]) which node will need to fetch when moving to a given new token
   *
   * @param rhs range to calculate difference
   * @return set of difference ranges
   */
  public Set<Range> differenceToFetch(Range rhs) {
    Set<Range> difference = new HashSet<Range>();

    int comparisonAC = Range.compare(left, rhs.left);

    if (comparisonAC == 0) // (A, B] & (A, C]
    {
      if (Range.compare(right, rhs.right) < 0) // B < C
      {
        difference.add(new Range(right, rhs.right));
      }
    } else if (comparisonAC > 0) // (A, B] & (C, D]  where C < A (A > C)
    {
      difference.add(new Range(rhs.left, left)); // first interval will be (C, A]

      if (Range.compare(rhs.right, right) > 0) // D > B
      {
        difference.add(new Range(rhs.right, right)); // (D, B]
      }
    } else // (A, B] & (C, D] where C > A (mean that comparisonAC < 0)
    {
      Token newLeft =
          (Range.compare(rhs.left, right) > 0) ? rhs.left : right; // C > B ? (C, D] : (B, D]
      difference.add(new Range(newLeft, rhs.right));
    }

    return difference;
  }
Ejemplo n.º 4
0
 /**
  * Removes the EXACT range defined by (low,high). If no range is defined on exactly those
  * coordinates, no elements are removed
  */
 public Object remove(int low, int high) {
   RangeHolder holder = new RangeHolder(low, high);
   int pos = VectorUtil.binarySearch(ranges, holder, rangeComparator, false);
   Range found = (Range) ranges.elementAt(pos);
   if (found.equals(holder)) return data.remove(holder);
   else return null;
 }
Ejemplo n.º 5
0
 private void readOneScan(
     Cinrad2Record[] mapScan, Range radialRange, Range gateRange, int datatype, IndexIterator ii)
     throws IOException {
   for (int i = radialRange.first(); i <= radialRange.last(); i += radialRange.stride()) {
     Cinrad2Record r = mapScan[i];
     readOneRadial(r, datatype, gateRange, ii);
   }
 }
Ejemplo n.º 6
0
 private static Set<Range> intersectionOneWrapping(Range wrapping, Range other) {
   Set<Range> intersection = new HashSet<Range>(2);
   if (other.contains(wrapping.right)) intersection.add(new Range(other.left, wrapping.right));
   // need the extra compareto here because ranges are asymmetrical; wrapping.left _is not_
   // contained by the wrapping range
   if (other.contains(wrapping.left) && wrapping.left.compareTo(other.right) < 0)
     intersection.add(new Range(wrapping.left, other.right));
   return Collections.unmodifiableSet(intersection);
 }
Ejemplo n.º 7
0
 private void readOneRadial(Cinrad2Record r, int datatype, Range gateRange, IndexIterator ii)
     throws IOException {
   if (r == null) {
     for (int i = gateRange.first(); i <= gateRange.last(); i += gateRange.stride())
       ii.setByteNext(Cinrad2Record.MISSING_DATA);
     return;
   }
   r.readData(volScan.raf, datatype, gateRange, ii);
 }
Ejemplo n.º 8
0
  public static boolean isTokenInRanges(Token token, Iterable<Range> ranges) {
    assert ranges != null;

    for (Range range : ranges) {
      if (range.contains(token)) {
        return true;
      }
    }
    return false;
  }
Ejemplo n.º 9
0
 public String toString() {
   StringBuffer out = new StringBuffer("(");
   for (int i = 0; i < ranges.size(); i++) {
     Range r = (Range) ranges.elementAt(i);
     Object o = data.get(r);
     if (i > 0) out.append(", ");
     out.append("{[" + r.getLow() + ", " + r.getHigh() + "] = " + o.toString() + "}");
   }
   out.append(")");
   return out.toString();
 }
Ejemplo n.º 10
0
 public int[] getDefinedInterval(int key) {
   RangeHolder holder = new RangeHolder(key, key);
   int pos = VectorUtil.binarySearch(ranges, holder, rangeComparator, true) - 1;
   if (pos < 0 || pos >= ranges.size()) return null;
   Range r = (Range) ranges.elementAt(pos);
   if (r.getLow() <= key && r.getHigh() >= key) {
     int[] out = new int[2];
     out[0] = r.getLow();
     out[1] = r.getHigh();
     return out;
   } else return null;
 }
Ejemplo n.º 11
0
  public Array readData(Variable v2, Section section) throws IOException, InvalidRangeException {
    Vgroup vgroup = (Vgroup) v2.getSPobject();

    Range scanRange = section.getRange(0);
    Range radialRange = section.getRange(1);
    Range gateRange = section.getRange(2);

    Array data = Array.factory(v2.getDataType().getPrimitiveClassType(), section.getShape());
    IndexIterator ii = data.getIndexIterator();

    for (int i = scanRange.first(); i <= scanRange.last(); i += scanRange.stride()) {
      Cinrad2Record[] mapScan = vgroup.map[i];
      readOneScan(mapScan, radialRange, gateRange, vgroup.datatype, ii);
    }

    return data;
  }
 private void readNames(int base) {
   pos = base;
   int nextra = readInt(2);
   names = new String[nextra];
   //	safenames= new String[nextra];
   for (int i = 0; i < nextra; i++) {
     Range r = getIndexEntry(base, i);
     names[i] = new String(data, r.getStart(), r.getLen());
     System.out.println(
         "Read name: "
             + i
             + " from "
             + r.getStart()
             + " to "
             + r.getEnd()
             + ": "
             + safe(names[i]));
   }
 }
 private void readDict(Range r) {
   //	System.out.println("reading dictionary from "+r.getStart()+" to "+r.getEnd());
   pos = r.getStart();
   while (pos < r.getEnd()) {
     int cmd = readCommand(false);
     if (cmd == 1006) { // charstringtype, default=2
       charstringtype = (int) stack[0];
     } else if (cmd == 1007) { // fontmatrix
       if (stackptr == 4) {
         at =
             new AffineTransform(
                 (float) stack[0], (float) stack[1], (float) stack[2], (float) stack[3], 0, 0);
       } else {
         at =
             new AffineTransform(
                 (float) stack[0],
                 (float) stack[1],
                 (float) stack[2],
                 (float) stack[3],
                 (float) stack[4],
                 (float) stack[5]);
       }
     } else if (cmd == 15) { // charset
       charsetbase = (int) stack[0];
     } else if (cmd == 16) { // encoding
       encodingbase = (int) stack[0];
     } else if (cmd == 17) { // charstrings
       charstringbase = (int) stack[0];
     } else if (cmd == 18) { // private
       privatesize = (int) stack[0];
       privatebase = (int) stack[1];
     } else if (cmd == 19) { // subrs (in Private dict)
       lsubrbase = (int) stack[0];
       lsubrsoffset = calcoffset(lsubrbase);
     } else if (cmd == 20) { // defaultWidthX (in Private dict)
       defaultWidthX = (int) stack[0];
     } else if (cmd == 21) { // nominalWidthX (in Private dict)
       nominalWidthX = (int) stack[0];
     }
     stackptr = 0;
   }
 }
Ejemplo n.º 14
0
  /**
   * @param that
   * @return the intersection of the two Ranges. this can be two disjoint Ranges if one is wrapping
   *     and one is not. say you have nodes G and M, with query range (D,T]; the intersection is
   *     (M-T] and (D-G]. If there is no intersection, an empty list is returned.
   */
  public Set<Range> intersectionWith(Range that) {
    if (that.contains(this)) return rangeSet(this);
    if (this.contains(that)) return rangeSet(that);

    boolean thiswraps = isWrapAround(left, right);
    boolean thatwraps = isWrapAround(that.left, that.right);
    if (!thiswraps && !thatwraps) {
      // neither wraps.  the straightforward case.
      if (!(left.compareTo(that.right) < 0 && that.left.compareTo(right) < 0))
        return Collections.emptySet();
      return rangeSet(
          new Range(
              (Token) ObjectUtils.max(this.left, that.left),
              (Token) ObjectUtils.min(this.right, that.right)));
    }
    if (thiswraps && thatwraps) {
      // if the starts are the same, one contains the other, which we have already ruled out.
      assert !this.left.equals(that.left);
      // two wrapping ranges always intersect.
      // since we have already determined that neither this nor that contains the other, we have 2
      // cases,
      // and mirror images of those case.
      // (1) both of that's (1, 2] endpoints lie in this's (A, B] right segment:
      //  ---------B--------A--1----2------>
      // (2) only that's start endpoint lies in this's right segment:
      //  ---------B----1---A-------2------>
      // or, we have the same cases on the left segement, which we can handle by swapping this and
      // that.
      return this.left.compareTo(that.left) < 0
          ? intersectionBothWrapping(this, that)
          : intersectionBothWrapping(that, this);
    }
    if (thiswraps && !thatwraps) return intersectionOneWrapping(this, that);
    assert (!thiswraps && thatwraps);
    return intersectionOneWrapping(that, this);
  }
Ejemplo n.º 15
0
  /**
   * Create a new GeoGrid that is a logical subset of this GeoGrid.
   *
   * @param t_range subset the time dimension, or null if you want all of it
   * @param z_range subset the vertical dimension, or null if you want all of it
   * @param bbox a lat/lon bounding box, or null if you want all x,y
   * @param z_stride use only if z_range is null, then take all z with this stride (1 means all)
   * @param y_stride use this stride on the y coordinate (1 means all)
   * @param x_stride use this stride on the x coordinate (1 means all)
   * @return subsetted GeoGrid
   * @throws InvalidRangeException if bbox does not intersect GeoGrid
   */
  public GeoGrid subset(
      Range t_range, Range z_range, LatLonRect bbox, int z_stride, int y_stride, int x_stride)
      throws InvalidRangeException {

    if ((z_range == null) && (z_stride > 1)) {
      Dimension zdim = getZDimension();
      if (zdim != null) z_range = new Range(0, zdim.getLength() - 1, z_stride);
    }

    Range y_range = null, x_range = null;
    if (bbox != null) {
      List yx_ranges = gcs.getRangesFromLatLonRect(bbox);
      y_range = (Range) yx_ranges.get(0);
      x_range = (Range) yx_ranges.get(1);
    }

    if (y_stride > 1) {
      if (y_range == null) {
        Dimension ydim = getYDimension();
        y_range = new Range(0, ydim.getLength() - 1, y_stride);
      } else {
        y_range = new Range(y_range.first(), y_range.last(), y_stride);
      }
    }

    if (x_stride > 1) {
      if (x_range == null) {
        Dimension xdim = getXDimension();
        x_range = new Range(0, xdim.getLength() - 1, x_stride);
      } else {
        x_range = new Range(x_range.first(), x_range.last(), x_stride);
      }
    }

    return subset(t_range, z_range, y_range, x_range);
  }
  public void parseGlyph(Range r, GlyphData gp, FlPoint pt) {
    pos = r.getStart();
    int i;
    float x1, y1, x2, y2, x3, y3, ybase;
    int hold;
    int stemhints = 0;
    gp.setAdvance(defaultWidthX);
    while (pos < r.getEnd()) {
      int cmd = readCommand(true);
      hold = 0;
      switch (cmd) {
        case 1: // hstem
        case 3: // vstem
          if ((stackptr & 1) == 1) {
            gp.setAdvance(nominalWidthX + stack[0]);
          }
          stackptr = 0;
          break;
        case 4: // vmoveto
          if (stackptr > 1) { // this is the first call, arg1 is width
            gp.setAdvance(nominalWidthX + stack[0]);
            stack[0] = stack[1];
          }
          pt.y += stack[0];
          if (pt.open) {
            gp.closePath();
          }
          pt.open = false;
          gp.moveTo(pt.x, pt.y);
          stackptr = 0;
          break;
        case 5: // rlineto
          for (i = 0; i < stackptr; ) {
            pt.x += stack[i++];
            pt.y += stack[i++];
            gp.lineTo(pt.x, pt.y);
          }
          pt.open = true;
          stackptr = 0;
          break;
        case 6: // hlineto
          for (i = 0; i < stackptr; ) {
            if ((i & 1) == 0) {
              pt.x += stack[i++];
            } else {
              pt.y += stack[i++];
            }
            gp.lineTo(pt.x, pt.y);
          }
          pt.open = true;
          stackptr = 0;
          break;
        case 7: // vlineto
          for (i = 0; i < stackptr; ) {
            if ((i & 1) == 0) {
              pt.y += stack[i++];
            } else {
              pt.x += stack[i++];
            }
            gp.lineTo(pt.x, pt.y);
          }
          pt.open = true;
          stackptr = 0;
          break;
        case 8: // rrcurveto
          for (i = 0; i < stackptr; ) {
            x1 = pt.x + stack[i++];
            y1 = pt.y + stack[i++];
            x2 = x1 + stack[i++];
            y2 = y1 + stack[i++];
            pt.x = x2 + stack[i++];
            pt.y = y2 + stack[i++];
            gp.curveTo(x1, y1, x2, y2, pt.x, pt.y);
          }
          pt.open = true;
          stackptr = 0;
          break;
        case 10: // callsubr
          hold = pos;
          i = (int) stack[--stackptr] + lsubrsoffset;
          Range lsubr = getIndexEntry(lsubrbase, i);
          parseGlyph(lsubr, gp, pt);
          pos = hold;
          break;
        case 11: // return
          return;
        case 14: // endchar
          if (stackptr == 5) {
            buildAccentChar(stack[1], stack[2], stack[3], stack[4], gp);
          }

          if (pt.open) {
            gp.closePath();
          }
          pt.open = false;
          stackptr = 0;
          return;
        case 18: // hstemhm
          if ((stackptr & 1) == 1) {
            gp.setAdvance(nominalWidthX + stack[0]);
          }
          stemhints += stackptr / 2;
          stackptr = 0;
          break;
        case 19: // hintmask
        case 20: // cntrmask
          if ((stackptr & 1) == 1) {
            gp.setAdvance(nominalWidthX + stack[0]);
          }
          stemhints += stackptr / 2;
          System.out.println(
              "Added "
                  + stackptr
                  + " extra bits;  skipping "
                  + ((stemhints - 1) / 8 + 1)
                  + " from "
                  + stemhints);
          pos += (stemhints - 1) / 8 + 1;
          stackptr = 0;
          break;
        case 21: // rmoveto
          if (stackptr > 2) {
            gp.setAdvance(nominalWidthX + stack[0]);
            stack[0] = stack[1];
            stack[1] = stack[2];
          }
          pt.x += stack[0];
          pt.y += stack[1];
          if (pt.open) {
            gp.closePath();
          }
          gp.moveTo(pt.x, pt.y);
          pt.open = false;
          stackptr = 0;
          break;
        case 22: // hmoveto
          if (stackptr > 1) {
            gp.setAdvance(nominalWidthX + stack[0]);
            stack[0] = stack[1];
          }
          pt.x += stack[0];
          if (pt.open) {
            gp.closePath();
          }
          gp.moveTo(pt.x, pt.y);
          pt.open = false;
          stackptr = 0;
          break;
        case 23: // vstemhm
          if ((stackptr & 1) == 1) {
            gp.setAdvance(nominalWidthX + stack[0]);
          }
          stemhints += stackptr / 2;
          stackptr = 0;
          break;
        case 24: // rcurveline
          for (i = 0; i < stackptr - 2; ) {
            x1 = pt.x + stack[i++];
            y1 = pt.y + stack[i++];
            x2 = x1 + stack[i++];
            y2 = y1 + stack[i++];
            pt.x = x2 + stack[i++];
            pt.y = y2 + stack[i++];
            gp.curveTo(x1, y1, x2, y2, pt.x, pt.y);
          }
          pt.x += stack[i++];
          pt.y += stack[i++];
          gp.lineTo(pt.x, pt.y);
          pt.open = true;
          stackptr = 0;
          break;
        case 25: // rlinecurve
          for (i = 0; i < stackptr - 6; ) {
            pt.x += stack[i++];
            pt.y += stack[i++];
            gp.lineTo(pt.x, pt.y);
          }
          x1 = pt.x + stack[i++];
          y1 = pt.y + stack[i++];
          x2 = x1 + stack[i++];
          y2 = y1 + stack[i++];
          pt.x = x2 + stack[i++];
          pt.y = y2 + stack[i++];
          gp.curveTo(x1, y1, x2, y2, pt.x, pt.y);
          pt.open = true;
          stackptr = 0;
          break;
        case 26: // vvcurveto
          i = 0;
          if ((stackptr & 1) == 1) { // odd number of arguments
            pt.x += stack[i++];
          }
          while (i < stackptr) {
            x1 = pt.x;
            y1 = pt.y + stack[i++];
            x2 = x1 + stack[i++];
            y2 = y1 + stack[i++];
            pt.x = x2;
            pt.y = y2 + stack[i++];
            gp.curveTo(x1, y1, x2, y2, pt.x, pt.y);
          }
          pt.open = true;
          stackptr = 0;
          break;
        case 27: // hhcurveto
          i = 0;
          if ((stackptr & 1) == 1) { // odd number of arguments
            pt.y += stack[i++];
          }
          while (i < stackptr) {
            x1 = pt.x + stack[i++];
            y1 = pt.y;
            x2 = x1 + stack[i++];
            y2 = y1 + stack[i++];
            pt.x = x2 + stack[i++];
            pt.y = y2;
            gp.curveTo(x1, y1, x2, y2, pt.x, pt.y);
          }
          pt.open = true;
          stackptr = 0;
          break;
        case 29: // callgsubr
          hold = pos;
          i = (int) stack[--stackptr] + gsubrsoffset;
          Range gsubr = getIndexEntry(gsubrbase, i);
          parseGlyph(gsubr, gp, pt);
          pos = hold;
          break;
        case 30: // vhcurveto
          hold = 4;
        case 31: // hvcurveto
          for (i = 0; i < stackptr; ) {
            boolean hv = (((i + hold) & 4) == 0);
            x1 = pt.x + (hv ? stack[i++] : 0);
            y1 = pt.y + (hv ? 0 : stack[i++]);
            x2 = x1 + stack[i++];
            y2 = y1 + stack[i++];
            pt.x = x2 + (hv ? 0 : stack[i++]);
            pt.y = y2 + (hv ? stack[i++] : 0);
            if (i == stackptr - 1) {
              if (hv) {
                pt.x += stack[i++];
              } else {
                pt.y += stack[i++];
              }
            }
            gp.curveTo(x1, y1, x2, y2, pt.x, pt.y);
          }
          pt.open = true;
          stackptr = 0;
          break;
        case 1003: // and
          x1 = stack[--stackptr];
          y1 = stack[--stackptr];
          stack[stackptr++] = ((x1 != 0) && (y1 != 0)) ? 1 : 0;
          break;
        case 1004: // or
          x1 = stack[--stackptr];
          y1 = stack[--stackptr];
          stack[stackptr++] = ((x1 != 0) || (y1 != 0)) ? 1 : 0;
          break;
        case 1005: // not
          x1 = stack[--stackptr];
          stack[stackptr++] = (x1 == 0) ? 1 : 0;
          break;
        case 1009: // abs
          stack[stackptr - 1] = Math.abs(stack[stackptr - 1]);
          break;
        case 1010: // add
          x1 = stack[--stackptr];
          y1 = stack[--stackptr];
          stack[stackptr++] = x1 + y1;
          break;
        case 1011: // sub
          x1 = stack[--stackptr];
          y1 = stack[--stackptr];
          stack[stackptr++] = y1 - x1;
          break;
        case 1012: // div
          x1 = stack[--stackptr];
          y1 = stack[--stackptr];
          stack[stackptr++] = y1 / x1;
          break;
        case 1014: // neg
          stack[stackptr - 1] = -stack[stackptr - 1];
          break;
        case 1015: // eq
          x1 = stack[--stackptr];
          y1 = stack[--stackptr];
          stack[stackptr++] = (x1 == y1) ? 1 : 0;
          break;
        case 1018: // drop
          stackptr--;
          break;
        case 1020: // put
          i = (int) stack[--stackptr];
          x1 = stack[--stackptr];
          temps[i] = x1;
          break;
        case 1021: // get
          i = (int) stack[--stackptr];
          stack[stackptr++] = temps[i];
          break;
        case 1022: // ifelse
          if (stack[stackptr - 2] > stack[stackptr - 1]) {
            stack[stackptr - 4] = stack[stackptr - 3];
          }
          stackptr -= 3;
          break;
        case 1023: // random
          stack[stackptr++] = (float) Math.random();
          break;
        case 1024: // mul
          x1 = stack[--stackptr];
          y1 = stack[--stackptr];
          stack[stackptr++] = y1 * x1;
          break;
        case 1026: // sqrt
          stack[stackptr - 1] = (float) Math.sqrt(stack[stackptr - 1]);
          break;
        case 1027: // dup
          x1 = stack[stackptr - 1];
          stack[stackptr++] = x1;
          break;
        case 1028: // exch
          x1 = stack[stackptr - 1];
          stack[stackptr - 1] = stack[stackptr - 2];
          stack[stackptr - 2] = x1;
          break;
        case 1029: // index
          i = (int) stack[stackptr - 1];
          if (i < 0) {
            i = 0;
          }
          stack[stackptr - 1] = stack[stackptr - 2 - i];
          break;
        case 1030: // roll
          i = (int) stack[--stackptr];
          int n = (int) stack[--stackptr];
          // roll n number by i (+ = upward)
          if (i > 0) {
            i = i % n;
          } else {
            i = n - (-i % n);
          }
          // x x x x i y y y -> y y y x x x x i (where i=3)
          if (i > 0) {
            float roll[] = new float[n];
            System.arraycopy(stack, stackptr - 1 - i, roll, 0, i);
            System.arraycopy(stack, stackptr - 1 - n, roll, i, n - i);
            System.arraycopy(roll, 0, stack, stackptr - 1 - n, n);
          }
          break;
        case 1034: // hflex
          x1 = pt.x + stack[0];
          y1 = ybase = pt.y;
          x2 = x1 + stack[1];
          y2 = y1 + stack[2];
          pt.x = x2 + stack[3];
          pt.y = y2;
          gp.curveTo(x1, y1, x2, y2, pt.x, pt.y);
          x1 = pt.x + stack[4];
          y1 = pt.y;
          x2 = x1 + stack[5];
          y2 = ybase;
          pt.x = x2 + stack[6];
          pt.y = y2;
          gp.curveTo(x1, y1, x2, y2, pt.x, pt.y);
          pt.open = true;
          stackptr = 0;
          break;
        case 1035: // flex
          x1 = pt.x + stack[0];
          y1 = pt.y + stack[1];
          x2 = x1 + stack[2];
          y2 = y1 + stack[3];
          pt.x = x2 + stack[4];
          pt.y = y2 + stack[5];
          gp.curveTo(x1, y1, x2, y2, pt.x, pt.y);
          x1 = pt.x + stack[6];
          y1 = pt.y + stack[7];
          x2 = x1 + stack[8];
          y2 = y1 + stack[9];
          pt.x = x2 + stack[10];
          pt.y = y2 + stack[11];
          gp.curveTo(x1, y1, x2, y2, pt.x, pt.y);
          pt.open = true;
          stackptr = 0;
          break;
        case 1036: // hflex1
          ybase = pt.y;
          x1 = pt.x + stack[0];
          y1 = pt.y + stack[1];
          x2 = x1 + stack[2];
          y2 = y1 + stack[3];
          pt.x = x2 + stack[4];
          pt.y = y2;
          gp.curveTo(x1, y1, x2, y2, pt.x, pt.y);
          x1 = pt.x + stack[5];
          y1 = pt.y;
          x2 = x1 + stack[6];
          y2 = y1 + stack[7];
          pt.x = x2 + stack[8];
          pt.y = ybase;
          gp.curveTo(x1, y1, x2, y2, pt.x, pt.y);
          pt.open = true;
          stackptr = 0;
          break;
        case 1037: // flex1
          ybase = pt.y;
          float xbase = pt.x;
          x1 = pt.x + stack[0];
          y1 = pt.y + stack[1];
          x2 = x1 + stack[2];
          y2 = y1 + stack[3];
          pt.x = x2 + stack[4];
          pt.y = y2 + stack[5];
          gp.curveTo(x1, y1, x2, y2, pt.x, pt.y);
          x1 = pt.x + stack[6];
          y1 = pt.y + stack[7];
          x2 = x1 + stack[8];
          y2 = y1 + stack[9];
          if (Math.abs(x2 - xbase) > Math.abs(y2 - ybase)) {
            pt.x = x2 + stack[10];
            pt.y = ybase;
          } else {
            pt.x = xbase;
            pt.y = y2 + stack[10];
          }
          gp.curveTo(x1, y1, x2, y2, pt.x, pt.y);
          pt.open = true;
          stackptr = 0;
          break;
        default:
          System.out.println("ERROR! TYPE1C CHARSTRING CMD IS " + cmd);
          break;
      }
    }
  }
Ejemplo n.º 17
0
 protected static boolean equals(Range a, Range b) {
   return a.getLow() == b.getLow() && a.getHigh() == b.getHigh();
 }
Ejemplo n.º 18
0
 protected static int compare(Range a, Range b) {
   if (a.getLow() < b.getLow()) return -1;
   else if (a.getLow() > b.getLow()) return 1;
   else return 0;
 }
Ejemplo n.º 19
0
 protected static boolean contains(Range r, int value) {
   return value >= r.getLow() && value <= r.getHigh();
 }
Ejemplo n.º 20
0
 protected static boolean overlaps(Range a, Range b) {
   return (contains(a, b.getLow())
       || contains(a, b.getHigh())
       || contains(b, a.getLow())
       || contains(b, a.getHigh()));
 }