Example usage for java.awt.event MouseMotionListener MouseMotionListener

List of usage examples for java.awt.event MouseMotionListener MouseMotionListener

Introduction

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

Prototype

MouseMotionListener

Source Link

Usage

From source file:edu.ku.brc.specify.tasks.subpane.LocalityMapperSubPane.java

/**
 *
 *//*from   www  .ja  v  a2  s .c  o m*/
protected void createUI() {
    kmlGen = new CollectingEventLocalityKMLGenerator();
    this.collectingEvents = new ArrayList<CollectingEvent>();

    CollectingEvent startCE = null;
    CollectingEvent endCE = null;

    Vector<Locality> localities = new Vector<Locality>();
    Vector<String> labels = new Vector<String>();
    for (Object obj : colEvents) {
        CollectingEvent collectingEvent = (CollectingEvent) obj;

        Locality locality = collectingEvent.getLocality();
        if (locality == null || locality.getLatitude1() == null || locality.getLongitude1() == null) {
            continue;
        }

        collectingEvents.add(collectingEvent);
        kmlGen.addDataObj(collectingEvent, "");

        if (collectingEvents.size() == 1) {
            startCE = collectingEvent;
            endCE = collectingEvent;
        }
        // XXX TODO FIX ME!
        if (startCE == null || endCE == null) {
            return;
        }
        // There may be an End Date that is further out than than the End Date of the last item
        // with the latest Start Date
        if (startCE.getStartDate().compareTo(collectingEvent.getStartDate()) > 1) {
            startCE = collectingEvent;
        }
        Calendar leftCal = endCE.getEndDate() != null ? endCE.getEndDate() : endCE.getStartDate();
        Calendar rightCal = collectingEvent.getEndDate() != null ? collectingEvent.getEndDate()
                : collectingEvent.getStartDate();
        if (leftCal.compareTo(rightCal) < 0) {
            endCE = collectingEvent;
        }

        Hashtable<String, Object> map = new Hashtable<String, Object>();

        Set<CollectionObject> colObjs = collectingEvent.getCollectionObjects();

        map.put("startDate", collectingEvent.getStartDate());
        map.put("endDate", collectingEvent.getEndDate());

        Set<Object> taxonNames = new HashSet<Object>();
        for (CollectionObject co : colObjs) {
            for (Determination d : co.getDeterminations()) {
                if (d.isCurrentDet()) {
                    //System.out.println(d.getTaxon().getName() + "("+co.getCountAmt()+")");
                    Taxon taxon = d.getPreferredTaxon();
                    if (taxon != null) {
                        taxonNames.add(taxon.getName()
                                + (co.getCountAmt() != null ? " (" + co.getCountAmt() + ")" : ""));
                        if (taxon.getRankId() == 220) {
                            Taxon genus = taxon.getParent();
                            if (genus.getRankId() == 180) {
                                ImageGetter imgGetter = new ImageGetter(imageGetterList, imageMap, imageURLs,
                                        genus.getName(), taxon.getName());
                                imageGetterList.add(imgGetter);
                            }
                        }
                    }
                    break;
                }
            }
        }
        map.put("taxonItems", taxonNames);

        map.put("latitude1", locality.getLatitude1());
        map.put("longitude1", locality.getLongitude1());

        /*
        Calendar cal = collectingEvent.getStartDate();
        if (cal != null)
        {
          labels.add(scrDateFormat.format(cal.getTime()));
                
        } else if (collectingEvent.getVerbatimDate() != null)
        {
          labels.add(collectingEvent.getVerbatimDate());
                
        } else
        {
          labels.add(Integer.toString(collectingEvent.getCollectingEventId()));
                
        }
        */
        labels.add(Integer.toString(collectingEvents.size()));
        localities.add(locality);
        valueList.add(map);

    }

    // XXX Fix me shouldn't be hard coded here to make it work
    localityMapper.setMaxMapWidth(515);
    localityMapper.setMaxMapHeight(375);

    Color arrow = new Color(220, 220, 220);
    localityMapper.setArrowColor(arrow);
    localityMapper.setDotColor(Color.WHITE);
    localityMapper.setDotSize(4);
    localityMapper.setLabelColor(Color.RED);

    int inx = 0;
    for (Locality locality : localities) {
        localityMapper.addLocationAndLabel(locality, labels != null ? labels.get(inx) : null);
        inx++;
    }
    localityMapper.setCurrentLoc(localities.get(0));
    localityMapper.setCurrentLocColor(Color.RED);

    // XXX DEMO  (Hard Coded 'null' means everyone would have one which may not be true)
    // "null" ViewSet name means it should use the default
    ViewIFace view = AppContextMgr.getInstance().getView("LocalityMapper");

    // TODO WHERE's the ERROR checking !
    multiView = new MultiView(null, null, view, AltViewIFace.CreationMode.VIEW, MultiView.NO_OPTIONS);
    multiView.setBorder(
            BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(new Color(138, 128, 128)),
                    BorderFactory.createEmptyBorder(4, 4, 4, 4)));

    formViewObj = multiView.getCurrentViewAsFormViewObj();
    formViewObj.getUIComponent().setBackground(Color.WHITE);

    imageJList = formViewObj.getCompById("taxonItems");
    imageJList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                String nameStr = (String) imageJList.getSelectedValue();
                if (nameStr != null) {
                    int index = nameStr.indexOf(" (");
                    if (index > -1) {
                        nameStr = nameStr.substring(0, index);
                    }
                }

                //System.out.println("Getting["+name+"]");
                Image img = null;
                if (StringUtils.isNotEmpty(nameStr)) {
                    img = imageMap.get(nameStr); // might return null
                    ImageDisplay imgDisplay = formViewObj.getCompById("image");
                    if (img != null) {
                        imgDisplay.setImage(new ImageIcon(img));
                    } else {
                        imgDisplay.setImage((Image) null);
                    }
                }

            }
        }
    });

    // XXX TODO FIX ME!
    if (startCE == null || endCE == null) {
        return;
    }
    String startDateStr = scrDateFormat.format(startCE.getStartDate().getTime());
    String endDateStr = scrDateFormat
            .format((endCE.getEndDate() != null ? endCE.getEndDate() : endCE.getStartDate()).getTime());

    Formatter formatter = new Formatter();
    titleLabel.setText(formatter
            .format(getResourceString("LocalityMapperTitle"), new Object[] { startDateStr, endDateStr })
            .toString());

    Font font = titleLabel.getFont();
    titleLabel.setFont(new Font(font.getFontName(), Font.BOLD, font.getSize() + 2));

    recordSetController = new ResultSetController(null, false, false, false, null, collectingEvents.size(),
            true);
    recordSetController.addListener(this);
    recordSetController.getPanel().setBackground(Color.WHITE);

    controlPanel = new ControlBarPanel(getBackground());
    controlPanel.add(recordSetController.getPanel());
    controlPanel.setRecordSetController(recordSetController);
    controlPanel.setBackground(Color.WHITE);

    googleBtn = new JButton(IconManager.getIcon("GoogleEarth", IconManager.STD_ICON_SIZE));
    googleBtn.setMargin(new Insets(1, 1, 1, 1));
    googleBtn.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
    googleBtn.setSize(new Dimension(18, 18));
    googleBtn.setPreferredSize(new Dimension(18, 18));
    googleBtn.setMaximumSize(new Dimension(18, 18));
    googleBtn.setFocusable(false);
    googleBtn.setBackground(Color.WHITE);

    controlPanel.addButtons(new JButton[] { googleBtn }, false);

    googleBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            try {
                UIRegistry.displayStatusBarText("Exporting Collecting Events in KML."); // XXX I18N
                kmlGen.setSpeciesToImageMapper(imageURLs);
                kmlGen.outputToFile(System.getProperty("user.home") + File.separator + "specify.kml");

            } catch (Exception ex) {
                edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
                edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(LocalityMapperSubPane.class, ex);
                ex.printStackTrace();
            }
        }
    });

    addMouseMotionListener(new MouseMotionListener() {
        public void mouseDragged(MouseEvent e) {
            // nothing
        }

        public void mouseMoved(MouseEvent e) {
            checkMouseLocation(e.getPoint(), false);
        }
    });

    addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            checkMouseLocation(e.getPoint(), true);
        }

    });

    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            getLocalityMap();
        }
    });

}

From source file:org.forester.archaeopteryx.ControlPanel.java

private void buildJSlider(int width, int min, int max) {
    _color_branches_edpl_slider = new JSlider(min, max);
    Dimension d = _color_branches_edpl_slider.getSize();
    d.width = width;//from   w w  w .j a  v a2s .c o  m
    d.height = 100;
    _color_branches_edpl_slider.setPreferredSize(d);
    //       _color_branches_edpl_slider.setLayout(null);

    // slider popup with cutoff value
    _slider_popup = new JPopupMenu();
    JLabel text = new JLabel();
    text.setText(String.valueOf(_edpl_current_cutoff));
    _slider_popup.add(text);
    if (!_configuration.isUseNativeUI()) {
        _color_branches_edpl_slider.setBackground(ControlPanel.jcb_background_color);
        _color_branches_edpl_slider.setForeground(ControlPanel.jcb_text_color);
    }
    _color_branches_edpl_slider.setToolTipText("Set cutoff for EDPL (0.5-1.0)");
    _color_branches_edpl_slider.setMinorTickSpacing(10);
    _color_branches_edpl_slider.setMajorTickSpacing(50);
    _color_branches_edpl_slider.setPaintTicks(true);
    _color_branches_edpl_slider.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            // get Treepanel function
            final TreePanel tp = getMainPanel().getCurrentTreePanel();
            if (tp == null) {
                return;
            }
            Phylogeny phy = tp.getPhylogeny();
            _edpl_next_cutoff = ((double) ((JSlider) (e.getSource())).getValue() / 100.0);
            tp.edplSliderMovement(_edpl_next_cutoff, _edpl_current_cutoff);
            _edpl_current_cutoff = _edpl_next_cutoff;
            //              System.out.println("Neuer Wert: "+
            //              ((JSlider)(e.getSource())).getValue());
        }
    });
    _color_branches_edpl_slider.addMouseMotionListener(new MouseMotionListener() {

        @Override
        public void mouseMoved(MouseEvent e) {
            if (_color_branches_edpl_slider.isEnabled()) {
                _slider_popup.setVisible(false);
            }
        }

        @Override
        public void mouseDragged(MouseEvent e) {
            if (_color_branches_edpl_slider.isEnabled()) {
                //               Point p = getMainPanel().getMainFrame().getLocation();
                Point p = _color_branches_edpl_slider.getLocationOnScreen();
                JLabel text = (JLabel) _slider_popup.getComponent(0);
                text.setText(String.valueOf(_edpl_current_cutoff));
                int x = (int) p.getX() + 18;
                int y = (int) p.getY() - 25;
                _slider_popup.setLocation(x, y);
                _slider_popup.setVisible(true);
            }

        }
    });
}

From source file:org.isatools.isacreator.spreadsheet.Spreadsheet.java

/**
 * Setup the JTable with its desired characteristics
 *//*from w w w  .  j  a  v  a2 s.  c  om*/
private void setupTable() {
    table = new CustomTable(spreadsheetModel);
    table.setShowGrid(true);
    table.setGridColor(Color.BLACK);
    table.setShowVerticalLines(true);
    table.setShowHorizontalLines(true);
    table.setGridColor(UIHelper.LIGHT_GREEN_COLOR);
    table.setRowSelectionAllowed(true);
    table.setColumnSelectionAllowed(true);
    table.setAutoCreateColumnsFromModel(false);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    table.getSelectionModel().addListSelectionListener(this);
    table.getColumnModel().getSelectionModel().addListSelectionListener(this);
    table.getTableHeader().setReorderingAllowed(true);
    table.getColumnModel().addColumnModelListener(this);
    try {
        table.setDefaultRenderer(Class.forName("java.lang.Object"), new SpreadsheetCellRenderer());
    } catch (ClassNotFoundException e) {
        // ignore this error
    }

    table.addMouseListener(this);
    table.getTableHeader().addMouseMotionListener(new MouseMotionListener() {
        public void mouseDragged(MouseEvent event) {
        }

        public void mouseMoved(MouseEvent event) {
            // display a tooltip when user hovers over a column. tooltip is derived
            // from the description of a field from the TableReferenceObject.
            JTable table = ((JTableHeader) event.getSource()).getTable();
            TableColumnModel colModel = table.getColumnModel();
            int colIndex = colModel.getColumnIndexAtX(event.getX());

            // greater than 1 to account for the row no. being the first col
            if (colIndex >= 1) {
                TableColumn tc = colModel.getColumn(colIndex);
                if (tc != null) {
                    try {
                        table.getTableHeader().setToolTipText(getFieldDescription(tc));
                    } catch (Exception e) {
                        // ignore this error
                    }
                }
            }
        }
    });

    //table.getColumnModel().addColumnModelListener(this);
    InputMap im = table.getInputMap(JTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    KeyStroke tab = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0);

    //  Override the default tab behaviour
    //  Tab to the next editable cell. When no editable cells goto next cell.
    final Action previousTabAction = table.getActionMap().get(im.get(tab));
    Action newTabAction = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            // maintain previous tab action procedure
            previousTabAction.actionPerformed(e);

            JTable table = (JTable) e.getSource();
            int row = table.getSelectedRow();
            int originalRow = row;
            int column = table.getSelectedColumn();
            int originalColumn = column;

            while (!table.isCellEditable(row, column)) {
                previousTabAction.actionPerformed(e);
                row = table.getSelectedRow();
                column = table.getSelectedColumn();

                //  Back to where we started, get out.
                if ((row == originalRow) && (column == originalColumn)) {
                    break;
                }
            }

            if (table.editCellAt(row, column)) {
                table.getEditorComponent().requestFocusInWindow();
            }
        }
    };

    table.getActionMap().put(im.get(tab), newTabAction);
    TableColumnModel model = table.getColumnModel();

    String previousColumnName = null;
    for (int columnIndex = 0; columnIndex < tableReferenceObject.getHeaders().size(); columnIndex++) {
        if (!model.getColumn(columnIndex).getHeaderValue().toString()
                .equals(TableReferenceObject.ROW_NO_TEXT)) {
            model.getColumn(columnIndex).setHeaderRenderer(columnRenderer);
            model.getColumn(columnIndex).setPreferredWidth(spreadsheetFunctions
                    .calcColWidths(model.getColumn(columnIndex).getHeaderValue().toString()));
            // add appropriate cell editor for cell.
            spreadsheetFunctions.addCellEditor(model.getColumn(columnIndex), previousColumnName);
            previousColumnName = model.getColumn(columnIndex).getHeaderValue().toString();
        } else {
            model.getColumn(columnIndex).setHeaderRenderer(new RowNumberCellRenderer());
        }
    }

    JTableHeader header = table.getTableHeader();
    header.setBackground(UIHelper.BG_COLOR);
    header.addMouseListener(new HeaderListener(header, columnRenderer));

    table.addNotify();
}

From source file:base.BasePlayer.Main.java

public Main() {

    super(new GridBagLayout());
    try {//from w w  w  .j av a2s .c  o  m

        //UIManager.put("PopupMenu.border", BorderFactory.createMatteBorder(0, 20, 0, 0, new Color(230,230,230)));
        //URL fontUrl = new URL("http://www.webpagepublicity.com/" +
        //       "free-fonts/a/Airacobra%20Condensed.ttf");
        //      URL fontUrl = new URL("C:/HY-Data/RKATAINE/WinPython-64bit-3.5.3.1Qt5/python-3.5.3.amd64/share/numdifftools/docs/_build/html/_static/fonts/Inconsolata-Regular.ttf");
        //   URL fonturl = this.getClass().getResource("OpenSans-Regular.ttf");
        //   menuFont = Font.createFont(Font.TRUETYPE_FONT, new File(fonturl.getFile()));
        //   C:\HY-Data\RKATAINE\WinPython-64bit-3.5.3.1Qt5\python-3.5.3.amd64\Lib\site-packages\reportlab\fonts
        Launcher.fromMain = true;
        Launcher.main(args);
        VariantHandler.main(argsit);
        glass = Toolkit.getDefaultToolkit().getImage(getClass().getResource("icons/glass.jpg"));
        ToolTipManager.sharedInstance().setInitialDelay(100);
        // ToolTipManager.sharedInstance().setDismissDelay(2000);
        UIManager.put("ToolTip.background", new Color(255, 255, 214));
        UIManager.put("ToolTip.border", BorderFactory.createCompoundBorder(
                UIManager.getBorder("ToolTip.border"), BorderFactory.createEmptyBorder(4, 4, 4, 4)));
        lineseparator = System.getProperty("line.separator");

        proxysettings = new ProxySettings();
        panel = new JPanel(new GridBagLayout());
        //menuFont = menuFont.deriveFont(Font.PLAIN,12);
        Draw.defaultFont = menuFont;

        gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
        width = gd.getDisplayMode().getWidth();
        height = gd.getDisplayMode().getHeight();
        if (Launcher.fontSize.equals("")) {
            if (width < 1500) {
                defaultFontSize = 11;

                buttonHeight = Main.defaultFontSize * 2;
                buttonWidth = Main.defaultFontSize * 6;

            } else if (width < 2000) {
                defaultFontSize = 12;

                buttonHeight = Main.defaultFontSize * 2 + 4;
                buttonWidth = Main.defaultFontSize * 6 + 4;

            } else if (width < 3000) {
                defaultFontSize = 15;
                buttonHeight = Main.defaultFontSize * 2 + 4;
                buttonWidth = Main.defaultFontSize * 6 + 4;
            } else {
                defaultFontSize = 19;
                buttonHeight = Main.defaultFontSize * 2 + 4;
                buttonWidth = Main.defaultFontSize * 6 + 4;
            }
        } else {
            try {
                defaultFontSize = Integer.parseInt(Launcher.fontSize);
            } catch (Exception e) {
                defaultFontSize = 12;
            }
        }

        menuFont = new Font("SansSerif", Font.PLAIN, Main.defaultFontSize);
        menuFontBold = new Font("SansSerif", Font.BOLD, Main.defaultFontSize);
        //   menuFont = new Font("SansSerif", Font.BOLD, Main.defaultFontSize);
    } catch (Exception e) {
        e.printStackTrace();
    }
    FileSystemView fsv = FileSystemView.getFileSystemView();
    File[] paths = File.listRoots();

    for (File path : paths) {
        if (fsv.getSystemDisplayName(path).contains("merit")) {
            pleiades = true;
        }
    }

    screenSize = new Dimension(width, height);

    drawHeight = (int) (screenSize.getHeight() * 0.6);
    sidebarWidth = (int) (screenSize.getWidth() * 0.1);
    drawWidth = (int) (screenSize.getWidth() - sidebarWidth);
    thisMainListener = this;
    try {
        htsjdk.samtools.util.Log.setGlobalLogLevel(htsjdk.samtools.util.Log.LogLevel.ERROR);
        /*   for(int i=0;i<snow.length; i++) {
              snow[i][0] = (height*Math.random());
              snow[i][1] = (4*Math.random() +1);
              snow[i][2] = (12*Math.random() -6);
              snow[i][3] = (2*Math.random() +1);
           }*/
        frame.addWindowListener(new java.awt.event.WindowAdapter() {
            @Override
            public void windowClosing(java.awt.event.WindowEvent windowEvent) {
                /*if (JOptionPane.showConfirmDialog(frame, "Are you sure to close this window?", "Really Closing?", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION){
                    System.exit(0);
                }*/
                if (configChanged) {

                    try {
                        BufferedWriter fileWriter = new BufferedWriter(new FileWriter(Launcher.configfile));
                        for (int i = 0; i < Launcher.config.size(); i++) {
                            fileWriter.write(Launcher.config.get(i) + lineseparator);
                        }
                        fileWriter.close();

                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }

            }
        });
        baseMap.put((byte) 'A', 1);
        baseMap.put((byte) 'C', 2);
        baseMap.put((byte) 'G', 3);
        baseMap.put((byte) 'T', 4);
        baseMap.put((byte) 'N', 5);
        baseMap.put((byte) 'I', 6);
        baseMap.put((byte) 'D', 7);
        mutTypes.put("TA", 0);
        mutTypes.put("AT", 0);
        mutTypes.put("TC", 1);
        mutTypes.put("AG", 1);
        mutTypes.put("TG", 2);
        mutTypes.put("AC", 2);
        mutTypes.put("CA", 3);
        mutTypes.put("GT", 3);
        mutTypes.put("CG", 4);
        mutTypes.put("GC", 4);
        mutTypes.put("CT", 5);
        mutTypes.put("GA", 5);

        getBase.put((byte) 'A', "A");
        getBase.put((byte) 'C', "C");
        getBase.put((byte) 'G', "G");
        getBase.put((byte) 'T', "T");
        getBase.put((byte) 'N', "N");
        getBase.put((byte) 'a', "A");
        getBase.put((byte) 'c', "C");
        getBase.put((byte) 'g', "G");
        getBase.put((byte) 't', "T");
        getBase.put((byte) 'n', "N");
        java.net.URL imgUrl = getClass().getResource("icons/save.gif");
        save = new ImageIcon(imgUrl);
        imgUrl = getClass().getResource("icons/open.gif");
        open = new ImageIcon(imgUrl);
        imgUrl = getClass().getResource("icons/settings.png");
        settingsIcon = new ImageIcon(imgUrl);
        userDir = new File(Main.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getParent()
                .replace("%20", " ");
        settings = new JMenuItem("Settings", settingsIcon);

        //   Average.frame.setVisible(false);

        try {

            savedir = Launcher.defaultSaveDir;
            path = Launcher.defaultDir;
            gerp = Launcher.gerpfile;
            defaultGenome = Launcher.defaultGenome;
            defaultAnnotation = Launcher.defaultAnnotation;
            isProxy = Launcher.isProxy;
            proxyHost = Launcher.proxyHost;
            proxyPort = Launcher.proxyPort;
            proxyType = Launcher.proxyType;
            if (isProxy) {
                ProxySettings.useProxy.setSelected(true);
            }
            if (!proxyHost.equals("")) {
                ProxySettings.hostField.setText(proxyHost);
            }
            if (!proxyPort.equals("")) {
                ProxySettings.portField.setText(proxyPort);
            }
            if (!Launcher.proxyType.equals("")) {
                ProxySettings.proxytypes.setSelectedItem(proxyType);
            }
            if (Launcher.backColor.equals("")) {
                Draw.backColor = new Color(90, 90, 90);
            }

            else {

                Draw.backColor = new Color(Integer.parseInt(Launcher.backColor),
                        Integer.parseInt(Launcher.backColor), Integer.parseInt(Launcher.backColor));
                Settings.graySlider.setValue(Integer.parseInt(Launcher.backColor));
            }

            if (Launcher.genomeDir.equals("")) {

                genomeDir = new File(userDir + "/genomes/");
            } else {
                if (new File(Launcher.genomeDir).exists()) {

                    genomeDir = new File(Launcher.genomeDir);
                } else {
                    genomeDir = new File(userDir + "/genomes/");
                }
            }

            annotationfile = defaultAnnotation;
            controlDir = Launcher.ctrldir;
            trackDir = Launcher.trackDir;
            projectDir = Launcher.projectDir;
            downloadDir = Launcher.downloadDir;
        } catch (Exception e) {
            e.printStackTrace();
        }
        File[] genomes = genomeDir.listFiles(new FilenameFilter() {
            public boolean accept(File dir, String name) {
                return !name.contains(".txt") && !name.startsWith(".");
            }
        });
        chromHeight = (int) (drawHeight * 0.1);
        drawDimensions = new Dimension(drawWidth, drawHeight - chromHeight);
        bedDimensions = new Dimension(drawWidth, bedHeight);
        chromDimensions = new Dimension(drawWidth - Main.sidebarWidth - 1, drawHeight);
        drawCanvas = new Draw((int) drawDimensions.getWidth(), (int) drawDimensions.getHeight());
        controlDraw = new ControlCanvas((int) bedDimensions.getWidth(), (int) bedDimensions.getHeight());
        iconImage = Toolkit.getDefaultToolkit().getImage(getClass().getResource("icons/icon.png"));
        frame.setIconImage(iconImage);
        /*   if(args.length > 0) {
               for(int i = 0; i<args.length; i++) {
                  if(args[i].startsWith("-opendir")) {
                     path = args[i].substring(9).replace(" ", "");
                  }
                  else if(args[i].startsWith("-ctrldir")) {
                     Control.path = args[i].substring(9).replace(" ", "");
                  }             
               }       
            }*/

        //   BGZIPInputStream in = this.getClass().getResourceAsStream("SELEX_1505_representative_matrices.bedhead.gz");
        searchField.getDocument().addDocumentListener(new DocumentListener() {
            private String searchstring;

            public void changedUpdate(DocumentEvent e) {
                if (searchField.getText().contains(";")) {
                    searchList = searchField.getText().split(";");
                    for (int i = 0; i < searchList.length; i++) {
                        warn(searchList[i].replace(" ", ""));
                    }
                } else {
                    warn(searchField.getText().replace(" ", ""));
                }

            }

            public void removeUpdate(DocumentEvent e) {
                if (searchField.getText().contains(";")) {
                    searchList = searchField.getText().split(";");
                    for (int i = 0; i < searchList.length; i++) {
                        warn(searchList[i].replace(" ", ""));
                    }
                } else {
                    warn(searchField.getText().replace(" ", ""));
                }
            }

            public void insertUpdate(DocumentEvent e) {
                if (searchField.getText().contains(";")) {
                    searchList = searchField.getText().split(";");
                    for (int i = 0; i < searchList.length; i++) {
                        warn(searchList[i].replace(" ", ""));
                    }
                } else {
                    warn(searchField.getText().replace(" ", ""));
                }
            }

            public void warn(String searchtext) {

                if (searchTable.containsKey(searchtext.toUpperCase())) {
                    if (searchTable.get(searchtext.toUpperCase())[0]
                            .equals(Main.chromosomeDropdown.getSelectedItem())) {
                        searchChrom = searchTable.get(searchtext.toUpperCase())[0];
                        searchStart = Integer.parseInt(searchTable.get(searchtext.toUpperCase())[1]);
                        searchEnd = Integer.parseInt(searchTable.get(searchtext.toUpperCase())[2]);
                    } else {
                        chromDraw.repaint();
                        searchStart = -1;
                        searchEnd = -1;
                    }
                    chromDraw.repaint();
                    searchField.setForeground(Color.black);
                } else if (searchField.getText().toUpperCase().matches("CHR.{1,2}(?!:)")) {

                    if (Main.chromnamevector.contains(searchtext.toUpperCase().substring(3))) {
                        searchField.setForeground(Color.black);

                    } else {
                        chromDraw.repaint();
                        searchField.setForeground(Color.red);
                    }
                } else if (searchtext.toUpperCase().replace(",", "").matches("(CHR)?(.+:)?\\d+(-\\d+)?")) {

                    searchField.setForeground(Color.black);
                    if (searchtext.contains(":")) {
                        searchstring = searchtext.substring(searchtext.indexOf(":") + 1).replace(",", "");
                    } else {
                        chromDraw.repaint();
                        searchstring = searchtext.replace(",", "");
                    }

                    if (!searchstring.contains("-")) {
                        try {
                            searchStart = Integer.parseInt(searchstring);
                        } catch (Exception ex) {

                        }
                        searchEnd = -1;
                    } else {
                        try {
                            searchStart = Integer
                                    .parseInt(searchstring.substring(0, searchstring.indexOf("-")));
                            searchEnd = Integer.parseInt(searchstring.substring(searchstring.indexOf("-") + 1));
                        } catch (Exception ex) {

                        }
                    }
                    chromDraw.repaint();

                } else {
                    chromDraw.repaint();
                    searchField.setForeground(Color.red);
                    searchStart = -1;
                    searchEnd = -1;
                }
            }
        });

        try {

            A = Toolkit.getDefaultToolkit().getImage(getClass().getResource("SELEX/A.png"));
            C = Toolkit.getDefaultToolkit().getImage(getClass().getResource("SELEX/C.png"));
            G = Toolkit.getDefaultToolkit().getImage(getClass().getResource("SELEX/G.png"));
            T = Toolkit.getDefaultToolkit().getImage(getClass().getResource("SELEX/T.png"));

        } catch (Exception e) {
            e.printStackTrace();
        }
        ErrorLog.main(args);

        this.setBackground(Color.black);
        UIManager.put("FileChooser.readOnly", Boolean.TRUE);

        panel.setBackground(Draw.sidecolor);
        panel.setBorder(BorderFactory.createLineBorder(Color.white));
        searchField.addKeyListener(this);

        frame.addKeyListener(this);
        frame.getContentPane().setBackground(Color.black);

        glassPane.addMouseListener(this);
        glassPane.addMouseMotionListener(new MouseMotionListener() {

            @Override
            public void mouseDragged(MouseEvent arg0) {

            }

            @Override
            public void mouseMoved(MouseEvent event) {

                // g.drawRect(drawScroll.getWidth()/2-Main.canceltextwidth/2-Main.defaultFontSize/2, Main.drawScroll.getViewport().getHeight()*2/3+Draw.loadingFont.getSize()*3-Main.defaultFontSize/4, Main.canceltextwidth+Main.defaultFontSize, Draw.loadingFont.getSize()+Main.defaultFontSize/2);                

                if (drawCanvas.loading
                        && event.getX() > drawScroll.getWidth() / 2 - Main.canceltextwidth / 2
                                - Main.defaultFontSize / 2
                        && event.getX() < drawScroll.getWidth() / 2 + Main.canceltextwidth / 2
                                + Main.defaultFontSize / 2
                        && event.getY() > frame.getHeight() * 1 / 3 + Draw.loadingFont.getSize() * 3
                                - Main.defaultFontSize / 4
                        && event.getY() < frame.getHeight() * 1 / 3 + Draw.loadingFont.getSize() * 4
                                + Main.defaultFontSize / 2) {
                    if (!Main.cancelhover) {
                        Main.cancelhover = true;
                        Main.glassPane.requestFocus();
                    }
                } else {
                    if (Main.cancelhover) {
                        Main.cancelhover = false;
                        Main.glassPane.requestFocus(false);
                    }
                }
            }
        });

        background.put((byte) 'A', 0.3);
        background.put((byte) 'C', 0.2);
        background.put((byte) 'G', 0.2);
        background.put((byte) 'T', 0.3);

        bases = new Hashtable<String, String>();
        bases.put("A", "A");
        bases.put("C", "C");
        bases.put("G", "G");
        bases.put("T", "T");
        bases.put("N", "N");
        bases.put("delA", "delA");
        bases.put("delC", "delC");
        bases.put("delG", "delG");
        bases.put("delT", "delT");
        bases.put("insA", "insA");
        bases.put("insC", "insC");
        bases.put("insG", "insG");
        bases.put("insT", "insT");

        chromDraw = new ChromDraw(drawWidth, chromHeight);

        VariantCaller.main(argsit);
        PeakCaller.main(argsit);
        tablebrowser = new TableBrowser();
        bedconverter = new BEDconvert();

        try {

            File annodir;

            File[] annotations;
            addGenome.addMouseListener(this);
            genome = new JMenu("Genomes");
            genome.setName("genomeMenu");
            genome.add(addGenome);
            genome.addComponentListener(this);
            File[] fastadir;
            String[] empty = {};

            refModel = new DefaultComboBoxModel<String>(empty);

            refDropdown = new SteppedComboBox(refModel);
            refDropdown.addMouseListener(this);
            String[] emptygenes = {};
            refDropdown.addActionListener(refDropActionListener);

            geneModel = new DefaultComboBoxModel<String>(emptygenes);
            geneDropdown = new SteppedComboBox(geneModel);
            geneDropdown.addMouseListener(this);
            if (genomes != null) {
                for (int i = 0; i < genomes.length; i++) {
                    if (!genomes[i].isDirectory()) {
                        continue;
                    }
                    annodir = new File(genomes[i].getAbsolutePath() + "/annotation/");
                    if (genomes[i].isDirectory()) {
                        fastadir = genomes[i].listFiles();
                        for (int f = 0; f < fastadir.length; f++) {
                            if (fastadir[f].isDirectory()) {
                                continue;
                            }
                            if (fastadir[f].getName().contains(".fai")) {
                                continue;
                            } else if (fastadir[f].getName().contains(".fa")) {
                                fastahash.put(genomes[i].getName(), fastadir[f]);
                            }
                        }
                    }

                    annotations = annodir.listFiles();
                    genomehash.put(genomes[i].getName(), new ArrayList<File>());

                    refModel.addElement(genomes[i].getName());
                    if (genomes[i].getName().length() > reflength) {
                        reflength = genomes[i].getName().length();
                    }
                    JMenu addMenu = new JMenu(genomes[i].getName());
                    addMenu.addMouseListener(this);
                    addMenu.setName(genomes[i].getName());
                    JMenuItem addAnnotation = new JMenuItem("Add new annotation file...");
                    addAnnotation.addMouseListener(this);
                    addAnnotation.setName("add_annotation");
                    addMenu.add(addAnnotation);
                    JLabel addLabel = new JLabel("  Select annotation: ");
                    labels.add(addLabel);
                    addMenu.add(addLabel);
                    addMenu.add(new JSeparator());

                    genome.add(addMenu);
                    addMenu.addComponentListener(this);
                    if (annotations != null) {
                        for (int j = 0; j < annotations.length; j++) {
                            annofiles = annotations[j].listFiles();
                            for (int f = 0; f < annofiles.length; f++) {
                                if (annofiles[f].getName().endsWith(".bed.gz")) {
                                    if (annofiles[f].getName()
                                            .substring(0, annofiles[f].getName().indexOf(".bed.gz"))
                                            .length() > annolength) {
                                        annolength = annofiles[f].getName().length();
                                    }

                                    genomehash.get(genomes[i].getName()).add(annofiles[f].getAbsoluteFile());
                                    JMenuItem additem = new JMenuItem(annofiles[f].getName().substring(0,
                                            annofiles[f].getName().indexOf(".bed.gz")));
                                    additem.setName(annofiles[f].getName().substring(0,
                                            annofiles[f].getName().indexOf(".bed.gz")));
                                    additem.addMouseListener(this);
                                    addMenu.add(additem);
                                    additem.addComponentListener(this);
                                    break;
                                }
                            }
                        }
                    }
                }
                refModel.addElement("Add new reference...");

            }

            if (genomes.length == 0) {
                /*if(Launcher.firstStart) {
                   Main.writeToConfig("FirstStart=false");
                }*/
                AddGenome.createAndShowGUI();
                AddGenome.frame.setTitle("Add new genome");

                AddGenome.remove.setEnabled(false);
                AddGenome.download.setEnabled(false);

                AddGenome.frame.setLocation((int) (screenSize.getWidth() / 2 - AddGenome.frame.getWidth() / 2),
                        (int) (screenSize.getHeight() / 6));

                AddGenome.frame.setState(JFrame.NORMAL);
                AddGenome.frame.setVisible(true);
                AddGenome.frame.setAlwaysOnTop(true);
                /*
                WelcomeScreen.main(args);
                WelcomeScreen.frame.setVisible(true);
                WelcomeScreen.frame.setLocation(frame.getLocationOnScreen().x+frame.getWidth()/2 - WelcomeScreen.frame.getWidth()/2, frame.getLocationOnScreen().y+frame.getHeight()/6);
                */
                if (genomes.length != 0) {
                    if (!genomehash.containsKey(defaultGenome)) {

                        setChromDrop(genomes[0].getName());
                        defaultGenome = genomes[0].getName();
                    } else {

                        setChromDrop(defaultGenome);
                    }
                    getBands();
                    getExons();
                } else {
                    setChromDrop(null);
                }
            } else {
                if (!genomehash.containsKey(defaultGenome)) {

                    setChromDrop(genomes[0].getName());
                    defaultGenome = genomes[0].getName();

                } else {

                    setChromDrop(defaultGenome);
                }
                getBands();
                getExons();
            }

            if (Launcher.firstStart) {

                WelcomeScreen.createAndShowGUI();
                WelcomeScreen.frame.setLocation(
                        (int) (screenSize.getWidth() / 2 - WelcomeScreen.frame.getWidth() / 2),
                        (int) (screenSize.getHeight() / 6));
                WelcomeScreen.frame.setVisible(true);
            }
            setMenuBar();
            setButtons();
            Settings.main(args);

            // Settings.main(args);
            frame.requestFocus();

            drawCanvas.addKeyListener(this);
            bedCanvas.addKeyListener(this);
            setFonts();
            chromLabel.setText("Chromosome " + chromosomeDropdown.getSelectedItem().toString());
            CheckUpdates check = new CheckUpdates();
            check.execute();
            //   Main.drawCanvas.loading("test");
            Main.drawCanvas.splits.get(0)
                    .setCytoImage(Main.chromDraw.createBands(Main.drawCanvas.splits.get(0)));
        } catch (Exception e) {
            e.printStackTrace();
        }

    } catch (Exception ex) {
        ex.printStackTrace();
        Main.showError(ex.getMessage(), "Error");

    }

}