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:Forms.frm_Penghuni.java

private void btnCariKTPActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCariKTPActionPerformed
    // TODO add your handling code here:
    FileNameExtensionFilter filter = new FileNameExtensionFilter("Image Files", "jpg", "png", "jpeg");
    jfc = new JFileChooser();
    jfc.setFileFilter(filter);// w ww . j av a2 s .c om
    if (jfc.showOpenDialog(pnlKTP) == JFileChooser.APPROVE_OPTION) {
        Rectangle rect1 = pnlKTP.getBounds();
        Toolkit toolkit = Toolkit.getDefaultToolkit();
        Image image = toolkit.getImage(jfc.getSelectedFile().getAbsolutePath());
        Image imagedResized = image.getScaledInstance(rect1.width, rect1.height, Image.SCALE_DEFAULT);
        ImageIcon imageIcon = new ImageIcon(imagedResized);

        pnlKTP.setBackgroundImage(imageIcon);
        tfPasKTP.setText(jfc.getSelectedFile().getName());

        file = new File(jfc.getSelectedFile().getPath());
    }
}

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

private void tblbienesMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblbienesMouseReleased
    // TODO add your handling code here:
    if (evt.getClickCount() == 1) {

        int fila = tblbienes.getSelectedRow();
        this.bien = lista.get(fila);

        try {//from  w ww.  j a  va  2s  .c o m
            nombreField.setText(BeanUtils.getProperty(bien, "nombre"));
            descripcionField.setText(BeanUtils.getProperty(bien, "descripcion"));
            fotoField.setText(BeanUtils.getProperty(bien, "foto"));
            spnStock.setValue(bien.getStockMinimo());
            spnStockMax.setValue(bien.getStockMaximo());
            txtCodigo.setText(bien.getCodigo());

            ImageIcon fot = new ImageIcon(fotoField.getText());
            //                if (fot.getImage().){
            //                    fot = new ImageIcon("img/no_disponible.png");
            //                }
            Icon icono = new ImageIcon(fot.getImage().getScaledInstance(fotoLbl.getWidth(), fotoLbl.getHeight(),
                    Image.SCALE_DEFAULT));
            fotoLbl.setIcon(icono);

            System.out.println("tamao icon: " + fotoLbl.getIcon().getIconHeight());
            if (fotoLbl.getIcon().getIconHeight() == -1) {
                fot = new ImageIcon("img/no_disponible.png");
                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);
        }

    }
}

From source file:org.eclipse.birt.chart.device.g2d.G2dRendererBase.java

/**
 * Scales image according to output DPI. If 96, do not need to scale
 * /*ww  w . j  a v  a2  s .c o  m*/
 * @param img
 * @return
 */
private java.awt.Image scaleImage(java.awt.Image img) {
    if (this._ids.getDpiResolution() == 96) {
        // Do not scale in normal dpi
        return img;
    }
    double scale = this._ids.getDpiResolution() / 96d;
    int newWidth = (int) (img.getWidth((ImageObserver) getDisplayServer().getObserver()) * scale);
    int newHeight = (int) (img.getHeight((ImageObserver) getDisplayServer().getObserver()) * scale);
    return img.getScaledInstance(newWidth, newHeight, Image.SCALE_DEFAULT);
}

From source file:com.t3.model.Token.java

public Icon getIcon(int width, int height) {
    ImageIcon icon = new ImageIcon(ImageManager.getImageAndWait(getImageAssetId()));
    Image image = icon.getImage().getScaledInstance(width, height, Image.SCALE_DEFAULT);
    return new ImageIcon(image);
}

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

private void tblbienesMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblbienesMouseReleased
    // TODO add your handling code here:
    if (evt.getClickCount() == 1) {

        int fila = tblbienes.getSelectedRow();
        this.bien = lista.get(fila);

        try {//from   w ww  .  j  a  va  2 s  .  c  o m
            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);
        }

    }
}

From source file:Forms.frm_Penghuni.java

private void btnDetailActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDetailActionPerformed
    // TODO add your handling code here:
    if (tblPenghuni.getSelectedRowCount() == 1) {
        int baris = tblPenghuni.getSelectedRow();
        String id_penyewa = tblPenghuni.getValueAt(baris, 0).toString();
        try {//from   w  w w.  j  a va 2  s. c  o m
            String sql = "Select *from penyewa where id_penyewa = " + id_penyewa + ";";
            stt = con.createStatement();
            rss = stt.executeQuery(sql);
            while (rss.next()) {
                Object[] o = new Object[15];
                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("email");
                o[7] = rss.getString("noktp");
                o[8] = rss.getString("nohp");
                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");
                o[14] = rss.getString("tgl_terdaftar");

                frm_detail_penghuni detail = new frm_detail_penghuni();
                String nama = o[1].toString();
                String alamat = o[2].toString();
                String tmptLahir = o[3].toString();
                String tglLahir = o[4].toString();
                String Gender = o[5].toString();
                String email = o[6].toString();
                String noKTP = o[7].toString();
                String noTelp = o[8].toString();
                String pekerjaan = o[9].toString();
                String almtPekerjaan = o[10].toString();
                String telpPek = o[11].toString();
                //                String tglMasuk = o[12].toString();
                String fotowajah = o[12].toString();
                String fotoktp = o[13].toString();
                String tgl_daftar = o[14].toString();
                //                frm_detail_penghuni.pnlDetPasFoto.setText(this.o[1].toString());
                //                frm_detail_penghuni.pnlDetPasKTP.setText(this.o[1].toString());

                frm_detail_penghuni.tfDetNama.setText(nama);
                frm_detail_penghuni.tfDetAlamat.setText(alamat);
                frm_detail_penghuni.tfDetTmptLahir.setText(tmptLahir);
                frm_detail_penghuni.tfDetTglLahir.setText(tglLahir);
                frm_detail_penghuni.tfDetGender.setText(Gender);
                frm_detail_penghuni.tfDetEmail.setText(email);
                frm_detail_penghuni.tfDetNomorKTP.setText(noKTP);
                frm_detail_penghuni.tfDetNomorTelp.setText(noTelp);
                frm_detail_penghuni.tfDetPekerjaan.setText(pekerjaan);
                frm_detail_penghuni.tfDetAlamatPekerjaan.setText(almtPekerjaan);
                frm_detail_penghuni.tfDetTelpPekerjaan.setText(telpPek);
                frm_detail_penghuni.tfDetTglMasuk.setText(tgl_daftar);

                try {
                    Toolkit toolkit = Toolkit.getDefaultToolkit();

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

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

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

                } catch (IOException ex) {
                    Logger.getLogger(frm_detail_penghuni.class.getName()).log(Level.SEVERE, null, ex);
                }
                detail.setVisible(true);
            }
        } catch (SQLException e) {
            System.out.println(e.getMessage());
        }

    } else {
        JOptionPane.showMessageDialog(null, "Silahkan Pilih Pengguna Terlebih Dahulu!..");
    }
}

From source file:org.datacleaner.windows.AnalysisJobBuilderWindowImpl.java

private JToggleButton createMoreMenuButton() {
    final JMenuItem optionsMenuItem = WidgetFactory.createMenuItem("Options", IconUtils.MENU_OPTIONS);
    optionsMenuItem.addActionListener(new ActionListener() {
        @Override/*from   ww w. jav  a 2s.c  o  m*/
        public void actionPerformed(ActionEvent e) {
            OptionsDialog optionsDialog = _optionsDialogProvider.get();
            optionsDialog.open();
        }
    });

    final JMenuItem monitorMenuItem = WidgetFactory.createMenuItem("DataCleaner monitor",
            IconUtils.MENU_DQ_MONITOR);
    monitorMenuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            MonitorConnectionDialog dialog = _monitorConnectionDialogProvider.get();
            dialog.open();
        }
    });

    final JMenuItem dictionariesMenuItem = WidgetFactory.createMenuItem("Dictionaries",
            IconUtils.DICTIONARY_IMAGEPATH);
    dictionariesMenuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            ReferenceDataDialog referenceDataDialog = _referenceDataDialogProvider.get();
            referenceDataDialog.selectDictionariesTab();
            referenceDataDialog.open();
        }
    });

    final JMenuItem synonymCatalogsMenuItem = WidgetFactory.createMenuItem("Synonyms",
            IconUtils.SYNONYM_CATALOG_IMAGEPATH);
    synonymCatalogsMenuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            ReferenceDataDialog referenceDataDialog = _referenceDataDialogProvider.get();
            referenceDataDialog.selectSynonymsTab();
            referenceDataDialog.open();
        }
    });

    final JMenuItem stringPatternsMenuItem = WidgetFactory.createMenuItem("String patterns",
            IconUtils.STRING_PATTERN_IMAGEPATH);
    stringPatternsMenuItem.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            ReferenceDataDialog referenceDataDialog = _referenceDataDialogProvider.get();
            referenceDataDialog.selectStringPatternsTab();
            referenceDataDialog.open();
        }
    });

    final PopupButton popupButton = new PopupButton("More",
            imageManager.getImageIcon(IconUtils.ACTION_SCROLLDOWN_BRIGHT));
    applyMenuPopupButttonStyling(popupButton);

    final JMenu windowsMenuItem = WidgetFactory.createMenu("Windows", 'w');
    windowsMenuItem.setIcon(imageManager.getImageIcon("images/menu/windows.png", IconUtils.ICON_SIZE_SMALL));
    final List<DCWindow> windows = getWindowContext().getWindows();

    getWindowContext().addWindowListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            windowsMenuItem.removeAll();
            for (final DCWindow window : windows) {
                final Image windowIcon = window.getWindowIcon();
                final String title = window.getWindowTitle();
                final ImageIcon icon = new ImageIcon(windowIcon.getScaledInstance(IconUtils.ICON_SIZE_SMALL,
                        IconUtils.ICON_SIZE_SMALL, Image.SCALE_DEFAULT));
                final JMenuItem switchToWindowItem = WidgetFactory.createMenuItem(title, icon);
                switchToWindowItem.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        window.toFront();
                    }
                });
                windowsMenuItem.add(switchToWindowItem);
            }

            windowsMenuItem.add(new JSeparator());

            JMenuItem closeAllWindowsItem = WidgetFactory.createMenuItem("Close all dialogs", (ImageIcon) null);
            closeAllWindowsItem.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    List<DCWindow> windows = new ArrayList<>(getWindowContext().getWindows());
                    for (DCWindow window : windows) {
                        if (window instanceof AbstractDialog) {
                            window.close();
                        }
                    }
                }
            });
            windowsMenuItem.add(closeAllWindowsItem);
        }

    });

    popupButton.getMenu().removeAll();
    popupButton.getMenu().add(dictionariesMenuItem);
    popupButton.getMenu().add(synonymCatalogsMenuItem);
    popupButton.getMenu().add(stringPatternsMenuItem);
    popupButton.getMenu().add(new JSeparator());
    popupButton.getMenu().add(windowsMenuItem);
    popupButton.getMenu().add(new JSeparator());
    popupButton.getMenu().add(monitorMenuItem);
    popupButton.getMenu().add(optionsMenuItem);

    return popupButton;
}

From source file:View.FormPengaturan.java

private void button_uploadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button_uploadActionPerformed
    JFileChooser jfc = new JFileChooser();
    if (jfc.showOpenDialog(label_gambar) == JFileChooser.APPROVE_OPTION) {

        Toolkit toolkit = Toolkit.getDefaultToolkit();
        Image image = toolkit.getImage(jfc.getSelectedFile().getAbsolutePath());
        Image imagedResized = image.getScaledInstance(200, 250, Image.SCALE_DEFAULT);
        ImageIcon imageIcon = new ImageIcon(imagedResized);

        label_gambar.setIcon(imageIcon);
        label_namaFile.setText(jfc.getSelectedFile().getName());//nama file nya
        //            System.out.println("jLabelnamaFile : " + label_namaFile.getText());

        file = new File(jfc.getSelectedFile().getPath()); // file untuk dikopi
        //            System.out.println("file : " + file.getPath());
    }/*from  w ww  . j  av a  2s  .  com*/
}

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

private void buscarInventario() {
    accion = Controlador.MODIFICAR;/*from w  ww.jav a  2s.com*/
    //        cargarCombos();
    //        cantidadField.setEditable(false);

    FormularioUtil.activarComponente(panelDatos, true);
    FormularioUtil.activarComponente(panelDatosB, true);
    FormularioUtil.activarComponente(panelFoto, true);
    //        FormularioUtil.activarComponente(panelOpciones, false);
    //        FormularioUtil.activarComponente(panelGuardar, true);

    //        lblbuscar.setText(txtBuscar.getText());
    List<Inventario> listaB = this.inventarioControlador.buscarXSerie(txtBuscar.getText().toUpperCase());

    this.txtBuscar.setText(null);
    this.txtBuscar.requestFocusInWindow();

    if (listaB.isEmpty()) {
        JOptionPane.showMessageDialog(null, "No se encontr el elemento", "Mensaje del Sistema",
                JOptionPane.ERROR_MESSAGE);
    } else {

        inventarioControlador.setSeleccionado(listaB.get(0));

        //            String serie = inventarioControlador.obtenerUltimaSerie(inventarioControlador.getSeleccionado().getBien().getClase().getCodigo());
        //            System.out.println("ULTIMO: "+ inventarioControlador.obtenerUltimaSerie(inventarioControlador.getSeleccionado().getBien().getClase().getCodigo()));
        //            int numero = Integer.valueOf(serie);
        //            System.out.println("ULTIMO NUMERO: "+ numero);
        nombreField.setText(inventarioControlador.getSeleccionado().getBien().getNombre());

        bienGlobal = inventarioControlador.getSeleccionado().getBien();
        //            descripcionField.setText(inventarioControlador.getSeleccionado().getBien().getDescripcion());
        //            fotoField.setText(inventarioControlador.getSeleccionado().getBien().getFoto());
        ImageIcon fot = new ImageIcon(inventarioControlador.getSeleccionado().getBien().getFoto());
        Icon icono = new ImageIcon(
                fot.getImage().getScaledInstance(lblFoto.getWidth(), lblFoto.getHeight(), Image.SCALE_DEFAULT));
        lblFoto.setIcon(icono);

        listaDetalle.clear();
        listaDetalle
                .addAll(detalleControlador.buscarXBienFull(inventarioControlador.getSeleccionado().getBien()));
        listarCampos();
        //INFO INVENTARIO
        cmbEstado.setSelectedItem(inventarioControlador.getSeleccionado().getEstado());

        cmbPeriodo1.setSelectedItem(inventarioControlador.getSeleccionado().getPeriodo());
        periodo = inventarioControlador.getSeleccionado().getPeriodo();

        //            cmbAmbiente.setSelectedItem(inventarioControlador.getSeleccionado().getAmbiente());
        if (inventarioControlador.getSeleccionado().getAmbiente() != null) {
            ambienteField.setText(inventarioControlador.getSeleccionado().getAmbiente().toString());
        }

        if (inventarioControlador.getSeleccionado().getProveedor() != null) {
            proveedorField.setText(inventarioControlador.getSeleccionado().getProveedor().getNombreProveedor());
            proveedor = inventarioControlador.getSeleccionado().getProveedor();
        }

        facturaField.setText(null);

        if (inventarioControlador.getSeleccionado().getFactura() != null) {
            facturaField.setText(inventarioControlador.getSeleccionado().getFactura().getNumeroFactura());
            factura = inventarioControlador.getSeleccionado().getFactura();
        }

        List<Inventario> conteo = inventarioControlador
                .buscarXBien3(inventarioControlador.getSeleccionado().getBien());
        int contar = conteo.size();

        //            lblStock.setText(String.valueOf(contar));
        //            lblUnidades.setVisible(true);
        if (inventarioControlador.getSeleccionado().getImpresionPendiente() != null) {
            chckImpresion.setSelected(inventarioControlador.getSeleccionado().getImpresionPendiente());
        }

        if (inventarioControlador.getSeleccionado().getPrecio() != null) {
            spnPrecio.setValue(inventarioControlador.getSeleccionado().getPrecio());
        }
        serieField.setText(inventarioControlador.getSeleccionado().getSerie());
        serieField.setEditable(false);
        if (inventarioControlador.getSeleccionado().getFechaIngreso() != null) {
            jDateIngreso.setDate(inventarioControlador.getSeleccionado().getFechaIngreso());
        }
        if (inventarioControlador.getSeleccionado().getCodigoFabrica() != null) {
            codFabField.setText(inventarioControlador.getSeleccionado().getCodigoFabrica());
        }
    }
}

From source file:View.FormPengaturan.java

public void sinkronGambar() {
    try {//from ww  w.j  a  v a2 s  .  co m
        Profil prof = PengaturanKontrol.getKoneksi().tampilProfil();
        String path = new File(".").getCanonicalPath() + "/Gambar/" + prof.getLogo();

        Toolkit toolkit = Toolkit.getDefaultToolkit();
        Image image = toolkit.getImage(path);
        Image imagedResized = image.getScaledInstance(110, 100, Image.SCALE_DEFAULT);
        ImageIcon imageIcon = new ImageIcon(imagedResized);
        label_kop.setIcon(imageIcon);
    } catch (IOException ex) {
        Logger.getLogger(FormPengaturan.class.getName()).log(Level.SEVERE, null, ex);
    } catch (SQLException ex) {
        Logger.getLogger(FormPengaturan.class.getName()).log(Level.SEVERE, null, ex);
    }
}