Search in sources :

Example 56 with FrameworkNode

use of kutch.biff.marvin.utility.FrameworkNode in project Board-Instrumentation-Framework by intel.

the class SteelGaugeRadialSteelWidget method HandleValueRange.

/**
 * Sets range for widget - not valid for all widgets
 *
 * @param rangeNode
 * @return
 */
@Override
public boolean HandleValueRange(FrameworkNode rangeNode) {
    double Min = -1234.5678;
    double Max = -1234.5678;
    if (rangeNode.hasAttribute("Min")) {
        Min = rangeNode.getDoubleAttribute("Min", Min);
        if (Min == -1234.5678) {
            return false;
        }
        this.MinValue = Min;
    }
    if (rangeNode.hasAttribute("Max")) {
        Max = rangeNode.getDoubleAttribute("Max", Max);
        if (Max == -1234.5678) {
            return false;
        }
        this.MaxValue = Max;
    }
    for (FrameworkNode node : rangeNode.getChildNodes()) {
        if (node.getNodeName().equalsIgnoreCase("#Text") || node.getNodeName().equalsIgnoreCase("#comment")) {
            continue;
        }
        if (node.getNodeName().equalsIgnoreCase("TickCount")) {
            double MajorTickVal = -1234;
            double MinorTickVal = -1234;
            if (node.hasAttribute("Major")) {
                MajorTickVal = node.getDoubleAttribute("Major", MajorTickVal);
                if (MajorTickVal != -1234) {
                    setMajorTick(MajorTickVal);
                } else {
                    LOGGER.severe("Invalid TickCount:Major ->" + node.getAttribute("Major"));
                    return false;
                }
            }
            if (node.hasAttribute("Minor")) {
                MinorTickVal = node.getDoubleAttribute("Minor", MinorTickVal);
                if (MinorTickVal != -1234) {
                    setMinorTick(MinorTickVal);
                } else {
                    LOGGER.severe("Invalid TickCount:Minor ->" + node.getAttribute("Minor"));
                    return false;
                }
            }
        }
    }
    return true;
}
Also used : FrameworkNode(kutch.biff.marvin.utility.FrameworkNode)

Example 57 with FrameworkNode

use of kutch.biff.marvin.utility.FrameworkNode in project Board-Instrumentation-Framework by intel.

the class TableChartWidget method readRows.

private boolean readRows(FrameworkNode rowMasterNode) {
    for (FrameworkNode rowNode : rowMasterNode.getChildNodes()) {
        if (rowNode.getNodeName().equalsIgnoreCase("Row")) {
            List<TableCellClass> columnsInRow = new ArrayList<>();
            _rows.add(columnsInRow);
            for (FrameworkNode columnNode : rowNode.getChildNodes()) {
                Utility.ValidateAttributes(new String[] { "ID", "Namespace", "DataIndex", "Separator" }, columnNode);
                try {
                    TableCellClass cell = new TableCellClass(columnNode.getAttribute("ID"), columnNode.getAttribute("Namespace"), columnNode.getTextContent());
                    columnsInRow.add(cell);
                    Pair<ValueRange, String> indexInfo = WidgetBuilder.ReadMinionSrcIndexInfo(columnNode);
                    cell.set__dataIndex(indexInfo.getKey());
                    cell.set__dataIndexToken(indexInfo.getValue());
                } catch (IllegalArgumentException ex) {
                    return false;
                }
            }
        }
    }
    return true;
}
Also used : ValueRange(java.time.temporal.ValueRange) ArrayList(java.util.ArrayList) FrameworkNode(kutch.biff.marvin.utility.FrameworkNode)

Example 58 with FrameworkNode

use of kutch.biff.marvin.utility.FrameworkNode in project Board-Instrumentation-Framework by intel.

the class TableChartWidget method readColumn.

private TableColumnClass readColumn(FrameworkNode colNode) {
    TableColumnClass objColumn = null;
    Utility.ValidateAttributes(new String[] { "Text", "Width", "Decimals" }, colNode);
    if (colNode.hasAttribute("Text")) {
        objColumn = new TableColumnClass(colNode.getAttribute("Text"));
        for (FrameworkNode subNode : colNode.getChildNodes()) {
            if (subNode.getNodeName().equalsIgnoreCase("Column")) {
                TableColumnClass objSubCol = readColumn(subNode);
                if (null != objSubCol) {
                    objColumn.addSubColumn(objSubCol);
                } else {
                    return null;
                }
            }
        }
    } else {
        LOGGER.severe("TableChart Widget <Column> requires 'Text' attribute");
        return null;
    }
    if (colNode.hasAttribute("Decimals")) {
        _decimals.add(colNode.getIntegerAttribute("Decimals", -1));
    } else {
        _decimals.add(-2);
    }
    if (colNode.hasAttribute("Width")) {
        int width = -1;
        if (!colNode.getAttribute("Width").contains("%")) {
            width = colNode.getIntegerAttribute("Width", -1);
        }
        if (-1 == width) {
            if (colNode.getAttribute("Width").contains("%")) {
                String[] parts = colNode.getAttribute("Width").split("%");
                if (parts.length == 1) {
                    try {
                        double dVal = Double.parseDouble(parts[0]);
                        objColumn.setPercentWidth(dVal);
                    } catch (Exception ex) {
                        LOGGER.severe("Width of TableChart column is invalid: " + colNode.getAttribute("Width"));
                    }
                } else {
                    LOGGER.severe("Width of TableChart column is invalid: " + colNode.getAttribute("Width"));
                }
            } else {
                LOGGER.severe("Width of TableChart column is invalid: " + colNode.getAttribute("Width"));
            }
        }
        objColumn.setWidth(width);
    }
    return objColumn;
}
Also used : FrameworkNode(kutch.biff.marvin.utility.FrameworkNode)

Example 59 with FrameworkNode

use of kutch.biff.marvin.utility.FrameworkNode in project Board-Instrumentation-Framework by intel.

the class QuickViewLCDWidgetBuilder method Build.

public static QuickViewLCDWidget Build(FrameworkNode masterNode, String widgetDefFilename) {
    QuickViewLCDWidget _widget = new QuickViewLCDWidget();
    for (FrameworkNode node : masterNode.getChildNodes()) {
        if (BaseWidget.HandleCommonDefinitionFileConfig(_widget, node)) {
        } else if (node.getNodeName().equalsIgnoreCase("#comment")) {
        } else if (node.getNodeName().equalsIgnoreCase("RowWidth")) {
            String str = node.getTextContent();
            try {
                _widget.setRowWidth(Integer.parseInt(str));
            } catch (NumberFormatException ex) {
                LOGGER.severe("Invalid <RowWidth> in QuickViewWidget Widget Definition File : " + str);
                return null;
            }
        } else if (node.getNodeName().equalsIgnoreCase("EvenBackgroundStyle")) {
            _widget.setEvenBackgroundStyle(node.getTextContent());
        } else if (node.getNodeName().equalsIgnoreCase("EvenStyle")) {
            String ID = "";
            if (node.hasAttribute("ID")) {
                ID = node.getAttribute("ID");
            }
            _widget.setEvenStyle(ID, node.getTextContent());
        } else if (node.getNodeName().equalsIgnoreCase("OddBackgroundStyle")) {
            _widget.setOddBackgroundStyle(node.getTextContent());
        } else if (node.getNodeName().equalsIgnoreCase("OddStyle")) {
            String ID = "";
            if (node.hasAttribute("ID")) {
                ID = node.getAttribute("ID");
            }
            _widget.setOddStyle(ID, node.getTextContent());
        } else if (node.getNodeName().equalsIgnoreCase("Order")) {
            String strVal = node.getTextContent();
            if (strVal.equalsIgnoreCase(QuickViewWidget.SortMode.Ascending.toString())) {
                _widget.setSortMode(QuickViewLCDWidget.SortMode.Ascending);
            } else if (strVal.equalsIgnoreCase(QuickViewLCDWidget.SortMode.Descending.toString())) {
                _widget.setSortMode(QuickViewLCDWidget.SortMode.Descending);
            } else if (strVal.equalsIgnoreCase(QuickViewWidget.SortMode.None.toString())) {
                _widget.setSortMode(QuickViewLCDWidget.SortMode.None);
            } else {
                LOGGER.severe("Invalid <Order> Tag in QuickViewLCDWidget Widget Definition File. " + strVal);
                return null;
            }
        } else {
            LOGGER.severe("Invalid QuickViewLCDWidget Widget Definition File.  Unknown Tag: " + node.getNodeName());
            return null;
        }
    }
    return _widget;
}
Also used : QuickViewLCDWidget(kutch.biff.marvin.widget.QuickViewLCDWidget) FrameworkNode(kutch.biff.marvin.utility.FrameworkNode)

Example 60 with FrameworkNode

use of kutch.biff.marvin.utility.FrameworkNode in project Board-Instrumentation-Framework by intel.

the class DynamicTransition method ReadTransitionInformation.

public static DynamicTransition ReadTransitionInformation(FrameworkNode baseNode) {
    DynamicTransition.Transition _TransitionType = DynamicTransition.Transition.NONE;
    int _Transition_xGridCount = 10;
    int _Transition_yGridCount = 10;
    int _Transition_Delay = 100;
    Color _Transition_Snapshot_Color_bg = Color.TRANSPARENT;
    Duration _Transition_Duration = Duration.millis(1500);
    for (FrameworkNode node : baseNode.getChildNodes()) {
        if (node.getNodeName().equalsIgnoreCase("#Text") || node.getNodeName().equalsIgnoreCase("#Comment")) {
            continue;
        }
        if (node.getNodeName().equalsIgnoreCase("Transition")) {
            String strTransition = node.getTextContent();
            _TransitionType = DynamicTransition.VerifyTransitionType(strTransition);
            if (_TransitionType == DynamicTransition.Transition.INVALID) {
                LOGGER.severe("Invalid Transition [" + strTransition + "] specified.  Valid values are: " + DynamicTransition.names());
                return null;
            }
            if (node.hasAttribute("xGrids")) {
                _Transition_xGridCount = node.getIntegerAttribute("xGrids", 0);
                if (_Transition_xGridCount <= 0) {
                    LOGGER.severe("Invlid xGrids value for Transition: " + node.getAttribute("xGrids"));
                    return null;
                }
            }
            if (node.hasAttribute("yGrids")) {
                _Transition_yGridCount = node.getIntegerAttribute("yGrids", 0);
                if (_Transition_yGridCount <= 0) {
                    LOGGER.severe("Invlid yGrids value for Transition: " + node.getAttribute("yGrids"));
                    return null;
                }
            }
            if (node.hasAttribute("Duration")) {
                int Transition_Duration = node.getIntegerAttribute("Duration", 0);
                if (Transition_Duration <= 0) {
                    LOGGER.severe("Invlid Duration value for Transition: " + node.getAttribute("Duration"));
                    return null;
                }
                _Transition_Duration = Duration.millis(Transition_Duration);
            }
            if (node.hasAttribute("Delay")) {
                _Transition_Delay = node.getIntegerAttribute("Delay", 0);
                if (_Transition_Delay <= 0) {
                    LOGGER.severe("Invlid Delay value for Transition: " + node.getAttribute("Delay"));
                    return null;
                }
            }
        // nuking this, s not really needed anymore
        // if (node.hasAttribute("Background"))
        // {
        // String strColor = node.getAttribute("Background");
        // try
        // {
        // _Transition_Snapshot_Color_bg = Color.web(strColor);
        // }
        // catch (Exception e)
        // {
        // LOGGER.severe("Invalid Background value for getTransition: " + strColor);
        // return false;
        // }
        // }
        }
    }
    DynamicTransition objTransition = new DynamicTransition(_TransitionType);
    objTransition.setDelay(_Transition_Delay);
    objTransition.setDuration(_Transition_Duration);
    objTransition.setNoOfTilesX(_Transition_xGridCount);
    objTransition.setNoOfTilesY(_Transition_yGridCount);
    objTransition.setSnapshotColor(_Transition_Snapshot_Color_bg);
    // _objTransition = objTransition;
    return objTransition;
}
Also used : Color(javafx.scene.paint.Color) Duration(javafx.util.Duration) FrameworkNode(kutch.biff.marvin.utility.FrameworkNode)

Aggregations

FrameworkNode (kutch.biff.marvin.utility.FrameworkNode)65 ArrayList (java.util.ArrayList)11 IOException (java.io.IOException)8 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)8 SAXException (org.xml.sax.SAXException)8 NodeList (org.w3c.dom.NodeList)6 List (java.util.List)4 BaseWidget (kutch.biff.marvin.widget.BaseWidget)4 Document (org.w3c.dom.Document)4 Pair (javafx.util.Pair)3 DynamicItemInfoContainer (kutch.biff.marvin.utility.DynamicItemInfoContainer)3 DynamicGridWidget (kutch.biff.marvin.widget.DynamicGridWidget)3 GridWidget (kutch.biff.marvin.widget.GridWidget)3 OnDemandGridWidget (kutch.biff.marvin.widget.OnDemandGridWidget)3 Node (org.w3c.dom.Node)3 File (java.io.File)2 ValueRange (java.time.temporal.ValueRange)2 DocumentBuilder (javax.xml.parsers.DocumentBuilder)2 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)2 SeriesDataSet (kutch.biff.marvin.utility.SeriesDataSet)2