Example usage for java.awt.event KeyEvent VK_5

List of usage examples for java.awt.event KeyEvent VK_5

Introduction

In this page you can find the example usage for java.awt.event KeyEvent VK_5.

Prototype

int VK_5

To view the source code for java.awt.event KeyEvent VK_5.

Click Source Link

Document

Constant for the "5" key.

Usage

From source file:org.photovault.swingui.PhotoViewController.java

/** Creates a new instance of PhotoViewController */
public PhotoViewController(Container view, AbstractController parentController) {
    super(view, parentController);
    photoDAO = getDAOFactory().getPhotoInfoDAO();
    folderDAO = getDAOFactory().getPhotoFolderDAO();
    ImageIcon rotateCWIcon = getIcon("rotate_cw.png");
    ImageIcon rotateCCWIcon = getIcon("rotate_ccw.png");
    ImageIcon rotate180DegIcon = getIcon("rotate_180.png");

    registerAction("rotate_cw", new RotateSelectedPhotoAction(this, 90, "Rotate CW", rotateCWIcon,
            "Rotates the selected photo 90 degrees clockwise", KeyEvent.VK_R));
    registerAction("rotate_ccw", new RotateSelectedPhotoAction(this, 270, "Rotate CCW", rotateCCWIcon,
            "Rotates the selected photo 90 degrees counterclockwise", KeyEvent.VK_L));
    registerAction("rotate_180", new RotateSelectedPhotoAction(this, 180, "Rotate 180 degrees",
            rotate180DegIcon, "Rotates the selected photo 180 degrees counterclockwise", KeyEvent.VK_T));
    registerAction("rotate_180", new RotateSelectedPhotoAction(this, 180, "Rotate 180 degrees",
            rotate180DegIcon, "Rotates the selected photo 180 degrees counterclockwise", KeyEvent.VK_T));
    String qualityStrings[] = { "Unevaluated", "Top", "Good", "OK", "Poor", "Unusable" };
    String qualityIconnames[] = { "quality_unevaluated.png", "quality_top.png", "quality_good.png",
            "quality_ok.png", "quality_poor.png", "quality_unusable.png" };
    KeyStroke qualityAccelerators[] = { null,
            KeyStroke.getKeyStroke(KeyEvent.VK_5, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()),
            KeyStroke.getKeyStroke(KeyEvent.VK_4, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()),
            KeyStroke.getKeyStroke(KeyEvent.VK_3, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()),
            KeyStroke.getKeyStroke(KeyEvent.VK_2, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()),
            KeyStroke.getKeyStroke(KeyEvent.VK_1, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), };
    ImageIcon[] qualityIcons = new ImageIcon[qualityStrings.length];
    for (int n = 0; n < qualityStrings.length; n++) {
        qualityIcons[n] = getIcon(qualityIconnames[n]);
        DataAccessAction qualityAction = new SetPhotoQualityAction(this, n, qualityStrings[n], qualityIcons[n],
                "Set quality of selected phots to \"" + qualityStrings[n] + "\"", null);
        qualityAction.putValue(AbstractAction.ACCELERATOR_KEY, qualityAccelerators[n]);
        registerAction("quality_" + n, qualityAction);

        registerEventListener(TaskFinishedEvent.class, new DefaultEventListener<BackgroundTask>() {

            public void handleEvent(DefaultEvent<BackgroundTask> event) {
                BackgroundTask task = event.getPayload();
                if (task instanceof IndexFileTask) {
                    IndexFileTask ifTask = (IndexFileTask) task;
                    if (ifTask.getResult() == IndexingResult.ERROR
                            || ifTask.getResult() == IndexingResult.NOT_IMAGE) {
                        return;
                    }/*  w  w  w . ja  va  2 s . c om*/
                    UUID volId = ifTask.getVolume().getId();
                    FileLocation loc = ifTask.getFileLocation();
                    Set<PhotoInfo> photos = ifTask.getPhotosFound();
                    log.debug("Found file " + loc.getFile() + " in volume " + volId);
                    for (PhotoInfo p : photos) {
                        log.debug("   linked to photo " + p.getUuid());
                    }
                    if (collection instanceof ExtDirPhotos) {
                        ExtDirPhotos dir = (ExtDirPhotos) collection;
                        if (loc.getVolume().getId().equals(dir.getVolId())
                                && loc.getDirName().equals(dir.getDirPath())) {
                            addPhotos(photos);
                            updateThumbView();
                        }
                    }
                }
            }
        });
    }

    // Create the UI controls
    thumbPane = new PhotoCollectionThumbView(this, null);
    thumbPane.addSelectionChangeListener(new SelectionChangeListener() {

        public void selectionChanged(SelectionChangeEvent e) {
            thumbSelectionChanged(e);
        }
    });
    previewPane = new JAIPhotoViewer(this);
    previewPane.getActionMap().put("hide_fullwindow_preview", new HidePhotoPreviewAction(this));
    previewPane.getActionMap().put("move_next", thumbPane.getSelectNextAction());
    previewPane.getActionMap().put("move_prev", thumbPane.getSelectPreviousAction());

    // Create the split pane to display both of these components

    thumbScroll = new JScrollPane(thumbPane);
    thumbPane.setBackground(Color.WHITE);
    thumbScroll.getViewport().setBackground(Color.WHITE);
    thumbScroll.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent e) {
            handleThumbAreaResize();
        }
    });

    scrollLayer = new JXLayer<JScrollPane>(thumbScroll);
    progressLayer = new ProgressIndicatorLayer();
    scrollLayer.setUI(progressLayer);

    collectionPane = new JPanel();
    splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    layeredPane = new JLayeredPane();
    layeredPane.setLayout(new StackLayout());
    collectionPane.add(splitPane);
    collectionPane.add(layeredPane);
    GridBagLayout layout = new GridBagLayout();
    collectionPane.setLayout(layout);

    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.weighty = 1.0;
    c.weightx = 1.0;
    c.gridy = 0;
    // collectionPane.add( scrollLayer );
    layout.setConstraints(splitPane, c);
    layout.setConstraints(layeredPane, c);
    //        collectionPane.add( previewPane );
    thumbPane.setRowHeight(200);
    setLayout(Layout.ONLY_THUMBS);

    /*
    Register action so that we are notified of changes to currently
    displayed folder
     */
    registerEventListener(CommandExecutedEvent.class, new DefaultEventListener<DataAccessCommand>() {

        public void handleEvent(DefaultEvent<DataAccessCommand> event) {
            DataAccessCommand cmd = event.getPayload();
            if (cmd instanceof ChangePhotoInfoCommand) {
                photoChangeCommandExecuted((ChangePhotoInfoCommand) cmd);
            } else if (cmd instanceof CreateCopyImageCommand) {
                imageCreated((CreateCopyImageCommand) cmd);
            } else if (cmd instanceof ApplyChangeCommand) {
                changeApplied((ApplyChangeCommand) cmd);
            }
        }
    });
}