Новое в разработке на java
TRANSCRIPT
![Page 1: Новое в разработке на Java](https://reader034.vdocuments.net/reader034/viewer/2022042700/555a81e1d8b42a98568b4e26/html5/thumbnails/1.jpg)
Series 40 Java
1
![Page 2: Новое в разработке на Java](https://reader034.vdocuments.net/reader034/viewer/2022042700/555a81e1d8b42a98568b4e26/html5/thumbnails/2.jpg)
Touch and Type
![Page 3: Новое в разработке на Java](https://reader034.vdocuments.net/reader034/viewer/2022042700/555a81e1d8b42a98568b4e26/html5/thumbnails/3.jpg)
Touch Gestures
Single Tap
Long Press
Long Press
Repeated
Drag
Drop
Flick
![Page 4: Новое в разработке на Java](https://reader034.vdocuments.net/reader034/viewer/2022042700/555a81e1d8b42a98568b4e26/html5/thumbnails/4.jpg)
Non Touch and Type MIDlets
Standard LCDUI screens (Alert, Form, List, TextBox)
Canvas
• No pointerXXX methods
• Has ponterXXX methods ?
![Page 5: Новое в разработке на Java](https://reader034.vdocuments.net/reader034/viewer/2022042700/555a81e1d8b42a98568b4e26/html5/thumbnails/5.jpg)
Inline/Native Aligned—TextField
import com.nokia.mid.ui.LCDUIUtil;
LCDUIUtil.setObjectTrait(
textField,“nokia.ui.s40.item.substate”,
new Boolean(true) );
![Page 6: Новое в разработке на Java](https://reader034.vdocuments.net/reader034/viewer/2022042700/555a81e1d8b42a98568b4e26/html5/thumbnails/6.jpg)
Gesture API
“To use platform specific
defined touch gestures and
align with the platform look
and feel.”
![Page 7: Новое в разработке на Java](https://reader034.vdocuments.net/reader034/viewer/2022042700/555a81e1d8b42a98568b4e26/html5/thumbnails/7.jpg)
Class Diagram
![Page 8: Новое в разработке на Java](https://reader034.vdocuments.net/reader034/viewer/2022042700/555a81e1d8b42a98568b4e26/html5/thumbnails/8.jpg)
Usage – step 1
• Create a GestureInteractiveZone
// Create a GestureInteractiveZone for all Gesture Types
GestureInteractiveZone giz =
new GestureInteractiveZone( GestureInteractiveZone.GESTURE_ALL );
// set bounding rectangle of zone.
giz.setRectangle( x, y, width, height);
![Page 9: Новое в разработке на Java](https://reader034.vdocuments.net/reader034/viewer/2022042700/555a81e1d8b42a98568b4e26/html5/thumbnails/9.jpg)
Usage – step 2
// Define a GestureListener
Class GestureCanvas extends Canvas implements GestureListener
{
protected void paint(Graphics g) { … }
public void gestureAction( Object container,
GestureInteractiveZone zone, GestureEvent event) {
...
}
}
![Page 10: Новое в разработке на Java](https://reader034.vdocuments.net/reader034/viewer/2022042700/555a81e1d8b42a98568b4e26/html5/thumbnails/10.jpg)
Usage – step 3
• Register the GestureInteractiveZone with the GestureRegistrationManager
// Register for Gesture events.
Canvas canvas = new GestureCanvas();
GestureRegistrationManager.register( canvas, giz );
GestureRegistationManager.setListener( canvas, canvas );
![Page 11: Новое в разработке на Java](https://reader034.vdocuments.net/reader034/viewer/2022042700/555a81e1d8b42a98568b4e26/html5/thumbnails/11.jpg)
Usage – gestureAction in more detail
public void gestureAction( Object container,
GestureInteractiveZone zone, GestureEvent event) {
switch( event.getType() ) {
case GestureInteractiveZone.GESTURE_TAP:
...;
break;
case GestureInteractiveZone.GESTURE_LONG_PRESS:
case GestureInteractiveZone.GESTURE_LONG_PRESS_REPEATED:
case GestureInteractiveZone.GESTURE_DRAG:
case GestureInteractiveZone.GESTURE_DROP:
case GestureInteractiveZone.GESTURE_FLICK:
}
}
![Page 12: Новое в разработке на Java](https://reader034.vdocuments.net/reader034/viewer/2022042700/555a81e1d8b42a98568b4e26/html5/thumbnails/12.jpg)
GestureEvent details
Methods int getType()
int getStartX()
int getStartY()
int getDragDistanceX()
int getDragDistanceY()
float getFlickDirection() returns flick direction in radians
int getFlickSpeed()
int getFlickSpeedX()
int getFlickSpeedY()
![Page 13: Новое в разработке на Java](https://reader034.vdocuments.net/reader034/viewer/2022042700/555a81e1d8b42a98568b4e26/html5/thumbnails/13.jpg)
Flick Direction
• getFlickDirection returns float which is the direction ( in radians )
![Page 14: Новое в разработке на Java](https://reader034.vdocuments.net/reader034/viewer/2022042700/555a81e1d8b42a98568b4e26/html5/thumbnails/14.jpg)
Frame Animator API
―To assist in providing
decelerated animations in
scrolling UI components.”
![Page 15: Новое в разработке на Java](https://reader034.vdocuments.net/reader034/viewer/2022042700/555a81e1d8b42a98568b4e26/html5/thumbnails/15.jpg)
Class Diagram
![Page 16: Новое в разработке на Java](https://reader034.vdocuments.net/reader034/viewer/2022042700/555a81e1d8b42a98568b4e26/html5/thumbnails/16.jpg)
Usage – step 1
• Define a GestureListener as before and a FrameAnimatorListener
class FrameAnimatorCanvas extends Canvas implements FrameAnimatorListener
{
public void animate(FrameAnimator frameAnimator,
short x, short y,
short delta, short deltaX, short deltaY,
boolean lastFrame) {
. . .
}
}
![Page 17: Новое в разработке на Java](https://reader034.vdocuments.net/reader034/viewer/2022042700/555a81e1d8b42a98568b4e26/html5/thumbnails/17.jpg)
Usage – step 2
• Register your FrameAnimatorListener
frameAnimator = new FrameAnimator();
frameAnimator.register(refX, refY, maxFps, maxPps, this);
![Page 18: Новое в разработке на Java](https://reader034.vdocuments.net/reader034/viewer/2022042700/555a81e1d8b42a98568b4e26/html5/thumbnails/18.jpg)
More on maxFps and maxPps
• maxFps is % of maximum supported frames per second.
• maxPps is % of maximum supported pixels per second.
• MIDlet gets default values though System properties.
System.getProperty( “com.nokia.mid.ui.frameanimator.fps” );
System.getProperty( “com.nokia.mid.ui.frameanimator.pps” );
![Page 19: Новое в разработке на Java](https://reader034.vdocuments.net/reader034/viewer/2022042700/555a81e1d8b42a98568b4e26/html5/thumbnails/19.jpg)
Usage – step 3
case GestureInteractiveZone.GESTURE_FLICK:
frameAnimator.kineticScroll(
event.getFlickSpeed(),
FrameAnimator.FRAME_ANIMATOR_FREE_ANGLE,
FrameAnimator.FRAME_ANIMATOR_FRICTION_MEDIUM,
event.getFlickDirection()
);
![Page 20: Новое в разработке на Java](https://reader034.vdocuments.net/reader034/viewer/2022042700/555a81e1d8b42a98568b4e26/html5/thumbnails/20.jpg)
More Information
Visit Forum Nokia Website to Download SDK | http://forum.nokia.com
Visit Forum Nokia Developer Library | http://library.forum.nokia.com
![Page 21: Новое в разработке на Java](https://reader034.vdocuments.net/reader034/viewer/2022042700/555a81e1d8b42a98568b4e26/html5/thumbnails/21.jpg)
New extensions to
Location API
![Page 22: Новое в разработке на Java](https://reader034.vdocuments.net/reader034/viewer/2022042700/555a81e1d8b42a98568b4e26/html5/thumbnails/22.jpg)
LocationUtil
• The com.nokia.mid.location.LocationUtil class provides an extra mechanism for
creating a LocationProvider.
• This is an extension to the JSR-179 Location API, which provides the
LocationProvider class.
class LocationUtils {
static LocationProvider LocationUtil.getLocationProvider(
int[] preferedMethods, String parameters );
}
• The parameters is for additional platform parameters, for now use null.
![Page 23: Новое в разработке на Java](https://reader034.vdocuments.net/reader034/viewer/2022042700/555a81e1d8b42a98568b4e26/html5/thumbnails/23.jpg)
LocationUtil
• The preferedMethods can be a combination of the following definitions of the
JSR-179 Location class:
MTA_ASSISTED
MTA_UNASSISTED
MTE_CELLID
MTE_SATELLTITE
MTE_SHORTRANGE
MTY_NETWORKBASED
MTY_TERMINALBASED
![Page 24: Новое в разработке на Java](https://reader034.vdocuments.net/reader034/viewer/2022042700/555a81e1d8b42a98568b4e26/html5/thumbnails/24.jpg)
Cell-ID based location
• A MIDlet can obtain approximate location by using the Cell-ID based method.
• This method will send to a network based server the cell-id that the phone is
connected to. This server will return the known location of that cell-id.
• This enabled phones without built in GPS to obtain an approximate Location
without requiring a separate Bluetooth GPS device.
• Note using Cell-ID based location, the coordinates can vary from a few meters to
hundreds of kilometers, depending on the local network deployment and on how
much information the backend database has been able to collect for that area.
![Page 25: Новое в разработке на Java](https://reader034.vdocuments.net/reader034/viewer/2022042700/555a81e1d8b42a98568b4e26/html5/thumbnails/25.jpg)
Cell-ID example code:
• Example code:
int[] methods = {(Location.MTA_ASSISTED |
Location.MTE_CELLID |
Location.MTY_NETWORKBASED)};
LocationProvider lp = LocationUtil.getLocationProvider(methods,
null);
Location loc = lp.getLocation(-1);
Coordinates coords = loc.getQualifiedCoordinates();
double lat = coords.getLatitude();
double lng = coords.getLongitude();
![Page 26: Новое в разработке на Java](https://reader034.vdocuments.net/reader034/viewer/2022042700/555a81e1d8b42a98568b4e26/html5/thumbnails/26.jpg)
Location Based
Services Platform API
![Page 27: Новое в разработке на Java](https://reader034.vdocuments.net/reader034/viewer/2022042700/555a81e1d8b42a98568b4e26/html5/thumbnails/27.jpg)
The Basics
• The Location Based Services Platform is a non resident API.
• Use it to include Maps and other location based services in your MIDlets.
• Download LBSP.zip from FN [ http://forum.nokia.com/maps ]
• This Zip files contains:
• The API Javadocs
• An Example MIDlet
• LBSP.jar
• The LBSP.jar implements the API using existing platform API.
• This file needs to be included in your MIDlet projects that use this API.
![Page 28: Новое в разработке на Java](https://reader034.vdocuments.net/reader034/viewer/2022042700/555a81e1d8b42a98568b4e26/html5/thumbnails/28.jpg)
Package overview
• The API is divided into four packages.
Package Description
com.nokia.maps.comon Common classes needed by other packages including
Address, ApplicationContext, GeoBoundingBox and
GeoCoordinate.
com.nokia.maps.map Map package contains classes needed to show and
interact with map content and place objects on map.
com.nokia.maps.routing Routing package contains classes to calculate route and
access route data. PositioningManager provides an easy
to get current location information based on GPS device
or device cell information.
com.nokia.maps.search Search package contains SearchManager for geocoding
and reverse geocoding.
![Page 29: Новое в разработке на Java](https://reader034.vdocuments.net/reader034/viewer/2022042700/555a81e1d8b42a98568b4e26/html5/thumbnails/29.jpg)
The minimal LBSP App
• Displaying interactive map to the user is simple as creating MapCanvas instance
and setting it as a current displayable:
import com.nokia.maps.map.MapCanvas;
/**
* Minimal MIDP application to show map content to the user.
*/
public class MapMIDlet extends MIDlet {
/**
* This method is called when the application is started and sets
* MapCanvas as a current Displayable.
*/
protected void startApp() throws MIDletStateChangeException {
Display display = Display.getDisplay(this);
MapCanvas mapCanvas = new MapCanvas( display );
display.setCurrent(mapCanvas);
}
}
![Page 30: Новое в разработке на Java](https://reader034.vdocuments.net/reader034/viewer/2022042700/555a81e1d8b42a98568b4e26/html5/thumbnails/30.jpg)
The minimal LBSP App (screen shots)
![Page 31: Новое в разработке на Java](https://reader034.vdocuments.net/reader034/viewer/2022042700/555a81e1d8b42a98568b4e26/html5/thumbnails/31.jpg)
The minimal LBSP App (screen shots)
![Page 32: Новое в разработке на Java](https://reader034.vdocuments.net/reader034/viewer/2022042700/555a81e1d8b42a98568b4e26/html5/thumbnails/32.jpg)
Map
![Page 33: Новое в разработке на Java](https://reader034.vdocuments.net/reader034/viewer/2022042700/555a81e1d8b42a98568b4e26/html5/thumbnails/33.jpg)
Map Markers
• A Marker can be added to a map with the following code:
double lat = 51.3;
double lng = 0.8;
int size = 10;
String s = “You are here!”;
GeoCoordinate coord = new GeoCoordinate(lat, lng, 0 );
MapFactory mapFactory = mapCanvas.getMapFactory();
MapStandardMarker marker =
mapFactory.createStandardMarker(coord, size, s);
mapCanvas.getMapDisplay().addMapObject( marker );
![Page 34: Новое в разработке на Java](https://reader034.vdocuments.net/reader034/viewer/2022042700/555a81e1d8b42a98568b4e26/html5/thumbnails/34.jpg)
Map Marker (screen shot)
![Page 35: Новое в разработке на Java](https://reader034.vdocuments.net/reader034/viewer/2022042700/555a81e1d8b42a98568b4e26/html5/thumbnails/35.jpg)
Other Map Markers
• The MapFactory class defines other types of Map Markers:
MapMarker createMapMarker( GeoCoordinate coordinate, Image image );
MapCircle createMapCircle( double radius, GeoCoordinate centre );
MapRectangle createMapRectangle( GeoBoundingBox boundingBox );
MapPolygon createMapPolygon( GeoCoordinate[] coordinates );
MapPolyline createMapOptPolyline( GeoCoordinate[] coordinates );
![Page 36: Новое в разработке на Java](https://reader034.vdocuments.net/reader034/viewer/2022042700/555a81e1d8b42a98568b4e26/html5/thumbnails/36.jpg)
Search Manager
• Places can be searched for with the SearchManager.
• You can also look up locations near a specified GeoCoordinate.
// Get instance of SearchManager
SearchManager searchManager = SearchManager.getInstance();
searchManager.setListener(this);
// Look up locations based on a search string
searchManager.geocode( “Germany,Berlin", null );
// Or, get locations at specified GeoCoordinate
GeoCoordinate coord = new GeoCoordinate(51.3, 0.8, 0 );
searchManager.reverseGeocode( coord );
![Page 37: Новое в разработке на Java](https://reader034.vdocuments.net/reader034/viewer/2022042700/555a81e1d8b42a98568b4e26/html5/thumbnails/37.jpg)
Routing
• RouteManager provides access to Ovi routing service.
• Calculating route requires at least two waypoints and wanted modes.
• Modes are used to control route calculation features.
// Create the waypoints
GeoCoordinate start = new GeoCoordinate(51.3, 0.8, 0);
GeoCoordinate end = new GeoCoordinate(55.0, 0.0, 0);
WaypointParameterList waypoints = new WaypointParameterList();
waypoints.addCoordinate(start);
waypoints.addCoordinate(end);
RouteManager rm = RouteManager.getInstance();
rm.setListener(this);
// Use default routing mode
RoutingMode[] modes = { new RoutingMode() };
rm.calculateRoute(waypoints, modes );
![Page 38: Новое в разработке на Java](https://reader034.vdocuments.net/reader034/viewer/2022042700/555a81e1d8b42a98568b4e26/html5/thumbnails/38.jpg)
Route Listener
public void calculateRouteRequestFinished(RouteManager rm) {
Route[] routes = rm.getRoutes();
Maneuver m = route[0].getFirstManeuver();
while( m != null ) {
String s = m.getInstruction();
…
m = m.getNextManeuver();
}
}
public void routeRequestError(RouteManager rm, Throwable error) {
// handle error condition
}
public void routeResponseCleared(RouteManager rm) {
// route cleared
}
![Page 39: Новое в разработке на Java](https://reader034.vdocuments.net/reader034/viewer/2022042700/555a81e1d8b42a98568b4e26/html5/thumbnails/39.jpg)
Routing Mode
• A RoutingMode consists of:
• A routing type.
• A list of transport modes.
• A list of routing options.
public RoutingMode(int routingType,
int[] transportModes,
java.lang.String[] routingOptions);
![Page 40: Новое в разработке на Java](https://reader034.vdocuments.net/reader034/viewer/2022042700/555a81e1d8b42a98568b4e26/html5/thumbnails/40.jpg)
Routing Types
• The Routing Type must be one of the types defined in RoutingType.
• These are static ints.
RoutingType.DIRECT_DRIVE
RoutingType.ECONOMIC
RoutingType.FASTEST
RoutingType.FASTEST_NOW
RoutingType.SCENIC
RoutingType.SHORTEST
![Page 41: Новое в разработке на Java](https://reader034.vdocuments.net/reader034/viewer/2022042700/555a81e1d8b42a98568b4e26/html5/thumbnails/41.jpg)
Transport Modes
• The following transport Modes are available.
TransportMode.BICYCLE
TransportMode.CAR
TransportMode.PEDESTRIAN
TransportMode.PUBLICTRANSPORT
TransportMode.TRUCK
![Page 42: Новое в разработке на Java](https://reader034.vdocuments.net/reader034/viewer/2022042700/555a81e1d8b42a98568b4e26/html5/thumbnails/42.jpg)
Routing Options
• These are string constants defines in RoutingOptions.
NOTE: HOVLANE = High occupancy vehicle lane.
RoutingOptions.AVOID_BOATFERRY
RoutingOptions.AVOID_DIRTROAD
RoutingOptions.AVOID_MOTORWAY
RoutingOptions.AVOID_PARK
RoutingOptions.AVOID_PUBLICTRANSPORT
RoutingOptions.AVOID_RAILFERRY
RoutingOptions.AVOID_STAIRS
RoutingOptions.AVOID_TOLLROAD
RoutingOptions.AVOID_TUNNEL
RoutingOptions.PREFER_HOVLANE
![Page 43: Новое в разработке на Java](https://reader034.vdocuments.net/reader034/viewer/2022042700/555a81e1d8b42a98568b4e26/html5/thumbnails/43.jpg)
Custom Display
• So far the example used a MapCanvas which performs all the Map rendering.
• The LBSP API also allows you to use the MapDisplay directly, to provide a
greater control on how the Maps are rendered to the canvas.
MapFactory mapFactory = MapFactory.createMapFactory(
MapDisplayType.TILE_MAP,
MapResolutionEnum.MAP_RESOLUTION_128_x_128,
getWidth(), getHeight() );
MapDisplay map = mapFactory.createMapDisplay();
• Display Type can be either: TILE_MAP or VECTOR_MAP
• Resolution can be either: 128 x 128 or 256 x 256
![Page 44: Новое в разработке на Java](https://reader034.vdocuments.net/reader034/viewer/2022042700/555a81e1d8b42a98568b4e26/html5/thumbnails/44.jpg)
Using MapDisplay
• You can then render the map on your own Canvas with renderMap(Graphics)
protected void paint(Graphics g) {
map.renderMap(g);
}
• Alternatively, you can render the map to an Image instead and then use that
Image wherever you like.
Image image = Image.createImage( width, height );
Graphics g = image.getGraphics();
map.renderMap(g);
![Page 45: Новое в разработке на Java](https://reader034.vdocuments.net/reader034/viewer/2022042700/555a81e1d8b42a98568b4e26/html5/thumbnails/45.jpg)
Custom Display Screen shot
![Page 46: Новое в разработке на Java](https://reader034.vdocuments.net/reader034/viewer/2022042700/555a81e1d8b42a98568b4e26/html5/thumbnails/46.jpg)
On-Line Resources: forum.nokia.com
http://forum.nokia.com/Develop/Java
http://forum.nokia.com/Develop/Web
![Page 47: Новое в разработке на Java](https://reader034.vdocuments.net/reader034/viewer/2022042700/555a81e1d8b42a98568b4e26/html5/thumbnails/47.jpg)
On-Line Resources: forum.nokia.com
http://forum.nokia.com/Maps
![Page 48: Новое в разработке на Java](https://reader034.vdocuments.net/reader034/viewer/2022042700/555a81e1d8b42a98568b4e26/html5/thumbnails/48.jpg)
Thank you!