I want to create a print preview for a variable-size set of images in Java. My first approach (in dev mode) was to create snapshots of the images in different JLabels (just as a quick developer solution).
But for the production solution I need to create a more efficient and elegant way to display the images for the user of this standalone software. So I was thinking in showing him maybe 7-8 snapshots of the images to be printed on each JLabel.
Is there another way to do this? (Speaking of Java GUI components)
You can store these Images in some sort of List<Image>, such as ArrayList<Image>. Please read the Graphics2D tutorial, which contains related examples. There are other examples here.
Related
Hi I'm working on a hard drive simulation in java and I want to be able to represent fragmentation in any given drive(represented as a series of Objects Hashmaps,Arrays etc) Something like the bars in xp's old fragmentation tool XP toolbar. I was thinking of a bar or pie chart from google i have gleamed that swing may be my best option? Could anyone give any pointers how I might go about this.
I would check out JFreeChart for a potentially huge number of possible renderings. Here's a page with a large number of samples, including code.
JFreeChart is usually the best choice for charting in Swing applications. There are some other open-source libraries as well. See the last question on this page.
However, if you need some custom features, you may need to do some custom rendering in Graphics2D.
JFreeChart might be a solution for bar or piecharts, but If you just need a simple stacked bar, I would indeed recommend overwriting a JLabel from the swing library. That will be very easy.
If you need some more graphs and plots and stuff anyway, definitely have a look at JFreeChart, it's great.
I wanted to load java images with some effects like we have in power point like blinds or appear in Java swing when user clicks on the image.
I have these specific questions in mind:
1.Is there a way to do this in Java?
2.Also how will this behave when the image to load is huge like 25 Mega Pixel?
3.If we are dealing with large images being switched, what mechanism should be used for incorporating images in the application?
Thanks,
Sandeep
1.Is there a way to do this in Java?
Yes, but it won't be with a single command or anything like that. Unless you find a library for this, you'll have to code it up manually.
To do animations like these I suggest you have a look at SwingWorkers.
2.Also how will this behave when the image to load is huge like 25 Mega Pixel?
25 mega pixel is quite large. It depends on your computer of course but if you code it reasonable well it should work fine.
3.If we are dealing with large images being switched, what mechanism should be used for incorporating images in the application?
Unless you really want the program to zoom into the details of the image, I suggest you shrink them immediately after loading, so your drawing-routines can work with them efficiently.
You can experiment with your target images using ImageJ. I routinely use it to manipulate images having scores of megapixels containing 8-, 16- and 32-bit data.
We need to implement a Java desktop application that allows us (initially) to create / edit / resize / polygons on (initially) images. Then these polygons would be mapped to objects in our domain model.
So we basically need a toolbar with the options describe above and the possibility for the example to create a polygon on the an image and then scale it, or resize it, just that.
Do you know some library that could facilitate our work?
We've analyzed GEF, Picollo, NetBeans Visual API, Plain Swing or SWT/JFace, but none of them seems to help us to achieve our goal, which is, implement a really basic image editing tool.
I would like to mention that I'm not saying that what I want to do is not possible with the analyzed libraries, of course it can be done, but I'd like to learn from your experiences which is the correct path to take for this problem.
Any suggestion will be welcomed.
You could try to use GEF and the eclipse plataform.
this article could help you.
saluti
You might look at GraphPanel, a simple object drawing program. The control components are arranged in a JPanel, but JToolBar is a more flexible alternative.
Have you looked at imagine.dev.java.net? It is a NetBeans Platform application, which, though unfinished, might provide you with an interesting starting point.
I can't seem to find anybody who has done or posted something like this; Essentially I want to design my own UI in photoshop and then slice down the images to use it in a Java application. Essentially coding in the PSD file as the GUI. Is this possible? If so, can anybody lead me in the right direction?
I'm not sure what editor to use for this sort of stuff. I am using the Eclipse IDE and I know there is a Visual Editor but, I already have the actual design for every component in a PSD file. All I want to do is to start incorporating this into the application. Thanks.
It depends on how far your design goes. If you simply want to have normal Swing components on top of your image this is easy. Convert your PSD into (for example) PNG, create a custom JPanel subclass that loads the image and overwrite the paintComponent() method to draw the image instead of the normal background. All child components can then be set to be transparent with setOpaque(false). This puts your image into the background and puts the components float on top of it.
If you want to change how individual components look, its a lot more work. You basically need to implement a new Look&Feel for Swing. I wouldn't recommend going that route, unless you really have to, we are talking about weeks of work here, and it requires a lot of testing to really make it work properly on all platforms.
Alternately, there are already tons of custom Look&Feels available, I suggest you take a look at some freely available ones (just google "java look and feel"). Many of them can be customized to some degree (how much depends on the actual implementation, so take a close look at the source/documentation for each of them).
You might want to take a look at NetBeans which has a Swing GUI Builder. You would have to redraw your components there, and then write all the code to process the events. It is sometimes good to start with that, though often times it is less frustrating to lay them out with code by hand as it can difficult to make changes in code and have the builder keep up. There is nothing I know that will let you start from a photoshop image and proceed to building a GUI. Sounds like a good project to make someone rich. :-)
I have a console application which screen scrapes some data, and now I need to do image comparisons. If the images are different, I want to show the images to the user. What's the best way to display two images during the execution of a console application? I'm assuming I would use some sort of inter-process communication to send information back and forth, but I'm not sure how exactly I would go about doing that in a good fashion.
Also, I'd rather NOT store the images to files if possible. There's no reason to persist the data, and if the console application terminates unexpectedly, it's better if I don't have any dirt left on the file system.
Does anyone have any thoughts on how best to accomplish this?
I am not sure I understand the concern. You should be perfectly able to conditionally pop up either a Swing JFrame or AWT Frame from your console application, am I wrong?
You can use e.g. BufferedImage to construct images, or the utilities in javax.imageio if your image is already in some common format (e.g. PNG, JPEG, BMP). As for displaying to the user, just use the regular Java GUI stuff, either Swing or AWT. Run the GUI in a separate thread if the console part needs to keep processing while the images are being displayed.
The Working with Images tutorial may contain some helpful examples.