/** * Modify the Node specified by Parameter n, if the Fields are valid. If Checks are active only * the selected Fields are changed * * @param n the Node that should be modified * @return the modified node if fields are valid, else null */ public VNode modifyNode(VNode n) { if (!VerifyInput().equals("")) return null; if (checksEnabled) { if (bChNodeNameDistance.isSelected()) n.setNameDistance(iNodeNameDistance.getValue()); if (bChNodeNameSize.isSelected()) n.setNameSize(iNodeNameSize.getValue()); if (bChNodeNameRotation.isSelected()) n.setNameRotation(iNodeNameRotation.getValue()); if (bChShowNodeName.isSelected()) n.setNameVisible(bShowNodeName.isSelected()); } else { n.setNameDistance(iNodeNameDistance.getValue()); n.setNameSize(iNodeNameSize.getValue()); n.setNameRotation(iNodeNameRotation.getValue() % 360); n.setNameVisible(bShowNodeName.isSelected()); } return n; }
/** * Initialize the values of the Inputfields. Choose -1 for Integers in the VNode to disable a * Value, if the Checkboxes are enabled. * * @param v VNode containing the Values for Initializeation * @param setVisibility set true, if the NodeNameVisibility should be activated, else false. Has * no effect, if checks are disabled */ public void InitValues(VNode v, boolean setVisibility) { chNode = v; if (chNode == null) { GeneralPreferences gp = GeneralPreferences.getInstance(); iNodeNameRotation.setValue(gp.getIntValue("node.name_rotation")); iNodeNameDistance.setValue(gp.getIntValue("node.name_distance")); iNodeNameSize.setValue(gp.getIntValue("node.name_size")); bShowNodeName.setSelected(!gp.getBoolValue("node.name_visible")); bShowNodeName.doClick(); } else { if (checksEnabled) { // if checks are enabled...set the activity and select the checkbox if a // value is given iNodeNameRotation.setEnabled((chNode.getNameRotation() != -1)); bChNodeNameRotation.setSelected((chNode.getNameRotation() != -1)); } if (chNode.getNameRotation() != -1) iNodeNameRotation.setValue(chNode.getNameRotation()); else if (checksEnabled) NodeNameRotation.setForeground(Color.GRAY); if (checksEnabled) { iNodeNameDistance.setEnabled((chNode.getNameDistance() != -1)); bChNodeNameDistance.setSelected((chNode.getNameDistance() != -1)); } if (chNode.getNameDistance() != -1) iNodeNameDistance.setValue(chNode.getNameDistance()); else if (checksEnabled) NodeNameDistance.setForeground(Color.GRAY); if (checksEnabled) { iNodeNameSize.setEnabled((chNode.getNameSize() != -1)); bChNodeNameSize.setSelected((chNode.getNameSize() != -1)); } if (chNode.getNameSize() != -1) iNodeNameSize.setValue(chNode.getNameSize()); else if (checksEnabled) NodeNameSize.setForeground(Color.GRAY); if (checksEnabled) { bShowNodeName.setEnabled(setVisibility); bChShowNodeName.setSelected(setVisibility); } if (setVisibility) { bShowNodeName.setSelected(!chNode.isNameVisible()); bShowNodeName.doClick(); } else { // disable } } }