/** * Exports the current view as a SVG image after prompting the user for a filename. * * @param parent Parent frame that is used to display error messages. * @param graph Graph to be exported to a SVG file. */ public static void exportAsSvg(final JFrame parent, final ZyGraph graph) { Preconditions.checkNotNull(parent, "IE01737: Parent argument can not be null"); Preconditions.checkNotNull(graph, "IE01738: Graph argument can not be null"); final LastDirFileChooser fileChooser = new LastDirFileChooser(); final int retval = fileChooser.showSaveDialog(parent); if (retval == JFileChooser.APPROVE_OPTION) { try { if (!GraphExporters.exportAllAsSVG( graph, fileChooser.getSelectedFile().getAbsolutePath())) { throw new IOException("Failed to save SVG"); } } catch (final IOException e) { CUtilityFunctions.logException(e); final String innerMessage = "E00195: " + "Could not save view to SVG file"; final String innerDescription = CUtilityFunctions.createDescription( String.format( "The view '%s' could not be written to the file '%s'.", graph.getViewName(), fileChooser.getSelectedFile().getAbsolutePath()), new String[] {"There was a problem writing the PNG file."}, new String[] {"The view was not written to the PNG file."}); NaviErrorDialog.show(parent, innerMessage, innerDescription, e); } } }
/** * Creates a new node synchronizer object. * * @param manager Breakpoint manager where the breakpoints are set. * @param graph The graph to update on relevant debugger events. * @param debugPerspective Describes the debug GUI perspective where the graph is shown. */ public CNodeSynchronizer( final BreakpointManager manager, final ZyGraph graph, final CDebugPerspectiveModel debugPerspective) { m_graph = Preconditions.checkNotNull(graph, "IE01511: Graph argument can not be null"); m_manager = Preconditions.checkNotNull(manager, "IE01512: Manager argument can not be null"); m_debugPerspective = Preconditions.checkNotNull( debugPerspective, "IE02296: debugPerspective argument can not be null"); graph.addNodeModifier(m_realizerListener); }
/** * Removes a node modifier from all the nodes. * * @param modifier The modifier to remove from the nodes. */ private void removeNodeModifier(final IZyNodeRealizerListener<NaviNode> modifier) { Preconditions.checkNotNull(modifier, "IE01513: Modifier argument can not be null"); m_graph.iterate( new INodeCallback<NaviNode>() { @Override public IterationMode next(final NaviNode node) { node.removeNodeModifier(modifier); return IterationMode.CONTINUE; } }); }
// ESCA-JAVA0138: Not our function @Override public Component getTableCellRendererComponent( final JTable table, final Object value, final boolean isSelected, final boolean hasFocus, final int row, final int column) { setFont(DEFAULT_CELL_FONT); final INaviViewNode node = getNode(m_table.modelIndex(row)); Color textColor = UNSELECTED_FOREGROUND; if (node.isSelected()) { textColor = SELECTED_FOREGROUND; } else if (!node.isVisible()) { textColor = INVISIBLE_FOREGROUND; } setForeground(textColor); if (column == CNodeChooserModel.COLUMN_IN) { setText(String.valueOf(node.getIncomingEdges().size())); } else if (column == CNodeChooserModel.COLUMN_OUT) { setText(String.valueOf(node.getOutgoingEdges().size())); } else if (column == CNodeChooserModel.COLUMN_ADDRESS) { setText(getNodeText(node)); } else { setText(""); } setBackground(DEFAULT_BACKGROUND); if (column == CNodeChooserModel.COLUMN_COLOR) { setBackground(node.getColor()); } else { calculateBackgroundColor(node); } setToolTipText(buildToolTip(m_graph.getNode(node).getNodeContent())); return this; }
/** * Small helper function to return the node of a given node index. * * @param index The node index. * @return The node at the given index. */ private INaviViewNode getNode(final int index) { return m_graph.getRawView().getGraph().getNodes().get(index); }