Search in sources :

Example 1 with CustomVisualizationViewer

use of org.eclipse.titanium.graph.gui.common.CustomVisualizationViewer in project titan.EclipsePlug-ins by eclipse.

the class GraphHandler method changeLayout.

/**
 * This function changes the layout for the graph set in the
 * {@link GraphHandler} class
 *
 * @param newLayout
 *            : The chosen layout's code
 * @param newWindowSize
 *            : The size of the parent window where to draw (or any
 *            resolution bigger than this)
 * @throws BadLayoutException On wrong layout code or bad graph
 */
public void changeLayout(final LayoutEntry newLayout, final Dimension newWindowSize) throws BadLayoutException {
    if (g == null) {
        throw new BadLayoutException("You must draw a graph before!", ErrorType.NO_OBJECT);
    }
    Dimension extSize = null;
    if (g.getVertexCount() >= 20) {
        extSize = new Dimension(newWindowSize.height * (g.getVertexCount() / 20), newWindowSize.width * (g.getVertexCount() / 20));
    } else {
        extSize = newWindowSize;
    }
    layout = new LayoutBuilder(g, newLayout, extSize).clusters(clusters).build();
    actVisualisator = new CustomVisualizationViewer(layout, popupMenu);
    actVisualisator.setPreferredSize(new Dimension(newWindowSize.width, newWindowSize.height));
    actVisualisator.getRenderContext().setVertexLabelTransformer(NODE_LABELER);
    final GraphRenderer<NodeDescriptor, EdgeDescriptor> rnd = new GraphRenderer<NodeDescriptor, EdgeDescriptor>(NODE_LABELER, actVisualisator.getPickedVertexState(), actVisualisator.getPickedEdgeState());
    setNodeRenderer(rnd, actVisualisator);
    renderer = rnd;
    actVisualisator.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR);
    actVisualisator.setBackground(Color.white);
    actVisualisator.setDoubleBuffered(false);
    initSatView();
}
Also used : CustomVisualizationViewer(org.eclipse.titanium.graph.gui.common.CustomVisualizationViewer) NodeDescriptor(org.eclipse.titanium.graph.components.NodeDescriptor) Dimension(java.awt.Dimension) EdgeDescriptor(org.eclipse.titanium.graph.components.EdgeDescriptor)

Example 2 with CustomVisualizationViewer

use of org.eclipse.titanium.graph.gui.common.CustomVisualizationViewer in project titan.EclipsePlug-ins by eclipse.

the class GraphEditor method elemChosen.

@Override
public void elemChosen(final NodeDescriptor element) {
    final CustomVisualizationViewer visualisator = handler.getVisualizator();
    visualisator.jumpToPlace(visualisator.getGraphLayout().apply(element));
    for (final NodeDescriptor node : graph.getVertices()) {
        node.setNodeColour(NodeColours.NOT_RESULT_COLOUR);
    }
    element.setNodeColour(NodeColours.RESULT_COLOUR);
}
Also used : CustomVisualizationViewer(org.eclipse.titanium.graph.gui.common.CustomVisualizationViewer) NodeDescriptor(org.eclipse.titanium.graph.components.NodeDescriptor)

Aggregations

NodeDescriptor (org.eclipse.titanium.graph.components.NodeDescriptor)2 CustomVisualizationViewer (org.eclipse.titanium.graph.gui.common.CustomVisualizationViewer)2 Dimension (java.awt.Dimension)1 EdgeDescriptor (org.eclipse.titanium.graph.components.EdgeDescriptor)1