Skip to content
Snippets Groups Projects
JamView.java 57.6 KiB
Newer Older
  • Learn to ignore specific revisions
  • tjc's avatar
    tjc committed
                  * maxUnitIncrement
                  - currentPosition;
        }
      }
    
    tjc's avatar
    tjc committed
      
    
      /**
       * Artemis event notification
       */
      public void displayAdjustmentValueChanged(DisplayAdjustmentEvent event)
      {
    
    tjc's avatar
    tjc committed
        if(event.getType() == DisplayAdjustmentEvent.SCALE_ADJUST_EVENT)
        {
    
    tjc's avatar
    tjc committed
          laststart = -1;
          lastend = -1;
          this.startBase = event.getStart();
          this.endBase   = event.getEnd();
          
    
          //int width = event.getEnd()-event.getStart()+1;
          int width = feature_display.getMaxVisibleBases();
    
          //System.out.println("displayAdjustmentValueChanged() "+event.getStart()+".."+event.getEnd()+"  +width");
    
    tjc's avatar
    tjc committed
    
          setZoomLevel(width);
          goToBasePosition(event.getStart());
    
    tjc's avatar
    tjc committed
          setDisplay(event.getStart(), event.getEnd(), event);
    
    tjc's avatar
    tjc committed
          repaint();
    
    tjc's avatar
    tjc committed
        }
        else
        {
          setDisplay(event.getStart(), event.getEnd(), event);
    
    tjc's avatar
    tjc committed
          repaint();
    
    tjc's avatar
    tjc committed
        }
    
      public void selectionChanged(SelectionChangeEvent event)
      {
        repaint();
      }
      
      
      
    
    tjc's avatar
    tjc committed
      public static void main(String[] args)
      {
        String bam = args[0];
    
    tjc's avatar
    tjc committed
        int nbasesInView = 1000;
    
    tjc's avatar
    tjc committed
        String reference = null;
        
    
    tjc's avatar
    tjc committed
        for(int i=0;i<args.length; i++)
        {
          if(args[i].equals("-a"))
            bam = args[++i];
          else if(args[i].equals("-r"))
            reference = args[++i];
          else if(args[i].equals("-v"))
            nbasesInView = Integer.parseInt(args[++i]);
          else if(args[i].equals("-s"))
            System.setProperty("samtoolDir", args[++i]);
          else if(args[i].startsWith("-h"))
          { 
            System.out.println("-h\t show help");
            
            System.out.println("-a\t BAM/SAM file to display");
            System.out.println("-r\t reference file (optional)");
            System.out.println("-v\t number of bases to display in the view (optional)");
    
            /*System.out.println("-s\t samtool directory");*/
    
    tjc's avatar
    tjc committed
    
            System.exit(0);
          }
        }
    
    
    tjc's avatar
    tjc committed
        final JamView view = new JamView(bam, reference, nbasesInView);
    
    tjc's avatar
    tjc committed
        JFrame frame = new JFrame("JAM");
    
    tjc's avatar
    tjc committed
        
    
        // translucent
        //frame.getRootPane().putClientProperty("Window.alpha", new Float(0.9f));
    
    
    tjc's avatar
    tjc committed
        frame.addWindowFocusListener(new WindowFocusListener()
        {
          public void windowGainedFocus(WindowEvent e)
          {
            view.requestFocus();
          }
          public void windowLostFocus(WindowEvent e){}
        });
        
    
    tjc's avatar
    tjc committed
        view.addJamToPanel((JPanel)frame.getContentPane(), frame, false, null);
    
    tjc's avatar
    tjc committed
        frame.pack();
    
    tjc's avatar
    tjc committed
        view.jspView.getVerticalScrollBar().setValue(
            view.jspView.getVerticalScrollBar().getMaximum());
    
        frame.setVisible(true);
    
    tjc's avatar
    tjc committed
      }
    
    tjc's avatar
    tjc committed
    }