I'm currently attempting to use the openoffice API to display a powerpoint presentation from Java - I've got a fair way in that I've managed to open a presentation and display it. However, there's a couple of things that I'd like to be able to do I can't figure out with the API as it stands:
I don't want the main Impress window to appear, just the presentation window. Now, I can start it minimized no problem with a property, but then the actual presentation window is minimised as well, which I don't want. I can also grab the window and call setVisible(false) on it, but it's still visible for a second or so while it's loading.
I want to be able to control the monitor which the presentation appears on (I'm using it in a multi-monitor setup.) I thought I might be able to grab the Window of the presentation and move it around that way as I need to, but I can't see how - for the main window I can do something like:
XModel xModel = UnoRuntime.queryInterface(XModel.class, xDrawDoc);
xModel.getCurrentController().getFrame().getContainerWindow().blah();
...but I haven't yet found a way to get the presentation Window. I'd like to be able to set the bounds of the window directly (x, y, width, height) rather than just being constrained by positioning on a single monitor.
I can live with the first point, the critical one I need to solve for my use case is the second.
Any ideas on the above? I'm an experienced Java programmer but new to UNO.
Seems the second point can be solved, ish, with the display property:
public void start() {
try {
xPresentation.setPropertyValue("Display", 1);
}
catch (Exception ex) {
ex.printStackTrace();
}
xPresentation.start();
}
Note however a few of things - firstly the display index is base 1, not 0. Secondly, trying to set the properties in an array and passing them to xPresentation on creation didn't seem to have any effect - it only worked for me setting the property later as above. Thirdly, it doesn't allow fine grained control over the window as I wanted, just control of the display the presentation appears on.
Related
Simplifying, I have this structure
Form {
tab=Container(BoxLayout.y());
other stuff
}
The Form is not scrollable (and it is not supposed to be), tab is.
At some point I want to redraw the Form to keep it up to date with some new info added, and I do that creating a new one and showing it.
But I want to scroll down the Container tab to its predecessor's Y-coordinate.
I can easily save the Y coordinate in a static variable using
scrolledToY=tab.getScrollY();
But I can't find a way to set it back when I create the new form.
setScrollY seems to be protected, and indeed if I try to run the program using it, I get an error
error: setScrollY(int) has protected access in Component
tab.setScrollY(scrolledToY);
What is the correct function to use, instead?
Thanks.
You can use scrollRectToVisible().
FYI you can just modify the container and call revalidate to update the UI. This will prevent a nasty refresh problem you might experience. Also check out InfiniteContainer which might be what you're really looking for.
I want to take screenshots of rendered scenes without displaying the game itself. The procedure I want to follow is:
createScene();
for(i = 0; i < num_screenshots; i++)
{
moveCameraRandomly();
saveScreenshot();
}
Basically, I want to randomly reposition the camera in the scene for each screenshot I take. However, I need to call this as a function, so I don't want to display the game itself (but I'm fine with it running in the background). Ideally, I would like to have two projects, one which creates screenshots and one which creates the game, where the first one calls the second one. Is there a way to do this?
Applications can be started in headless mode.
Application app = new Main();
app.start(JmeContext.Type.Headless);
http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:headless_server
The ScreenshotAppState can take screenshots:
http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:screenshots
Now you need to develop a combination of both, which is automatically taking screenshots. I recommend that you read the source code of ScreenshotAppState. A already did a similar thing and can tell it is possible.
I think this is so wrong, but I need it...
So, to run Processing's sketch in Java mode, you have to extends PApplet in the main class, and there, in the setup() determine the window size using size(int x, int y). Then when you run it, it'll show a Java window Applet Viewer.
What I wanna ask is, how to prevent that window from appearing? I've tried to remove the size method, but it appeared in (what seems like) it's default size. Tried put 0 as params, went wrong (the x and y have to be > 0).
Is there any way to do that?
If there's any lack information or I've made a mistake with the post, please tell me.
1st edit - add more info
Let's say I have 2 classes: the one that implemented Processing and extends PApplet is named Pikachu by me, and an ordinary Java class I named Jojo. Jojo will pass params to Pikachu and Pikachu will process that param. The param is image's name, or if it could, an image itself (I don't know yet tho, can Processing execute Image class from Java?). Then Processing will process that image, gave an output, again as image (Yet, again I don't know yet, can Processing gave output an image for Java to use?). So, that's why I don't need a window to appear.
Perhaps you can try to use the Frame object.
In the documentation there is a function .setVisible(boolean b)
If you call .setVisible(false) you can turn the frame off.
http://docs.oracle.com/javase/7/docs/api/java/awt/Window.html#setVisible(boolean)
I am not sure how to access the frame using pure Java. In processing you can simply call
frame.setVisible(false);
Hope this helps
Is there a way to take the screenshot of the display in a browser in Java minus the browser window. The flow is :
Load the webpage in a browser. Then make an AJAX call to a Java service which captures the screenshot using the code from : How to take a screenshot in Java? .
The problem here is that I only want to capture the visible area in the browser excluding the browser window, the windows task bar and the other unwanted stuff.
Thanks
You can just measure how big is the displayable area and capture that section only.
As for the AJAX call to a Java service part is not posible.
As #OscarRyz already mentioned AJAX call is irrelevant here.
You have to create java applet that calls new Robot().checkScreenCaptureAllowed(). This will capture whole screen.
The problem is how to understand where the visible area is. You can probably do it. You have to create at least one visible element in your applet. This element could be even very small (e.g. one pixel), so user will not see it. Then you can invoke getLocationOnScreen() that gives you the absolute coordinate on screen. If your java applet is in the top-left corner this is the point where your visible area starts.
JavaScript allows you to know the height and width of current window: window.innerWidht and window.innerHeight. So, you now you can take your screen capture and cut the area that you need.
But please take into consideration that new Robot().checkScreenCaptureAllowed() checks READ_DISPLAY_PIXELS_PERMISSION and I do not believe you have such permissions for unsigned applet, so you will have to sign your applet.
To avoid this problem take a look on this: http://html2canvas.hertzen.com/ - script that "captures" screen and uses JavaScript only.
I intend to write a XSL-FO designer in java for which i need to write an UI. The basic idea is to give the user a work pane wherein he/she can draw rectangles and these rectangles would in turn be associated to field containers in the underlying XSL-FO generator. Once the field container are done, the user should also be able to select any of the rectangles(field containers) created and add components into it. These will in turn be translated into field blocks that fall under the chosen field container.
Till now I have created a simple UI using JFames with mouseListeners hooked to them so that i can have users draw the rectangles on the work area.
Im stuck at the point on how to implement the part where the user selects one of the rectangles created in the previous steps.
Given the intent of the designer, is it possible to accomplish this using Jframes ?
Any pointers/suggestions on how i can achieve the motive of this designer would be of great help !
Please excuse me if any part of this post is noobish. I am one when it comes to UI.
JInternalFrame might be a starting point. You can connect them, as shown here, and add arbitrary components as required.