List of usage examples for com.google.gwt.i18n.client NumberFormat format
public String format(Number number)
From source file:org.uberfire.ext.widgets.table.client.UberfireSimplePager.java
License:Apache License
protected String createText() { NumberFormat formatter = NumberFormat.getFormat("#,###"); HasRows display = getDisplay();//w ww .j av a2 s . co m Range range = display.getVisibleRange(); int pageStart = range.getStart() + 1; int pageSize = range.getLength(); int dataSize = display.getRowCount(); int endIndex = Math.min(dataSize, pageStart + pageSize - 1); endIndex = Math.max(pageStart, endIndex); boolean exact = display.isRowCountExact(); if (dataSize == 0) { return "0 " + of() + " 0"; } else if (pageStart == endIndex) { return formatter.format(pageStart) + " " + of() + " " + formatter.format(dataSize); } return formatter.format(pageStart) + "-" + formatter.format(endIndex) + (exact ? " " + of() + " " : " " + of() + " " + over() + " ") + formatter.format(dataSize); }
From source file:org.unitime.timetable.gwt.client.sectioning.StudentSchedule.java
License:Apache License
protected void fillInRequests() { ArrayList<WebTable.Row> rows = new ArrayList<WebTable.Row>(); boolean hasPref = false, hasWarn = false, hasWait = false, hasStat = false, hasCrit = false; NumberFormat df = NumberFormat.getFormat("0.#"); if (iAssignment.hasRequest()) { CheckCoursesResponse check = new CheckCoursesResponse(iAssignment.getRequest().getConfirmations()); hasWarn = iAssignment.getRequest().hasConfirmations(); int priority = 1; for (Request request : iAssignment.getRequest().getCourses()) { if (!request.hasRequestedCourse()) continue; boolean first = true; if (request.isWaitList()) hasWait = true;//from w ww . j a v a 2 s. com if (request.isCritical()) hasCrit = true; for (RequestedCourse rc : request.getRequestedCourse()) { if (rc.isCourse()) { ImageResource icon = null; String iconText = null; String msg = check.getMessage(rc.getCourseName(), "\n"); if (check.isError(rc.getCourseName()) && (rc.getStatus() == null || rc.getStatus() != RequestedCourseStatus.OVERRIDE_REJECTED)) { icon = RESOURCES.requestError(); iconText = (msg); } else if (rc.getStatus() != null) { switch (rc.getStatus()) { case ENROLLED: icon = RESOURCES.requestEnrolled(); iconText = (MESSAGES.enrolled(rc.getCourseName())); break; case OVERRIDE_NEEDED: icon = RESOURCES.requestNeeded(); iconText = (MESSAGES.overrideNeeded(msg)); break; case SAVED: icon = RESOURCES.requestSaved(); iconText = ((msg == null ? "" : MESSAGES.requestWarnings(msg) + "\n\n") + MESSAGES.requested(rc.getCourseName())); break; case OVERRIDE_REJECTED: icon = RESOURCES.requestRejected(); iconText = ((msg == null ? "" : MESSAGES.requestWarnings(msg) + "\n\n") + MESSAGES.overrideRejected(rc.getCourseName())); break; case OVERRIDE_PENDING: icon = RESOURCES.requestPending(); iconText = ((msg == null ? "" : MESSAGES.requestWarnings(msg) + "\n\n") + MESSAGES.overridePending(rc.getCourseName())); break; case OVERRIDE_CANCELLED: icon = RESOURCES.requestCancelled(); iconText = ((msg == null ? "" : MESSAGES.requestWarnings(msg) + "\n\n") + MESSAGES.overrideCancelled(rc.getCourseName())); break; case OVERRIDE_APPROVED: icon = RESOURCES.requestSaved(); iconText = ((msg == null ? "" : MESSAGES.requestWarnings(msg) + "\n\n") + MESSAGES.overrideApproved(rc.getCourseName())); break; default: if (check.isError(rc.getCourseName())) icon = RESOURCES.requestError(); iconText = (msg); } } if (rc.hasStatusNote()) iconText += "\n" + MESSAGES.overrideNote(rc.getStatusNote()); Collection<Preference> prefs = null; if (rc.hasSelectedIntructionalMethods()) { if (rc.hasSelectedClasses()) { prefs = new ArrayList<Preference>(rc.getSelectedIntructionalMethods().size() + rc.getSelectedClasses().size()); prefs.addAll(new TreeSet<Preference>(rc.getSelectedIntructionalMethods())); prefs.addAll(new TreeSet<Preference>(rc.getSelectedClasses())); } else { prefs = new TreeSet<Preference>(rc.getSelectedIntructionalMethods()); } } else if (rc.hasSelectedClasses()) { prefs = new TreeSet<Preference>(rc.getSelectedClasses()); } String status = ""; if (rc.getStatus() != null) { switch (rc.getStatus()) { case ENROLLED: status = MESSAGES.reqStatusEnrolled(); break; case OVERRIDE_APPROVED: status = MESSAGES.reqStatusApproved(); hasStat = true; break; case OVERRIDE_CANCELLED: status = MESSAGES.reqStatusCancelled(); hasStat = true; break; case OVERRIDE_PENDING: status = MESSAGES.reqStatusPending(); hasStat = true; break; case OVERRIDE_REJECTED: status = MESSAGES.reqStatusRejected(); hasStat = true; break; } } if (status.isEmpty()) status = MESSAGES.reqStatusRegistered(); if (prefs != null) hasPref = true; WebTable.Cell credit = new WebTable.Cell( rc.hasCredit() ? (rc.getCreditMin().equals(rc.getCreditMax()) ? df.format(rc.getCreditMin()) : df.format(rc.getCreditMin()) + " - " + df.format(rc.getCreditMax())) : ""); credit.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); String note = null, noteTitle = null; if (check != null) { note = check.getMessageWithColor(rc.getCourseName(), "<br>", "CREDIT"); noteTitle = check.getMessage(rc.getCourseName(), "\n", "CREDIT"); } if (rc.hasStatusNote()) { note = (note == null ? "" : note + "<br>") + rc.getStatusNote(); noteTitle = (noteTitle == null ? "" : noteTitle + "\n") + rc.getStatusNote(); } WebTable.Row row = new WebTable.Row( new WebTable.Cell(first ? MESSAGES.courseRequestsPriority(priority) : ""), new WebTable.Cell(rc.getCourseName()), new WebTable.Cell(rc.hasCourseTitle() ? rc.getCourseTitle() : ""), credit, new WebTable.Cell(ToolBox.toString(prefs)), new WebTable.NoteCell(note, noteTitle), (icon == null ? new WebTable.Cell(status) : new WebTable.IconCell(icon, iconText, status)), (first && request.isCritical() ? new WebTable.IconCell(RESOURCES.requestsCritical(), MESSAGES.descriptionRequestCritical(), "") : new WebTable.Cell("")), (first && request.isWaitList() ? new WebTable.IconCell(RESOURCES.requestsWaitList(), MESSAGES.descriptionRequestWaitListed(), "") : new WebTable.Cell("")), new WebTable.Cell( first && request.hasTimeStamp() ? sDF.format(request.getTimeStamp()) : "")); if (priority > 1 && first) for (WebTable.Cell cell : row.getCells()) cell.setStyleName("top-border-dashed"); rows.add(row); } else if (rc.isFreeTime()) { String free = ""; for (FreeTime ft : rc.getFreeTime()) { if (!free.isEmpty()) free += ", "; free += ft.toString(CONSTANTS.shortDays(), CONSTANTS.useAmPm()); } WebTable.Row row = new WebTable.Row( new WebTable.Cell(first ? MESSAGES.courseRequestsPriority(priority) : ""), new WebTable.Cell(CONSTANTS.freePrefix() + free, 3, null), new WebTable.Cell(""), new WebTable.Cell(""), new WebTable.IconCell(RESOURCES.requestSaved(), MESSAGES.requested(free), MESSAGES.reqStatusRegistered()), new WebTable.Cell(""), new WebTable.Cell(""), new WebTable.Cell( first && request.hasTimeStamp() ? sDF.format(request.getTimeStamp()) : "")); if (priority > 1 && first) for (WebTable.Cell cell : row.getCells()) cell.setStyleName("top-border-dashed"); rows.add(row); } first = false; } priority++; } priority = 1; for (Request request : iAssignment.getRequest().getAlternatives()) { if (!request.hasRequestedCourse()) continue; boolean first = true; if (request.isWaitList()) hasWait = true; if (request.isCritical()) hasCrit = true; for (RequestedCourse rc : request.getRequestedCourse()) { if (rc.isCourse()) { ImageResource icon = null; String iconText = null; String msg = check.getMessage(rc.getCourseName(), "\n"); if (check.isError(rc.getCourseName()) && (rc.getStatus() == null || rc.getStatus() != RequestedCourseStatus.OVERRIDE_REJECTED)) { icon = RESOURCES.requestError(); iconText = (msg); } else if (rc.getStatus() != null) { switch (rc.getStatus()) { case ENROLLED: icon = RESOURCES.requestEnrolled(); iconText = (MESSAGES.enrolled(rc.getCourseName())); break; case OVERRIDE_NEEDED: icon = RESOURCES.requestNeeded(); iconText = (MESSAGES.overrideNeeded(msg)); break; case SAVED: icon = RESOURCES.requestSaved(); iconText = ((msg == null ? "" : MESSAGES.requestWarnings(msg) + "\n\n") + MESSAGES.requested(rc.getCourseName())); break; case OVERRIDE_REJECTED: icon = RESOURCES.requestRejected(); iconText = ((msg == null ? "" : MESSAGES.requestWarnings(msg) + "\n\n") + MESSAGES.overrideRejected(rc.getCourseName())); break; case OVERRIDE_PENDING: icon = RESOURCES.requestPending(); iconText = ((msg == null ? "" : MESSAGES.requestWarnings(msg) + "\n\n") + MESSAGES.overridePending(rc.getCourseName())); break; case OVERRIDE_CANCELLED: icon = RESOURCES.requestCancelled(); iconText = ((msg == null ? "" : MESSAGES.requestWarnings(msg) + "\n\n") + MESSAGES.overrideCancelled(rc.getCourseName())); break; case OVERRIDE_APPROVED: icon = RESOURCES.requestSaved(); iconText = ((msg == null ? "" : MESSAGES.requestWarnings(msg) + "\n\n") + MESSAGES.overrideApproved(rc.getCourseName())); break; default: if (check.isError(rc.getCourseName())) icon = RESOURCES.requestError(); iconText = (msg); } } if (rc.hasStatusNote()) iconText += "\n" + MESSAGES.overrideNote(rc.getStatusNote()); Collection<Preference> prefs = null; if (rc.hasSelectedIntructionalMethods()) { if (rc.hasSelectedClasses()) { prefs = new ArrayList<Preference>(rc.getSelectedIntructionalMethods().size() + rc.getSelectedClasses().size()); prefs.addAll(new TreeSet<Preference>(rc.getSelectedIntructionalMethods())); prefs.addAll(new TreeSet<Preference>(rc.getSelectedClasses())); } else { prefs = new TreeSet<Preference>(rc.getSelectedIntructionalMethods()); } } else if (rc.hasSelectedClasses()) { prefs = new TreeSet<Preference>(rc.getSelectedClasses()); } if (prefs != null) hasPref = true; String status = ""; if (rc.getStatus() != null) { switch (rc.getStatus()) { case ENROLLED: status = MESSAGES.reqStatusEnrolled(); break; case OVERRIDE_APPROVED: status = MESSAGES.reqStatusApproved(); hasStat = true; break; case OVERRIDE_CANCELLED: status = MESSAGES.reqStatusCancelled(); hasStat = true; break; case OVERRIDE_PENDING: status = MESSAGES.reqStatusPending(); hasStat = true; break; case OVERRIDE_REJECTED: status = MESSAGES.reqStatusRejected(); hasStat = true; break; } } if (status.isEmpty()) status = MESSAGES.reqStatusRegistered(); WebTable.Cell credit = new WebTable.Cell( rc.hasCredit() ? (rc.getCreditMin().equals(rc.getCreditMax()) ? df.format(rc.getCreditMin()) : df.format(rc.getCreditMin()) + " - " + df.format(rc.getCreditMax())) : ""); credit.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); String note = null, noteTitle = null; if (check != null) { note = check.getMessageWithColor(rc.getCourseName(), "<br>", "CREDIT"); noteTitle = check.getMessage(rc.getCourseName(), "\n", "CREDIT"); } if (rc.hasStatusNote()) { note = (note == null ? "" : note + "<br>") + rc.getStatusNote(); noteTitle = (noteTitle == null ? "" : noteTitle + "\n") + rc.getStatusNote(); } WebTable.Row row = new WebTable.Row( new WebTable.Cell(first ? MESSAGES.courseRequestsAlternative(priority) : ""), new WebTable.Cell(rc.getCourseName()), new WebTable.Cell(rc.hasCourseTitle() ? rc.getCourseTitle() : ""), credit, new WebTable.Cell(ToolBox.toString(prefs)), new WebTable.NoteCell(note, noteTitle), (icon == null ? new WebTable.Cell(status) : new WebTable.IconCell(icon, iconText, status)), (first && request.isCritical() ? new WebTable.IconCell(RESOURCES.requestsCritical(), MESSAGES.descriptionRequestCritical(), "") : new WebTable.Cell("")), (first && request.isWaitList() ? new WebTable.IconCell(RESOURCES.requestsWaitList(), MESSAGES.descriptionRequestWaitListed(), "") : new WebTable.Cell("")), new WebTable.Cell( first && request.hasTimeStamp() ? sDF.format(request.getTimeStamp()) : "")); if (first) for (WebTable.Cell cell : row.getCells()) cell.setStyleName(priority == 1 ? "top-border-solid" : "top-border-dashed"); rows.add(row); } else if (rc.isFreeTime()) { String free = ""; for (FreeTime ft : rc.getFreeTime()) { if (!free.isEmpty()) free += ", "; free += ft.toString(CONSTANTS.shortDays(), CONSTANTS.useAmPm()); } WebTable.Row row = new WebTable.Row( new WebTable.Cell(first ? MESSAGES.courseRequestsPriority(priority) : ""), new WebTable.Cell(CONSTANTS.freePrefix() + free, 3, null), new WebTable.Cell(""), new WebTable.Cell(""), new WebTable.IconCell(RESOURCES.requestSaved(), MESSAGES.requested(free), MESSAGES.reqStatusRegistered()), new WebTable.Cell(""), new WebTable.Cell(""), new WebTable.Cell( first && request.hasTimeStamp() ? sDF.format(request.getTimeStamp()) : "")); if (first) for (WebTable.Cell cell : row.getCells()) cell.setStyleName(priority == 1 ? "top-border-solid" : "top-border-dashed"); rows.add(row); } first = false; } priority++; } } if (iAssignment.getRequest().getMaxCreditOverrideStatus() != null) { ImageResource icon = null; String status = ""; String note = null, noteTitle = null; String iconText = null; if (iAssignment.getRequest().hasCreditWarning()) { note = iAssignment.getRequest().getCreditWarning().replace("\n", "<br>"); noteTitle = iAssignment.getRequest().getCreditWarning(); iconText = iAssignment.getRequest().getCreditWarning(); hasWarn = true; } else if (iAssignment.getRequest().getMaxCreditOverrideStatus() != RequestedCourseStatus.SAVED) { note = noteTitle = iconText = MESSAGES.creditWarning(iAssignment.getRequest().getCredit()); } switch (iAssignment.getRequest().getMaxCreditOverrideStatus()) { case CREDIT_HIGH: icon = RESOURCES.requestError(); status = MESSAGES.reqStatusRejected(); note = "<span class='text-red'>" + note + "</span>"; iconText += "\n" + MESSAGES.creditStatusTooHigh(); break; case OVERRIDE_REJECTED: icon = RESOURCES.requestError(); status = MESSAGES.reqStatusRejected(); note = "<span class='text-red'>" + note + "</span>"; iconText += "\n" + MESSAGES.creditStatusDenied(); break; case CREDIT_LOW: case OVERRIDE_NEEDED: icon = RESOURCES.requestNeeded(); status = MESSAGES.reqStatusWarning(); note = "<span class='text-orange'>" + note + "</span>"; break; case OVERRIDE_CANCELLED: icon = RESOURCES.requestNeeded(); status = MESSAGES.reqStatusCancelled(); iconText += "\n" + MESSAGES.creditStatusCancelled(); note = "<span class='text-orange'>" + note + "</span>"; break; case OVERRIDE_PENDING: icon = RESOURCES.requestPending(); status = MESSAGES.reqStatusPending(); iconText += "\n" + MESSAGES.creditStatusPending(); note = "<span class='text-orange'>" + note + "</span>"; break; case OVERRIDE_APPROVED: icon = RESOURCES.requestSaved(); status = MESSAGES.reqStatusApproved(); iconText += (iconText == null ? "" : iconText + "\n") + MESSAGES.creditStatusApproved(); break; case SAVED: icon = RESOURCES.requestSaved(); status = MESSAGES.reqStatusRegistered(); break; } if (!status.isEmpty()) hasStat = true; if (iAssignment.getRequest().hasCreditNote()) { note = (note == null ? "" : note + "<br>") + iAssignment.getRequest().getCreditNote().replace("\n", "<br>"); noteTitle = (noteTitle == null ? "" : noteTitle + "\n") + MESSAGES.overrideNote(iAssignment.getRequest().getCreditNote()); iconText = (iconText == null ? "" : iconText + "\n") + iAssignment.getRequest().getCreditNote(); hasWarn = true; } float[] range = iAssignment.getRequest().getCreditRange(); WebTable.Cell credit = new WebTable.Cell(range != null ? range[0] < range[1] ? df.format(range[0]) + " - " + df.format(range[1]) : df.format(range[0]) : ""); credit.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); WebTable.Row row = new WebTable.Row(new WebTable.Cell(MESSAGES.rowRequestedCredit(), 2, null), new WebTable.Cell(""), credit, new WebTable.Cell(""), new WebTable.NoteCell(note, noteTitle), (icon == null ? new WebTable.Cell(status) : new WebTable.IconCell(icon, iconText, status)), new WebTable.Cell(""), new WebTable.Cell("")); for (WebTable.Cell cell : row.getCells()) cell.setStyleName("top-border-solid"); row.getCell(0).setStyleName("top-border-solid text-bold"); rows.add(row); } WebTable.Row[] rowArray = new WebTable.Row[rows.size()]; int idx = 0; for (WebTable.Row row : rows) rowArray[idx++] = row; iRequests.setData(rowArray); iRequests.setColumnVisible(4, hasPref); iRequests.setColumnVisible(5, hasWarn); iRequests.setColumnVisible(6, hasStat); iRequests.setColumnVisible(7, hasCrit); iRequests.setColumnVisible(8, hasWait); }
From source file:org.vaadin.johannes.graph.client.ui.VVaadinGraph.java
License:LGPL
private VectorObject getInfo() { final NumberFormat df = NumberFormat.getDecimalFormat(); final String zoom = df.format(zoomFactor); final String angl = df.format(angle); final String fpss = df.format(fps); final Text info = new Text(canvas.getWidth() - 130, 10, "Zoom: " + zoom + " Rot.: " + angl + " Fps " + fpss); info.setStrokeOpacity(0);//from www . j av a 2 s . co m info.setFillColor(edgeLabelColor); info.setFontSize(8); return info; }
From source file:smartgwt.client.ui.AdvancedFilterPortlet.java
License:Open Source License
public AdvancedFilterPortlet() { VStack vStack = new VStack(10); initWidget(vStack);//w ww. j a v a 2s . com dataSource = CountryDto.getDataSource(this); dataSource.setPortlet(this); final FilterBuilder filterBuilder = new FilterBuilder(); filterBuilder.setDataSource(dataSource); final ListGrid countryGrid = new ListGrid(); countryGrid.setWidth(550); countryGrid.setHeight(224); countryGrid.setDataSource(dataSource); countryGrid.setAutoFetchData(true); ListGridField nameField = new ListGridField("countryName", "Country"); ListGridField continentField = new ListGridField("continent", "Continent"); ListGridField populationField = new ListGridField("population", "Population"); populationField.setType(ListGridFieldType.INTEGER); populationField.setCellFormatter(new CellFormatter() { public String format(Object value, ListGridRecord record, int rowNum, int colNum) { if (value == null) return null; try { NumberFormat nf = NumberFormat.getFormat("0,000"); return nf.format(((Number) value).longValue()); } catch (Exception e) { return value.toString(); } } }); ListGridField independenceField = new ListGridField("independence", "Independence"); countryGrid.setFields(nameField, continentField, populationField, independenceField); IButton filterButton = new IButton("Filter"); filterButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { countryGrid.filterData(filterBuilder.getCriteria()); } }); vStack.addMember(filterBuilder); vStack.addMember(filterButton); vStack.addMember(countryGrid); }
From source file:strat.mining.multipool.stats.client.mvp.presenter.DonationViewPresenter.java
License:Open Source License
private String formatBTCValue(Number value) { NumberFormat nf = NumberFormat.getFormat("#.########"); return nf.format(value); }
From source file:strat.mining.multipool.stats.client.mvp.view.coinshift.component.AddressChartPanel.java
License:Open Source License
private void initPowerChart() { powerChart = new Chart(); powerChart.setChartTitleText("Power"); powerChart.setHeight(350);//from w ww.j a va 2 s. c o m powerChart.setZoomType(BaseChart.ZoomType.X); powerChart.setAnimation(false); powerChart.setShadow(false); powerChart.setOption("/plotOptions/series/turboThreshold", 10); powerChart.setAreaPlotOptions(new AreaPlotOptions().setStacking(Stacking.NORMAL).setMarker( new Marker().setEnabled(false).setHoverState(new Marker().setEnabled(true).setRadius(5)))); powerChart.setColumnPlotOptions(new ColumnPlotOptions().setStacking(Stacking.NORMAL).setMarker( new Marker().setEnabled(false).setHoverState(new Marker().setEnabled(true).setRadius(5)))); powerChart.setLinePlotOptions(new LinePlotOptions().setMarker( new Marker().setEnabled(false).setHoverState(new Marker().setEnabled(true).setRadius(5)))); powerChart .setSeriesPlotOptions(new SeriesPlotOptions().setDataGrouping(new DataGrouping().setEnabled(true))); powerChart.getXAxis().setType(Axis.Type.DATE_TIME); powerChart.getXAxis().setAxisTitleText("Date"); powerChart.getYAxis(0).setType(Axis.Type.LINEAR); powerChart.getYAxis(0).setAxisTitleText("Total"); powerChart.getYAxis(0).setMinorTickIntervalAuto(); powerChart.getYAxis(0).setGridLineWidth(2); powerChart.getYAxis(1).setType(Axis.Type.LINEAR); powerChart.getYAxis(1).setAxisTitleText("Shares"); powerChart.getYAxis(1).setMinorTickIntervalAuto(); powerChart.getYAxis(1).setGridLineWidth(2); powerChart.getYAxis(1).setOpposite(true); acceptedMHSeries = powerChart.createSeries(); acceptedMHSeries.setType(Series.Type.AREA); acceptedMHSeries.setName("Accepted MH/s"); acceptedMHSeries.setStack("mhs"); acceptedMHSeries.setYAxis(0); acceptedMHSeries.setPlotOptions(new AreaPlotOptions().setShadow(false).setHoverStateLineWidth(2) .setColor(new Color(0, 170, 0, 0.5)).setFillOpacity(0.5)); powerChart.addSeries(acceptedMHSeries); rejectedMHSeries = powerChart.createSeries(); rejectedMHSeries.setType(Series.Type.AREA); rejectedMHSeries.setName("Rejected MH/s"); rejectedMHSeries.setStack("mhs"); rejectedMHSeries.setYAxis(0); rejectedMHSeries.setPlotOptions(new AreaPlotOptions().setShadow(false).setHoverStateLineWidth(2) .setColor(new Color(190, 0, 0, 0.5)).setFillOpacity(0.5)); powerChart.addSeries(rejectedMHSeries); final DateTimeFormat dtf = DateTimeFormat.getFormat("EEE d MMM HH:mm:ss"); final NumberFormat nf = NumberFormat.getFormat("#.##"); powerChart.setToolTip(new ToolTip().setFormatter(new ToolTipFormatter() { public String format(ToolTipData toolTipData) { String result = ""; AddressStatsDTO stat = getStatsFromDate(toolTipData.getXAsLong()); if (stat != null) { String rejectedMHPercentValue = nf.format((((stat.getRejectedMegaHashesPerSeconds()) * 100F) / (stat.getRejectedMegaHashesPerSeconds() + stat.getMegaHashesPerSeconds()))); result = "<b>Accepted MH/s:</b> " + formatPowerValue(stat.getMegaHashesPerSeconds()); result += "<br/><b>Rejected MH/s:</b> " + formatPowerValue(stat.getRejectedMegaHashesPerSeconds()); result += "<br/><b>Total MH/s:</b> " + formatPowerValue( (stat.getRejectedMegaHashesPerSeconds() + stat.getMegaHashesPerSeconds())); result += "<br/><b>% rejected:</b> " + rejectedMHPercentValue; result += "<br/><b>Date:</b> " + dtf.format(stat.getRefreshTime()); } return result; } }).setFollowPointer(true).setShadow(false).setUseHTML(true)); contentPanel.addResizeHandler(new ResizeHandler() { public void onResize(ResizeEvent event) { Scheduler.get().scheduleDeferred(new ScheduledCommand() { public void execute() { powerChart.setSizeToMatchContainer(); } }); } }); }
From source file:strat.mining.multipool.stats.client.mvp.view.coinshift.component.AddressChartPanel.java
License:Open Source License
private String formatPowerValue(Number value) { NumberFormat nf = NumberFormat.getFormat("0.000"); return nf.format(value); }
From source file:strat.mining.multipool.stats.client.mvp.view.coinshift.component.AddressChartPanel.java
License:Open Source License
public Widget createLastStatsPanel(AddressStatsDTO lastStats) { // Remove the last panel if (lastStatsPanel != null) { contentPanel.remove(lastStatsPanel); }/*from ww w . j a v a 2 s .com*/ lastStatsPanel = new HorizontalLayoutContainer(); HtmlLayoutContainerTemplate templates = GWT.create(HtmlLayoutContainerTemplate.class); HtmlLayoutContainer htmlLayout = new HtmlLayoutContainer(templates.getTemplate()); final DateTimeFormat dtf = DateTimeFormat.getFormat("EEE d MMM HH:mm:ss"); // Name labels Label balanceLabel = new Label("Balance: "); Label unexchangedLabel = new Label("Unexchanged: "); Label totalLabel = new Label("Total: "); Label paidoutLabel = new Label("Paid out: "); Label acceptedMegaHashLabel = new Label("Accepted MH/s: "); Label rejectedMegaHashLabel = new Label("Rejected MH/s: "); Label totalMegaHashLabel = new Label("Total MH/s: "); Label percentRejectedMegaHashLabel = new Label("% rejected MH/s: "); Label lastUpdateTimeLabel = new Label("Last update: "); // Values label NumberFormat nf = NumberFormat.getFormat("#.##"); String rejectedMHPercentValueString = ""; if (lastStats != null) { rejectedMHPercentValueString = nf.format((((lastStats.getRejectedMegaHashesPerSeconds()) * 100F) / (lastStats.getRejectedMegaHashesPerSeconds() + lastStats.getMegaHashesPerSeconds()))); } Label balanceValue = new Label(lastStats != null ? formatBTCValue(lastStats.getBalance()) : ""); Label unexchangedValue = new Label(lastStats != null ? formatBTCValue(lastStats.getUnexchanged()) : ""); paidoutAnchor = new Anchor(lastStats != null ? formatBTCValue(lastStats.getPaidOut()) : ""); Label totalValue = new Label( lastStats != null ? formatBTCValue(lastStats.getBalance() + lastStats.getUnexchanged()) : ""); Label acceptedMegaHashValue = new Label( lastStats != null ? formatPowerValue(lastStats.getMegaHashesPerSeconds()) : ""); Label rejectedMegaHashValue = new Label( lastStats != null ? formatPowerValue(lastStats.getRejectedMegaHashesPerSeconds()) : ""); Label totalMegaHashValue = new Label( lastStats != null ? formatPowerValue( (lastStats.getMegaHashesPerSeconds() + lastStats.getRejectedMegaHashesPerSeconds())) : ""); Label percentRejectedMegaHashValue = new Label(lastStats != null ? rejectedMHPercentValueString : ""); Label lastUpdateTimeValue = new Label(lastStats != null ? dtf.format(lastStats.getRefreshTime()) : ""); htmlLayout.add(balanceLabel, new HtmlData(".label1")); htmlLayout.add(unexchangedLabel, new HtmlData(".label2")); htmlLayout.add(totalLabel, new HtmlData(".label3")); htmlLayout.add(paidoutLabel, new HtmlData(".label4")); htmlLayout.add(acceptedMegaHashLabel, new HtmlData(".label5")); htmlLayout.add(rejectedMegaHashLabel, new HtmlData(".label6")); htmlLayout.add(totalMegaHashLabel, new HtmlData(".label7")); htmlLayout.add(percentRejectedMegaHashLabel, new HtmlData(".label8")); htmlLayout.add(lastUpdateTimeLabel, new HtmlData(".label9")); htmlLayout.add(balanceValue, new HtmlData(".value1")); htmlLayout.add(unexchangedValue, new HtmlData(".value2")); htmlLayout.add(totalValue, new HtmlData(".value3")); htmlLayout.add(paidoutAnchor, new HtmlData(".value4")); htmlLayout.add(acceptedMegaHashValue, new HtmlData(".value5")); htmlLayout.add(rejectedMegaHashValue, new HtmlData(".value6")); htmlLayout.add(totalMegaHashValue, new HtmlData(".value7")); htmlLayout.add(percentRejectedMegaHashValue, new HtmlData(".value8")); htmlLayout.add(lastUpdateTimeValue, new HtmlData(".value9")); lastStatsPanel.add(htmlLayout, new HorizontalLayoutData(650, 100, new Margins(5, 0, 5, 10))); ToolTipConfig config = new ToolTipConfig(); String tooltip = "<b>" + balanceLabel.getText() + "</b>" + balanceValue.getText(); tooltip += "<br/><b>" + unexchangedLabel.getText() + "</b>" + unexchangedValue.getText(); tooltip += "<br/><b>" + totalLabel.getText() + "</b>" + totalValue.getText(); tooltip += "<br/><b>" + paidoutLabel.getText() + "</b>" + paidoutAnchor.getText(); tooltip += "<br/><b>" + acceptedMegaHashLabel.getText() + "</b>" + acceptedMegaHashValue.getText(); tooltip += "<br/><b>" + rejectedMegaHashLabel.getText() + "</b>" + rejectedMegaHashValue.getText(); tooltip += "<br/><b>" + totalMegaHashLabel.getText() + "</b>" + totalMegaHashValue.getText(); tooltip += "<br/><b>" + percentRejectedMegaHashLabel.getText() + "</b>" + percentRejectedMegaHashValue.getText(); tooltip += "<br/><b>" + lastUpdateTimeLabel.getText() + "</b>" + lastUpdateTimeValue.getText(); config.setBodyHtml(tooltip); config.setTrackMouse(true); config.setDismissDelay(0); config.setHideDelay(0); htmlLayout.setToolTipConfig(config); return lastStatsPanel; }
From source file:strat.mining.multipool.stats.client.mvp.view.coinshift.component.GlobalChartPanel.java
License:Open Source License
private void initPowerChart() { powerChart = new Chart(); powerChart.setChartTitleText("Power"); powerChart.setHeight(350);/*from ww w. j av a 2s.c o m*/ powerChart.setZoomType(BaseChart.ZoomType.X); powerChart.setShadow(false); powerChart.setAnimation(false); powerChart.setOption("/plotOptions/series/turboThreshold", 10); powerChart.setAreaPlotOptions(new AreaPlotOptions().setStacking(Stacking.NORMAL).setMarker( new Marker().setEnabled(false).setHoverState(new Marker().setEnabled(true).setRadius(5)))); powerChart .setSeriesPlotOptions(new SeriesPlotOptions().setDataGrouping(new DataGrouping().setEnabled(true))); powerChart.setLinePlotOptions(new LinePlotOptions().setOption("turboThreshold", 10).setMarker( new Marker().setEnabled(false).setHoverState(new Marker().setEnabled(true).setRadius(5)))); powerChart.getXAxis().setType(Axis.Type.DATE_TIME); powerChart.getXAxis().setAxisTitleText("Date"); powerChart.getYAxis(0).setType(Axis.Type.LINEAR); powerChart.getYAxis(0).setAxisTitleText("MH/s"); powerChart.getYAxis(0).setMinorTickIntervalAuto(); powerChart.getYAxis(0).setGridLineWidth(2); acceptedMHSeries = powerChart.createSeries(); acceptedMHSeries.setType(Series.Type.AREA); acceptedMHSeries.setName("Accepted MH/s"); acceptedMHSeries.setStack("mhs"); acceptedMHSeries.setYAxis(0); acceptedMHSeries.setPlotOptions(new AreaPlotOptions().setShadow(false).setHoverStateLineWidth(2) .setColor(new Color(0, 170, 0, 0.5)).setFillOpacity(0.5)); powerChart.addSeries(acceptedMHSeries); rejectedMHSeries = powerChart.createSeries(); rejectedMHSeries.setType(Series.Type.AREA); rejectedMHSeries.setName("Rejected MH/s"); rejectedMHSeries.setStack("mhs"); rejectedMHSeries.setYAxis(0); rejectedMHSeries.setPlotOptions(new LinePlotOptions().setShadow(false).setHoverStateLineWidth(2) .setColor(new Color(240, 0, 0, 0.5)).setMarker( new Marker().setEnabled(false).setHoverState(new Marker().setEnabled(true).setRadius(5)))); powerChart.addSeries(rejectedMHSeries); final DateTimeFormat dtf = DateTimeFormat.getFormat("EEE d MMM HH:mm:ss"); final NumberFormat nf = NumberFormat.getFormat("#.##"); powerChart.setToolTip(new ToolTip().setFormatter(new ToolTipFormatter() { public String format(ToolTipData toolTipData) { String result = ""; GlobalStatsDTO stat = getStatsFromDate(toolTipData.getXAsLong()); if (stat != null) { String rejectedMHPercentValue = nf.format((((stat.getTotalRejectedMegahashesPerSecond()) * 100F) / (stat.getTotalRejectedMegahashesPerSecond() + stat.getTotalMegahashesPerSecond()))); result = "<b>Accepted MH/s:</b> " + formatPowerValue(stat.getTotalMegahashesPerSecond()); result += "<br/><b>Rejected MH/s:</b> " + formatPowerValue(stat.getTotalRejectedMegahashesPerSecond()); result += "<br/><b>Total MH/s:</b> " + formatPowerValue( (stat.getTotalMegahashesPerSecond() + stat.getTotalRejectedMegahashesPerSecond())); result += "<br/><b>% rejected:</b> " + rejectedMHPercentValue; result += "<br/><b>Date:</b> " + dtf.format(stat.getRefreshTime()); } return result; } }).setFollowPointer(true).setShadow(false).setUseHTML(true)); contentPanel.addResizeHandler(new ResizeHandler() { public void onResize(ResizeEvent event) { Scheduler.get().scheduleDeferred(new ScheduledCommand() { public void execute() { powerChart.setSizeToMatchContainer(); } }); } }); }
From source file:strat.mining.multipool.stats.client.mvp.view.coinshift.component.GlobalChartPanel.java
License:Open Source License
private String formatPowerValue(Number value) { NumberFormat nf = NumberFormat.getFormat("#.###"); return nf.format(value); }