⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jsee.java

📁 java写的图片浏览器,类似acds
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
package org.net9.oops.jsee;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.io.*;
//import java.util.*;
//import javax.swing.border.*;
import java.net.*;

/**
* Jsee is a simple application to view .JPG, .GIF and .BMP image files
* Current features:
* <ul>
* <li> Simple list file browser
* <li> Full screen mode
* <li> Different display mode
* </ul>
* <p>
* bla bla bla bla
* blo blo blo blo
* @author	Tran To Huu Tri
* @version 	%I%, %G%
* @since	JDK 1.2 (or later)
*/
public class Jsee extends JFrame
{
    double scale;  // the display width/height scale to determine the max display for width or height
    JSplitPane Spane, smallSplitPane;
    int res_height, res_width;    // resolution height and width

    // final int MenuBarHeight = 0;
    String JseeVersion = "Jsee 1.0.0";
    // File menu section
    JMenuBar  jMenuBar;
    JMenu     jFileMenu,
              jViewMenu,
              jHelpMenu;
    //Added by Neoya 2002-03-12
    JMenu     jShowColumnsMenu;
    JCheckBoxMenuItem
              jShowSizeItem,
              jShowModifiedItem,
              jShowTypeItem,
              jShowPropertyItem;

    JMenuItem jExitItem,
              jAboutItem,
              jOptionItem;

    JFrame    jViewer;
    JScrollPane jViewerSP;
    boolean   ThumbNailIsShowing = false,
              ViewFullScreen = false,
              OptionsChanged = false,
              FileRenamed = false,
              slideShowForward = true;

    boolean PreviewAreaIsHiding = false;
    public int slideShowDelayTime = 2; // 2 seconds

    JCheckBoxMenuItem jThumbNailItem;
    // end File menu

    FileListView FileListScrollPane;
    FileSystemModel model; // model of tree view
    FileSystemTreeScrollPane fileTree; // tree view scroll panel

    ThumbLabel  thumblabel;
    Thread      thumb_thread;
    PreviewScrollPane imageScrollPane;

    //Add by Neoya 2002-03-12
    Properties properties;
    //Used to save the divider location when hide preview in thumbnail mode
    int dividerLocation;
    int smallDividerLocation;
    //View types
    final int VIEW_TYPE_LIST=1;
    final int VIEW_TYPE_THUMB=2;
    //refer to FileListScrollPane or thumbLabel to change the view type
    JScrollPane fileListOrThumbLabel;
    //End of added by Neoya

    FullScreenWindow fsw;
    ViewerWindow vw;
    JScrollPane iViewerSrollPane;

    StatusBarPanel statusBar;

    OptionsDialog optionsDialog;
    String  currentDir = "\0",
            thumbDir = "\0",
            osName;

    int Preview_Area_Width,
        Preview_Area_Height;

    int Last_Divider_Position = 0;

    int thumb_width = 120/*80 min*/,
        thumb_height = 90+17/*70 min*/,
        image_thumb_height;

    public int resize_quality = 1;    // predefine the resize quality to default

    ImageIcon image, originalImage;

    // tool bar
    ToolBarButton viewButton,
                  GoUpToolButton,
                  ViewFullScreenButton,
                  DeleteButton,
                  RefreshButton;

    ImageIcon thumbNailIcon,
              listIcon;

    public boolean //image_change = false,
            Save_Previous_Option = false,
            Hide_Preview_in_ThumbNail_Mode = false;

    private boolean Auto_Size = true;
    private boolean CheckOnce = true;

    File    file,
            parentDir;
    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    JPopupMenu menu;
    ProgressWindow progress;

    int progressValue = 1;
    int progressScale = 10;

    int currentSelectedFile = 0;

    int OS; // Windows = 0; Linux/Unix/MacX = 1;

    class ToolBarButton extends JButton
    {
        public ToolBarButton(Action a)
        {
            super((Icon)a.getValue(Action.SMALL_ICON));
            String toolTip = (String)a.getValue(Action.SHORT_DESCRIPTION);
            if (toolTip == null)
                toolTip = (String)a.getValue(Action.NAME);
            if (toolTip != null)
                setToolTipText(toolTip);
            addActionListener(a);
        }
    }

    protected class TreeListener implements TreeSelectionListener {
        Jsee pf;
        public TreeListener( Jsee parentFrame ) {
          pf = parentFrame;
        }
        public void valueChanged( TreeSelectionEvent e ) {
            File fileSysEntity = (File)e.getPath().getLastPathComponent();
            pf.FileListScrollPane.RefreshFileList( fileSysEntity );
            if (pf.ThumbNailIsShowing) {
                pf.ChangeThumbNailDirectory(pf.FileListScrollPane.getFileList());
                thumbDir = fileSysEntity.toString();
            }
        }
    }

    public Jsee(){
    // Get the Java Virtual Machine version
/** comment this part for older jre */
    char versionNo = System.getProperty("java.version", ".").charAt(2);
    if (versionNo < '3') {
        JOptionPane.showMessageDialog(null, "You are using old jre, please use Jre 1.3 or \n go to JCDSee home page (www.jcdsee.com) \n to optain the version that work with older jre.");
        System.exit(0);
    }
/** end */
        // do progress splash screen
        progress = new ProgressWindow(this, JseeVersion);

        res_height = (int)d.getHeight();
        res_width = (int)d.getWidth();

        scale = (res_width-125) / (res_height-25);

        setSize(res_width,res_height);
        setForeground(Color.black);
        setBackground(Color.lightGray);
        setFont(new Font("Courier",Font.BOLD,12));
        setTitle("Jsee");

        model = new FileSystemModel();
        fileTree = new FileSystemTreeScrollPane( model );

        progress.setValue( (progressValue++) * progressScale );
        // option dialog section
        optionsDialog = new OptionsDialog(this);

        progress.setValue((progressValue++) * progressScale);

        progress.setValue((progressValue++) * progressScale);

        osName = System.getProperty("os.name",".");

        if ( osName.startsWith("Windows") ) /* Win32 */
            OS = 0;
        else // hopefully Unix for the moment
            OS = 1;
        //Modified by Neoya 2002-03-06
        //if (optionsDialog.Save_Previous_Option)
        //{
            currentDir = optionsDialog.getDefaultPath();
            if (currentDir == null)
                currentDir = System.getProperty( "user.home" );
            Auto_Size = optionsDialog.Auto_Size_Preview;
            resize_quality = optionsDialog.scale_quality;
            file = new File(currentDir);
            if (!file.exists() || !file.isDirectory()) {
                file = AssignStartupFile();
                currentDir = file.toString();
            }
            thumb_width = OptionsDialog.GetPreviewWidth();
            // 17 is the static height of thumb's filename title
            thumb_height = OptionsDialog.GetPreviewHeight() + 17;
        //}
        //else
        //{
        //    file = AssignStartupFile();
        //}
        //End of modified by Neoya
        parentDir = file.getParentFile();

        progress.setValue((progressValue++) * progressScale);

        FileListScrollPane = new FileListView(file, this);

        thumblabel = new ThumbLabel(FileListScrollPane.getFileList(),
                                        thumb_width,
                                        thumb_height,
                                        this,
                                        1);
        //Added by Neoya ,set the default view to FileListScrollPane ,NOT thumblabel
        fileListOrThumbLabel=FileListScrollPane;
        thumb_thread = new Thread(thumblabel);

        fileTree.getTree().addTreeSelectionListener( new TreeListener( this ) );

        progress.setValue((progressValue++) * progressScale);

    // Preview area
        imageScrollPane = new PreviewScrollPane(this);
        imageScrollPane.Load_Image(FileListScrollPane.getSelectedFile());
    // end preview area

        //Modified by Neoya 2002-03-05
        properties=new Properties();
        this.ChangeColumnLayout(properties.getIntProperty(Properties.COLUMN_LAYOUT));
        // End of Modified by Neoya

        progress.setValue((progressValue++) * progressScale);

        addWindowListener(new WindowAdapter(){
            public void windowClosing(WindowEvent e){
                Quit();
            }
        });
/*
        addKeyListener( new KeyAdapter() {
            public void keyReleased( KeyEvent e ) {
                if ( e.getKeyCode() == KeyEvent.VK_ESCAPE )
                {
                    if ( aboutbox.isShowing() )
                        aboutbox.dispose();
                }
                /* Do no delete. This feature is need.
                else if ( e.getKeyCode() == KeyEvent.VK_LEFT )
                {
                    if (  ThumbNailIsShowing )
                        thumblabel.SelectNextThumb(-1);
                }
                else if ( e.getKeyCode() == KeyEvent.VK_RIGHT )
                {
                    if ( ThumbNailIsShowing )
                        thumblabel.SelectNextThumb(+1);
                }
                else if ( e.getKeyCode() == KeyEvent.VK_DOWN )
                {
                    if ( ThumbNailIsShowing )
                        thumblabel.SelectNextThumb(+thumblabel.getNumberOfThumbsOnRow());
                }
                else if ( e.getKeyCode() == KeyEvent.VK_UP )
                {
                    if ( ThumbNailIsShowing )
                        thumblabel.SelectNextThumb(-thumblabel.getNumberOfThumbsOnRow());
                }
            }
        });
*/
        // menu section
        menu = new JPopupMenu();
        menu.setBackground(Color.lightGray);

        final JCheckBoxMenuItem thumbNail_item = new JCheckBoxMenuItem("Thumb Nail", ThumbNailIsShowing);
        thumbNail_item.setBackground(Color.lightGray);
        final JMenuItem exit_item = new JMenuItem("Exit");
        exit_item.setBackground(Color.lightGray);
        final JMenuItem about_item = new JMenuItem("About Jsee");
        about_item.setBackground(Color.lightGray);
        final JMenuItem option_item = new JMenuItem("Options");
        option_item.setBackground(Color.lightGray);

        final JCheckBoxMenuItem fullSize_item = new JCheckBoxMenuItem("Full Size", !Auto_Size);
        fullSize_item.setBackground(Color.lightGray);
        final JCheckBoxMenuItem autoSize_item = new JCheckBoxMenuItem("Auto Size", Auto_Size);
        autoSize_item.setBackground(Color.lightGray);

        final JSeparator jSeparator1 = new javax.swing.JSeparator ();
        final JSeparator jSeparator2 = new javax.swing.JSeparator ();

        progress.setValue((progressValue++) * progressScale);

        thumbNail_item.addActionListener(
            new ActionListener() {
                public void actionPerformed( ActionEvent event ) {
                    if ( !thumbNail_item.getState() )
                    {
                        DisplayFileList();
                        ThumbNailIsShowing = false;
                        jThumbNailItem.setSelected(false);
                        viewButton.setIcon(thumbNailIcon);
                    }
                    else {
                        DisplayThumbNail();
                        ThumbNailIsShowing = true;
                        jThumbNailItem.setSelected(true);
                        thumbNail_item.setSelected(true);
                        viewButton.setIcon(listIcon);
                    }
                }
            }
        );

        fullSize_item.addActionListener(
            new ActionListener() {
                public void actionPerformed( ActionEvent event ) {
                    if ( !fullSize_item.getState() )
                    {
                        autoSize_item.setSelected(true);
                        Auto_Size = true;
                    }
                    else
                    {
                        autoSize_item.setSelected(false);
                        Auto_Size = false;
                    }
                }
            }
        );

        autoSize_item.addActionListener(
            new ActionListener() {
                public void actionPerformed( ActionEvent event ) {
                    if ( !autoSize_item.getState() )
                    {
                        fullSize_item.setSelected(true);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -