Example usage for java.awt Image SCALE_DEFAULT

List of usage examples for java.awt Image SCALE_DEFAULT

Introduction

In this page you can find the example usage for java.awt Image SCALE_DEFAULT.

Prototype

int SCALE_DEFAULT

To view the source code for java.awt Image SCALE_DEFAULT.

Click Source Link

Document

Use the default image-scaling algorithm.

Usage

From source file:com.digitalpersona.onetouch.ui.swing.sample.Enrollment.Dashboard.java

public void drawPicture(Image image) {
    jLabel1.setIcon(new ImageIcon(
            image.getScaledInstance(jLabel1.getWidth(), jLabel1.getHeight(), Image.SCALE_DEFAULT)));
    fingerprint_list.add(image);/* w ww. j ava  2s .co  m*/
}

From source file:com.digitalpersona.onetouch.ui.swing.sample.Enrollment.Dashboard.java

private void save_list() {
    List<Image> datas = fingerprint_list;
    List<S1_test.to_test> to_list = new ArrayList();
    for (Image to : datas) {

        BufferedImage buffered = new BufferedImage(jLabel1.getWidth(), jLabel1.getHeight(),
                Image.SCALE_DEFAULT);
        buffered.getGraphics().drawImage(to, 0, 0, null);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        try {/*from   w w  w  .ja v a2  s.  co m*/
            ImageIO.write(buffered, "jpg", baos);
        } catch (IOException ex) {
            Logger.getLogger(Dlg_test.class.getName()).log(Level.SEVERE, null, ex);
        }
        byte[] imageInByte = baos.toByteArray();

        S1_test.to_test f = new S1_test.to_test(0, imageInByte);
        to_list.add(f);
    }
    S1_test.add_data(to_list);

}

From source file:com.digitalpersona.onetouch.ui.swing.sample.Enrollment.Dashboard.java

private void list2() {
    List<S1_test.to_test> datas = S1_test.ret_data("");
    S1_test.to_test to = (S1_test.to_test) datas.get(1);
    Image img = Toolkit.getDefaultToolkit().createImage(to.finger_print);
    ImageIcon icon = new ImageIcon(img);
    jLabel2.setIcon(/* ww w  . j  av  a  2  s  . com*/
            new ImageIcon(img.getScaledInstance(jLabel2.getWidth(), jLabel2.getHeight(), Image.SCALE_DEFAULT)));
    BufferedImage img1;
    try {

        InputStream input = new ByteArrayInputStream(to.finger_print);
        OutputStream output = new FileOutputStream("C:\\Users\\Guinness\\Documents\\10.jpg");
        IOUtils.copy(input, output);

    } catch (IOException ex) {
        Logger.getLogger(Dlg_test.class.getName()).log(Level.SEVERE, null, ex);
    }

    verify();
}

From source file:com.biosis.biosislite.vistas.inventario.MantenimientoBien.java

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
    // TODO add your handling code here:
    //        JFileChooser fc = new JFileChooser();
    //        int respuesta = fc.showOpenDialog(this);
    //        if (respuesta == JFileChooser.APPROVE_OPTION) {
    //            File archivoElegido = fc.getSelectedFile();
    //            String absolute = archivoElegido.getAbsolutePath();
    //            fotoField.setText(archivoElegido.ge);
    ///*from  w  ww  . j  av  a 2 s . co m*/
    ////            fotolbl.setIcon(new ImageIcon("C:/Users/Documentos/Desktop/HS/" + fotosField.getText()));
    //            ImageIcon fot = new ImageIcon(absolute);
    //            Icon icono = new ImageIcon(fot.getImage().getScaledInstance(fotoLbl.getWidth(), fotoLbl.getHeight(), Image.SCALE_DEFAULT));
    //            fotoLbl.setIcon(icono);
    //
    //        }
    String foto = FormularioUtil.chooserImagen(this);

    if (!foto.equals("")) {
        fotoField.setText(foto);

        ImageIcon fot = new ImageIcon(foto);
        Icon icono = new ImageIcon(
                fot.getImage().getScaledInstance(fotoLbl.getWidth(), fotoLbl.getHeight(), Image.SCALE_DEFAULT));
        fotoLbl.setIcon(icono);
    }
}

From source file:Formulario.CapturaHuella.java

public void DibujarHuella(Image image) {

    lblImagenHuella.setIcon(new ImageIcon(image.getScaledInstance(lblImagenHuella.getWidth(),
            lblImagenHuella.getHeight(), Image.SCALE_DEFAULT)));
    repaint();//from w w  w  . j a  va 2  s . c om
}

From source file:com.proyecto.vista.MantenimientoBien.java

private void btnmodificarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnmodificarActionPerformed
    // TODO add your handling code here:
    accion = Controlador.MODIFICAR;//from  w w  w .j  a va  2  s .  c  o m

    //        cargarCombo();
    int fila = this.tblbienes.getSelectedRow();
    if (fila != -1) {
        FormularioUtil.activarComponente(panelDatos, true);
        FormularioUtil.activarComponente(panelOpciones, false);
        FormularioUtil.activarComponente(panelGuardar, true);
        claseField.setEditable(false);
        fotoField.setEditable(false);

        accion = Controlador.MODIFICAR;
        bienControlador.setSeleccionado(lista.get(fila));
        Bien bien = bienControlador.getSeleccionado();
        try {
            nombreField.setText(BeanUtils.getProperty(bien, "nombre"));
            descripcionField.setText(BeanUtils.getProperty(bien, "descripcion"));
            fotoField.setText(BeanUtils.getProperty(bien, "foto"));

            ImageIcon fot = new ImageIcon(fotoField.getText());
            Icon icono = new ImageIcon(fot.getImage().getScaledInstance(fotoLbl.getWidth(), fotoLbl.getHeight(),
                    Image.SCALE_DEFAULT));
            fotoLbl.setIcon(icono);

            //                cmbClase.setSelectedItem(bien.getClase());
            claseField.setText(bien.getClase().getNombre());
            listarCamposMod(bien);
        } catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException ex) {
            Logger.getLogger(MantenimientoClase.class.getName()).log(Level.SEVERE, null, ex);
        }
    } else {
        JOptionPane.showMessageDialog(null, "Debe seleccionar un Bien", "Mensaje del Sistema",
                JOptionPane.ERROR_MESSAGE);
    }
}

From source file:Forms.frm_Penghuni.java

private void btnEditActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEditActionPerformed
    // TODO add your handling code here:
    if ((tblPenghuni.getSelectedRow() == -1)) {
        JOptionPane.showMessageDialog(null, "Silahkan pilih baris yang ingin diedit pada Tabel..");
    } else {/*from  ww w.  j  a  v a2 s.co m*/
        int baris = tblPenghuni.getSelectedRow();
        id_penyewa = tblPenghuni.getValueAt(baris, 0).toString();

        try {
            String sql = "Select *from penyewa where id_penyewa = " + id_penyewa + ";";
            stt = con.createStatement();
            rss = stt.executeQuery(sql);
            while (rss.next()) {
                Object[] o = new Object[14];
                o[0] = rss.getString("id_penyewa");
                o[1] = rss.getString("nama");
                o[2] = rss.getString("alamat");
                o[3] = rss.getString("tempat_lahir");
                o[4] = rss.getDate("tgl_lahir");
                o[5] = rss.getString("jk");
                o[6] = rss.getString("noktp");
                o[7] = rss.getString("nohp");
                o[8] = rss.getString("email");
                o[9] = rss.getString("pekerjaan");
                o[10] = rss.getString("alamat_kerja");
                o[11] = rss.getString("notelp_kerja");
                o[12] = rss.getString("foto_wajah");
                o[13] = rss.getString("foto_ktp");

                id_penyewa = rss.getString("id_penyewa");
                tfNamaPenghuni.setText(o[1].toString());
                tfAlamatPenghuni.setText(o[2].toString());
                tfTempatLahirPenghuni.setText(o[3].toString());

                DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
                dcTanggalLahirPenghuni.setDate(dateFormat.parse(o[4].toString()));
                cbGender.setSelectedItem(o[5]);
                tfEmail.setText(o[8].toString());
                tfNomorKTP.setText(o[6].toString());
                tfNomorTelp.setText(o[7].toString());
                tfPekerjaan.setText(o[9].toString());
                tfAlamatPekerjaan.setText(o[10].toString());
                tfNomorTelpPekerjaan.setText(o[11].toString());
                tfPasFoto.setText(o[12].toString());
                tfPasKTP.setText(o[13].toString());

                String fotowajah = o[12].toString();
                String fotoktp = o[13].toString();

                //================== tambah foto ================== 
                try {
                    Toolkit toolkit = Toolkit.getDefaultToolkit();

                    String path = new File(".").getCanonicalPath();

                    Rectangle rect2 = pnlFoto.getBounds();
                    Image image = toolkit.getImage(path + "/image/" + fotowajah);
                    Image imagedResized = image.getScaledInstance(rect2.width, rect2.height,
                            Image.SCALE_DEFAULT);
                    ImageIcon icon = new ImageIcon(imagedResized);
                    pnlFoto.setBackgroundImage(icon);

                    Rectangle rect3 = pnlKTP.getBounds();
                    Image image1 = toolkit.getImage(path + "/image/" + fotoktp);
                    Image imagedResized1 = image1.getScaledInstance(rect3.width, rect3.height,
                            Image.SCALE_DEFAULT);
                    ImageIcon icon1 = new ImageIcon(imagedResized1);
                    pnlKTP.setBackgroundImage(icon1);

                } catch (IOException ex) {
                    Logger.getLogger(frm_detail_penghuni.class.getName()).log(Level.SEVERE, null, ex);
                }
                //================================================= 

                KunciField(true);
            }
        } catch (SQLException e) {
            System.out.println(e.getMessage());
        } catch (ParseException ex) {
            Logger.getLogger(frm_Penghuni.class.getName()).log(Level.SEVERE, null, ex);
        }

    }
}

From source file:View.Main.java

public void setData(String btnOption) {
    ArrayList<DataSet> dataset = downloader.getDataset();
    ArrayList<String> nameList = downloader.getNameList();

    if (dataset.size() == 0) {
        jLabel_txtDoctorName.setVisible(false);
        jLabel_txtHospitalContact.setVisible(false);
        jLabel_txtHospitalName.setVisible(false);

        jButton_next.setEnabled(false);/*w ww.j a  v a  2  s  .c  om*/
        jButton_prev.setEnabled(false);
    } else {
        jLabel_txtDoctorName.setVisible(true);
        jLabel_txtHospitalContact.setVisible(true);
        jLabel_txtHospitalName.setVisible(true);

        jButton_next.setEnabled(true);
        jButton_prev.setEnabled(true);
    }

    if (btnOption.toLowerCase().equals("start")) {
        cnt = 0;
    } else if (btnOption.toLowerCase().equals("next")) {
        cnt++;
    } else {
        cnt--;
    }

    if (cnt >= dataset.size()) {
        cnt = 0;
    } else if (cnt < 0) {
        cnt = dataset.size() - 1;
    }

    System.out.println("dataset size :" + dataset.size());

    if (dataset.size() > 1) {
        jLabel_doctorName.setText(dataset.get(cnt).getDoctorName());

        jLabel_hospitalName.setText(dataset.get(cnt).getHospitalName());
        jLabel_hospitalContact.setText(dataset.get(cnt).getHospitalContact());

        String imageA = Data.directoryPath_downloadNews + nameList.get(2 * cnt);
        String imageB = Data.directoryPath_downloadNews + nameList.get(2 * cnt + 1);
        System.out.println(imageA);

        File imageFileA = new File(imageA);
        File imageFileB = new File(imageB);

        BufferedImage bufImgA = null;
        BufferedImage bufImgB = null;

        try {
            bufImgA = ImageIO.read(imageFileA);
            bufImgB = ImageIO.read(imageFileB);
        } catch (IOException e) {
            e.printStackTrace();
        }

        Image scaledImgA = bufImgA.getScaledInstance(jLabel_newsFeed_displayImageAfter.getWidth(),
                jLabel_newsFeed_displayImageAfter.getHeight(), Image.SCALE_DEFAULT);
        Image scaledImgB = bufImgB.getScaledInstance(jLabel_newsFeed_displayImageBefore.getWidth(),
                jLabel_newsFeed_displayImageBefore.getHeight(), Image.SCALE_DEFAULT);

        jLabel_newsFeed_displayImageAfter.setIcon(new ImageIcon(scaledImgA));
        jLabel_newsFeed_displayImageBefore.setIcon(new ImageIcon(scaledImgB));
    }
}

From source file:View.Main.java

private void setImage(String path) throws IOException {
    BufferedImage bi = ImageIO.read(new File(path));
    Image scaledImg = bi.getScaledInstance(jLabel_displayImage.getWidth(), jLabel_displayImage.getHeight(),
            Image.SCALE_DEFAULT);
    jLabel_displayImage.setIcon(new ImageIcon(scaledImg));
    jLabel_displayImage.setHorizontalAlignment(JLabel.CENTER);
    jLabel_displayImage.setVerticalAlignment(JLabel.CENTER);
}

From source file:Forms.frm_Penghuni.java

private void btnCariFotoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCariFotoActionPerformed
    // TODO add your handling code here:
    FileNameExtensionFilter filter = new FileNameExtensionFilter("Image Files", "jpg", "png", "jpeg");
    jfc1 = new JFileChooser();
    jfc1.setFileFilter(filter);//from  w  w  w  . j  av a  2 s  .co m

    if (jfc1.showOpenDialog(pnlFoto) == JFileChooser.APPROVE_OPTION) {

        Rectangle rect = pnlFoto.getBounds();

        Toolkit toolkit = Toolkit.getDefaultToolkit();
        Image image1 = toolkit.getImage(jfc1.getSelectedFile().getAbsolutePath());
        Image imagedResized = image1.getScaledInstance(rect.width, rect.height, Image.SCALE_DEFAULT);
        ImageIcon imageIcon1 = new ImageIcon(imagedResized);

        pnlFoto.setBackgroundImage(imageIcon1);
        tfPasFoto.setText(jfc1.getSelectedFile().getName());

        file1 = new File(jfc1.getSelectedFile().getPath());
    }
}