use of com.biglybt.core.devices.TranscodeFile in project BiglyBT by BiglySoftware.
the class DataSourceUtils method getFileInfo.
public static com.biglybt.core.disk.DiskManagerFileInfo getFileInfo(Object ds) {
try {
if (ds instanceof DiskManagerFileInfo) {
return PluginCoreUtils.unwrap((DiskManagerFileInfo) ds);
} else if (ds instanceof com.biglybt.core.disk.DiskManagerFileInfo) {
return (com.biglybt.core.disk.DiskManagerFileInfo) ds;
} else if ((ds instanceof ISelectedContent) && ((ISelectedContent) ds).getFileIndex() >= 0) {
ISelectedContent sc = (ISelectedContent) ds;
int idx = sc.getFileIndex();
DownloadManager dm = sc.getDownloadManager();
return dm.getDiskManagerFileInfoSet().getFiles()[idx];
} else if (ds instanceof TranscodeJob) {
TranscodeJob tj = (TranscodeJob) ds;
try {
return PluginCoreUtils.unwrap(tj.getFile());
} catch (DownloadException e) {
}
} else if (ds instanceof TranscodeFile) {
TranscodeFile tf = (TranscodeFile) ds;
try {
DiskManagerFileInfo file = tf.getSourceFile();
return PluginCoreUtils.unwrap(file);
} catch (DownloadException e) {
}
}
} catch (Exception e) {
Debug.printStackTrace(e);
}
return null;
}
use of com.biglybt.core.devices.TranscodeFile in project BiglyBT by BiglySoftware.
the class ColumnTJ_Duration method refresh.
// @see com.biglybt.pif.ui.tables.TableCellRefreshListener#refresh(com.biglybt.pif.ui.tables.TableCell)
@Override
public void refresh(TableCell cell) {
TranscodeFile tf = (TranscodeFile) cell.getDataSource();
if (tf == null) {
return;
}
long duration = tf.getDurationMillis();
cell.setText(duration == 0 ? "" : TimeFormatter.format(duration / 1000));
}
use of com.biglybt.core.devices.TranscodeFile in project BiglyBT by BiglySoftware.
the class ColumnTJ_Profile method refresh.
// @see com.biglybt.pif.ui.tables.TableCellRefreshListener#refresh(com.biglybt.pif.ui.tables.TableCell)
@Override
public void refresh(TableCell cell) {
TranscodeFile tf = (TranscodeFile) cell.getDataSource();
if (tf == null) {
return;
}
cell.setText(tf.getTranscodeRequired() ? tf.getProfileName() : "");
}
use of com.biglybt.core.devices.TranscodeFile in project BiglyBT by BiglySoftware.
the class ColumnTJ_Rank method refresh.
// @see com.biglybt.pif.ui.tables.TableCellRefreshListener#refresh(com.biglybt.pif.ui.tables.TableCell)
@Override
public void refresh(TableCell cell) {
TranscodeFile tf = (TranscodeFile) cell.getDataSource();
if (tf == null) {
return;
}
TranscodeJob job = tf.getJob();
long value;
if (job == null) {
try {
value = Integer.MAX_VALUE + tf.getCreationDateMillis() + 1;
} catch (Throwable t) {
value = Integer.MAX_VALUE + 1L;
}
} else {
value = job.getIndex();
}
if (cell.setSortValue(value) || !cell.isValid()) {
if (value > Integer.MAX_VALUE) {
cell.setText("");
} else {
cell.setText("" + value);
}
}
}
use of com.biglybt.core.devices.TranscodeFile in project BiglyBT by BiglySoftware.
the class ColumnTJ_Completion method cellPaint.
@Override
public void cellPaint(GC gcImage, TableCellSWT cell) {
TranscodeFile tf = (TranscodeFile) cell.getDataSource();
int perThouDone = getPerThouDone(tf);
Rectangle bounds = cell.getBounds();
int yOfs = (bounds.height - 13) / 2;
int x1 = bounds.width - borderWidth - 2;
int y1 = bounds.height - 3 - yOfs;
if (x1 < 10 || y1 < 3) {
return;
}
ImageLoader imageLoader = ImageLoader.getInstance();
Image imgEnd = imageLoader.getImage("tc_bar_end");
Image img0 = imageLoader.getImage("tc_bar_0");
Image img1 = imageLoader.getImage("tc_bar_1");
// draw begining and end
if (!imgEnd.isDisposed()) {
gcImage.drawImage(imgEnd, bounds.x, bounds.y + yOfs);
gcImage.drawImage(imgEnd, bounds.x + x1 + 1, bounds.y + yOfs);
}
int limit = (x1 * perThouDone) / 1000;
if (!img1.isDisposed() && limit > 0) {
Rectangle imgBounds = img1.getBounds();
gcImage.drawImage(img1, 0, 0, imgBounds.width, imgBounds.height, bounds.x + 1, bounds.y + yOfs, limit, imgBounds.height);
}
if (perThouDone < 1000 && !img0.isDisposed()) {
Rectangle imgBounds = img0.getBounds();
gcImage.drawImage(img0, 0, 0, imgBounds.width, imgBounds.height, bounds.x + limit + 1, bounds.y + yOfs, x1 - limit, imgBounds.height);
}
imageLoader.releaseImage("tc_bar_end");
imageLoader.releaseImage("tc_bar_0");
imageLoader.releaseImage("tc_bar_1");
if (textColor == null) {
textColor = ColorCache.getColor(gcImage.getDevice(), "#006600");
}
gcImage.setForeground(textColor);
if (fontText == null) {
fontText = FontUtils.getFontWithHeight(gcImage.getFont(), 10, SWT.DEFAULT);
}
gcImage.setFont(fontText);
String sText;
if (tf != null && perThouDone == 1000 && !tf.getTranscodeRequired()) {
sText = na_text;
} else {
// DisplayFormatters.formatPercentFromThousands(perThouDone);
sText = percentage_format.format(perThouDone / 1000.0);
if (tf != null && perThouDone < 1000) {
String eta = getETA(tf);
if (eta != null) {
sText += " - " + eta;
}
}
}
GCStringPrinter.printString(gcImage, sText, new Rectangle(bounds.x + 4, bounds.y + yOfs, bounds.width - 4, 13), true, false, SWT.CENTER);
}
Aggregations