Example usage for javax.swing JCheckBoxMenuItem getAction

List of usage examples for javax.swing JCheckBoxMenuItem getAction

Introduction

In this page you can find the example usage for javax.swing JCheckBoxMenuItem getAction.

Prototype

public Action getAction() 

Source Link

Document

Returns the currently set Action for this ActionEvent source, or null if no Action is set.

Usage

From source file:org.openmicroscopy.shoola.agents.imviewer.view.ImViewerUI.java

/**
 * Updates UI components when a zooming factor is selected.
 * //from  w  w  w  .ja  va2  s .  c o m
 * @param factor   The magnification factor.
 * @param zoomIndex The index of the selected zoomFactor.
 */
void setZoomFactor(double factor, int zoomIndex) {
    setMagnificationStatus(factor, zoomIndex);
    JCheckBoxMenuItem b;
    Enumeration e;
    Action a;
    if (zoomingGroup == null)
        return;
    for (e = zoomingGroup.getElements(); e.hasMoreElements();) {
        b = (JCheckBoxMenuItem) e.nextElement();
        a = b.getAction();
        if (a instanceof ZoomAction) {
            b.removeActionListener(a);
            b.setSelected(((ZoomAction) a).getIndex() == zoomIndex);
            b.setAction(a);
        }
    }
    controlPane.setZoomFactor(zoomIndex);
}

From source file:org.openmicroscopy.shoola.agents.imviewer.view.ImViewerUI.java

/**
 * Returns the index associated to the zoom factor.
 * /*from   ww w .j  a  v  a2  s .com*/
 * @return See above.
 */
int getZoomIndex() {
    if (zoomingGroup == null)
        return ZoomAction.ZOOM_FIT_TO_WINDOW;
    JCheckBoxMenuItem b;
    Enumeration e;
    Action a;
    for (e = zoomingGroup.getElements(); e.hasMoreElements();) {
        b = (JCheckBoxMenuItem) e.nextElement();
        a = b.getAction();
        if (b.isSelected())
            return ((ZoomAction) a).getIndex();
    }
    return ZoomAction.ZOOM_FIT_TO_WINDOW;
}

From source file:org.openmicroscopy.shoola.agents.imviewer.view.ImViewerUI.java

/**
 * Returns the index of the scale bar.//from w  ww  . j av a  2 s  .c om
 * 
 * @return See above.
 */
int getScaleBarIndex() {
    if (scaleBarGroup == null)
        return -1;
    JCheckBoxMenuItem item;
    Enumeration e;
    for (e = scaleBarGroup.getElements(); e.hasMoreElements();) {
        item = (JCheckBoxMenuItem) e.nextElement();
        if (item.isSelected())
            return ((UnitBarSizeAction) item.getAction()).getIndex();
    }
    return -1;
}

From source file:org.openmicroscopy.shoola.agents.imviewer.view.ImViewerUI.java

/** 
 * Sets the magnification for the grid view.
 * /*w  w  w .  j a v  a2  s  .co  m*/
 * @param factor The value to set.
 */
void setGridMagnificationFactor(double factor) {
    if (model.getTabbedIndex() == ImViewer.GRID_INDEX)
        setMagnificationStatus(factor, ZoomAction.getIndex(factor));
    JCheckBoxMenuItem b;
    Enumeration e;
    Action a;
    int zoomIndex = ZoomGridAction.getIndex(factor);
    for (e = zoomingGridGroup.getElements(); e.hasMoreElements();) {
        b = (JCheckBoxMenuItem) e.nextElement();
        a = b.getAction();
        if (a instanceof ZoomGridAction) {
            b.removeActionListener(a);
            b.setSelected(((ZoomGridAction) a).getIndex() == zoomIndex);
            b.setAction(a);
        }
    }
    controlPane.setGridMagnificationFactor((int) (factor * 10));
}