Example usage for java.awt Cursor DEFAULT_CURSOR

List of usage examples for java.awt Cursor DEFAULT_CURSOR

Introduction

In this page you can find the example usage for java.awt Cursor DEFAULT_CURSOR.

Prototype

int DEFAULT_CURSOR

To view the source code for java.awt Cursor DEFAULT_CURSOR.

Click Source Link

Document

The default cursor type (gets set if no cursor is defined).

Usage

From source file:org.javaswift.cloudie.CloudiePanel.java

@Override
public void onDone() {
    busyCnt--;//from   w  w w.j a v a 2 s.c o  m
    if (busyCnt == 0) {
        setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
        statusPanel.onEnd();
    }
    enableDisable();
}

From source file:org.fhaes.jsea.JSEAFrame.java

/**
 * Actually perform the Superposed Epoch Analysis
 *//*from   ww  w  .  j a  va 2s . c  om*/
private void runAnalysis() {

    // Create default segment if segmentation was selected but not defined
    if (segmentationPanel.chkSegmentation.isSelected()
            && segmentationPanel.table.tableModel.getSegments().isEmpty()) {
        segmentationPanel.table.tableModel
                .addSegment(new SegmentModel(Integer.parseInt(this.firstPossibleYear.toString()),
                        Integer.parseInt(this.lastPossibleYear.toString())));
        segmentationPanel.table.setEarliestYear(Integer.parseInt(this.firstPossibleYear.toString()));
        segmentationPanel.table.setLatestYear(Integer.parseInt(this.lastPossibleYear.toString()));
    }

    // Run the analysis via the JSEAProgressDialog
    new JSEAProgressDialog(this);

    try {
        if (jsea == null)
            return;

        // Populate summary text field
        this.txtSummary.setText(jsea.getReportText());
        setScrollBarToTop();

        // Populate actual data table
        tblActual.setModel(TableUtil.createTableModel(jsea.getActualTableText(), null));
        tblActual.packAll();

        // Populate simulation data table
        tblSimulation.setModel(TableUtil.createTableModel(jsea.getSimulationTableText(), null));
        tblSimulation.packAll();

        // Populate chart panel
        populateSegmentComboBoxAndDrawChart(segmentationPanel.table.tableModel);

        setAnalysisAvailable(true);
    } catch (Exception e) {
        JOptionPane.showMessageDialog(this,
                "An error was caught while running the analysis.\nPlease check the logs for further information",
                "Error", JOptionPane.ERROR_MESSAGE);
        log.error("Error caught when running jSEA analysis");
        e.printStackTrace();
        jsea = null;
        setAnalysisAvailable(false);
    } finally {
        setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    }
}

From source file:org.bigwiv.blastgraph.gui.BlastGraphFrame.java

private void initComponents() {

    URL icon;/*from  w  ww . j a  v  a 2s  .  com*/
    icon = getClass().getResource("/org/bigwiv/blastgraph/icons/icon.png");
    this.setIconImage(Toolkit.getDefaultToolkit().createImage(icon));
    JComponent pane;
    pane = (JComponent) getContentPane();

    // ====================Menu Setting=======================
    newItem = new JMenuItem("New From Blast");
    newItem.setMnemonic('n');
    newItem.addActionListener(commandActionListener);

    openItem = new JMenuItem("Open");
    openItem.setMnemonic('o');
    openItem.addActionListener(commandActionListener);

    appendGraphItem = new JMenuItem("Append Graph");
    appendGraphItem.setMnemonic('a');
    appendGraphItem.addActionListener(commandActionListener);

    saveItem = new JMenuItem("Save");
    saveItem.setMnemonic('s');
    saveItem.addActionListener(commandActionListener);

    saveAsGraphItem = new JMenuItem("Save As");
    saveAsGraphItem.addActionListener(commandActionListener);

    exportGraphItem = new JMenuItem("Export");
    exportGraphItem.addActionListener(commandActionListener);

    saveCurGraphItem = new JMenuItem("Save Current Graph");
    saveCurGraphItem.addActionListener(commandActionListener);

    saveCurImgItem = new JMenuItem("Save Image");
    saveCurImgItem.addActionListener(commandActionListener);

    saveAllVertexAttrItem = new JMenuItem("Save Vertex Attribute");
    saveAllVertexAttrItem.addActionListener(commandActionListener);

    saveCurVertexAttrItem = new JMenuItem("Save Vertex Attribute");
    saveCurVertexAttrItem.addActionListener(commandActionListener);

    saveAsMenu = new JMenu("Save As");
    saveAsMenu.add(saveAsGraphItem);
    saveAsMenu.add(saveAllVertexAttrItem);

    saveCurGraphMenu = new JMenu("Save Current Graph");
    saveCurGraphMenu.add(saveCurGraphItem);
    saveCurGraphMenu.add(saveCurImgItem);
    saveCurGraphMenu.add(saveCurVertexAttrItem);

    printItem = new JMenuItem("Print...");
    printItem.setMnemonic('p');
    printItem.addActionListener(commandActionListener);

    importVertexAttrItem = new JMenuItem("Import Vertex Attribute");
    importVertexAttrItem.addActionListener(commandActionListener);

    closeItem = new JMenuItem("Close");
    closeItem.setMnemonic('c');
    closeItem.addActionListener(commandActionListener);

    exitItem = new JMenuItem("Exit");
    exitItem.setMnemonic('x');
    exitItem.addActionListener(commandActionListener);

    fileMenu = new JMenu("File");
    fileMenu.setMnemonic('f');
    fileMenu.add(newItem);
    fileMenu.add(openItem);
    fileMenu.add(appendGraphItem);
    fileMenu.add(new JSeparator());
    fileMenu.add(closeItem);
    fileMenu.add(new JSeparator());
    fileMenu.add(saveItem);
    fileMenu.add(saveAsMenu);
    fileMenu.add(saveCurGraphMenu);
    fileMenu.add(new JSeparator());
    fileMenu.add(printItem);
    fileMenu.add(new JSeparator());
    fileMenu.add(importVertexAttrItem);
    fileMenu.add(exportGraphItem);
    fileMenu.add(new JSeparator());
    fileMenu.add(exitItem);

    // edit menu
    undoItem = new JMenuItem("Undo");
    redoItem = new JMenuItem("Redo");
    Global.COMMAND_MANAGER.registerUndoRedoItem(undoItem, redoItem);
    removeSingleItem = new JMenuItem("Remove Single Vertices");
    removeSingleItem.addActionListener(commandActionListener);
    filterItem = new JMenuItem("Filt Graph");
    filterItem.addActionListener(commandActionListener);
    settingItem = new JMenuItem("Setting");
    settingItem.addActionListener(commandActionListener);

    markovClusterItem = new JMenuItem("Markov Cluster");
    markovClusterItem.addActionListener(commandActionListener);

    // genomeNumFiltItem = new JMenuItem("GenomeNum Filt");
    // genomeNumFiltItem.addActionListener(commandActionListener);

    // removeSingleLinkageItem = new JMenuItem("Remove Single Linkage");
    // removeSingleLinkageItem.addActionListener(commandActionListener);

    editMenu = new JMenu("Edit");
    editMenu.setMnemonic('e');
    editMenu.add(undoItem);
    editMenu.add(redoItem);
    editMenu.add(filterItem);
    editMenu.add(markovClusterItem);
    editMenu.add(removeSingleItem);
    // editMenu.add(genomeNumFiltItem);
    // editMenu.add(removeSingleLinkageItem);
    editMenu.add(settingItem);

    // Tools Item
    geneContentItem = new JMenuItem("Gene Content Table");
    geneContentItem.addActionListener(commandActionListener);

    batchSaveItem = new JMenuItem("Batch Save");
    batchSaveItem.addActionListener(commandActionListener);

    mstItem = new JMenuItem("Minimum Spanning Tree");
    mstItem.addActionListener(commandActionListener);

    viewNeighborItem = new JMenuItem("View Neighbor of...");
    viewNeighborItem.addActionListener(commandActionListener);

    //
    // tempWorkItem = new JMenuItem("Temp Work");
    // tempWorkItem.addActionListener(commandActionListener);

    toolsMenu = new JMenu("Tools");
    toolsMenu.setMnemonic('t');
    toolsMenu.add(geneContentItem);
    toolsMenu.add(viewNeighborItem);
    toolsMenu.add(mstItem);
    toolsMenu.add(batchSaveItem);
    // toolsMenu.add(tempWorkItem);

    // graph Menu
    graphMenu = new JMenu("Graph");
    previousItem = new JMenuItem("Previous");
    previousItem.addActionListener(commandActionListener);
    nextItem = new JMenuItem("Next");
    nextItem.addActionListener(commandActionListener);
    resortItem = new JMenuItem("Resort graphs");
    resortItem.addActionListener(commandActionListener);

    graphMenu.add(nextItem);
    graphMenu.add(previousItem);
    graphMenu.add(resortItem);

    // help Menu
    helpContentItem = new JMenuItem("Online Manual");
    helpContentItem.addActionListener(commandActionListener);
    aboutItem = new JMenuItem("About BlastGraph");
    aboutItem.addActionListener(commandActionListener);

    helpMenu = new JMenu("Help");
    helpMenu.add(helpContentItem);
    helpMenu.add(aboutItem);

    // menu bar
    menuBar = new JMenuBar();
    menuBar.add(fileMenu);
    menuBar.add(editMenu);
    menuBar.add(graphMenu);
    menuBar.add(toolsMenu);
    menuBar.add(helpMenu);

    setJMenuBar(menuBar);

    // ===================mainPanel Setting===================
    GridBagManager.reset();
    GridBagManager.GRID_BAG.fill = GridBagConstraints.BOTH;
    GridBagManager.GRID_BAG.anchor = GridBagConstraints.FIRST_LINE_START;
    GridBagManager.GRID_BAG.weightx = 0;
    GridBagManager.GRID_BAG.weighty = 0;
    GridBagManager.GRID_BAG.insets = new Insets(2, 2, 1, 1);

    mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout());
    pane.add(mainPanel);

    hsplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    hsplitPane.setContinuousLayout(true);
    hsplitPane.setOneTouchExpandable(true);
    hsplitPane.setResizeWeight(0.9);

    // ===================toolBarPanel Setting===================

    // graph file toolbar
    fileToolBar = new JToolBar();
    fileToolBar.setRollover(true);
    newButton = new JButton();
    newButton.setBorderPainted(false);
    newButton.setMnemonic('n');
    newButton.setToolTipText("New From Blast");
    newButton.addActionListener(commandActionListener);
    icon = getClass().getResource("/org/bigwiv/blastgraph/icons/filenew.png");
    // System.out.println(icon);
    newButton.setIcon(new ImageIcon(icon));

    openButton = new JButton();
    openButton.setBorderPainted(false);
    openButton.setMnemonic('o');
    openButton.setToolTipText("Open");
    openButton.addActionListener(commandActionListener);
    icon = getClass().getResource("/org/bigwiv/blastgraph/icons/fileopen.png");
    openButton.setIcon(new ImageIcon(icon));

    saveButton = new JButton();
    saveButton.setBorderPainted(false);
    saveButton.setMnemonic('s');
    saveButton.setToolTipText("Save");
    saveButton.addActionListener(commandActionListener);
    icon = getClass().getResource("/org/bigwiv/blastgraph/icons/filesave.png");
    saveButton.setIcon(new ImageIcon(icon));

    saveCurImgButton = new JButton();
    saveCurImgButton.setBorderPainted(false);
    saveCurImgButton.setToolTipText("Save current image");
    saveCurImgButton.addActionListener(commandActionListener);
    icon = getClass().getResource("/org/bigwiv/blastgraph/icons/saveimage.png");
    saveCurImgButton.setIcon(new ImageIcon(icon));

    printButton = new JButton();
    printButton.setBorderPainted(false);
    printButton.setToolTipText("Print...");
    printButton.addActionListener(commandActionListener);
    icon = getClass().getResource("/org/bigwiv/blastgraph/icons/fileprint.png");
    printButton.setIcon(new ImageIcon(icon));

    fileToolBar.add(newButton);
    fileToolBar.add(openButton);
    fileToolBar.add(saveButton);
    fileToolBar.add(saveCurImgButton);
    fileToolBar.add(printButton);

    // graph control toolbar
    graphToolBar = new JToolBar();
    graphToolBar.setRollover(true);

    previousButton = new JButton();
    previousButton.setBorderPainted(false);
    previousButton.setToolTipText("Previous graph");
    previousButton.addActionListener(commandActionListener);
    icon = getClass().getResource("/org/bigwiv/blastgraph/icons/previous.png");
    previousButton.setIcon(new ImageIcon(icon));

    indexField = new JTextField();
    indexField.setSize(new Dimension(25, 16));
    indexField.setMinimumSize(new Dimension(25, 16));
    indexField.setPreferredSize(new Dimension(25, 16));
    indexField.addKeyListener(keyListener);

    nextButton = new JButton();
    nextButton.setBorderPainted(false);
    nextButton.setToolTipText("Next graph");
    nextButton.addActionListener(commandActionListener);
    icon = getClass().getResource("/org/bigwiv/blastgraph/icons/next.png");
    nextButton.setIcon(new ImageIcon(icon));

    filterButton = new JButton();
    filterButton.setBorderPainted(false);
    filterButton.setToolTipText("Filt graph");
    filterButton.addActionListener(commandActionListener);
    icon = getClass().getResource("/org/bigwiv/blastgraph/icons/filter.png");
    filterButton.setIcon(new ImageIcon(icon));

    resortButton = new JButton();
    resortButton.setBorderPainted(false);
    resortButton.setToolTipText("Resort graph");
    resortButton.addActionListener(commandActionListener);
    icon = getClass().getResource("/org/bigwiv/blastgraph/icons/resort.png");
    resortButton.setIcon(new ImageIcon(icon));

    searchField = new JTextField();
    searchField.setSize(new Dimension(60, 16));
    searchField.setMinimumSize(new Dimension(60, 16));
    searchField.setPreferredSize(new Dimension(60, 16));
    searchField.addKeyListener(keyListener);

    searchButton = new JButton();
    searchButton.setBorderPainted(false);
    searchButton.setToolTipText("Search");
    searchButton.addActionListener(commandActionListener);
    icon = getClass().getResource("/org/bigwiv/blastgraph/icons/search.png");
    searchButton.setIcon(new ImageIcon(icon));

    graphToolBar.add(filterButton);
    graphToolBar.add(resortButton);
    // graphToolBar.add(new JToolBar.Separator());
    graphToolBar.add(previousButton);
    graphToolBar.add(indexField);
    graphToolBar.add(nextButton);
    graphToolBar.add(searchField);
    graphToolBar.add(searchButton);

    // view toolbar (modebox & layoutbox)
    viewToolBar = new JToolBar();
    viewToolBar.setRollover(true);
    modeBox = graphMouse.getModeComboBox();
    modeBox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            int index = modeBox.getSelectedIndex();
            if (index == 2) {
                int annotCount = annotationToolBar.getComponentCount();
                for (int i = 0; i < annotCount; i++) {
                    annotationToolBar.getComponent(i).setEnabled(true);
                }
            } else {
                int annotCount = annotationToolBar.getComponentCount();
                for (int i = 0; i < annotCount; i++) {
                    annotationToolBar.getComponent(i).setEnabled(false);
                }
            }

        }
    });
    layoutBox = this.getLayoutComboBox();
    viewToolBar.add(modeBox);
    viewToolBar.add(layoutBox);

    colorComboBox = new JComboBox(new String[] { "vertex color", "index", "strand", "genomeAcc", "organism" });
    viewToolBar.add(colorComboBox);

    // add additional menu to graphMenu
    modeMenu = graphMouse.getModeMenu();
    modeMenu.setText("Mode");
    layoutMenu = getLayoutMenu();
    layoutMenu.setText("Layout");
    graphMenu.add(modeMenu);
    graphMenu.add(layoutMenu);

    // annotation toolbar
    AnnotationControls<HitVertex, ValueEdge> annotationControls = new AnnotationControls<HitVertex, ValueEdge>(
            annotatingPlugin);
    annotationToolBar = annotationControls.getAnnotationsToolBar();
    ((JButton) annotationToolBar.getComponent(1)).setBorderPainted(false);
    ((JToggleButton) annotationToolBar.getComponent(2)).setBorderPainted(false);

    // add toolbars to toolBarPanel
    toolBarPanel = new JPanel();
    toolBarPanel.setLayout(new ModifiedFlowLayout(ModifiedFlowLayout.LEFT, 0, 0));
    toolBarPanel.setBorder(new EtchedBorder());
    toolBarPanel.add(fileToolBar);
    toolBarPanel.add(graphToolBar);
    toolBarPanel.add(viewToolBar);
    toolBarPanel.add(annotationToolBar);

    mainPanel.add(toolBarPanel, BorderLayout.NORTH);
    mainPanel.add(hsplitPane, BorderLayout.CENTER);

    // GridBagManager.add(mainPanel, toolBarPanel, 0, 0, 1, 1);
    // GridBagManager.add(mainPanel, hsplitPane, 0, 1, 1, 1);

    // mainPanel.add(toolBarPanel, BorderLayout.NORTH);

    // ===================vsplitPane Setting=================
    vsplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    vsplitPane.setContinuousLayout(true);
    vsplitPane.setOneTouchExpandable(true);
    vsplitPane.setResizeWeight(0.9);

    hsplitPane.setLeftComponent(vsplitPane);
    // GridBagManager.GRID_BAG.weightx = 0.9;
    // GridBagManager.GRID_BAG.weighty = 1;
    // GridBagManager.add(mainPanel, vsplitPane, 0, 1, 1, 2);
    // mainPanel.add(vsplitPane, BorderLayout.CENTER);

    // ===================vvPanel Setting===================

    vvPanel = new GraphZoomScrollPane(vv);
    vsplitPane.setTopComponent(vvPanel);

    // ===================Tab Panel Setting=======================
    // progressPanel = new ProgressPanel();

    verticesTable = new VerticesTable();
    verticesTable.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            int row = verticesTable.rowAtPoint(e.getPoint());
            int col = verticesTable.columnAtPoint(e.getPoint());
            // System.out.println(row + " " + col);
            String value = verticesTable.getValueAt(row, col).toString();
            // System.out.println(value);
            if (Global.graph.containsVertex(new HitVertex(value))) {
                for (int i = 0; i < subSetList.size(); i++) {
                    if (subSetList.get(i).contains(new HitVertex(value))) {
                        curGraph = FilterUtils.createInducedSubgraph(subSetList.get(i), Global.graph);
                        PickedState<HitVertex> pickedVertexState = vv.getPickedVertexState();

                        // picked is a reference to picked vertices
                        // use a temp set to avoid concurrent modification
                        Set<HitVertex> picked = pickedVertexState.getPicked();
                        Set<HitVertex> temp = new HashSet<HitVertex>();
                        for (HitVertex hitVertex : picked) {
                            temp.add(hitVertex);
                        }
                        for (HitVertex hv : temp) {
                            pickedVertexState.pick(hv, false);
                        }

                        pickedVertexState.pick(new HitVertex(value), true);
                        // refreshSubGraphView();
                        return;
                    }
                }
            }
        }
    });

    verticesTable.addMouseMotionListener(new MouseMotionAdapter() {
        @Override
        public void mouseMoved(MouseEvent e) {
            int row = verticesTable.rowAtPoint(e.getPoint());
            int col = verticesTable.columnAtPoint(e.getPoint());
            String value = verticesTable.getValueAt(row, col).toString();
            // System.out.println(value);
            if (Global.graph.containsVertex(value)) {
                Cursor normalCursor = new Cursor(Cursor.HAND_CURSOR);
                setCursor(normalCursor);
            } else {
                Cursor normalCursor = new Cursor(Cursor.DEFAULT_CURSOR);
                setCursor(normalCursor);
            }
        }
    });
    verticesPanel = new JPanel();
    verticesPanel.setLayout(new GridLayout());
    verticesPanel.add(new JScrollPane(verticesTable));

    edgesTable = new EdgesTable();
    edgesPanel = new JPanel();
    edgesPanel.setLayout(new GridLayout());
    edgesPanel.add(new JScrollPane(edgesTable));

    tabbedPane = new JTabbedPane();
    tabbedPane.addTab("Vertices", verticesPanel);
    tabbedPane.addTab("Edges", edgesPanel);
    vsplitPane.setBottomComponent(tabbedPane);

    graphMouse.addPichedChangeListener(verticesTable, edgesTable);

    // ===================Info Panel Setting===================
    infoPanel = new JPanel(new GridBagLayout());
    GridBagManager.GRID_BAG.weightx = 0.1;
    GridBagManager.GRID_BAG.weighty = 1;
    hsplitPane.setRightComponent(infoPanel);

    JPanel mainInfoPanel = new JPanel(new GridBagLayout());
    mainInfoPanel
            .setBorder(BorderFactory.createTitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "Main Info"));

    JPanel currentInfoPanel = new JPanel(new GridBagLayout());
    currentInfoPanel.setBorder(
            BorderFactory.createTitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "Current Graph"));
    JPanel selectedInfoPanel = new JPanel(new GridBagLayout());
    selectedInfoPanel
            .setBorder(BorderFactory.createTitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "Selected"));

    JPanel statisticsInfoPanel = new JPanel(new GridBagLayout());
    statisticsInfoPanel
            .setBorder(BorderFactory.createTitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "Statistics"));

    JPanel progressInfoPanel = new JPanel(new GridBagLayout());
    progressInfoPanel
            .setBorder(BorderFactory.createTitledBorder(new EtchedBorder(EtchedBorder.LOWERED), "Progress"));

    GridBagManager.GRID_BAG.anchor = GridBagConstraints.NORTH;
    GridBagManager.GRID_BAG.fill = GridBagConstraints.HORIZONTAL;
    GridBagManager.GRID_BAG.weighty = 0;
    GridBagManager.add(infoPanel, mainInfoPanel, 0, 1, 1, 1);
    GridBagManager.add(infoPanel, currentInfoPanel, 0, 2, 1, 1);
    GridBagManager.add(infoPanel, selectedInfoPanel, 0, 3, 1, 1);
    GridBagManager.GRID_BAG.weighty = 0.5;
    GridBagManager.GRID_BAG.fill = GridBagConstraints.BOTH;
    GridBagManager.add(infoPanel, statisticsInfoPanel, 0, 4, 1, 1);
    GridBagManager.add(infoPanel, progressInfoPanel, 0, 5, 1, 1);

    // mainInfoPanel
    {
        JLabel vertices = new JLabel("Vertices:");
        vertexCountLabel = new JLabel("0");
        JLabel edges = new JLabel("Edges:");
        edgeCountLabel = new JLabel("0");
        JLabel subGraphs = new JLabel("SubGraphs:");
        subGraphCountLabel = new JLabel("0");
        GridBagManager.GRID_BAG.anchor = GridBagConstraints.WEST;
        GridBagManager.GRID_BAG.weightx = 0.5;
        GridBagManager.add(mainInfoPanel, vertices, 0, 0, 1, 1);
        GridBagManager.add(mainInfoPanel, edges, 0, 1, 1, 1);
        GridBagManager.add(mainInfoPanel, subGraphs, 0, 2, 1, 1);
        GridBagManager.GRID_BAG.anchor = GridBagConstraints.EAST;
        GridBagManager.GRID_BAG.weightx = 0.5;
        GridBagManager.add(mainInfoPanel, vertexCountLabel, 1, 0, 1, 1);
        GridBagManager.add(mainInfoPanel, edgeCountLabel, 1, 1, 1, 1);
        GridBagManager.add(mainInfoPanel, subGraphCountLabel, 1, 2, 1, 1);

    } // end of mainInfoPanel

    // currentInfoPanel
    {
        JLabel vertices = new JLabel("Vertices:");
        currentVertexCountLabel = new JLabel("0");

        JLabel edges = new JLabel("Edges:");
        currentEdgeCountLabel = new JLabel("0");

        JLabel acc = new JLabel("ACC:");
        currentAccLabel = new JLabel("0");

        GridBagManager.GRID_BAG.anchor = GridBagConstraints.WEST;
        GridBagManager.GRID_BAG.weightx = 0.5;
        GridBagManager.add(currentInfoPanel, vertices, 0, 0, 1, 1);
        GridBagManager.add(currentInfoPanel, edges, 0, 1, 1, 1);
        GridBagManager.add(currentInfoPanel, acc, 0, 2, 1, 1);
        GridBagManager.GRID_BAG.anchor = GridBagConstraints.EAST;
        GridBagManager.GRID_BAG.weightx = 0.5;
        GridBagManager.add(currentInfoPanel, currentVertexCountLabel, 1, 0, 1, 1);
        GridBagManager.add(currentInfoPanel, currentEdgeCountLabel, 1, 1, 1, 1);
        GridBagManager.add(currentInfoPanel, currentAccLabel, 1, 2, 1, 1);

    } // end of currentInfoPanel

    // selectedInfoPanel
    {
        JLabel vertices = new JLabel("Vertices:");
        selectedVertexCountLabel = new JLabel("0");
        JLabel edges = new JLabel("Edges:");
        selectedEdgeCountLabel = new JLabel("0");
        GridBagManager.GRID_BAG.anchor = GridBagConstraints.WEST;
        GridBagManager.GRID_BAG.weightx = 0.5;
        GridBagManager.add(selectedInfoPanel, vertices, 0, 0, 1, 1);
        GridBagManager.add(selectedInfoPanel, edges, 0, 1, 1, 1);
        GridBagManager.GRID_BAG.anchor = GridBagConstraints.EAST;
        GridBagManager.GRID_BAG.weightx = 0.5;
        GridBagManager.add(selectedInfoPanel, selectedVertexCountLabel, 1, 0, 1, 1);
        GridBagManager.add(selectedInfoPanel, selectedEdgeCountLabel, 1, 1, 1, 1);
        CollectionChangeListener<HitVertex> svListener = new CollectionChangeListener<HitVertex>() {

            @Override
            public void onCollectionChange(Set<HitVertex> set) {
                selectedVertexCountLabel.setText("" + set.size());
            }
        };

        CollectionChangeListener<ValueEdge> veListener = new CollectionChangeListener<ValueEdge>() {

            @Override
            public void onCollectionChange(Set<ValueEdge> set) {
                selectedEdgeCountLabel.setText("" + set.size());
            }
        };

        graphMouse.addPichedChangeListener(svListener, veListener);

    } // end of selectedInfoPanel

    {// statistics Panel
        GridBagManager.GRID_BAG.anchor = GridBagConstraints.NORTH;
        GridBagManager.GRID_BAG.fill = GridBagConstraints.BOTH;
        GridBagManager.add(statisticsInfoPanel, graphStatisticsPanel, 0, 0, 1, 1);
    } // statistics Panel

    {// progressInfoPanel
        GridBagManager.GRID_BAG.anchor = GridBagConstraints.NORTH;
        GridBagManager.GRID_BAG.fill = GridBagConstraints.BOTH;
        GridBagManager.add(progressInfoPanel, progressPanel, 0, 0, 1, 1);
    } // progressInfoPanel
      // set frame size
    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    setSize((screen.width * 3) / 4, (screen.height * 9) / 10);
    setLocation(screen.width / 6, screen.height / 16);

    refreshUI(false);
}

From source file:org.gumtree.vis.plot1d.Plot1DPanel.java

@Override
public void mousePressed(MouseEvent e) {
    int mods = e.getModifiers();
    //        if (isMaskingEnabled() && (mods & maskingKeyMask) != 0) {
    if (isInternalLegendEnabled && isInternalLegendSelected) {
        int cursorType = findCursorOnSelectedItem(e.getX(), e.getY());
        if (cursorType == Cursor.DEFAULT_CURSOR) {
            Rectangle2D screenDataArea = getScreenDataArea(e.getX(), e.getY());
            if (screenDataArea != null) {
                legendPoint = e.getPoint();
            } else {
                legendPoint = null;/*www  .ja  v a2 s  .  c  o  m*/
            }
        } else {
            if (cursorType == Cursor.MOVE_CURSOR) {
                legendPoint = e.getPoint();
            }
        }
    }
    if (isMaskingEnabled()) {
        // Prepare masking service.
        int cursorType = findCursorOnSelectedItem(e.getX(), e.getY());
        if (cursorType == Cursor.DEFAULT_CURSOR && (mods & maskingKeyMask) != 0) {
            Rectangle2D screenDataArea = getScreenDataArea(e.getX(), e.getY());
            if (screenDataArea != null) {
                this.maskPoint = getPointInRectangle(e.getX(), e.getY(), screenDataArea).getX();
            } else {
                this.maskPoint = Double.NaN;
            }
        } else {
            if (cursorType == Cursor.MOVE_CURSOR) {
                //                 this.maskMovePoint = translateScreenToChart(
                //                       translateScreenToJava2D(e.getPoint())).getX();
                Insets insets = getInsets();
                this.maskMovePoint = ChartMaskingUtilities.translateScreenX(
                        (e.getX() - insets.left) / getScaleX(), getScreenDataArea(), getChart());
            }
            setMaskDragIndicator(cursorType);
        }
    }
    if (getMaskDragIndicator() == Cursor.DEFAULT_CURSOR) {
        super.mousePressed(e);
    }
}

From source file:com.josescalia.tumblr.form.TumblrImageViewer.java

private void btnDownloadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDownloadActionPerformed
    frame = (MainFrame) this.getTopLevelAncestor();
    form = this;//from ww  w. j  a v a 2  s . c  o m
    /*since the application using cache, all we need is only copying target file to destination folder*/

    //busy cursor and progress bar panel and frame
    form.setCursor(new Cursor(Cursor.WAIT_CURSOR));
    frame.setCursor(new Cursor(Cursor.WAIT_CURSOR));
    frame.startProgressBar("Downloading");
    new SwingWorker<String, String>() {
        @Override
        protected String doInBackground() throws Exception {
            int successCount = 0;
            int failedCount = 0;
            for (DownloadableImage image : imgList) {
                String fileName = image.getUrl().substring(image.getUrl().lastIndexOf("/") + 1);
                String downloadUrl = image.getUrl();
                File targetFile = new File(BinaryCacheUtil.getBinaryImagePath(".cache", fileName, downloadUrl));
                try {
                    FileSystemUtils.copyRecursively(targetFile, new File(downloadPath + "//" + fileName));
                    successCount++;
                } catch (IOException e) {
                    logger.error("Copy Failed Exception : " + e.getMessage());
                    failedCount++;
                }
            }
            return "Download file finished : \n" + successCount + " file(s) downloaded successfully \n"
                    + failedCount + "failed to download";
        }

        @Override
        protected void done() {
            try {
                UIAlert.showInformation(null, get());
            } catch (InterruptedException e) {
                logger.error(e);
            } catch (ExecutionException e) {
                logger.error(e);
            }
            form.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
            frame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
            frame.stopProgressBar("");
        }
    }.execute();

}

From source file:edu.harvard.i2b2.previousquery.QueryPreviousRunsPanel.java

public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equalsIgnoreCase("Rename ...")) {
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getSelectionPath().getLastPathComponent();
        QueryMasterData ndata = (QueryMasterData) node.getUserObject();
        Object inputValue = JOptionPane.showInputDialog(this, "Rename this query to: ", "Rename Query Dialog",
                JOptionPane.PLAIN_MESSAGE, null, null,
                ndata.name().substring(0, ndata.name().lastIndexOf("[") - 1));

        if (inputValue != null) {
            String newQueryName = (String) inputValue;
            String requestXml = ndata.writeRenameQueryXML(newQueryName);
            lastRequestMessage = requestXml;

            setCursor(new Cursor(Cursor.WAIT_CURSOR));

            String response = QueryListNamesClient.sendQueryRequestREST(requestXml);
            if (response.equalsIgnoreCase("CellDown")) {
                final JPanel parent = this;
                java.awt.EventQueue.invokeLater(new Runnable() {
                    public void run() {
                        JOptionPane.showMessageDialog(parent,
                                "Trouble with connection to the remote server, "
                                        + "this is often a network error, please try again",
                                "Network Error", JOptionPane.INFORMATION_MESSAGE);
                    }/*from ww w  . j  a va 2 s . c o  m*/
                });
                setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                return;
            }
            lastResponseMessage = response;

            if (response != null) {
                JAXBUtil jaxbUtil = PreviousQueryJAXBUtil.getJAXBUtil();

                try {
                    JAXBElement jaxbElement = jaxbUtil.unMashallFromString(response);
                    ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue();
                    StatusType statusType = messageType.getResponseHeader().getResultStatus().getStatus();
                    String status = statusType.getType();

                    if (status.equalsIgnoreCase("DONE")) {
                        ndata.name(newQueryName + " [" + ndata.userId() + "]");
                        node.setUserObject(ndata);
                        //DefaultMutableTreeNode parent = (DefaultMutableTreeNode) node.getParent();

                        jTree1.repaint();
                    }
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
            setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        }
    } else if (e.getActionCommand().equalsIgnoreCase("Delete")) {
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getSelectionPath().getLastPathComponent();
        QueryMasterData ndata = (QueryMasterData) node.getUserObject();
        Object selectedValue = JOptionPane.showConfirmDialog(this, "Delete Query \"" + ndata.name() + "\"?",
                "Delete Query Dialog", JOptionPane.YES_NO_OPTION);
        if (selectedValue.equals(JOptionPane.YES_OPTION)) {
            System.out.println("delete " + ndata.name());
            String requestXml = ndata.writeDeleteQueryXML();
            lastRequestMessage = requestXml;
            //System.out.println(requestXml);

            setCursor(new Cursor(Cursor.WAIT_CURSOR));

            String response = QueryListNamesClient.sendQueryRequestREST(requestXml);
            if (response.equalsIgnoreCase("CellDown")) {
                final JPanel parent = this;
                java.awt.EventQueue.invokeLater(new Runnable() {
                    public void run() {
                        JOptionPane.showMessageDialog(parent,
                                "Trouble with connection to the remote server, "
                                        + "this is often a network error, please try again",
                                "Network Error", JOptionPane.INFORMATION_MESSAGE);
                    }
                });
                setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                return;
            }
            lastResponseMessage = response;

            if (response != null) {
                JAXBUtil jaxbUtil = PreviousQueryJAXBUtil.getJAXBUtil();

                try {
                    JAXBElement jaxbElement = jaxbUtil.unMashallFromString(response);
                    ResponseMessageType messageType = (ResponseMessageType) jaxbElement.getValue();
                    StatusType statusType = messageType.getResponseHeader().getResultStatus().getStatus();
                    String status = statusType.getType();

                    if (status.equalsIgnoreCase("DONE")) {
                        treeModel.removeNodeFromParent(node);

                        //jTree1.repaint();
                    }
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
            setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        }
    } else if (e.getActionCommand().equalsIgnoreCase("Refresh All")) {
        String status = loadPreviousQueries(false);
        if (status.equalsIgnoreCase("")) {
            reset(200, false);
        } else if (status.equalsIgnoreCase("CellDown")) {
            final JPanel parent = this;
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    JOptionPane.showMessageDialog(parent,
                            "Trouble with connection to the remote server, "
                                    + "this is often a network error, please try again",
                            "Network Error", JOptionPane.INFORMATION_MESSAGE);
                }
            });
        }
    }
}

From source file:base.BasePlayer.BedCanvas.java

void drawSidebar() {

    buf.setColor(Draw.sidecolor.darker());
    buf.fillRect(0, 0, Main.sidebarWidth - 4, this.getHeight());
    //   buf.setColor(Draw.softColor);
    //   buf.fillRect(0, 0, Main.sidebarWidth, this.getHeight());
    buf.setColor(Color.black);/*from   www . j  a v a  2 s  .c  om*/

    if (bedTrack.size() > 0) {
        //   buf.setStroke(Draw.doubleStroke);
        overlapping = false;
        for (int i = 0; i < bedTrack.size(); i++) {
            if (!buf.getColor().equals(Color.black)) {
                buf.setColor(Color.black);
            }
            if (i == 0) {
                trackstart = Main.defaultFontSize;
                trackheight = (int) (trackDivider.get(i) * this.getHeight());
            } else {

                trackstart = Main.defaultFontSize + (int) (trackDivider.get(i - 1) * this.getHeight());
                trackheight = (int) (trackDivider.get(i) * this.getHeight())
                        - (int) (trackDivider.get(i - 1) * this.getHeight());
            }

            if (bedTrack.get(i).file != null) {

                buf.drawString(bedTrack.get(i).file.getName(), 10, trackstart);
            } else {

                buf.drawString(FilenameUtils.getName(bedTrack.get(i).url.getFile()), 10, trackstart);
            }

            if (trackheight > Main.defaultFontSize + Main.defaultFontSize
                    + (int) (Main.defaultFontSize * 1.4)) {

                if ((int) bedTrack.get(i).playbox.y != trackstart + Main.defaultFontSize) {

                    bedTrack.get(i).playbox.setBounds(10, trackstart + Main.defaultFontSize,
                            (int) (Main.defaultFontSize * 1.4), (int) (Main.defaultFontSize * 1.4));
                    bedTrack.get(i).playTriangle.reset();
                    bedTrack.get(i).playTriangle.addPoint(
                            bedTrack.get(i).playbox.x + (Main.defaultFontSize / 5),
                            bedTrack.get(i).playbox.y + (Main.defaultFontSize / 5));
                    bedTrack.get(i).playTriangle.addPoint(
                            bedTrack.get(i).playbox.x + (Main.defaultFontSize / 5), bedTrack.get(i).playbox.y
                                    + (bedTrack.get(i).playbox.width - (Main.defaultFontSize / 5)));
                    bedTrack.get(i).playTriangle.addPoint(
                            bedTrack.get(i).playbox.x
                                    + (bedTrack.get(i).playbox.width - (Main.defaultFontSize / 5)),
                            bedTrack.get(i).playbox.y + bedTrack.get(i).playbox.height / 2);
                    bedTrack.get(i).graphBox.setBounds(
                            bedTrack.get(i).playbox.x + (int) (Main.defaultFontSize * 1.4)
                                    + Main.defaultFontSize,
                            trackstart + Main.defaultFontSize, (int) (Main.defaultFontSize * 1.4),
                            (int) (Main.defaultFontSize * 1.4));
                    if (bedTrack.get(i).settingsButton == null) {
                        bedTrack.get(i).settingsButton = new Rectangle();
                    }
                    bedTrack.get(i).settingsButton.setBounds(
                            Main.sidebarWidth - (int) (this.remoBox.width * (1.8)) - 4,
                            trackstart - Main.defaultFontSize, (int) (this.remoBox.width * (1.5)) + 2,
                            (int) (this.remoBox.height * (1.5)));

                }
                if (bedTrack.get(i).settingsButton == null) {
                    bedTrack.get(i).settingsButton = new Rectangle();
                }
                if (bedTrack.get(i).settingsButton.y == 0
                        || bedTrack.get(i).settingsButton.x != Main.sidebarWidth
                                - (int) (this.remoBox.width * (1.8))
                        || bedTrack.get(i).settingsButton.width != (int) (this.remoBox.width * (1.5)) + 2) {
                    bedTrack.get(i).settingsButton.setBounds(
                            Main.sidebarWidth - (int) (this.remoBox.width * (1.8)),
                            trackstart - Main.defaultFontSize - 4, (int) (this.remoBox.width * (1.5)) + 2,
                            (int) (this.remoBox.height * (1.5)));

                }
                if (Main.varsamples > 0 || FileRead.caller) {
                    if (bedTrack.get(i).getCurrent() != null
                            || (!bedTrack.get(i).small || bedTrack.get(i).getZoomlevel() != null)) {
                        buf.setColor(Color.white);
                        buf.fillRoundRect(bedTrack.get(i).playbox.getBounds().x - 1,
                                bedTrack.get(i).playbox.getBounds().y - 1,
                                bedTrack.get(i).playbox.getBounds().width,
                                bedTrack.get(i).playbox.getBounds().height, 2, 2);
                        buf.setColor(Color.gray);
                        buf.fillRoundRect(bedTrack.get(i).playbox.getBounds().x + 1,
                                bedTrack.get(i).playbox.getBounds().y + 1,
                                bedTrack.get(i).playbox.getBounds().width,
                                bedTrack.get(i).playbox.getBounds().height, 2, 2);
                        if (sideMouseRect.intersects(bedTrack.get(i).playbox)) {
                            overlapping = true;
                            if (getCursor().getType() != Cursor.HAND_CURSOR) {
                                selectedPlay = i;
                                setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
                            }
                            buf.setColor(Color.white);
                            //   buf.drawRect(bedTrack.get(i).playbox.getBounds().x-1,bedTrack.get(i).playbox.getBounds().y-1,bedTrack.get(i).playbox.getBounds().width+1, bedTrack.get(i).playbox.getBounds().height+1);
                            buf.fillRoundRect(bedTrack.get(i).playbox.getBounds().x,
                                    bedTrack.get(i).playbox.getBounds().y,
                                    bedTrack.get(i).playbox.getBounds().width,
                                    bedTrack.get(i).playbox.getBounds().height, 2, 2);

                        } else {
                            buf.setColor(Draw.sidecolor);
                            buf.fillRoundRect(bedTrack.get(i).playbox.getBounds().x,
                                    bedTrack.get(i).playbox.getBounds().y,
                                    bedTrack.get(i).playbox.getBounds().width,
                                    bedTrack.get(i).playbox.getBounds().height, 2, 2);
                        }
                        if (bedTrack.get(i).intersect) {
                            buf.setColor(Draw.greenColor);
                            buf.fillRect(bedTrack.get(i).playTriangle.getBounds().x,
                                    bedTrack.get(i).playTriangle.getBounds().y,
                                    bedTrack.get(i).playTriangle.getBounds().width,
                                    bedTrack.get(i).playTriangle.getBounds().height);
                        } else {
                            buf.setColor(Draw.redColor);
                            buf.fillPolygon(bedTrack.get(i).playTriangle);
                        }
                    }
                }

                if (bedTrack.get(i).hasvalues) {

                    if (bedTrack.get(i).getCurrent() != null || !bedTrack.get(i).small) {
                        buf.setColor(Color.lightGray);
                        buf.fillRect(bedTrack.get(i).graphBox.getBounds().x,
                                bedTrack.get(i).graphBox.getBounds().y,
                                bedTrack.get(i).graphBox.getBounds().width,
                                bedTrack.get(i).graphBox.getBounds().height);
                        buf.setColor(Color.white);
                        buf.fillRoundRect(bedTrack.get(i).graphBox.getBounds().x - 1,
                                bedTrack.get(i).graphBox.getBounds().y - 1,
                                bedTrack.get(i).graphBox.getBounds().width,
                                bedTrack.get(i).graphBox.getBounds().height, 2, 2);
                        buf.setColor(Color.gray);
                        buf.fillRoundRect(bedTrack.get(i).graphBox.getBounds().x + 1,
                                bedTrack.get(i).graphBox.getBounds().y + 1,
                                bedTrack.get(i).graphBox.getBounds().width,
                                bedTrack.get(i).graphBox.getBounds().height, 2, 2);
                        if (sideMouseRect.intersects(bedTrack.get(i).graphBox)) {
                            overlapping = true;
                            if (getCursor().getType() != Cursor.HAND_CURSOR) {
                                selectedPlay = i;
                                setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
                            }
                            buf.setColor(Color.white);
                            //   buf.drawRect(bedTrack.get(i).graphBox.getBounds().x-1,bedTrack.get(i).graphBox.getBounds().y-1,bedTrack.get(i).graphBox.getBounds().width+1, bedTrack.get(i).graphBox.getBounds().height+1);
                            buf.fillRoundRect(bedTrack.get(i).graphBox.getBounds().x,
                                    bedTrack.get(i).graphBox.getBounds().y,
                                    bedTrack.get(i).graphBox.getBounds().width,
                                    bedTrack.get(i).graphBox.getBounds().height, 2, 2);

                        } else {
                            buf.setColor(Draw.sidecolor);
                            buf.fillRoundRect(bedTrack.get(i).graphBox.getBounds().x,
                                    bedTrack.get(i).graphBox.getBounds().y,
                                    bedTrack.get(i).graphBox.getBounds().width,
                                    bedTrack.get(i).graphBox.getBounds().height, 2, 2);
                        }
                        if (bedTrack.get(i).graph) {
                            buf.setColor(Draw.greenColor);
                            buf.drawLine(bedTrack.get(i).graphBox.getBounds().x,
                                    bedTrack.get(i).graphBox.getBounds().y
                                            + bedTrack.get(i).graphBox.getBounds().height,
                                    bedTrack.get(i).graphBox.getBounds().x
                                            + bedTrack.get(i).graphBox.getBounds().width / 4,
                                    bedTrack.get(i).graphBox.getBounds().y
                                            + bedTrack.get(i).graphBox.getBounds().height / 2);
                            buf.drawLine(
                                    bedTrack.get(i).graphBox.getBounds().x
                                            + bedTrack.get(i).graphBox.getBounds().width / 4,
                                    bedTrack.get(i).graphBox.getBounds().y
                                            + bedTrack.get(i).graphBox.getBounds().height / 2,
                                    bedTrack.get(i).graphBox.getBounds().x
                                            + bedTrack.get(i).graphBox.getBounds().width / 2,
                                    bedTrack.get(i).graphBox.getBounds().y
                                            + (int) (bedTrack.get(i).graphBox.getBounds().height * 0.66));
                            buf.drawLine(
                                    bedTrack.get(i).graphBox.getBounds().x
                                            + bedTrack.get(i).graphBox.getBounds().width / 2,
                                    bedTrack.get(i).graphBox.getBounds().y
                                            + (int) (bedTrack.get(i).graphBox.getBounds().height * 0.66),
                                    (int) (bedTrack.get(i).graphBox.getBounds().x
                                            + bedTrack.get(i).graphBox.getBounds().width * 0.66),
                                    bedTrack.get(i).graphBox.getBounds().y
                                            + bedTrack.get(i).graphBox.getBounds().height / 4);
                            buf.drawLine(
                                    (int) (bedTrack.get(i).graphBox.getBounds().x
                                            + bedTrack.get(i).graphBox.getBounds().width * 0.66),
                                    bedTrack.get(i).graphBox.getBounds().y
                                            + bedTrack.get(i).graphBox.getBounds().height / 4,
                                    bedTrack.get(i).graphBox.getBounds().x
                                            + bedTrack.get(i).graphBox.getBounds().width,
                                    bedTrack.get(i).graphBox.getBounds().y
                                            + bedTrack.get(i).graphBox.getBounds().height / 2);

                        } else {
                            buf.setColor(Draw.redColor);
                            buf.drawLine(bedTrack.get(i).graphBox.getBounds().x,
                                    bedTrack.get(i).graphBox.getBounds().y
                                            + bedTrack.get(i).graphBox.getBounds().height,
                                    bedTrack.get(i).graphBox.getBounds().x
                                            + bedTrack.get(i).graphBox.getBounds().width / 4,
                                    bedTrack.get(i).graphBox.getBounds().y
                                            + bedTrack.get(i).graphBox.getBounds().height / 2);
                            buf.drawLine(
                                    bedTrack.get(i).graphBox.getBounds().x
                                            + bedTrack.get(i).graphBox.getBounds().width / 4,
                                    bedTrack.get(i).graphBox.getBounds().y
                                            + bedTrack.get(i).graphBox.getBounds().height / 2,
                                    bedTrack.get(i).graphBox.getBounds().x
                                            + bedTrack.get(i).graphBox.getBounds().width / 2,
                                    bedTrack.get(i).graphBox.getBounds().y
                                            + (int) (bedTrack.get(i).graphBox.getBounds().height * 0.66));
                            buf.drawLine(
                                    bedTrack.get(i).graphBox.getBounds().x
                                            + bedTrack.get(i).graphBox.getBounds().width / 2,
                                    bedTrack.get(i).graphBox.getBounds().y
                                            + (int) (bedTrack.get(i).graphBox.getBounds().height * 0.66),
                                    (int) (bedTrack.get(i).graphBox.getBounds().x
                                            + bedTrack.get(i).graphBox.getBounds().width * 0.66),
                                    bedTrack.get(i).graphBox.getBounds().y
                                            + bedTrack.get(i).graphBox.getBounds().height / 4);
                            buf.drawLine(
                                    (int) (bedTrack.get(i).graphBox.getBounds().x
                                            + bedTrack.get(i).graphBox.getBounds().width * 0.66),
                                    bedTrack.get(i).graphBox.getBounds().y
                                            + bedTrack.get(i).graphBox.getBounds().height / 4,
                                    bedTrack.get(i).graphBox.getBounds().x
                                            + bedTrack.get(i).graphBox.getBounds().width,
                                    bedTrack.get(i).graphBox.getBounds().y
                                            + bedTrack.get(i).graphBox.getBounds().height / 2);

                        }
                        /*if(sideMouseRect.intersects(bedTrack.get(i).graphBox)) {
                                   
                           overlapping = true;
                           selectedPlay = i;
                           if(getCursor().getType() != Cursor.HAND_CURSOR) {
                                      
                              setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
                           }   
                           buf.setColor(Color.white);
                           buf.drawRect(bedTrack.get(i).graphBox.getBounds().x-1,bedTrack.get(i).graphBox.getBounds().y-1,bedTrack.get(i).graphBox.getBounds().width+1, bedTrack.get(i).graphBox.getBounds().height+1);
                                   
                        }*/
                    }
                }
            }
            if (trackheight > bedTrack.get(i).settingsButton.height) {
                /*if(this.sideMouseRect.intersects(bedTrack.get(i).settingsButton)) {                        
                   buf.setColor(Color.white);
                }
                else {         
                           
                }*/
                buf.setColor(Draw.sidecolor.darker());
                buf.fillRect(bedTrack.get(i).settingsButton.x, bedTrack.get(i).settingsButton.y,
                        bedTrack.get(i).settingsButton.width, bedTrack.get(i).settingsButton.height);
                buf.drawImage(Main.settingsIcon.getImage(),
                        Main.sidebarWidth - (int) (this.remoBox.width * (1.8)) - 4,
                        trackstart - Main.defaultFontSize, (int) (this.remoBox.width * (1.5)),
                        (int) (this.remoBox.height * (1.5)), this);
            }
        }

        if (!overlapping && !resizer) {

            if (getCursor().getType() != Cursor.DEFAULT_CURSOR) {

                selectedPlay = -1;
                setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            }
        }
        if (sidebar) {
            buf.setColor(Color.black);

            if (sidebar && sideMouseRect.intersects(this.remoBox)) {
                //   buf.setStroke(Draw.doubleStroke);
                removeTrack = hoverIndex;
                buf.setColor(Color.white);
                buf.fillRect(this.remoBox.x - 2, this.remoBox.y - 1, this.remoBox.width + 2,
                        this.remoBox.height + 2);
            } else {
                removeTrack = -1;
                if (this.remoBox.getBounds().x != Main.sidebarWidth - (Main.defaultFontSize + 10) - 4
                        || this.remoBox.getBounds().y != (int) (trackDivider.get(hoverIndex) * this.getHeight())
                                - (Main.defaultFontSize + 6)) {
                    this.remoBox.setBounds(Main.sidebarWidth - (Main.defaultFontSize + 10) - 4,
                            (int) (trackDivider.get(hoverIndex) * this.getHeight())
                                    - (Main.defaultFontSize + 6),
                            Main.defaultFontSize + 3, Main.defaultFontSize + 3);
                }
                /*   if(this.remoBox.getBounds().y != (int)(trackDivider.get(hoverIndex)*this.getHeight())-11|| this.remoBox.getBounds().x != Main.sidebarWidth-11) {
                      this.remoBox.setBounds(Main.sidebarWidth-11, (int)(trackDivider.get(hoverIndex)*this.getHeight())-11, 8, 8);
                   }*/
            }

            buf.setColor(Color.black);
            buf.drawRect(this.remoBox.x, this.remoBox.y, this.remoBox.width, this.remoBox.height);
            buf.drawLine(this.remoBox.x, this.remoBox.y, this.remoBox.x + this.remoBox.width,
                    this.remoBox.y + (int) this.remoBox.getHeight());
            buf.drawLine(this.remoBox.x, this.remoBox.y + (int) this.remoBox.getHeight(),
                    this.remoBox.x + this.remoBox.width, this.remoBox.y);

        }
        buf.setStroke(Draw.doubleStroke);
        buf.setColor(Color.gray);
        buf.drawLine(Main.sidebarWidth - 5, 0, Main.sidebarWidth - 5, this.getHeight());
        buf.drawLine(1, 0, 1, this.getHeight());
        buf.setColor(Color.lightGray);
        buf.drawLine(3, 0, 3, this.getHeight());
        buf.drawLine(Main.sidebarWidth - 7, 0, Main.sidebarWidth - 7, this.getHeight());
        buf.setStroke(Draw.basicStroke);
    }

}

From source file:com.vgi.mafscaling.OpenLoop.java

protected void loadLogFile() {
    fileChooser.setMultiSelectionEnabled(true);
    if (JFileChooser.APPROVE_OPTION != fileChooser.showOpenDialog(this))
        return;//w w w. j  av a2  s.  com
    boolean isPolSet = polfTable.isSet();
    File[] files = fileChooser.getSelectedFiles();
    for (File file : files) {
        BufferedReader br = null;
        ArrayDeque<String[]> buffer = new ArrayDeque<String[]>();
        try {
            br = new BufferedReader(new FileReader(file.getAbsoluteFile()));
            String line = br.readLine();
            if (line != null) {
                String[] elements = line.split("(\\s*)?,(\\s*)?", -1);
                getColumnsFilters(elements, false);

                boolean resetColumns = false;
                if (logThtlAngleColIdx >= 0 || logAfLearningColIdx >= 0 || logAfCorrectionColIdx >= 0
                        || logMafvColIdx >= 0 || logAfrColIdx >= 0 || logRpmColIdx >= 0 || logLoadColIdx >= 0
                        || logCommandedAfrCol >= 0) {
                    if (JOptionPane.YES_OPTION == JOptionPane.showConfirmDialog(null,
                            "Would you like to reset column names or filter values?", "Columns/Filters Reset",
                            JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE))
                        resetColumns = true;
                }

                if (resetColumns || logThtlAngleColIdx < 0 || logAfLearningColIdx < 0
                        || logAfCorrectionColIdx < 0 || logMafvColIdx < 0 || logAfrColIdx < 0
                        || logRpmColIdx < 0 || logLoadColIdx < 0 || (logCommandedAfrCol < 0 && !isPolSet)) {
                    ColumnsFiltersSelection selectionWindow = new OLColumnsFiltersSelection(isPolSet);
                    if (!selectionWindow.getUserSettings(elements) || !getColumnsFilters(elements, isPolSet))
                        return;
                }

                String[] flds;
                String[] afrflds;
                boolean wotFlag = true;
                boolean foundWot = false;
                double throttle;
                double stft;
                double ltft;
                double afr;
                double rpm;
                double load;
                double mafv;
                double cmdafr = 0;
                double afrErr = 0;
                int skipRowCount = 0;
                int row = 0;
                int i = 0;
                int j = 0;
                for (; i < runTables.length; ++i) {
                    if (runTables[i].getValueAt(0, 0).toString().isEmpty())
                        break;
                }
                if (i == runTables.length)
                    return;
                setCursor(new Cursor(Cursor.WAIT_CURSOR));
                for (int k = 0; k <= afrRowOffset && line != null; ++k) {
                    line = br.readLine();
                    if (line != null)
                        buffer.addFirst(line.split(",", -1));
                }
                while (line != null && buffer.size() > afrRowOffset) {
                    afrflds = buffer.getFirst();
                    flds = buffer.removeLast();
                    line = br.readLine();
                    if (line != null)
                        buffer.addFirst(line.split(",", -1));

                    try {
                        throttle = Double.valueOf(flds[logThtlAngleColIdx]);
                        if (row == 0 && throttle < 99)
                            wotFlag = false;
                        if (throttle < wotPoint) {
                            if (wotFlag == true) {
                                wotFlag = false;
                                skipRowCount = 0;
                                j -= 1;
                                while (j > 0 && skipRowCount < skipRowsOnTransition) {
                                    runTables[i].setValueAt("", j, 0);
                                    runTables[i].setValueAt("", j, 1);
                                    runTables[i].setValueAt("", j, 2);
                                    skipRowCount += 1;
                                    j -= 1;
                                }
                                skipRowCount = 0;
                            }
                        } else {
                            if (wotFlag == false) {
                                wotFlag = true;
                                skipRowCount = 0;
                                if (foundWot) {
                                    i += 1;
                                    if (i == runTables.length)
                                        return;
                                }
                                if (row > 0)
                                    j = 0;
                            }
                            if (skipRowCount >= skipRowsOnTransition) {
                                mafv = Double.valueOf(flds[logMafvColIdx]);
                                if (minMafV <= mafv) {
                                    foundWot = true;
                                    stft = Double.valueOf(flds[logAfCorrectionColIdx]);
                                    ltft = Double.valueOf(flds[logAfLearningColIdx]);
                                    afr = Double.valueOf(afrflds[logAfrColIdx]);
                                    rpm = Double.valueOf(flds[logRpmColIdx]);
                                    load = Double.valueOf(flds[logLoadColIdx]);

                                    afr = afr / ((100.0 - (ltft + stft)) / 100.0);

                                    if (logCommandedAfrCol >= 0)
                                        cmdafr = Double.valueOf(flds[logCommandedAfrCol]);
                                    else if (isPolSet)
                                        cmdafr = Utils.calculateCommandedAfr(rpm, load, minWotEnrichment,
                                                polfTable);
                                    else {
                                        JOptionPane.showMessageDialog(null,
                                                "Please set either \"Commanded AFR\" column or \"Primary Open Loop Fueling\" table",
                                                "Error", JOptionPane.ERROR_MESSAGE);
                                        return;
                                    }

                                    afrErr = (afr - cmdafr) / cmdafr * 100.0;
                                    if (Math.abs(afrErr) <= afrErrPrct) {
                                        Utils.ensureRowCount(j + 1, runTables[i]);
                                        runTables[i].setValueAt(rpm, j, 0);
                                        runTables[i].setValueAt(mafv, j, 1);
                                        runTables[i].setValueAt(afrErr, j, 2);
                                        j += 1;
                                    }
                                }
                            }
                            skipRowCount += 1;
                        }
                    } catch (NumberFormatException e) {
                        logger.error(e);
                        JOptionPane.showMessageDialog(null,
                                "Error parsing number at " + file.getName() + " line " + (row + 1) + ": " + e,
                                "Error processing file", JOptionPane.ERROR_MESSAGE);
                        return;
                    }
                    row += 1;
                }

                if (!foundWot) {
                    setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                    JOptionPane.showMessageDialog(null, "Sorry, no WOT pulls were found in the log file",
                            "No WOT data", JOptionPane.INFORMATION_MESSAGE);
                }
            }
        } catch (Exception e) {
            logger.error(e);
            JOptionPane.showMessageDialog(null, e, "Error opening file", JOptionPane.ERROR_MESSAGE);
        } finally {
            setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
            if (br != null) {
                try {
                    br.close();
                } catch (IOException e) {
                    logger.error(e);
                }
            }
        }
    }
}

From source file:com.josescalia.tumblr.form.TumblrImageViewer.java

private void btnAddToCollectionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddToCollectionActionPerformed
    frame = (MainFrame) this.getTopLevelAncestor();
    form = this;//  w w w  . j a  v  a 2s . com
    if (validateUrl()) {
        final Rss rss = constructNewObject();

        if (rss != null) {
            //set Progressbar and cursor
            form.setCursor(new Cursor(Cursor.WAIT_CURSOR));
            frame.setCursor(new Cursor(Cursor.WAIT_CURSOR));
            frame.startProgressBar("Saving");

            new SwingWorker<Boolean, Boolean>() {
                @Override
                protected Boolean doInBackground() throws Exception {
                    try {
                        rssService.save(rss);
                        return Boolean.TRUE;
                    } catch (Exception e) {
                        UIAlert.showError(null, UIMessageConstants.saveFailedMsg + "\n" + e.getMessage());
                    }
                    return Boolean.FALSE;
                }

                protected void done() {
                    try {
                        if (get()) {
                            UIAlert.showInformation(null, UIMessageConstants.saveSucceedMsg);
                        } else {
                            UIAlert.showInformation(null, UIMessageConstants.saveFailedMsg);
                        }
                    } catch (InterruptedException e) {
                        logger.error(e);
                    } catch (ExecutionException e) {
                        logger.error(e);
                    }
                    form.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                    frame.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
                    frame.stopProgressBar("");
                }
            }.execute();

        }
    }
}

From source file:edu.harvard.mcz.imagecapture.MainFrame.java

public void setSpecimenBrowseList(Specimen searchCriteria) {
    Singleton.getSingletonInstance().getMainFrame().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    slb = new SpecimenBrowser(searchCriteria, true);
    if (ilb != null) {
        jPanelCenter.remove(ilb);//w  ww.  ja  v  a 2s  . c om
    }
    if (ulb != null) {
        jPanelCenter.remove(ulb);
    }
    jPanelCenter.removeAll();
    jPanelCenter.add(slb, BorderLayout.CENTER);
    jPanelCenter.revalidate();
    jPanelCenter.repaint();
    if (Singleton.getSingletonInstance().getProperties().getProperties()
            .getProperty(ImageCaptureProperties.KEY_ENABLE_BROWSE).equals("false")) {
        jMenuItemBrowseSpecimens.setEnabled(false);
        jMenuItemBrowseImages.setEnabled(false);
    } else {
        jMenuItemBrowseSpecimens.setEnabled(true);
        jMenuItemBrowseImages.setEnabled(true);
    }
    setStatusMessage("Found " + slb.getRowCount() + " matching specimens");
    Singleton.getSingletonInstance().getMainFrame()
            .setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}