Example #1
0
 public String hash(String code, Integer year) {
   return code
       + ","
       + year
       + ","
       + mTimeLineCharter.getState()
       + ","
       + mPieCharter.getState()
       + ","
       + mResultsGrid.getState();
 }
Example #2
0
  @Override
  public void onValueChange(ValueChangeEvent<String> event) {
    String hash = event.getValue();

    recordAnalyticsHit(Window.Location.getPath() + Window.Location.getHash());

    String[] parts = hash.split(",");

    if (parts.length == 12) {
      String code = parts[0];
      Integer year = Integer.decode(parts[1]);
      try {
        Integer timeLineDataType = Integer.decode(parts[2]);
        Integer timeLineChartSelect0 = Integer.decode(parts[3]);
        Integer timeLineChartSelect1 = Integer.decode(parts[4]);
        Integer timeLineChartSelect2 = Integer.decode(parts[5]);
        Integer timeLineChartSelect3 = Integer.decode(parts[6]);
        Integer timeLineChartSelect4 = Integer.decode(parts[7]);
        Integer timeLineChartSelect5 = Integer.decode(parts[8]);
        Integer pieChartDataType = Integer.decode(parts[9]);
        Integer pieChartNet = Integer.decode(parts[10]);
        Integer resultsGridNet = Integer.decode(parts[11]);
        selectBudgetCode(code, year);
        mTimeLineCharter.setState(
            timeLineDataType,
            timeLineChartSelect0,
            timeLineChartSelect1,
            timeLineChartSelect2,
            timeLineChartSelect3,
            timeLineChartSelect4,
            timeLineChartSelect5);
        mPieCharter.setState(pieChartDataType, pieChartNet);
        mResultsGrid.setState(resultsGridNet);
      } catch (Exception e) {
        Log.error("Application::onValueChange: Error while parsing url", e);
        newCodeAndYear("00", 2012);
      }
    } else {
      Log.error("Application::onValueChange: Error while parsing url");
      newCodeAndYear("00", 2012);
    }
  }
Example #3
0
  public void init() {
    TotalBudget.getInstance();

    Integer height = null;
    Integer width = null;
    Map<String, List<String>> parameters = Window.Location.getParameterMap();
    if (parameters.containsKey("w") && parameters.containsKey("h")) {
      height = Integer.parseInt(parameters.get("h").get(0));
      width = Integer.parseInt(parameters.get("w").get(0));
    }

    mResultsGrid = new ResultGrid();
    mResultsGrid.setWidth("100%");

    Integer pieWidth = width == null ? 485 : width;
    Integer pieHeight = height == null ? 400 : height;
    mPieCharter = new PieCharter(this, mEmbedded, pieWidth, pieHeight);
    mPieCharter.setWidth(pieWidth + "px");
    mPieCharter.setHeight(pieHeight + "px");

    Integer timeWidth = width == null ? 686 : width;
    Integer timeHeight = height == null ? 400 : height;
    mTimeLineCharter = new TimeLineCharter(this, mEmbedded, timeWidth, timeHeight);
    mTimeLineCharter.setWidth(timeWidth + "px");
    mTimeLineCharter.setHeight(timeHeight + "px");

    mBreadcrumbs = new HTML("");
    mBreadcrumbs.setHeight("20px");
    mBreadcrumbs.setWidth("100%");

    mYearSelection = new ListBox();
    mYearSelection.addChangeHandler(
        new ChangeHandler() {
          @Override
          public void onChange(ChangeEvent event) {
            Integer index = mYearSelection.getSelectedIndex();
            String yearStr = mYearSelection.getItemText(index);
            Integer year;
            try {
              year = Integer.parseInt(yearStr);
            } catch (Exception e) {
              yearStr = yearStr.split(" ")[0];
              year = Integer.parseInt(yearStr);
            }
            selectYear(year);
          }
        });

    mSearchBox = new SuggestBox(new BudgetSuggestionOracle());
    mSearchBox.setWidth("300px");
    mSearchBox.setAutoSelectEnabled(false);
    mSearchBox.addSelectionHandler(
        new SelectionHandler<Suggestion>() {
          @Override
          public void onSelection(SelectionEvent<Suggestion> event) {
            final BudgetSuggestion bs = (BudgetSuggestion) event.getSelectedItem();

            BudgetAPICaller api = new BudgetAPICaller();
            api.setCode(bs.getCode());
            api.setParameter("depth", "0");
            api.setParameter("text", bs.getTitle());

            api.go(
                new BudgetAPICallback() {

                  @Override
                  public void onSuccess(JSONArray data) {
                    if (data.size() > 0) {
                      Integer year =
                          (int) data.get(0).isObject().get("year").isNumber().doubleValue();
                      newCodeAndYear(bs.getCode(), year);
                    }
                  }
                });
          }
        });

    mSummary1 = new Label();
    mSummary2 = new Label();
    mSummary2_1 = new Label();
    mSummary3 = new HTML();
    mSummary3_1 = new HTML();

    try {
      mBudgetNews = new BudgetNews();
    } catch (Exception e) {
      Log.error("Failed to init mBudgetNews", e);
    }

    mCheatSheet = new HTML("(הסברים)");
    final DecoratedPopupPanel simplePopup = new DecoratedPopupPanel(true);
    simplePopup.setWidth("450px");
    HTML simplePopupContents =
        new HTML(
            "<h4>מונחון מקוצר</h4>"
                + "<lu>"
                + "<li><b>נטו</b>: <u>תקציב הוצאה נטו</u> – הסכום המותר להוצאה בשנה כלשהי כפי שמפורט בחוק התקציב. תקציב זה מכונה גם \"תקציב המזומנים\".</li>"
                + "<li><b>ברוטו</b>: <u>תקציב ההוצאה נטו</u> בתוספת <u>תקציב ההוצאה המותנית בהכנסה</u> – תקציב נוסף המותר בהוצאה, ובלבד שיתקבלו תקבולים למימון ההוצאה מגורמים חוץ-ממשלתיים. תקבולים אלו אינם כוללים אגרה המשולמת לאוצר המדינה שהוטלה על-פי חיקוק שנחקק אחרי תחילת שנת הכספים 1992, ואינה כוללת הכנסה שמקורה במלווה (חוץ מתקציבי פיתוח וחשבון הון).</li>"
                + "<li><b>הקצאה</b>: <u>תקציב מקורי</u> – התקציב שאושר בכנסת במסגרת חוק התקציב. ייתכנו הבדלים בין הצעת התקציב לבין התקציב שיאושר בכנסת בסופו של דבר.</li>"
                + "<li><b>הקצאה מעודכנת</b>: <u>תקציב על שינוייו</u> – תקציב המדינה עשוי להשתנות במהלך השנה. שינויים אלו כוללים תוספות, הפחתות והעברות תקציביות בין סעיפי תקציב (באישור ועדת הכספים של הכנסת). נוסף על כך, פעמים רבות מועברים עודפים מחויבים משנה קודמת הנכללים בתקציב זה. רוב השינויים בתקציב דורשים את אישורה של ועדת הכספים של הכנסת. התקציב בסוף השנה הכולל את השינויים שנעשו בו במהלך השנה נקרא התקציב על שינוייו או התקציב המאושר.</li>"
                + "<li><b>שימוש</b>:  <u>ביצוע</u> – התקציב שכבר נוצל ושולם בפועל על-ידי החשב.</li>"
                + "<li><b>ערך ריאלי ונומינלי</b>:  ראו הסבר ב<a href='http://he.wikipedia.org/wiki/%D7%A2%D7%A8%D7%9A_%D7%A8%D7%99%D7%90%D7%9C%D7%99_%D7%95%D7%A2%D7%A8%D7%9A_%D7%A0%D7%95%D7%9E%D7%99%D7%A0%D7%9C%D7%99' target ='_blank'>ויקיפדיה</a>.</li>"
                + "<li><b>ערך יחסי</b>:  האחוז היחסי של סעיף זה מכלל תקציב המדינה</li>"
                + "</lu>"
                + "<br/>"
                + "<i>לחץ מחוץ לחלונית זו לסגירתה</i>"
                + "<br/>"
                + "מקור: <a href='http://www.knesset.gov.il/mmm/data/docs/m02217.doc' target='_blank'>מסמך Word ממחלקת המחקר של הכנסת</a>"
                + "<p><b>התקציב הפתוח הוא פרויקט התנדבותי של עמותת 'הסדנא לידע ציבורי'. הנתונים המופיעים"
                + " בתקציב הפתוח נסמכים על פרסומי המדינה ואינם באים לשקף כל דעה שהיא. אין לסדנא לידע ציבורי"
                + " כל אחריות על השימוש בפרויקט וראוי לבדוק את הנתונים לגופם במקורותיהם לפני הסתמכות עליהם.</b></p>");
    simplePopupContents.setStyleName("obudget-cheatsheet-popup");
    simplePopup.setWidget(simplePopupContents);
    mCheatSheet.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            Widget source = (Widget) event.getSource();
            int left = source.getAbsoluteLeft() + 10;
            int top = source.getAbsoluteTop() + 10;
            simplePopup.setPopupPosition(left, top);
            simplePopup.show();
          }
        });

    History.addValueChangeHandler(this);
  }
Example #4
0
  private static ResultGrid makeResultGrid(List<BoneWorldGrid> boneWorldGrids) {
    // find min and max location for all BoneWorldGrids
    Vector3i minLocation = new Vector3i(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE);
    Vector3i maxLocation = new Vector3i(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE);
    for (BoneWorldGrid bwg : boneWorldGrids) {
      minLocation.x = Math.min(minLocation.x, bwg.location.x);
      minLocation.y = Math.min(minLocation.y, bwg.location.y);
      minLocation.z = Math.min(minLocation.z, bwg.location.z);

      maxLocation.x = Math.max(maxLocation.x, bwg.location.x + bwg.grid.getWidth());
      maxLocation.y = Math.max(maxLocation.y, bwg.location.y + bwg.grid.getHeight());
      maxLocation.z = Math.max(maxLocation.z, bwg.location.z + bwg.grid.getDepth());
    }

    int requiredSize =
        Math.max(
            Math.max(maxLocation.x - minLocation.x, maxLocation.y - minLocation.y),
            maxLocation.z - minLocation.z);
    // System.out.println("required grid size = " + requiredSize);

    ResultGrid resultGrid = new ResultGrid();
    resultGrid.minLocation = minLocation;
    resultGrid.dataGrid = new ByteArray3d(requiredSize, requiredSize, requiredSize);
    for (int i = 0; i < MAX_BONES_PER_TILE; i++) {
      resultGrid.boneIndexGrid[i] = new ByteArray3d(requiredSize, requiredSize, requiredSize);
      resultGrid.boneWeightGrid[i] = new ByteArray3d(requiredSize, requiredSize, requiredSize);
    }

    ByteArray3d dataGrid = resultGrid.dataGrid;

    int boneIndex = 0;
    for (BoneWorldGrid bwg : boneWorldGrids) {
      ByteArray3d grid = bwg.grid;
      int w = grid.getWidth();
      int h = grid.getHeight();
      int d = grid.getDepth();
      Vector3i offset = bwg.location.subtract(minLocation);
      Vector3i pos = new Vector3i();
      for (int x = 0; x < w; x++) {
        for (int y = 0; y < h; y++) {
          for (int z = 0; z < d; z++) {
            byte add = grid.get(x, y, z);
            if (add > 0) {
              pos.set(x + offset.x, y + offset.y, z + offset.z);
              byte old = dataGrid.get(pos);
              int newValue = (int) old + (int) add;
              // int newValue = Math.max((int) old, (int) add);
              if (newValue > 127) {
                newValue = 127;
              }
              dataGrid.set(pos, (byte) newValue);

              // assign bone weight in next free slot in boneWeightGrid
              int bcount = 0;
              while (bcount < MAX_BONES_PER_TILE
                  && resultGrid.boneWeightGrid[bcount].get(pos) != 0) {
                bcount++;
              }
              if (bcount < MAX_BONES_PER_TILE) {
                resultGrid.boneIndexGrid[bcount].set(pos, (byte) boneIndex);
                resultGrid.boneWeightGrid[bcount].set(pos, add);
              }
            }
          }
        }
      }
      boneIndex++;
    }
    return resultGrid;
  }