1*31e76637SAndrew Rist /************************************************************** 2*31e76637SAndrew Rist * 3*31e76637SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*31e76637SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*31e76637SAndrew Rist * distributed with this work for additional information 6*31e76637SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*31e76637SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*31e76637SAndrew Rist * "License"); you may not use this file except in compliance 9*31e76637SAndrew Rist * with the License. You may obtain a copy of the License at 10*31e76637SAndrew Rist * 11*31e76637SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*31e76637SAndrew Rist * 13*31e76637SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*31e76637SAndrew Rist * software distributed under the License is distributed on an 15*31e76637SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*31e76637SAndrew Rist * KIND, either express or implied. See the License for the 17*31e76637SAndrew Rist * specific language governing permissions and limitations 18*31e76637SAndrew Rist * under the License. 19*31e76637SAndrew Rist * 20*31e76637SAndrew Rist *************************************************************/ 21*31e76637SAndrew Rist 22cdf0e10cSrcweir 23cdf0e10cSrcweir import java.awt.Dimension; 24cdf0e10cSrcweir import java.awt.Image; 25cdf0e10cSrcweir import java.io.File; 26cdf0e10cSrcweir import javax.swing.ImageIcon; 27cdf0e10cSrcweir import javax.swing.JLabel; 28cdf0e10cSrcweir import javax.swing.SwingWorker; 29cdf0e10cSrcweir 30*31e76637SAndrew Rist 31cdf0e10cSrcweir 32cdf0e10cSrcweir /* 33cdf0e10cSrcweir * Simple windows, which should show differences if there are some 34cdf0e10cSrcweir */ 35cdf0e10cSrcweir 36cdf0e10cSrcweir public class ConvwatchGUI extends javax.swing.JFrame 37cdf0e10cSrcweir { 38cdf0e10cSrcweir private ImageIcon[] m_aImageIcon; 39cdf0e10cSrcweir private String m_sInifile; 40cdf0e10cSrcweir private int m_nMaxPages; 41cdf0e10cSrcweir private int m_nCurrentPage; 42cdf0e10cSrcweir 43cdf0e10cSrcweir /** Creates new form ConvwatchGUI 44cdf0e10cSrcweir * @param args 45cdf0e10cSrcweir */ 46cdf0e10cSrcweir ConvwatchGUI(String args[])47cdf0e10cSrcweir private ConvwatchGUI(String args[]) 48cdf0e10cSrcweir { 49cdf0e10cSrcweir if (args.length > 0) 50cdf0e10cSrcweir { 51cdf0e10cSrcweir if (args[0].endsWith(".ini")) 52cdf0e10cSrcweir { 53cdf0e10cSrcweir m_sInifile = args[0]; 54cdf0e10cSrcweir fillImageIconsFromInifile(); 55cdf0e10cSrcweir } 56cdf0e10cSrcweir else 57cdf0e10cSrcweir { 58cdf0e10cSrcweir fillImageIcons(args); 59cdf0e10cSrcweir } 60cdf0e10cSrcweir } 61cdf0e10cSrcweir 62cdf0e10cSrcweir String sVersion = System.getProperty("java.version"); 63cdf0e10cSrcweir Float f = Float.valueOf(sVersion.substring(0,3)); 64cdf0e10cSrcweir if (f.floatValue() < (float)1.6) 65cdf0e10cSrcweir { 66cdf0e10cSrcweir System.out.println("You need at least Java version 1.6"); 67cdf0e10cSrcweir System.exit(1); 68cdf0e10cSrcweir } 69cdf0e10cSrcweir 70cdf0e10cSrcweir initComponents(); 71cdf0e10cSrcweir jLabelDocumentName.setText("Document: " + m_sInifile); 72cdf0e10cSrcweir } 73cdf0e10cSrcweir fillImageIconsFromInifile()74cdf0e10cSrcweir void fillImageIconsFromInifile() 75cdf0e10cSrcweir { 76cdf0e10cSrcweir File aFile = new File(m_sInifile); 77cdf0e10cSrcweir if (!aFile.exists()) 78cdf0e10cSrcweir { 79cdf0e10cSrcweir GlobalLogWriter.println("Inifile '" + m_sInifile + "' not found."); 80cdf0e10cSrcweir printUsage(); 81cdf0e10cSrcweir System.exit(1); 82cdf0e10cSrcweir } 83cdf0e10cSrcweir 84cdf0e10cSrcweir IniFile aIniFile = new IniFile(aFile); 85cdf0e10cSrcweir int nPages = aIniFile.getIntValue("global", "pages", 0); 86cdf0e10cSrcweir if (nPages < 1) 87cdf0e10cSrcweir { 88cdf0e10cSrcweir System.out.println("No pages found."); 89cdf0e10cSrcweir } 90cdf0e10cSrcweir m_nMaxPages = nPages; 91cdf0e10cSrcweir m_nCurrentPage = 1; 92cdf0e10cSrcweir fillImageIcons(); 93cdf0e10cSrcweir } 94cdf0e10cSrcweir fillImageIcons()95cdf0e10cSrcweir private void fillImageIcons() 96cdf0e10cSrcweir { 97cdf0e10cSrcweir File aFile = new File(m_sInifile); 98cdf0e10cSrcweir IniFile aIniFile = new IniFile(aFile); 99cdf0e10cSrcweir String sSection = "page" + m_nCurrentPage; 100cdf0e10cSrcweir String[] files = new String[3]; 101cdf0e10cSrcweir files[0] = aIniFile.getValue(sSection, "newgfx"); // current created picture 102cdf0e10cSrcweir files[1] = aIniFile.getValue(sSection, "oldgfx"); // reference picture 103cdf0e10cSrcweir files[2] = aIniFile.getValue(sSection, "diffgfx"); 104cdf0e10cSrcweir fillImageIcons(files); 105cdf0e10cSrcweir } 106cdf0e10cSrcweir 107cdf0e10cSrcweir /** 108cdf0e10cSrcweir * Give 3 file names 109cdf0e10cSrcweir * @param args 110cdf0e10cSrcweir */ fillImageIcons(String args[])111cdf0e10cSrcweir private void fillImageIcons(String args[]) 112cdf0e10cSrcweir { 113cdf0e10cSrcweir boolean bLoadImages = false; 114cdf0e10cSrcweir m_aImageIcon = new ImageIcon[3]; 115cdf0e10cSrcweir for (int i=0;i<3;i++) 116cdf0e10cSrcweir { 117cdf0e10cSrcweir if (args.length > i && args[i] != null) 118cdf0e10cSrcweir { 119cdf0e10cSrcweir File aFile = new File(args[i]); 120cdf0e10cSrcweir if (aFile.exists()) 121cdf0e10cSrcweir { 122cdf0e10cSrcweir // TODO: Load images 123cdf0e10cSrcweir // Image aImage = new BufferedImage(100,100, BufferedImage.TYPE_INT_RGB); 124cdf0e10cSrcweir // aImage. 125cdf0e10cSrcweir m_aImageIcon[i] = new ImageIcon(args[i]); 126cdf0e10cSrcweir if (m_aImageIcon[i] != null) 127cdf0e10cSrcweir { 128cdf0e10cSrcweir bLoadImages = true; 129cdf0e10cSrcweir } 130cdf0e10cSrcweir } 131cdf0e10cSrcweir else 132cdf0e10cSrcweir { 133cdf0e10cSrcweir System.out.println("Can't read file: " + aFile.getName()); 134cdf0e10cSrcweir bLoadImages = false; 135cdf0e10cSrcweir } 136cdf0e10cSrcweir } 137cdf0e10cSrcweir else 138cdf0e10cSrcweir { 139cdf0e10cSrcweir System.out.println("There is no #" + (i + 1) + " image given."); 140cdf0e10cSrcweir bLoadImages = false; 141cdf0e10cSrcweir } 142cdf0e10cSrcweir } 143cdf0e10cSrcweir // if (!bLoadImages) 144cdf0e10cSrcweir // { 145cdf0e10cSrcweir // printUsage(); 146cdf0e10cSrcweir // System.exit(1); 147cdf0e10cSrcweir // } 148cdf0e10cSrcweir 149cdf0e10cSrcweir 150cdf0e10cSrcweir 151cdf0e10cSrcweir // TODO: Set images. 152cdf0e10cSrcweir 153cdf0e10cSrcweir // formComponentResized(null); 154cdf0e10cSrcweir } 155cdf0e10cSrcweir printUsage()156cdf0e10cSrcweir private void printUsage() 157cdf0e10cSrcweir { 158cdf0e10cSrcweir System.out.println("Usage:"); 159cdf0e10cSrcweir System.out.println(" ConvwatchGUI <pic1> <pic2> <pic3>"); 160cdf0e10cSrcweir System.out.println("or ConvwatchGUI <inifile>"); 161cdf0e10cSrcweir } 162cdf0e10cSrcweir 163cdf0e10cSrcweir // private int m_nOldWidth; 164cdf0e10cSrcweir 165cdf0e10cSrcweir /** This method is called from within the constructor to 166cdf0e10cSrcweir * initialize the form. 167cdf0e10cSrcweir * WARNING: Do NOT modify this code. The content of this method is 168cdf0e10cSrcweir * always regenerated by the Form Editor. 169cdf0e10cSrcweir */ 170cdf0e10cSrcweir @SuppressWarnings("unchecked") 171cdf0e10cSrcweir // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents initComponents()172cdf0e10cSrcweir private void initComponents() { 173cdf0e10cSrcweir 174cdf0e10cSrcweir jPanelOriginal = new javax.swing.JPanel(); 175cdf0e10cSrcweir jLabelOriginalImage = new javax.swing.JLabel(); 176cdf0e10cSrcweir jPanelReference = new javax.swing.JPanel(); 177cdf0e10cSrcweir jLabelReferenceImage = new javax.swing.JLabel(); 178cdf0e10cSrcweir jPanelDifference = new javax.swing.JPanel(); 179cdf0e10cSrcweir jLabelDifferenceImage = new javax.swing.JLabel(); 180cdf0e10cSrcweir jPanel4 = new javax.swing.JPanel(); 181cdf0e10cSrcweir jButton1 = new javax.swing.JButton(); 182cdf0e10cSrcweir jButton2 = new javax.swing.JButton(); 183cdf0e10cSrcweir jButton3 = new javax.swing.JButton(); 184cdf0e10cSrcweir jLabelCurrentPage = new javax.swing.JLabel(); 185cdf0e10cSrcweir jPanel5 = new javax.swing.JPanel(); 186cdf0e10cSrcweir jLabel1 = new javax.swing.JLabel(); 187cdf0e10cSrcweir jLabelDocumentName = new javax.swing.JLabel(); 188cdf0e10cSrcweir 189cdf0e10cSrcweir setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); 190cdf0e10cSrcweir addComponentListener(new java.awt.event.ComponentAdapter() { 191cdf0e10cSrcweir public void componentResized(java.awt.event.ComponentEvent evt) { 192cdf0e10cSrcweir formComponentResized(evt); 193cdf0e10cSrcweir } 194cdf0e10cSrcweir }); 195cdf0e10cSrcweir addPropertyChangeListener(new java.beans.PropertyChangeListener() { 196cdf0e10cSrcweir public void propertyChange(java.beans.PropertyChangeEvent evt) { 197cdf0e10cSrcweir formPropertyChange(evt); 198cdf0e10cSrcweir } 199cdf0e10cSrcweir }); 200cdf0e10cSrcweir 201cdf0e10cSrcweir jPanelOriginal.setBorder(javax.swing.BorderFactory.createTitledBorder("Picture")); 202cdf0e10cSrcweir 203cdf0e10cSrcweir javax.swing.GroupLayout jPanelOriginalLayout = new javax.swing.GroupLayout(jPanelOriginal); 204cdf0e10cSrcweir jPanelOriginal.setLayout(jPanelOriginalLayout); 205cdf0e10cSrcweir jPanelOriginalLayout.setHorizontalGroup( 206cdf0e10cSrcweir jPanelOriginalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 207cdf0e10cSrcweir .addGroup(jPanelOriginalLayout.createSequentialGroup() 208cdf0e10cSrcweir .addContainerGap() 209cdf0e10cSrcweir .addComponent(jLabelOriginalImage, javax.swing.GroupLayout.DEFAULT_SIZE, 299, Short.MAX_VALUE) 210cdf0e10cSrcweir .addContainerGap()) 211cdf0e10cSrcweir ); 212cdf0e10cSrcweir jPanelOriginalLayout.setVerticalGroup( 213cdf0e10cSrcweir jPanelOriginalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 214cdf0e10cSrcweir .addGroup(jPanelOriginalLayout.createSequentialGroup() 215cdf0e10cSrcweir .addComponent(jLabelOriginalImage, javax.swing.GroupLayout.DEFAULT_SIZE, 514, Short.MAX_VALUE) 216cdf0e10cSrcweir .addContainerGap()) 217cdf0e10cSrcweir ); 218cdf0e10cSrcweir 219cdf0e10cSrcweir jPanelReference.setBorder(javax.swing.BorderFactory.createTitledBorder("Reference Picture")); 220cdf0e10cSrcweir 221cdf0e10cSrcweir javax.swing.GroupLayout jPanelReferenceLayout = new javax.swing.GroupLayout(jPanelReference); 222cdf0e10cSrcweir jPanelReference.setLayout(jPanelReferenceLayout); 223cdf0e10cSrcweir jPanelReferenceLayout.setHorizontalGroup( 224cdf0e10cSrcweir jPanelReferenceLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 225cdf0e10cSrcweir .addGroup(jPanelReferenceLayout.createSequentialGroup() 226cdf0e10cSrcweir .addContainerGap() 227cdf0e10cSrcweir .addComponent(jLabelReferenceImage, javax.swing.GroupLayout.DEFAULT_SIZE, 299, Short.MAX_VALUE) 228cdf0e10cSrcweir .addContainerGap()) 229cdf0e10cSrcweir ); 230cdf0e10cSrcweir jPanelReferenceLayout.setVerticalGroup( 231cdf0e10cSrcweir jPanelReferenceLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 232cdf0e10cSrcweir .addGroup(jPanelReferenceLayout.createSequentialGroup() 233cdf0e10cSrcweir .addComponent(jLabelReferenceImage, javax.swing.GroupLayout.DEFAULT_SIZE, 514, Short.MAX_VALUE) 234cdf0e10cSrcweir .addContainerGap()) 235cdf0e10cSrcweir ); 236cdf0e10cSrcweir 237cdf0e10cSrcweir jPanelDifference.setBorder(javax.swing.BorderFactory.createTitledBorder("Difference")); 238cdf0e10cSrcweir 239cdf0e10cSrcweir jLabelDifferenceImage.setName("DifferenceImage"); // NOI18N 240cdf0e10cSrcweir 241cdf0e10cSrcweir javax.swing.GroupLayout jPanelDifferenceLayout = new javax.swing.GroupLayout(jPanelDifference); 242cdf0e10cSrcweir jPanelDifference.setLayout(jPanelDifferenceLayout); 243cdf0e10cSrcweir jPanelDifferenceLayout.setHorizontalGroup( 244cdf0e10cSrcweir jPanelDifferenceLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 245cdf0e10cSrcweir .addGroup(jPanelDifferenceLayout.createSequentialGroup() 246cdf0e10cSrcweir .addContainerGap() 247cdf0e10cSrcweir .addComponent(jLabelDifferenceImage, javax.swing.GroupLayout.DEFAULT_SIZE, 298, Short.MAX_VALUE) 248cdf0e10cSrcweir .addContainerGap()) 249cdf0e10cSrcweir ); 250cdf0e10cSrcweir jPanelDifferenceLayout.setVerticalGroup( 251cdf0e10cSrcweir jPanelDifferenceLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 252cdf0e10cSrcweir .addGroup(jPanelDifferenceLayout.createSequentialGroup() 253cdf0e10cSrcweir .addComponent(jLabelDifferenceImage, javax.swing.GroupLayout.DEFAULT_SIZE, 514, Short.MAX_VALUE) 254cdf0e10cSrcweir .addContainerGap()) 255cdf0e10cSrcweir ); 256cdf0e10cSrcweir 257cdf0e10cSrcweir jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Action")); 258cdf0e10cSrcweir 259cdf0e10cSrcweir jButton1.setText("Close"); 260cdf0e10cSrcweir jButton1.addActionListener(new java.awt.event.ActionListener() { 261cdf0e10cSrcweir public void actionPerformed(java.awt.event.ActionEvent evt) { 262cdf0e10cSrcweir jButton1ActionPerformed(evt); 263cdf0e10cSrcweir } 264cdf0e10cSrcweir }); 265cdf0e10cSrcweir 266cdf0e10cSrcweir jButton2.setLabel("prev page"); 267cdf0e10cSrcweir jButton2.addActionListener(new java.awt.event.ActionListener() { 268cdf0e10cSrcweir public void actionPerformed(java.awt.event.ActionEvent evt) { 269cdf0e10cSrcweir jButton2ActionPerformed(evt); 270cdf0e10cSrcweir } 271cdf0e10cSrcweir }); 272cdf0e10cSrcweir 273cdf0e10cSrcweir jButton3.setLabel("next page"); 274cdf0e10cSrcweir jButton3.addActionListener(new java.awt.event.ActionListener() { 275cdf0e10cSrcweir public void actionPerformed(java.awt.event.ActionEvent evt) { 276cdf0e10cSrcweir jButton3ActionPerformed(evt); 277cdf0e10cSrcweir } 278cdf0e10cSrcweir }); 279cdf0e10cSrcweir 280cdf0e10cSrcweir jLabelCurrentPage.setText("Current page: 1"); 281cdf0e10cSrcweir 282cdf0e10cSrcweir javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4); 283cdf0e10cSrcweir jPanel4.setLayout(jPanel4Layout); 284cdf0e10cSrcweir jPanel4Layout.setHorizontalGroup( 285cdf0e10cSrcweir jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 286cdf0e10cSrcweir .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup() 287cdf0e10cSrcweir .addContainerGap() 288cdf0e10cSrcweir .addComponent(jButton2) 289cdf0e10cSrcweir .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 290cdf0e10cSrcweir .addComponent(jButton3) 291cdf0e10cSrcweir .addGap(18, 18, 18) 292cdf0e10cSrcweir .addComponent(jLabelCurrentPage, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE) 293cdf0e10cSrcweir .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 614, Short.MAX_VALUE) 294cdf0e10cSrcweir .addComponent(jButton1) 295cdf0e10cSrcweir .addContainerGap()) 296cdf0e10cSrcweir ); 297cdf0e10cSrcweir jPanel4Layout.setVerticalGroup( 298cdf0e10cSrcweir jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 299cdf0e10cSrcweir .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup() 300cdf0e10cSrcweir .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 301cdf0e10cSrcweir .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 302cdf0e10cSrcweir .addComponent(jButton1) 303cdf0e10cSrcweir .addComponent(jButton2) 304cdf0e10cSrcweir .addComponent(jButton3) 305cdf0e10cSrcweir .addComponent(jLabelCurrentPage)) 306cdf0e10cSrcweir .addContainerGap()) 307cdf0e10cSrcweir ); 308cdf0e10cSrcweir 309cdf0e10cSrcweir jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("Information")); 310cdf0e10cSrcweir 311cdf0e10cSrcweir jLabel1.setText("<html>Here you see a graphical compare by pictures created with a current running office, a stored reference picture and the difference between those both pictures created by ImageMagicks 'composite'.\n</html>"); // NOI18N 312cdf0e10cSrcweir 313cdf0e10cSrcweir jLabelDocumentName.setText("jLabel2"); 314cdf0e10cSrcweir 315cdf0e10cSrcweir javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5); 316cdf0e10cSrcweir jPanel5.setLayout(jPanel5Layout); 317cdf0e10cSrcweir jPanel5Layout.setHorizontalGroup( 318cdf0e10cSrcweir jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 319cdf0e10cSrcweir .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup() 320cdf0e10cSrcweir .addContainerGap() 321cdf0e10cSrcweir .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) 322cdf0e10cSrcweir .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 972, Short.MAX_VALUE) 323cdf0e10cSrcweir .addComponent(jLabelDocumentName, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 972, Short.MAX_VALUE)) 324cdf0e10cSrcweir .addContainerGap()) 325cdf0e10cSrcweir ); 326cdf0e10cSrcweir jPanel5Layout.setVerticalGroup( 327cdf0e10cSrcweir jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 328cdf0e10cSrcweir .addGroup(jPanel5Layout.createSequentialGroup() 329cdf0e10cSrcweir .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 50, Short.MAX_VALUE) 330cdf0e10cSrcweir .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 331cdf0e10cSrcweir .addComponent(jLabelDocumentName, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE) 332cdf0e10cSrcweir .addContainerGap()) 333cdf0e10cSrcweir ); 334cdf0e10cSrcweir 335cdf0e10cSrcweir javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); 336cdf0e10cSrcweir getContentPane().setLayout(layout); 337cdf0e10cSrcweir layout.setHorizontalGroup( 338cdf0e10cSrcweir layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 339cdf0e10cSrcweir .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() 340cdf0e10cSrcweir .addContainerGap() 341cdf0e10cSrcweir .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) 342cdf0e10cSrcweir .addComponent(jPanel5, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 343cdf0e10cSrcweir .addComponent(jPanel4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 344cdf0e10cSrcweir .addGroup(layout.createSequentialGroup() 345cdf0e10cSrcweir .addComponent(jPanelOriginal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 346cdf0e10cSrcweir .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 347cdf0e10cSrcweir .addComponent(jPanelReference, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 348cdf0e10cSrcweir .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 349cdf0e10cSrcweir .addComponent(jPanelDifference, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) 350cdf0e10cSrcweir .addContainerGap()) 351cdf0e10cSrcweir ); 352cdf0e10cSrcweir layout.setVerticalGroup( 353cdf0e10cSrcweir layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 354cdf0e10cSrcweir .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() 355cdf0e10cSrcweir .addContainerGap() 356cdf0e10cSrcweir .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 357cdf0e10cSrcweir .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 358cdf0e10cSrcweir .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) 359cdf0e10cSrcweir .addComponent(jPanelReference, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 360cdf0e10cSrcweir .addComponent(jPanelOriginal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 361cdf0e10cSrcweir .addComponent(jPanelDifference, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 362cdf0e10cSrcweir .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 363cdf0e10cSrcweir .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 364cdf0e10cSrcweir .addContainerGap()) 365cdf0e10cSrcweir ); 366cdf0e10cSrcweir 367cdf0e10cSrcweir pack(); 368cdf0e10cSrcweir }// </editor-fold>//GEN-END:initComponents 369cdf0e10cSrcweir 370cdf0e10cSrcweir private boolean bAdd = false; 371cdf0e10cSrcweir formComponentResized(java.awt.event.ComponentEvent evt)372cdf0e10cSrcweir private void formComponentResized(java.awt.event.ComponentEvent evt)//GEN-FIRST:event_formComponentResized 373cdf0e10cSrcweir {//GEN-HEADEREND:event_formComponentResized 374cdf0e10cSrcweir // TODO add your handling code here: 375cdf0e10cSrcweir // we need to set icons to null 376cdf0e10cSrcweir // if we don't do this, icons can only grow, but not shrink :-( 377cdf0e10cSrcweir 378cdf0e10cSrcweir initialiseImages(); 379cdf0e10cSrcweir } initialiseImages()380cdf0e10cSrcweir private void initialiseImages() 381cdf0e10cSrcweir { 382cdf0e10cSrcweir if (jLabelOriginalImage.getIcon() != null) 383cdf0e10cSrcweir { 384cdf0e10cSrcweir jLabelOriginalImage.setIcon(null); 385cdf0e10cSrcweir jLabelReferenceImage.setIcon(null); 386cdf0e10cSrcweir jLabelDifferenceImage.setIcon(null); 387cdf0e10cSrcweir 388cdf0e10cSrcweir int w = getWidth(); 389cdf0e10cSrcweir int h = getHeight(); 390cdf0e10cSrcweir if (bAdd) 391cdf0e10cSrcweir { 392cdf0e10cSrcweir this.setSize(w, h + 1); 393cdf0e10cSrcweir bAdd = false; 394cdf0e10cSrcweir } 395cdf0e10cSrcweir else 396cdf0e10cSrcweir { 397cdf0e10cSrcweir this.setSize(w, h - 1); 398cdf0e10cSrcweir bAdd = true; 399cdf0e10cSrcweir } 400cdf0e10cSrcweir } 401cdf0e10cSrcweir else 402cdf0e10cSrcweir { 403cdf0e10cSrcweir new ResizeImage(jLabelOriginalImage, m_aImageIcon[0]).execute(); 404cdf0e10cSrcweir new ResizeImage(jLabelReferenceImage, m_aImageIcon[1]).execute(); 405cdf0e10cSrcweir new ResizeImage(jLabelDifferenceImage, m_aImageIcon[2]).execute(); 406cdf0e10cSrcweir } 407cdf0e10cSrcweir int dummy=0; 408cdf0e10cSrcweir }//GEN-LAST:event_formComponentResized 409cdf0e10cSrcweir jButton1ActionPerformed(java.awt.event.ActionEvent evt)410cdf0e10cSrcweir private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButton1ActionPerformed 411cdf0e10cSrcweir {//GEN-HEADEREND:event_jButton1ActionPerformed 412cdf0e10cSrcweir // TODO add your handling code here: 413cdf0e10cSrcweir System.exit(1); 414cdf0e10cSrcweir }//GEN-LAST:event_jButton1ActionPerformed 415cdf0e10cSrcweir formPropertyChange(java.beans.PropertyChangeEvent evt)416cdf0e10cSrcweir private void formPropertyChange(java.beans.PropertyChangeEvent evt)//GEN-FIRST:event_formPropertyChange 417cdf0e10cSrcweir {//GEN-HEADEREND:event_formPropertyChange 418cdf0e10cSrcweir // TODO add your handling code here: 419cdf0e10cSrcweir int dummy = 0; 420cdf0e10cSrcweir }//GEN-LAST:event_formPropertyChange 421cdf0e10cSrcweir jButton2ActionPerformed(java.awt.event.ActionEvent evt)422cdf0e10cSrcweir private void jButton2ActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButton2ActionPerformed 423cdf0e10cSrcweir {//GEN-HEADEREND:event_jButton2ActionPerformed 424cdf0e10cSrcweir // TODO add your handling code here: 425cdf0e10cSrcweir int nOldPage = m_nCurrentPage; 426cdf0e10cSrcweir if (m_nCurrentPage > 1) 427cdf0e10cSrcweir { 428cdf0e10cSrcweir m_nCurrentPage--; 429cdf0e10cSrcweir } 430cdf0e10cSrcweir if (nOldPage != m_nCurrentPage) 431cdf0e10cSrcweir { 432cdf0e10cSrcweir jLabelCurrentPage.setText("Current page: " + m_nCurrentPage); 433cdf0e10cSrcweir fillImageIcons(); 434cdf0e10cSrcweir initialiseImages(); 435cdf0e10cSrcweir } 436cdf0e10cSrcweir }//GEN-LAST:event_jButton2ActionPerformed 437cdf0e10cSrcweir jButton3ActionPerformed(java.awt.event.ActionEvent evt)438cdf0e10cSrcweir private void jButton3ActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButton3ActionPerformed 439cdf0e10cSrcweir {//GEN-HEADEREND:event_jButton3ActionPerformed 440cdf0e10cSrcweir // TODO add your handling code here: 441cdf0e10cSrcweir int nOldPage = m_nCurrentPage; 442cdf0e10cSrcweir if (m_nCurrentPage < m_nMaxPages) 443cdf0e10cSrcweir { 444cdf0e10cSrcweir m_nCurrentPage++; 445cdf0e10cSrcweir } 446cdf0e10cSrcweir if (nOldPage != m_nCurrentPage) 447cdf0e10cSrcweir { 448cdf0e10cSrcweir jLabelCurrentPage.setText("Current page: " + m_nCurrentPage); 449cdf0e10cSrcweir fillImageIcons(); 450cdf0e10cSrcweir initialiseImages(); 451cdf0e10cSrcweir } 452cdf0e10cSrcweir }//GEN-LAST:event_jButton3ActionPerformed 453cdf0e10cSrcweir 454cdf0e10cSrcweir class ResizeImage extends SwingWorker <ImageIcon, Object> 455cdf0e10cSrcweir { 456cdf0e10cSrcweir private JLabel m_jLabel; 457cdf0e10cSrcweir private ImageIcon m_aImageIcon; 458cdf0e10cSrcweir private int w; 459cdf0e10cSrcweir private int h; 460cdf0e10cSrcweir ResizeImage(JLabel _aLabel, ImageIcon _aImageIcon)461cdf0e10cSrcweir public ResizeImage(JLabel _aLabel, ImageIcon _aImageIcon) 462cdf0e10cSrcweir { 463cdf0e10cSrcweir m_jLabel = _aLabel; 464cdf0e10cSrcweir m_aImageIcon = _aImageIcon; 465cdf0e10cSrcweir w = _aLabel.getWidth(); 466cdf0e10cSrcweir h = _aLabel.getHeight(); 467cdf0e10cSrcweir } 468cdf0e10cSrcweir 469cdf0e10cSrcweir // dont access here anything to "Event Swing Thread" 470cdf0e10cSrcweir @Override doInBackground()471cdf0e10cSrcweir public ImageIcon doInBackground() 472cdf0e10cSrcweir { 473cdf0e10cSrcweir Image aImage = m_aImageIcon.getImage().getScaledInstance(w, h, Image.SCALE_AREA_AVERAGING); // SCALE_SMOOTH 474cdf0e10cSrcweir final ImageIcon aIcon = new ImageIcon(aImage); 475cdf0e10cSrcweir // m_jLabel.setIcon(aIcon); 476cdf0e10cSrcweir return aIcon; 477cdf0e10cSrcweir } 478cdf0e10cSrcweir 479cdf0e10cSrcweir @Override done()480cdf0e10cSrcweir protected void done() 481cdf0e10cSrcweir { 482cdf0e10cSrcweir try 483cdf0e10cSrcweir { 484cdf0e10cSrcweir m_jLabel.setIcon(get()); 485cdf0e10cSrcweir } 486cdf0e10cSrcweir catch (Exception e) 487cdf0e10cSrcweir {} 488cdf0e10cSrcweir } 489cdf0e10cSrcweir 490cdf0e10cSrcweir } 491cdf0e10cSrcweir 492cdf0e10cSrcweir /** 493cdf0e10cSrcweir * @param args the command line arguments 494cdf0e10cSrcweir */ main(final String args[])495cdf0e10cSrcweir public static void main(final String args[]) 496cdf0e10cSrcweir { 497cdf0e10cSrcweir 498cdf0e10cSrcweir // Start GUI 499cdf0e10cSrcweir 500cdf0e10cSrcweir java.awt.EventQueue.invokeLater(new Runnable() 501cdf0e10cSrcweir { 502cdf0e10cSrcweir 503cdf0e10cSrcweir public void run() 504cdf0e10cSrcweir { 505cdf0e10cSrcweir ConvwatchGUI aGUI = new ConvwatchGUI(args); 506cdf0e10cSrcweir aGUI.setTitle("Graphical Compare"); 507cdf0e10cSrcweir aGUI.setPreferredSize(new Dimension(1024, 768)); 508cdf0e10cSrcweir 509cdf0e10cSrcweir aGUI.setVisible(true); 510cdf0e10cSrcweir } 511cdf0e10cSrcweir }); 512cdf0e10cSrcweir } 513cdf0e10cSrcweir // Variables declaration - do not modify//GEN-BEGIN:variables 514cdf0e10cSrcweir private javax.swing.JButton jButton1; 515cdf0e10cSrcweir private javax.swing.JButton jButton2; 516cdf0e10cSrcweir private javax.swing.JButton jButton3; 517cdf0e10cSrcweir private javax.swing.JLabel jLabel1; 518cdf0e10cSrcweir private javax.swing.JLabel jLabelCurrentPage; 519cdf0e10cSrcweir private javax.swing.JLabel jLabelDifferenceImage; 520cdf0e10cSrcweir private javax.swing.JLabel jLabelDocumentName; 521cdf0e10cSrcweir private javax.swing.JLabel jLabelOriginalImage; 522cdf0e10cSrcweir private javax.swing.JLabel jLabelReferenceImage; 523cdf0e10cSrcweir private javax.swing.JPanel jPanel4; 524cdf0e10cSrcweir private javax.swing.JPanel jPanel5; 525cdf0e10cSrcweir private javax.swing.JPanel jPanelDifference; 526cdf0e10cSrcweir private javax.swing.JPanel jPanelOriginal; 527cdf0e10cSrcweir private javax.swing.JPanel jPanelReference; 528cdf0e10cSrcweir // End of variables declaration//GEN-END:variables 529cdf0e10cSrcweir } 530