2 * Copyright 2007 Google Inc.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package com.google.zxing.client.j2me;
19 import javax.microedition.lcdui.Canvas;
20 import javax.microedition.lcdui.Command;
21 import javax.microedition.lcdui.CommandListener;
22 import javax.microedition.lcdui.Displayable;
23 import javax.microedition.lcdui.Graphics;
26 * @author Sean Owen (srowen@google.com)
28 final class VideoCanvas extends Canvas implements CommandListener {
30 private static final Command exit = new Command("Exit", Command.EXIT, 1);
32 private final ZXingMIDlet zXingMIDlet;
34 VideoCanvas(ZXingMIDlet zXingMIDlet) {
35 this.zXingMIDlet = zXingMIDlet;
37 setCommandListener(this);
40 protected void paint(Graphics graphics) {
44 protected void keyPressed(int keyCode) {
45 // Use the "FIRE" key as a "take snapshot" key
46 if (FIRE == getGameAction(keyCode)) {
47 SnapshotThread.startThread(zXingMIDlet);
51 public void commandAction(Command command, Displayable displayable) {
52 if (command.getCommandType() == Command.EXIT || command.getCommandType() == Command.STOP) {