Java FX - Dividing a Node for multiple page printout - javafx

I been searching for post about multiple page printout on javafx. they say that for a node that is too big to fit on one page must be divided and pass each for printjob. the instruction given for that is too vague for me to understand.
Let say i have a TextArea with a list of hundreds of names which obviously would not fit in one page. How will i divide that into a multiple of nodes to pass each on the print method of PrintJob? (output to be printed on a letter size paper)

I have to admit that I have never done that myself but what I would try is the following: Assume you have a node which would cover two pages when printed as a whole. I would then set a clipping rectange on the top level node which covers the left page and then print it. After that I would set a new clipping rectangle wich covers the second page and transform the node so that the second page starts in the uppder left corner and then again print it. I think this could work but as I said before I have never done that before.

Related

How can I force vis.js edges in a rendered DAG to "jump" graph levels?

I have used vis.js to draw some DAGs using the hierarchical layout option. It works well, however for my use case there are often going to be edges that must "jump vertex generations," not certain if I am saying that properly. Essentially, one branch may have 10 levels, and then a sibling of the parent of the deep branch may want to connect to the deepest leaf node.
This "works" - vis.js draws it. But it screws up my layout, shifting a large portion of the preexisting graph, and it will not be useful for a user to look at the result. I have attached a picture of what I am trying to achieve and what the current results are, can anyone point me in the right direction?
Solution turned out to be very simple, I just overlooked it. Using the hierarchical layout, it is possible to assign each node a field called level. It is an all-or-nothing option: either you let vis.js take care of the levels, or you manually assign all your nodes a level. It respects the levels very well, and when adding edges to nodes whose levels have been manually defined, the nodes no longer jump around the layout.

Accessing a Components Property prior to the Instantiation

I have the following problem:
I have a list of Components, that contain Rectangles with a width of either 200 or 800. I'd like to filter this list, and only create objects of the Rectangles with a width of 200 as I work on a small screen.
Preferably I do not want to create all objects, check their width, and destroy those with the wrong width again. For obvious reasons I really only want to create those with a width of 200.
To do this I would need to aquire knowledge of the width, before I instantiate them.
As far as I have seen, there is no publicly available and documented way of introspecting/reflecting the Component prior to it's instantiation.
My question is: Is there a non-public way to gain knowledge about what is packaged inside of my Component? Might it be possible with C++?
Or would it at least be possible to find out what kind of Object is encapsulated? Whether it will be a CustomComponent1, a Button, a RedRectangle...
Unfortunately not. You can't even predict it, since the Component could even point to a qml file that hasn't even been downloaded yet, if it was fetched from the network.
There are a couple of things you can try though, if you have room to approach the problem from another angle:
What you can do is pass properties from outside the component into it as it gets created. Assuming you control the code within the Component, you can then adjust how the internal elements get created based on the value of the property(ies) that was(were) set from outside.
If that's not good enough, say your Component provides multiple elements and you only want to create the ones that match your criteria (possibly a combination of many), then you can introduce a second Component layer within the first Component, and have that second Component either create the actual element if it matches your criteria, or an empty Item{} if it doesn't, which is as close as it gets to not creating anything.
I hope that helps!

Changing QGraphicsScene Insertion Order Without Reloading

I'm working on a graphical shape editor that uses the QGraphicsScene/QGraphicsView as its basis. I have a lot of experience with the scene/view framework and understand it fairly well. The issue that I'm having is that QGraphicsScene::items always returns items in the insertion order (either ascending or descending) regardless of the Z-order or the use of QGraphicsItem::stackBefore call.
The issue is that, as with most graphics editors, I need to be able to move shapes forward or backward in the stacking order. At the end, to save the resulting data, I have to traverse the list of the items in the scene and save each item's data in whatever format I'm using.
The only way that I've found to do this is that I have to remove items from the scene and reinsert them in the desired stacking order. In this particular task, it's a small number of items and happens without noticeable delay, but in a related editor, it could be many thousands.
While the QGraphicsItem::zValue and QGraphicsItem::stackBefore allow me to influence the drawing order, neither of them changes the order that gets returned from QGraphicsScene::items. Since the data I ultimately save needs to reflect the drawing order, I have to remove and reinsert to get the correct ordering at the end.
Questions:
Have I've overlooked any other techniques for managing items within the scene that will influence the results of QGraphicsItem::items?
Or is there another method for traversing the items within the scene that will give me the drawing order?
I can confirm that QGraphicsScene::items() and items(sortOrder) return the item list in the original creation and stacking order, which does not at all agree with the docs.
However, I found that by using
QGraphicsScene::items( QGraphicsScene::itemsBoundingRect, Qt::IntersectsItemBoundingRect, sortOrder) I do get the items in the correct drawing order, so this function apparently takes calls to QGraphicsItem::stackBefore() into account.
i don't use the z-order feature so I can't comment on whether that works in this scenario or not.

Troubles with arangodb graph viewer

In graph viewer, is it possible to not start with a random vertice? When I uncheck the option, the graph simply disappears. But I don't get to choose the starting point anywhere.
And when I set up the configuration it is not saved to the graph view. Is this going to be fixed? I find it kind of a key feature for a graph-database to be able to easily explore the graph.
I am working with arrangodb 2.3.1
Anyway, besides some trouble with the graph viewer, I really enjoy this fancy multi model database! And for me it is a big plus it's made in Germany! Keep on the great work arangodb-team!
As already mentioned in the comments you can select the start vertex later.
Click on the Filter icon (see image)
Two input boxes should appear - Attribute name and Attribute value. Type in _key into the left box (see image)
Type in a known _key of a vertex (or another attribute) into the right box (see image)
Simply hit return and you should see the vertex with the given _key value

Display opencv frames in a window with button and text control

I'd like to ask you some information about a problem which i want to solve.
At the moment, I have two opencv applications:
application A: where i track an object with two types of algorithms and each time i save a frame in an image file and i control the application behavior with some commands which i write in the shell
application B: where i have a loop which reads every time the image file and display it
So, I launch these two applications together in order to track the object with appA and to display results with appB which reads everytime the frames saved by appA in the hard disk.
I want to integrate application B in application A in order to show a window (like this: http://lnx.mangaitalia.net/window.jpg) in order to have a loop which shows image in the first area and to use buttons in order to give commands which at the moment i write in the shell.
Do you think it's possible to display the frames in an area with Qt or opengl or wxwidgets?
Which solution is the better and the easier to apply?
At the moment, my application B is very simple:
while(1)
{
Mat img=imread("result.jpg",1);
if(!img.empty())
imshow("HOG",img);
if(waitKey(200)==27) break;
}
I want to show these frames in a window which has also some buttons.
In particular, as you can see in the attached image in this post, i want to create a window divided in two parts: the first one which display the frames captured from opencv camera and the second part (or area) which has some buttons (B1, B2, B3..) which the user can press in order to control the application behavior.
(At the moment, i use a switch/case in appA to trap the keyboard keys)
There is some example based on a template similar to what i'd like to do?
(like the jpg image i've told before: http://lnx.mangaitalia.net/window.jpg)
I propose that you just use the inbuilt GUI in OpenCV: highgui. It has keyboard/mouse IO, window control with a message loop, buttons, sliders etc. And there is no need to do any conversions of the cv images to show them.
Have a look at: http://dasl.mem.drexel.edu/~noahKuntz/openCVTut3.html (It is written for old IplImage style CV, but the C++ interface is almost the same, use cv::imshow to draw images)
Also, here is the documentation for the C++ style interface.
There is also the possibility to convert your CV images to QImage in Qt and do it that way... you should be able to find solutions for that on Google.
There are some examples out there for implimenting this.
see http://larryo.org/work/information/wxopencv/index.html
Basically what you want to do is:
capture a frame from your camera
manipulate the image
use cvConvertImage to convert it into a format wxImage can read
draw this image on to a wxCanvas
For the GUI part of this, you would need to create a wxFrame or wxWindow, place some sizers and buttons at appropriate places.
So basically make a frame, put a sizer on the frame, then put a panel in the sizer.
next make a vertical sizer on the panel. First add a wxCanvas to the vertical sizer, then place a horizontal sizer in the vertical sizer. Now add 3 buttons to the horizontal sizer, and you have your panel.

Resources