Search in sources :

Example 26 with VisualizationViewer

use of edu.uci.ics.jung.visualization.VisualizationViewer in project titan.EclipsePlug-ins by eclipse.

the class GraphHandler method saveToImage.

/**
 * Exports the graph set for this class to a PNG file
 *
 * @param path
 *            : The PNG file's path
 * @param mode
 *            : The way of export, see {@link GraphHandler}
 *            <code>public static</code> fields for possible values (EXPORT_
 *            named fields)
 * @param size
 *            : This parameter sets the size of the exported image in pixels
 * @throws Exception
 *             on file handling error
 */
public void saveToImage(final String path, final ImageExportType mode) throws BadLayoutException {
    if (layout == null || actVisualisator == null) {
        throw new BadLayoutException("Either the layout or the visuaizer is not set (is null)", ErrorType.NO_OBJECT);
    }
    VisualizationViewer<NodeDescriptor, EdgeDescriptor> tempVisualisator = null;
    Dimension size = null;
    switch(mode) {
        case EXPORT_SEEN_GRAPH:
            {
                tempVisualisator = actVisualisator;
                size = actVisualisator.getPreferredSize();
            }
            break;
        case EXPORT_WHOLE_GRAPH:
            {
                layout = actVisualisator.getGraphLayout();
                if (size == null) {
                    size = new Dimension(layout.getSize().width, layout.getSize().height);
                }
                final Function<NodeDescriptor, Point2D> trf = new Function<NodeDescriptor, Point2D>() {

                    @Override
                    public Point2D apply(final NodeDescriptor v) {
                        return layout.apply(v);
                    }
                };
                tempVisualisator = new VisualizationViewer<NodeDescriptor, EdgeDescriptor>(new LayoutBuilder(g, Layouts.LAYOUT_STATIC, size).transformer(trf).build());
                tempVisualisator.setPreferredSize(size);
                tempVisualisator.setSize(size);
                tempVisualisator.getRenderContext().setVertexLabelTransformer(NODE_LABELER);
                final GraphRenderer<NodeDescriptor, EdgeDescriptor> rnd = new GraphRenderer<NodeDescriptor, EdgeDescriptor>(NODE_LABELER, tempVisualisator.getPickedVertexState(), tempVisualisator.getPickedEdgeState());
                setNodeRenderer(rnd, tempVisualisator);
                tempVisualisator.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR);
                tempVisualisator.setBackground(Color.white);
                tempVisualisator.setDoubleBuffered(false);
            }
            break;
        case EXPORT_SATELLITE:
            {
                tempVisualisator = satView;
                size = tempVisualisator.getSize();
            }
            break;
        default:
            ErrorReporter.logError("Unexpected image export type " + mode);
            return;
    }
    BufferedImage image;
    final GUIErrorHandler errorHandler = new GUIErrorHandler();
    try {
        image = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_RGB);
    } catch (OutOfMemoryError e) {
        final long needed = (long) size.width * (long) size.height * 4;
        String temp;
        if (needed < 1024) {
            temp = needed + " bytes";
        } else if (needed < 1024 * 1024) {
            temp = needed / 1024 + " Kbytes";
        } else {
            temp = needed / 1024 / 1024 + " Mbytes";
        }
        final String errorText = "Could not save an image of " + size.width + "*" + size.height + " size as there was not enough free memory (" + temp + ")";
        errorHandler.reportErrorMessage(errorText);
        ErrorReporter.logExceptionStackTrace(errorText, e);
        return;
    }
    final Graphics2D g2 = image.createGraphics();
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    tempVisualisator.paint(g2);
    g2.dispose();
    try {
        ImageIO.write(image, "png", new File(path));
    } catch (IOException e) {
        final String message = "Error while writing to file" + path;
        ErrorReporter.logExceptionStackTrace(message, e);
        errorHandler.reportException(message, e);
    }
}
Also used : GUIErrorHandler(org.eclipse.titanium.error.GUIErrorHandler) NodeDescriptor(org.eclipse.titanium.graph.components.NodeDescriptor) Dimension(java.awt.Dimension) IOException(java.io.IOException) EdgeDescriptor(org.eclipse.titanium.graph.components.EdgeDescriptor) BufferedImage(java.awt.image.BufferedImage) Graphics2D(java.awt.Graphics2D) Function(com.google.common.base.Function) Point2D(java.awt.geom.Point2D) VisualizationViewer(edu.uci.ics.jung.visualization.VisualizationViewer) CustomVisualizationViewer(org.eclipse.titanium.graph.gui.common.CustomVisualizationViewer) File(java.io.File)

Example 27 with VisualizationViewer

use of edu.uci.ics.jung.visualization.VisualizationViewer in project dwoss by gg-net.

the class Grapher method showFull.

/**
 * Show the full StateMachine with a special formater.
 * <p/>
 * @param <T>          type of state machine
 * @param stateMachine the statemachine to show
 * @param formater     an optional formater
 */
public static <T> void showFull(final StateMachine<T> stateMachine, final StateFormater<T> formater) {
    DirectedGraph<State<T>, String> g = new DirectedSparseMultigraph<>();
    int i = 0;
    for (Link<T> link : stateMachine.getLinks()) {
        // TODO: A Graph needs for each transition a unique id. A StateMachine not. So we build it here.
        g.addEdge("[" + (i++) + "] " + link.getTransition().toString(), link.getSource(), link.getDestination());
    }
    FRLayout<State<T>, String> layout = new FRLayout<>(g);
    // layout.setRepulsionMultiplier(2);
    // layout.setMaxIterations(20);
    // sets the initial size of the space
    layout.setSize(new Dimension(1100, 950));
    VisualizationViewer<State<T>, String> vv = new VisualizationViewer<>(layout);
    // Sets the viewing area size
    vv.setPreferredSize(new Dimension(1280, 1024));
    vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller());
    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
    vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.AUTO);
    // final VisualizationModel<String,Number> visualizationModel =
    // new DefaultVisualizationModel<String,Number>(layout, preferredSize);
    // this class will provide both label drawing and vertex shapes
    VertexLabelAsShapeRenderer<State<T>, String> vlasr = new VertexLabelAsShapeRenderer<>(vv.getRenderContext());
    // // customize the render context
    if (formater != null) {
        vv.getRenderContext().setVertexLabelTransformer((state) -> {
            return formater.toHtml(state);
        });
        vv.setVertexToolTipTransformer((state) -> {
            return formater.toToolTipHtml(state);
        });
    }
    vv.getRenderContext().setVertexShapeTransformer(vlasr);
    vv.getRenderContext().setVertexLabelRenderer(new DefaultVertexLabelRenderer(Color.RED));
    vv.getRenderContext().setEdgeDrawPaintTransformer((input) -> {
        return Color.DARK_GRAY;
    });
    vv.getRenderContext().setEdgeStrokeTransformer((input) -> {
        return new BasicStroke(2.5f);
    });
    // customize the renderer
    vv.getRenderer().setVertexRenderer(new GradientVertexRenderer<State<T>, String>(Color.LIGHT_GRAY, Color.WHITE, true));
    vv.getRenderer().setVertexLabelRenderer(vlasr);
    DefaultModalGraphMouse gm = new DefaultModalGraphMouse();
    gm.setMode(ModalGraphMouse.Mode.TRANSFORMING);
    vv.setGraphMouse(gm);
    vv.addKeyListener(gm.getModeKeyListener());
    JFrame frame = new JFrame("Simple Graph View");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().setLayout(new BorderLayout());
    frame.getContentPane().add(vv, BorderLayout.CENTER);
    frame.getContentPane().add(gm.getModeComboBox(), BorderLayout.SOUTH);
    frame.pack();
    frame.setVisible(true);
}
Also used : DefaultModalGraphMouse(edu.uci.ics.jung.visualization.control.DefaultModalGraphMouse) FRLayout(edu.uci.ics.jung.algorithms.layout.FRLayout) ToStringLabeller(edu.uci.ics.jung.visualization.decorators.ToStringLabeller) JFrame(javax.swing.JFrame) DirectedSparseMultigraph(edu.uci.ics.jung.graph.DirectedSparseMultigraph) VisualizationViewer(edu.uci.ics.jung.visualization.VisualizationViewer)

Example 28 with VisualizationViewer

use of edu.uci.ics.jung.visualization.VisualizationViewer in project fql by CategoricalData.

the class Transform method doView.

// public JComponent lowerComp() throws FQLException {
// JComponent c = src.thesig.pretty();
// c.setMaximumSize(new Dimension(400,100));
// return c;
// }
/*
	 * public JComponent lowerComp(String s, String d) { int size =
	 * src.thesig.nodes.size();
	 *
	 * // JPanel pan = new JPanel(new GridLayout(1, size + 1)); // for (Node n :
	 * src.thesig.nodes) {  // JLabel l = new JLabel(n.string); //
	 * l.setOpaque(true); // l.setHorizontalAlignment(SwingConstants.CENTER); //
	 * l.setBackground(sColor); // pan.add(l); // }
	 *
	 * //JPanel xxx = new JPanel(); // xxx.add(new JLabel(" ")); //JPanel yu =
	 * new MyLabel2(); // yu.setSize(20, 12); //xxx.add(new MyLabel2()); //
	 * xxx.add(new JLabel(s + " (source)")); // xxx.add(new JLabel("    ")); //
	 * JPanel uy = new MyLabel(); // uy.setSize(20,20); // xxx.add(uy); //
	 * xxx.add(new JLabel(d + " (target)")); // pan.add(xxx); // pan.set
	 * JScrollPane p = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_NEVER,
	 * JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
	 *
	 * pan.setBorder(BorderFactory.createTitledBorder(
	 * BorderFactory.createEmptyBorder(2, 2, 2, 2), "Legend"));
	 * p.setViewportView(pan); return p; }
	 */
@SuppressWarnings("unchecked")
private static JPanel doView(Color scolor, Color tcolor, @SuppressWarnings("unused") String src_n, @SuppressWarnings("unused") String dst_n, Graph<Quad<Node, Object, String, Boolean>, Pair<Path, Integer>> first, Map<Quad<Node, Object, String, Boolean>, Map<Attribute<Node>, Object>> second) {
    // HashMap<Pair<Node, Object>,String> map = new HashMap<>();
    JPanel cards = new JPanel(new CardLayout());
    try {
        Class<?> c = Class.forName(FqlOptions.layout_prefix + DefunctGlobalOptions.debug.fql.trans_graph);
        Constructor<?> x = c.getConstructor(Graph.class);
        Layout<Quad<Node, Object, String, Boolean>, Pair<Path, Integer>> layout = (Layout<Quad<Node, Object, String, Boolean>, Pair<Path, Integer>>) x.newInstance(first);
        layout.setSize(new Dimension(600, 350));
        VisualizationViewer<Quad<Node, Object, String, Boolean>, Pair<Path, Integer>> vv = new VisualizationViewer<>(layout);
        Function<Quad<Node, Object, String, Boolean>, Paint> vertexPaint = (Quad<Node, Object, String, Boolean> i) -> i.fourth ? scolor : tcolor;
        DefaultModalGraphMouse<String, String> gm = new DefaultModalGraphMouse<>();
        gm.setMode(Mode.TRANSFORMING);
        vv.setGraphMouse(gm);
        gm.setMode(Mode.PICKING);
        // Set up a new stroke Transformer for the edges
        float[] dash = { 1.0f };
        Stroke edgeStroke = new BasicStroke(0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash, 10.0f);
        // Function<String, Stroke> edgeStrokeTransformer = new
        // Function<String, Stroke>() {
        // public Stroke transform(String s) {
        // return edgeStroke;
        // }
        // };
        vv.getRenderContext().setVertexLabelRenderer(new MyVertexT(cards));
        Stroke bs = new BasicStroke();
        Function<Pair<Path, Integer>, Stroke> edgeStrokeTransformer = (Pair<Path, Integer> s) -> (s.first == null) ? edgeStroke : bs;
        vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
        vv.getRenderContext().setEdgeStrokeTransformer(edgeStrokeTransformer);
        // vv.getRenderContext().setVertexLabelTransformer(
        // new ToStringLabeller());
        vv.getRenderContext().setEdgeLabelTransformer((Pair<Path, Integer> t) -> (t.first == null) ? "" : t.first.toString());
        // new ToStringLabeller());
        // vv.getRenderer().getVertexRenderer().
        // vv.getRenderContext().setLabelOffset(20);
        // vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR);
        vv.getRenderContext().setVertexLabelTransformer((Quad<Node, Object, String, Boolean> t) -> t.third + "." + t.first + "." + t.second);
        // vv.getRenderer().setVertexRenderer(new MyRenderer());
        JPanel ret = new JPanel(new BorderLayout());
        JSplitPane pane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
        for (Quad<Node, Object, String, Boolean> n : first.getVertices()) {
            Map<Attribute<Node>, Object> s = second.get(n);
            Object[] columnNames = new Object[s.keySet().size()];
            Object[][] rowData = new Object[1][s.keySet().size()];
            int i = 0;
            // Map<Attribute<Node>, Object> v = ma;
            for (Attribute<Node> a : s.keySet()) {
                columnNames[i] = a.name;
                rowData[0][i] = s.get(a);
                i++;
            }
            // }
            JPanel p = new JPanel(new GridLayout(1, 1));
            @SuppressWarnings("serial") JTable table = new JTable(rowData, columnNames) {

                @Override
                public Dimension getPreferredScrollableViewportSize() {
                    Dimension d = getPreferredSize();
                    return new Dimension(d.width, d.height);
                }
            };
            JScrollPane jsp = new JScrollPane(table);
            p.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "Attributes for " + n.second));
            p.add(jsp);
            cards.add(p, n.second.toString());
        }
        cards.add(new JPanel(), "blank");
        CardLayout cl = (CardLayout) (cards.getLayout());
        cl.show(cards, "blank");
        pane.add(new GraphZoomScrollPane(vv));
        pane.setResizeWeight(1.0d);
        pane.add(cards);
        cards.setPreferredSize(new Dimension(400, 100));
        ret.add(pane, BorderLayout.CENTER);
        // JComponent iii = lowerComp(src_n, dst_n);
        // iii.setPreferredSize(new Dimension(1, 60));
        // ret.add(iii, BorderLayout.NORTH);
        ret.setBorder(BorderFactory.createEtchedBorder());
        return ret;
    } catch (Throwable t) {
        t.printStackTrace();
        throw new RuntimeException();
    }
}
Also used : BasicStroke(java.awt.BasicStroke) JPanel(javax.swing.JPanel) Quad(catdata.Quad) GridLayout(java.awt.GridLayout) BorderLayout(java.awt.BorderLayout) VisualizationViewer(edu.uci.ics.jung.visualization.VisualizationViewer) Pair(catdata.Pair) JScrollPane(javax.swing.JScrollPane) CardLayout(java.awt.CardLayout) Stroke(java.awt.Stroke) BasicStroke(java.awt.BasicStroke) DefaultModalGraphMouse(edu.uci.ics.jung.visualization.control.DefaultModalGraphMouse) GraphZoomScrollPane(edu.uci.ics.jung.visualization.GraphZoomScrollPane) Dimension(java.awt.Dimension) Paint(java.awt.Paint) Paint(java.awt.Paint) CardLayout(java.awt.CardLayout) GridLayout(java.awt.GridLayout) BorderLayout(java.awt.BorderLayout) Layout(edu.uci.ics.jung.algorithms.layout.Layout) JTable(javax.swing.JTable) JSplitPane(javax.swing.JSplitPane)

Example 29 with VisualizationViewer

use of edu.uci.ics.jung.visualization.VisualizationViewer in project fql by CategoricalData.

the class FqlppDisplay method doFNView.

@SuppressWarnings("unchecked")
private <X, Y> JComponent doFNView(Functor fn, JPanel p, Color clr, Graph<X, Y> sgv) {
    Layout<X, Y> layout = new FRLayout<>(sgv);
    layout.setSize(new Dimension(600, 400));
    VisualizationViewer<X, Y> vv = new VisualizationViewer<>(layout);
    Function<X, Paint> vertexPaint = z -> clr;
    DefaultModalGraphMouse<String, String> gm = new DefaultModalGraphMouse<>();
    gm.setMode(Mode.TRANSFORMING);
    vv.setGraphMouse(gm);
    gm.setMode(Mode.PICKING);
    vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
    Function fff = arg0 -> Util.nice(arg0.toString());
    vv.getRenderContext().setVertexLabelTransformer(fff);
    vv.getRenderContext().setEdgeLabelTransformer(fff);
    vv.getPickedVertexState().addItemListener((ItemEvent e) -> {
        if (e.getStateChange() != ItemEvent.SELECTED) {
            return;
        }
        vv.getPickedEdgeState().clear();
        X str = ((X) e.getItem());
        Object y = fn.applyO(str);
        p.removeAll();
        if (y instanceof Category) {
            Category ttt = (Category) y;
            JPanel sss = showCat(ttt, getColor(ttt));
            p.add(sss);
        } else if (y instanceof Set) {
            Set ttt = (Set) y;
            JPanel sss = showSet(ttt, getColor(ttt));
            p.add(sss);
        } else if (y instanceof Functor) {
            Functor ttt = (Functor) y;
            JPanel sss = showFtr(ttt, getColor(ttt), null);
            p.add(sss);
        } else {
            String sss = Util.nice(y.toString());
            p.add(new CodeTextPanel(BorderFactory.createEtchedBorder(), null, sss));
        }
        p.revalidate();
    });
    vv.getPickedEdgeState().addItemListener((ItemEvent e) -> {
        if (e.getStateChange() != ItemEvent.SELECTED) {
            return;
        }
        vv.getPickedVertexState().clear();
        X str = ((X) e.getItem());
        Object y = fn.applyA(str);
        p.removeAll();
        if (y instanceof Functor) {
            Functor ttt = (Functor) y;
            JPanel sss = showFtr(ttt, getColor(ttt.source), null);
            p.add(sss);
        } else if (y instanceof Fn) {
            Fn ttt = (Fn) y;
            JPanel sss = showFn(ttt, getColor(ttt.source), getColor(ttt.target));
            p.add(sss);
        } else if (y instanceof Transform) {
            Transform ttt = (Transform) y;
            JPanel sss = showTrans(ttt, getColor(ttt.source));
            p.add(sss);
        } else {
            String sss = Util.nice(y.toString());
            p.add(new CodeTextPanel(BorderFactory.createEtchedBorder(), null, sss));
        }
        p.revalidate();
    });
    GraphZoomScrollPane zzz = new GraphZoomScrollPane(vv);
    JPanel ret = new JPanel(new GridLayout(1, 1));
    ret.add(zzz);
    ret.setBorder(BorderFactory.createEtchedBorder());
    return ret;
}
Also used : Color(java.awt.Color) Edge(catdata.fqlpp.cat.Signature.Edge) Vector(java.util.Vector) Map(java.util.Map) FinCat(catdata.fqlpp.cat.FinCat) DirectedSparseMultigraph(edu.uci.ics.jung.graph.DirectedSparseMultigraph) FunCat(catdata.fqlpp.cat.FunCat) JFrame(javax.swing.JFrame) ListSelectionEvent(javax.swing.event.ListSelectionEvent) Pair(catdata.Pair) KeyStroke(javax.swing.KeyStroke) ItemEvent(java.awt.event.ItemEvent) Fn(catdata.fqlpp.cat.FinSet.Fn) Quad(catdata.Quad) Function(com.google.common.base.Function) Disp(catdata.ide.Disp) Category(catdata.fqlpp.cat.Category) Set(java.util.Set) Inst(catdata.fqlpp.cat.Inst) BorderFactory(javax.swing.BorderFactory) KeyEvent(java.awt.event.KeyEvent) Component(java.awt.Component) GraphZoomScrollPane(edu.uci.ics.jung.visualization.GraphZoomScrollPane) Dimension(java.awt.Dimension) List(java.util.List) Paint(java.awt.Paint) Entry(java.util.Map.Entry) Triple(catdata.Triple) BasicStroke(java.awt.BasicStroke) GuiUtil(catdata.ide.GuiUtil) JPanel(javax.swing.JPanel) DefunctGlobalOptions(catdata.ide.DefunctGlobalOptions) InputEvent(java.awt.event.InputEvent) ListSelectionModel(javax.swing.ListSelectionModel) Const(catdata.fqlpp.CatExp.Const) CardLayout(java.awt.CardLayout) ActionListener(java.awt.event.ActionListener) JSplitPane(javax.swing.JSplitPane) Node(catdata.fqlpp.cat.Signature.Node) VisualizationViewer(edu.uci.ics.jung.visualization.VisualizationViewer) Functor(catdata.fqlpp.cat.Functor) HashMap(java.util.HashMap) GridLayout(java.awt.GridLayout) Signature(catdata.fqlpp.cat.Signature) JTabbedPane(javax.swing.JTabbedPane) Graph(edu.uci.ics.jung.graph.Graph) GUI(catdata.ide.GUI) LinkedList(java.util.LinkedList) Stroke(java.awt.Stroke) JComponent(javax.swing.JComponent) Transform(catdata.fqlpp.cat.Transform) Layout(edu.uci.ics.jung.algorithms.layout.Layout) CodeTextPanel(catdata.ide.CodeTextPanel) JList(javax.swing.JList) Util(catdata.Util) ActionEvent(java.awt.event.ActionEvent) FinSet(catdata.fqlpp.cat.FinSet) JScrollPane(javax.swing.JScrollPane) DefaultModalGraphMouse(edu.uci.ics.jung.visualization.control.DefaultModalGraphMouse) FRLayout(edu.uci.ics.jung.algorithms.layout.FRLayout) Mode(edu.uci.ics.jung.visualization.control.ModalGraphMouse.Mode) JPanel(javax.swing.JPanel) ItemEvent(java.awt.event.ItemEvent) Category(catdata.fqlpp.cat.Category) Set(java.util.Set) FinSet(catdata.fqlpp.cat.FinSet) FRLayout(edu.uci.ics.jung.algorithms.layout.FRLayout) Function(com.google.common.base.Function) GridLayout(java.awt.GridLayout) CodeTextPanel(catdata.ide.CodeTextPanel) VisualizationViewer(edu.uci.ics.jung.visualization.VisualizationViewer) DefaultModalGraphMouse(edu.uci.ics.jung.visualization.control.DefaultModalGraphMouse) Fn(catdata.fqlpp.cat.FinSet.Fn) GraphZoomScrollPane(edu.uci.ics.jung.visualization.GraphZoomScrollPane) Dimension(java.awt.Dimension) Paint(java.awt.Paint) Functor(catdata.fqlpp.cat.Functor) Transform(catdata.fqlpp.cat.Transform)

Example 30 with VisualizationViewer

use of edu.uci.ics.jung.visualization.VisualizationViewer in project fql by CategoricalData.

the class FqlppDisplay method doElements2View.

private static JComponent doElements2View(Color clr, Graph<Triple, Quad> sgv) {
    Layout<Triple, Quad> layout = new FRLayout<>(sgv);
    layout.setSize(new Dimension(600, 400));
    VisualizationViewer<Triple, Quad> vv = new VisualizationViewer<>(layout);
    DefaultModalGraphMouse<String, String> gm = new DefaultModalGraphMouse<>();
    gm.setMode(Mode.TRANSFORMING);
    vv.setGraphMouse(gm);
    gm.setMode(Mode.PICKING);
    Color clr1 = clr.brighter().brighter();
    Color clr2 = clr.darker().darker();
    Function<Triple, Paint> vertexPaint = x -> x.third.equals("src") ? clr1 : clr2;
    vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
    Function<Triple, String> ttt1 = arg0 -> Util.nice(arg0.first.toString());
    vv.getRenderContext().setVertexLabelTransformer(ttt1);
    Function<Quad, String> ttt2 = arg0 -> Util.nice(arg0.first.toString());
    vv.getRenderContext().setEdgeLabelTransformer(ttt2);
    float[] dash = { 1.0f };
    Stroke edgeStroke = new BasicStroke(0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash, 10.0f);
    Stroke bs = new BasicStroke();
    Function<Quad, Stroke> edgeStrokeTransformer = x -> x.fourth instanceof Integer ? edgeStroke : bs;
    vv.getRenderContext().setEdgeStrokeTransformer(edgeStrokeTransformer);
    GraphZoomScrollPane zzz = new GraphZoomScrollPane(vv);
    JPanel ret = new JPanel(new GridLayout(1, 1));
    ret.add(zzz);
    ret.setBorder(BorderFactory.createEtchedBorder());
    return ret;
}
Also used : Color(java.awt.Color) Edge(catdata.fqlpp.cat.Signature.Edge) Vector(java.util.Vector) Map(java.util.Map) FinCat(catdata.fqlpp.cat.FinCat) DirectedSparseMultigraph(edu.uci.ics.jung.graph.DirectedSparseMultigraph) FunCat(catdata.fqlpp.cat.FunCat) JFrame(javax.swing.JFrame) ListSelectionEvent(javax.swing.event.ListSelectionEvent) Pair(catdata.Pair) KeyStroke(javax.swing.KeyStroke) ItemEvent(java.awt.event.ItemEvent) Fn(catdata.fqlpp.cat.FinSet.Fn) Quad(catdata.Quad) Function(com.google.common.base.Function) Disp(catdata.ide.Disp) Category(catdata.fqlpp.cat.Category) Set(java.util.Set) Inst(catdata.fqlpp.cat.Inst) BorderFactory(javax.swing.BorderFactory) KeyEvent(java.awt.event.KeyEvent) Component(java.awt.Component) GraphZoomScrollPane(edu.uci.ics.jung.visualization.GraphZoomScrollPane) Dimension(java.awt.Dimension) List(java.util.List) Paint(java.awt.Paint) Entry(java.util.Map.Entry) Triple(catdata.Triple) BasicStroke(java.awt.BasicStroke) GuiUtil(catdata.ide.GuiUtil) JPanel(javax.swing.JPanel) DefunctGlobalOptions(catdata.ide.DefunctGlobalOptions) InputEvent(java.awt.event.InputEvent) ListSelectionModel(javax.swing.ListSelectionModel) Const(catdata.fqlpp.CatExp.Const) CardLayout(java.awt.CardLayout) ActionListener(java.awt.event.ActionListener) JSplitPane(javax.swing.JSplitPane) Node(catdata.fqlpp.cat.Signature.Node) VisualizationViewer(edu.uci.ics.jung.visualization.VisualizationViewer) Functor(catdata.fqlpp.cat.Functor) HashMap(java.util.HashMap) GridLayout(java.awt.GridLayout) Signature(catdata.fqlpp.cat.Signature) JTabbedPane(javax.swing.JTabbedPane) Graph(edu.uci.ics.jung.graph.Graph) GUI(catdata.ide.GUI) LinkedList(java.util.LinkedList) Stroke(java.awt.Stroke) JComponent(javax.swing.JComponent) Transform(catdata.fqlpp.cat.Transform) Layout(edu.uci.ics.jung.algorithms.layout.Layout) CodeTextPanel(catdata.ide.CodeTextPanel) JList(javax.swing.JList) Util(catdata.Util) ActionEvent(java.awt.event.ActionEvent) FinSet(catdata.fqlpp.cat.FinSet) JScrollPane(javax.swing.JScrollPane) DefaultModalGraphMouse(edu.uci.ics.jung.visualization.control.DefaultModalGraphMouse) FRLayout(edu.uci.ics.jung.algorithms.layout.FRLayout) Mode(edu.uci.ics.jung.visualization.control.ModalGraphMouse.Mode) BasicStroke(java.awt.BasicStroke) Quad(catdata.Quad) JPanel(javax.swing.JPanel) KeyStroke(javax.swing.KeyStroke) BasicStroke(java.awt.BasicStroke) Stroke(java.awt.Stroke) DefaultModalGraphMouse(edu.uci.ics.jung.visualization.control.DefaultModalGraphMouse) FRLayout(edu.uci.ics.jung.algorithms.layout.FRLayout) Color(java.awt.Color) GraphZoomScrollPane(edu.uci.ics.jung.visualization.GraphZoomScrollPane) Dimension(java.awt.Dimension) Paint(java.awt.Paint) Triple(catdata.Triple) GridLayout(java.awt.GridLayout) VisualizationViewer(edu.uci.ics.jung.visualization.VisualizationViewer)

Aggregations

VisualizationViewer (edu.uci.ics.jung.visualization.VisualizationViewer)35 Dimension (java.awt.Dimension)33 DefaultModalGraphMouse (edu.uci.ics.jung.visualization.control.DefaultModalGraphMouse)32 GraphZoomScrollPane (edu.uci.ics.jung.visualization.GraphZoomScrollPane)31 JPanel (javax.swing.JPanel)31 GridLayout (java.awt.GridLayout)29 Layout (edu.uci.ics.jung.algorithms.layout.Layout)25 Paint (java.awt.Paint)25 JSplitPane (javax.swing.JSplitPane)21 Pair (catdata.Pair)20 FRLayout (edu.uci.ics.jung.algorithms.layout.FRLayout)20 Color (java.awt.Color)18 Function (com.google.common.base.Function)17 Graph (edu.uci.ics.jung.graph.Graph)17 BasicStroke (java.awt.BasicStroke)17 CardLayout (java.awt.CardLayout)17 Stroke (java.awt.Stroke)17 List (java.util.List)17 Triple (catdata.Triple)16 DirectedSparseMultigraph (edu.uci.ics.jung.graph.DirectedSparseMultigraph)16