private Settings unmarshallFiles(Node urlNode, Settings settings) { Node n; NodeList nodes = urlNode.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { n = nodes.item(i); if (n.getNodeType() == ELEMENT_NODE && n.getNodeName().equalsIgnoreCase("ecudefinitionfile")) { settings.addEcuDefinitionFile(new File(unmarshallAttribute(n, "name", "ecu_defs.xml"))); } else if (n.getNodeType() == ELEMENT_NODE && n.getNodeName().equalsIgnoreCase("image_dir")) { settings.setLastImageDir(new File(unmarshallAttribute(n, "path", "ecu_defs.xml"))); } } return settings; }
private Settings unmarshallColors(Node colorNode, Settings settings) { Node n; NodeList nodes = colorNode.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { n = nodes.item(i); if (n.getNodeType() == ELEMENT_NODE && n.getNodeName().equalsIgnoreCase("max")) { settings.setMaxColor(unmarshallColor(n)); } else if (n.getNodeType() == ELEMENT_NODE && n.getNodeName().equalsIgnoreCase("min")) { settings.setMinColor(unmarshallColor(n)); } else if (n.getNodeType() == ELEMENT_NODE && n.getNodeName().equalsIgnoreCase("highlight")) { settings.setHighlightColor(unmarshallColor(n)); } else if (n.getNodeType() == ELEMENT_NODE && n.getNodeName().equalsIgnoreCase("increaseborder")) { settings.setIncreaseBorder(unmarshallColor(n)); } else if (n.getNodeType() == ELEMENT_NODE && n.getNodeName().equalsIgnoreCase("decreaseborder")) { settings.setDecreaseBorder(unmarshallColor(n)); } else if (n.getNodeType() == ELEMENT_NODE && n.getNodeName().equalsIgnoreCase("axis")) { settings.setAxisColor(unmarshallColor(n)); } else if (n.getNodeType() == ELEMENT_NODE && n.getNodeName().equalsIgnoreCase("warning")) { settings.setWarningColor(unmarshallColor(n)); } } return settings; }
public IIOMetadataNode buildFiles(Settings settings) { IIOMetadataNode files = new IIOMetadataNode("files"); // image directory IIOMetadataNode imageDir = new IIOMetadataNode("image_dir"); imageDir.setAttribute("path", settings.getLastImageDir().getAbsolutePath()); files.appendChild(imageDir); // ecu definition files Vector<File> defFiles = settings.getEcuDefinitionFiles(); for (int i = 0; i < defFiles.size(); i++) { IIOMetadataNode ecuDef = new IIOMetadataNode("ecudefinitionfile"); ecuDef.setAttribute("name", defFiles.get(i).getAbsolutePath()); files.appendChild(ecuDef); } return files; }
private Settings unmarshallLogger(Node windowNode, Settings settings) { Node n; NodeList nodes = windowNode.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { n = nodes.item(i); if (n.getNodeType() == ELEMENT_NODE && n.getNodeName().equalsIgnoreCase("size")) { settings.setLoggerWindowSize( new Dimension(unmarshallAttribute(n, "y", 600), unmarshallAttribute(n, "x", 1000))); } else if (n.getNodeType() == ELEMENT_NODE && n.getNodeName().equalsIgnoreCase("location")) { settings.setLoggerWindowLocation( new Point(unmarshallAttribute(n, "x", 150), unmarshallAttribute(n, "y", 150))); } else if (n.getNodeType() == ELEMENT_NODE && n.getNodeName().equalsIgnoreCase("profile")) { settings.setLoggerProfileFilePath(unmarshallAttribute(n, "path", "")); } } return settings; }
private Settings unmarshallOptions(Node optionNode, Settings settings) { Node n; NodeList nodes = optionNode.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { n = nodes.item(i); if (n.getNodeType() == ELEMENT_NODE && n.getNodeName().equalsIgnoreCase("obsoletewarning")) { settings.setObsoleteWarning(Boolean.parseBoolean(unmarshallAttribute(n, "value", "true"))); } else if (n.getNodeType() == ELEMENT_NODE && n.getNodeName().equalsIgnoreCase("debug")) { settings.setDebug(Boolean.parseBoolean(unmarshallAttribute(n, "value", "true"))); } else if (n.getNodeType() == ELEMENT_NODE && n.getNodeName().equalsIgnoreCase("calcconflictwarning")) { settings.setCalcConflictWarning( Boolean.parseBoolean(unmarshallAttribute(n, "value", "true"))); } else if (n.getNodeType() == ELEMENT_NODE && n.getNodeName().equalsIgnoreCase("userlevel")) { settings.setUserLevel(unmarshallAttribute(n, "value", 1)); } else if (n.getNodeType() == ELEMENT_NODE && n.getNodeName().equalsIgnoreCase("tableclickcount")) { settings.setTableClickCount(unmarshallAttribute(n, "value", 2)); } else if (n.getNodeType() == ELEMENT_NODE && n.getNodeName().equalsIgnoreCase("version")) { settings.setRecentVersion(unmarshallAttribute(n, "value", "")); } else if (n.getNodeType() == ELEMENT_NODE && n.getNodeName().equalsIgnoreCase("savedebugtables")) { settings.setSaveDebugTables(Boolean.parseBoolean(unmarshallAttribute(n, "value", "false"))); } else if (n.getNodeType() == ELEMENT_NODE && n.getNodeName().equalsIgnoreCase("displayhightables")) { settings.setDisplayHighTables( Boolean.parseBoolean(unmarshallAttribute(n, "value", "false"))); } else if (n.getNodeType() == ELEMENT_NODE && n.getNodeName().equalsIgnoreCase("valuelimitwarning")) { settings.setValueLimitWarning( Boolean.parseBoolean(unmarshallAttribute(n, "value", "true"))); } } return settings; }
public IIOMetadataNode buildWindow(Settings settings) { IIOMetadataNode windowSettings = new IIOMetadataNode("window"); // window size IIOMetadataNode size = new IIOMetadataNode("size"); size.setAttribute("x", ((int) settings.getWindowSize().getHeight()) + ""); size.setAttribute("y", ((int) settings.getWindowSize().getWidth()) + ""); windowSettings.appendChild(size); // window location IIOMetadataNode location = new IIOMetadataNode("location"); location.setAttribute("x", ((int) settings.getWindowLocation().getX()) + ""); location.setAttribute("y", ((int) settings.getWindowLocation().getY()) + ""); windowSettings.appendChild(location); // splitpane location IIOMetadataNode splitpane = new IIOMetadataNode("splitpane"); splitpane.setAttribute("location", settings.getSplitPaneLocation() + ""); windowSettings.appendChild(splitpane); return windowSettings; }
private Settings unmarshallWindow(Node windowNode, Settings settings) { Node n; NodeList nodes = windowNode.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { n = nodes.item(i); if (n.getNodeType() == ELEMENT_NODE && n.getNodeName().equalsIgnoreCase("size")) { settings.setWindowSize( new Dimension(unmarshallAttribute(n, "y", 600), unmarshallAttribute(n, "x", 800))); } else if (n.getNodeType() == ELEMENT_NODE && n.getNodeName().equalsIgnoreCase("location")) { // set default location in top left screen if no settings file found settings.setWindowLocation( new Point(unmarshallAttribute(n, "x", 0), unmarshallAttribute(n, "y", 0))); } else if (n.getNodeType() == ELEMENT_NODE && n.getNodeName().equalsIgnoreCase("splitpane")) { settings.setSplitPaneLocation(unmarshallAttribute(n, "location", 150)); } } return settings; }
private Settings unmarshallTableDisplay(Node tableDisplayNode, Settings settings) { Node n; NodeList nodes = tableDisplayNode.getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { n = nodes.item(i); if (n.getNodeType() == ELEMENT_NODE && n.getNodeName().equalsIgnoreCase("font")) { settings.setTableFont( new Font( unmarshallAttribute(n, "face", "Arial"), unmarshallAttribute(n, "decoration", BOLD), unmarshallAttribute(n, "size", 12))); } else if (n.getNodeType() == ELEMENT_NODE && n.getNodeName().equalsIgnoreCase("cellsize")) { settings.setCellSize( new Dimension(unmarshallAttribute(n, "x", 42), unmarshallAttribute(n, "y", 18))); } else if (n.getNodeType() == ELEMENT_NODE && n.getNodeName().equalsIgnoreCase("colors")) { settings = unmarshallColors(n, settings); } } return settings; }
public IIOMetadataNode buildOptions(Settings settings, String versionNumber) { IIOMetadataNode options = new IIOMetadataNode("options"); // obsolete warning IIOMetadataNode obsoleteWarning = new IIOMetadataNode("obsoletewarning"); obsoleteWarning.setAttribute("value", settings.isObsoleteWarning() + ""); options.appendChild(obsoleteWarning); // calcultion conflicting warning IIOMetadataNode calcConflictWarning = new IIOMetadataNode("calcconflictwarning"); calcConflictWarning.setAttribute("value", settings.isCalcConflictWarning() + ""); options.appendChild(calcConflictWarning); // debug mode IIOMetadataNode debug = new IIOMetadataNode("debug"); debug.setAttribute("value", settings.isDebug() + ""); options.appendChild(debug); // userlevel IIOMetadataNode userLevel = new IIOMetadataNode("userlevel"); userLevel.setAttribute("value", settings.getUserLevel() + ""); options.appendChild(userLevel); // table click count IIOMetadataNode tableClickCount = new IIOMetadataNode("tableclickcount"); tableClickCount.setAttribute("value", settings.getTableClickCount() + ""); options.appendChild(tableClickCount); // last version used IIOMetadataNode version = new IIOMetadataNode("version"); version.setAttribute("value", versionNumber); options.appendChild(version); // save debug level tables IIOMetadataNode saveDebugTables = new IIOMetadataNode("savedebugtables"); saveDebugTables.setAttribute("value", settings.isSaveDebugTables() + ""); options.appendChild(saveDebugTables); // display tables higher than userlevel IIOMetadataNode displayHighTables = new IIOMetadataNode("displayhightables"); displayHighTables.setAttribute("value", settings.isDisplayHighTables() + ""); options.appendChild(displayHighTables); return options; }
public IIOMetadataNode buildTableDisplay(Settings settings) { IIOMetadataNode tableDisplay = new IIOMetadataNode("tabledisplay"); // font IIOMetadataNode font = new IIOMetadataNode("font"); font.setAttribute("face", settings.getTableFont().getName()); font.setAttribute("size", settings.getTableFont().getSize() + ""); font.setAttribute("decoration", settings.getTableFont().getStyle() + ""); tableDisplay.appendChild(font); // table cell size IIOMetadataNode cellSize = new IIOMetadataNode("cellsize"); cellSize.setAttribute("height", ((int) settings.getCellSize().getHeight()) + ""); cellSize.setAttribute("width", ((int) settings.getCellSize().getWidth()) + ""); tableDisplay.appendChild(cellSize); // colors IIOMetadataNode colors = new IIOMetadataNode("colors"); // max IIOMetadataNode max = new IIOMetadataNode("max"); max.setAttribute("r", settings.getMaxColor().getRed() + ""); max.setAttribute("g", settings.getMaxColor().getGreen() + ""); max.setAttribute("b", settings.getMaxColor().getBlue() + ""); colors.appendChild(max); // min IIOMetadataNode min = new IIOMetadataNode("min"); min.setAttribute("r", settings.getMinColor().getRed() + ""); min.setAttribute("g", settings.getMinColor().getGreen() + ""); min.setAttribute("b", settings.getMinColor().getBlue() + ""); colors.appendChild(min); // highlight IIOMetadataNode highlight = new IIOMetadataNode("highlight"); highlight.setAttribute("r", settings.getHighlightColor().getRed() + ""); highlight.setAttribute("g", settings.getHighlightColor().getGreen() + ""); highlight.setAttribute("b", settings.getHighlightColor().getBlue() + ""); colors.appendChild(highlight); // increased cell border IIOMetadataNode increaseBorder = new IIOMetadataNode("increaseborder"); increaseBorder.setAttribute("r", settings.getIncreaseBorder().getRed() + ""); increaseBorder.setAttribute("g", settings.getIncreaseBorder().getGreen() + ""); increaseBorder.setAttribute("b", settings.getIncreaseBorder().getBlue() + ""); colors.appendChild(increaseBorder); // decreased cell border IIOMetadataNode decreaseBorder = new IIOMetadataNode("decreaseborder"); decreaseBorder.setAttribute("r", settings.getDecreaseBorder().getRed() + ""); decreaseBorder.setAttribute("g", settings.getDecreaseBorder().getGreen() + ""); decreaseBorder.setAttribute("b", settings.getDecreaseBorder().getBlue() + ""); colors.appendChild(decreaseBorder); // axis cells IIOMetadataNode axis = new IIOMetadataNode("axis"); axis.setAttribute("r", settings.getAxisColor().getRed() + ""); axis.setAttribute("g", settings.getAxisColor().getGreen() + ""); axis.setAttribute("b", settings.getAxisColor().getBlue() + ""); colors.appendChild(axis); tableDisplay.appendChild(colors); return tableDisplay; }