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


Java RenderContext类代码示例

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


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

示例1: renderSet

import edu.uci.ics.jung.visualization.RenderContext; //导入依赖的package包/类
private void renderSet(
        RenderContext<ViwnNode, ViwnEdge> rc,
        Point2D p,
        ViwnNodeSet node) {
    GraphicsDecorator g = rc.getGraphicsContext();
    String text = "" + node.getSynsets().size();

    Font f = new Font("Sansserif", Font.BOLD, 14);
    Font old_font = g.getFont();
    g.setFont(f);

    FontMetrics metrics = g.getFontMetrics(g.getFont());
    int width = metrics.stringWidth(text);
    int height = metrics.getHeight();

    g.setColor(Color.black);
    g.drawString(text,
            (int) p.getX() - width / 2,
            (int) p.getY());

    width = metrics.stringWidth("...");
    g.drawString("...",
            (int) p.getX() - width / 2,
            (int) p.getY() + 0.25f * height);
    g.setFont(old_font);
}
 
开发者ID:CLARIN-PL,项目名称:WordnetLoom,代码行数:27,代码来源:ViwnVertexRenderer.java

示例2: paintVertex

import edu.uci.ics.jung.visualization.RenderContext; //导入依赖的package包/类
/**
 * Paint vertex <code>v</code> on <code>g</code> at <code>(x,y)</code>.
 *
 * @param rc
 * @param v
 * @param layout
 */
protected void paintVertex(
        RenderContext<ViwnNode, ViwnEdge> rc,
        ViwnNode v,
        Layout<ViwnNode, ViwnEdge> layout) {
    Point2D p = layout.transform(v);
    p = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, p);

    if (v instanceof ViwnNodeSet) {
        delegate.paintVertex(rc, layout, v);
        renderSet(rc, p, (ViwnNodeSet) v);
    } else if (v instanceof ViwnNodeSynset) {
        renderSynset(rc, p, (ViwnNodeSynset) v, layout);
    } else if (v instanceof ViwnNodeWord) {
        delegate.paintVertex(rc, layout, v);
        renderWord(rc, p, (ViwnNodeWord) v);
    }
}
 
开发者ID:CLARIN-PL,项目名称:WordnetLoom,代码行数:25,代码来源:ViwnVertexRenderer.java

示例3: labelVertex

import edu.uci.ics.jung.visualization.RenderContext; //导入依赖的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

示例4: vertexHit

import edu.uci.ics.jung.visualization.RenderContext; //导入依赖的package包/类
protected boolean vertexHit(RenderContext<V, E> rc, Shape s) {
	JComponent vv = rc.getScreenDevice();
	Rectangle deviceRectangle = null;
	if (vv != null) {
		Dimension d = vv.getSize();
		deviceRectangle = new Rectangle(0, 0, d.width, d.height);
	}
	if (deviceRectangle != null) {
		MutableTransformer vt = rc.getMultiLayerTransformer().getTransformer(Layer.VIEW);
		if (vt instanceof MutableTransformerDecorator) {
			vt = ((MutableTransformerDecorator) vt).getDelegate();
		}
		return vt.transform(s).intersects(deviceRectangle);
	} else {
		return false;
	}
}
 
开发者ID:rapidminer,项目名称:rapidminer-studio,代码行数:18,代码来源:TreeModelNodeRenderer.java

示例5: paintVertex

import edu.uci.ics.jung.visualization.RenderContext; //导入依赖的package包/类
@Override public void paintVertex(RenderContext<String, String> rc,
    Layout<String, String> layout, String vertex) {
  GraphicsDecorator graphicsContext = rc.getGraphicsContext();
  Point2D center = layout.transform(vertex);
  Shape shape = null;
  Color color = null;
  if(vertex.equals("Square")) {
    shape = new Rectangle((int)center.getX()-10, (int)center.getY()-10, 20, 20);
    color = new Color(127, 127, 0);
  } else if(vertex.equals("Rectangle")) {
    shape = new Rectangle((int)center.getX()-10, (int)center.getY()-20, 20, 40);
    color = new Color(127, 0, 127);
  } else if(vertex.equals("Circle")) {
    shape = new Ellipse2D.Double(center.getX()-10, center.getY()-10, 20, 20);
    color = new Color(0, 127, 127);
  }
  graphicsContext.setPaint(color);
  graphicsContext.fill(shape);
}
 
开发者ID:marcvanzee,项目名称:mdp-plan-revision,代码行数:20,代码来源:VertexShapes.java

示例6: applyStyles

import edu.uci.ics.jung.visualization.RenderContext; //导入依赖的package包/类
public static <V, E> void applyStyles(final VisualizationViewer<V, E> visualizationViewer) {
    final RenderContext<V, E> renderContext = visualizationViewer.getRenderContext();

    renderContext.setEdgeLabelRenderer(new DefaultEdgeLabelRenderer(WidgetUtils.BG_COLOR_BLUE_MEDIUM, false));
    renderContext.setEdgeStrokeTransformer(input -> stroke);
    renderContext.setEdgeDrawPaintTransformer(input -> WidgetUtils.BG_COLOR_LESS_BRIGHT);
    renderContext.setVertexLabelRenderer(new DefaultVertexLabelRenderer(WidgetUtils.BG_COLOR_BLUE_MEDIUM));
    renderContext.setEdgeFontTransformer(GraphUtils.createFontTransformer());
    renderContext.setVertexFontTransformer(GraphUtils.createFontTransformer());

    final DefaultModalGraphMouse<Object, Integer> graphMouse = new DefaultModalGraphMouse<Object, Integer>() {
        @Override
        public void mouseWheelMoved(final MouseWheelEvent e) {
            // avoid zooming
            return;
        }
    };
    graphMouse.setMode(ModalGraphMouse.Mode.PICKING);
    graphMouse.setZoomAtMouse(false);

    visualizationViewer.setGraphMouse(graphMouse);
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:23,代码来源:GraphUtils.java

示例7: getArrowTransform

import edu.uci.ics.jung.visualization.RenderContext; //导入依赖的package包/类
public AffineTransform getArrowTransform(RenderContext<V,E> rc, Shape edgeShape, Shape vertexShape) {
	GeneralPath path = new GeneralPath(edgeShape);
    float[] seg = new float[6];
    Point2D p1=null;
    Point2D p2=null;
    AffineTransform at = new AffineTransform();
    // when the PathIterator is done, switch to the line-subdivide
    // method to get the arrowhead closer.
    for(PathIterator i=path.getPathIterator(null,1); !i.isDone(); i.next()) {
        int ret = i.currentSegment(seg);
        if(ret == PathIterator.SEG_MOVETO) {
            p2 = new Point2D.Float(seg[0],seg[1]);
        } else if(ret == PathIterator.SEG_LINETO) {
            p1 = p2;
            p2 = new Point2D.Float(seg[0],seg[1]);
            if(vertexShape.contains(p2)) {
                at = getArrowTransform(rc, new Line2D.Float(p1,p2),vertexShape);
                break;
            }
        } 
    }
    return at;
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:24,代码来源:BasicEdgeArrowRenderingSupport.java

示例8: getReverseArrowTransform

import edu.uci.ics.jung.visualization.RenderContext; //导入依赖的package包/类
public AffineTransform getReverseArrowTransform(RenderContext<V,E> rc, Shape edgeShape, Shape vertexShape,
        boolean passedGo) {
	GeneralPath path = new GeneralPath(edgeShape);
    float[] seg = new float[6];
    Point2D p1=null;
    Point2D p2=null;

    AffineTransform at = new AffineTransform();
    for(PathIterator i=path.getPathIterator(null,1); !i.isDone(); i.next()) {
        int ret = i.currentSegment(seg);
        if(ret == PathIterator.SEG_MOVETO) {
            p2 = new Point2D.Float(seg[0],seg[1]);
        } else if(ret == PathIterator.SEG_LINETO) {
            p1 = p2;
            p2 = new Point2D.Float(seg[0],seg[1]);
            if(passedGo == false && vertexShape.contains(p2)) {
                passedGo = true;
             } else if(passedGo==true &&
                    vertexShape.contains(p2)==false) {
                 at = getReverseArrowTransform(rc, new Line2D.Float(p1,p2),vertexShape);
                break;
            }
        } 
    }
    return at;
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:27,代码来源:BasicEdgeArrowRenderingSupport.java

示例9: paintEdge

import edu.uci.ics.jung.visualization.RenderContext; //导入依赖的package包/类
public void paintEdge(RenderContext<V,E> rc, Layout<V, E> layout, E e) {
    GraphicsDecorator g2d = rc.getGraphicsContext();
    Graph<V,E> graph = layout.getGraph();
    if (!rc.getEdgeIncludePredicate().evaluate(Context.<Graph<V,E>,E>getInstance(graph,e)))
        return;
    
    // don't draw edge if either incident vertex is not drawn
    Pair<V> endpoints = graph.getEndpoints(e);
    V v1 = endpoints.getFirst();
    V v2 = endpoints.getSecond();
    if (!rc.getVertexIncludePredicate().evaluate(Context.<Graph<V,E>,V>getInstance(graph,v1)) || 
        !rc.getVertexIncludePredicate().evaluate(Context.<Graph<V,E>,V>getInstance(graph,v2)))
        return;
    
    Stroke new_stroke = rc.getEdgeStrokeTransformer().transform(e);
    Stroke old_stroke = g2d.getStroke();
    if (new_stroke != null)
        g2d.setStroke(new_stroke);
    
    drawSimpleEdge(rc, layout, e);

    // restore paint and stroke
    if (new_stroke != null)
        g2d.setStroke(old_stroke);

}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:27,代码来源:BasicEdgeRenderer.java

示例10: labelVertex

import edu.uci.ics.jung.visualization.RenderContext; //导入依赖的package包/类
/**
* Labels the specified vertex with the specified label.  
* Uses the font specified by this instance's 
* <code>VertexFontFunction</code>.  (If the font is unspecified, the existing
* font for the graphics context is used.)  If vertex label centering
* is active, the label is centered on the position of the vertex; otherwise
   * the label is offset slightly.
   */
  public void labelVertex(RenderContext<V,E> rc, Layout<V,E> layout, V v, String label) {
  	Graph<V,E> graph = layout.getGraph();
      if (rc.getVertexIncludePredicate().evaluate(Context.<Graph<V,E>,V>getInstance(graph,v)) == false) {
      	return;
      }
      GraphicsDecorator g = rc.getGraphicsContext();
      Component component = prepareRenderer(rc, rc.getVertexLabelRenderer(), label,
      		rc.getPickedVertexState().isPicked(v), v);
      Dimension d = component.getPreferredSize();
      
      int h_offset = -d.width / 2;
      int v_offset = -d.height / 2;
      
      Point2D p = layout.transform(v);
      p = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, p);

      int x = (int)p.getX();
      int y = (int)p.getY();

      g.draw(component, rc.getRendererPane(), x+h_offset, y+v_offset, d.width, d.height, true);

      Dimension size = component.getPreferredSize();
      Rectangle bounds = new Rectangle(-size.width/2 -2, -size.height/2 -2, size.width+4, size.height);
      shapes.put(v, bounds);
  }
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:34,代码来源:VertexLabelAsShapeRenderer.java

示例11: paintShapeForVertex

import edu.uci.ics.jung.visualization.RenderContext; //导入依赖的package包/类
protected void paintShapeForVertex(RenderContext<V,E> rc, V v, Shape shape) {
    GraphicsDecorator g = rc.getGraphicsContext();
    Paint oldPaint = g.getPaint();
    Paint fillPaint = rc.getVertexFillPaintTransformer().transform(v);
    if(fillPaint != null) {
        g.setPaint(fillPaint);
        g.fill(shape);
        g.setPaint(oldPaint);
    }
    Paint drawPaint = rc.getVertexDrawPaintTransformer().transform(v);
    if(drawPaint != null) {
    	g.setPaint(drawPaint);
    	Stroke oldStroke = g.getStroke();
    	Stroke stroke = rc.getVertexStrokeTransformer().transform(v);
    	if(stroke != null) {
    		g.setStroke(stroke);
    	}
    	g.draw(shape);
    	g.setPaint(oldPaint);
    	g.setStroke(oldStroke);
    }
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:23,代码来源:BasicVertexRenderer.java

示例12: getArrowTransform

import edu.uci.ics.jung.visualization.RenderContext; //导入依赖的package包/类
/**
 * This is used for the arrow of a directed and for one of the
 * arrows for non-directed edges
 * Get a transform to place the arrow shape on the passed edge at the
 * point where it intersects the passed shape
 * @param edgeShape
 * @param vertexShape
 * @return
 */
public AffineTransform getArrowTransform(RenderContext<V,E> rc, Line2D edgeShape, Shape vertexShape) {
    
    // find the midpoint of the edgeShape line, and use it to make the transform
    Line2D left = new Line2D.Float();
    Line2D right = new Line2D.Float();
    this.subdivide(edgeShape, left, right);
    edgeShape = right;
    float dx = (float) (edgeShape.getX1()-edgeShape.getX2());
    float dy = (float) (edgeShape.getY1()-edgeShape.getY2());
    double atheta = Math.atan2(dx,dy)+Math.PI/2;
    AffineTransform at = 
        AffineTransform.getTranslateInstance(edgeShape.getX1(), edgeShape.getY1());
    at.rotate(-atheta);
    return at;
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:25,代码来源:CenterEdgeArrowRenderingSupport.java

示例13: BoundingRectanglePaintable

import edu.uci.ics.jung.visualization.RenderContext; //导入依赖的package包/类
public BoundingRectanglePaintable(RenderContext<V, E> rc, Layout<V, E> layout) {
	super();
	this.rc = rc;
	this.layout = layout;
	this.graph = layout.getGraph();
	final BoundingRectangleCollector<V,E> brc = new BoundingRectangleCollector<V,E>(rc, layout);
	this.rectangles = brc.getRectangles();
	if(layout instanceof ChangeEventSupport) {
		((ChangeEventSupport)layout).addChangeListener(new ChangeListener() {

			public void stateChanged(ChangeEvent e) {
				brc.compute();
				rectangles = brc.getRectangles();
			}});
	}
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:17,代码来源:BoundingRectanglePaintable.java

示例14: vertexHit

import edu.uci.ics.jung.visualization.RenderContext; //导入依赖的package包/类
protected boolean vertexHit(RenderContext<V,E> rc, Shape s) {
    JComponent vv = rc.getScreenDevice();
    Rectangle deviceRectangle = null;
    if(vv != null) {
        Dimension d = vv.getSize();
        deviceRectangle = new Rectangle(
                0,0,
                d.width,d.height);
    }
    if (deviceRectangle != null) {
    	MutableTransformer vt = rc.getMultiLayerTransformer().getTransformer(Layer.VIEW);
    	if(vt instanceof MutableTransformerDecorator) {
    		vt = ((MutableTransformerDecorator)vt).getDelegate();
    	}
    	return vt.transform(s).intersects(deviceRectangle);
    } else {
    	return false;
    }
}
 
开发者ID:rapidminer,项目名称:rapidminer-5,代码行数:20,代码来源:TreeModelNodeRenderer.java

示例15: init

import edu.uci.ics.jung.visualization.RenderContext; //导入依赖的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


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