1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package net.sf.webphotos.tools; |
17 | |
|
18 | |
import java.awt.MediaTracker; |
19 | |
import java.io.File; |
20 | |
import java.sql.*; |
21 | |
import javax.swing.*; |
22 | |
|
23 | 0 | public class Resolucao { |
24 | |
|
25 | |
public static void main(String args[]) { |
26 | 0 | TelaResolucao f = new TelaResolucao(); |
27 | |
|
28 | 0 | f.setVisible(true); |
29 | 0 | f.iniciar(); |
30 | 0 | } |
31 | |
} |
32 | |
|
33 | |
class TelaResolucao extends JFrame { |
34 | |
|
35 | |
private JTextArea texto; |
36 | |
private JTextArea instrucao; |
37 | 0 | private JLabel contador = new JLabel("0/0"); |
38 | 0 | private JLabel bons = new JLabel("0"); |
39 | 0 | private JLabel maus = new JLabel("0"); |
40 | |
|
41 | 0 | public TelaResolucao() { |
42 | 0 | setSize(470, 400); |
43 | 0 | setDefaultCloseOperation(EXIT_ON_CLOSE); |
44 | 0 | getContentPane().setLayout(null); |
45 | |
|
46 | 0 | texto = new JTextArea(); |
47 | 0 | instrucao = new JTextArea(); |
48 | |
|
49 | |
|
50 | 0 | JScrollPane scrTexto = new JScrollPane(texto); |
51 | 0 | JScrollPane scrInstrucao = new JScrollPane(instrucao); |
52 | |
|
53 | 0 | maus.setBounds(3, 3, 150, 20); |
54 | 0 | scrTexto.setBounds(3, 20, 450, 80); |
55 | |
|
56 | 0 | bons.setBounds(3, 110, 150, 20); |
57 | 0 | scrInstrucao.setBounds(3, 130, 450, 200); |
58 | |
|
59 | 0 | contador.setBounds(3, 335, 150, 20); |
60 | |
|
61 | 0 | getContentPane().add(bons); |
62 | 0 | getContentPane().add(maus); |
63 | 0 | getContentPane().add(scrTexto); |
64 | 0 | getContentPane().add(scrInstrucao); |
65 | 0 | getContentPane().add(contador); |
66 | |
|
67 | 0 | } |
68 | |
|
69 | |
public void iniciar() { |
70 | 0 | String url = "jdbc:mysql://192.168.0.2/saopaulosp"; |
71 | |
Connection conn; |
72 | |
ResultSet rs1; |
73 | |
ResultSet rs2; |
74 | |
Statement st1; |
75 | |
Statement st2; |
76 | |
int albumID; |
77 | |
int fotoID; |
78 | |
ImageIcon foto; |
79 | |
int altura, largura; |
80 | |
int totalRegistros; |
81 | 0 | int ct = 0; |
82 | 0 | int ctB = 0; |
83 | 0 | int ctM = 0; |
84 | |
File f; |
85 | |
String msgErro; |
86 | |
|
87 | |
try { |
88 | 0 | Class.forName("com.mysql.jdbc.Driver").newInstance(); |
89 | 0 | conn = DriverManager.getConnection(url, "root", ""); |
90 | 0 | Statement st = conn.createStatement(); |
91 | 0 | ResultSet rs = st.executeQuery("select count(*) from fotos"); |
92 | 0 | rs.first(); |
93 | 0 | totalRegistros = rs.getInt(1); |
94 | 0 | rs.close(); |
95 | 0 | st.close(); |
96 | |
|
97 | 0 | st1 = conn.createStatement(); |
98 | 0 | rs1 = st1.executeQuery("select albumID from albuns order by albumID"); |
99 | |
|
100 | 0 | while (rs1.next()) { |
101 | 0 | albumID = rs1.getInt("albumID"); |
102 | 0 | st2 = conn.createStatement(); |
103 | 0 | rs2 = st2.executeQuery("select fotoID from fotos where altura=0 and altura=0 and albumID=" + albumID); |
104 | 0 | while (rs2.next()) { |
105 | 0 | ct++; |
106 | 0 | contador.setText(ct + "/" + totalRegistros); |
107 | 0 | fotoID = rs2.getInt("fotoID"); |
108 | 0 | String caminho = "F:/albuns_sp/" + albumID + "/" + fotoID + ".jpg"; |
109 | 0 | foto = new ImageIcon(caminho); |
110 | |
|
111 | 0 | if (foto.getImageLoadStatus() == MediaTracker.COMPLETE) { |
112 | 0 | ctB++; |
113 | 0 | bons.setText("" + ctB); |
114 | 0 | altura = foto.getIconHeight(); |
115 | 0 | largura = foto.getIconWidth(); |
116 | 0 | caminho = "update fotos set largura=" + largura + ", altura=" + altura + " where fotoID=" + fotoID + ";\n"; |
117 | 0 | instrucao.append(caminho); |
118 | |
} else { |
119 | 0 | ctM++; |
120 | 0 | maus.setText("" + ctM); |
121 | |
|
122 | 0 | msgErro = ""; |
123 | 0 | f = new File("F:/albuns_sp/" + albumID + "/" + fotoID + ".jpg"); |
124 | 0 | if (!f.exists()) { |
125 | 0 | msgErro = " | arquivo não existe"; |
126 | |
} |
127 | 0 | if (!f.isFile()) { |
128 | 0 | msgErro = msgErro + " | não é arquivo"; |
129 | |
} |
130 | 0 | if (!f.canRead()) { |
131 | 0 | msgErro = msgErro + " | não pode ser lido"; |
132 | |
} |
133 | 0 | caminho = albumID + "/" + fotoID + msgErro + "\n"; |
134 | 0 | texto.append(caminho); |
135 | |
} |
136 | 0 | } |
137 | 0 | rs2.close(); |
138 | |
} |
139 | |
|
140 | 0 | } catch (Exception e) { |
141 | 0 | texto.append("erro na leitura do driver " + e); |
142 | 0 | } |
143 | 0 | } |
144 | |
} |