# Class ModelKit

java.lang.Object
org.jmol.modelkit.ModelKit

public class ModelKit extends Object
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
Description
`protected final BS`
`bsKeyModels`
a bitset indicating the presence of element keys for models; clearing a bit will cause a new key to be produced.
`protected final BS`
`bsKeyModelsOFF`
tracks models for which the element key has been explicitly set OFF, overriding global SET elementKey ON
`protected boolean`
`haveKeys`
`protected char`
`keyType`
from SET ELEMENTKEY ON/OFF or SET LABELKEY ON/OFF; TRUE to automatically set element keys for all model s; off to turn them off
`protected ModelSet`
`lastModelSet`
`protected Viewer`
`vwr`

## Constructor Summary

Constructors
Constructor
Description
`ModelKit()`

## Method Summary

Modifier and Type
Method
Description
`void`
`actionRotateBond(int deltaX, int deltaY, int x, int y, boolean forceFull)`
Actually rotate the bond.
`void`
`addAtomSet(String data)`
`void`
`addLockedAtoms(SymmetryInterface sg, BS bsLocked)`
Only for the current model
`int`
`checkMovedAtoms(BS bsFixed, BS bsAtoms, P3[] apos0)`
Something has changed atom positions.
`protected boolean`
`checkNewModel()`
`boolean`
`checkOption(char type, String key)`
MODELKIT SET options for syntax checking.
`void`
`clearAtomConstraints()`
`void`
`clickAssignAtom(int atomIndex, String element, P3 ptNew)`
From Mouse or handleAtomOrBondBicked
`protected void`
`clickProcessXtal(String id, String action)`
`int`
`cmdAssignAddAtoms(String type, P3[] pts, BS bsAtoms, float packing, String cmd)`
MODELKIT ADD @3 ...
`void`
`cmdAssignAtom(BS bs, P3 pt, String type, String cmd)`
A versatile method that allows changing element, setting charge, setting position, adding or deleting an atom via MODELKIT ASSIGN ATOM
`void`
`cmdAssignBond(int bondIndex, char type, String cmd)`
`void`
`cmdAssignConnect(int index, int index2, char type, String cmd)`
`int`
`cmdAssignDeleteAtoms(BS bs)`
Delete all atoms that are equivalent to this atom.
`int`
`cmdAssignMoveAtoms(BS bsSelected, int iatom, P3 p, P3[] pts, boolean allowProjection, boolean isMolecule, boolean isCommand)`
`void`
`cmdAssignSpaceGroup(String transform, SB sb, String cmd, float packing, boolean doDraw)`
MODELKIT SPACEGROUP
`int`
`cmdFillOABC(T3[] oabc, float packing, String cmd)`
`void`
`cmdMinimize(JmolScriptEvaluator eval, BS bsBasis, int steps, float crit, float rangeFixed, int flags)`
Minimize a unit cell with full symmetry constraints.
`void`
`cmdPackUnitCell(SymmetryInterface sym, BS bsAtoms, float packing)`
MODELKIT {1 0 0} PACKED
`int`
`cmdRotateAtoms(BS bsAtoms, P3[] points, float endDegrees)`
`void`
`dispose()`
`void`
`drawAxes(P3[] points, String id, String swidth)`
`String`
`drawSymmetry(String thisId, boolean isSymop, int iatom, String xyz, int iSym, P3 trans, P3 center, P3 target, int intScale, int nth, int options, int[] opList, boolean isModelkit)`
`void`
`drawSymop(int a1, int a2)`
from set picking symop
`void`
`drawUnitCell(String id, T3 ucLattice, String swidth)`
`protected void`
`exitBondRotation(String text)`
`String`
`getActiveMenu()`
for the thin box on the top left of the window
`protected String[]`
`getAllOperators()`
`protected Atom`
`getBasisAtom(int iatom)`
`protected String`
`getCenterText()`
`String`
`getDefaultModel()`
`protected String`
`getElementFromUser()`
`protected static String`
`getKey(int modelIndex, char ext)`
`protected int`
`getMKState()`
`Object`
`getProperty(String name)`
Get a property of the modelkit.
`int`
`getRotateBondIndex()`
`SymmetryInterface`
`getSym(int iatom)`
`protected int`
`getSymEditState()`
`protected String`
`getSymopText()`
`protected int`
`getSymViewState()`
`protected int`
`getUnitCellState()`
`boolean`
`handleAssignNew(MouseState pressed, MouseState dragged, MeasurementPending mp, int dragAtomIndex, int key)`
handle a mouse-generated assignNew event
`boolean`
`hasConstraint(int iatom, boolean ignoreGeneral, boolean addNew)`
`boolean`
`isHidden()`
`boolean`
`isPickAtomAssignCharge()`
`protected boolean`
`isXtalState()`
`void`
`minimizeEnd(BS bsBasis2, boolean isEnd)`
`int`
`moveMinConstrained(int iatom, P3 p, BS bsAtoms)`
`protected void`
`processMKPropertyItem(String name, boolean TF)`
`protected boolean`
`processSymop(String id, boolean isFocus)`
`protected void`
`resetAtomPickType()`
`MeasurementPending`
`setBondMeasure(int bi, MeasurementPending mp)`
`protected org.jmol.modelkit.ModelKit.Constraint`
`setConstraint(SymmetryInterface sym, int ia, int mode)`
This constraint will be set for the site only.
`protected boolean`
`setHasUnitCell()`
`protected void`
`setHoverLabel(String mode, String text)`
`void`
`setMenu(ModelKitPopup menu)`
`protected void`
`setMKState(int bits)`
`Object`
`setProperty(String key, Object value)`
Modify the state by setting a property.
`void`
`showMenu(int x, int y)`
`boolean`
`transformAtomsToUnitCell(SymmetryInterface sym, T3[] oabc, String ucname)`
Transform the atoms to fractional coordinate, set the unit cell to a new cell, and then transform them back to Cartesians.
`void`
`updateMenu()`
`boolean`
`wasRotating()`

### Methods inherited from class Object

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

## Field Details

### vwr

protected Viewer vwr

### lastModelSet

protected ModelSet lastModelSet

### keyType

protected char keyType
from SET ELEMENTKEY ON/OFF or SET LABELKEY ON/OFF; TRUE to automatically set element keys for all model s; off to turn them off

### bsKeyModels

protected final BS bsKeyModels
a bitset indicating the presence of element keys for models; clearing a bit will cause a new key to be produced.

### bsKeyModelsOFF

protected final BS bsKeyModelsOFF
tracks models for which the element key has been explicitly set OFF, overriding global SET elementKey ON

### haveKeys

protected boolean haveKeys

## Constructor Details

### ModelKit

public ModelKit()

## Method Details

### getKey

protected static String getKey(int modelIndex, char ext)

### actionRotateBond

public void actionRotateBond(int deltaX, int deltaY, int x, int y, boolean forceFull)
Actually rotate the bond.

Parameters:
  `deltaX` -
  `deltaY` -
  `x` -
  `y` -
  `forceFull` -

### addLockedAtoms

public void addLockedAtoms(SymmetryInterface sg, BS bsLocked)
Only for the current model

Parameters:
  `sg` -
  `bsLocked` -

### checkMovedAtoms

public int checkMovedAtoms(BS bsFixed, BS bsAtoms, P3[] apos0)
Something has changed atom positions. Check to see that this is allowed and, if it is, move all equivalent atoms appropriately. If it is not, then revert.

Parameters:
  `bsFixed` -
  `bsAtoms` -
  `apos0` - original positions
Returns:
  number of atoms moved, possibly 0

### checkOption

public boolean checkOption(char type, String key)
MODELKIT SET options for syntax checking.

Parameters:
  `type` - 'M' menu, 'S' symmetry 'U' unit cell, 'B' boolean
  `key` -
Returns:
  true if the type exists

### clearAtomConstraints

public void clearAtomConstraints()

### clickAssignAtom

public void clickAssignAtom(int atomIndex, String element, P3 ptNew)
From Mouse or handleAtomOrBondBicked

Parameters:
  `atomIndex` - initiating atom clicked or dragged from
  `element` - chemical symbol or "X" for delete, or one of the pickAssignTypes, such as increase/decrease charge
  `ptNew` - if dragged to a new location to create a bond

### cmdAssignAddAtoms

public int cmdAssignAddAtoms(String type, P3[] pts, BS bsAtoms, float packing, String cmd)
MODELKIT ADD @3 ... MODELKIT ADD _C wyckoff invalid input: '<'[a-zAG] MODELKIT ADD C <point> | <array of points> this model only

Parameters:
  `type` - <element Symbol> | "_"<element Symbol> | <element symbol>":"invalid input: '<'Wyckoff letter [a-zAG]
  `pts` - one or more new points, may be null
  `bsAtoms` - the atoms to process, presumably from different sites
  `packing` -
  `cmd` - the command generating this call
Returns:
  the number of atoms added

### cmdAssignAtom

public void cmdAssignAtom(BS bs, P3 pt, String type, String cmd)
A versatile method that allows changing element, setting charge, setting position, adding or deleting an atom via MODELKIT ASSIGN ATOM

Parameters:
  `bs` - may be -1
  `pt` - a Cartesian position for a new atom or when moving an atom to a new position
  `type` - one of: an element symbol, "X" (delete), "Mi" (decrement charge), "Pl" (increment charge), "." (from connect; just adding hydrogens)
  `cmd` - reference command given; may be null

### cmdAssignBond

public void cmdAssignBond(int bondIndex, char type, String cmd)

### cmdAssignConnect

public void cmdAssignConnect(int index, int index2, char type, String cmd)

Parameters:
  `index` -
  `index2` -
  `type` -
  `cmd` -

### cmdAssignSpaceGroup

public void cmdAssignSpaceGroup(String transform, SB sb, String cmd, float packing, boolean doDraw)
MODELKIT SPACEGROUP

Parameters:
  `transform` -
  `sb` -
  `cmd` -
  `packing` -
  `doDraw` -

### cmdAssignDeleteAtoms

public int cmdAssignDeleteAtoms(BS bs)
Delete all atoms that are equivalent to this atom.

Parameters:
  `bs` -
Returns:
  number of deleted atoms

### cmdPackUnitCell

public void cmdPackUnitCell(SymmetryInterface sym, BS bsAtoms, float packing)
MODELKIT {1 0 0} PACKED

Parameters:
  `sym` -
  `bsAtoms` -
  `packing` -

### cmdFillOABC

public int cmdFillOABC(T3[] oabc, float packing, String cmd)

### cmdAssignMoveAtoms

public int cmdAssignMoveAtoms(BS bsSelected, int iatom, P3 p, P3[] pts, boolean allowProjection, boolean isMolecule, boolean isCommand)

### cmdMinimize

public void cmdMinimize(JmolScriptEvaluator eval, BS bsBasis, int steps, float crit, float rangeFixed, int flags) throws Exception
Minimize a unit cell with full symmetry constraints. The model will be loaded with a 27-cell packing, but only the basis atoms themselves will be loaded.

Parameters:
  `eval` -
  `bsBasis` -
  `steps` -
  `crit` -
  `rangeFixed` -
  `flags` -
Throws:
  `Exception`

### cmdRotateAtoms

public int cmdRotateAtoms(BS bsAtoms, P3[] points, float endDegrees)

### dispose

public void dispose()

### getActiveMenu

public String getActiveMenu()
for the thin box on the top left of the window

Returns:
  [ "atomMenu" | "bondMenu" | "xtalMenu" | null ]

### getDefaultModel

public String getDefaultModel()

### getProperty

public Object getProperty(String name)
Get a property of the modelkit.

Parameters:
  `name` -
Returns:
  value

### getRotateBondIndex

public int getRotateBondIndex()

### getSym

public SymmetryInterface getSym(int iatom)

### handleAssignNew

public boolean handleAssignNew(MouseState pressed, MouseState dragged, MeasurementPending mp, int dragAtomIndex, int key)
handle a mouse-generated assignNew event

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

### hasConstraint

public boolean hasConstraint(int iatom, boolean ignoreGeneral, boolean addNew)

### isHidden

public boolean isHidden()

### isPickAtomAssignCharge

public boolean isPickAtomAssignCharge()

### minimizeEnd

public void minimizeEnd(BS bsBasis2, boolean isEnd)

### moveMinConstrained

public int moveMinConstrained(int iatom, P3 p, BS bsAtoms)

### setBondMeasure

public MeasurementPending setBondMeasure(int bi, MeasurementPending mp)

### setMenu

public void setMenu(ModelKitPopup menu)

### setProperty

public Object setProperty(String key, Object value)
Modify the state by setting a property. Also can be used for "get" purposes.

Parameters:
  `key` -
  `value` - to set, or null to simply return the current value
Returns:
  null or "get" value

### showMenu

public void showMenu(int x, int y)

### updateMenu

public void updateMenu()

### wasRotating

public boolean wasRotating()

### checkNewModel

protected boolean checkNewModel()

### clickProcessXtal

protected void clickProcessXtal(String id, String action)

### exitBondRotation

protected void exitBondRotation(String text)

### getAllOperators

protected String[] getAllOperators()

### getBasisAtom

protected Atom getBasisAtom(int iatom)

### getCenterText

protected String getCenterText()

### getElementFromUser

protected String getElementFromUser()

### getMKState

protected int getMKState()

### getSymEditState

protected int getSymEditState()

### getSymopText

protected String getSymopText()

### getSymViewState

protected int getSymViewState()

### getUnitCellState

protected int getUnitCellState()

### isXtalState

protected boolean isXtalState()

### processMKPropertyItem

protected void processMKPropertyItem(String name, boolean TF)

### processSymop

protected boolean processSymop(String id, boolean isFocus)

### resetAtomPickType

protected void resetAtomPickType()

### setConstraint

protected org.jmol.modelkit.ModelKit.Constraint setConstraint(SymmetryInterface sym, int ia, int mode)
This constraint will be set for the site only.

Parameters:
  `sym` -
  `ia` -
  `mode` - GET, GET_CREATE, or GET_DELETE
Returns:
  a Constraint, or possibly null if not createNew

### setHasUnitCell

protected boolean setHasUnitCell()

### setHoverLabel

protected void setHoverLabel(String mode, String text)

### setMKState

protected void setMKState(int bits)

### transformAtomsToUnitCell

public boolean transformAtomsToUnitCell(SymmetryInterface sym, T3[] oabc, String ucname)
Transform the atoms to fractional coordinate, set the unit cell to a new cell, and then transform them back to Cartesians.

Parameters:
  `sym` -
  `oabc` -
  `ucname` -
Returns:
  true if this is a "reset" with no atoms or sym == null

### drawSymop

public void drawSymop(int a1, int a2)
from set picking symop

Parameters:
  `a1` -
  `a2` -

### addAtomSet

public void addAtomSet(String data)

### drawUnitCell

public void drawUnitCell(String id, T3 ucLattice, String swidth)

Parameters:
  `id` -
  `ucLattice` -
  `swidth` -

### drawAxes

public void drawAxes(P3[] points, String id, String swidth)

### drawSymmetry

public String drawSymmetry(String thisId, boolean isSymop, int iatom, String xyz, int iSym, P3 trans, P3 center, P3 target, int intScale, int nth, int options, int[] opList, boolean isModelkit)