Package com.lightcrafts.ui.browser.model

Examples of com.lightcrafts.ui.browser.model.ImageDatum


        for (int i=indices.length-1; i>=0; i--) {
            int index = indices[i];
            if (index < 0) {
                continue;
            }
            ImageDatum datum = datums.get(index);
            if (datum == null) {
                // A race; the image disappeared during painting.
                continue;
            }
            RenderedImage image = datum.getImage(this);

            // This queue prevents GC of recently painted images:
            recentImages.add(image);

            Rectangle rect = getBounds(index);
            g.setClip(clip.intersection(rect));

            // If this ImageDatum is a member of a nontrivial ImageGroup,
            // then render a background highlight.
            if (isGroupStart(datums, index)) {
                // paint the start-group
                Shape highlight = new RoundRectangle2D.Double(
                    rect.x + 4, rect.y + 4,
                    2 * rect.width - 8, rect.height - 8,
                    rect.width / 8, rect.height / 8
                );
                g.fill(highlight);
            }
            else if (isGroupEnd(datums, index)) {
                // paint the end-group
                Shape highlight = new RoundRectangle2D.Double(
                    rect.x - rect.width + 4, rect.y + 4,
                    2 * rect.width - 8, rect.height - 8,
                    rect.width / 8, rect.height / 8
                );
                g.fill(highlight);
            }
            else if (datum.getGroup().isNonTrivial()) {
                // paint the mid-group
                Shape highlight = new Rectangle(
                    rect.x, rect.y + 4, rect.width, rect.height - 8
                );
                g.fill(highlight);
            }
            File file = datum.getFile();
            String label = file.getName();
            ImageDatumType type = datum.getType();
            String tag = type.toString();
            ImageMetadata meta = datum.getMetadata(true);
            int rating = meta.getRating();
            boolean selected = selection.isSelected(datum);
            renderer.paint(g, image, label, tag, rating, rect, selected);
        }
        g.setColor(oldColor);
View Full Code Here


    ArrayList<ImageDatum> getAllImageData() {
        return list.getAllImageData();
    }

    private boolean isGroupStart(List<ImageDatum> datums, int index) {
        ImageDatum datum = datums.get(index);
        ImageGroup group = datum.getGroup();

        if (! group.isNonTrivial()) {
            return false;
        }
        if (index == 0) {
            return true;
        }
        ImageDatum prev = datums.get(index - 1);
        return group != prev.getGroup();
    }
View Full Code Here

        ImageDatum prev = datums.get(index - 1);
        return group != prev.getGroup();
    }

    private boolean isGroupEnd(List<ImageDatum> datums, int index) {
        ImageDatum datum = datums.get(index);
        ImageGroup group = datum.getGroup();

        if (! group.isNonTrivial()) {
            return false;
        }
        if (index == datums.size() - 1) {
            return true;
        }
        ImageDatum next = datums.get(index + 1);
        return group != next.getGroup();
    }
View Full Code Here

                browser.repaint(starsRect);
            }
        }
        // Handle clicks on the rotate affordances
        if (event.getID() == MouseEvent.MOUSE_PRESSED) {
            ImageDatum datum = browser.getImageDatum(index);

            // Figure out which affordance, and update the datum.
            Point p = event.getPoint();

            Rectangle leftRect = getRotateLeftRect();
View Full Code Here

                browser.repaint(newRect);
            }
            index = newIndex;
            isEnabled = true;
            if (index >= 0) {
                ImageDatum datum = browser.getImageDatum(index);
                if (datum != null) {
                    Rectangle rect = getRect();
                    stars.setup(datum, rect);
                    if (datum.getType().hasLznData()) {
                        isEnabled = false;
                    }
                }
            }
        }
View Full Code Here

            controller.handleEvent(event);
        }
        else if (event.getClickCount() == 2) {
            Point p = event.getPoint();
            int index = browser.getIndex(p);
            ImageDatum datum = browser.getImageDatum(index);
            if (datum != null) {
                browser.notifyDoubleClicked(datum);
            }
        }
    }
View Full Code Here

            int index = browser.getIndex(p);
            if (index < 0) {
                selection.clearSelected();
                return;
            }
            ImageDatum datum = browser.getImageDatum(index);

            // Scroll that ImageDatum's thumbnail into full view:
            Rectangle bounds = browser.getBounds(index);
            browser.scrollRectToVisible(bounds);
View Full Code Here

        boolean isBasic = ApplicationMode.isBasicMode();

        editAction = new LeadSelectionAction("EditMenuItem", browser, true) {
            public void actionPerformed(ActionEvent event) {
                ImageDatum lead = getLeadDatum();
                browser.notifyDoubleClicked(lead);
            }
        };
        copyAction = new LeadSelectionAction(
            "CopyMenuItem", browser, ! isBasic
        ) {
            public void actionPerformed(ActionEvent event) {
                ImageDatum datum = getLeadDatum();
                TemplateClipboard = datum.getFile();
            }
            void update() {
                super.update();
                if (isEnabled()) {
                    ImageDatum lead = getLeadDatum();
                    ImageDatumType type = lead.getType();
                    boolean hasLzn = type.hasLznData();
                    copyAction.setEnabled(hasLzn);
                }
            }
        };
        pasteAction = new SelectionAction(
            LOCALE.get("PasteMenuItem"), browser, null, true, ! isBasic
        ) {
            public void actionPerformed(ActionEvent event) {
                List<ImageDatum> selection = getSelection();
                List<File> files = new ArrayList<File>();
                for (ImageDatum datum : selection) {
                    File file = datum.getFile();
                    files.add(file);
                }
                TemplateProvider templates = browser.getTemplateProvider();
                templates.applyTemplate(
                    TemplateClipboard, files.toArray(new File[0])
                );
            }
            void update() {
                super.update();
                if (isEnabled()) {
                    TemplateProvider templates = browser.getTemplateProvider();
                    List<ImageDatum> selection = getSelection();
                    boolean hasTemplates = (templates != null);
                    boolean hasSelection = ! selection.isEmpty();
                    boolean hasClipboard = (TemplateClipboard != null);
                    setEnabled(hasTemplates && hasSelection && hasClipboard);
                }
            }
        };
        refreshAction = new SelectionAction(
            LOCALE.get("RefreshMenuItem"), browser, null, true, true
        ) {
            public void actionPerformed(ActionEvent e) {
                List<ImageDatum> selection = getSelection();
                for (ImageDatum datum : selection) {
                    datum.refresh(false);   // don't use caches
                }
            }
        };
        ratingActions =
            RatingActions.createRatingActions(browser, true);
//        ratingAdvanceActions =
//            RatingActions.createRatingAdvanceActions(browser, true);
        clearRatingAction =
            RatingActions.createClearRatingAction(browser, true);
//        clearRatingAdvanceAction =
//            RatingActions.createClearRatingAdvanceAction(browser, true);

        leftAction = RotateActions.createRotateLeftAction(browser, true);
        rightAction = RotateActions.createRotateRightAction(browser, true);

        renameAction = new LeadSelectionAction(
            "RenameMenuItem", browser, ! isBasic
        ) {
            public void actionPerformed(ActionEvent event) {
                ImageDatum datum = browser.getLeadSelectedDatum();
                FileActions.renameFile(
                    datum.getFile(), browser
                );
            }
        };
        selectLatestAction = new AbstractAction(
            LOCALE.get("SelectLatestActionName")
        ) {
            public void actionPerformed(ActionEvent event) {
                browser.selectLatest();
            }
        };
        selectLatestAction.setEnabled(! ApplicationMode.isBasicMode());

        selectAllAction = new AbstractAction(
            LOCALE.get("SelectAllActionName")
        ) {
            public void actionPerformed(ActionEvent event) {
                browser.selectAll();
            }
        };
        selectAllAction.setEnabled(! ApplicationMode.isBasicMode());

        // This accelerator key setup should be localized and maybe unified
        // with the centralized menu configuration in MenuFactory.
        String modifier =
            Platform.getType() == Platform.MacOSX ? "meta" : "ctrl";
        selectAllAction.putValue(
            Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(
                modifier + " " + "A"
            )
        );
        selectNoneAction = new SelectionAction(
            LOCALE.get("SelectNoneActionName"), browser, null, true, true
        ) {
            public void actionPerformed(ActionEvent e) {
                browser.clearSelection();
            }
        };
        showHideTypesAction = new ToggleAction(
            LOCALE.get("HideImageTypeMenuItem"),
            LOCALE.get("ShowImageTypeMenuItem")
        ) {
            protected void onActionPerformed(ActionEvent event) {
                ImageDatumRenderer.setShowImageTypes(true);
                browser.repaint();
            }
            protected void offActionPerformed(ActionEvent event) {
                ImageDatumRenderer.setShowImageTypes(false);
                browser.repaint();
            }
        };
        showHideTypesAction.setState(ImageDatumRenderer.doesShowImageTypes());

        // The trash action does get a key binding, defined in
        // AbstractImageBrowser instead of here.
        trashAction = new SelectionAction(
            LOCALE.get("TrashMenuItem"), browser, null, true, ! isBasic
        ) {
            public void actionPerformed(ActionEvent event) {
                List<ImageDatum> datums = browser.getSelectedDatums();
                List<File> files = new ArrayList<File>();
                for (ImageDatum datum : datums) {
                    File file = datum.getFile();
                    files.add(file);
                }
                FileActions.deleteFiles(files.toArray(new File[0]), browser);
            }
        };
        showAction = new SelectionAction(
            LOCALE.get("ShowMenuItem"), browser, null, true, true
        ) {
            public void actionPerformed(ActionEvent event) {
                List<ImageDatum> datums = browser.getSelectedDatums();
                List<File> files = new ArrayList<File>();
                for (ImageDatum datum : datums) {
                    File file = datum.getFile();
                    files.add(file);
                }
                Platform platform = Platform.getPlatform();
                for (File file : files) {
                    file = FileUtil.resolveAliasFile(file);
View Full Code Here

        for (int i=indices.length-1; i>=0; i--) {
            int index = indices[i];
            if (index < 0) {
                continue;
            }
            ImageDatum datum = datums.get(index);
            if (datum == null) {
                // A race; the image disappeared during painting.
                continue;
            }
            RenderedImage image = datum.getImage(this);

            // This queue prevents GC of recently painted images:
            recentImages.add(image);

            Rectangle rect = getBounds(index);
            g.setClip(clip.intersection(rect));

            File file = datum.getFile();
            String label = file.getName();
            ImageDatumType type = datum.getType();
            String tag = type.toString();
            ImageMetadata meta = datum.getMetadata(true);
            int rating = meta.getRating();
            boolean selected = selection.isSelected(datum);
            renderer.paint(g, image, label, tag, rating, rect, selected);

            ImageGroup group = datum.getGroup();
            if (group.isNonTrivial()) {
                ImageGroupCountRenderer.paint(g, rect, datum);
            }
        }
        g.setClip(clip);
View Full Code Here

        Set<ImageDatum> recentDatums = new LinkedHashSet<ImageDatum>();
        for (ImageDatum datum : allDatums) {
            ImageGroup group = datum.getGroup();
            List<ImageDatum> members = group.getImageDatums();
            long lastTime = 0;
            ImageDatum lastMember = null;
            for (ImageDatum member : members) {
                File file = member.getFile();
                long modTime = file.lastModified();
                if (modTime > lastTime) {
                    lastMember = member;
View Full Code Here

TOP

Related Classes of com.lightcrafts.ui.browser.model.ImageDatum

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.