Search in sources :

Example 6 with TranscodeFile

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;
}
Also used : DiskManagerFileInfo(com.biglybt.pif.disk.DiskManagerFileInfo) ISelectedContent(com.biglybt.ui.selectedcontent.ISelectedContent) DownloadException(com.biglybt.pif.download.DownloadException) TranscodeFile(com.biglybt.core.devices.TranscodeFile) DownloadManager(com.biglybt.core.download.DownloadManager) DownloadException(com.biglybt.pif.download.DownloadException) TranscodeJob(com.biglybt.core.devices.TranscodeJob)

Example 7 with TranscodeFile

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));
}
Also used : TranscodeFile(com.biglybt.core.devices.TranscodeFile)

Example 8 with TranscodeFile

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() : "");
}
Also used : TranscodeFile(com.biglybt.core.devices.TranscodeFile)

Example 9 with TranscodeFile

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);
        }
    }
}
Also used : TranscodeFile(com.biglybt.core.devices.TranscodeFile) TranscodeJob(com.biglybt.core.devices.TranscodeJob)

Example 10 with TranscodeFile

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);
}
Also used : TranscodeFile(com.biglybt.core.devices.TranscodeFile) ImageLoader(com.biglybt.ui.swt.imageloader.ImageLoader)

Aggregations

TranscodeFile (com.biglybt.core.devices.TranscodeFile)14 TranscodeJob (com.biglybt.core.devices.TranscodeJob)4 DownloadManager (com.biglybt.core.download.DownloadManager)2 DiskManagerFileInfo (com.biglybt.pif.disk.DiskManagerFileInfo)2 DownloadException (com.biglybt.pif.download.DownloadException)2 ISelectedContent (com.biglybt.ui.selectedcontent.ISelectedContent)2 ActivitiesEntry (com.biglybt.activities.ActivitiesEntry)1 Device (com.biglybt.core.devices.Device)1 DeviceMediaRenderer (com.biglybt.core.devices.DeviceMediaRenderer)1 TranscodeTargetListener (com.biglybt.core.devices.TranscodeTargetListener)1 GlobalManager (com.biglybt.core.global.GlobalManager)1 TagDownload (com.biglybt.core.tag.TagDownload)1 TOTorrent (com.biglybt.core.torrent.TOTorrent)1 HashWrapper (com.biglybt.core.util.HashWrapper)1 Download (com.biglybt.pif.download.Download)1 Torrent (com.biglybt.pif.torrent.Torrent)1 ImageLoader (com.biglybt.ui.swt.imageloader.ImageLoader)1