TestExposureControl.java
/**
* Copyright (c) 2012 Nokia Corporation. All rights reserved.
* Nokia and Nokia Connecting People are registered trademarks of Nokia Corporation.
* Oracle and Java are trademarks or registered trademarks of Oracle and/or its
* affiliates. Other product and company names mentioned herein may be trademarks
* or trade names of their respective owners.
* See LICENSE.TXT for license information.
*/
package com.nokia.example.ammscamera;
import javax.microedition.lcdui.*;
import javax.microedition.media.MediaException;
public class TestExposureControl extends TestControl {
public TestExposureControl(CameraMIDlet cm) {
super(cm);
super.optionsForm.setTitle("Exposure Control Options");
createCameraForm(super.midlet.exposurecontrol);
if (isSupported()) {
CreateOptionsForm();
}
}
public void CreateOptionsForm() {
lightCG = new ChoiceGroup("Light Meterings:", 1, super.exposureControl.getSupportedLightMeterings(), null);
expCG = new ChoiceGroup("Exposure Compensations: ", 1);
fstopCG = new ChoiceGroup("Choose FStop:", 1);
isoCG = new ChoiceGroup("ISO: ", 1);
int exp[] = super.exposureControl.getSupportedExposureCompensations();
if (exp.length > 0) {
for (int i = 0; i < exp.length; i++) {
expCG.append(String.valueOf(exp[i]), null);
}
}
else {
expCG.append("Not supported", null);
}
String lightmeters[] = super.exposureControl.getSupportedLightMeterings();
if (lightmeters.length == 0) {
lightCG.append("Not supported", null);
}
int fstops[] = super.exposureControl.getSupportedFStops();
if (fstops.length > 0) {
for (int i = 0; i < fstops.length; i++) {
fstopCG.append(String.valueOf(fstops[i]), null);
}
}
else {
fstopCG.append("Not supported", null);
}
int isos[] = super.exposureControl.getSupportedISOs();
if (isos.length > 0) {
for (int i = 0; i < isos.length; i++) {
isoCG.append(String.valueOf(isos[i]), null);
}
}
else {
isoCG.append("Not supported", null);
}
super.optionsForm.append(lightCG);
super.optionsForm.append(expCG);
super.optionsForm.append(fstopCG);
super.optionsForm.append(isoCG);
super.optionsForm.addCommand(super.cmdBack);
super.optionsForm.setCommandListener(this);
}
public void SaveOptions() {
try {
super.exposureControl.setExposureCompensation(Integer.parseInt(expCG.getString(expCG.getSelectedIndex())));
}
catch (NumberFormatException e) {
super.midlet.showAlert("Number Format Exception", "Error saving exposure compensation.", super.canvas);
}
catch (MediaException e) {
super.midlet.showAlert("Media Exception", "Error saving exposure compensation.", super.canvas);
}
try {
super.exposureControl.setFStop(Integer.parseInt(fstopCG.getString(fstopCG.getSelectedIndex())));
}
catch (NumberFormatException e) {
super.midlet.showAlert("Number Format Exception", "Error saving fstop.", super.canvas);
}
catch (MediaException e) {
super.midlet.showAlert("Media Exception", "Error saving fstop.", super.canvas);
}
try {
super.exposureControl.setISO(Integer.parseInt(isoCG.getString(isoCG.getSelectedIndex())));
}
catch (NumberFormatException e) {
super.midlet.showAlert("Number Format Exception", "Error saving ISO.", super.canvas);
}
catch (MediaException e) {
super.midlet.showAlert("Media Exception", "Error saving ISO.", super.canvas);
}
super.exposureControl.setLightMetering(lightCG.getString(lightCG.getSelectedIndex()));
}
ChoiceGroup expCG;
ChoiceGroup lightCG;
ChoiceGroup fstopCG;
ChoiceGroup isoCG;
}