Java - Custom rendering Component supporting DnD & Zooming [closed] - java

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I want to create a custom Swing component that renders certain enteties and connections between them. The user shall be allowed to select those entities and connections as well as moving them using Drag&Drop (only within that component). Additionally the user shall be able to zoom in and out of the overall view.
Do you know of any rendering framework that might help creating such a component or do I need to implement it all on my own?

A custom rendering program is an item that takes some understood data and turns it into drawing instructions.
If you want to add zooming, your custom rendering program will keep track of the size of the data item it is to draw, and the zoom scaling factor, such that if you were to zoom in 1.1 on a 12 pixel tall item, you would then draw that at 13.2 pixels high.
If you want to add drag and drop, you need to be able to receive a mouse click-and-drag event, which will give you a pixel coordinate. You back map that starting pixel coordinate to some non-zoomed pixel, then find out the non-zoomed item under that pixel. You then move that item the (translated for the zoom) correct number of non-zoomed pixels and request a redraw (remember the drawing layer will take care of the current zoom level).
As far as a rendering framework, there are two that come default with Java, and you've mentioned one. Swing is fine if you really want to build this functionality yourself, and AWT is also in Java, but it probably shouldn't be used independently of Swing unless you have some special requirements.
Outside of that there's SWT, and a number of high level convenience libraries like JGraph, etc which bind to one or other underlying frameworks to do the actual work. Whether those convenience libraries will do exactly what you wish, or even if they can be configured to do what you wish remains to be seen, depending on the very specific details that will only be discovered and handled after you start trying a convenience library.

Related

How to get the best graphical performance out of Java2D [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
This question does not apply to libraries such as LWJGL, JavaFX, etc. The goal here is to determine how to get the best performance out of Java2D. More particularly, how to get the best performance out of Java2D to create visually appealing yet efficient 2D games. I have come across quite a lot of practices: drawing directly onto a JFrame, overriding JPanel or JComponent, overriding Canvas to provide some nice double buffering strategies, using a library (ehm), etc.
In the past, I have simply overriden a JPanel and its paintComponent method, and, in the end, it ran at a steady 35 FPS! Not really the pinnacle of performance for a simple top-down 2D Java game (or maybe it is?).
So, what is the best strategy to get every drop of performance out of Java2D?
If you want to use Java's Graphics2D class to draw objects with nice performance, I recommend using VolatileImage. It is available since Java 1.4 and uses hardware accelerated processing (if possible) to render its stuff. It extends java.awt.Image so there are not so much changes for you, if you used BufferedImage or so before. But there are some tricky things using this class. For example before you render its content you need to check whether it is still valid, but usually it is not so hard to manage this stuff· But therefor you get pretty nice performance boost to your app, without the need to change a lot of code. :)
This link should give you good advice using this class.

Moving a JLabel in a circular path [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am.working. on a Netbeans Java project in JFrame form (a GUI application) where I want to move a JLabel into circular path. Can any tell or help to how to do that?
It sounds like you haven't done anything yet, and when that happens and you need to get started, then you should try to break the main problem into little steps, and then try to solve each little step one at a time, including looking at references for each of these steps such as using a Timer, doing animation, positioning components, etc...
So general recommendations:
Look up using a Swing Timer (or just click on link)
Use the Timer to drive your animation.
You can move a JLabel if the layout is null, but this is generally to be avoided.
Consider instead using a custom layout if you absolutely need to move a JComponent (the JLabel) along a prescribed path.
Or if you just want to move an image, then draw the image inside of a JPanel's paintComponent(...) method, setting its position with two int fields that are changed by the Timer. This JPanel of course will need to be displayed in your GUI. There are lots of examples on how to do this on this site, some written by me (for example), that simple searching can help you find.
But most important, take the first steps, do something, anything, that moves you forward with this project.
Then when you try this if it doesn't work, show your code and we'll be much better able to help.

Library to segment and classify binary or grayscale images [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
I am interpreting scientific (STEM) images into their component parts and adding semantics. These images are born digital, noise-free and either binary (monochrome) or have a small number of colours. I would like Java libraries/methods to partition the images into the whitespace-separated components and to identify (classify) the resulting segments. A typical image is:
where I would want the extracted segments to include numerals and other characters (some rotated) and the asterisks in the diagram. [I will use other methods to extract the geometrical components - e.g. the bars) . I would also like the library to identify identical segments (e.g. 6 zero characters, 5 decimal points). I have successfully used Tesseract for characters but many of the segments may not belong to a Unicode character set (e.g. purpose-created symbols).
UPDATE: I have opened a bounty. I am only interested in libraries, NOT suggestions for algorithms as I have already written a prototype one. If the functionality is part of a larger system (e.g. I think JBIG2 has this functionality) please make it clear where the entry points are.
NOTE: "born-digital" means that the image was created without noise, clean lines unlike - say - scanned documents.
I am only aware of openCV. With this you can analyze your image like:
binarizing it (if you have a few colors or greyscale)
gather blobs in Mat-objects
get the position of those Mats to get the correct label (which should be a Mat for each letter)
and then apply your algorithm to those Mats

Double handled slider android [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
I was wondering if anyone had some code, or knew of a place that has code for creating a double handled slider. Example :
I am looking to do something similar using a double slider to search for a range of ages on a time array , like in the photo
Thanks in advance
I managed to build it myself... the idea I followed was different from the answers above. I created some items that can be dragged on the screen with the finger, and I fixed the Y position so it can only move from left to right. After that, I generated rectangles that signify the progress (between knobs and outside them). The good thing about this technique is that you can easily customize the slider to be vertical or horizontal, or if you want to put a custom picture in the background. The source is in the link below, and if anyone has any questions please ask.
link: eclipse project
Have you seen the range-seek-bar. It looks like it would work perfectly.!
You could try and extend the AbsSeekBar and have a look at the single-thumbed-SeekBar how it works.
I have looked through the entire Widgets package and incredibly, the ADT doesn't have any slider control! This obviously puts you at a serious disadvantage since there is nothing already implemented for you to extend or modify.
However, there is this guide on hacking together a custom slider component out of a ProgressBar component. This might be your solution. The author overrides the onTouchEvent method to set the progress bar's value according to the touch coordinates. Very clever. However, since a progress bar can only show one value, it's only possible to show the lower or upper bound using a single progress bar.
My suggestion is to create a compound component which has one progress bar that is always at 0%, and another progress bar which is always at 100%. The second bar is overlaid on top of the first one, and its coordinates and width set so its left edge represents the lower bound (x), and the right edge shows the upper bound (x + width). Your onTouchEvent will detect whether the touch coordinates are closer to the lower or upper bound, and then start adjusting that bound until released. When the bounds change, you simply reposition and resize the second bar. Provided you can position components absolutely and on top of other components, this should look great!

Object detection/tracking within Java [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I'm looking to do some image processing in Java and I'll be developing in Ubuntu with Eclipse.
So here is my objective:
From a greyscale image, I would like to be able to detect certain sized objects and draw a rectangular frame around them. However, the catch is that this image is captured from a thermal imaging camera so to detect body heat the pixels will have a value within a certain range.
After detecting all the objects in the image, I will need to count them, but that's later.
So here's my challenge. Which tools/apis/open classes can I use to do something like this. I looked around and found some basic manipulations such as rotate, crop, resize. But haven't really found anything I can use.
Where should I look/start?
thanks a lot in advance
ImageJ is very useful:
http://rsbweb.nih.gov/ij/
Although ImageJ is set up as a GUI, you can use it as a library too (I do that too)
You'll have to search for a proper object detection plugin (but there are some floating around...)
good luck!
Eelco
On this page you can find open-source tool for image processing and image mining:
http://spl.utko.feec.vutbr.cz/en/image-processing-extension-for-rapidminer-5
This article fully explains the algorithm you're looking for, and the accompanying source code is here. You can see it in action in this video.
(Disclaimer: I'm the author; but I do think this is very useful, and have successfully used the algorithm a lot myself.)
The algorithm tracks moving objects, finds their bounding rectangle (which the application draws), counts the number of pixels in each objects, correlates them throughout frames as the same object (with an int ID). You may need to do a trival conversion of your grayscale image to RGB (by copying the gray values to all three channels) since the algorithm was designed for color input.
When it comes to commercial computer vision applications, OpenCV and the Point Cloud Library aka PCL are your best friends. And articles like the one linked explains how to use tools like OpenCV to accomplish full stack motion tracking. (The pure Java implementation shows how it works down to the individual pixels.)

Categories

Resources