While with Processing data files were packed into the .jar, and while in a Web application, only this single file had to be transmitted to the browser, in Processingjs the situation is different: The Web server has to deliver each of the data files individually to the browser. Depending on the type of application, this might result in several hundred individual queries the Web server has to deliver.
In fast networks and with only a few hops between client and server, this is not a problem, but might easily become one for slower networks.
Are there any ideas how to overcome such a situation? E.g. compressing the folder with the data files and do a JavaScript uncompress on the browser side, or similar?
I have migrated a map application to Processingjs and in addition to the mouseWheel event that handles map zoom it would be nice to gestures such as pinch to zoom for application on mobile devices.
Has anybody already done this and could show an example?
The library navigator is an interactive map application that displays floor plans of libraries (but other rooms and their premises may be visualized as well). It helps library users to find documents easily. For this it highlights library facilities, topics and locations, shows the quickest path to a facility, and provides an overview on the library services.
The maps show the rooms of the Chemistry Biology Pharmacy Information of ETH Zürich, a small-to-middle-size science library (about 100-150 K physical documents and links to about 900K electronic documents (journal issues, e-books, webpages)).
All maps and objects are stored as SVG (scalable vector graphics). A minimal set of SVG objects (i.e. only the shelves, which are simple rectangles) is provided with the download so that the code can be tried out.
The library navigator consists of several components:
1. The library visualization applet
made with Processing and Java.
The path finding algorithms use functions of the Java library JGraphT, an open source library for objects and algorithms of graph theory.
2. Web page(s) (HTML/CSS/JavaScript, requires Yahoo YUI library)
Contains the visualization applet and provides logic for navigation of the building floors as well as for queries for topics, services, locations, or statistical library data.
3. A database for library space information (not provided with source code)
The database must provide an XML API for passing all library data to the applet. The current implementation by the Chemistry Biology Pharmacy Information Center uses FileMaker and the XML/XSLT API.
The maps of the Chemistry Biology Pharmacy Information Center use about 8000-10000 database records to describe all space objects, topics, services, and paths.
Instead of a database, XML files only can be used also. A set of XML files is provided with the source code.
We recommended to use a database, since this facilitates querying and filtering of data. Whether this is implemented as MySQL/PHP or something else, depends completely on the implementer.
4. A database for storing navigation queries (optional, not provided with source code)
5. Library catalog links for calling the library navigator
The web page (see 2.) may be called stand-alone, or it may be called from a library catalog by using an URL to pass a
localization parameter.
The library navigator software is a followup project of the GIS visualisations of library data created by the Chemistry Biology Pharmacy Information Center of ETH Zürich, see http://www.infochembio.ethz.ch/en/holdings.html. Work on adding these visualisations to the next version of the the library navigator software is currently done.
I have a slight problem with the status() function in my applet. In the applet,
status() updates an object-specific URL if an object is hovered, otherwise it is reset to an empty string.
The code that resets the browser status is
if (hovered_object == -1 && online) {
status("");
}
So far so good, everything works as expected as long as the applet runs.
However, the funny (or slightly disturbing, depending on one's perspective) thing happens after the applet is quit, e.g. by loading another web page. The Java console outputs the following error (note that the error occurs
after the applet had been quit):
everything works fine, no NullPointerException upon applet quit.
What is going on? My assumption is that there is either a timing problem or a memory problem upon stopping the threads. The complete applet code is pretty long, consisting of about 3600 lines of code and using several libraries.
I have some problems with passing focus between a Processing applet and the HTML/JavaScript page it is embedded in. My aim is that the different parts obtain focus without the user having to click them.
After initial loading of the page, focus is first on the HTML/JavaScript part. In the navigation frame at the left, floors can be hovered with the mouse and are highlighted accordingly. When one clicks a topic, a service, or simply a floor in the building, parameters are passed by calling an API method of the Processing applet and the applet obtains focus by using the Java requestFocus() method. That it has obtained focus can be seen by hovering over the space objects. Of course, now the navigation frame has lost focus (hover over building floors disabled), and one would have to click outside the applet frame to pass focus back to the navigation frame.
One idea of mine was to use a LiveConnect JSObject window.eval("window.focus();") to pass focus back to the HTML window as soon as the mouse pointer leaves the applet frame. However, there are some problems associated with that:
1. One could use the Java mouse methods as discussed in this thread (
http://processing.org/discourse/yabb2/YaBB.pl?num=1263445642 ), but this is not possible in an applet context because of the standard Java Runtime Environment policies that do not allow to track the mouse position outside the applet. One would obtain a java.security.AccessControlException: access denied (java.awt.AWTPermission watchMousePointer). Of course, I can't control the JRE settings of each individual user who accesses the applet.
2. One could use a small border region to detect mouseout:
At present, this code is implemented in draw(). However, this is not very reliable if the mouse is moved too fast (since the last draw() frame-cycle had recorded a mouseX/mouseY still in the inner region, so window.eval does not fire). Also it does not distinguish between mouse move-in and mouse move-out.
So here my question: Is there a simple Java method that tells me if the mouse pointer is within the applet frame (I don't need the exact position, which would violate the AWT permission, just in/out or true/false).
there is a textWidth() function in Processing, but not a textHeight() function.
Is there a general rule how I can determine from a given font and font size the (e.g. Verdana 9pt) the actual minimal line height in pixel (except by trial and error or by plotting some text and measuring it).