public final boolean isAlphaModeEnabled(final Window window) {
   if (!window.isDisplayable() || !window.isShowing()) {
     throw new IllegalArgumentException(
         "window must be displayable and showing. window=" + window);
   }
   return isAlphaModeSupported();
 }
Ejemplo n.º 2
0
 /**
  * @param component component
  * @return whether the component in Swing tree or not. This method is more weak then {@link
  *     Component#isShowing() }
  */
 private boolean isInTree(final Component component) {
   if (component instanceof Window) {
     return component.isShowing();
   } else {
     Window windowAncestor = SwingUtilities.getWindowAncestor(component);
     return windowAncestor != null && windowAncestor.isShowing();
   }
 }
Ejemplo n.º 3
0
  // recenter the mouse using the robot
  public synchronized void recenterMouse() {
    Window w = s.getFullScreenWindow();

    if (robot != null && w.isShowing()) {
      center.x = w.getWidth() / 2;
      center.y = w.getHeight() / 2;

      SwingUtilities.convertPointToScreen(center, w);
      centering = true;
      robot.mouseMove(center.x, center.y);
    }
  }
  public final void setAlphaModeRatio(final Window window, final float ratio) {
    if (!window.isDisplayable() || !window.isShowing()) {
      throw new IllegalArgumentException(
          "window must be displayable and showing. window=" + window);
    }
    if (ratio < 0.0f || ratio > 1.0f) {
      throw new IllegalArgumentException("ratio must be in [0..1] range. ratio=" + ratio);
    }
    if (!isAlphaModeSupported() || !isAlphaModeEnabled(window)) {
      return;
    }

    setAlphaMode(window, ratio);
  }
 public final void setAlphaModeEnabled(final Window window, final boolean state) {
   if (!window.isDisplayable() || !window.isShowing()) {
     throw new IllegalArgumentException(
         "window must be displayable and showing. window=" + window);
   }
 }
Ejemplo n.º 6
0
  public void showEmbeddedMacros(int modifier) {

    showPopUp = ((modifier & KeyEvent.ALT_MASK) != 0);
    String macros_text = OJ.getData().getLinkedMacroText();
    if (macros_text == null) {
      macros_text = "";
    }
    Window theWindow = OJ.editorWindow;
    if (theWindow != null && theWindow.isShowing() && OJ.editor != null) {
      theWindow.setVisible(true);
      return;
    }

    String version = IJ.getFullVersion();
    Editor ed;
    if (version.compareToIgnoreCase("1.49i03") >= 0) {
      ed = new EditorOJ(16, 60, 0, Editor.MONOSPACED + Editor.MENU_BAR);
    } else {
      ed = new Editor(16, 60, 0, Editor.MONOSPACED + Editor.MENU_BAR);
    }
    ed.create("Embedded Macros", macros_text);
    JButton loadButton = new JButton("Install in ObjectJ menu");
    loadButton.addActionListener(LoadEmbeddedMacroAction);

    TextArea ta = ed.getTextArea();
    ed.remove(ta);
    ed.setLayout(new BorderLayout());
    JPanel panel1 = new JPanel();

    panel1.setLayout(new FlowLayout());
    loadButton.setFont(new Font("SansSerif", Font.PLAIN, 14));
    panel1.add(loadButton);

    JLabel myLabel = new JLabel("Macros Overview");

    if (showPopUp) {
      panel1.add(myLabel);
    }
    myLabel.setForeground(Color.blue);
    myLabel.setAutoscrolls(true);

    macrosPopup = new javax.swing.JPopupMenu();

    myLabel.addMouseListener(
        new java.awt.event.MouseAdapter() {
          public void mouseEntered(java.awt.event.MouseEvent evt) {

            refreshPopupItems();
          }

          public void mouseReleased(java.awt.event.MouseEvent evt) {
            if ((evt.getModifiers() & InputEvent.BUTTON1_MASK) != 0) {
              ij.IJ.showStatus("Right-Click to navigate through macros");
              //                            + "\n-"
              //                            + "\nYou also can enter bookmark tags into the macro
              // text:"
              //                            + "\n //<<   bookmarks left part of line"
              //                            + "\n //>>   bookmarks right part of line");
            }
          }
        });

    myLabel.setComponentPopupMenu(macrosPopup);

    ed.add(BorderLayout.NORTH, panel1);
    ed.add(BorderLayout.CENTER, ta);

    Font monoFont = new Font("Monospaced", Font.PLAIN, 14);
    ta.setFont(monoFont);
    OJ.editor = ed;
    Frame[] frames = WindowManager.getNonImageWindows();
    Frame frame = frames[frames.length - 1];
    // ij.IJ.log(WindowManager.getFrontWindow().getTitle());
    // ij.IJ.log(frame.getTitle());//"Embedded Macros"
    // ij.IJ.log("---");//"Embedded Macros"
    OJ.editorWindow = WindowManager.getFrontWindow();
    refreshPopupItems();
    loadButton.transferFocus();
  }