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

📄 jsee.java

📁 java写的图片浏览器,类似acds
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
        this.hide();
      }
    }

    public synchronized void DisplayFileList()
    {
        thumblabel.Stop();
        /* Modified by Neoya
        int divLocation = smallSplitPane.getDividerLocation();
        smallSplitPane.remove(thumblabel);
        if (FileRenamed)
            FileListScrollPane.RefreshFileList(new File(currentDir));
        smallSplitPane.setRightComponent(FileListScrollPane);
        smallSplitPane.setDividerLocation(divLocation);
        getContentPane().repaint();
        */
        if (FileRenamed)
            FileListScrollPane.RefreshFileList(new File(currentDir));
        this.changeViewType(this.VIEW_TYPE_LIST);
    }

    public void ChangeThumbNailDirectory(File[] thumblist) {
        thumblabel.DisplayImages(thumblist);
        //int divLocation = smallSplitPane.getDividerLocation();
        if (thumb_thread.isAlive()) {
            thumb_thread.stop();
            thumb_thread = new Thread(thumblabel);
            thumb_thread.start();
        } else {
            thumb_thread = new Thread(thumblabel);
            thumb_thread.start();
        }
        /*
        smallSplitPane.setRightComponent(thumblabel);
        smallSplitPane.setDividerLocation(divLocation);
        getContentPane().repaint();
        */
        this.changeViewType(this.VIEW_TYPE_THUMB);
    }

    public void ChangeThumbNailDirectory(String imageFullFileName) {
        FileListScrollPane.RefreshFileList(new File(imageFullFileName));
        ChangeThumbNailDirectory(FileListScrollPane.getFileList());
        thumbDir = imageFullFileName;
    }

    public void DisplayThumbNail()
    {
        //int divLocation = smallSplitPane.getDividerLocation();
        thumblabel.Go();
        if (!thumbDir.equals(FileListScrollPane.currentDir) || FileRenamed) {
          // Put thumb nail on list area
          // Resize the left pane of split view
          thumblabel.DisplayImages(FileListScrollPane.getFileList());
          Thread t = new Thread(thumblabel);
          t.start();
          //smallSplitPane.remove(FileListScrollPane);
          thumbDir = currentDir;
        } //end if
        /*
        smallSplitPane.setRightComponent(thumblabel);
        smallSplitPane.setDividerLocation(divLocation);
        if (optionsDialog.getHidePreview())
        {
          Spane.remove(2);
        }
        */
        this.changeViewType(this.VIEW_TYPE_THUMB);
    }

    public ImageIcon Load_Image(String filename) {
      if (filename==null || filename.equals(""))
        return null;
      ImageIcon image = new ImageIcon();
      String lowerFileName = "";
/* testing */
if (CheckOnce) {
  CheckOnce = false;
  File f = new File(filename);
  if (!f.isDirectory()) {
      image = new ImageIcon(filename);
      if (image.getIconHeight() < 0) {
        try {
          if (filename.toLowerCase().endsWith(".xpm")) {
              FileInputStream file      = new FileInputStream (filename);
              DataInputStream in     = new DataInputStream (file);
              byte[] buff = new byte[in.available ()];

              int i = file.read(buff);
              String s = new String(buff);
              image = new ImageIcon(Xpm.XpmToImage(s));
          }
            else if (filename.toLowerCase().endsWith(".bmp")) {
              try {
                  URL url = (new File(filename)).toURL();
                  image = new ImageIcon(createImage(BMPReader.getBMPImage(url.openStream())));
              } catch ( MalformedURLException e ) {System.out.println("File or URL exception");}
                catch (IOException e) {}
          } else
              image = new ImageIcon(PcxReader102V01.loadImage(new FileInputStream(filename)));
        } catch (FileNotFoundException fnfe) {System.out.println("FileNotFoundException or access denied");}
          catch (NullPointerException npe) {}
          catch(IOException e) {}
          if (image.getIconHeight() < 0)
            return new ImageIcon();
          else
            return image;
        } // end if
    } // end if
    return new ImageIcon();
} else {
    image = new ImageIcon(filename);
    if (image.getIconHeight() < 0) {
        try {
          if (filename.toLowerCase().endsWith(".xpm")) {
              FileInputStream file      = new FileInputStream (filename);
              DataInputStream in     = new DataInputStream (file);
              byte[] buff = new byte[in.available ()];

              int i = file.read(buff);
              String s = new String(buff);
              image = new ImageIcon(Xpm.XpmToImage(s));
          }
          else if (filename.toLowerCase().endsWith(".bmp")) {
              try {
                  URL url = (new File(filename)).toURL();
                  image = new ImageIcon(createImage(BMPReader.getBMPImage(url.openStream())));
              } catch ( MalformedURLException e ) {System.out.println("File or URL exception");}
                catch (IOException e) {}
          } else
              image = new ImageIcon(PcxReader102V01.loadImage(new FileInputStream(filename)));
        } catch (FileNotFoundException fnfe) {System.out.println("FileNotFoundException or access denied");}
          catch (NullPointerException npe) {}
          catch(IOException e) {}
        if (image.getIconHeight() < 0) {
          return new ImageIcon();
        }
      } // end if
      return image;
    }
    } // end Load_Image

    public static void main(String[] args){
        (new Jsee()).show();
    }

    public void SetTitle() {
      setTitle( "Jsee - " + currentDir );
    }

    public File AssignStartupFile() {
        if ( osName.startsWith("Windows") ) /* Win32 */
        {
            OS = 0;
            return new File("C:\\");
        }
        else // hopefully Unix for the moment
            return new File("/");
    }

    public void setEnableGoUpButton(boolean enable) {
        GoUpToolButton.setEnabled(enable);
    }

    public void setEnableViewButton(boolean enable) {
        ViewFullScreenButton.setEnabled(enable);
    }

    public void setEnableDeleteButton(boolean enable) {
        DeleteButton.setEnabled(enable);
    }

    public boolean getGoUpButtonState() {
        return GoUpToolButton.isEnabled();
    }

    public void HidePreview(boolean hide) {
      Hide_Preview_in_ThumbNail_Mode = hide;
      if (ThumbNailIsShowing)
        if (hide && Spane.getRightComponent().equals(imageScrollPane))
        {
          Spane.remove(imageScrollPane);
          Last_Divider_Position = Spane.getDividerLocation();
          PreviewAreaIsHiding = true;
        }
        else if (!hide)
        {
          Spane.setRightComponent(imageScrollPane);
          if (Last_Divider_Position == 0)
            Spane.setDividerLocation(400);
          else
            Spane.setDividerLocation(Last_Divider_Position);
          getContentPane().repaint();
          PreviewAreaIsHiding = false;
        }
    }
    public void ChangeColumnLayout(int columns) {
        ChangeColumnLayout(columns,this.VIEW_TYPE_LIST);
    }
    /**
     *  Last modified by Neoya 2002-03-11
     *  @param listOrThumb The original ViewType
     */
    public void ChangeColumnLayout(int columns,int listOrThumb) {
        int smallSplitLocation;
        int splitLocation;
        boolean hidePreview=optionsDialog.getHidePreview() && this.isThumbMode();
        //If it is first created,then get the splits' location else get it from the saved values or default
        if (!(Spane==null)){ // NOT first create
            smallSplitLocation=smallSplitPane.getDividerLocation();
            splitLocation=Spane.getDividerLocation();
        }else{ //First create
            String sSize=properties.getProperty(Properties.SMALL_SPANE);
            if (!sSize.equals(""))
                smallSplitLocation=Integer.parseInt(sSize);
            else
                smallSplitLocation=200;//Default Value
            sSize=properties.getProperty(Properties.SPANE);
            if (!sSize.equals(""))
                splitLocation=Integer.parseInt(sSize);
            else
                splitLocation=300;//Default Value
        }
        //Change the location values if needed
        if (listOrThumb==this.VIEW_TYPE_LIST){
            if(hidePreview)
                this.saveDividerLocation();
        }else if(listOrThumb==this.VIEW_TYPE_THUMB){
            if(optionsDialog.getHidePreview()&& !this.isThumbMode()){
                //Get the saved value
                if(columns==Properties.COLUMN_LAYOUT_LIST)
                    smallSplitLocation=smallDividerLocation;
                else
                    splitLocation=dividerLocation;
            }
        }
        if (!(Spane==null)){ // NOT first create
            //Remove all JScrollPane
            Spane.remove(smallSplitPane);
            if(Spane.isAncestorOf(imageScrollPane))
                Spane.remove(imageScrollPane);
            if(Spane.isAncestorOf(FileListScrollPane))
                Spane.remove(FileListScrollPane);
            if(Spane.isAncestorOf(thumblabel))
                Spane.remove(thumblabel);
        }
        if(columns==Properties.COLUMN_LAYOUT_PREVIEW)
            smallSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, fileTree, fileListOrThumbLabel);
        else if(hidePreview){
            smallSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,fileTree,null);
        }else{
            smallSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, fileTree, imageScrollPane);
        }
        //
        if(Spane==null){ //First Created
            //String sSize=properties.getProperty(Properties.SMALL_SPANE);
            if(columns==Properties.COLUMN_LAYOUT_PREVIEW){
            if(hidePreview)
                Spane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, smallSplitPane,null);
            else
                Spane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, smallSplitPane, imageScrollPane);
            }
            else
            Spane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, smallSplitPane, fileListOrThumbLabel);
        }else{
            Spane.add(smallSplitPane);
            if(columns==Properties.COLUMN_LAYOUT_PREVIEW){
                if(!hidePreview)
                    Spane.add(imageScrollPane);
            }else
                Spane.add(fileListOrThumbLabel);
        }
        //Set Divider size
        if(columns==Properties.COLUMN_LAYOUT_LIST && hidePreview)
            smallSplitPane.setDividerSize(0);
        else
            smallSplitPane.setDividerSize(8);
        if(columns==Properties.COLUMN_LAYOUT_PREVIEW && hidePreview)
            Spane.setDividerSize(0);
        else
            Spane.setDividerSize(8);
        smallSplitPane.setOneTouchExpandable(true);
        Spane.setOneTouchExpandable(true);
        smallSplitPane.setDividerLocation(smallSplitLocation);
        Spane.setDividerLocation(splitLocation);

        getContentPane().repaint();
    }
    /**
     * Change the FileListScroll or ThumbLabel view
     * @author Neoya 2002-03-08
     */
    public void changeViewType(int viewType){        
        if (viewType==this.VIEW_TYPE_LIST)
            fileListOrThumbLabel=FileListScrollPane;
        else if (viewType==this.VIEW_TYPE_THUMB)
            fileListOrThumbLabel=thumblabel;
        //
        int view = (viewType==this.VIEW_TYPE_LIST)?this.VIEW_TYPE_THUMB :this.VIEW_TYPE_LIST;
        this.ChangeColumnLayout(optionsDialog.getColumnLayout(),view);

        getContentPane().repaint();                
    }
    /**
     * Test if it is in Thumbnail  Mode
     * @author Neoya 2002-03-11
     */
    public boolean isThumbMode(){
        if (fileListOrThumbLabel==thumblabel)
            return true;
        return false;
    }
    /**
     * Save Divider Location when hide preview in thumbnail  mode
     * @author Neoya 2002-03-11
     */
    public void saveDividerLocation(){
        dividerLocation=Spane.getDividerLocation();
        smallDividerLocation=smallSplitPane.getDividerLocation();
    }
    public void SetProgressValue(int value) {
      statusBar.setStatusBarValue(value);
    }

    public boolean getAutoSize() {
        return Auto_Size;
    }

    public void setAutoSize(boolean b) {
        Auto_Size = b;
    }

    public void Run_Slide_Show_For_Dir() {
    // There is a bug here, if directory start with the first item is an image then that
    // image cannot be displayed by slide show. Normally the first item of a list is a dir
        FileListScrollPane.fileListTable.setRowSelectionInterval(1, 1);
        Display_Image_FullScreen(FileListScrollPane.getSelectedFile());
        fsw.Run_Slide_Show();
    }

    public void ViewFullScreen(boolean vfs) {
        ViewFullScreen = vfs;
    }

    public void Quit() {
        //Modified by Neoya 2002-03-12
        //Save properties every time
        Properties p=properties;

        p.setProperty(Properties.PATH,FileListScrollPane.getCurrentDir());
        p.setProperty(Properties.SPANE,Spane.getDividerLocation());
        p.setProperty(Properties.SMALL_SPANE,smallSplitPane.getDividerLocation());
        p.setProperty(Properties.THUMBNAIL_SHOW,ThumbNailIsShowing);
        //Show Columns
        p.setProperty(Properties.SHOW_COLUMN_SIZE,jShowSizeItem.isSelected());
        p.setProperty(Properties.SHOW_COLUMN_DATE,jShowModifiedItem.isSelected());
        p.setProperty(Properties.SHOW_COLUMN_TYPE,jShowTypeItem.isSelected());
        p.setProperty(Properties.SHOW_COLUMN_PROPERTIES,jShowPropertyItem.isSelected());

        System.exit(0);
    }
}

⌨️ 快捷键说明

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