use of com.biglybt.ui.swt.imageloader.ImageLoader in project BiglyBT by BiglySoftware.
the class CompletionItem method cellPaint.
// @see com.biglybt.ui.swt.views.table.TableCellSWTPaintListener#cellPaint(org.eclipse.swt.graphics.GC, com.biglybt.ui.swt.views.table.TableCellSWT)
@Override
public void cellPaint(GC gcImage, TableCellSWT cell) {
int percentDone = getPercentDone(cell);
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;
}
int textYofs = 0;
if (y1 >= 28) {
yOfs = 2;
y1 = 16;
// textYofs = yOfs;
}
mapCellLastPercentDone.put(cell, new Integer(percentDone));
ImageLoader imageLoader = ImageLoader.getInstance();
Image imgEnd = imageLoader.getImage("dl_bar_end");
Image img0 = imageLoader.getImage("dl_bar_0");
Image img1 = imageLoader.getImage("dl_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);
}
// draw border
// Color fg = gcImage.getForeground();
// gcImage.setForeground(Colors.grey);
// gcImage.drawRectangle(bounds.x, bounds.y + yOfs, x1 + 1, y1 + 1);
// gcImage.setForeground(fg);
int limit = (x1 * percentDone) / 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 (percentDone < 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("dl_bar_end");
imageLoader.releaseImage("dl_bar_0");
imageLoader.releaseImage("dl_bar_1");
if (textColor == null) {
textColor = ColorCache.getColor(gcImage.getDevice(), "#005ACF");
}
// if (textYofs == 0) {
// if (fontText == null) {
// fontText = Utils.getFontWithHeight(gcImage.getFont(), gcImage, y1);
// }
// gcImage.setFont(fontText);
gcImage.setForeground(textColor);
// }
String sPercent = DisplayFormatters.formatPercentFromThousands(percentDone);
GCStringPrinter.printString(gcImage, sPercent, new Rectangle(bounds.x + 4, bounds.y + yOfs, bounds.width - 4, 13), true, false, SWT.CENTER);
}
use of com.biglybt.ui.swt.imageloader.ImageLoader in project BiglyBT by BiglySoftware.
the class AnimatedImage method setImageFromName.
public void setImageFromName(String imageName) {
this.imageName = imageName;
ImageLoader imageLoader = ImageLoader.getInstance();
images = imageLoader.getImages(imageName);
}
use of com.biglybt.ui.swt.imageloader.ImageLoader in project BiglyBT by BiglySoftware.
the class AnimatedImage method disposeImages.
private void disposeImages() {
if (images != null) {
ImageLoader imageLoader = ImageLoader.getInstance();
imageLoader.releaseImage(imageName);
images = null;
}
}
use of com.biglybt.ui.swt.imageloader.ImageLoader in project BiglyBT by BiglySoftware.
the class ConfigSectionQueue method configSectionCreate.
/**
* Create the "Queue" Tab in the Configuration view
*/
@Override
public Composite configSectionCreate(Composite parent) {
GridData gridData;
GridLayout layout;
Label label;
// main tab set up
Composite cSection = new Composite(parent, SWT.NULL);
gridData = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL);
Utils.setLayoutData(cSection, gridData);
layout = new GridLayout();
layout.numColumns = 2;
layout.marginHeight = 0;
cSection.setLayout(layout);
// row
label = new Label(cSection, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.label.maxdownloads");
gridData = new GridData();
final IntParameter maxDLs = new IntParameter(cSection, "max downloads", 0, Integer.MAX_VALUE);
maxDLs.setLayoutData(gridData);
// subrow - ignore checking downloads
final Composite cMaxDownloads = new Composite(cSection, SWT.NULL);
layout = new GridLayout();
layout.numColumns = 3;
layout.marginWidth = 0;
layout.marginHeight = 0;
cMaxDownloads.setLayout(layout);
gridData = new GridData();
gridData.horizontalIndent = 15;
gridData.horizontalSpan = 2;
Utils.setLayoutData(cMaxDownloads, gridData);
ImageLoader imageLoader = ImageLoader.getInstance();
label = new Label(cMaxDownloads, SWT.NULL);
imageLoader.setLabelImage(label, "subitem");
gridData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
Utils.setLayoutData(label, gridData);
label = new Label(cMaxDownloads, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.label.ignoreChecking");
gridData = new GridData();
BooleanParameter ignoreChecking = new BooleanParameter(cMaxDownloads, "StartStopManager_bMaxDownloadIgnoreChecking");
ignoreChecking.setLayoutData(gridData);
// row
label = new Label(cSection, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.label.maxactivetorrents");
gridData = new GridData();
final IntParameter maxActiv = new IntParameter(cSection, "max active torrents", 0, Integer.MAX_VALUE);
maxActiv.setLayoutData(gridData);
final Composite cMaxActiveOptionsArea = new Composite(cSection, SWT.NULL);
layout = new GridLayout();
layout.numColumns = 3;
layout.marginWidth = 0;
layout.marginHeight = 0;
cMaxActiveOptionsArea.setLayout(layout);
gridData = new GridData();
gridData.horizontalIndent = 15;
gridData.horizontalSpan = 2;
Utils.setLayoutData(cMaxActiveOptionsArea, gridData);
label = new Label(cMaxActiveOptionsArea, SWT.NULL);
imageLoader.setLabelImage(label, "subitem");
gridData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
Utils.setLayoutData(label, gridData);
gridData = new GridData();
BooleanParameter maxActiveWhenSeedingEnabled = new BooleanParameter(cMaxActiveOptionsArea, "StartStopManager_bMaxActiveTorrentsWhenSeedingEnabled", "ConfigView.label.queue.maxactivetorrentswhenseeding");
maxActiveWhenSeedingEnabled.setLayoutData(gridData);
gridData = new GridData();
final IntParameter maxActivWhenSeeding = new IntParameter(cMaxActiveOptionsArea, "StartStopManager_iMaxActiveTorrentsWhenSeeding", 0, Integer.MAX_VALUE);
maxActivWhenSeeding.setLayoutData(gridData);
// min downloads
label = new Label(cSection, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.label.mindownloads");
gridData = new GridData();
final IntParameter minDLs = new IntParameter(cSection, "min downloads", 0, Integer.MAX_VALUE);
minDLs.setLayoutData(gridData);
// / 2);
minDLs.setMaximumValue(maxDLs.getValue());
final Composite cMinMaxLink = new Composite(cSection, SWT.NULL);
layout = new GridLayout();
layout.numColumns = 3;
layout.marginWidth = 0;
layout.marginHeight = 0;
cMinMaxLink.setLayout(layout);
gridData = new GridData();
gridData.horizontalIndent = 15;
gridData.horizontalSpan = 2;
Utils.setLayoutData(cMinMaxLink, gridData);
label = new Label(cMinMaxLink, SWT.NULL);
imageLoader.setLabelImage(label, "subitem");
gridData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
Utils.setLayoutData(label, gridData);
gridData = new GridData();
gridData.horizontalSpan = 2;
BooleanParameter minmaxlink = new BooleanParameter(cMinMaxLink, "StartStopManager_bMaxMinDLLinked", "ConfigView.label.maxmindownloadlinked");
minmaxlink.setLayoutData(gridData);
minmaxlink.addChangeListener(new ParameterChangeAdapter() {
@Override
public void parameterChanged(Parameter p, boolean caused_internally) {
minDLs.setEnabled(!minmaxlink.isSelected());
}
});
minDLs.setEnabled(!minmaxlink.isSelected());
// change controllers for above items
maxActiveWhenSeedingEnabled.setAdditionalActionPerformer(new ChangeSelectionActionPerformer(maxActivWhenSeeding));
maxDLs.addChangeListener(new ParameterChangeAdapter() {
@Override
public void parameterChanged(Parameter p, boolean caused_internally) {
int iMaxDLs = maxDLs.getValue();
// / 2);
minDLs.setMaximumValue(iMaxDLs);
int iMinDLs = minDLs.getValue();
int iMaxActive = maxActiv.getValue();
if ((iMaxDLs == 0 || iMaxDLs > iMaxActive) && iMaxActive != 0) {
maxActiv.setValue(iMaxDLs);
}
}
});
maxActiv.addChangeListener(new ParameterChangeAdapter() {
@Override
public void parameterChanged(Parameter p, boolean caused_internally) {
int iMaxDLs = maxDLs.getValue();
int iMaxActive = maxActiv.getValue();
if ((iMaxDLs == 0 || iMaxDLs > iMaxActive) && iMaxActive != 0) {
maxDLs.setValue(iMaxActive);
}
}
});
// row
final ArrayList values = new ArrayList();
int exp = 29;
for (int val = 0; val <= 8 * 1024 * 1024; ) {
values.add(new Integer(val));
if (val < 256)
val += 64;
else if (val < 1024)
val += 256;
else if (val < 16 * 1024)
val += 1024;
else
val = (int) (Math.pow(2, exp++ / 2) + (exp % 2 == 0 ? Math.pow(2, (exp - 3) / 2) : 0));
}
String[] activeDLLabels = new String[values.size()];
int[] activeDLValues = new int[activeDLLabels.length];
label = new Label(cSection, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.label.minSpeedForActiveDL");
for (int i = 0; i < activeDLLabels.length; i++) {
activeDLValues[i] = ((Integer) values.get(i)).intValue();
activeDLLabels[i] = DisplayFormatters.formatByteCountToKiBEtcPerSec(activeDLValues[i], true);
}
new IntListParameter(cSection, "StartStopManager_iMinSpeedForActiveDL", activeDLLabels, activeDLValues);
// row
label = new Label(cSection, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.label.minSpeedForActiveSeeding");
String[] activeSeedingLabels = new String[values.size() - 4];
int[] activeSeedingValues = new int[activeSeedingLabels.length];
System.arraycopy(activeDLLabels, 0, activeSeedingLabels, 0, activeSeedingLabels.length);
System.arraycopy(activeDLValues, 0, activeSeedingValues, 0, activeSeedingValues.length);
new IntListParameter(cSection, "StartStopManager_iMinSpeedForActiveSeeding", activeSeedingLabels, activeSeedingValues);
// subrow
final Composite cMinSpeedActiveCDing = new Composite(cSection, SWT.NULL);
layout = new GridLayout();
layout.numColumns = 3;
layout.marginWidth = 0;
layout.marginHeight = 0;
cMinSpeedActiveCDing.setLayout(layout);
gridData = new GridData();
gridData.horizontalIndent = 15;
gridData.horizontalSpan = 2;
Utils.setLayoutData(cMinSpeedActiveCDing, gridData);
label = new Label(cMinSpeedActiveCDing, SWT.NULL);
imageLoader.setLabelImage(label, "subitem");
gridData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
Utils.setLayoutData(label, gridData);
label = new Label(cMinSpeedActiveCDing, SWT.NULL);
Messages.setLanguageText(label, "ConfigView.label.maxStalledSeeding");
gridData = new GridData();
final IntParameter maxStalledSeeding = new IntParameter(cMinSpeedActiveCDing, "StartStopManager_iMaxStalledSeeding", 0, Integer.MAX_VALUE);
maxStalledSeeding.setMinimumValue(0);
maxStalledSeeding.setLayoutData(gridData);
label = new Label(cMinSpeedActiveCDing, SWT.NULL);
imageLoader.setLabelImage(label, "subitem");
gridData = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
Utils.setLayoutData(label, gridData);
gridData = new GridData();
gridData.horizontalSpan = 2;
new BooleanParameter(cMinSpeedActiveCDing, "StartStopManager_bMaxStalledSeedingIgnoreZP", "ConfigView.label.maxStalledSeedingIgnoreZP").setLayoutData(gridData);
// row
gridData = new GridData();
gridData.horizontalSpan = 2;
new BooleanParameter(cSection, "StartStopManager_bStopOnceBandwidthMet", "ConfigView.label.queue.stoponcebandwidthmet").setLayoutData(gridData);
// row
gridData = new GridData();
gridData.horizontalSpan = 2;
new BooleanParameter(cSection, "StartStopManager_bNewSeedsMoveTop", "ConfigView.label.queue.newseedsmovetop").setLayoutData(gridData);
// row
gridData = new GridData();
gridData.horizontalSpan = 2;
new BooleanParameter(cSection, "StartStopManager_bRetainForceStartWhenComplete", "ConfigView.label.queue.retainforce").setLayoutData(gridData);
// row
gridData = new GridData();
gridData.horizontalSpan = 2;
new BooleanParameter(cSection, "Alert on close", "ConfigView.label.showpopuponclose").setLayoutData(gridData);
// row
gridData = new GridData();
gridData.horizontalSpan = 2;
new BooleanParameter(cSection, "StartStopManager_bDebugLog", "ConfigView.label.queue.debuglog").setLayoutData(gridData);
return cSection;
}
use of com.biglybt.ui.swt.imageloader.ImageLoader in project BiglyBT by BiglySoftware.
the class AboutWindow method _show.
private static void _show() {
if (instance != null) {
instance.open();
return;
}
paintColorTo = 0;
final Shell window = ShellFactory.createMainShell(SWT.DIALOG_TRIM);
Utils.setShellIcon(window);
final Display display = window.getDisplay();
window.setText(MessageText.getString("MainWindow.about.title") + " " + Constants.getCurrentVersion());
GridData gridData;
window.setLayout(new GridLayout(2, false));
ImageLoader imageLoader = ImageLoader.getInstance();
imgSrc = imageLoader.getImage(IMG_SPLASH);
if (imgSrc != null) {
int w = imgSrc.getBounds().width;
int ow = w;
int h = imgSrc.getBounds().height;
Image imgGray = new Image(display, imageLoader.getImage(IMG_SPLASH), SWT.IMAGE_GRAY);
imageLoader.releaseImage(IMG_SPLASH);
GC gc = new GC(imgGray);
if (Constants.isOSX) {
gc.drawImage(imgGray, (w - ow) / 2, 0);
} else {
gc.copyArea(0, 0, ow, h, (w - ow) / 2, 0);
}
gc.dispose();
Image image2 = new Image(display, w, h);
gc = new GC(image2);
gc.setBackground(window.getBackground());
gc.fillRectangle(image2.getBounds());
gc.dispose();
imageToDispose = image = Utils.renderTransparency(display, image2, imgGray, new Point(0, 0), 180);
image2.dispose();
imgGray.dispose();
}
final Canvas labelImage = new Canvas(window, SWT.DOUBLE_BUFFERED);
// labelImage.setImage(image);
gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL);
gridData.horizontalSpan = 2;
gridData.horizontalIndent = gridData.verticalIndent = 0;
final Rectangle imgBounds = image.getBounds();
final Rectangle boundsColor = imgSrc.getBounds();
gridData.widthHint = Utils.adjustPXForDPI(300);
gridData.heightHint = imgBounds.height + imgBounds.y + 20;
labelImage.setLayoutData(gridData);
labelImage.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
try {
Rectangle clipping = e.gc.getClipping();
int ofs = (labelImage.getSize().x - boundsColor.width) / 2;
if (paintColorTo > 0) {
e.gc.drawImage(imgSrc, 0, 0, paintColorTo, boundsColor.height, ofs, 10, paintColorTo, boundsColor.height);
}
if (clipping.x + clipping.width > ofs + paintColorTo && imgBounds.width - paintColorTo - 1 > 0) {
e.gc.drawImage(image, paintColorTo + 1, 0, imgBounds.width - paintColorTo - 1, imgBounds.height, paintColorTo + 1 + ofs, 10, imgBounds.width - paintColorTo - 1, imgBounds.height);
}
} catch (Throwable f) {
// seen some 'argument not valid errors spewed here, couldn't track down
// the cause though :( parg.
}
}
});
Group gInternet = new Group(window, SWT.NULL);
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 2;
gridLayout.makeColumnsEqualWidth = true;
gInternet.setLayout(gridLayout);
// $NON-NLS-1$
Messages.setLanguageText(gInternet, "MainWindow.about.section.internet");
gridData = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL);
Utils.setLayoutData(gInternet, gridData);
Group gSys = new Group(window, SWT.NULL);
gSys.setLayout(new GridLayout());
// $NON-NLS-1$
Messages.setLanguageText(gSys, "MainWindow.about.section.system");
gridData = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL);
gridData.verticalSpan = 1;
Utils.setLayoutData(gSys, gridData);
String swt = "";
if (Utils.isGTK) {
try {
swt = "/" + System.getProperty("org.eclipse.swt.internal.gtk.version");
} catch (Throwable e1) {
// TODO Auto-generated catch block
}
}
Text txtSysInfo = new Text(gSys, SWT.READ_ONLY | SWT.MULTI | SWT.WRAP);
txtSysInfo.setBackground(Colors.getSystemColor(display, SWT.COLOR_WIDGET_BACKGROUND));
String about_text = "Java " + System.getProperty("java.version") + " (" + (Constants.is64Bit ? 64 : 32) + " bit)\n " + System.getProperty("java.vendor") + "\n" + System.getProperty("java.home") + "\n\n" + "SWT v" + SWT.getVersion() + ", " + SWT.getPlatform() + swt + "\n" + System.getProperty("os.name") + " v" + System.getProperty("os.version") + ", " + System.getProperty("os.arch") + " (" + (Constants.isOS64Bit ? 64 : 32) + " bit)\n" + Constants.APP_NAME.charAt(0) + Constants.getCurrentVersion() + (Constants.AZUREUS_SUBVER.length() == 0 ? "" : ("-" + Constants.AZUREUS_SUBVER)) + "/" + CorePatchLevel.getCurrentPatchLevel() + " " + COConfigurationManager.getStringParameter("ui");
txtSysInfo.setText(about_text);
Utils.setLayoutData(txtSysInfo, gridData = new GridData(GridData.FILL_BOTH));
if (window.getCaret() != null)
window.getCaret().setVisible(false);
final String[][] link = { { "homepage", "bugreports", "forumdiscussion", "wiki", "!" + MessageText.getString("ConfigView.section.plugins"), "!" + MessageText.getString("ConfigView.section.plugins") + " (Tor)" }, { Constants.URL_CLIENT_HOME, Constants.URL_BUG_REPORTS, Constants.URL_FORUMS, Constants.AZUREUS_WIKI, Constants.PLUGINS_WEB_SITE, "http://ezhdqq3jjpsqg65l.onion" } };
for (int i = 0; i < link[0].length; i++) {
final CLabel linkLabel = new CLabel(gInternet, SWT.NONE);
if (link[0][i].startsWith("!")) {
linkLabel.setText(link[0][i].substring(1));
} else {
linkLabel.setText(MessageText.getString("MainWindow.about.internet." + link[0][i]));
}
linkLabel.setData(link[1][i]);
linkLabel.setCursor(display.getSystemCursor(SWT.CURSOR_HAND));
linkLabel.setForeground(Colors.blue);
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 1;
Utils.setLayoutData(linkLabel, gridData);
linkLabel.addMouseListener(new MouseAdapter() {
@Override
public void mouseDoubleClick(MouseEvent arg0) {
Utils.launch((String) ((CLabel) arg0.widget).getData());
}
@Override
public void mouseUp(MouseEvent arg0) {
Utils.launch((String) ((CLabel) arg0.widget).getData());
}
});
ClipboardCopy.addCopyToClipMenu(linkLabel);
}
Listener keyListener = new Listener() {
@Override
public void handleEvent(Event e) {
if (e.character == SWT.ESC) {
window.dispose();
}
}
};
window.addListener(SWT.KeyUp, keyListener);
window.pack();
txtSysInfo.setFocus();
Utils.centreWindow(window);
window.open();
instance = window;
window.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent event) {
instance = null;
disposeImage();
}
});
final int maxX = image.getBounds().width;
final int maxY = image.getBounds().height;
Utils.execSWTThread(new AERunnable() {
@Override
public void runSupport() {
if (image == null || image.isDisposed() || labelImage.isDisposed()) {
return;
}
if (display.isDisposed()) {
return;
}
paintColorTo += paintColorDir;
Utils.execSWTThreadLater(7 * paintColorDir, this);
int ofs = (labelImage.getSize().x - boundsColor.width) / 2;
labelImage.redraw(paintColorTo - paintColorDir + ofs, 10, paintColorDir, maxY, true);
if (paintColorTo >= maxX || paintColorTo <= 0) {
paintColorTo = 0;
// paintColorDir = (int) (Math.random() * 5) + 2;
Image tmp = image;
image = imgSrc;
imgSrc = tmp;
}
}
});
}
Aggregations