Flex 2D graphics learning path for Java/GWT developer? - java

I have been developing with Java for several years and last six months I have been building GWT based application. But I have almost no Flash or Action Script experience and I would like to try out some hobby programming with Flex. Especially 2D graphics and image manipulation would be interesting topics.
Adobe's tutorials for Java developers are naturally the starting point but I would need some pointers for graphics. Something like drawing 2D graphics based on data from the server or modifying image uploaded by user. How much can be done on the Flex and what must be done on the server side?

For drawing you don't need the 'full' flex library, flex will mostly provide you with a nice set of GUI components and some ways to integrate with your back-end server easily.
If you just want to draw something check out the Graphics object http://livedocs.adobe.com/flex/3/langref/flash/display/Graphics.html - it works similar to the java Graphics object.
If you want to modify an image uploaded by the user you are of course already at the server (because the image was uploaded) - however the new flash player (version 10) allows some manipulations of local data as well, so it might even be possible to show a modified image that was not even uploaded, see http://www.mikechambers.com/blog/2008/08/20/reading-and-writing-local-files-in-flash-player-10/ for example.
Flex/AS3 will feel a bit weird to a java programmer - parts of it are very easy and other parts will be frustrating, tooling support is worse, slow compiler, no support for running unittests without jumping through lots of hoops (don't get me started...). But as a deployment platform I must say I like it a lot.

Related

Simple way to convert .svg to .png

I am working on a Java Swing client for JIRA REST API.
Most of the work is done, and I'm now giving the UI a final touch, and I'm having trouble to view the icons/avatars of users, projects and issue types.
The REST service does provide an API for acquiring the avatars, but I can only download them as svg format, which is not usable with swing, AFAIK.
I am familiar with libraries / executables such as batik and jmagick, but using these 3rd party, platform dependent, heavy weighted tools for such low priority UI issue seems to me like an overkill.
Since the client might not have access to the internet (for users of local JIRA servers), online conversion services are also ruled out.
Is there some other simple way to convert SVG to a Swing compatible format? I was thinking maybe there's a Swing component that handles rendering SVG's, or a very simple and light library/open source code/command line tool that only handles rendering. I am also open to ideas using a specific browser installed on the client machine (if there's any way to silently load a download page in chrome to get a png file, that would be great).

Is it possible to force Java to write all graphics output to FrameBuffer? [duplicate]

Does X-Windows have to be installed on a Linux-box in order for Java to display fullscreen graphics?
Well "fullscreen graphics" is a bit vague.
Anyway, apparently there is a an effort ongoing to access the framebuffer from Java: Framebuffer Toolkit.
The objective of this project is to produce a body of code which is
a lightweight framebuffer-based peer implementation for AWT and Swing.
The goal of this code is to remove the dependency on X or
other graphics layers such that graphics can be redirected to
a framebuffer (e.g. a raw buffer, VNC, etc.). This example
implementation will prefer pure-Java solutions, with public
extension points available to enter native resources as necessary.
See Project proposal: fbtoolkit.
Other answerers appear to assume that "full screen graphics in Java" necessarily means "a working implementation of AWT". This is, of course, not necessarily true, as it is perfectly possible (some would even say desirable) to use Java without AWT.
Cairo is a 2D graphics rendering library that can be used from Java, and can also be used without X11. It looks at first glance as though it should be possible to configure it for this scenario. You'll need to configure it to use OpenGL rendering, and provide a suitable non-X11 OpenGL implementation (e.g. MesaGL with the 'fbdev' device driver).
SDLJava is a Java port of the popular C SDL game development library. This also should be able to do what you ask for, although it doesn't seem to have been updated since 2005 so if you have any problems with it support may not be forthcoming.
As an alternative, you could always use some fairly simple C code to open and configure the framebuffer, and then use JNI to return the memory-mapped framebuffer as a direct-mode ByteBuffer, so you can draw to it directly.
To really display something graphical on the screen, yes. Bud there is a headless version of the JRE for just running it. You won't see any graphical output, but it will run.
Alternatively, you can log in remotely and use X forwarding to run the java code on the server but let the client handle displaying graphics.
On an embedded device, such as a Raspberry Pi, if you don't want to go through full X11 with standard Java AWT + Swing, then this https://github.com/ttww/JavaFrameBuffer project to write straight into the frame buffer seems interesting.
An alternative may be to use e.g. SWT on GTK, or Qt Jambi, to write into the Frame Buffer (both GTK and QT can directly use a FB without X11).

Recommendations / advice needed for application technology set

I have an idea for a GUI application, however it needs a set of technologies that i do not use frequently (as such i am a bit of a novice here, apologies if this is stupid!).
I want a 3D Earth Model, (like google earth, the actual look to be like the terrain overlay in google maps (I don't care about roads, just height & position)). Like google maps & google earth i will wish to add my custom tracks & locations & boundaries; and move / pan / tilt etc...
I cannot however be continually connected to the internet. So i will need a 1 time download of terrain/geodata before i startup the program. (Can this be done as a single kml dataset ? (Is that even correct?) i guess i would need a 'local map server' instead of an internet connection?)
I will need to use a precompiled language (preferably java) to actually write the program in. (Scripting / Javascript is not acceptable) Can i interface Java & KML using an existing library ?
Is it possible to reproduce the google maps 'map window' with the terrain imaging in 3rd party software ? (Can i pull this from open source somewhere?)
Everything you want to do is possible -- however -- let me preface this by saying that it will be a long, difficult journey.
Let's start with the easy thing: you can load your data as KML, it will show up as a layer in Google Earth, and you'll be able to turn it on and off. You'll also be able to turn off default layers (roads, etc) either programmatically or via the GUI.
I would use Google Earth (the web plugin thing) tied to a C# application. You do not want to use the old Google Earth COM API. It was deprecated by Google as of GE 6, and was truly a terrible thing to work with. Java could also work, but I prefer C# development. In either case, you can use the language's ability to call into the Google Earth API directly.
Here's a good example (C#). It's GNU/GPL, so it may work as a base for your app:
http://code.google.com/p/winforms-geplugin-control-library/
Essentially, you load a Google Earth web page in a WebBrowser control, which allows you to manage it directly. Actually interfacing with the web page is the hard part (but still easier than the COM API!) -- hopefully you can use the control library linked above to get a feel for how it works.
As for your internet connectivity issue: yes -- Google Earth (even the web plugin) supports caching. The exact amount of cache that is allowed is ~100 MB. Exactly what goes in the cache is a complete mystery. The 100MB limit won't get you very far -- but you can create larger caches (up to 2GB) using the full Google Earth app. These caches work with the web browser plugin, you just have to copy the database file into the Google Earth application data directory (and rename the file I think -- the plugin appends a 0 or something to the file name.) The process for creating a cache is simple -- fly around the area in question at the altitude you'd like. There are tools to help automate this, such as:
http://bx11.110mb.com/gecacher.htm
Note that caching Google's data isn't exactly what they'd like you to do. So please keep in mind that you'll need to fully review the EULA to make sure you're not violating it...
Good luck! I've been working with GE in a large app for ~3 years; It's definitely a fun thing to work with and can make your application really stand out.

Local application with maps

I'm currently building a web application using Google Maps. Unfortunately, I've reached the absolute maximum limit that Javascript will reach for all of the different things I'd like to do, and we're exploring all of the alternatives.
We've looked at server-side caching and pre-generation/computing. It's definitely a possibility, but supposedly even that is 'too slow' while trying to plot 100k+ points in one go. As everything (as always) needs to always load instantly (or as near as darnit), I'm looking at a local application as an alternative.
Before I put forward the idea (which I already know that everyone will go for), there are two things I'm looking at first:
Can I use Google Maps locally?
I want to take the application between just PC and Mac. I'm a WPF and Web developer. Windows side, fine. Mac, however, doesn't play so nicely with those technologies. Is it time for me to bite the bullet and learn Java?
Thanks for your help!
No idea if this meets their TOS, but you could look into: http://www.howtogeek.com/90565/how-to-download-google-maps-for-offline-use/
Java AFAIK is the most main-stream high level cross-platform language for desktop applications.
Mono install rate on macs is probably extremely low in comparison to Java, though that might not be a problem if you use mkbundle. and WPF isn't supported (though GTK# is). You could do Silverlight/Moonlight, which are supported outside the browser, and quite similar to WPF.
You could also look at using C++ or Python with wxWidgets. Though if you go with Python, there are a ton of GUI libraries for it.
As I understand it, your map application involves plotting 100,000+ markers (latitude/longitude points) on a single map. You presently draw the markers on the map using JavaScript code and function calls.
Consider sticking with web-hosted Google Maps, and using one of two alternate implementation approaches.
Aggregate points. You can try drawing 100 markers onto the same screen pixel, but the user won't get any more information than if you just drew one marker. Consider aggregating multiple closely-spaced markers into aggregate markers. Google's docs have suggestions about how to do this in "Too Many Markers!", by Luke Mahe and Chris Broadfoot, Google Geo APIs Team, December 2010 (http://code.google.com/apis/maps/articles/toomanymarkers.html).
Draw markers yourself onto custom map tiles. I'm involved with a maps application which uses the Webfoot Map Tile Generator code, which takes this approach to draw approx 50,000 dots on a map of the continental US marking the location of each US Zip Code. See (http://maps.webfoot.com/demos/election2008/), and in the left pane, under "Dots Layer", select "Zip Codes" in the pull-down menu. Drawing your own map tiles isn't easy, but it's very powerful, and the Webfoot code shows it can be fast. Google doesn't completely document how to do this. But start with their description of implementing "your own custom map type using GMapType" (code.google.com/apis/maps/documentation/javascript/v2/overlays.html#CustomMapTiles) in the Maps Javascript API v2. The equivalent for the Javascript API v3 appears to be missing from (code.google.com/apis/maps/documentation/javascript/overlays.html#CustomMapTypes).

Java VNC Applet vs Screen Capture

I am trying to make an application in which one component captures the screen of the user (for screen casting). I am aware that there are two options to achieve the same using a Java applet (please correct me if I am wrong). First is to use the java applet to take screen shots continuously and convert it into a video and upload it as a video file. And second is to create a java vnc server and record it as a .fbs file and play it using a player like: http://www.wizhelp.com/flashlight-vnc/index.html
I would like to know the best solution in terms of video quality, file size, cross-platform compatibility (windows and mac), firewall problems and finally ease of implementation.
I am very new to Java. Please tell me whats the best solution for my problem. Also, is it easy enough for me to program it on my own or should I get it developed via a freelancer. I have tons of programming experience (5+ years in LAMP) but none in Java.
Thank you very much.
I agree that this is pretty hard. I implemented those two solutions (VNC and onboard screen capture) plus a third (capture from an external VGA source via an Epiphan grabber) for a former employer. I had the best bandwidth-to-quality ratio with VNC, but I got higher framerate with VGA capture. In all three cases, I reduced the frames + capture times to PNGs and sequenced them in a QuickTime reference movie. Then I made flattened video (MPEG4 or SWF) of the results. In my case, I then synchronized the screen video with a DV stream.
In the end the technology worked (see a sample of the output) but our business model failed.
From what I know, the older versions of applet had security restrictions that may not allow for screen capture. Instead, a java application may be feasible.
Regarding the build-it-yourself vs the fire-a-coder, it depends on how you value your time compared to what you can find on a freelancer site.
I think you can find someone from India/Romania/Poland/Other countries that can make it for an affordable price
Given your Java knowledge and the difficulty of the task, have you considered taking an alternative approach? For example, how about a native VNC server for the end-user, which is just a small download and then they click "Run." And that native server is programmed to capture the screen and send it straight to your web server, which has a client like vnc2swf or other means of converting the VNC stream to a video or .fbs file? Does all that make sense?
Admittedly, without Java, you have to prepare one executable program per platform you want to support, however, I don't know. That still sounds easier to me. Consider Copilot.com. They are doing VNC but they still use small native apps for each platform.
Sorry but this seems the kind of job that requires a lot of experience. Even if you find code snippets all around the net to fix this and that, the overall result may be way worse than simply hiring an experienced Java programmer.

Categories