当前位置: 首页>>代码示例>>Java>>正文


Java Renderer类代码示例

本文整理汇总了Java中edu.uci.ics.jung.visualization.renderers.Renderer的典型用法代码示例。如果您正苦于以下问题:Java Renderer类的具体用法?Java Renderer怎么用?Java Renderer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Renderer类属于edu.uci.ics.jung.visualization.renderers包,在下文中一共展示了Renderer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: labelVertex

import edu.uci.ics.jung.visualization.renderers.Renderer; //导入依赖的package包/类
@Override
public void labelVertex(RenderContext<GUINode, GUILink> rc, Layout<GUINode, GUILink> layout, GUINode v, String label)
{
    if (!callback.getVisualizationState().isVisibleInCanvas(v)) return;
    if (callback.getVisualizationState().isCanvasShowNodeNames() && v.getLayer().isDefaultLayer())
    {
        Point2D vertexPositionInPixels = layout.transform(v);
        vertexPositionInPixels = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, vertexPositionInPixels);
        final Component component = prepareRenderer(rc, rc.getVertexLabelRenderer(), "<html><font color='black'>" + v.getLabel() + "</font></html>", rc.getPickedVertexState().isPicked(v), v);
        final GraphicsDecorator g = rc.getGraphicsContext();
        final Dimension dimensionMessage = component.getPreferredSize();
        final Icon vertexIcon = v.getIcon();
        final Rectangle2D boundsVertex = new Rectangle2D.Double(vertexPositionInPixels.getX() - vertexIcon.getIconWidth() / 2, vertexPositionInPixels.getY() - vertexIcon.getIconHeight() / 2, vertexIcon.getIconWidth(), vertexIcon.getIconHeight());
        final Point anchorPointInPixels = getAnchorPoint(boundsVertex, dimensionMessage, Renderer.VertexLabel.Position.NE);
        g.draw(component, rc.getRendererPane(), anchorPointInPixels.x, anchorPointInPixels.y, dimensionMessage.width, dimensionMessage.height, true);
    }
}
 
开发者ID:girtel,项目名称:Net2Plan,代码行数:18,代码来源:JUNGCanvas.java

示例2: getAnchorPoint

import edu.uci.ics.jung.visualization.renderers.Renderer; //导入依赖的package包/类
@Override
protected Point getAnchorPoint(Rectangle2D vertexBounds, Dimension labelSize, Renderer.VertexLabel.Position position)
{
    double x;
    double y;
    int offset = 0;
    switch (position)
    {
        case NE:
            x = vertexBounds.getMaxX() - offset;
            y = vertexBounds.getMinY() + offset - labelSize.height;
            return new Point((int) x, (int) y);
        case CNTR:
            x = vertexBounds.getCenterX() - ((double) labelSize.width / 2);
            y = vertexBounds.getCenterY() - ((double) labelSize.height / 2);
            return new Point((int) x, (int) y);

        default:
            return new Point();
    }

}
 
开发者ID:girtel,项目名称:Net2Plan,代码行数:23,代码来源:JUNGCanvas.java

示例3: init

import edu.uci.ics.jung.visualization.renderers.Renderer; //导入依赖的package包/类
private void init() {
    setOpaque(true);
    setBackground(new Color(255, 255, 255, 0));

    final RenderContext<Node, Edge> context = getRenderContext();

    context.setVertexFillPaintTransformer(new VertexFillPaintTransformer());
    context.setVertexShapeTransformer(new VertexShapeTransformer(getFontMetrics(getFont())));
    context.setVertexLabelTransformer(new VertexLabelTransformer());
    getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR);

    context.setEdgeLabelTransformer(new EdgeLabelTransformer());
    context.setEdgeShapeTransformer(new EdgeShape.Line<Node, Edge>());
    context.setEdgeLabelClosenessTransformer(new EdgeLabelClosenessTransformer());
    context.getEdgeLabelRenderer().setRotateEdgeLabels(rotateEdges);
    getRenderer().setEdgeLabelRenderer(new EdgeLabelRenderer());
}
 
开发者ID:apache,项目名称:incubator-batchee,代码行数:18,代码来源:DiagramGenerator.java

示例4: VisualizationImageServerDemo

import edu.uci.ics.jung.visualization.renderers.Renderer; //导入依赖的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);
}
 
开发者ID:marcvanzee,项目名称:mdp-plan-revision,代码行数:40,代码来源:VisualizationImageServerDemo.java

示例5: createGraphViewer

import edu.uci.ics.jung.visualization.renderers.Renderer; //导入依赖的package包/类
private void createGraphViewer() {
        MyVisualizationViewer vv = this;
        vv.addGraphMouseListener(new TestGraphMouseListener<String>());
        // add my listeners for ToolTips
        vv.setVertexToolTipTransformer(createNodeTooltipTransformer());
        final VertexIconShapeTransformer<String> vertexImageShapeFunction =
            new VertexIconShapeTransformer<String>(new EllipseVertexShapeTransformer<String>());
        vv.getRenderContext().setVertexShapeTransformer(vertexImageShapeFunction);
        final DefaultVertexIconTransformer<String> vertexIconFunction =
        	new DefaultVertexIconTransformer<String>();
        vv.getRenderContext().setVertexIconTransformer(vertexIconFunction);
        vertexImageShapeFunction.setIconMap(iconMap);
        vertexIconFunction.setIconMap(iconMap);

        vv.setEdgeToolTipTransformer(createEdgeToolTipTransformer());

        vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<String>());
        vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.AUTO);

        // 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);
//        Transformer<String, Stroke> edgeStrokeTransformer =
//              new Transformer<String, Stroke>() {
//                    public Stroke transform(String s) {
//                        return edgeStroke;
//                    }
//        };
//        vv.getRenderContext().setEdgeStrokeTransformer(edgeStrokeTransformer);
        vv.getRenderContext().setEdgeStrokeTransformer(createEdgeStrokeTransformer());
        vv.getRenderContext().setEdgeLabelTransformer(createEdgeLabelTransformer());
        vv.getRenderContext().setEdgeLabelRenderer(new DefaultEdgeLabelRenderer(Color.cyan));
        vv.getRenderContext().setEdgeDrawPaintTransformer(createEdgeDrawPaintTransformer());
    }
 
开发者ID:iTransformers,项目名称:netTransformer,代码行数:36,代码来源:MyVisualizationViewer.java

示例6: paintGraph

import edu.uci.ics.jung.visualization.renderers.Renderer; //导入依赖的package包/类
private void paintGraph(Collection<Planet> planets) {
	planetsInGraph = new HashMap<String, Planet>();
	graph = new SparseMultigraph<Planet, String>();

	for (Planet planet : planets) {
		graph.addVertex(planet);
		planetsInGraph.put(planet.getId(), planet);
	}

	paintEdges();
	locationTransformer = new LocationTransformer(
			Collections.unmodifiableCollection(planets), vm.getGameType());
	final Layout<Planet, String> layout = new StaticLayout<Planet, String>(graph,
			locationTransformer);
	layout.setSize(new Dimension(View.START_WIDTH, View.START_HEIGHT));

	vv = new VisualizationViewer<Planet, String>(layout);
	vv.setPreferredSize(new Dimension(View.START_WIDTH, View.START_HEIGHT));
	vv.setRenderer(new UglyHuckRenderer());
	vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
	vv.getRenderContext().setVertexShapeTransformer(vertexSize);
	// vv.getRenderContext().setEdgeStrokeTransformer(edgeStrokeTransformer);
	vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
	vv.getRenderContext().setEdgeDrawPaintTransformer(edgePaint);
	vv.getRenderContext().setArrowDrawPaintTransformer(edgePaint);
	vv.getRenderContext().setEdgeLabelTransformer(edgeLabel);

	vv.getRenderer().getVertexLabelRenderer()
			.setPosition(Renderer.VertexLabel.Position.CNTR);

	vv.getRenderContext().setEdgeShapeTransformer(
			new EdgeShape.Line<Planet, String>());			

	this.add(vv);
	updateUI();
	// this.validate();
	this.repaint();
}
 
开发者ID:burningrain,项目名称:planetBot,代码行数:39,代码来源:GraphWidget.java

示例7: painGraph

import edu.uci.ics.jung.visualization.renderers.Renderer; //导入依赖的package包/类
public void painGraph(Forest f)
{
	Layout daLayout = new FRLayout((edu.uci.ics.jung.graph.Graph)f);
	Renderer r = new BasicRenderer();
	VisualizationViewer vv = new VisualizationViewer(daLayout);
	
	vv.setRenderer(r);
	vv.getRenderContext().setVertexLabelTransformer(new SPVertexLabelTransformer());
	JFrame frame = new JFrame();
	frame.getContentPane().add(vv);
	frame.pack();
	frame.setVisible(true);
}
 
开发者ID:SEMOSS,项目名称:semoss,代码行数:14,代码来源:BigDataEngine.java

示例8: getVertexRenderer

import edu.uci.ics.jung.visualization.renderers.Renderer; //导入依赖的package包/类
/** Returns the renderer used for the nodes. May return null (use default renderer). */
public Renderer.Vertex<V, E> getVertexRenderer();
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:3,代码来源:GraphCreator.java

示例9: getVertexLabelRenderer

import edu.uci.ics.jung.visualization.renderers.Renderer; //导入依赖的package包/类
/** Returns the renderer used for node labels. May return null (use default renderer). */
public Renderer.VertexLabel<V, E> getVertexLabelRenderer();
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:3,代码来源:GraphCreator.java

示例10: getEdgeLabelRenderer

import edu.uci.ics.jung.visualization.renderers.Renderer; //导入依赖的package包/类
/** Returns the renderer for edge labels. May return null (use default renderer). */
public Renderer.EdgeLabel<V, E> getEdgeLabelRenderer();
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:3,代码来源:GraphCreator.java

示例11: ViwnVertexRenderer

import edu.uci.ics.jung.visualization.renderers.Renderer; //导入依赖的package包/类
public ViwnVertexRenderer(Renderer.Vertex<ViwnNode, ViwnEdge> delegate) {
    this.delegate = delegate;
}
 
开发者ID:CLARIN-PL,项目名称:WordnetLoom,代码行数:4,代码来源:ViwnVertexRenderer.java

示例12: setRenderer

import edu.uci.ics.jung.visualization.renderers.Renderer; //导入依赖的package包/类
@Override
public void setRenderer(Renderer<INode, IConnection> renderer) {
    throw new UnsupportedOperationException("Operation not implemented yet");
}
 
开发者ID:truffle-hog,项目名称:truffle-hog,代码行数:5,代码来源:FXVisualizationViewer.java

示例13: getRenderer

import edu.uci.ics.jung.visualization.renderers.Renderer; //导入依赖的package包/类
@Override
public Renderer<INode, IConnection> getRenderer() {
    throw new UnsupportedOperationException("Operation not implemented yet");
}
 
开发者ID:truffle-hog,项目名称:truffle-hog,代码行数:5,代码来源:FXVisualizationViewer.java

示例14: ShortestPathDemo

import edu.uci.ics.jung.visualization.renderers.Renderer; //导入依赖的package包/类
public ShortestPathDemo() {

	this.mGraph = getGraph();
	setBackground(Color.WHITE);
	// show graph
       final Layout<String,Number> layout = new FRLayout<String,Number>(mGraph);
       final VisualizationViewer<String,Number> vv = new VisualizationViewer<String,Number>(layout);
       vv.setBackground(Color.WHITE);

       vv.getRenderContext().setVertexDrawPaintTransformer(new MyVertexDrawPaintFunction<String>());
       vv.getRenderContext().setVertexFillPaintTransformer(new MyVertexFillPaintFunction<String>());
       vv.getRenderContext().setEdgeDrawPaintTransformer(new MyEdgePaintFunction());
       vv.getRenderContext().setEdgeStrokeTransformer(new MyEdgeStrokeFunction());
       vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<String>());
       vv.setGraphMouse(new DefaultModalGraphMouse<String, Number>());
       vv.addPostRenderPaintable(new VisualizationViewer.Paintable(){
           
           public boolean useTransform() {
               return true;
           }
           public void paint(Graphics g) {
               if(mPred == null) return;
               
               // for all edges, paint edges that are in shortest path
               for (Number e : layout.getGraph().getEdges()) {
                   
                   if(isBlessed(e)) {
                       String v1 = mGraph.getEndpoints(e).getFirst();
                       String v2 = mGraph.getEndpoints(e).getSecond();
                       Point2D p1 = layout.transform(v1);
                       Point2D p2 = layout.transform(v2);
                       p1 = vv.getRenderContext().getMultiLayerTransformer().transform(Layer.LAYOUT, p1);
                       p2 = vv.getRenderContext().getMultiLayerTransformer().transform(Layer.LAYOUT, p2);
                       Renderer<String,Number> renderer = vv.getRenderer();
                       renderer.renderEdge(
                               vv.getRenderContext(),
                               layout,
                               e);
                   }
               }
           }
       });
       
       setLayout(new BorderLayout());
       add(vv, BorderLayout.CENTER);
       // set up controls
       add(setUpControls(), BorderLayout.SOUTH);
}
 
开发者ID:marcvanzee,项目名称:mdp-plan-revision,代码行数:49,代码来源:ShortestPathDemo.java

示例15: init

import edu.uci.ics.jung.visualization.renderers.Renderer; //导入依赖的package包/类
@Override
    public void init() {

        //create a graph
    	Graph<Number,Number> ig = Graphs.<Number,Number>synchronizedDirectedGraph(new DirectedSparseMultigraph<Number,Number>());

        ObservableGraph<Number,Number> og = new ObservableGraph<Number,Number>(ig);
        og.addGraphEventListener(new GraphEventListener<Number,Number>() {

			public void handleGraphEvent(GraphEvent<Number, Number> evt) {
				System.err.println("got "+evt);

			}});
        
        this.g = og;
        //create a graphdraw
        layout = new FRLayout2<Number,Number>(g);
//        ((FRLayout)layout).setMaxIterations(200);

        vv = new VisualizationViewer<Number,Number>(layout, new Dimension(600,600));

        JRootPane rp = this.getRootPane();
        rp.putClientProperty("defeatSystemEventQueueCheck", Boolean.TRUE);

        getContentPane().setLayout(new BorderLayout());
        getContentPane().setBackground(java.awt.Color.lightGray);
        getContentPane().setFont(new Font("Serif", Font.PLAIN, 12));

        vv.getModel().getRelaxer().setSleepTime(500);
        vv.setGraphMouse(new DefaultModalGraphMouse<Number,Number>());

        vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR);
        vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<Number>());
        vv.setForeground(Color.white);
        getContentPane().add(vv);
        switchLayout = new JButton("Switch to SpringLayout");
        switchLayout.addActionListener(new ActionListener() {

            @SuppressWarnings("unchecked")
            public void actionPerformed(ActionEvent ae) {
            	Dimension d = new Dimension(600,600);
                if (switchLayout.getText().indexOf("Spring") > 0) {
                    switchLayout.setText("Switch to FRLayout");
                    layout = new SpringLayout<Number,Number>(g,
                        new ConstantTransformer(EDGE_LENGTH));
                    layout.setSize(d);
                    vv.getModel().setGraphLayout(layout, d);
                } else {
                    switchLayout.setText("Switch to SpringLayout");
                    layout = new FRLayout<Number,Number>(g, d);
                    vv.getModel().setGraphLayout(layout, d);
                }
            }
        });

        getContentPane().add(switchLayout, BorderLayout.SOUTH);

        timer = new Timer();
    }
 
开发者ID:marcvanzee,项目名称:mdp-plan-revision,代码行数:60,代码来源:AddNodeDemo.java


注:本文中的edu.uci.ics.jung.visualization.renderers.Renderer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。