Examples of DcImageIcon


Examples of net.datacrow.util.DcImageIcon

     * Copy an existing picture and set it on this item. This is the safest way to copy
     * an picture of another item to this item.
     */
    public void copyImage(Picture picture, int field) {
        if (picture != null) {
            DcImageIcon icon = (DcImageIcon) picture.getValue(Picture._D_IMAGE);
            if (icon != null)
                setValue(field, new DcImageIcon(icon.getImage()));
        }
    }
View Full Code Here

Examples of net.datacrow.util.DcImageIcon

    protected void beforeSave() throws ValidationException {
        super.beforeSave();

        Picture picture = (Picture) getValue(_E_PHOTO);
        if (picture == null || picture.getValue(Picture._D_IMAGE) == null) {
            setValue(User._E_PHOTO, new DcImageIcon(DataCrow.installationDir + "icons/" + "user.png"));
        }
       
        String loginname = (String) getValue(_A_LOGINNAME);
        if (loginname != null)
            setValue(_A_LOGINNAME, loginname.toLowerCase());
View Full Code Here

Examples of net.datacrow.util.DcImageIcon

            image.setIDs();
            image.setValue(Image._A_TITLE, getName(filename, directoryUsage));
            image.setValue(Image._SYS_FILENAME, filename);
           
            Picture pic = (Picture) DcModules.get(DcModules._PICTURE).getItem();
            DcImageIcon icon;
            if (filename.toLowerCase().endsWith(".svg")) {
                SVGtoBufferedImageConverter converter = new SVGtoBufferedImageConverter();
                BufferedImage bi = converter.renderSVG(filename);
                icon = new DcImageIcon(Utilities.getScaledImage(new DcImageIcon(bi), 400, 400));
                filename = File.createTempFile(String.valueOf(Utilities.getUniqueID()), ".png").toString();
                icon.setFilename(filename);
                icon.save();
                bi.flush();
            } else {
                icon = new DcImageIcon(Utilities.getScaledImage(new DcImageIcon(filename), 400, 400));
                pic.setValue(Picture._G_EXTERNAL_FILENAME, filename);
            }
           
            int width = icon.getIconWidth();
            int height = icon.getIconHeight();
           
            image.setValue(Image._F_WIDTH, width != -1 ? Long.valueOf(width) : null);
            image.setValue(Image._G_HEIGHT, height != -1 ? Long.valueOf(height) : null);
           
            icon.getImage().flush();
           
            pic.setValue(Picture._A_OBJECTID, image.getID());
            pic.setValue(Picture._B_FIELD, image.getField(Image._I_IMAGE).getDatabaseFieldName());
            pic.setValue(Picture._D_IMAGE, icon);
            pic.isEdited(true);
View Full Code Here

Examples of net.datacrow.util.DcImageIcon

        importerClass = module.getImporter();
        hasDependingModules = module.hasDependingModules();
       
        icon16filename = module.getIcon16Filename();
        icon32filename = module.getIcon32Filename();
        icon16 = new DcImageIcon(module.getIcon16());
        icon32 = new DcImageIcon(module.getIcon32());
       
        nameFieldIdx = module.getNameFieldIdx();
        canBeLended = module.canBeLend();
       
        displayIndex = module.getDisplayIndex();
View Full Code Here

Examples of net.datacrow.util.DcImageIcon

                genre = getGenre(tag.getFirst(FieldKey.GENRE));
                year = tag.getFirst(FieldKey.YEAR);
                title = tag.getFirst(FieldKey.TITLE);
               
                for (Artwork aw : tag.getArtworkList())
                    image = new DcImageIcon(aw.getBinaryData());
               
                bitrate = (int) audioFile.getAudioHeader().getBitRateAsNumber();
                length = audioFile.getAudioHeader().getTrackLength();
                encodingType = audioFile.getAudioHeader().getEncodingType();
               
View Full Code Here

Examples of net.datacrow.util.DcImageIcon

       
        try {
            if (file.exists())
                file.delete();
           
            DcImageIcon icon = (DcImageIcon) picture.getValue(Picture._D_IMAGE);
            File realImgFile = icon.getFilename() != null ? new File(icon.getFilename()) : null;
            if (realImgFile != null && realImgFile.exists()) {
                FileInputStream fis  = new FileInputStream(realImgFile);
                FileOutputStream fos = new FileOutputStream(file);
                try {
                    byte[] buf = new byte[1024];
                    int i = 0;
                    while ((i = fis.read(buf)) != -1) {
                        fos.write(buf, 0, i);
                    }
                } catch (Exception e) {
                    throw e;
                } finally {
                    if (fis != null) fis.close();
                    if (fos != null) fos.close();
                }
                Utilities.writeScaledImageToFile(icon, new File(picture.getScaledFilename(imageFile)));
            } else {
                ImageIO.write(Utilities.toBufferedImage(icon), "PNG", file);
                Utilities.writeScaledImageToFile(icon, new File(picture.getScaledFilename(imageFile)));
                icon.flush();
            }
        } catch (Exception e) {
            logger.error("Could not save [" + imageFile + "]", e);
        }
    }
View Full Code Here

Examples of net.datacrow.util.DcImageIcon

            if (o == null) {
                picture = null;
            } else {
                if (o instanceof URL) {
                    URL url = (URL) o;
                    picture = new DcImageIcon(url.getFile());
                } else if (o instanceof String) {
                    String value = (String) o;
                    if (value.endsWith("jpg")) {
                        picture = new DcImageIcon(value);
                    } else {
                        String base64 = (String) o;
                        if (base64.length() > 0)
                            picture = new DcImageIcon(Base64.decode(base64.toCharArray()));
                    }
                } else if (o instanceof DcImageIcon) {
                    picture = (DcImageIcon) o;
                    picture.setImage(picture.getImage());
                }
View Full Code Here

Examples of net.datacrow.util.DcImageIcon

        OpenFromUrlDialog dialog = new OpenFromUrlDialog();
        dialog.setVisible(true);
       
        byte[] image = dialog.getImage();
        if (image != null) {
            picture = new DcImageIcon(image);
            initialize();
            changed = true;
            dialog.setImage(null);
        }
    }
View Full Code Here

Examples of net.datacrow.util.DcImageIcon

            if (file != null) {
               
                if (file.toString().toLowerCase().endsWith(".svg")) {
                    SVGtoBufferedImageConverter converter = new SVGtoBufferedImageConverter();
                    BufferedImage bi = converter.renderSVG(file.toString());
                    picture = new DcImageIcon(Utilities.getBytes(new DcImageIcon(bi)));
                } else {
                    String filename = file.toString().toLowerCase();
                    picture = new DcImageIcon(Utilities.getBytes(
                            Toolkit.getDefaultToolkit().createImage(Utilities.readFile(file)),
                            filename.endsWith(".png") ? DcImageIcon._TYPE_PNG : DcImageIcon._TYPE_JPEG));
                }
               
                initialize();
View Full Code Here

Examples of net.datacrow.util.DcImageIcon

        }
    }
   
    private void grayscale() {
        img = picture.getImage();
        BufferedImage src = Utilities.toBufferedImage(new DcImageIcon(img));
        BufferedImageOp op = new ColorConvertOp(ColorSpace.getInstance(ColorSpace.CS_GRAY), null);
        update(op, src);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.