Sunteți pe pagina 1din 48

Cdigo 1

package veridis.biometric.samples.util;
import
import
import
import
import

java.awt.Component;
java.io.File;
java.io.IOException;
java.io.PrintStream;
java.util.Scanner;

import javax.swing.JDialog;
import javax.swing.JOptionPane;
import veridis.biometric.BiometricSDK;
import veridis.biometric.BiometricException.LicenseException;
/**
* Helper class to license the SDK.
* <p>
* If you are using the FREE version of this SDK, there is no need to
worry about licensing.
* Otherwise, licensing would usually take a single line:
* <p>
* {@code BiometricSDK.installLicense("MY LICENSE KEY");}
* <p>
* Unfortunately, the samples don't know whenever you are using the
FREE license or what is you license key, . It's needed to show a
dialog, test if the license entered is OK, try again, etc. That's what
this class does!
*/
public class LicenseHelper {
/**
* Asks the license key to the user, and use it to start the
SDK
* If you plan to use the FREE edition, calling this method is
not required at all.
* Also, this method can be replaced by a single line of code:
BiometricSDK.installLicense("MY LICENSE KEY");
*/
public static void installLicense() {
installLicense(null);
}

/**
* Asks the license key to the user, and use it to start the
SDK.

*
* If you plan to use the FREE edition, calling this method is
not required at all.
* Also, this method can be replaced by a single line of code:
BiometricSDK.installLicense("MY LICENSE KEY");
* @param parent Parent component, which will be blocked by a
modal dialog.
*/
public static void installLicense(Component parent) {

System.out.println(BiometricSDK.getVersion());
File licenseFile = new File("vrlicense");
try {
String licenseText="";
Scanner s = new Scanner(licenseFile);
while (s.hasNextLine())
licenseText += s.nextLine() + "\n";
BiometricSDK.installLicense(licenseText);
return; //SUCESS!
} catch (Exception e) {
//No conseguiu utilizar uma licena salva
anteriormente.

String OK_OPTION="Use license key";


String CANCEL_OPTION="Use FREE";
JOptionPane freeOptionPane = new JOptionPane("Enter
your " + BiometricSDK.getVersion().getLibraryName() + " license key,
or use FREE", JOptionPane.QUESTION_MESSAGE,
JOptionPane.DEFAULT_OPTION, null, new String[] {OK_OPTION,
CANCEL_OPTION} );
freeOptionPane.setWantsInput(true);
JDialog dialog = freeOptionPane.createDialog(parent,
"Install License Key?");
dialog.setModal(true);

licensing.

//Asks the user for the license key and do online

while (true) {
dialog.setVisible(true);
if (freeOptionPane.getValue() != OK_OPTION) {
System.out.println("Licensed as " +
BiometricSDK.getLicense().getKey());
return; //Self-licensed as FREE
}
try {

BiometricSDK.installLicense(freeOptionPane.getInputValue().toString())
;
} catch (LicenseException e) {
JOptionPane.showMessageDialog(parent,
"Licensing failed:\n" + e, "Licensing failed",
JOptionPane.ERROR_MESSAGE);
continue;
}
//Licenciado com sucesso
System.out.println("Licensed as " +
BiometricSDK.getLicense().getKey());
//Salva o texto da licena para a prxima
vez...
try {
new
PrintStream(licenseFile).print(BiometricSDK.getLicense().getFullText()
);
} catch (IOException e) { /*Never mind...*/ }
//Sucesso!
return;

}
}

Cdigo 2
package veridis.biometric.samples.applet;
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import

java.awt.BorderLayout;
java.awt.Dimension;
java.awt.Graphics2D;
java.awt.image.BufferedImage;
java.io.ByteArrayOutputStream;
java.io.CharArrayWriter;
java.io.InputStream;
java.io.PrintWriter;
java.net.URL;
java.net.URLConnection;
java.net.URLStreamHandler;
java.security.AccessController;
java.security.PrivilegedAction;
java.text.SimpleDateFormat;
java.util.ArrayList;
java.util.Calendar;
java.util.List;

import
import
import
import

javax.imageio.ImageIO;
javax.swing.JApplet;
javax.swing.JOptionPane;
javax.swing.SwingUtilities;

import
import
import
import
import
import
import
import

veridis.biometric.BiometricException;
veridis.biometric.BiometricIdentification;
veridis.biometric.BiometricImage;
veridis.biometric.BiometricSDK;
veridis.biometric.BiometricScanner;
veridis.biometric.BiometricTemplate;
veridis.biometric.CaptureEventListener;
veridis.biometric.JBiometricPanel;

/**
* <p>
* Essa classe &eacute; usada para fornecer acesso a m&eacute;todos de
captura
* /extra&ccedil;&atilde;o / verifica&ccedil;&atilde;o.
* </p>
*
*
* Parmetros:
*
* <ul>
* <li><i>Callbacks:</i></li>
* <li><b>onLoaded</b> - Esse callback chamado assim que o applet
totalmente carregado.</li>
* <li><b>onInitialization</b> - Esse callback chamado aps o
carregamento do applet, aps o licenciamento ser feito com
sucesso.</li>

* <li><b>onCapture</b> - Esse callback chamado a cada captura


realizada pelo equipamento biom&eacute;trico. Se o parmetro
*
<b>verifyTemplates</b> for verdadeiro, a imagem capturada
verificada com os templates armazenados internamente. Se a imagem
capturada obtiver
*
<i>matching</i>, o callback chamado. Caso contrrio,
chamado o callback <b>onBadVerify</b></li>
* <li><b>onBadVerify</b> - Esse <i>callback</i> chamado quando uma
captura realizada pelo equipamento biomtrico no obtiver matching
com os templates armazenados internamente.
* S chamado se o parmetro <b>verifyTemplates</b> for
verdadeiro.</li>
* <li><b>onPlaced</b> - Esse <i>callback</i> chamado quando a
biometria colocada no equipamento de captura.</li>
* <li><b>onRemoved</b> - Esse <i>callback</i> chamado quando a
biometria removida do equipamento de captura.</li>
*
* <li><i>Outros:</i></li>
* <li><b>license</b> - A chave da licena do Veridis Biometric
SDK.</li>
* <li><b>verifyTemplates</b> - Esse parmetro define se, para cada
captura, ser verificada se o template compatvel com os templates
armazenados internamente.</li>
* <li><b>verifyMinThreshold</b> - Esse parmetroc define o limiar
que determina quando ocorre uma verifica&cco com sucesso entre
dois templates. Por padro <b>20</b></li>
* <li><b>identifyTemplates</b> - Esse parmetro define se, para cada
captura, ser verificada se o template compatvel com os templates
armazenados internamente.</li>
* <li><b>identifyThreshold</b> - Esse parmetroc define o limiar que
determina quando ocorre uma verifica&cco com sucesso entre dois
templates. Por padro <b>20</b></li>
* </ul>
*
* @author <a href="mailto:moacyr.ricardo@veridistec.com.br">Moacyr
Ricardo Pereira Neto</a>
*
*/
public class AppletIdentificationSample extends JApplet implements
CaptureEventListener {
private static final long serialVersionUID =
7349792354643528033L;
private JBiometricPanel fingerprintViewPanel = new
JBiometricPanel();
private BufferedImage logo = null;
private List<BiometricTemplate> allTemplates = new
ArrayList<BiometricTemplate>();
private BiometricImage
lastImage;
private BiometricTemplate lastTemplate;
private BiometricScanner lastScanner;

//============================================================
//===================== APPLET LIFECICLE =====================

//============================================================
debug("Failed to install the license \"" + licenseKey + "\":" +
e.toString())
@Override
public void init() {
Thread.setDefaultUncaughtExceptionHandler(new
Thread.UncaughtExceptionHandler() {
public void uncaughtException(Thread t,
Throwable e) {
e.printStackTrace(System.err);
CharArrayWriter exceptionString = new
CharArrayWriter();
PrintWriter printWriter = new
PrintWriter(exceptionString);
e.printStackTrace(printWriter);
JOptionPane.showMessageDialog(getContentPane(),
exceptionString.toString(), "Uncaught Exception",
JOptionPane.ERROR_MESSAGE);
}
});
debug("Applet.init()");
super.init();
setPreferredSize(new Dimension(200, 250));
getContentPane().setLayout(new BorderLayout());
getContentPane().add(fingerprintViewPanel,
BorderLayout.CENTER);
try {

InputStream in =
AppletIdentificationSample.class.getResourceAsStream("veridislogo.png"
);
if (in == null)
debug("Can't find resource
veridislogo.png");
else
logo = ImageIO.read(in);
} catch (Exception e) {
debug("Failed to load veridislogo.png", e);
}
try {
this.getClass().getClassLoader().loadClass("netscape.javascript.JSObje
ct");
} catch (ClassNotFoundException e) {
debug("ClassNotFoundException: " +
e.getMessage());
}
callback("onInit");
}
@Override
public void start() {
debug("Applet.start()");
//Reset the UI
resetTemplateData();

//License the library.


//Will do it later, otherwise the applet won't be
displayed until it has finished =/
SwingUtilities.invokeLater(new Runnable() {
public void run() {
boolean firstLoop = true;
String licenseKey = null;
while (BiometricSDK.getLicense() ==
null) { //Retries until OK
if (firstLoop) {
licenseKey =
getParameter("license");
firstLoop = false;
if (licenseKey==null)
continue;
} else {
licenseKey =
JOptionPane.showInputDialog(getContentPane(), "Type the license key:",
licenseKey);
if (licenseKey==null) {
JOptionPane.showMessageDialog(getContentPane(), "Applet
disabled");
return;
}
}
if (licenseKey != null) {
try {
BiometricSDK.installLicense(licenseKey);
} catch
(BiometricException e) {
debug("Failed to
install the license \"" + licenseKey + "\":" + e.toString());
JOptionPane.showMessageDialog(getContentPane(), "Failed to
install the license \"" + licenseKey + "\":" + e.toString(), "Failed
to install license", JOptionPane.ERROR_MESSAGE);
}
}
}
debug("License installed: " +
BiometricSDK.getLicense().getKey());
callback("onStart");
}
});
}
@Override
public void stop() {
debug("Applet.stop()");

};

stopCapture();
callback("onStop");
super.stop();

@Override
public void destroy() {
debug("Applet.destroy()");

stopCapture();
callback("onDestroy");
super.destroy();

public void persistTemplate() {


allTemplates.add(lastTemplate);
}
public void persistTemplate(String template64Base) {
try {
allTemplates.add(new
BiometricTemplate( Base64.decode(template64Base) ));
} catch (Exception e) {
debug("Failed to decode Base64 template", e);
}
}
public String getTemplate() {
if (lastTemplate == null) return null;
return Base64.encodeBytes(this.lastTemplate.getData());
}
public int getIdentificationScore(){
return identificationScore;
}
public int getIdentificationIndex(){
return identificationIndex;
}
public String getImage() {
return getImage(lastImage.getWidth(),
lastImage.getHeight());
}
public String getImage(final int _width, final int _height) {
return AccessController.doPrivileged(new
PrivilegedAction<String>() {
public String run() {
if (lastImage == null) return null;
try {
int width = _width;
int height = _height;
double scale = 1;
BufferedImage img = lastImage;
if (width >= 1)
scale = Math.min(scale,
width / (double)img.getWidth() );
if (height >= 1)
scale = Math.min(scale,
height / (double)img.getHeight() );
(img.getWidth (null)*scale + 0.5);
(img.getHeight(null)*scale + 0.5);

int destWidth

= (int)

int destHeight = (int)


if (width <= 0)

destWidth;

width =

if (height <= 0) height =


destHeight;
destHeight!=img.getHeight()) {

if (destWidth!=img.getWidth() ||

BufferedImage dest = new


BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
Graphics2D g =
dest.createGraphics();
g.drawImage(img, (widthdestWidth)/2, (height-destHeight)/2, destWidth, destHeight, null);
g.dispose();
img = dest;
}
ByteArrayOutputStream();

ByteArrayOutputStream baos = new

ImageIO.write(img, "png", baos);


return
Base64.encodeBytes(baos.toByteArray());
} catch (Exception e) {
debug("Failed to get Base64 PNG
image", e);
return null;
}
}
});
}
public String getScannerName() {
System.out.println("lastScanner = " + lastScanner);
if (lastScanner == null) return null;
return lastScanner.toString();
}
/**
* Clears the applet's inner template list.<br/>
* <br/>
* Limpa a lista de templates interna do applet.
*
* @see
AppletIdentificationSample#persistTemplateDataOnTemplates()
*/
public void resetTemplateData() {
allTemplates.clear();
for (int i = 1; getParameter("template" + i) != null;
i++) {
String strTemp = getParameter("template" + i,
"").trim();
if (strTemp.length() == 0) break;
try {
byte[] tempData =
Base64.decode(strTemp);
allTemplates.add(new
BiometricTemplate(tempData));
} catch (Exception e) {
debug("Invalid Template #" + i, e);
}
}
lastTemplate = null;
lastImage = null;
lastScanner = null;

fingerprintViewPanel.setImage(logo);
debug("Applet.resetTemplateData()");
}
/**
* Returns a {@link String} containing debug messages.<br/>
* <br/>
* Retorna uma {@link String} contendo mensagens de debug.
*
* @return The debug messages
*/
public String getDebug() {
return this.logBuffer.toString();
}

//==========================================================
//===================== DEBUG MESSAGES =====================
//==========================================================
private StringBuffer logBuffer = new StringBuffer();
private int identificationScore;
private int identificationIndex;
private void debug(String m) {
debug(m, null);
}
private void debug(String m, Throwable t) {
SimpleDateFormat f = new SimpleDateFormat("dd/MM/yyyy
HH:mm:ss.SSS");
this.logBuffer
.append(f.format(Calendar.getInstance().getTime
()))
.append(" : ")
.append(m)
.append("\n");
System.err.println(m);
if (t != null) {
CharArrayWriter exceptionString = new
CharArrayWriter();
PrintWriter printWriter = new
PrintWriter(exceptionString);
t.printStackTrace(printWriter);
this.logBuffer.append(exceptionString.toString());
t.printStackTrace(System.err);
}
}

callback("onDebug");

===

//=============================================================

//===================== START / STOP CAPTURE


=====================
//=============================================================
===
/**
* This method causes the applet to respond to the events of
the capture devices.<br/>
* <br/>
* Esse mtodo faz com que o applet comece a responder pelos
eventos dos equipamentos de captura.
*/
public void startCapture() {
try {
BiometricSDK.addCaptureEventListener(this);
debug("Capture started.");
} catch (BiometricException e) {
debug("Failed to start capture: " +
e.toString());
}
}
/**
* This method is the counterpart of the method <i>{@link
AppletIdentificationSample} .startCapture()</i>
* and causes the applet to stop responding to events of the
capture device.<br/>
* <br/>
* Esse mtodo a contrapartida do mtodo <i>{@link
AppletIdentificationSample} .startCapture()</i>
* e faz com que o applet pare de responder aos eventos dos
equipamentos de captura.
*/
public void stopCapture() {
try {
BiometricSDK.removeCaptureEventListener(this);
debug("Capture stopped.");
} catch (BiometricException e) {
debug("Failed to stop capture: " +
e.toString());
}
}
public void onCaptureEvent(CaptureEventType evt,
BiometricScanner bioScanner, BiometricImage img) {
lastScanner = bioScanner;
if (evt == CaptureEventType.PLUG) {
debug(bioScanner + ": Plugged");
callback("onPlug");
try {
bioScanner.addCaptureEventListener(this);
} catch (BiometricException e) {}
}
if (evt == CaptureEventType.UNPLUG) {
debug(bioScanner + ": Unplugged");
callback("onUnplug");
}
if (evt == CaptureEventType.PLACED) {

debug(bioScanner + ": Finger placed");


callback("onPlaced");

}
if (evt == CaptureEventType.REMOVED) {
debug(bioScanner + ": Finger removed");
callback("onRemoved");
}
if (evt == CaptureEventType.IMAGE_CAPTURED) {
debug(bioScanner + ": Image captured");
BiometricTemplate template = new
BiometricTemplate(img);
boolean identifyTemplates
=
Boolean.parseBoolean( getParameter("identifyTemplates"
, "false") );
boolean verifyTemplates
=
Boolean.parseBoolean( getParameter("verifyTemplates"
, "false") );
boolean captureFailed = false;
if (verifyTemplates) {
int
verifyMinThreshold =
Integer.parseInt
( getParameter("verifyMinThreshold", "20") );
for (BiometricTemplate tpt :
allTemplates) {
int score = tpt.match(template);
debug("Verifing templates: score
= " + score + "; min = " + verifyMinThreshold);
if (score < verifyMinThreshold)
captureFailed = true;
}
} else {
if(identifyTemplates){
int
identifyThreshold =
Integer.parseInt
( getParameter("identifyThreshold", "25") );
captureFailed = false;
BiometricIdentification bioId =
new BiometricIdentification(template);
identificationScore = -1;
identificationIndex = -1;
for (int ind = 0;ind <
allTemplates.size();ind++){
BiometricTemplate tpt =
allTemplates.get(ind);
int score =
tpt.match(template);
if (score >=
identifyThreshold){
debug("Identified: score = " + score + "; min = " +
identifyThreshold+";index="+(ind+1));
identificationScore = score;
identificationIndex = ind+1; //primeiro tem
true;

captureFailed =

}
}

}
fingerprintViewPanel.setImage(img);
lastImage = img;

lastTemplate = new BiometricTemplate(img);


if (!captureFailed) {
callback("onCapture");
} else {
debug(bioScanner + ": Image verification
failed");

callback("onBadVerify");
}

===

//=============================================================

//===================== JAVASCRIPT CALLBACKS


=====================
//=============================================================
===
/**Avoids MalformedURLExceptionbug*/
private static final URLStreamHandler streamHandler = new
URLStreamHandler() {
protected URLConnection openConnection(URL u) {
return null;
}
};
/**Calls a javascript function[s]*/
private synchronized void callback(String callbackname) {
if (callbackname == null) return;
final String callback = getParameter(callbackname);
if (callback == null) return;
AccessController.doPrivileged(new
PrivilegedAction<Void>() {
public Void run() {
java.applet.AppletContext context =
getAppletContext();
if (context != null) {
for (String cb :
callback.split(";")) {
try {
URL url = new
java.net.URL(null, "javascript:" + cb, streamHandler);
System.err.println(url);
context.showDocument(url, "_self");

} catch (Exception e) {

e.printStackTrace();
debug(): If the onDebug event is buggy, it will loop.
}
}
}
return null;
}
});

//Can't use

}
/**
* Returns an Applet parameter. If the parameter is not
defines,
* a default value will be used.
* @param name The parameter name.
* @param def The parameter's default value.
*/
private String getParameter(String name, String def) {
String r = getParameter(name);
return r!=null ? r : def;
}
}

Cdigo 3
import
import
import
import
import
import
import
import
import

java.io.IOException;
java.net.MalformedURLException;
java.net.URL;
java.sql.Connection;
java.sql.DriverManager;
java.sql.ResultSet;
java.sql.SQLException;
java.sql.Statement;
java.util.Scanner;

import javax.sound.sampled.AudioFormat.Encoding;
import
import
import
import

veridis.biometric.BiometricIdentification;
veridis.biometric.BiometricSDK;
veridis.biometric.BiometricTemplate;
veridis.biometric.samples.applet.Base64;

import veridis.biometric.BiometricImage;
import veridis.biometric.BiometricTemplate;
import veridis.biometric.BiometricException.FeatureNotAvailableForFreeException;
import veridis.biometric.BiometricException.FeatureNotLicensedException;
import
veridis.biometric.BiometricException.UnsupportedBiometricModalityException;
import veridis.sample.util.ButtonLayout;
import org.json.*;
public class dbAccess {
private static final BiometricTemplate AddTemplate = null;
protected static Connection con = null;
protected static Statement stm = null;
protected static int minimumThreshold = 40;
public static Object Console;
public static boolean AddTemplate(BiometricTemplate template) throws
SQLException {
String str = "http://192.168.51.199/ponto/index.php/JSON/listaTemplate/";
try {
URL url = new URL(str);

Scanner scan;
try {
scan = new Scanner(url.openStream());
String str2 = new String();
while (scan.hasNext()) {
str2 += scan.nextLine();
}
scan.close();
JSONObject obj = new JSONObject(str2);
JSONArray elenco = obj.getJSONArray("usuarios");
for (int i = 0; i < elenco.length(); i++) {
String[] tmp = elenco.getString(i).split("-");
BiometricTemplate tempBD;
try {
tempBD = new BiometricTemplate((Base64.decode(tmp[1])));
System.out.println(template.getData());
System.out.println(Base64.decode(tmp[1]));
Object bytes = template;
System.out.println("Text [Byte Format] : " + bytes);
if (tempBD.match(tempBD) > minimumThreshold) {
System.out.println("Achou");
return true;
}
} catch (Exception e) {
System.out.println(e.getLocalizedMessage());
return false;
}
//System.out.println(spl[0]);
//usersmodel.addElement(elenco.getString(i));

}
} catch (MalformedURLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
/*if(res.next()){
try{

BiometricTemplate tempBD = new


BiometricTemplate((Base64.decode(res.getString("template"))));
if (tempBD.match(template) > minimumThreshold)
return 1;
}
catch(Exception e ){

System.out.println(e.getLocalizedMessage());
return -1;
}*/
System.exit(0);
return true;
}
/*Function to get Template from database*/
public static BiometricTemplate getTemplate(BiometricTemplate template, String
id) throws SQLException {
if (con == null) {
connectToDB();
}
if (stm == null) {
stm = con.createStatement();
}
String query = "SELECT * FROM usuarios where id = \"" + id + "\"";
ResultSet res = stm.executeQuery(query);
if (res.next()) {
try {
BiometricTemplate tempBD = new
BiometricTemplate((Base64.decode(res.getString("Template"))));
return tempBD;
} catch (Exception e) {
System.out.println(e.getLocalizedMessage());
return null;
}

}
return null;

/*Function to verify if the given template matches with the template


corresponding to the given id*/
public static int verificaIdentificador(BiometricTemplate template, String id)
throws SQLException {
ResultSet res = stm.executeQuery(id);
if (res.next()) {
try {
BiometricTemplate tempBD = new
BiometricTemplate((Base64.decode(res.getString("template"))));
if (tempBD.match(template) > minimumThreshold) {
return 1;
}
} catch (Exception e) {
System.out.println(e.getLocalizedMessage());
return -1;
}

}
return 0;

/*Given a ID, tries to find correspondent template*/


public static String findIDTemplate(BiometricTemplate template) throws
SQLException {
if (con == null) {
connectToDB();
}
if (stm == null) {
stm = con.createStatement();
}
String query = "SELECT * FROM usuarios";
ResultSet res = stm.executeQuery(query);
/*prepares identification context to perform match faster*/
BiometricIdentification temp = new BiometricIdentification(template);
while (res.next()) {
try {
//retrieves template
BiometricTemplate tempBD = new
BiometricTemplate((Base64.decode(res.getString("Template"))));
//checks if match score is higher than minimum threshold
if (temp.match(tempBD) > 40) {
return res.getString("id");
}
} catch (Exception e) {
System.out.println(e.getLocalizedMessage());
return null;
}
}
return null;
}
public static void main(String[] args) {
dbAccess.connectToDB();
}
public static void connectToDB() {
Connection con = null;
try {
Class.forName("com.mysql.jdbc.Driver");
String
String
String
String

userName = "root";
password = "12rafael34";
url = "jdbc:mysql://192.168.51.199//";
dbName = "survey";

Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection(url + dbName, userName, password);
stm = con.createStatement();
stm.executeUpdate("DROP TABLE IF EXISTS template");

stm.executeUpdate("CREATE TABLE template ("


+ "id varchar(100) PRIMARY KEY NOT NULL,"
+ "template varchar(1000) NOT NULL,"
+ "nome varchar(1000) NOT NULL);");
} catch (Exception e) {
System.out.println(e.getMessage());
}
}

public static BiometricTemplate getAddtemplate() {


return AddTemplate;
}

Cdigo 4

Para realizar a comparao eu usava este cdigo na parte do servidor....

1.

import com.nitgen.SDK.BSP.NBioBSPJNI;

2.

import com.nitgen.SDK.BSP.NBioBSPJNI.IndexSearch;

3.

import java.util.List;

4.

import modelo.Digital;

5.

/**

6.

7.

* @author Ulisses

8.

*/

9.

public class LeitorBiometrico {

10.
11.

private static NBioBSPJNI bsp;

12.

private NBioBSPJNI.IndexSearch IndexSearchEngine;

13.

private NBioBSPJNI.FIR_TEXTENCODE textSavedFIRBD;

14.

private NBioBSPJNI.FIR_TEXTENCODE textSavedFIRMC;

15.

private NBioBSPJNI.FIR_HANDLE hFIR;

16.

private NBioBSPJNI.INPUT_FIR inputFIRBD;

17.

private NBioBSPJNI.INPUT_FIR inputFIRMC;

18.

private NBioBSPJNI.IndexSearch.SAMPLE_INFO sampleInfo;

19.

20.

public LeitorBiometrico() {

21.
22.

bsp = new NBioBSPJNI();

23.

if (CheckError()) {

24.

return;

25.

26.
27.

IndexSearchEngine = bsp.new IndexSearch();

28.

if (CheckError()){

29.

return;

30.

31.
32.

bsp.OpenDevice();

33.

if (CheckError()) {

34.

return;

35.

36.
37.

System.err.println("Dispositivo Iniciado com Sucesso");

38.
39.

40.
41.
42.

public void dispose() {


if (IndexSearchEngine != null) {

43.

IndexSearchEngine.dispose();

44.

IndexSearchEngine = null;

45.

46.
47.
48.

if (bsp != null) {
bsp.CloseDevice();

49.

bsp.dispose();

50.

bsp = null;

51.

52.
53.
54.

if (textSavedFIRBD != null) {

55.

textSavedFIRBD = null;

56.

57.
58.

if (textSavedFIRMC != null) {

59.

textSavedFIRMC = null;

60.

61.
62.

if (hFIR != null) {

63.

hFIR.dispose();

64.

hFIR = null;

65.

66.
67.

if (inputFIRBD != null) {

68.

inputFIRBD = null;

69.

70.
71.

if (inputFIRMC != null) {

72.

inputFIRMC = null;

73.

74.
75.

if (sampleInfo != null) {

76.

sampleInfo = null;

77.

78.
79.

80.
81.

private Boolean CheckError() {

82.

if (bsp.IsErrorOccured()) {

83.

//labelStatus.setText("NBioBSP Error Occured [" + bsp.GetErrorCode() + "]");

84.

return true;

85.

86.
87.
88.

return false;
}

89.
90.

public void Closing() {

91.
92.

dispose();
}

93.
94.

void populaIndexEngine(List<Digital> lista){

95.

//Instancia o Handle para receber a digital

96.

textSavedFIRBD = bsp.new FIR_TEXTENCODE();

97.

inputFIRBD = bsp.new INPUT_FIR();

98.
99.
100.

//Percorre a lista de Digitais e popula a SerchEngine com o ID do funcionrio


for (int i=0;i<lista.size();i++){

101.
System.out.println(lista.get(i).getIddigital() +"
"+lista.get(i).getBiometria());
102.

textSavedFIRBD.TextFIR = lista.get(i).getBiometria();

103.

inputFIRBD.SetTextFIR(textSavedFIRBD);

104.
IndexSearchEngine.AddFIR(inputFIRBD,
lista.get(i).getIdfuncionario().getIdfuncionario(), sampleInfo);
105.

106.

107.
108.

int verificaDigital(String digitalMicro){

109.

//Recebendo String do Microcontrolador e convertendo

110.

textSavedFIRMC = bsp.new FIR_TEXTENCODE();

111.

textSavedFIRMC.TextFIR = digitalMicro;

112.

inputFIRMC = bsp.new INPUT_FIR();

113.

inputFIRMC.SetTextFIR(textSavedFIRMC);

114.

//Instanciando TIPO: resultado da busca

115.
NBioBSPJNI.IndexSearch.FP_INFO fpInfo =
IndexSearchEngine.new FP_INFO();
116.

//Realizando pesquisa com a digital recebida do microcontrolador

117.

IndexSearchEngine.Identify(inputFIRMC, 5, fpInfo);

118.
119.

//Retorna o ID do funcionrio (0 = No encontrado)

120.

return fpInfo.ID;

121.
122.

123.
124.
125.

Cdigo 5

Na parte web... utilizei a prpria interface para cadastramento dos funcionrio que facilitava
muito a vida...

1.

package controle.digital;

2.
3.
4.

import com.nitgen.SDK.BSP.NBioBSPJNI;

5.

/**

6.

7.

* @author Ulisses

8.

*/

9.

public class LeitorBiometrico {

10.
11.

private static NBioBSPJNI bsp;

12.

private NBioBSPJNI.IndexSearch IndexSearchEngine;

13.

private NBioBSPJNI.FIR_TEXTENCODE textSavedFIR;

14.

private NBioBSPJNI.FIR_HANDLE hFIR;

15.

private NBioBSPJNI.INPUT_FIR inputFIR;

16.

private NBioBSPJNI.IndexSearch.SAMPLE_INFO sampleInfo;

17.
18.

public LeitorBiometrico() {

19.
20.

bsp = new NBioBSPJNI();

21.

if (CheckError()) {

22.
23.

return;
}

24.
25.

IndexSearchEngine = bsp.new IndexSearch();

26.

if (CheckError()){

27.
28.

return;
}

29.
30.

bsp.OpenDevice();

31.

if (CheckError()) {

32.
33.
34.

return;
}

35.

System.err.println("Dispositivo Iniciado com Sucesso");

36.
37.

38.
39.
40.

public void dispose() {


if (IndexSearchEngine != null) {

41.

IndexSearchEngine.dispose();

42.

IndexSearchEngine = null;

43.

44.
45.

if (bsp != null) {

46.

bsp.CloseDevice();

47.

bsp.dispose();

48.

bsp = null;

49.

50.
51.
52.

if (textSavedFIR != null) {

53.

textSavedFIR = null;

54.

55.
56.

if (hFIR != null) {

57.

hFIR.dispose();

58.

hFIR = null;

59.

60.
61.

if (inputFIR != null) {

62.

inputFIR = null;

63.

64.
65.

if (sampleInfo != null) {

66.

sampleInfo = null;

67.

68.
69.

70.
71.

private Boolean CheckError() {

72.

if (bsp.IsErrorOccured()) {

73.

//labelStatus.setText("NBioBSP Error Occured [" + bsp.GetErrorCode() + "]");

74.

return true;

75.

76.
77.
78.

return false;
}

79.
80.

public void Closing() {

81.
82.

dispose();
}

83.
84.

// registra a digital do usuario

85.

public String registrarDigital() {

86.
87.

//Registrar

88.

hFIR = bsp.new FIR_HANDLE();

89.

bsp.Enroll(hFIR, null);

90.
91.

// transforma od dados da digital em texto

92.

if (bsp.IsErrorOccured() == false) {

93.

textSavedFIR = bsp.new FIR_TEXTENCODE();

94.

bsp.GetTextFIRFromHandle(hFIR, textSavedFIR);

95.

String sDigital = textSavedFIR.TextFIR;

96.

Closing();

97.

return sDigital;

98.
99.

} else {
Closing();

100.

return null;

101.

102.
103.

104.
105.

public void inserirDigital(int codigo, String digital){

106.

//Recebendo a digital gravada no BD

107.

textSavedFIR = bsp.new FIR_TEXTENCODE();

108.

textSavedFIR.TextFIR = digital;

109.

inputFIR = bsp.new INPUT_FIR();

110.

inputFIR.SetTextFIR(textSavedFIR);

111.
112.

//indexando a digital e o ID do usuario extrados do BD na memria

113.

IndexSearchEngine.AddFIR(inputFIR, codigo, sampleInfo);

114.

if (CheckError()) {

115.

Closing();

116.

117.
118.

119.
120.
121.

public boolean verificarDigital(int codigo, String digital) {


//Recebendo a digital gravada no BD

122.

textSavedFIR = bsp.new FIR_TEXTENCODE();

123.

textSavedFIR.TextFIR = digital;

124.

inputFIR = bsp.new INPUT_FIR();

125.

inputFIR.SetTextFIR(textSavedFIR);

126.
127.

//indexando a digital e o ID do usuario extrados do BD na memria

128.

IndexSearchEngine.AddFIR(inputFIR, codigo, sampleInfo);

129.

if (CheckError()) {

130.

Closing();

131.

return false;

132.

133.

//Capturando a digital do usuario

134.

NBioBSPJNI.FIR_HANDLE hCapture = bsp.new FIR_HANDLE();

135.

bsp.Capture(hCapture);

136.

if (CheckError()) {

137.

return false;

138.

139.

NBioBSPJNI.INPUT_FIR inputFIR1;

140.

inputFIR1 = bsp.new INPUT_FIR();

141.

inputFIR1.SetFIRHandle(hCapture);

142.
NBioBSPJNI.IndexSearch.FP_INFO fpInfo =
IndexSearchEngine.new FP_INFO();
143.
144.

//identificado a digital capturada com a que foi indexada

145.

IndexSearchEngine.Identify(inputFIR1, 5, fpInfo);

146.

if (CheckError()) {

147.

Closing();

148.

return false;

149.

} else {

150.

Closing();

151.

return true;

152.

153.

154.
155.

Cdigo 6
Para realizar a comparao eu usava este cdigo na parte do servidor....

Boa noite, estou precisando de uma luz...


Estou fazendo um sistema para um salo de esttica e nele, tenho uma tabela
para cada profissional marcar os horrios que iro atender de segunda a
sbado. Por exemplo, tenho o horrio Matutino (Entrada1 e Saida1) e
Vespertino (Entrada2 e Sada2), entre cada um desses cadastrados, na tabela
quando for visualizar, precisa preencher intervalos entre 08:00 at 12:00
(exemplo), que esteja Disponvel e o que no estiver entre os intervalos,
marcar como Indisponvel, algo assim.

1.

package classes;

2.
3.

import java.text.SimpleDateFormat;

4.

import java.util.ArrayList;

5.

import java.util.Calendar;

6.

import java.util.GregorianCalendar;

7.

import java.util.List;

8.

import java.util.logging.Level;

9.

import java.util.logging.Logger;

10.

import static javax.swing.JOptionPane.*;

11.

import javax.swing.table.DefaultTableModel;

12.
13.

public class JFHorarioProfissional extends javax.swing.JFrame {

14.
15.

SimpleDateFormat formatar = new SimpleDateFormat("HH:mm"<img


src="http://javafree.uol.com.br/forum/images/smiles/icon_wink.gif">;

16.

char op;

17.

List<Horario> Lhorario = new ArrayList<Horario>();

18.

List<Horario> newLhorario = new ArrayList<Horario>();

19.

List<Horario> finalLhorario = new ArrayList<Horario>();

20.
21.

/**

22.

* Creates new form JFHorarioProfissional

23.

*/

24.

public JFHorarioProfissional() throws Exception {

25.
26.
27.

initComponents();
//

atualizarGrade();
}

28.
29.
30.

/**

31.

* This method is called from within the constructor to initialize the for
m.

32.

* WARNING: Do NOT modify this code. The content of this method is


always

33.

* regenerated by the Form Editor.

34.

*/

35.

@SuppressWarnings("unchecked"<img src="http://javafree.uol.com.b
r/forum/images/smiles/icon_wink.gif">

36.

// <editor-fold defaultstate="collapsed" desc="Generated Code">

37.

private void initComponents() {

38.
39.

jpPesquisa = new javax.swing.JPanel();

40.

jpBusca = new javax.swing.JPanel();

41.

jlCodigo = new javax.swing.JLabel();

42.

tfcodigo = new javax.swing.JTextField();

43.

jlDescricao = new javax.swing.JLabel();

44.

tfdescricao = new javax.swing.JTextField();

45.

btPesquisar = new javax.swing.JButton();

46.

jpBotao = new javax.swing.JPanel();

47.

btSalvar = new javax.swing.JButton();

48.

jButton2 = new javax.swing.JButton();

49.

jButton3 = new javax.swing.JButton();

50.

jButton4 = new javax.swing.JButton();

51.

jpTabela = new javax.swing.JPanel();

52.

jScrollPane3 = new javax.swing.JScrollPane();

53.

tbHorario = new javax.swing.JTable();

54.
55.

setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_
ON_CLOSE);

56.

setTitle("Calendrio do Profissional"<img src="http://javafree.uol.c


om.br/forum/images/smiles/icon_wink.gif">;

57.
58.

jpPesquisa.setLayout(new java.awt.BorderLayout());

59.
60.

jlCodigo.setText("Cdigo:"<img src="http://javafree.uol.com.br/for
um/images/smiles/icon_wink.gif">;

61.
62.

jlDescricao.setText("Descrio:"<img src="http://javafree.uol.com.
br/forum/images/smiles/icon_wink.gif">;

63.
64.

btPesquisar.setText("Buscar"<img src="http://javafree.uol.com.br/f
orum/images/smiles/icon_wink.gif">;

65.

btPesquisar.addActionListener(new java.awt.event.ActionListener()
{

66.

public void actionPerformed(java.awt.event.ActionEvent evt) {

67.
68.
69.

btPesquisarActionPerformed(evt);
}
});

70.
71.

javax.swing.GroupLayout jpBuscaLayout = new javax.swing.GroupL


ayout(jpBusca);

72.

jpBusca.setLayout(jpBuscaLayout);

73.

jpBuscaLayout.setHorizontalGroup(

74.

jpBuscaLayout.createParallelGroup(javax.swing.GroupLayout.Ali
gnment.LEADING)

75.

.addGroup(jpBuscaLayout.createSequentialGroup()

76.

.addContainerGap()

77.

.addComponent(jlCodigo)

78.

.addGap(18, 18, 1<img src="http://javafree.uol.com.br/foru


m/images/smiles/icon_cool.gif">

79.

.addComponent(tfcodigo, javax.swing.GroupLayout.PREFERRE
D_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)

80.

.addGap(18, 18, 1<img src="http://javafree.uol.com.br/foru


m/images/smiles/icon_cool.gif">

81.

.addComponent(jlDescricao)

82.

.addGap(18, 18, 1<img src="http://javafree.uol.com.br/foru


m/images/smiles/icon_cool.gif">

83.

.addComponent(tfdescricao, javax.swing.GroupLayout.DEFAU
LT_SIZE, 437, Short.MAX_VALUE)

84.

.addGap(18, 18, 1<img src="http://javafree.uol.com.br/foru


m/images/smiles/icon_cool.gif">

85.

.addComponent(btPesquisar)

86.

.addContainerGap())

87.

);

88.

jpBuscaLayout.setVerticalGroup(

89.

jpBuscaLayout.createParallelGroup(javax.swing.GroupLayout.Ali
gnment.LEADING)

90.

.addGroup(jpBuscaLayout.createSequentialGroup()

91.

.addGap(19, 19, 19)

92.

.addGroup(jpBuscaLayout.createParallelGroup(javax.swing.Gr
oupLayout.Alignment.BASELINE)

93.

.addComponent(jlCodigo)

94.

.addComponent(tfcodigo, javax.swing.GroupLayout.PREFE
RRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLay
out.PREFERRED_SIZE)

95.

.addComponent(jlDescricao)

96.

.addComponent(tfdescricao, javax.swing.GroupLayout.PRE
FERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupL
ayout.PREFERRED_SIZE)

97.
98.

.addComponent(btPesquisar))
.addContainerGap())

99.

);

100.
101.

jpPesquisa.add(jpBusca, java.awt.BorderLayout.CENTER);

102.
103.

jpBotao.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.R

IGHT));
104.
105.

btSalvar.setText("Salvar"<img src="http://javafree.uol.com.br/foru

m/images/smiles/icon_wink.gif">;
106.

btSalvar.addActionListener(new java.awt.event.ActionListener() {

107.

public void actionPerformed(java.awt.event.ActionEvent evt) {

108.
109.

btSalvarActionPerformed(evt);
}

110.

});

111.

jpBotao.add(btSalvar);

112.
113.

jButton2.setText("Alterar"<img src="http://javafree.uol.com.br/for

um/images/smiles/icon_wink.gif">;
114.

jpBotao.add(jButton2);

115.
116.

jButton3.setText("Excluir"<img src="http://javafree.uol.com.br/for

um/images/smiles/icon_wink.gif">;

117.

jpBotao.add(jButton3);

118.
119.

jButton4.setText("Voltar"<img src="http://javafree.uol.com.br/foru

m/images/smiles/icon_wink.gif">;
120.

jpBotao.add(jButton4);

121.
122.

jpPesquisa.add(jpBotao, java.awt.BorderLayout.PAGE_START);

123.
124.

getContentPane().add(jpPesquisa, java.awt.BorderLayout.PAGE_ST

ART);
125.
126.

jpTabela.setLayout(new java.awt.BorderLayout());

127.
128.
129.
130.

tbHorario.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{"Segunda-feira", "", null, null, null, null, null, null, null, null,

null, null, null, null},


131.

{"Tera-feira", "", null, null, null, null, null, null, null, null, nul

l, null, null, null},


132.

{"Quarta-feira", "", null, null, null, null, null, null, null, null, n

ull, null, null, null},


133.

{"Quinta-feira", "", null, null, null, null, null, null, null, null, nu

ll, null, null, null},

134.

{"Sexta-feira", "", null, null, null, null, null, null, null, null, nul

l, null, null, null},


135.

{"Sbado", "", null, null, null, null, null, null, null, null, null, n

ull, null, null},


136.

{null, "", null, null, null, null, null, null, null, null, null, null, nu

ll, null}
137.

},

138.

new String [] {

139.

"Dia da Semana", "08:00", "09:00", "10:00", "11:00", "12:00

", "13:00", "14:00", "15:00", "16:00", "17:00", "18:00", "19:00", "20:00"


140.
141.
142.

}
){
Class[] types = new Class [] {

143.

java.lang.String.class, java.lang.Object.class, java.lang.Objec

t.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class,


java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.la
ng.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Obj
ect.class, java.lang.Object.class
144.

};

145.
146.

public Class getColumnClass(int columnIndex) {

147.
148.
149.

return types [columnIndex];


}
});

150.

tbHorario.getTableHeader().setResizingAllowed(false);

151.

tbHorario.getTableHeader().setReorderingAllowed(false);

152.

jScrollPane3.setViewportView(tbHorario);

153.

tbHorario.getColumnModel().getColumn(0).setResizable(false);

154.

tbHorario.getColumnModel().getColumn(0).setPreferredWidth(250)

;
155.
156.

jpTabela.add(jScrollPane3, java.awt.BorderLayout.CENTER);

157.
158.

getContentPane().add(jpTabela, java.awt.BorderLayout.CENTER);

159.
160.

java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit

().getScreenSize();
161.

setBounds((screenSize.width-757)/2, (screenSize.height-292)/2, 7

57, 292);
162.

}// </editor-fold>

163.
164.

private void btPesquisarActionPerformed(java.awt.event.ActionEvent e

vt) {
165.

// TODO add your handling code here:

166.
167.

JBProfissional calen = new JBProfissional(null, true);

168.

calen.setVisible(true);

169.
170.

if (calen.getpessoaselecionada() != null) {

171.

tfcodigo.setText(String.valueOf(calen.getpessoaselecionada().ge

tCodigo()));
172.

tfdescricao.setText(String.valueOf(calen.getpessoaselecionada().

getNome()));
173.

174.

try {

175.

atualizarGrade();

176.

} catch (Exception ex) {

177.

Logger.getLogger(JFHorarioProfissional.class.getName()).log(Lev

el.SEVERE, null, ex);


178.
179.

}
}

180.
181.

private void btSalvarActionPerformed(java.awt.event.ActionEvent evt)

{
182.
183.
184.

// TODO add your handling code here:

185.

// op uma variavel para verificar se o calendario tem hrs configur

ada, ou nao;
186.

// o for da primeira liha percorre a tabela par veificar qual checkbo

x esta marcado e gravando o horario no banco;


187.

// o for da segunda linha percorre a coluna;

188.

// toda vez que axar um marcado (true) vai inserir no banco

189.

if (op == 'c') {

190.

try {

191.

HorarioDAO dao = new HorarioDAO();

192.

for (int i = 0; i < tbHorario.getRowCount(); i++) {

193.

for (int j = 0; j < tbHorario.getColumnCount(); j++) {

194.

if (tbHorario.getValueAt(i, j).toString() == "true"<img s

rc="http://javafree.uol.com.br/forum/images/smiles/icon_wink.gif"> {
195.

Horario hora = new Horario();

196.

hora.setCodigohorariopadrao(Integer.parseInt(tfcodig

o.getText()));
197.

hora.setDiasemana(i);

198.

hora.setEntrada1(tbHorario.getColumnName(j));

199.

dao.incluir(hora);

200.

201.
202.

}
}

203.

showMessageDialog(null, "Calendario configurado com sucess

o"<img src="http://javafree.uol.com.br/forum/images/smiles/icon_wink.gif"
>;
204.
205.

this.dispose();
} catch (Exception ex) {

206.

Logger.getLogger(JFHorarioProfissional.class.getName()).log(

Level.SEVERE, null, ex);


207.

208.

} else {

209.

try {

210.

HorarioDAO dao = new HorarioDAO();

211.

dao.excluir(Integer.parseInt(tfcodigo.getText()));

212.

newLhorario.clear();

213.

for (int i = 0; i < tbHorario.getRowCount(); i++) {

214.
215.

for (int j = 0; j < tbHorario.getColumnCount(); j++) {


if (tbHorario.getValueAt(i, j).toString() == "true"<img s

rc="http://javafree.uol.com.br/forum/images/smiles/icon_wink.gif"> {
216.

Horario hora = new Horario();

217.

hora.setCodigohorariopadrao(Integer.parseInt(tfcodig

o.getText()));
218.

hora.setDiasemana(i);

219.

hora.setEntrada1(tbHorario.getColumnName(j));

220.

dao.incluir(hora);

221.

222.

223.

224.

showMessageDialog(null, "Calendario configurado com sucess

o"<img src="http://javafree.uol.com.br/forum/images/smiles/icon_wink.gif"
>;
225.

this.dispose();

226.

} catch (Exception ex) {

227.

Logger.getLogger(JFHorarioProfissional.class.getName()).log(

Level.SEVERE, null, ex);


228.

229.

230.
231.

232.
233.

public void atualizarGrade() throws Exception {

234.
235.

Horario calendario;

236.

// Recuperar o codigo do cliente

237.

//lembre de verifica tipos (int,string)

238.

calendario = new HorarioDAO().pesquisar(Integer.parseInt(tfcodigo

.getText()));
239.
240.

GregorianCalendar cgc = new GregorianCalendar();

241.

GregorianCalendar cgate = new GregorianCalendar();

242.

GregorianCalendar gc = new GregorianCalendar();

243.

GregorianCalendar gate = new GregorianCalendar();

244.
245.

int contador = 0;

246.
247.

gc.setTime(calendario.getEntrada1());

248.

gate.setTime(calendario.getSaida1());

249.

cgc.setTime(calendario.getEntrada2());

250.

cgate.setTime(calendario.getSaida2());

251.
252.
253.

//

//verificar quantas colunas cabem no calendario


for (int i = 0; cgc.before(cgate); i++) {

254.

cgc.add(Calendar.MINUTE, 15);

255.

contador = i;

256.
257.

258.

String vetor[] = new String[contador + 2]; //armazenar a qtd cont

ada no for de cima


259.
260.

//colocar colunas necessarias para a grade

261.

for (int i = 1; i <= contador + 1; i++) {

262.

if (i == 1) {

263.

vetor<i> = formatar.format(gc.getTime());

264.

gc.add(Calendar.MINUTE, 15);

265.

} else if (gc.before(gate) && i != 0) {

266.

vetor<i> = formatar.format(gc.getTime());

267.

gc.add(Calendar.MINUTE, 15);

268.
269.

}
}

270.

// monta a grid, onde a primeira coluna os dias da semana

271.

Object[][] semana = new Object[7][vetor.length];

272.

for (int i = 0; i < 7; i++) {

273.
274.
275.
276.
277.

for (int j = 0; j < vetor.length; j++) {


if (i == 0 && j == 0) {
semana<i>[j] = "Domingo";
} else if (i == 1 && j == 0) {
semana<i>[j] = "Segunda-Feira";

278.

} else if (i == 2 && j == 0) {

279.

semana<i>[j] = "Tera-Feira";

280.

} else if (i == 3 && j == 0) {

281.

semana<i>[j] = "Quarta-Feira";

282.

} else if (i == 4 && j == 0) {

283.

semana<i>[j] = "Quinta-Feira";

284.

} else if (i == 5 && j == 0) {

285.

semana<i>[j] = "Sexta-Feira";

286.

} else if (i == 6 && j == 0) {

287.

semana<i>[j] = "Sbado";

288.

} else {

289.

semana<i>[j] = "D";

290.

291.
292.

}
}

293.
294.

//atualizar as colunas da

295.

try {

296.
297.

tbHorario.setModel(new DefaultTableModel(semana, vetor));

298.

HorarioDAO dao = new HorarioDAO();

299.

Lhorario = (List<Horario><img src="http://javafree.uol.com.br/

forum/images/smiles/icon_wink.gif"> dao.carregarCombo();//retorna uma li


sta de checkbox marcado
300.

if (Lhorario == null || Lhorario.size() == 0) {//verifica se o cale

ndario esta vazio ou nao, ou seja nunca foi config


301.
302.
303.

op = 'c';
} else {
for (int i = 0; i < Lhorario.size(); i++) {//preenche os horario

s marcados.
304.

for (int j = 0; j < tbHorario.getColumnCount(); j++) {

305.

if (formatar.format(Lhorario.get(i).getEntrada1()).equals

(tbHorario.getColumnName(j)) &&
306.

formatar.format(Lhorario.get(i).getSaida1()).equal

s(tbHorario.getColumnName(j)) &&
307.

formatar.format(Lhorario.get(i).getEntrada2()).equ

als(tbHorario.getColumnName(j)) &&
308.

formatar.format(Lhorario.get(i).getSaida2()).equal

s(tbHorario.getColumnName(j))) {
309.

tbHorario.setValueAt(true, Lhorario.get(i).getDiasema

na(), j);
310.

311.
312.

}
}

313.

op = 'a';

314.

315.

} catch (Exception e) {

316.

e.printStackTrace();

317.

showMessageDialog(this, e.getMessage(), "Erro", ERROR_MESS

AGE);
318.

319.
320.

321.
322.

/**

323.

* @param args the command line arguments

324.

*/

325.

public static void main(String args[]) {

326.

/* Set the Nimbus look and feel */

327.

//<editor-fold defaultstate="collapsed" desc=" Look and feel settin

g code (optional) ">


328.

/* If Nimbus (introduced in Java SE 6) is not available, stay with th

e default look and feel.


329.

* For details see http://download.oracle.com/javase/tutorial/uiswi

ng/lookandfeel/plaf.html
330.

*/

331.

try {

332.

for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.

UIManager.getInstalledLookAndFeels()) {
333.

if ("Nimbus".equals(info.getName())) {

334.

javax.swing.UIManager.setLookAndFeel(info.getClassName

());
335.

break;

336.

337.
338.

}
} catch (ClassNotFoundException ex) {

339.

java.util.logging.Logger.getLogger(JFHorarioProfissional.class.get

Name()).log(java.util.logging.Level.SEVERE, null, ex);


340.

} catch (InstantiationException ex) {

341.

java.util.logging.Logger.getLogger(JFHorarioProfissional.class.get

Name()).log(java.util.logging.Level.SEVERE, null, ex);


342.

} catch (IllegalAccessException ex) {

343.

java.util.logging.Logger.getLogger(JFHorarioProfissional.class.get

Name()).log(java.util.logging.Level.SEVERE, null, ex);


344.

} catch (javax.swing.UnsupportedLookAndFeelException ex) {

345.

java.util.logging.Logger.getLogger(JFHorarioProfissional.class.get

Name()).log(java.util.logging.Level.SEVERE, null, ex);


346.

347.

//</editor-fold>

348.
349.

/* Create and display the form */

350.

java.awt.EventQueue.invokeLater(new Runnable() {

351.

public void run() {

352.

try {

353.

new JFHorarioProfissional().setVisible(true);

354.

} catch (Exception ex) {

355.

Logger.getLogger(JFHorarioProfissional.class.getName()).lo

g(Level.SEVERE, null, ex);


356.

357.

358.

});

359.

360.

// Variables declaration - do not modify

361.

private javax.swing.JButton btPesquisar;

362.

private javax.swing.JButton btSalvar;

363.

private javax.swing.JButton jButton2;

364.

private javax.swing.JButton jButton3;

365.

private javax.swing.JButton jButton4;

366.

private javax.swing.JScrollPane jScrollPane3;

367.

private javax.swing.JLabel jlCodigo;

368.

private javax.swing.JLabel jlDescricao;

369.

private javax.swing.JPanel jpBotao;

370.

private javax.swing.JPanel jpBusca;

371.

private javax.swing.JPanel jpPesquisa;

372.

private javax.swing.JPanel jpTabela;

373.

private javax.swing.JTable tbHorario;

374.

private javax.swing.JTextField tfcodigo;

375.

private javax.swing.JTextField tfdescricao;

376.

// End of variables declaration

377.

Cdigo 7

Cdigo 8
Cdigo 9
Cdigo 10
Cdigo 11
Cdigo 12
Cdigo 13
Cdigo 14
Cdigo 15
Cdigo 16
Cdigo 17

S-ar putea să vă placă și