Processing 2. Креативное программирование
.pdfAndroid
GPSLocationListener. pde., LocationListener.
class GPSLocationListener implements LocationListener
{
void onLocationChanged( Location _loc )
{
latitude = (float) _loc.getLatitude(); longitude = (float) _loc.getLongitude(); accuracy = (float) _loc.getAccuracy(); provider = _loc.getProvider();
}
void onProviderDisabled( String _provider )
{
provider = "";
}
void onProviderEnabled( String _provider )
{
provider = _provider;
}
void onStatusChanged( String _provider, int status, Bundle xtras )
{
}
}
setup() :
void setup()
{
orientation( PORTRAIT );
latitude = 0; longitude = 0; accuracy = 0; provider = "";
junction = createFont( "Junction.otf", 32 ); textFont( junction, 32 );
}
240
10
draw() String , , . :
void draw()
{
background( 5, 10, 85 ); fill( 250, 255, 13 ); noStroke();
translate( width/2, height/2 );
String msg = "Latitude: " + latitude + "\n"; msg += "Longitude: " + longitude + "\n";
msg += "Accuracy: " + accuracy + "\n"; msg += "Provider: " + provider;
textAlign( CENTER, CENTER );
text( msg, 0, 0 );
}
onResume() onPause() GPS :
void onResume()
{
super.onResume();
gps = new GPSLocationListener();
manager = (LocationManager) getSystemService( Context.LOCATION_ SERVICE );
manager.requestLocationUpdates( LocationManager.NETWORK_PROVIDER, 0, 0, gps );
}
void onPause()
{
super.onPause();
}
241
Android
, - ,Android GPS. Android | Sketch Permissions ACCESS_FINE_LOCATION:
, - ., .
242
10
GPSLocationListener, , Android LocationListener. Java , - . . , , ,. LocationListener : onLocationChanged(), onProviderDisabled(), onProviderEnabled() onStatusChanged(). onStatusChanged() ,, . onLocationChanged()latitude, longitude, accuracy provider. onProviderDisabled() onProviderEnabled().
onResume() GPSLocationListener, LocationManager :
manager = (LocationManager) getSystemService( Context.LOCATION_SERVICE );
manager.requestLocationUpdates( LocationManager.NETWORK_PROVIDER, 0, 0, gps );
- . Android Network Location Provider,Wi-Fi GPS. , ,. GPS, -LocationManager.NETWORK_ PROVIDER LocationManager.GPS_Provider.
3D Android
3, 3D -3D. ,Android.
. ., .
void setup()
{
size( displayWidth, displayHeight, P3D );
}
243
Android
void draw()
{
background( 0 );
translate( width/2, height/2, 0 );
pushMatrix();
rotateY( radians( frameCount ) ); fill( 255 );
noStroke(); box( 100 ); popMatrix();
pushMatrix();
rotateY( radians( frameCount ) ); rotateX( radians( frameCount ) ); beginShape();
fill( 255, 0, 255 ); vertex( -200, -200 ); fill( 0, 255, 0 ); vertex( 200, -200 ); fill( 0, 0, 255 ); vertex( 200, 200 ); fill( 255, 255, 0 ); vertex( -200, 200 ); endShape( CLOSE ); popMatrix();
}
244
10
Android, size()sketchWidth(), sketchHeight() sketchRenderer(). -size(), 2D, .
size( sketchWidth, sketchHeight, P3D );,3D. , Android 3.,Android , .
Android
, , -, . , , ,Android Market, .
,ANBB. :
void setup()
{
size( displayWidth, displayHeight ); smooth();
}
void draw()
{
// draw red background with white shape. background( 255, 0, 0 );
fill( 255 ); noStroke();
beginShape(); vertex( width/2, 0 );
vertex( width, height/2 ); vertex( width/2, height ); vertex( 0, height/2 ); endShape( CLOSE );
}
245
Android
, . - . , 72 x 72icon-72.png .48 x 48 36 x 36 ;icon-48.png icon-36.png. , :
, ,..
246
10
Android , ,., - . PNG - . - , . ,
Android UI Guidelines. : http://developer.android.com/ guide/practices/ ui_guidelines/icon_design.html.
Processing ., Processing. icon-72.png, icon-48. png icon-36.png.
ၖၔၬၙၗၢ, data.
247
11
Processing
:
fEclipse
fProcessing Eclipse
fProcessing Eclipse
fProcessing Eclipse
fProcessing
fProcessing
fProcessing
fProcessing IntelliJ IDEA
PDE, , ..
, .
, , PDE .Processing Java, , ,IDE. , Processing Eclipse IntelliJ IDEA Processing.
Eclipse
Eclipse. Eclipse Mac OS X, Windows, and Linux.