Package org.zkoss.zss.model

Examples of org.zkoss.zss.model.Range


      return true;
    }
    if (!(other instanceof Range)) {
      return false;
    }
    final Range o = (Range) other;
    return Objects.equals(o.getSheet(), getSheet())
      && Objects.equals(o.getSheetTo(), getSheetTo())
      && o.getLeft() == getLeft()
      && o.getTop() == getTop()
      && o.getRight() == getRight()
      && o.getBottom() == getBottom();
  }
View Full Code Here


   */
  public static List toListHelper(List result, Object arg, boolean skipBoolean, boolean skipText, XelContext ctx){
    if (arg instanceof SSError) {
      throw new SSErrorXelException((SSError) arg);
    } else if (arg instanceof Range) { // a range, iterator thru available cells
      final Range rng = (Range) arg;
      final Book book = rng.getSheet().getBook();
      final Collection cells = rng.getCells();
      for(final Iterator it = cells.iterator(); it.hasNext();) {
        final Cell cell = (Cell) it.next();
        toListHelper(result, cell.getResult(), skipBoolean, skipText, (XelContext) book); // recursive
      }
    } else if (arg instanceof Range[]) { //a range array, iterator thru available ranges
      for (int j = 0; j < ((Range[])arg).length; ++j) {
        final Range rng = (Range) ((Range[])arg)[j];
        final Book book = rng.getSheet().getBook();
        toListHelper(result, rng, skipBoolean, skipText, (XelContext) book); // recursive
      }
    } else if (arg instanceof String) {
      if (!skipText) {
        result.add(Objects.ZERO_DOUBLE);
View Full Code Here

    }
  }

  public static double[][] toDoubleMatrix(Object arg) {
    if (arg instanceof Range) {
      final Range rng = (Range) arg;
      final Cell[][][] cella = rng.getCellsArray();
      final int rowsz = cella[0].length;
      final int colsz = cella[0][0].length;
      final double[][] vala = new double[rowsz][];
      for (int rj = 0; rj < colsz; ++rj) {
        vala[rj] = new double[colsz];
View Full Code Here

      } else if (_subtype == TokenSubtype.LOGICAL) {
        return Boolean.valueOf(CommonFns.toBoolean(_value));
      } else if (_subtype == TokenSubtype.ERROR) {
        throw new SSErrorXelException(SSError.valueOf((String)_value));
      } else if (_subtype == TokenSubtype.CELL) { //refer to a cell
        final Range rng = (Range) _value;
        final Iterator it = rng.getCells().iterator();
        final Cell cell = it.hasNext() ? (Cell) it.next() : null;
        return cell != null ? cell.getResult() : null;
      } else if (_subtype == TokenSubtype.RANGE) { //refer to a range
        return (Range) _value;
      } else if (_subtype == TokenSubtype.VAR) { //refer to a variable
View Full Code Here

    }
    return result;
  }
 
  private Range getRange(Object opn1, Object opn2, XelContext ctx) {
    final Range rng1 = (Range) opn1;
    final Range rng2 = (Range) opn2;
    final Sheet sheet1 = rng1.getSheet();
    if (sheet1 != rng2.getSheet()) {
      throw new SSErrorXelException(SSError.VALUE);
    }
    final int left = rngmin(rng1.getLeft(), rng2.getLeft());
    final int top = rngmin(rng1.getTop(), rng2.getTop());
    final int right = rngmax(rng1.getRight(), rng2.getRight());
    final int bottom = rngmax(rng1.getBottom(), rng2.getBottom());
    return new RangeSimple(sheet1, null, left, top, right, bottom);
  }
View Full Code Here

    final int bottom = rngmax(rng1.getBottom(), rng2.getBottom());
    return new RangeSimple(sheet1, null, left, top, right, bottom);
  }
 
  private Range[] getUnion(Object opn1, Object opn2, XelContext ctx) {
    final Range rng1 = (Range) opn1;
    final Range rng2 = (Range) opn2;
    return new Range[] {rng1, rng2};
  }
View Full Code Here

    final Range rng2 = (Range) opn2;
    return new Range[] {rng1, rng2};
  }
 
  private Range getIntersect(Object opn1, Object opn2, XelContext ctx) {
    final Range rng1 = (Range) opn1;
    final Range rng2 = (Range) opn2;
    final Sheet sheet1 = rng1.getSheet();
    if (sheet1 != rng2.getSheet()) {
      throw new SSErrorXelException(SSError.VALUE);
    }
    final int left = rngmax(rng1.getLeft(), rng2.getLeft());
    final int top = rngmax(rng1.getTop(), rng2.getTop());
    final int right = rngmin(rng1.getRight(), rng2.getRight());
    final int bottom = rngmin(rng1.getBottom(), rng2.getBottom());
   
    if (right >= 0) {
      if (left < 0 || left > right) {
        throw new SSErrorXelException(SSError.NULL);
      }
View Full Code Here

 
  public Token clone(Sheet sheet, int rowoff, int coloff, List ranges)
  throws XelException {
    final Token clone = new Token(_value, _type, _subtype);
    if (_subtype == TokenSubtype.CELL || _subtype == TokenSubtype.RANGE) { //refer to a range
      final Range cloneVal = ((Range) _value).clone(sheet, rowoff, coloff);
      ranges.add(cloneVal);
      clone.setValue(cloneVal);
    }
    if (_operands != null) {
      for(final Iterator it = _operands.iterator(); it.hasNext();) {
View Full Code Here

      } else if (_subtype == TokenSubtype.LOGICAL) {
        sb.append(CommonFns.toBoolean(_value) ? "TRUE" : "FALSE");
      } else if (_subtype == TokenSubtype.ERROR) {
        sb.append(_value);
      } else if (_subtype == TokenSubtype.CELL) { //refer to a cell
        final Range rng = (Range) _value;
        final Iterator it = rng.getCells().iterator();
        final Cell cell = it.hasNext() ? (Cell) it.next() : null;
        sb.append(getCellPrintString(cell, rng.isTopAbsolute(), rng.isLeftAbsolute(), ctx));
      } else if (_subtype == TokenSubtype.RANGE) { //refer to a range
        sb.append(getRangePrintString((Range) _value, ctx));
      } else if (_subtype == TokenSubtype.VAR) { //refer to a variable
        sb.append(_value);
      }
View Full Code Here

System.out.println(Objects.toString(ssl.getList()));
    assertEquals(2, ssl.getList().size());
   
    for(final Iterator it = ssl.getList().iterator(); it.hasNext();) {
      final SSDataEvent evt = (SSDataEvent) it.next();
      final Range rng = evt.getRange();
      if (rng.getLeft() == 1 && rng.getTop() == 0) {
        assertEquals(5d, ((Number)sheet1.getCell(0,1).getResult()).doubleValue(), 0d);
      } else  if (rng.getLeft() == 5 && rng.getTop() == 5) {
        assertEquals(8d, ((Number)sheet1.getCell(5,5).getResult()).doubleValue(), 0d);
      } else {
        assertFalse("should not come here", false);
      }
    }
View Full Code Here

TOP

Related Classes of org.zkoss.zss.model.Range

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.