Skip to content
This repository has been archived by the owner on Sep 4, 2019. It is now read-only.

Commit

Permalink
BlackBerry Samples for Java release 7.0.0.
Browse files Browse the repository at this point in the history
An Open Source version of the samples as they were released
with the 7.0.0 Java Development Environment release.

The BlackBerry Samples for Java project is an Open Source
repository of samples that in the past were released through
the BlackBerry Developer Knowledge Base or within the
BlackBerry Java Tools.  The samples range in scope from Hello
World, to Advanced UI components and include both samples and
libraries that offer extended functionality.

Copyright (c) 2011 Research In Motion Limited

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
  • Loading branch information
slegge committed Dec 1, 2011
1 parent ea58453 commit ec58ace
Show file tree
Hide file tree
Showing 284 changed files with 16,047 additions and 4,808 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ AccessibleContext.ACCESSIBLE_STATE_CHANGED, new Integer(
}

/**
* @see Field#onUnFocus()
* @see Field#onUnfocus()
*/
protected void onUnfocus() {
super.onUnfocus();
Expand All @@ -215,7 +215,7 @@ AccessibleContext.ACCESSIBLE_STATE_CHANGED, new Integer(
}

/**
* @see Field#getAccesssibleContext()
* @see Field#getAccessibleContext()
*/
public AccessibleContext getAccessibleContext() {
return this;
Expand Down Expand Up @@ -298,7 +298,7 @@ public boolean isAccessibleStateSet(final int state) {
}

/**
* @see AccessibleContext#getAccessibleChildSelected(int)
* @see AccessibleContext#isAccessibleChildSelected(int)
*/
public boolean isAccessibleChildSelected(final int index) {
// Check whether child icon at the specified index is selected
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public TableComponent(final int columnCount, final int rowCount) {
}

/**
* @see Manager#getAccesssibleContext()
* @see Manager#getAccessibleContext()
*/
public AccessibleContext getAccessibleContext() {
return this;
Expand Down Expand Up @@ -386,7 +386,7 @@ public int getAccessibleStateSet() {
}

/**
* @see AccessibleContext#isAccessibleStateSet()
* @see AccessibleContext#isAccessibleStateSet(int)
*/
public boolean isAccessibleStateSet(final int state) {
return (state & getAccessibleStateSet()) != 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public TextComponent(final String text) {
// *********************** Field implementation ****************************

/**
* @see Field#getAccesssibleContext()
* @see Field#getAccessibleContext()
*/
public AccessibleContext getAccessibleContext() {
return this;
Expand All @@ -96,7 +96,7 @@ public int getPreferredHeight() {
}

/**
* @see Field#layout(width, height)
* @see Field#layout(int, int)
*/
protected void layout(final int width, final int height) {
// Split text into lines based on the given width
Expand Down Expand Up @@ -279,7 +279,7 @@ public AccessibleValue getAccessibleValue() {
}

/**
* @see AccessibleContext#getAccessibleChildSelected(int)
* @see AccessibleContext#isAccessibleChildSelected(int)
*/
public boolean isAccessibleChildSelected(final int index) {
// Text field doesn't have any children
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public ValueComponent(final int min, final int current, final int max) {
// ********************Field implementation ********************************

/**
* @see Field#getAccesssibleContext()
* @see Field#getAccessibleContext()
*/
public AccessibleContext getAccessibleContext() {
return this;
Expand Down Expand Up @@ -169,7 +169,7 @@ AccessibleContext.ACCESSIBLE_STATE_CHANGED, new Integer(
}

/**
* @see Field#onUnFocus()
* @see Field#onUnfocus()
*/
protected void onUnfocus() {
super.onUnfocus();
Expand Down Expand Up @@ -233,7 +233,7 @@ public boolean isAccessibleStateSet(final int state) {
}

/**
* @see AccessibleContext#getAccessibleChildAt(int
* @see AccessibleContext#getAccessibleChildAt(int)
*/
public AccessibleContext getAccessibleChildAt(final int index) {
// No children in the value component
Expand Down
13 changes: 7 additions & 6 deletions com/rim/samples/device/attachmentdemo/FileExplorerScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public Field[] getDataFields(final int modelRowIndex) {
_view.setDataTemplate(dataTemplate);
dataTemplate.useFixedHeight(true);

// Add the file to the screen
// Add the TableView to the screen
add(_view);

readRoots(ROOT);
Expand Down Expand Up @@ -218,10 +218,11 @@ private void readRoots(final String root) {
// Reset the table contents
_model.removeAllRows();

FileConnection fc = null;
Enumeration rootEnum = null;

if (root != null) {
FileConnection fc = null;

// Open the file system and get the list of directories/files
try {
fc = (FileConnection) Connector.open(root);
Expand Down Expand Up @@ -276,8 +277,8 @@ private void readSubroots(final String file) {
new FileHolder(file, fc.isDirectory());
_model.addRow(fileholder);
} catch (final IOException e) {
AttachmentDemo
.errorDialog("Connector.open() threw " + e.toString());
System.out.println("Connector.open(" + file + ") threw "
+ e.toString());
} finally {
if (fc != null) {
// Everything is read. Close the connection.
Expand Down Expand Up @@ -375,7 +376,7 @@ protected boolean doAddRow(final Object row) {
}

/**
* @see net.rim.device.api.ui.component.table.TableModelAdapter#doRemoveRowAt()
* @see net.rim.device.api.ui.component.table.TableModelAdapter#doRemoveRowAt(int)
*/
protected boolean doRemoveRowAt(final int index) {
_elements.removeElementAt(index);
Expand All @@ -390,7 +391,7 @@ protected Object doGetRow(final int index) {
}

/**
* @see net.rim.device.api.ui.component.table.TableModelAdapter#removeAllRows()
* Removes all rows by repeatedly invoking {@link #removeRowAt}
*/
public void removeAllRows() {
while (getNumberOfRows() > 0) {
Expand Down
139 changes: 139 additions & 0 deletions com/rim/samples/device/augmentedrealitydemo/ARDemoCameraScreen.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
/*
* ARDemoCameraScreen.java
*
* Copyright © 1998-2011 Research In Motion Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Note: For the sake of simplicity, this sample application may not leverage
* resource bundles and resource strings. However, it is STRONGLY recommended
* that application developers make use of the localization features available
* within the BlackBerry development platform to ensure a seamless application
* experience across a variety of languages and geographies. For more information
* on localizing your application, please refer to the BlackBerry Java Development
* Environment Development Guide associated with this release.
*/

package com.rim.samples.device.augmentedrealitydemo;

import javax.microedition.media.Player;
import javax.microedition.media.control.GUIControl;
import javax.microedition.media.control.VideoControl;

import net.rim.device.api.system.Display;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.RichTextField;
import net.rim.device.api.ui.container.ComponentCanvas;
import net.rim.device.api.ui.container.MainScreen;

/**
* MainScreen subclass for the Augmented Reality Demo application. This screen
* positions a rotating 3D cube on top of the camera view finder. The cube
* changes its axis of rotation when the orientation of the device changes.
*/
public final class ARDemoCameraScreen extends MainScreen {
private Field _cameraField;
private Player _player;
private DemoGLField _glField;
private static final int GL_FIELD_HEIGHT = Display.getHeight() / 3;
private static final int GL_FIELD_WIDTH = GL_FIELD_HEIGHT;
private static final int GL_FRAME_RATE = 60;

/**
* Creates a new ARDemoCameraScreen object
*/
public ARDemoCameraScreen() {
// Set the title of the screen
setTitle("Augmented Reality Demo");

// Initialize the camera object and camera field
initializeCamera();

// If the camera field was constructed successfully, create the UI
if (_cameraField != null) {
// Add the camera field to a new ComponentCanvas
final ComponentCanvas compCanvas =
new ComponentCanvas(Display.getWidth(), Display.getHeight());
compCanvas.add(_cameraField, 0, 0);

// Initialize GLField
_glField = new DemoGLField(GL_FIELD_WIDTH, GL_FIELD_HEIGHT);
_glField.setTargetFrameRate(GL_FRAME_RATE);

// Add the GLField to the canvas
compCanvas.add(_glField, 100, 100);

// Add the ComponentCanvas to the screen
add(compCanvas);
} else {
add(new RichTextField("Error connecting to camera"));
}
}

/**
* @see net.rim.device.api.ui.Screen#close()
*/
public void close() {
if (_player != null) {
try {
_player.close();
} catch (final Exception e) {
}
}

_glField.cleanUp();

super.close();
}

/**
* Initializes the Player, VideoControl and camera field
*/
private void initializeCamera() {
try {
// Create a player for the camera view finder
_player =
javax.microedition.media.Manager
.createPlayer("capture://video");

// Set the player to the REALIZED state
_player.realize();

// Get the video control
final VideoControl videoControl =
(VideoControl) _player.getControl("VideoControl");

if (videoControl != null) {
// Create the video field as a GUI primitive
_cameraField =
(Field) videoControl.initDisplayMode(
GUIControl.USE_GUI_PRIMITIVE,
"net.rim.device.api.ui.Field");
videoControl.setDisplayFullScreen(true);
videoControl.setVisible(true);
}

// Set the player to the STARTED state
_player.start();
} catch (final Exception e) {
UiApplication.getUiApplication().invokeLater(new Runnable() {
public void run() {
Dialog.alert("ERROR " + e.getClass() + ": "
+ e.getMessage());
}
});
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* AugmentedRealityDemo.java
*
* Copyright © 1998-2011 Research In Motion Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Note: For the sake of simplicity, this sample application may not leverage
* resource bundles and resource strings. However, it is STRONGLY recommended
* that application developers make use of the localization features available
* within the BlackBerry development platform to ensure a seamless application
* experience across a variety of languages and geographies. For more information
* on localizing your application, please refer to the BlackBerry Java Development
* Environment Development Guide associated with this release.
*/

package com.rim.samples.device.augmentedrealitydemo;

import net.rim.device.api.opengles.GLUtils;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.Dialog;

/**
* This application shows an example of overlaying a graphical object on a
* surface backed field to create an augmented reality experience. The
* application displays a spinning 3D cube object on top of the camera view
* finder. The cube changes its axis of rotation when the orientation of the
* device changes.
*/
public final class AugmentedRealityDemo extends UiApplication {

/**
* Entry point for application
*
* @param args
* Command line arguments (not used)
*/
public static void main(final String[] args) {
// Create a new instance of the application and make the currently
// running thread the application's event dispatch thread.
final AugmentedRealityDemo app = new AugmentedRealityDemo();
app.enterEventDispatcher();
}

/**
* Creates a new AugmentedRealityDemo object
*/
public AugmentedRealityDemo() {
// Check whether OpenGL is supported on the current BlackBerry
// Smartphone
if (GLUtils.isSupported()) {
pushScreen(new ARDemoCameraScreen());
} else {
UiApplication.getUiApplication().invokeLater(new Runnable() {
public void run() {
Dialog.alert("This device does not support OpenGL, exiting Augmented Reality Demo application...");
System.exit(0);
}
});
}
}
}
Loading

0 comments on commit ec58ace

Please sign in to comment.