com.jidesoft.swing.JidePopupMenu Java Examples

The following examples show how to use com.jidesoft.swing.JidePopupMenu. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ImageInfoEditor.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private void showSliderActions(MouseEvent evt, final int sliderIndex) {
    final JPopupMenu menu = new JidePopupMenu();
    boolean showPopupMenu = false;
    JMenuItem menuItem;
    if (canChangeSliderCount()) {
        menuItem = createMenuItemAddNewSlider(sliderIndex, evt);
        if (menuItem != null) {
            menu.add(menuItem);
            showPopupMenu = true;
        }
        if (getSliderCount() > 2 && sliderIndex != INVALID_INDEX) {
            menuItem = createMenuItemDeleteSlider(sliderIndex);
            menu.add(menuItem);
            showPopupMenu = true;
        }
    }
    if (getSliderCount() > 2
            && sliderIndex > 0
            && sliderIndex < getSliderCount() - 1
            && isSliderEditable(sliderIndex)) {
        menuItem = createMenuItemCenterSampleValue(sliderIndex);
        menu.add(menuItem);
        menuItem = createMenuItemCenterColorValue(sliderIndex);
        menu.add(menuItem);
        showPopupMenu = true;
    }
    if (showPopupMenu) {
        menu.show(evt.getComponent(), evt.getX(), evt.getY());
    }
}
 
Example #2
Source File: HeatmapPanel.java    From Juicebox with MIT License 4 votes vote down vote up
private void addJumpToDiagonalMenuItems(JidePopupMenu menu, int xMousePos, int yMousePos) {

    final double preJumpBinOriginX = hic.getXContext().getBinOrigin();
    final double preJumpBinOriginY = hic.getYContext().getBinOrigin();

    // xMousePos and yMousePos coordinates are relative to the heatmap panel and not the screen
    final int clickedBinX = (int) (preJumpBinOriginX + xMousePos / hic.getScaleFactor());
    final int clickedBinY = (int) (preJumpBinOriginY + yMousePos / hic.getScaleFactor());

    // these coordinates are relative to the screen and not the heatmap panel
    final int defaultPointerDestinationX = (int) (getLocationOnScreen().getX() + xMousePos);
    final int defaultPointerDestinationY = (int) (getLocationOnScreen().getY() + yMousePos);

    // get maximum number of bins on the X and Y axes
    Matrix matrix = hic.getMatrix();
    MatrixZoomData matrixZoomData = matrix.getZoomData(hic.getZoom());
    final int binCountX = matrixZoomData.getXGridAxis().getBinCount();
    final int binCountY = matrixZoomData.getYGridAxis().getBinCount();

    if (clickedBinX > clickedBinY) {

      final JMenuItem jumpToDiagonalLeft = new JMenuItem('\u25C0' + "  Jump To Diagonal");
      jumpToDiagonalLeft.setSelected(straightEdgeEnabled);
      jumpToDiagonalLeft.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
          double postJumpBinOriginX = preJumpBinOriginX - (clickedBinX - clickedBinY);
          hic.moveBy(clickedBinY - clickedBinX, 0);
          if (postJumpBinOriginX < 0) {
            heatmapMouseBot.mouseMove((int) (defaultPointerDestinationX + postJumpBinOriginX * hic.getScaleFactor()), defaultPointerDestinationY);
            return;
          }
          heatmapMouseBot.mouseMove(defaultPointerDestinationX, defaultPointerDestinationY);
        }
      });
      menu.add(jumpToDiagonalLeft);

      final JMenuItem jumpToDiagonalDown = new JMenuItem('\u25BC' + "  Jump To Diagonal");
      jumpToDiagonalDown.setSelected(straightEdgeEnabled);
      jumpToDiagonalDown.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
          double postJumpBinOriginY = preJumpBinOriginY + (clickedBinX - clickedBinY);
          hic.moveBy(0, clickedBinX - clickedBinY);
          if (postJumpBinOriginY + getHeight() / hic.getScaleFactor() > binCountY) {
            heatmapMouseBot.mouseMove(defaultPointerDestinationX, (int) (defaultPointerDestinationY + (postJumpBinOriginY + getHeight() / hic.getScaleFactor() - binCountY)));
            return;
          }
          heatmapMouseBot.mouseMove(defaultPointerDestinationX, defaultPointerDestinationY);
        }
      });
      menu.add(jumpToDiagonalDown);

    } else if (clickedBinX < clickedBinY) {

      final JMenuItem jumpToDiagonalUp = new JMenuItem('\u25B2' + "  Jump To Diagonal");
      jumpToDiagonalUp.setSelected(straightEdgeEnabled);
      jumpToDiagonalUp.addActionListener(new ActionListener() {