Does anybody know where are and how can I obtain internal images which are used by SWT/JFace, like WARNING, ERROR or INFORMATION icons and others...? Where are they situated and how to get them into my code ?
Some parts of JFace uses images from JFaceResources rather than SWT. You find these as
Image i = JFaceResources.getImage(...);
Unfortunately, everybody can install new images into the resource manager, so there are no way to predict the names of images. Some general images are installed in JFaceResources.initializeDefaultImages().
(If you have images, font or colors you use multiple times across your application, then look into JFaceResources.)
Also - if you are using Eclipse RCP - you can find a number of images using
Image i = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages...);
You can find additional constants in org.eclipse.ui.ide.IDE.SharedImages and org.eclipse.ui.internal.ide.IDEInternalWorkbenchImages (for IDEs).
You can use the getSystemImage() method of Display to get those images.
For example:
Display d = Display.getCurrent();
Image img = d.getSystemImage(SWT.ICON_WARNING);
Hope that helps
Related
I am building a tree table using Nebula nattable and am trying to style it like a swt tree table. The issue now is I am trying to use the same icons for decorators as an swt table and can't find them.
The current icons are selected with the following:
TreeImagePainter treeImagePainter =
new TreeImagePainter(
false,
GUIHelper.getImage("right"), //$NON-NLS-1$
GUIHelper.getImage("right_down"), //$NON-NLS-1$
GUIHelper.getImage("leaf")); // This is an empty image acting as a placeholder to match the
// indentation
I would like to replace them with the icons shown in this image:
A is the desired icons, B is the current icons.
Is there a relativity easy way to achieve this?
These icons are coming from the operating system and afaik there is no easy way to access them. At least I have not yet found a way which is the reason for having those icons in NatTable itself.
I have uploaded a static image (e.g., at location: /images/no-image.jpg) as part of my code that gets used as the default image when there is no specific image available (basically of the type: "no image for this item")
Just realized that this image may have to be served at more than one size (I have uploaded -- and want to upload -- just one size).
How do I resize this image using Google's Images Service?
If I use the example shown at https://developers.google.com/appengine/docs/java/images/#Java_Transforming_images_in_Java , that means having to read the file, apply the transform, then write a servlet to serve up the file... which seems like a lot of work. Is there an easier way?
Will it be easier to just upload the image to the BlobStore :-)?
You can add the following lines to your CSS file:
.placeholder {
background-image:url('../images/bg.png');
background-repeat:no-repeat;
background-size:contain;
background-position:center;
}
Now, when you don't have a specific image to serve, simply add "placeholder" class to your container element.
Remember to make this image cacheable.
I strongly recommend using the getServingUrl function for serving and resizing images for two reasons:
simpler to use. to resize, you just append parameters to the image url
It will significantly reduce the load off your instances, since the images are served without a servlet, but with google magic
I would like to display files and folders in a TreeViewer with the associated Windows shell icons. I use the SHGetFileInfo function to get the icons, and then I convert them to org.eclipse.swt.graphics.Image.
It works great, but when I display a large number of files I get an error: "org.eclipse.swt.SWTError: No more handles". SWT is right, I created too many images. Because I must return them from org.eclipse.jface.viewers.LabelProvider.getImage(Object).
How should I handle this situation?
(I can't "cache" the images, because the icons can be dynamic, and even different for every folder.)
You do need to work out a way to identify the different unique images you get from SHGetFileInfo and only create one Image for each. You must also keep track of the images you create because you must also dispose of them.
You may be able to use org.eclipse.jface.resource.ImageRegistry to help manage the images. This requires a string key to identify each image. It looks like SHGetFileInfo gives you an index number that could be used as a unique key.
I'm building a very basic gallery on android, it shows the last image on the camera folder and the user can slide left to see the previous one.
I finished an implementation using a viewpager, and a pagerAdapter using sampleSize to scale images. My problem is that the implementation is nowhere as efficient as the default gallery app, every time you slide an image you have to wait around 200ms for the next one to load. So basically my idea on how to implement it is not working out.
How can I do this efficiently, and if possible with an implementation that allows zooming in and out later on?
This looks promising but I don't know how to implement it with files instead of drawables
http://www.androidviews.net/2012/11/photoview/
EDIT:
I've managed to improve speed a bit using photoview (a hacked viewpager), however it takes too much to convert the filepaths to bitmaps or drawables.
I have tried these two methods suggested by dilix and iDroid Explorer:
// Method A
Drawable d = Drawable.createFromPath(imagePath);
imageView.setImageDrawable(d);
// Method B
Bitmap myBitmap = BitmapFactory.decodeFile(imagePath);
imageView.setImageBitmap(myBitmap);
But both produce error Bitmap too large to be uploaded into a texture. I need to get the image to the imageView as fast as possible and somehow bypass this error and maybe I'll get a decent speed. Right now I'm scaling the images and converting them to a drawable but it's not very efficient.
Check this awesome website : http://www.androidviews.net/
and maybe this is what you want: http://www.androidviews.net/2012/11/photoview/
It has page scroll, zooming and panning as you need
I have used it in my project with some modifications and lazy image loading. It is working exactly as you need.
See the official documentation for a great example that will walk you through using bitmaps with a viewpager efficiently. You should use a cache of the images that have already been loaded, and the images should be loaded outside of the UI thread. You also want to scale the image to the minimum size needed for your display (usually powers of two - note that the image won't always scale to what you ask it to!)
ViewPager also loads images in the background to prepare for the next slide, which is set with the setOffScreenPageLimit method (the default is usually good, I think it's 2.)
https://developer.android.com/training/displaying-bitmaps/index.html
I am not sure whether you got correct solution or not. But if you want to continue with your own implementation with your given link then:
http://www.androidviews.net/2012/11/photoview/ //this link is given in your question
And you can see this SO for how to convert file's path in to the drawable. Now, you get drawable of your specified file and implement on the link you have given.
I think that link will works nice.
Feel free to comments.
1)
This looks promising but I don't know how to implement it with files
instead of drawables http://www.androidviews.net/2012/11/photoview/
You have to store not list of drawables in you adapter, but links to files on your sd card and then load it.
2) But i can imagine that file instead of drawables won't be so efficient because to load from files you have to parse it from sd card.
I think you can save time by loading several images in your memory simultaneously (compressed) and when you swype to your othe image you'll already have the image and memory and while swyping you can start loading other image in memory.
When fling over the gallery you may not load images and load it after almost stopping.
It's the main problem: memory consuming vs performance.
UPDATE
I think better than exploring this by yourself will be exploring existing code of google gallery: https://github.com/CyanogenMod/android_packages_apps_Gallery
As i checked - they store cache (almost as i've said about loading multiple bitmaps) and store only resized images - seems to be efficient.
Is there a way to show an SVG image in a GEF editor? I found that one can convert the SVG image in a SWT image but I need it to be in vector format, so that when I zoom in I don't get quality loss.
According to this site, you should be able to use the SVGFigure class of GMF.
This class does not have dependencies to GMF.
Ok, I finally found something that works.
It seems like using org.eclipse.gmf.runtime.draw2d.ui.render.figures.ScalableImageFigure ist the answer. ScalableImageFigure is a sublcass of Figure so it works like a normal GEF Figure.
You cand find this in the runtime library pack from GMF.
Using ScalableImageFigure you can show an SVG image in GEF but when you zoom in you still get quality loss. To overcome this you need to sublcass ScalableImageFigure and implement org.eclipse.gmf.runtime.draw2d.ui.mapmode.IMapMode. When you zoom in the scalable figure will be repainted, and the image rerendered. org.eclipse.gmf.runtime.draw2d.ui.mapmode.IMapMode.LPtoDP(Translatable) will return the scale for the image to be rendered. I didn't have enough time to properly implement this interface, I just needed to check if it works so i simply created a field in the subclass(int named scale with default value 1) which is incremented each time LPtoDP is called
public Translatable LPtoDP(Translatable t) {
t.performScale(scale++);
return t;
}
This is totally experimental, when I will implement this feature in our application I'll revisit this Question and post a functional and corect implementation of this interface and class.Until then I hope this will help others who are looking into something like this.