Subversion Repositories svnkaklik

Compare Revisions

Ignore whitespace Rev 156 → Rev 157

/programy/Java/AVRcamVIEW/src/avr/lang/AVRSystem.java
0,0 → 1,89
/*
AVRcamVIEW: A PC application to test out the functionallity of the
AVRcam real-time image processing engine.
Copyright (C) 2004 Brent A. Taylor
 
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
 
You should have received a copy of the GNU General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
For more information on the AVRcamVIEW, please contact:
 
taylorba@comcast.net
 
or go to www.jrobot.net for more details regarding the system.
*/
 
package avr.lang;
 
import java.util.logging.*;
import java.util.prefs.*;
import javax.swing.*;
 
import avr.device.*;
 
public class AVRSystem {
 
public static final Resource RES;
 
public static final Logger LOG;
 
public static final String RELEASE_MINOR;
public static final String RELEASE_MAJOR;
 
public static final String BUILD_DATE;
 
public static final Preferences PREFS;
 
public static final JFileChooser FILE_CHOOSER;
public static final String BAYER_FILE_EXT;
public static final String TRACK_FILE_EXT;
 
public static final int IMAGE_WIDTH;
public static final int IMAGE_HEIGHT;
 
public static final int NUM_INTENSITIES;
 
public static final Device DEVICE;
 
static {
 
LOG = Logger.getLogger("AVRcamVIEW");
LOG.setLevel(Level.ALL);
 
PREFS = Preferences.userRoot().node("AVRcamVIEW");
 
RES = new Resource("avr.resource.avr");
 
FILE_CHOOSER = new JFileChooser(".");
 
BAYER_FILE_EXT = RES.getString("file.ext.byr");
TRACK_FILE_EXT = RES.getString("file.ext.trk");
 
IMAGE_WIDTH = RES.getInt("image.width");
IMAGE_HEIGHT = RES.getInt("image.height");
 
NUM_INTENSITIES = RES.getInt("number.intensities");
 
BUILD_DATE = RES.getString("build.date");
RELEASE_MAJOR = RES.getString("build.major");
RELEASE_MINOR = RES.getString("build.minor");
 
DEVICE = new Device();
 
}
 
private AVRSystem() {
}
 
}
/programy/Java/AVRcamVIEW/src/avr/lang/Resource.java
0,0 → 1,120
/*
AVRcamVIEW: A PC application to test out the functionallity of the
AVRcam real-time image processing engine.
Copyright (C) 2004 Brent A. Taylor
 
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
 
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
 
You should have received a copy of the GNU General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
For more information on the AVRcamVIEW, please contact:
 
taylorba@comcast.net
 
or go to www.jrobot.net for more details regarding the system.
*/
 
package avr.lang;
 
import java.util.*;
 
/***************************************************************
* This is a convience class wrapped around a ResourceBundle.
*/
public class Resource {
 
/**
* The ResourceBundle to retrieve the key=value mappings.
*/
private final ResourceBundle BUNDLE;
 
/**
* Create an instance of this resource bundle to retrieve the
* key=value pairs from the given file.
* @param file The file containing the key=value pairs.
*/
public Resource(String file) {
BUNDLE = ResourceBundle.getBundle(file);
}
 
/**
* Gets a String for the given key from this resource bundle
* @param key The key for the desired string
* @return The string for the given key
*/
public String getString(String key) {
return BUNDLE.getString(key);
}
 
/**
* Convience method to convert the returned value for the key into
* an integer.
* @param key The key for the desired integer
* @return The integer for the given key.
*/
public int getInt(String key) {
return Integer.parseInt(getString(key));
}
 
/**
* Convience method to convert the returned value for the key into
* an character.
* @param key The key for the desired character
* @return The character for the given key.
*/
public char getChar(String key) {
return getString(key).charAt(0);
}
 
/**
* Convience method to convert the returned value for the key into
* an boolean.
* @param key The key for the desired boolean
* @return The boolean for the given key.
*/
public boolean getBoolean(String key) {
return new Boolean(getString(key)).booleanValue();
}
 
/**
* Convience method to convert the returned value for the key into
* an array of Strings.
* @param key The key for the desired array of Strings
* @return The array of Strings for the given key.
*/
public String[] getStrings(String key) {
// split the value string on every "," or ", "
return getString(key).split(",\\s*");
}
 
/**
* Convience method to convert the returned value for the key into
* an array of Integers.
* @param key The key for the desired array of Integers
* @return The array of Integers for the given key.
*/
public Integer[] getIntegers(String key) {
 
String[] strValues = getStrings(key);
 
Integer[] values = new Integer[strValues.length];
 
for(int i = 0; i < strValues.length; i++) {
values[i] = new Integer(strValues[i]);
}
 
return values;
 
}
 
}