Java Reference
In-Depth Information
We have seen the stored images and would like to take a new picture
and upload it to the website with the location information. First, we get
our current location using JSR-179:
LocationProvider lp = getLocationProvider();
Location loc = lp.getLastKnownLocation();
// TODO: check not null, check timestamp etc..
QualifiedCoordinates qc = loc.getQualifiedCoordinates();
double lat = qc.getLatitude(),
double lon = qc.getLongitude(),
Next, we get a map of the current location from a geo site using
JSR-172 Web Services, which retrieves the map as an SVG image. We use
the NetBeans SVGPlayer utility class, which can be used as a component
in NetBeans Visual Designer and encapsulates SVGAnimator :
Display display = getMIDletDisplay();
InputStream in = getMapFromServer(); // get input stream to SVG map, using
// Web Services
SVGImage svgMap = (SVGImage)SVGImage.createImage(in, null);
svgPlayer = new SVGPlayer(svgMap, getDisplay());
svgPlayer.setStartAnimationImmediately(true);
svgPlayer.setTitle("Current location map:"); // set title
SVGElement labelElement = getSVGMapLabelElement(svgPlayer);
// Set the SVG element trait
labelElement.setTrait("#text", "Picture taken here!");
display.setCurrent(svgPlayer.getSvgCanvas());
We can then take a picture using JSR-234 AMMS, which provides
enhanced access for camera-specific controls, such as brightness, con-
trast, flash lights, lighting modes and zooming. These enable us to have
fine-grained control over the camera and the resulting picture. The fol-
lowing example demonstrates some of the controls that JSR-234 AMMS
adds on top of JSR-135 MMAPI:
player = Manager.createPlayer("capture://video");
...
snapshotControl = (SnapshotControl) player.getControl
("javax.microedition.amms.control.camera.SnapshotControl");
flashControl = (FlashControl) player.getControl
("javax.microedition.amms.control.camera.FlashControl");
zoomControl = (ZoomControl) player.getControl
("javax.microedition.amms.control.camera.ZoomControl");
focusControl = (FocusControl) player.getControl
("javax.microedition.amms.control.camera.FocusControl");
exposureControl = (ExposureControl) player.getControl
("javax.microedition.amms.control.camera.ExposureControl");
imageFormatControl = (ImageFormatControl) player.getControl
("javax.microedition.amms.control.ImageFormatControl");
...
Search WWH ::




Custom Search