ModelKitPopup
Date: 2019-10-22

org.jmol.modelkit

## Class ModelKitPopup

- java.lang.Object
- - org.jmol.popup.GenericPopup
  - - org.jmol.popup.JmolGenericPopup
    - - org.jmol.modelkit.ModelKitPopup

- All Implemented Interfaces:
    GenericMenuInterface
  Direct Known Subclasses:
    AwtModelKitPopup, JSModelKitPopup

      public abstract class ModelKitPopup
      extends JmolGenericPopup

  An abstract popup class that is instantiated for a given platform and context as one of:

         -- abstract ModelKitPopup
            -- AwtModelKitPopup
            -- JSModelKitPopup

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private java.lang.String` | `activeMenu`
    `private boolean` | `addXtalHydrogens` when TRUE, add H atoms to C when added to the modelSet.
    `private boolean` | `alertedNoEdit`
    `private java.lang.String[]` | `allOperators`
    `private java.lang.String` | `atomHoverLabel`
    `private int` | `atomIndexSphere`
    `private int` | `bondAtomIndex1`
    `private int` | `bondAtomIndex2`
    `private java.lang.String` | `bondHoverLabel`
    `private int` | `bondIndex`
    `static java.lang.String` | `BOOLEAN_OPTIONS`
    `private int` | `branchAtomIndex`
    `private javajs.util.BS` | `bsHighlight`
    `private javajs.util.BS` | `bsRotateBranch`
    `private static PopupResource` | `bundle`
    `private int` | `centerAtomIndex`
    `private float` | `centerDistance`
    `private javajs.util.P3` | `centerPoint`
    `private boolean` | `clickToSetElement` Except for H atoms, do not allow changes to elements just by clicking them.
    `private int` | `currentModelIndex`
    `private java.lang.String` | `drawData`
    `private java.lang.String` | `drawScript`
    `private boolean` | `hasUnitCell`
    `private int` | `iatom0`
    `private boolean` | `isPickAtomAssignCharge`
    `private boolean` | `isRotateBond`
    `private java.lang.String` | `lastCenter`
    `private ModelSet` | `lastModelSet`
    `private java.lang.String` | `lastOffset`
    `private static int` | `MAX_LABEL`
    `private java.util.Map<java.lang.String,java.lang.Object>` | `mkdata`
    `static java.lang.String` | `MODE_OPTIONS`
    `private java.lang.String` | `pickAtomAssignType`
    `private java.lang.String` | `pickBondAssignType`
    `private static javajs.util.P3` | `Pt000`
    `private float` | `rotationDeg`
    `private int[]` | `screenXY`
    `private int` | `secondAtomIndex`
    `static java.lang.String` | `SET_OPTIONS`
    `private boolean` | `showSymopInfo`
    `private javajs.util.P3` | `spherePoint`
    `private int` | `state`
    `static int` | `STATE_BITS_SYM_EDIT`
    `static int` | `STATE_BITS_SYM_VIEW`
    `static int` | `STATE_BITS_UNITCELL`
    `static int` | `STATE_BITS_XTAL`
    `static int` | `STATE_MOLECULAR`
    `static int` | `STATE_SYM_APPLYFULL`
    `static int` | `STATE_SYM_APPLYLOCAL`
    `static int` | `STATE_SYM_NONE`
    `static int` | `STATE_SYM_RETAINLOCAL`
    `static int` | `STATE_SYM_SHOW`
    `static int` | `STATE_UNITCELL_EXTEND`
    `static int` | `STATE_UNITCELL_PACKED`
    `static int` | `STATE_XTALEDIT`
    `static int` | `STATE_XTALVIEW`
    `static java.lang.String` | `SYMMETRY_OPTIONS`
    `private java.lang.Object` | `symop`
    `static java.lang.String` | `UNITCELL_OPTIONS`
    `private javajs.util.P3` | `viewOffset`
    `private java.lang.String` | `xtalHoverLabel`

    - ### Fields inherited from class org.jmol.popup.JmolGenericPopup

      `frankPopup, menuText, nFrankList, vwr`

    - ### Fields inherited from class org.jmol.popup.GenericPopup

      `allowSignedFeatures, buttonGroup, currentMenuItemId, helper, htCheckbox, htMenus, isApplet, isJS, isSigned, isTainted, isWebGL, menuName, popupMenu, strMenuStructure, thisPopup, thisx, thisy, updatingForShow`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ModelKitPopup()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `actionRotateBond(int deltaX, int deltaY, int x, int y, boolean forceFull)` Actually rotate the bond.
    `private void` | `addAllCheckboxItems(SC menu, java.lang.String[] labels)`
    `private void` | `addData(java.lang.String key, java.lang.Object value)`
    `protected boolean` | `appGetBooleanProperty(java.lang.String name)`
    `protected void` | `appUpdateForShow()`
    `protected void` | `appUpdateSpecialCheckBoxValue(SC source, java.lang.String actionCommand, boolean selected)` Set the active menu based on updating a value -- usually by the user, but also during setup (ignored).
    `private void` | `assignAtom(int atomIndex, java.lang.String type, boolean autoBond, boolean addHsAndBond)` Original ModelKitPopup functionality -- assign an atom.
    `private javajs.util.BS` | `assignBond(int bondIndex, int type)` Original ModelKit functionality -- assign a bond.
    `private boolean` | `checkUpdateSymmetryInfo()`
    `void` | `doMenuClickCallbackMK(SC source, java.lang.String script)`
    `java.lang.String` | `getActiveMenu()` for FrankRender -- the thin box on the top left
    `protected PopupResource` | `getBundle(java.lang.String menu)`
    `private java.lang.Object` | `getData(java.lang.String key)`
    `private java.lang.String` | `getHoverLabel(int atomIndex)` Called by Viewer.hoverOn to set the special label if desired.
    `private int` | `getMKState()`
    `java.lang.Object` | `getProperty(java.lang.Object data)` Get a property of the modelkit.
    `int` | `getRotateBondIndex()`
    `protected java.lang.String` | `getScriptForCallback(SC source, java.lang.String id, java.lang.String script)` Secondary processing of menu item click
    `private int` | `getSymEditState()`
    `private int` | `getSymViewState()`
    `private int` | `getUnitCellState()`
    `java.lang.String` | `getUnknownCheckBoxScriptToRun(SC item, java.lang.String name, java.lang.String what, boolean TF)` From JmolGenericPopup.appRunSpecialCheckBox when name starts with "mk" or has "??" in it.
    `private int` | `getViewState()`
    `boolean` | `handleAssignNew(MouseState pressed, MouseState dragged, MeasurementPending mp, int dragAtomIndex)` C
    `boolean` | `handleDragAtom(MouseState pressed, MouseState dragged, int[] countPlusIndices)` Called from ActionManager for a drag-drop
    `protected void` | `initialize(Viewer vwr, PopupResource bundle, java.lang.String title)`
    `void` | `initializeForModel()`
    `boolean` | `isPickAtomAssignCharge()`
    `private static boolean` | `isTrue(java.lang.Object value)`
    `private boolean` | `isVwrRotateBond()`
    `private boolean` | `isXtalState()`
    `void` | `jpiUpdateComputedMenus()`
    `void` | `menuClickCallback(SC source, java.lang.String script)`
    `void` | `menuFocusCallback(java.lang.String name, java.lang.String actionCommand, boolean gained)`
    `private static void` | `notImplemented(java.lang.String action)`
    `private static javajs.util.P3` | `pointFromTriad(java.lang.String pos)`
    `private boolean` | `processAtomClick(int atomIndex)` An atom has been clicked -- handle it.
    `private void` | `processMKPropertyItem(java.lang.String name, boolean TF)`
    `private void` | `processModeClick(java.lang.String action)`
    `private void` | `processSelClick(java.lang.String action)`
    `private void` | `processSelOpClick(java.lang.String action)`
    `private void` | `processSymClick(java.lang.String action)`
    `private boolean` | `processSymop(java.lang.String id, boolean isFocus)`
    `private void` | `processUCClick(java.lang.String action)`
    `private void` | `processXtalClick(java.lang.String id, java.lang.String action)`
    `private java.lang.String` | `promptUser(java.lang.String msg, java.lang.String def)`
    `private void` | `resetBondFields(java.lang.String where)`
    `private java.lang.String` | `runScriptBuffered(java.lang.String script)`
    `java.lang.String` | `setActiveMenu(java.lang.String name)` Set the active menu and request a repaint.
    `private void` | `setBondIndex(int index, boolean isRotate)` Set the bond for rotation -- called by Sticks.checkObjectHovered via Viewer.highlightBond.
    `private void` | `setDefaultState(int mode)`
    `private void` | `setLabel(java.lang.String key, java.lang.String label)`
    `private void` | `setMKState(int bits)`
    `java.lang.Object` | `setProperty(java.lang.String name, java.lang.Object value)` Modify the state by setting a property -- primarily from CmdExt.modelkit.
    `private void` | `setSymEdit(int bits)`
    `private void` | `setSymViewState(int bits)`
    `private void` | `setUnitCell(int bits)`
    `private void` | `showSymop(java.lang.Object symop)`
    `private void` | `showXtalSymmetry()` Draw the symmetry element
    `private void` | `updateAllXtalMenuOptions()`
    `private void` | `updateAllXtalMenus()`
    `private void` | `updateOperatorMenu()`

    - ### Methods inherited from class org.jmol.popup.JmolGenericPopup

      `appFixLabel, appRestorePopupMenu, appRunScript, appRunSpecialCheckBox, jpiDispose, jpiGetMenuAsObject, jpiInitialize, jpiShow, showFrankMenu`

    - ### Methods inherited from class org.jmol.popup.GenericPopup

      `addMenuItem, addMenuItems, appCheckItem, appCheckSpecialMenu, appGetMenuAsString, convertToMegabytes, doMenuCheckBoxCallback, doMenuClickCallback, getEntryIcon, getImageIcon, initSwing, jpiGetMenuAsString, menuAddSeparator, menuAddSubMenu, menuCheckBoxCallback, menuCreateCheckboxItem, menuCreateItem, menuEnable, menuGetId, menuGetListPosition, menuNewSubMenu, menuRemoveAll, menuSetAutoscrolls, menuSetLabel, menuShowPopup, setText, show, updateButton, updateSignedAppletItems`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### hasUnitCell

          private boolean hasUnitCell

    - #### allOperators

          private java.lang.String[] allOperators

    - #### currentModelIndex

          private int currentModelIndex

    - #### alertedNoEdit

          private boolean alertedNoEdit

    - #### atomHoverLabel

          private java.lang.String atomHoverLabel

    - #### bondHoverLabel

          private java.lang.String bondHoverLabel

    - #### xtalHoverLabel

          private java.lang.String xtalHoverLabel

    - #### activeMenu

          private java.lang.String activeMenu

    - #### lastModelSet

          private ModelSet lastModelSet

    - #### pickAtomAssignType

          private java.lang.String pickAtomAssignType

    - #### pickBondAssignType

          private java.lang.String pickBondAssignType

    - #### isPickAtomAssignCharge

          private boolean isPickAtomAssignCharge

    - #### bsHighlight

          private javajs.util.BS bsHighlight

    - #### bondIndex

          private int bondIndex

    - #### bondAtomIndex1

          private int bondAtomIndex1

    - #### bondAtomIndex2

          private int bondAtomIndex2

    - #### bsRotateBranch

          private javajs.util.BS bsRotateBranch

    - #### branchAtomIndex

          private int branchAtomIndex

    - #### isRotateBond

          private boolean isRotateBond

    - #### screenXY

          private int[] screenXY

    - #### mkdata

          private java.util.Map<java.lang.String,java.lang.Object> mkdata

    - #### showSymopInfo

          private boolean showSymopInfo

    - #### addXtalHydrogens

          private boolean addXtalHydrogens

      when TRUE, add H atoms to C when added to the modelSet.

    - #### clickToSetElement

          private boolean clickToSetElement

      Except for H atoms, do not allow changes to elements just by clicking them. This protects against doing that inadvertently when editing.

    - #### centerPoint

          private javajs.util.P3 centerPoint

    - #### spherePoint

          private javajs.util.P3 spherePoint

    - #### viewOffset

          private javajs.util.P3 viewOffset

    - #### centerDistance

          private float centerDistance

    - #### symop

          private java.lang.Object symop

    - #### centerAtomIndex

          private int centerAtomIndex

    - #### secondAtomIndex

          private int secondAtomIndex

    - #### atomIndexSphere

          private int atomIndexSphere

    - #### drawData

          private java.lang.String drawData

    - #### drawScript

          private java.lang.String drawScript

    - #### iatom0

          private int iatom0

    - #### MAX_LABEL

          private static final int MAX_LABEL

      See Also:
        Constant Field Values

    - #### bundle

          private static PopupResource bundle

    - #### STATE_BITS_XTAL

          public static final int STATE_BITS_XTAL

      See Also:
        Constant Field Values

    - #### STATE_MOLECULAR

          public static final int STATE_MOLECULAR

      See Also:
        Constant Field Values

    - #### STATE_XTALVIEW

          public static final int STATE_XTALVIEW

      See Also:
        Constant Field Values

    - #### STATE_XTALEDIT

          public static final int STATE_XTALEDIT

      See Also:
        Constant Field Values

    - #### STATE_BITS_SYM_VIEW

          public static final int STATE_BITS_SYM_VIEW

      See Also:
        Constant Field Values

    - #### STATE_SYM_NONE

          public static final int STATE_SYM_NONE

      See Also:
        Constant Field Values

    - #### STATE_SYM_SHOW

          public static final int STATE_SYM_SHOW

      See Also:
        Constant Field Values

    - #### STATE_BITS_SYM_EDIT

          public static final int STATE_BITS_SYM_EDIT

      See Also:
        Constant Field Values

    - #### STATE_SYM_APPLYLOCAL

          public static final int STATE_SYM_APPLYLOCAL

      See Also:
        Constant Field Values

    - #### STATE_SYM_RETAINLOCAL

          public static final int STATE_SYM_RETAINLOCAL

      See Also:
        Constant Field Values

    - #### STATE_SYM_APPLYFULL

          public static final int STATE_SYM_APPLYFULL

      See Also:
        Constant Field Values

    - #### STATE_BITS_UNITCELL

          public static final int STATE_BITS_UNITCELL

      See Also:
        Constant Field Values

    - #### STATE_UNITCELL_PACKED

          public static final int STATE_UNITCELL_PACKED

      See Also:
        Constant Field Values

    - #### STATE_UNITCELL_EXTEND

          public static final int STATE_UNITCELL_EXTEND

      See Also:
        Constant Field Values

    - #### MODE_OPTIONS

          public static final java.lang.String MODE_OPTIONS

      See Also:
        Constant Field Values

    - #### SYMMETRY_OPTIONS

          public static final java.lang.String SYMMETRY_OPTIONS

      See Also:
        Constant Field Values

    - #### UNITCELL_OPTIONS

          public static final java.lang.String UNITCELL_OPTIONS

      See Also:
        Constant Field Values

    - #### BOOLEAN_OPTIONS

          public static final java.lang.String BOOLEAN_OPTIONS

      See Also:
        Constant Field Values

    - #### SET_OPTIONS

          public static final java.lang.String SET_OPTIONS

      See Also:
        Constant Field Values

    - #### Pt000

          private static final javajs.util.P3 Pt000

    - #### state

          private int state

    - #### rotationDeg

          private float rotationDeg

    - #### lastCenter

          private java.lang.String lastCenter

    - #### lastOffset

          private java.lang.String lastOffset

  - ### Constructor Detail

    - #### ModelKitPopup

          public ModelKitPopup()

  - ### Method Detail

    - #### initialize

          protected void initialize(Viewer vwr,
                                    PopupResource bundle,
                                    java.lang.String title)

      Overrides:
        `initialize` in class `JmolGenericPopup`

    - #### getBundle

          protected PopupResource getBundle(java.lang.String menu)

      Specified by:
        `getBundle` in class `JmolGenericPopup`

    - #### initializeForModel

          public void initializeForModel()

    - #### jpiUpdateComputedMenus

          public void jpiUpdateComputedMenus()

    - #### appUpdateForShow

          protected void appUpdateForShow()

      Specified by:
        `appUpdateForShow` in class `GenericPopup`

    - #### checkUpdateSymmetryInfo

          private boolean checkUpdateSymmetryInfo()

    - #### updateAllXtalMenus

          private void updateAllXtalMenus()

    - #### updateOperatorMenu

          private void updateOperatorMenu()

    - #### addAllCheckboxItems

          private void addAllCheckboxItems(SC menu,
                                           java.lang.String[] labels)

    - #### updateAllXtalMenuOptions

          private void updateAllXtalMenuOptions()

    - #### setLabel

          private void setLabel(java.lang.String key,
                                java.lang.String label)

    - #### getActiveMenu

          public java.lang.String getActiveMenu()

      for FrankRender -- the thin box on the top left
      Returns:
        [ "atomMenu" | "bondMenu" | "xtalMenu" | null ]

    - #### setActiveMenu

          public java.lang.String setActiveMenu(java.lang.String name)

      Set the active menu and request a repaint.
      Parameters:
        `name` -
      Returns:
        activeMenu or null

    - #### appUpdateSpecialCheckBoxValue

          protected void appUpdateSpecialCheckBoxValue(SC source,
                                                       java.lang.String actionCommand,
                                                       boolean selected)

      Set the active menu based on updating a value -- usually by the user, but also during setup (ignored).
      Specified by:
        `appUpdateSpecialCheckBoxValue` in class `GenericPopup`

    - #### isXtalState

          private boolean isXtalState()

    - #### setMKState

          private void setMKState(int bits)

    - #### getMKState

          private int getMKState()

    - #### setSymEdit

          private void setSymEdit(int bits)

    - #### getSymEditState

          private int getSymEditState()

    - #### getViewState

          private int getViewState()

    - #### setSymViewState

          private void setSymViewState(int bits)

    - #### getSymViewState

          private int getSymViewState()

    - #### setUnitCell

          private void setUnitCell(int bits)

    - #### getUnitCellState

          private int getUnitCellState()

    - #### isPickAtomAssignCharge

          public boolean isPickAtomAssignCharge()

    - #### getProperty

          public java.lang.Object getProperty(java.lang.Object data)

      Get a property of the modelkit.
      Parameters:
        `data` - a name or an array with [name, value]
      Returns:
        value

    - #### setProperty

          public java.lang.Object setProperty(java.lang.String name,
                                              java.lang.Object value)

      Modify the state by setting a property -- primarily from CmdExt.modelkit. Also can be used for "get" purposes.
      Parameters:
        `name` -
        `value` -
      Returns:
        null or "get" value

    - #### isTrue

          private static boolean isTrue(java.lang.Object value)

    - #### getData

          private java.lang.Object getData(java.lang.String key)

    - #### addData

          private void addData(java.lang.String key,
                               java.lang.Object value)

    - #### processAtomClick

          private boolean processAtomClick(int atomIndex)

      An atom has been clicked -- handle it. Called from CmdExt.assignAtom from the script created in ActionManager.assignNew from Actionmanager.checkReleaseAction
      Parameters:
        `atomIndex` -
      Returns:
        true if handled

    - #### getHoverLabel

          private java.lang.String getHoverLabel(int atomIndex)

      Called by Viewer.hoverOn to set the special label if desired.
      Parameters:
        `atomIndex` -
      Returns:
        special label or null

    - #### setDefaultState

          private void setDefaultState(int mode)

    - #### appGetBooleanProperty

          protected boolean appGetBooleanProperty(java.lang.String name)

      Overrides:
        `appGetBooleanProperty` in class `JmolGenericPopup`

    - #### getUnknownCheckBoxScriptToRun

          public java.lang.String getUnknownCheckBoxScriptToRun(SC item,
                                                                java.lang.String name,
                                                                java.lang.String what,
                                                                boolean TF)

      From JmolGenericPopup.appRunSpecialCheckBox when name starts with "mk" or has "??" in it.
      Specified by:
        `getUnknownCheckBoxScriptToRun` in class `GenericPopup`

    - #### processMKPropertyItem

          private void processMKPropertyItem(java.lang.String name,
                                             boolean TF)

    - #### showXtalSymmetry

          private void showXtalSymmetry()

      Draw the symmetry element

    - #### assignAtom

          private void assignAtom(int atomIndex,
                                  java.lang.String type,
                                  boolean autoBond,
                                  boolean addHsAndBond)

      Original ModelKitPopup functionality -- assign an atom.
      Parameters:
        `atomIndex` -
        `type` -
        `autoBond` -
        `addHsAndBond` -

    - #### assignBond

          private javajs.util.BS assignBond(int bondIndex,
                                            int type)

      Original ModelKit functionality -- assign a bond.
      Parameters:
        `bondIndex` -
        `type` -
      Returns:
        bit set of atoms to modify

    - #### isVwrRotateBond

          private boolean isVwrRotateBond()

    - #### getRotateBondIndex

          public int getRotateBondIndex()

    - #### resetBondFields

          private void resetBondFields(java.lang.String where)

    - #### setBondIndex

          private void setBondIndex(int index,
                                    boolean isRotate)

      Set the bond for rotation -- called by Sticks.checkObjectHovered via Viewer.highlightBond.
      Parameters:
        `index` -
        `isRotate` -

    - #### actionRotateBond

          public void actionRotateBond(int deltaX,
                                       int deltaY,
                                       int x,
                                       int y,
                                       boolean forceFull)

      Actually rotate the bond. Called by ActionManager.checkDragWheelAction.
      Parameters:
        `deltaX` -
        `deltaY` -
        `x` -
        `y` -

    - #### menuFocusCallback

          public void menuFocusCallback(java.lang.String name,
                                        java.lang.String actionCommand,
                                        boolean gained)

      Specified by:
        `menuFocusCallback` in class `GenericPopup`

    - #### menuClickCallback

          public void menuClickCallback(SC source,
                                        java.lang.String script)

      Overrides:
        `menuClickCallback` in class `GenericPopup`

    - #### doMenuClickCallbackMK

          public void doMenuClickCallbackMK(SC source,
                                            java.lang.String script)

    - #### getScriptForCallback

          protected java.lang.String getScriptForCallback(SC source,
                                                          java.lang.String id,
                                                          java.lang.String script)

      Secondary processing of menu item click
      Specified by:
        `getScriptForCallback` in class `GenericPopup`

    - #### processXtalClick

          private void processXtalClick(java.lang.String id,
                                        java.lang.String action)

    - #### processSelOpClick

          private void processSelOpClick(java.lang.String action)

    - #### processSymop

          private boolean processSymop(java.lang.String id,
                                       boolean isFocus)

    - #### showSymop

          private void showSymop(java.lang.Object symop)

    - #### processModeClick

          private void processModeClick(java.lang.String action)

    - #### processSelClick

          private void processSelClick(java.lang.String action)

    - #### processSymClick

          private void processSymClick(java.lang.String action)

    - #### processUCClick

          private void processUCClick(java.lang.String action)

    - #### handleDragAtom

          public boolean handleDragAtom(MouseState pressed,
                                        MouseState dragged,
                                        int[] countPlusIndices)

      Called from ActionManager for a drag-drop
      Parameters:
        `pressed` -
        `dragged` -
        `index` -
        `countPlusIndices` -
      Returns:
        true if handled here

    - #### pointFromTriad

          private static javajs.util.P3 pointFromTriad(java.lang.String pos)

    - #### notImplemented

          private static void notImplemented(java.lang.String action)

    - #### promptUser

          private java.lang.String promptUser(java.lang.String msg,
                                              java.lang.String def)

    - #### runScriptBuffered

          private java.lang.String runScriptBuffered(java.lang.String script)

    - #### handleAssignNew

          public boolean handleAssignNew(MouseState pressed,
                                         MouseState dragged,
                                         MeasurementPending mp,
                                         int dragAtomIndex)

      C
      Parameters:
        `pressed` -
        `dragged` -
        `mp` -
        `dragAtomIndex` -
      Returns:
        true if we should do a refresh now