use of com.cpjd.roblu.models.metrics.RStopwatch in project Roblu by wdavies973.
the class CheckoutEncoder method encodeCheckout.
/**
* This method will encode a checkout with as little overhead as possible (as opposed to JSON
* serialization). This method is used for QR serialization to minimize the data transfer, since
* compression isn't supported well by QR. This could be expanded for the whole project, but isn't really versatile enough yet.
* @return The encoded string
*/
public String encodeCheckout(String nameTag, RCheckout checkout) {
StringBuilder builder = new StringBuilder();
// Checkout components
builder.append(checkout.getID()).append("\n");
builder.append(nameTag).append("\n");
// Team meta
builder.append(checkout.getTeam().getID()).append("\n");
builder.append(checkout.getTeam().getLastEdit()).append("\n");
// Tabs!
for (RTab tab : checkout.getTeam().getTabs()) {
builder.append("TAB").append(tab.getTitle()).append("\n");
builder.append(tab.isWon()).append("\n");
// Edits
builder.append("EDITS");
if (tab.getEdits() != null) {
for (Object o : tab.getEdits().keySet()) {
builder.append(",");
if (o.toString().equals(""))
builder.append("Unknown");
else
builder.append(o.toString());
// EDITS,will:120391823,john,12039123
builder.append(",").append(tab.getEdits().get(o.toString()));
}
}
builder.append("\n");
// -RDivider and RCalculation don't need to be encoded since they don't contain any user information
for (RMetric metric : tab.getMetrics()) {
builder.append(getMetricType(metric)).append(DELIMITER).append(metric.getID()).append(DELIMITER).append(metric.getTitle()).append(DELIMITER).append(metric.isModified()).append(DELIMITER);
if (metric instanceof RBoolean)
builder.append(((RBoolean) metric).isValue());
else if (metric instanceof RCheckbox) {
if (((RCheckbox) metric).getValues() != null) {
for (Object o : ((RCheckbox) metric).getValues().keySet()) {
// :(title,value):(title,value):
builder.append("(").append(o.toString()).append(",").append(((RCheckbox) metric).getValues().get(o.toString())).append(")").append(DELIMITER);
}
}
} else if (metric instanceof RChooser) {
builder.append(((RChooser) metric).getSelectedIndex()).append(DELIMITER);
if (((RChooser) metric).getValues() != null) {
for (String s : ((RChooser) metric).getValues()) {
// :1:option:option:option:
builder.append(s).append(DELIMITER);
}
}
} else if (metric instanceof RCounter)
builder.append(((RCounter) metric).isVerboseInput()).append(DELIMITER).append(((RCounter) metric).getValue()).append(DELIMITER).append(((RCounter) metric).getIncrement());
else if (metric instanceof RSlider)
builder.append(((RSlider) metric).getValue()).append(DELIMITER).append(((RSlider) metric).getMin()).append(DELIMITER).append(((RSlider) metric).getMax());
else if (metric instanceof RStopwatch) {
builder.append(((RStopwatch) metric).getTime()).append(DELIMITER);
if (((RStopwatch) metric).getTimes() != null) {
for (Double t : ((RStopwatch) metric).getTimes()) {
// :curr:1:2:3:
builder.append(t).append(DELIMITER);
}
}
} else if (metric instanceof RTextfield)
builder.append(((RTextfield) metric).getText());
builder.append("\n");
}
}
return builder.toString();
}
use of com.cpjd.roblu.models.metrics.RStopwatch in project Roblu by wdavies973.
the class MatchData method generateSheet.
@Override
public void generateSheet(XSSFSheet sheet, REvent event, RForm form, RTeam[] teams, ArrayList<RCheckout> checkouts) {
/*
* Output the headers
*/
Row row = createRow(sheet);
createCell(row, 0, "Team Number");
createCell(row, 1, "Match number");
for (int i = 0; i < form.getMatch().size(); i++) {
createCell(row, i + 2, form.getMatch().get(i).getTitle());
}
/*
* Output the data
*/
for (RCheckout checkout : checkouts) {
if (checkout.getTeam().getTabs().get(0).getTitle().equalsIgnoreCase("PIT") || checkout.getTeam().getTabs().get(0).getTitle().equalsIgnoreCase("PREDICTIONS"))
continue;
Row data = createRow(sheet);
Cell cs = data.createCell(0);
cs.setCellValue(checkout.getTeam().getNumber());
cs.setCellStyle(getStyle());
createCell(data, 1, checkout.getTeam().getTabs().get(0).getTitle().replace("Quals ", ""));
int index = 0;
for (RMetric metric : checkout.getTeam().getTabs().get(0).getMetrics()) {
if (shouldWriteMetric(checkout.getTeam(), metric)) {
if (metric instanceof RStopwatch)
createCell(data, index + 2, ((RStopwatch) metric).getLapsString());
else if (metric instanceof RCalculation)
createCell(data, index + 2, ((RCalculation) metric).getValue(checkout.getTeam().getTabs().get(0).getMetrics()));
else if (metric instanceof RFieldData)
continue;
else
createCell(data, index + 2, metric.toString());
} else
createCell(data, index + 2, "");
index++;
}
}
}
Aggregations