Package net.rim.device.api.ui.container

Examples of net.rim.device.api.ui.container.ComponentCanvas


        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"));
View Full Code Here


            final int videoFieldX = (displayWidth - VIDEO_WIDTH) / 2;
            final int videoFieldY = (displayHeight - VIDEO_HEIGHT) / 2;
            absoluteFieldManager.add(videoField, videoFieldX, videoFieldY);

            // Create a ComponentCanvas for overlaying fields on the video
            final ComponentCanvas componentCanvas =
                    new ComponentCanvas(VIDEO_WIDTH + MARGIN, VIDEO_HEIGHT
                            + MARGIN);

            // Calculate the position of the ComponentCanvas
            // and add to the manager.
            final int canvasX = (displayWidth - (VIDEO_WIDTH + MARGIN)) / 2;
            final int canvasY = (displayHeight - (VIDEO_HEIGHT + MARGIN)) / 2;
            absoluteFieldManager.add(componentCanvas, canvasX, canvasY);

            // Button for pausing the video
            final ButtonField pauseButton =
                    new ButtonField("Pause", ButtonField.CONSUME_CLICK
                            | ButtonField.NEVER_DIRTY);
            pauseButton.setCommand(new Command(new CommandHandler() {
                public void execute(final ReadOnlyCommandMetadata metadata,
                        final Object object) {
                    // Pause the video
                    try {
                        _player.stop();
                    } catch (final Exception e) {
                        NWMDemo.errorDialog(e.toString());
                    }
                }
            }));

            final Image pauseImage =
                    ImageFactory.createImage(Bitmap
                            .getBitmapResource("pause.png"));
            pauseButton.setImage(pauseImage);
            componentCanvas.add(pauseButton, 0, VIDEO_HEIGHT - 15);

            // Button to start/re-start the video
            final ButtonField playButton =
                    new ButtonField("Play", ButtonField.CONSUME_CLICK
                            | ButtonField.NEVER_DIRTY);
            playButton.setCommand(new Command(new CommandHandler() {
                public void execute(final ReadOnlyCommandMetadata metadata,
                        final Object object) {
                    // Start the video
                    try {
                        _player.start();
                    } catch (final Exception e) {
                        NWMDemo.errorDialog(e.toString());
                    }
                }
            }));

            final Image playImage =
                    ImageFactory.createImage(Bitmap
                            .getBitmapResource("play.png"));
            playButton.setImage(playImage);
            componentCanvas
                    .add(playButton, VIDEO_WIDTH - 80, VIDEO_HEIGHT - 15);
        }
    }
View Full Code Here

TOP

Related Classes of net.rim.device.api.ui.container.ComponentCanvas

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.