use of com.codename1.db.Row in project CodenameOne by codenameone.
the class Table method createCell.
/**
* Creates a cell based on the given value
*
* @param value the new value object
* @param row row number, -1 for the header rows
* @param column column number
* @param editable true if the cell is editable
* @return cell component instance
*/
protected Component createCell(Object value, int row, final int column, boolean editable) {
if (row == -1) {
Button header = new Button((String) value, getUIID() + "Header");
header.getAllStyles().setAlignment(titleAlignment);
header.setTextPosition(LEFT);
if (isSortSupported()) {
header.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
Comparator cmp = createColumnSortComparator(column);
if (cmp == null) {
return;
}
if (column == sortedColumn) {
ascending = !ascending;
} else {
sortedColumn = column;
ascending = false;
}
setModel(new SortableTableModel(sortedColumn, ascending, model, cmp));
}
});
if (sortedColumn == column) {
if (ascending) {
FontImage.setMaterialIcon(header, FontImage.MATERIAL_ARROW_DROP_UP);
} else {
FontImage.setMaterialIcon(header, FontImage.MATERIAL_ARROW_DROP_DOWN);
}
}
}
return header;
}
if (editable) {
TextField cell = new TextField("" + value, -1);
cell.setLeftAndRightEditingTrigger(false);
cell.setUIID(getUIID() + "Cell");
return cell;
}
Label cell = new Label("" + value);
cell.setUIID(getUIID() + "Cell");
cell.getUnselectedStyle().setAlignment(cellAlignment);
cell.getSelectedStyle().setAlignment(cellAlignment);
cell.setFocusable(true);
return cell;
}
use of com.codename1.db.Row in project CodenameOne by codenameone.
the class CN1ImageLuminanceSource method getRow.
// Instead of multiplying by 306, 601, 117, we multiply by 256, 512, 256, so that
// the multiplies can be implemented as shifts.
//
// Really, it's:
//
// return ((((pixel >> 16) & 0xFF) << 8) +
// (((pixel >> 8) & 0xFF) << 9) +
// (( pixel & 0xFF) << 8)) >> 10;
//
// That is, we're replacing the coefficients in the original with powers of two,
// which can be implemented as shifts, even though changing the coefficients slightly
// alters the conversion. The difference is not significant for our purposes.
public byte[] getRow(int y, byte[] row) {
if (y < 0 || y >= getHeight()) {
throw new IllegalArgumentException("Requested row is outside the image: " + y);
}
int width = getWidth();
if (row == null || row.length < width) {
row = new byte[width];
}
/*
* if (rgbData == null || rgbData.length < width) { rgbData = new
* int[width]; }
*/
// image.getRGB(rgbData, 0, width, 0, y, width, 1);
// For LWUIT Image get the row as sub image without alpha processing,
// as we don't need alpha channel anyway
Image rowImg = image.subImage(0, y, width, 1, false);
rgbData = rowImg.getRGB();
for (int x = 0; x < width; x++) {
row[x] = toLuminance(rgbData[x]);
}
return row;
}
Aggregations