本文整理汇总了Java中edu.uci.ics.jung.visualization.decorators.ToStringLabeller类的典型用法代码示例。如果您正苦于以下问题:Java ToStringLabeller类的具体用法?Java ToStringLabeller怎么用?Java ToStringLabeller使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ToStringLabeller类属于edu.uci.ics.jung.visualization.decorators包,在下文中一共展示了ToStringLabeller类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getServer
import edu.uci.ics.jung.visualization.decorators.ToStringLabeller; //导入依赖的package包/类
/**
* @param args the command line arguments
* @return
*/
public VisualizationImageServer<Integer, String> getServer() {
// Layout<V, E>, VisualizationComponent<V,E>
Layout<Integer, String> layout = new CircleLayout<>(
this);
layout.setSize(new Dimension(300, 300));
VisualizationImageServer<Integer, String> vv = new VisualizationImageServer<>(
layout, new Dimension(350, 350));
// Setup up a new vertex to paint transformer...
// Set up a new stroke Transformer for the edges
float dash[] = {10.0f};
final Stroke edgeStroke = new BasicStroke(1.0f,
BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, dash,
0.0f);
vv.getRenderContext().setVertexFillPaintTransformer(i -> Color.GREEN);
vv.getRenderContext().setEdgeStrokeTransformer(
s -> edgeStroke);
vv.getRenderContext().setVertexLabelTransformer(
new ToStringLabeller());
vv.getRenderContext().setEdgeLabelTransformer(
new ToStringLabeller());
vv.getRenderer().getVertexLabelRenderer()
.setPosition(Position.CNTR);
return vv;
}
示例2: getPanel
import edu.uci.ics.jung.visualization.decorators.ToStringLabeller; //导入依赖的package包/类
public static GraphVisualizationPanel<MarkovVertex, MarkovEdge> getPanel(
Graph<MarkovVertex, MarkovEdge> test_graph) {
GraphVisualizationPanel<MarkovVertex, MarkovEdge> graph_panel = GraphVisualizationPanel
.factory(test_graph);
Transformer<MarkovVertex, Paint> transformer = new VertexTransformer<MarkovVertex, Paint>();
graph_panel.getRenderContext().setVertexFillPaintTransformer(
transformer);
graph_panel.getRenderContext().setEdgeLabelTransformer(
new ToStringLabeller<MarkovEdge>());
PluggableGraphMouse gm = new PluggableGraphMouse();
gm.add(new PopupMousePlugin<MarkovVertex, MarkovEdge>());
gm.add(new TranslatingGraphMousePlugin(MouseEvent.BUTTON1_MASK));
graph_panel.setGraphMouse(gm);
Transformer<MarkovVertex, String> labelTransform = new VertexLabelTransformer<MarkovVertex, String>();
graph_panel.getRenderContext()
.setVertexLabelTransformer(labelTransform);
return graph_panel;
}
示例3: DerivationViewer
import edu.uci.ics.jung.visualization.decorators.ToStringLabeller; //导入依赖的package包/类
public DerivationViewer(DerivationTree g, Dimension d, Color targetColor, AnchorType anchor) {
super(new CircleLayout<>(g));
anchorStyle = anchor;
DerivationTreeTransformer dtt = new DerivationTreeTransformer(g, d, false);
StaticLayout<Node, DerivationTreeEdge> derivationLayout = new StaticLayout<>(g, dtt);
// derivationLayout.setSize(dtt.getSize());
setGraphLayout(derivationLayout);
scaleToLayout(new LayoutScalingControl());
// g.addCorrespondences();
setPreferredSize(new Dimension(DEFAULT_HEIGHT, DEFAULT_WIDTH));
getRenderContext().setVertexLabelTransformer(new ToStringLabeller<>());
DefaultModalGraphMouse<Node, DerivationTreeEdge> graphMouse = new DefaultModalGraphMouse<>();
graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING);
setGraphMouse(graphMouse);
addKeyListener(graphMouse.getModeKeyListener());
// this.setPickedVertexState(new DerivationTreePickedState(g));
getRenderContext().setVertexFillPaintTransformer(vp);
getRenderContext().setEdgeStrokeTransformer(es);
getRenderContext().setVertexShapeTransformer(ns);
getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR);
TGT = targetColor;
anchorPoint = dtt.getAnchorPosition(anchorStyle);
}
示例4: setUpView
import edu.uci.ics.jung.visualization.decorators.ToStringLabeller; //导入依赖的package包/类
private void setUpView(Graph graph)
{
// layout = new SpringLayout2(graph);
layout = new KKLayout(graph);
//layout.setSize(new Dimension(700,700));
vv = new VisualizationViewer(layout);
vv.setPreferredSize(new Dimension(900,900));
vv.setBackground( Color.white );
// Tell the renderer to use our own customized label rendering
vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller());
vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR);
getContentPane().add(new GraphZoomScrollPane(vv), BorderLayout.CENTER);
/*Mouse controller plugins*/
PluggableGraphMouse gm = new PluggableGraphMouse();
gm.add(new TranslatingGraphMousePlugin(MouseEvent.BUTTON3_MASK));
gm.add(new ScalingGraphMousePlugin(new CrossoverScalingControl(), 0, 1.1f, 0.9f));
gm.add(new PickingGraphMousePlugin());
vv.setGraphMouse(gm);
}
示例5: testJUNG2
import edu.uci.ics.jung.visualization.decorators.ToStringLabeller; //导入依赖的package包/类
@Test
public void testJUNG2() throws Exception {
Graph<String, String> graph = new SparseMultigraph<String, String>();
graph.addVertex("state 1");
graph.addVertex("state 2");
graph.addVertex("state 3");
graph.addVertex("state 4");
graph.addVertex("state 5");
graph.addVertex("state 6");
graph.addEdge("edge 1", "state 1", "state 2", EdgeType.DIRECTED);
graph.addEdge("edge 2", "state 1", "state 3", EdgeType.DIRECTED);
graph.addEdge("edge 3", "state 1", "state 4", EdgeType.DIRECTED);
graph.addEdge("edge 4", "state 3", "state 4", EdgeType.DIRECTED);
CircleLayout<String, String> layout = new CircleLayout<String, String>(graph);
layout.setSize(new Dimension(300, 300));
BasicVisualizationServer<String, String> visualization = new BasicVisualizationServer<String, String>(layout);
visualization.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<String>());
visualization.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller<String>());
visualization.setPreferredSize(new Dimension(350, 350));
JOptionPane.showMessageDialog(null, visualization);
}
示例6: StateVisualizer
import edu.uci.ics.jung.visualization.decorators.ToStringLabeller; //导入依赖的package包/类
public StateVisualizer() {
super("Model Visualizer");
graph = new DirectedSparseMultigraph<>();
graph.addVertex(current);
// Layout<FSMTransition, String> layout = new CircleLayout<FSMTransition, String>(graph);
layout = new KKLayout<>(graph);
layout.setSize(new Dimension(800, 600)); // sets the initial size of the space
vv = new VisualizationViewer<>(layout);
vv.setPreferredSize(new Dimension(800, 600)); //Sets the viewing area size
vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller());
vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR);
VertexLabelAsShapeRenderer<String, StepCounter> vlasr = new VertexLabelAsShapeRenderer<>(vv.getRenderContext());
// vv.getRenderContext().setVertexShapeTransformer(vlasr);
vv.getRenderContext().setVertexShapeTransformer(new EllipseVertexTransformer());
// vv.getRenderContext().setVertexLabelRenderer(new TransitionVertextLabelRenderer(Color.GREEN));
DefaultModalGraphMouse gm = new DefaultModalGraphMouse();
vv.addKeyListener(gm.getModeKeyListener());
gm.setMode(ModalGraphMouse.Mode.TRANSFORMING);
vv.setGraphMouse(gm);
getContentPane().add(vv);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(1024, 768);
pack();
setVisible(true);
}
示例7: FSMBuildVisualizer
import edu.uci.ics.jung.visualization.decorators.ToStringLabeller; //导入依赖的package包/类
public FSMBuildVisualizer() {
super("Model Visualizer");
graph = new DirectedSparseMultigraph<>();
graph.addVertex(current);
// Layout<FSMTransition, String> layout = new CircleLayout<FSMTransition, String>(graph);
layout = new KKLayout<>(graph);
layout.setSize(new Dimension(800, 600)); // sets the initial size of the space
vv = new VisualizationViewer<>(layout);
vv.setPreferredSize(new Dimension(800, 600)); //Sets the viewing area size
vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller());
vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR);
VertexLabelAsShapeRenderer<String, StepCounter> vlasr = new VertexLabelAsShapeRenderer<>(vv.getRenderContext());
// vv.getRenderContext().setVertexShapeTransformer(vlasr);
vv.getRenderContext().setVertexShapeTransformer(new EllipseVertexTransformer());
// vv.getRenderContext().setVertexLabelRenderer(new TransitionVertextLabelRenderer(Color.GREEN));
DefaultModalGraphMouse gm = new DefaultModalGraphMouse();
vv.addKeyListener(gm.getModeKeyListener());
gm.setMode(ModalGraphMouse.Mode.TRANSFORMING);
vv.setGraphMouse(gm);
getContentPane().add(vv);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(1024, 768);
pack();
setVisible(true);
}
示例8: getGraphPanel
import edu.uci.ics.jung.visualization.decorators.ToStringLabeller; //导入依赖的package包/类
private JComponent getGraphPanel() {
if (vv == null) {
layout = new RoleGraphLayout(graph);
layout.setSize(new Dimension(300, 300));
vv = new VisualizationViewer<String, String>(layout);
vv.setBorder(new LineBorder(new Color(0, 0, 0)));
vv.getRenderContext().setVertexFillPaintTransformer(new RoleVertexColorTransformer());
vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<String>());
vv.getRenderContext().setVertexShapeTransformer(new RoleVertexSizeTransformer());
vv.getRenderContext().setEdgeLabelTransformer(new RoleEdgeLabeller());
vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR);
vv.setPreferredSize(new Dimension(350, 350));
gm = new RoleGraphMouse(vv.getRenderContext());
vv.setGraphMouse(gm);
gm.setPickingMode();
gm.addEdgeAddedListener(this);
vv.setFocusable(true);
vv.addKeyListener(new GraphKeyListener());
}
return vv;
}
示例9: main
import edu.uci.ics.jung.visualization.decorators.ToStringLabeller; //导入依赖的package包/类
public static void main(String [] args) {
JOptionPane.showMessageDialog(null,
"Block already exists!",
"Error",
JOptionPane.ERROR_MESSAGE);
InteractionGraphs igraphs = InteractionGraphs.getInstance();
igraphs.buildFromDB();
InteractionGraph graph = igraphs.getGraph(new EntityMID("test"));
Layout<Integer,String> layout = new CircleLayout(graph);
layout.setSize(new Dimension(300,300));
BasicVisualizationServer<Integer,String> vv = new BasicVisualizationServer<Integer,String>(layout);
vv.setPreferredSize(new Dimension(350,350));
vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
JFrame frame = new JFrame("simple");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(vv);
frame.pack();
frame.setVisible(true);
System.out.println("done");
}
示例10: actionPerformed
import edu.uci.ics.jung.visualization.decorators.ToStringLabeller; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
GraphViewerPanel viewerPanel = (GraphViewerPanel) frame.getTabbedPane().getSelectedComponent();
if(viewerPanel.isEdgeLabel()){
viewerPanel.getVisualizationViewer().getRenderContext().setEdgeLabelTransformer(new ConstantTransformer(null));
viewerPanel.getVisualizationViewer().repaint();
viewerPanel.setEdgeLabel(false);
}
else{
viewerPanel.getVisualizationViewer().getRenderContext().setEdgeLabelTransformer(new ToStringLabeller<String>());
viewerPanel.getVisualizationViewer().repaint();
viewerPanel.setEdgeLabel(true);
}
}
示例11: GraphRenderer
import edu.uci.ics.jung.visualization.decorators.ToStringLabeller; //导入依赖的package包/类
/**
* Full constructor
*
* @param graph
* The graph to render
* @param layout
* The layout to use
*/
public GraphRenderer(Graph<V, E> graph, Layout<V, E> layout) {
this.graph = graph;
this.setBackground(Color.WHITE);
layout.setSize(new Dimension(1680, 1050));
final VisualizationViewer<V, E> viewer = new VisualizationViewer<V, E>(
layout);
viewer.setBackground(Color.WHITE);
viewer.getRenderContext().setVertexDrawPaintTransformer(
new BlackVertexDrawPaintFunction<V>());
viewer.getRenderContext().setVertexFillPaintTransformer(
new HighlightingVertexFillPaintFunction<V>());
viewer.getRenderContext().setEdgeDrawPaintTransformer(
new HighlightingEdgePaintFunction());
viewer.getRenderContext().setEdgeStrokeTransformer(
new HighlightingEdgeStrokeFunction());
viewer.getRenderContext().setVertexLabelTransformer(
new ToStringLabeller<V>());
viewer.setGraphMouse(new DefaultModalGraphMouse<V, E>());
this.setLayout(new BorderLayout());
this.add(viewer, BorderLayout.CENTER);
}
示例12: visualizeGraph
import edu.uci.ics.jung.visualization.decorators.ToStringLabeller; //导入依赖的package包/类
public static <V, E> void visualizeGraph(Graph<V,E> g) {
Layout<Integer, String> layout = new KKLayout(g);
layout.setSize(new Dimension(800,800)); // sets the initial size of the layout space
// The BasicVisualizationServer<V,E> is parameterized by the vertex and edge types
VisualizationViewer<Integer,String> vv = new VisualizationViewer<Integer,String>(layout);
DefaultModalGraphMouse gm = new DefaultModalGraphMouse();
gm.setMode(DefaultModalGraphMouse.Mode.TRANSFORMING);
vv.setGraphMouse(gm);
vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
vv.setPreferredSize(new Dimension(800,800)); //Sets the viewing area size
JFrame frame = new JFrame("Simple Graph View");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(vv);
frame.pack();
frame.setVisible(true);
}
示例13: DrawnIconVertexDemo
import edu.uci.ics.jung.visualization.decorators.ToStringLabeller; //导入依赖的package包/类
public DrawnIconVertexDemo(final Deployment dm) {
this.dmodel = dm;
// create a simple graph for the demo
graph = new DirectedSparseGraph<Vertex, Edge>();
vv = new VisualizationViewer<Vertex, Edge>(new SpringLayout2<Vertex, Edge>(graph));
vv.getRenderContext().setVertexLabelRenderer(new DefaultVertexLabelRenderer(Color.cyan));
vv.getRenderContext().setEdgeLabelRenderer(new DefaultEdgeLabelRenderer(Color.cyan));
vv.getRenderContext().setVertexIconTransformer(vertexColor);
vv.getRenderContext().setVertexFillPaintTransformer(new PickableVertexPaintTransformer<Vertex>(vv.getPickedVertexState(), Color.white, Color.yellow));
vv.getRenderContext().setEdgeDrawPaintTransformer(edgeColor);
vv.setBackground(Color.white);
// add my listener for ToolTips
vv.setVertexToolTipTransformer(new ToStringLabeller<Vertex>());
}
示例14: MapperEngine
import edu.uci.ics.jung.visualization.decorators.ToStringLabeller; //导入依赖的package包/类
public MapperEngine() {
graph = new SparseMultigraph<Room, Exit>();
mapperLayout = new MapperLayout( graph );
mapperLayout.setSize( new Dimension( 500, 500 ) ); //????
vv = new VisualizationViewer<Room, Exit>( mapperLayout );
pickedState = vv.getPickedVertexState();
pickedState.addItemListener( this );
vv.setPreferredSize( new Dimension( 500, 500 ) ); //????
RenderContext<Room, Exit> rc = vv.getRenderContext();
rc.setEdgeLabelTransformer( new ToStringLabeller<Exit>() );
rc.setEdgeLabelRenderer( new ExitLabelRenderer() );
rc.setEdgeShapeTransformer( new EdgeShape.QuadCurve<Room, Exit>() );
rc.setEdgeShapeTransformer( new EdgeShape.Wedge<Room, Exit>( 30 ) );
rc.setEdgeFillPaintTransformer( new ExitPaintTransformer( vv ) );
rc.setVertexShapeTransformer( new RoomShape( graph ) );
rc.setVertexIconTransformer( new RoomIconTransformer() );
vv.getRenderContext().setLabelOffset( 5 );
PluggableGraphMouse pgm = new PluggableGraphMouse();
pgm.add( new MapperPickingGraphMousePlugin<Room, Exit>( MouseEvent.BUTTON1_MASK, MouseEvent.BUTTON3_MASK ) );
pgm.add( new TranslatingGraphMousePlugin( MouseEvent.BUTTON1_MASK ) );
scaler = new ScalingGraphMousePlugin( new CrossoverScalingControl(), 0, 1 / 1.1f, 1.1f );
pgm.add( scaler );
mousePlugin = new MapperEditingGraphMousePlugin( this );
pgm.add( mousePlugin );
vv.setGraphMouse( pgm );
panel = new MapperPanel( this );
}
示例15: VisualizationImageServerDemo
import edu.uci.ics.jung.visualization.decorators.ToStringLabeller; //导入依赖的package包/类
/**
*
*/
public VisualizationImageServerDemo() {
// create a simple graph for the demo
graph = new DirectedSparseMultigraph<String, Number>();
String[] v = createVertices(10);
createEdges(v);
vv = new VisualizationImageServer<String,Number>(new KKLayout<String,Number>(graph), new Dimension(600,600));
vv.getRenderer().setVertexRenderer(
new GradientVertexRenderer<String,Number>(
Color.white, Color.red,
Color.white, Color.blue,
vv.getPickedVertexState(),
false));
vv.getRenderContext().setEdgeDrawPaintTransformer(new ConstantTransformer(Color.lightGray));
vv.getRenderContext().setArrowFillPaintTransformer(new ConstantTransformer(Color.lightGray));
vv.getRenderContext().setArrowDrawPaintTransformer(new ConstantTransformer(Color.lightGray));
vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
vv.getRenderer().getVertexLabelRenderer().setPositioner(new InsidePositioner());
vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.AUTO);
// create a frome to hold the graph
final JFrame frame = new JFrame();
Container content = frame.getContentPane();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Image im = vv.getImage(new Point2D.Double(300,300), new Dimension(600,600));
Icon icon = new ImageIcon(im);
JLabel label = new JLabel(icon);
content.add(label);
frame.pack();
frame.setVisible(true);
}