Package net.java.truevfs.access

Examples of net.java.truevfs.access.TFile


        if (card.isToken()) {
            if (pathCache.containsKey(card)) {
                return pathCache.get(card);
            }
            String filePath = getTokenImagePath(card);
            TFile file = new TFile(filePath);

            if (!file.exists() && card.getTokenSetCode() != null) {
                filePath = searchForCardImage(card);
                file = new TFile(filePath);
            }

            if (file.exists()) {
                pathCache.put(card, filePath);
                return filePath;
            }
        }
View Full Code Here


    }

    private static String getTokenImagePath(CardDownloadData card) {
        String filename = generateImagePath(card);

        TFile file = new TFile(filename);
        if (!file.exists()) {
            CardDownloadData updated = new CardDownloadData(card);
            updated.setName(card.getName() + " 1");
            filename = generateImagePath(updated);
            file = new TFile(filename);
            if (!file.exists()) {
                updated = new CardDownloadData(card);
                updated.setName(card.getName() + " 2");
                filename = generateImagePath(updated);
            }
        }
View Full Code Here

        return filename;
    }

    private static String searchForCardImage(CardDownloadData card) {
        TFile file;
        String path;
        CardDownloadData c = new CardDownloadData(card);
        c.setSet(card.getTokenSetCode());
        path = getTokenImagePath(c);
        file = new TFile(path);
        if (file.exists()) {
            pathCache.put(card, path);
            return path;
        }

//        for (String set : SettingsManager.getIntance().getTokenLookupOrder()) {
View Full Code Here

            imageName = name + "." + card.getCollectorId() + ".full.jpg";
        } else {
            imageName = name + type + ".full.jpg";
        }

        if (new TFile(imageDir).exists() && !new TFile(imageDir + TFile.separator + imageName).exists()) {
            for (String fileName : new TFile(imageDir).list()) {
                if (fileName.toLowerCase().equals(imageName.toLowerCase())) {
                    imageName = fileName;
                    break;
                }
            }
View Full Code Here

    public static BufferedImage getMorphImage() {
        CardDownloadData info = new CardDownloadData("Morph", "KTK", 0, false, 0, "KTK");
        info.setToken(true);
        String path = CardImageUtils.generateTokenImagePath(info);
        TFile file = new TFile(path);
        return loadImage(file);
    }
View Full Code Here

        return image;
    }

    public static BufferedImage makeThumbnail(BufferedImage original, String path) {
        BufferedImage image = getResizedImage(original, Constants.THUMBNAIL_SIZE_FULL);
        TFile imageFile = new TFile(path);
        try {
            TFileOutputStream outputStream = null;
            try {
                //log.debug("thumbnail path:"+path);
                outputStream = new TFileOutputStream(imageFile);
View Full Code Here

        Object[] options = { startDownloadButton, closeButton = new JButton("Cancel") };
        dlg = new JOptionPane(p0, JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null, options, options[1]);
    }

    public static boolean checkForNewCards(List<CardInfo> allCards) {
        TFile file;
        for (CardInfo card : allCards) {
            if (card.getCardNumber() > 0 && !card.getSetCode().isEmpty()) {
                CardDownloadData url = new CardDownloadData(card.getName(), card.getSetCode(), card.getCardNumber(), card.usesVariousArt(), 0, "", false, card.isDoubleFaced(), card.isNightCard());
                file = new TFile(CardImageUtils.generateImagePath(url));
                if (!file.exists()) {
                    return true;
                }
            }
        }       
        return false;
View Full Code Here

            allCardsUrls.addAll(getTokenCardUrls());
        } catch (Exception e) {
            log.error(e);
        }

        TFile file;

        /**
         * check to see which cards we already have
         */
        for (CardDownloadData card : allCardsUrls) {
            file = new TFile(CardImageUtils.generateImagePath(card));
            if (!file.exists()) {
                cardsToDownload.add(card);
            }
        }

        for (CardDownloadData card : cardsToDownload) {
View Full Code Here

                    card, count, mb));
        } else {
            Iterator<CardDownloadData> cardsIterator = DownloadPictures.this.cards.iterator();
            while (cardsIterator.hasNext()) {
                CardDownloadData cardDownloadData = cardsIterator.next();
                TFile file = new TFile(CardImageUtils.generateImagePath(cardDownloadData));
                if (file.exists()) {
                    cardsIterator.remove();
                }
            }
            count = DownloadPictures.this.cards.size();
View Full Code Here

                StringBuilder filePath = new StringBuilder();
                filePath.append(Constants.IO.imageBaseDir).append(File.separator);
                filePath.append(card.hashCode()).append(".").append(card.getName().replace(":", "").replace("//", "-")).append(".jpg");
                File temporaryFile = new File(filePath.toString());
                String imagePath = CardImageUtils.generateImagePath(card);
                TFile outputFile = new TFile(imagePath);
                if (!outputFile.exists()) {
                    outputFile.getParentFile().mkdirs();
                }
                File existingFile = new File(imagePath.replaceFirst("\\w{3}.zip", ""));
                if (existingFile.exists()) {
                    new TFile(existingFile).cp_rp(outputFile);
                    synchronized (sync) {
                        update(cardIndex + 1, count);
                    }
                    existingFile.delete();
                    File parent = existingFile.getParentFile();
                    if (parent != null && parent.isDirectory() && parent.list().length == 0) {
                        parent.delete();
                    }
                    return;
                }
                BufferedOutputStream out;

                // Logger.getLogger(this.getClass()).info(url.toString());
                URLConnection httpConn = url.openConnection(p);
                httpConn.connect();
                if (((HttpURLConnection) httpConn).getResponseCode() == 200) {
                    try (BufferedInputStream in = new BufferedInputStream(((HttpURLConnection) httpConn).getInputStream())) {
                        //try (BufferedInputStream in = new BufferedInputStream(url.openConnection(p).getInputStream())) {
                        out = new BufferedOutputStream(new TFileOutputStream(temporaryFile));
                        byte[] buf = new byte[1024];
                        int len;
                        while ((len = in.read(buf)) != -1) {
                            // user cancelled
                            if (cancel) {
                                in.close();
                                out.flush();
                                out.close();
                                temporaryFile.delete();
                                return;
                            }
                            out.write(buf, 0, len);
                        }

                    }
                    out.flush();
                    out.close();

                    if (card.isTwoFacedCard()) {
                        BufferedImage image = ImageIO.read(temporaryFile);
                        if (image.getHeight() == 470) {
                            BufferedImage renderedImage = new BufferedImage(265, 370, BufferedImage.TYPE_INT_RGB);
                            renderedImage.getGraphics();
                            Graphics2D graphics2D = renderedImage.createGraphics();
                            if (card.isTwoFacedCard() && card.isSecondSide()) {
                                graphics2D.drawImage(image, 0, 0, 265, 370, 313, 62, 578, 432, null);
                            } else {
                                graphics2D.drawImage(image, 0, 0, 265, 370, 41, 62, 306, 432, null);
                            }
                            graphics2D.dispose();
                            writeImageToFile(renderedImage, outputFile);
                        } else {
                            new TFile(temporaryFile).cp_rp(outputFile);
                        }
                        temporaryFile.delete();
                    } else {
                        new TFile(temporaryFile).cp_rp(outputFile);
                        temporaryFile.delete();
                    }
                } else {
                    Logger.getLogger(this.getClass()).error(convertStreamToString(((HttpURLConnection) httpConn).getErrorStream()));
                }
View Full Code Here

TOP

Related Classes of net.java.truevfs.access.TFile

Copyright © 2018 www.massapicom. 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.