Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Nebula » help about gallery
help about gallery [message #64576] Tue, 16 June 2009 19:30 Go to next message
gaston  is currently offline gaston Friend
Messages: 8
Registered: July 2009
Junior Member
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.

import java.io.File;
import java.util.Arrays;

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.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.BORDER|SWT.MULTI );
list.setLowQualityOnUserAction(true);
list.setAntialias(SWT.ON);
list.setInterpolation(SWT.LOW);


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--;
}

}
Re: help about gallery [message #64920 is a reply to message #64576] Sun, 21 June 2009 16:47 Go to previous message
Nicolas Richeton is currently offline Nicolas RichetonFriend
Messages: 179
Registered: July 2009
Senior Member
Hi Gaston,

2 issues in you code :
- You didn't understand how the VIRTUAL flag works, your code doesn't
take benefit of it. Look at :
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet202.java?view=co

- You are creating item with full-sized images. The gallery has to
resize each item for each redraw, by default with interpolation and
antialiasing. If some images are > than 640x400 this will slow the
redraws down. To fix this :
* Change resize quality : Gallery#setAntialias and
Gallery#setInterpolation.
* and/or Use Gallery#setLowQualityOnUserAction()
* and/or Resize images before calling GalleryItem#setImage()

Note that Linux / GTK is really slower than windows or mac osx when
drawing with interpolation and antialias. On this platform you ofter
need to reduce quality to get a decent speed.

See : http://wiki.eclipse.org/Nebula_Gallery_FAQ

I hope this will help you.

Regards,
--
Nicolas

gaston a écrit :
> 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.
> import java.io.File;
> import java.util.Arrays;
>
> 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.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.BORDER|SWT.MULTI );
> list.setLowQualityOnUserAction(true);
> list.setAntialias(SWT.ON);
> list.setInterpolation(SWT.LOW);
>
>
> 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--;
> }
>
> }
>
Re: help about gallery [message #595327 is a reply to message #64576] Sun, 21 June 2009 16:47 Go to previous message
Nicolas Richeton is currently offline Nicolas RichetonFriend
Messages: 179
Registered: July 2009
Senior Member
Hi Gaston,

2 issues in you code :
- You didn't understand how the VIRTUAL flag works, your code doesn't
take benefit of it. Look at :
http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet202.java?view=co

- You are creating item with full-sized images. The gallery has to
resize each item for each redraw, by default with interpolation and
antialiasing. If some images are > than 640x400 this will slow the
redraws down. To fix this :
* Change resize quality : Gallery#setAntialias and
Gallery#setInterpolation.
* and/or Use Gallery#setLowQualityOnUserAction()
* and/or Resize images before calling GalleryItem#setImage()

Note that Linux / GTK is really slower than windows or mac osx when
drawing with interpolation and antialias. On this platform you ofter
need to reduce quality to get a decent speed.

See : http://wiki.eclipse.org/Nebula_Gallery_FAQ

I hope this will help you.

Regards,
--
Nicolas

gaston a écrit :
> 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.
> import java.io.File;
> import java.util.Arrays;
>
> 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.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.BORDER|SWT.MULTI );
> list.setLowQualityOnUserAction(true);
> list.setAntialias(SWT.ON);
> list.setInterpolation(SWT.LOW);
>
>
> 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--;
> }
>
> }
>
Previous Topic:Row-wise table editing
Next Topic:Gantt: remove Connections
Goto Forum:
  


Current Time: Sat Dec 21 16:25:11 GMT 2024

Powered by FUDForum. Page generated in 0.03714 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top