Help about gallery [message #64553] |
Tue, 16 June 2009 14:37 |
Eclipse User |
|
|
|
Hi:
I am using the gallery and the expansion and redraw process are very slow,
could you help me ?
The attached code pick up photos from a folder. Thank you very much
Greetings.
Gaston. Argentina
import java.io.File;
import java.util.Arrays;
import org.eclipse.nebula.widgets.gallery.DefaultGalleryGroupRender er;
import org.eclipse.nebula.widgets.gallery.Gallery;
import org.eclipse.nebula.widgets.gallery.GalleryItem;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class prueba {
static int indentLevel=-1;
static Gallery list ;
static Shell shell;
public static void main (String [] args) {
Display display = new Display ();
shell = new Shell (display);
FillLayout fillLayout = new FillLayout ();
shell.setLayout (fillLayout);
list = new Gallery (shell, SWT.V_SCROLL | SWT.VIRTUAL );
DefaultGalleryGroupRenderer gr = new
DefaultGalleryGroupRenderer();
gr.setMinMargin(2);
gr.setItemHeight(100);
gr.setItemWidth(112);
gr.setAutoMargin(true);
list.setGroupRenderer(gr);
shell.open ();
listPath(new File("C:\\FotosVeterinaria"));
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ())
display.sleep ();
}
display.dispose ();
}
public static void listPath(File path) {
File files[];
indentLevel++;
files = path.listFiles();
Arrays.sort(files);
Image nuevo;
GalleryItem group = new GalleryItem(list, SWT.VIRTUAL);
GalleryItem item ;
group.setText("Imagenes");
group.setExpanded(true);
Display display = shell.getDisplay();
for (int i = 0, n = files.length; i < n; i++) {
for (int indent = 0; indent < indentLevel; indent++) {
System.out.print(" *** ");
}
if (files[i].toString().contains(".JPG")) {
item = new GalleryItem(group, SWT.NONE);
nuevo = new Image(display,files[i].toString() );
item.setImage(nuevo);
// item.setText(files[i].toString());
// item.setData(files[i].toString());
}
// }
}
indentLevel--;
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.03309 seconds