Package org.zkoss.json

Examples of org.zkoss.json.JSONObject


 
 
  @SuppressWarnings("unchecked")
  @Override
  public JSONAware getShapeJSONObject() {
    JSONObject result = new JSONObject();
    result.put("cnt", getSnapshotCntRef());
   
    result.put("dx", _dx);
    result.put("dy", _dy);
   
    if(_dw >= 0 && _dh >= 0) {
      result.put("dw", _dw);
      result.put("dh", _dh);
    }
   
    if(_sx >= 0 && _sy >= 0 && _sw >= 0 && _sh >= 0) {
      result.put("sx", _sx);
      result.put("sy", _sy);
      result.put("sw", _sw);
      result.put("sh", _sh);
    }
   
    return result;
  }
View Full Code Here


 
  /* interface implementation */
  @SuppressWarnings("unchecked")
  @Override
  public JSONAware getShapeJSONObject() {
    JSONObject obj = new JSONObject();
    obj.put("t", _text);
    obj.put("x", _x);
    obj.put("y", _y);
    return obj;
  }
View Full Code Here

   * Inserts the Drawable at specific index
   */
  @SuppressWarnings("unchecked")
  public void insert(int index, Drawable drawable){
    _drawables.add(index, cloneIfPossible(drawable));
    JSONObject args = new JSONObject();
    args.put("i", index);
    args.put("drw", drawable);
    smartUpdate("insert", args, true);
  }
View Full Code Here

   */
  @SuppressWarnings("unchecked")
  public Drawable replace(int index, Drawable drawable){
    Drawable removed = _drawables.remove(index);
    _drawables.add(index, cloneIfPossible(drawable));
    JSONObject args = new JSONObject();
    args.put("i", index);
    args.put("drw", drawable);
    smartUpdate("replace", args, true);
    return removed;
  }
View Full Code Here

 
  @SuppressWarnings("unchecked")
  @Override
  public JSONAware getShapeJSONObject() {
    Rectangle2D.Double rect = (Rectangle2D.Double) _internalShape;
    JSONObject m = new JSONObject();
    m.put("x", rect.x);
    m.put("y", rect.y);
    m.put("w", rect.width);
    m.put("h", rect.height);
    return m;
  }
View Full Code Here

  private static void appendEventByJSON(StringBuffer sb, Calendars calendars, String key, CalendarEvent ce) {
    DateFormatter df = calendars.getDateFormatter();
    Locale locale = Locales.getCurrent();
    TimeZone timezone = calendars.getDefaultTimeZone();
   
    JSONObject json = new JSONObject();
    json.put("id", calendars.getCalendarEventId(ce));
    json.put("key", key);
    json.put("title", Util.createEventTitle(df, locale, timezone, ce));
    json.put("headerColor", ce.getHeaderColor());
    json.put("contentColor", ce.getContentColor());
    json.put("content", calendars.isEscapeXML() ? escapeXML(ce.getContent()): ce.getContent());
    json.put("beginDate", String.valueOf(getDSTTime(timezone, ce.getBeginDate())));
    json.put("endDate", String.valueOf(getDSTTime(timezone ,ce.getEndDate())));
    json.put("isLocked", String.valueOf(ce.isLocked()));
    json.put("zclass", ce.getZclass());
   
    sb.append(json.toString()).append(",");
  }
View Full Code Here

    if(model != null && _type != null){
      if("pie".equals(_type)) {  //Draw PieChart
        PieModel tempModel = (PieModel)model;
        for(int i = 0, nCategories = tempModel.getCategories().size(); i < nCategories; i++){
          Comparable category = tempModel.getCategory(i);
          JSONObject json = new JSONObject();
          json.put("categoryField", category);
          json.put("dataField", tempModel.getValue(category));
          list.add(json);
        }
      } else if("bar".equals(_type) || "line".equals(_type) || "column".equals(_type)) {
        CategoryModel tempModel = (CategoryModel)model;
        for (int j = 0,  nSeries = tempModel.getSeries().size(); j < nSeries; j++) {
          Comparable series = tempModel.getSeries(j);
          for (int i = 0, nCategories = tempModel.getCategories().size(); i < nCategories; i++) {
            Comparable category = tempModel.getCategory(i);
            JSONObject json = new JSONObject();
            if ("line".equals(_type) || "column".equals(_type)) { // Draw, LineChart, and ColumnChart
              json.put("horizontalField", category);
              json.put("verticalField", tempModel.getValue(
                  series, category));
            } else { // Draw BarChart
              json.put("horizontalField", tempModel.getValue(
                  series, category));
              json.put("verticalField", category);
            }
            list.add(json);
          }
        }
      } else if(_type.startsWith("stackbar")){    //Draw StackedBarChart
        _seriesList = new LinkedList();
        CategoryModel tempModel = (CategoryModel)model;
        for(int i = 0, nSeries = tempModel.getSeries().size(); i < nSeries; i++){
          Comparable series = tempModel.getSeries(i)
          JSONObject json = new JSONObject();     
          json.put("xField", series);
          json.put("displayName", series);
          _seriesList.add(json);
        }
        for(int i = 0, nCategories = tempModel.getCategories().size(); i < nCategories; i++){
          Comparable category = tempModel.getCategory(i);         
          JSONObject jData = new JSONObject();
          jData.put("verticalField", category);
          for(int j = 0; j < _seriesList.size(); j++){
            Comparable series = tempModel.getSeries(j)
            JSONObject temp = (JSONObject) _seriesList.get(j);           
            jData.put(temp.get("xField"), tempModel.getValue(series, category));
          }
          list.add(jData);         
        }
      } else if(_type.startsWith("stackcolumn")){    //Draw StackedColumnChart
        _seriesList = new LinkedList();
        XYModel tempModel = (XYModel)model;
        for(int i = 0, nSeries = tempModel.getSeries().size(); i < nSeries; i++){
          Comparable series = tempModel.getSeries(i);         
          JSONObject jData = new JSONObject();
          jData.put("horizontalField", series);
          jData.put(_xAxis, tempModel.getX(series, 0));
          jData.put(_yAxis, tempModel.getY(series, 0));
          list.add(jData);
        }
        for(int j = 0; j < 2; j++){
          JSONObject json = new JSONObject();
          String tempType = _type.split(":")[1];
          if(j == 0){
            json.put("type", tempType.split(",")[0]);
            json.put("displayName", _yAxis);
            json.put("yField", _yAxis);
          } else {
            json.put("type", tempType.split(",")[1]);
            json.put("displayName", _xAxis);
            json.put("yField", _xAxis);
          }
          _seriesList.add(json);
        }
      }
    };
View Full Code Here

      token = new Yytoken(Yytoken.TYPE_EOF, null);
  }
 
  private Map createObjectContainer(ContainerFactory containerFactory){
    if(containerFactory == null)
      return new JSONObject();
    Map m = containerFactory.createObjectContainer();
   
    if(m == null)
      return new JSONObject();
    return m;
  }
View Full Code Here

    Worksheet sheet = spreadsheet.getSelectedSheet();
   
    if (sheetId.equals(((SheetCtrl)sheet).getUuid())) {
      final SpreadsheetCtrl spreadsheetCtrl = ((SpreadsheetCtrl) spreadsheet.getExtraCtrl());
     
      JSONObject mainBlock = spreadsheetCtrl.getRangeAttrs(sheet, SpreadsheetCtrl.Header.BOTH, SpreadsheetCtrl.CellAttribute.ALL, left, top, right, bottom);
      if (spreadsheet.getColumnfreeze() >= 0) {
        mainBlock.put("leftFrozen",
            spreadsheetCtrl.getRangeAttrs(sheet, SpreadsheetCtrl.Header.BOTH, SpreadsheetCtrl.CellAttribute.ALL, 0, top, spreadsheet.getColumnfreeze(), bottom));
      }
      if (spreadsheet.getRowfreeze() >= 0) {
        mainBlock.put("topFrozen",
            spreadsheetCtrl.getRangeAttrs(sheet, SpreadsheetCtrl.Header.BOTH, SpreadsheetCtrl.CellAttribute.ALL, left, 0, right, spreadsheet.getRowfreeze()));
      }
      spreadsheet.smartUpdate("activeRangeUpdate", mainBlock);
    }
  }
View Full Code Here

    int w = right - left + 1;
    int h = bottom - top + 1;
   
    //check merge range;
    JSONObject json = new JSONObject();
   
    json.put("type", "jump");
    json.put("left", left);
    json.put("top", top);
    json.put("width", w);
    json.put("height", h);
   
    SpreadsheetCtrl.Header header = SpreadsheetCtrl.Header.NONE;
    if (!_hidecolhead && !_hiderowhead) {
      header = SpreadsheetCtrl.Header.BOTH;
    } else if (!_hidecolhead) {
      header = SpreadsheetCtrl.Header.COLUMN;
    } else if (!_hiderowhead) {
      header = SpreadsheetCtrl.Header.ROW;
    }
   
    int preloadColSize = _spreadsheet.getPreloadColumnSize();
    int preloadRowSize = _spreadsheet.getPreloadRowSize();
   
    int re = top + h;
    int ce = left + w;
   
    int rangeLeft = left;
    int rangeRight = right;
    int rangeTop = top;
    int rangeBtm = bottom;
   
    if (preloadColSize > 0 && preloadRowSize > 0) {
      //extends both
      preloadColSize = preloadColSize / 2;
      preloadRowSize = preloadRowSize / 2;
     
      int newLeft = Math.max(rangeLeft - preloadColSize, 0);
      int newTop = Math.max(rangeTop - preloadRowSize, 0);
      int newRight = Math.min(rangeRight + preloadColSize, _spreadsheet.getMaxcolumns() - 1);
      int newBtm = Math.min(rangeBtm + preloadRowSize, _spreadsheet.getMaxrows() - 1);
     
      rangeTop = _mergeMatrix.getTopConnectedRow(newTop, newLeft, newRight);
      rangeBtm = _mergeMatrix.getBottomConnectedRow(newBtm, newLeft, newRight);
      rangeRight = _mergeMatrix.getRightConnectedColumn(newRight, newTop, newBtm);
      rangeLeft = _mergeMatrix.getLeftConnectedColumn(newLeft, newTop, newBtm);
     
    } else if (preloadColSize > 0) {
      //extends range left and right
      int preloadSize =  preloadColSize / 2;
      int newLeft = Math.max(rangeLeft - preloadSize, 0);
      int newRight = Math.min(rangeRight + preloadSize, _spreadsheet.getMaxcolumns() - 1);
     
      rangeLeft = _mergeMatrix.getLeftConnectedColumn(newLeft, rangeTop, rangeBtm);
      rangeRight = _mergeMatrix.getRightConnectedColumn(newRight, rangeTop, rangeBtm);
    } else if (preloadRowSize > 0) {
     
      int preloadSize = preloadRowSize / 2;
      int newTop = Math.max(rangeTop - preloadSize, 0);
      int newBtm = Math.min(rangeBtm + preloadSize, _spreadsheet.getMaxrows() - 1);
     
      rangeTop = _mergeMatrix.getTopConnectedRow(newTop, rangeLeft, rangeRight);
      rangeBtm = _mergeMatrix.getBottomConnectedRow(newBtm, rangeLeft, rangeRight);
    }

   
    final SpreadsheetCtrl spreadsheetCtrl = ((SpreadsheetCtrl) _spreadsheet.getExtraCtrl());
    JSONObject mainBlock = spreadsheetCtrl.getRangeAttrs(sheet,
        header, SpreadsheetCtrl.CellAttribute.ALL, rangeLeft, rangeTop, rangeRight, rangeBtm);
    mainBlock.put("dir", "jump");
    json.put("data", mainBlock);
   
    _lastleft = left;
    _lastright = right;
    _lasttop = top;
    _lastbottom = bottom;
   
    _loadedLeft = rangeLeft;
    _loadedRight = rangeRight;
    _loadedTop = rangeTop;
    _loadedRight = rangeBtm;
   
    // prepare top frozen cell
    int fzr = _spreadsheet.getRowfreeze();
    if (fzr > -1) {
      mainBlock.put("topFrozen", spreadsheetCtrl.getRangeAttrs(sheet,
          header, SpreadsheetCtrl.CellAttribute.ALL, rangeLeft, 0, rangeRight, fzr));
    }

    //prepare left frozen cell
    int fzc = _spreadsheet.getColumnfreeze();
    if (fzc > -1) {
      mainBlock.put("leftFrozen", spreadsheetCtrl.getRangeAttrs(sheet,
          header, SpreadsheetCtrl.CellAttribute.ALL, 0, rangeTop, fzc, rangeBtm));
    }
    return json.toString();
  }
View Full Code Here

TOP

Related Classes of org.zkoss.json.JSONObject

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.