Search in sources :

Example 6 with BitPackNodeIndex

use of CCDD.CcddClassesDataTable.BitPackNodeIndex in project CCDD by nasa.

the class CcddCommonTreeHandler method getStringVariableMembers.

/**
 ********************************************************************************************
 * Determine the node indices in the table tree that encompass the array members that represent
 * the individual bytes of a string variable
 *
 * @param node
 *            selected node for a (potentially) bit-packed variable
 *
 * @return NodeIndex object containing the node indices bounding the string variable
 ********************************************************************************************
 */
protected BitPackNodeIndex getStringVariableMembers(ToolTipTreeNode node) {
    // Get the target variable's data type and name from the node without the string size array
    // index
    String variableName = ArrayVariable.removeStringSize(removeExtraText(node.getUserObject().toString()));
    // Get the corresponding node in the variable tree
    ToolTipTreeNode tblParent = (ToolTipTreeNode) node.getParent();
    // Get this variable tree node's index in the variable tree relative to its parent node
    int tblIndex = tblParent.getIndex(node);
    // Set the current index in preparation for locating other variables packed with this one
    int curIndex = tblIndex - 1;
    // the array members that make up the target string
    while (curIndex >= 0) {
        // Check if the variable at this node doesn't match the target variable
        if (!variableName.equals(ArrayVariable.removeStringSize(removeExtraText(((ToolTipTreeNode) tblParent.getChildAt(curIndex)).getUserObject().toString())))) {
            // Stop searching
            break;
        }
        curIndex--;
    }
    // Adjust the index and save this as the starting index, and store its associated tree node
    // index
    curIndex++;
    int firstIndex = curIndex;
    // the target string
    while (curIndex < node.getSiblingCount()) {
        // Check if this variable at this node doesn't match the target variable
        if (!variableName.equals(ArrayVariable.removeStringSize(removeExtraText(((ToolTipTreeNode) tblParent.getChildAt(curIndex)).getUserObject().toString())))) {
            // Stop searching
            break;
        }
        curIndex++;
    }
    // Store the last index in the pack. If the variable isn't bit-packed (i.e., has no bit
    // length or has no other pack members) then the last index is the same as the first index
    int lastIndex = curIndex - 1;
    return new BitPackNodeIndex(firstIndex, lastIndex, tblIndex);
}
Also used : BitPackNodeIndex(CCDD.CcddClassesDataTable.BitPackNodeIndex) ToolTipTreeNode(CCDD.CcddClassesComponent.ToolTipTreeNode)

Example 7 with BitPackNodeIndex

use of CCDD.CcddClassesDataTable.BitPackNodeIndex in project CCDD by nasa.

the class CcddCommonTreeHandler method setVariableNodeIcon.

/**
 ********************************************************************************************
 * Set the tree icon for nodes representing a variable. The icon indicates if the variable is
 * or isn't bit-wise, is or isn't linked, and is or isn't bit-packed
 *
 * @param renderer
 *            reference to the tree's cell renderer
 *
 * @param node
 *            node for which the icon is to be set
 *
 * @param currentRow
 *            row index of the node in the tree
 *
 * @param isLinked
 *            true if the variable is a member of a link
 ********************************************************************************************
 */
protected void setVariableNodeIcon(DefaultTreeCellRenderer renderer, ToolTipTreeNode node, int currentRow, boolean isLinked) {
    // Assume this is a normal variable (not bit-wise, linked, or packed)
    Icon icon = variableIcon;
    // Check if this is a bit-wise variable (node name ends with ':#')
    if (node.toString().matches("^.+:\\d+$")) {
        // an earlier row
        if (currentRow <= lastPackRow) {
            // Check if the variable is a link member
            if (isLinked) {
                // Set the icon to indicate this is a linked & bit-packed variable
                icon = linkedPackedVariableIcon;
            } else // The variable isn't a link member
            {
                // Set the icon to indicate this is a bit-packed variable
                icon = packedVariableIcon;
            }
        } else // The row is not within a known bit-packed group
        {
            // Determine if this row's variable is bit-packed with other variables
            BitPackNodeIndex nodeIndex = getBitPackedVariables(node);
            // Check if the variable is bit-packed with other variables
            if (nodeIndex.getFirstIndex() != nodeIndex.getLastIndex()) {
                // Check if the variable is a link member
                if (isLinked) {
                    // Set the icon to indicate this is a linked & bit-packed variable
                    icon = linkedPackedVariableIcon;
                } else // The variable isn't a link member
                {
                    // Set the icon to indicate this is a bit-packed variable
                    icon = packedVariableIcon;
                }
                // Store the row containing the last member of the pack
                lastPackRow = nodeIndex.getLastIndex();
            } else // The variable is not bit-packed
            {
                // Check if the variable is a link member
                if (isLinked) {
                    // Set the icon to indicate this is a linked & bit-wise variable
                    icon = linkedBitVariableIcon;
                } else // The variable isn't a link member
                {
                    // Set the icon to indicate a bit-wise variable
                    icon = bitVariableIcon;
                }
                // Reset the last pack member row
                lastPackRow = -1;
            }
        }
    } else // Not a bit-wise variable
    {
        // Check if the variable is a link member
        if (isLinked) {
            // Set the icon to indicate this is a linked variable
            icon = linkedVariableIcon;
        }
        // Reset the last pack member row
        lastPackRow = -1;
    }
    // Display the icon for the variable
    renderer.setIcon(icon);
}
Also used : BitPackNodeIndex(CCDD.CcddClassesDataTable.BitPackNodeIndex) Icon(javax.swing.Icon) ImageIcon(javax.swing.ImageIcon)

Aggregations

BitPackNodeIndex (CCDD.CcddClassesDataTable.BitPackNodeIndex)7 ToolTipTreeNode (CCDD.CcddClassesComponent.ToolTipTreeNode)6 ArrayList (java.util.ArrayList)2 AssociatedVariable (CCDD.CcddClassesDataTable.AssociatedVariable)1 TelemetryData (CCDD.CcddClassesDataTable.TelemetryData)1 Variable (CCDD.CcddClassesDataTable.Variable)1 List (java.util.List)1 Icon (javax.swing.Icon)1 ImageIcon (javax.swing.ImageIcon)1