I am trying to make an image Viewer like the one shown in the figure below:-
Before i can start i have following questions in mind :-
How would i check for the number of images in the target folder so that i can iterate and include all the images in my app.
Secondly,i am thiking to scale the images down to 75x75 .But what i can't think is that how will i slide the images as scrollbar is moved
To be specific,what is the appropriate container for those 75x75 images queue and how that queue is shifted to left or right?(I already know how to get current scrollbar value and add event listeners on it to respond)
To check the number of images in the target folder you can use the File class.
As for the container you might need to create the animation your self. There is no a container ready for doing so.
This site ( and book ) has some ideas about it. I don't know how out-dated it might be though
http://filthyrichclients.org/
Unless I am misunderstanding, making a scrolling list of images is quite simple.
First, create a JList with a datamodel that allows images.
A great example is shown here:
Java drag and drop images in a list
Second, add the JList to a JScrollPane.
The scaling aspect can be easily performed using Scalr:
http://www.thebuzzmedia.com/software/imgscalr-java-image-scaling-library/
Related
I am using a Vaadin 10 (Flow) Grid to stream data to new rows, and I am trying to add a custom image icon to my TemplateRenderer.
I have a TemplateRenderer setup like this:
TemplateRenderer<TradeUni> sizee = TemplateRenderer.<TradeUni>
of("<div class$=\"[[item.class]]\">[[item.size]]</div>")
.withProperty("class", cssClassProvider)
.withProperty("size", TradeUni::getSize);
Which displays my numbers correctly in the grid cell like this:
I would like to have my image rendered inside the same cell, to the left of the numbers.
This was my (very crude) attempt to import it using html:
TemplateRenderer<TradeUni> sizee = TemplateRenderer.<TradeUni>
of("<div class$=\"[[item.class]]\"><img src=\"i.imgur.com/3LQBglR.png\">[[item.size]]</div>")
.withProperty("class", cssClassProvider)
.withProperty("size", TradeUni::getSize);
Which give's me this:
I think that I might have to wrap the image and numbers into a HorizontalLayout with the image being a separate component - I think I could handle that, but I am unsure of how to do the actual rendering of the image. I can probably accomplish it simply with the internal Vaadin Icons set, but I need to use my own little images.. all icons that I am going to use will be at or less than 25 x 25px.
Thank you so much in advance!
I think you're on the right track, but there's one small detail that causes you trouble. The URL i.imgur.com/3LQBglR.png doesn't define a protocol, which means that the entire string will be treated as a path relative to the location of the hosting page. It will thus try to find a file in a directory named i.imgur.com on your own server.
To fix this, you need to also include the protocol in the image URL, i.e. https://i.imgur.com/3LQBglR.png.
I can also offer a small suggestion for how to make the code easier to read. HTML also supports using ' for enclosing attribute values. This is more convenient to use from Java string since you don't need to use \ to escape ' characters. Your template string could thus be "<div class$='[[item.class]]'><img src='https://i.imgur.com/3LQBglR.png'>[[item.size]]</div>".
Okay So today I sat down to make a options panel that would allow you to scroll down through the list of options and for some reason I drew a blank... Anyone got an example at where I could get started for some reason I can't seem to see in my mind how to do it though It seems really simple.
You should use ScrollPane() as the container of your list. and you can use List and List.ListStyle to set your options list if you to use text for it.You should set the style of List.ListStyle and ScrollPane.ScrollPaneStyle linked to a json file and therefore your Skin. And then add a table to the stage containing the ScrollPane Actor.
here is a video tutorial: http://youtu.be/CNjkPPveqG8 talking about this.
PEACE!
The problem is to create a dynamic label printing where in I will present to the user the fields that are available (ex. Name, ID No, Address etc) and I will let them draw their own label.
It is something like on the left side, there are the available fields, and on the right side is a big field where I let them drag and drop the fields and draw boxes and grids.
The system should be able to save the drawing (in any format as long as it can be saved in the database) that they created and the fields in that drawing can be called in the backend.
The saving part is important because if the user created so many labels, I want them to be able to choose which drawing they can use to Print their labels.
I would like to integrate this with my existing web Maven Spring 3.x system.
If anybody could point to where to look, either in the drawing creation or in the saving it would be great.
I did that drawing/saving stuff in a webapp some time ago using Javascript. Use the HTML canvas element to define a place users can draw on.
Guess there are several js/jquery libraries for that (It is also possible to do everything on your own)
There are also exporting functionalities (I do not remember exactly) but it is possible to convert the drawing to a data-url and upload it with a hidden text field. Of course it can be directly stored on the user's computer as well.
Start by having a look at introduction to canvas drawing on w3cschools.com
I am trying to display an image in a jlabel, which is in the default jFrame created by Netbeans. I know how to display an image in a new Jframe, but I dont know how to acces the default Jframe since I cant customize the code and create a variable name for it. Any work arounds?
The application is supposed to display pictures from a directory, so when u press next, next image, and if you press previous the previous image will be shown. What will be the best data structure to do this efficiently so that I can keep track of the index as well?
Instead of letting the GUI designer manage your frame, let it manage the content, as suggested in this example.
Addendum: There's an example of flipping through images here.
Regarding displaying the images, you can number the images in the directory as 1,2,3...and so on. If you do this, you can use a simple counter variable (increment with the next button and decrement with the previous button ) to scan through the images. You can use this counter variable for your image name with the format.
I am creating an application that converts files from xml to pptx. The user will drag items from a JTree to a JList to create the slide. I have managed to get everything working but the JList seems to disappear after the drop. I know the drop is received because of print statements, and that it's not null. The JList is still there I believe, because I can print the items in the array. Through testing, I think that something is wrong in the custom DefaultListModel I have created. It is not calling an update/redraw/revalidate after the drop for some reason, or has released its action listeners because I notice that the getSize and getElementAt methods stop getting called after the drop. It does however draw correctly if I add items to the ListModel on app init.
I've been looking through all the documentation on ListModels and TransferHandlers but have not been able to get the List to display after the drop. Is my model missing an Override or not handling listeners in some way?
Full source:
http://code.google.com/p/app4args/
Possible problematic file:
http://code.google.com/p/app4args/source/browse/trunk/src/edu/gatech/app4args/utils/CustomListModel.java
To recreate:
Download latest release/source & example xml file from downloads section of project site
Run app, choose File > Import, browse to example xml file
Create new slide: Slide > New Slide, choose Standard (any works)
Drag JTree item from Library to a List in Slide Content View
List does not update, clicking on it or elsewhere in the app and back on the list will make it disappear
Thanks
Turns out I was overriding methods in CustomListModel that were relevant to the updating of how to draw the content of a list. I removed these and reworked a few things and it is correctly drawing now.