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


Java GraphicsDecorator.getTransform方法代码示例

本文整理汇总了Java中edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator.getTransform方法的典型用法代码示例。如果您正苦于以下问题:Java GraphicsDecorator.getTransform方法的具体用法?Java GraphicsDecorator.getTransform怎么用?Java GraphicsDecorator.getTransform使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator的用法示例。


在下文中一共展示了GraphicsDecorator.getTransform方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: drawFrame

import edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator; //导入方法依赖的package包/类
private void drawFrame(GraphicsDecorator g, Shape shape, Color color, Point2D.Float pos) {
    Shape old_clip = g.getClip();
    AffineTransform old = g.getTransform();
    AffineTransform t = g.getTransform();
    t.concatenate(AffineTransform.getTranslateInstance(pos.x, pos.y));
    g.setTransform(t);
    g.setColor(color);
    Stroke old_stroke = g.getStroke();
    g.setStroke(new BasicStroke(10.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND));
    Area a = new Area(g.getClip());
    a.subtract(new Area(shape));
    g.setClip(a);
    g.draw(shape);
    g.setTransform(old);
    g.setStroke(old_stroke);
    g.setClip(old_clip);
}
 
开发者ID:CLARIN-PL,项目名称:WordnetLoom,代码行数:18,代码来源:ViwnVertexRenderer.java

示例2: labelEdge

import edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator; //导入方法依赖的package包/类
@Override
public void labelEdge(RenderContext<V, E> rc, Layout<V, E> layout, E e, String label) {
	if (Strings.isNullOrEmpty(label)) {
		return;
	}

	Shape edgeShape = JungUtils.getTransformedEdgeShape(rc, layout, e);

	if (edgeShape == null) {
		return;
	}

	Line2D line = JungUtils.getLineInMiddle(edgeShape);

	GraphicsDecorator g = rc.getGraphicsContext();
	Font font = rc.getEdgeFontTransformer().transform(e);
	double width = font.getStringBounds(label, g.getFontRenderContext()).getWidth();
	AffineTransform old = g.getTransform();
	AffineTransform trans = new AffineTransform(old);
	double angle = Math.atan2(line.getY2() - line.getY1(), line.getX2() - line.getX1());

	if (angle < -Math.PI / 2) {
		angle += Math.PI;
	} else if (angle > Math.PI / 2) {
		angle -= Math.PI;
	}

	trans.translate(line.getX1(), line.getY1());
	trans.rotate(angle);
	g.setTransform(trans);
	g.setColor(rc.getPickedEdgeState().isPicked(e) ? Color.GREEN : Color.BLACK);
	g.setFont(rc.getEdgeFontTransformer().transform(e));
	g.drawString(label, (int) (-width / 2), 0);
	g.setTransform(old);
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:36,代码来源:BetterEdgeLabelRenderer.java

示例3: labelEdge

import edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator; //导入方法依赖的package包/类
public void labelEdge(final RenderContext<Node, Edge> rc, final Layout<Node, Edge> layout, final Edge e, final String label) {
    if (label == null || label.length() == 0) {
        return;
    }

    final Graph<Node, Edge> graph = layout.getGraph();
    // don't draw edge if either incident vertex is not drawn
    final Pair<Node> endpoints = graph.getEndpoints(e);
    final Node v1 = endpoints.getFirst();
    final Node v2 = endpoints.getSecond();
    if (!rc.getEdgeIncludePredicate().evaluate(Context.<Graph<Node, Edge>, Edge>getInstance(graph, e))) {
        return;
    }

    if (!rc.getVertexIncludePredicate().evaluate(Context.<Graph<Node, Edge>, Node>getInstance(graph, v1)) ||
        !rc.getVertexIncludePredicate().evaluate(Context.<Graph<Node, Edge>, Node>getInstance(graph, v2))) {
        return;
    }

    final Point2D p1 = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, layout.transform(v1));
    final Point2D p2 = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, layout.transform(v2));

    final GraphicsDecorator g = rc.getGraphicsContext();
    final Component component = prepareRenderer(rc, rc.getEdgeLabelRenderer(), label, rc.getPickedEdgeState().isPicked(e), e);
    final Dimension d = component.getPreferredSize();

    final AffineTransform old = g.getTransform();
    final AffineTransform xform = new AffineTransform(old);
    final FontMetrics fm = g.getFontMetrics();
    int w = fm.stringWidth(e.text);
    double p = Math.max(0, p1.getX() + p2.getX() - w);
    xform.translate(Math.min(layout.getSize().width - w, p / 2), (p1.getY() + p2.getY() - fm.getHeight()) / 2);
    g.setTransform(xform);
    g.draw(component, rc.getRendererPane(), 0, 0, d.width, d.height, true);

    g.setTransform(old);
}
 
开发者ID:apache,项目名称:incubator-batchee,代码行数:38,代码来源:DiagramGenerator.java

示例4: labelEdge

import edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator; //导入方法依赖的package包/类
@Override
public void labelEdge(RenderContext<V, E> rc, Layout<V, E> layout, E e, String label) {
	if (label == null || label.length() == 0) {
		return;
	}

	Graph<V, E> graph = layout.getGraph();
	// 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;
	}

	Point2D p1 = layout.transform(v1);
	Point2D p2 = layout.transform(v2);
	p1 = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, p1);
	p2 = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, p2);
	float x1 = (float) p1.getX();
	float y1 = (float) p1.getY();
	float x2 = (float) p2.getX();
	float y2 = (float) p2.getY();

	GraphicsDecorator g = rc.getGraphicsContext();
	float distX = x2 - x1;
	float distY = y2 - y1;
	double totalLength = Math.sqrt(distX * distX + distY * distY);

	double closeness = rc.getEdgeLabelClosenessTransformer().transform(Context.<Graph<V, E>, E> getInstance(graph, e))
			.doubleValue();

	int posX = (int) (x1 + closeness * distX);
	int posY = (int) (y1 + closeness * distY);

	int xDisplacement = 0;
	int yDisplacement = 0;

	xDisplacement = (int) (rc.getLabelOffset() * (distX / totalLength));
	yDisplacement = (int) (rc.getLabelOffset() * (-distY / totalLength));

	AffineTransform old = g.getTransform();
	AffineTransform xform = new AffineTransform(old);
	xform.translate(posX + xDisplacement, posY + yDisplacement);

	double parallelOffset = 0.0d;
	Component component = prepareRenderer(rc, rc.getEdgeLabelRenderer(), label, rc.getPickedEdgeState().isPicked(e), e);
	Dimension d = component.getPreferredSize();
	xform.translate(-d.width / 2.0d, -(d.height / 2.0d - parallelOffset));
	g.setTransform(xform);
	g.setColor(Colors.WHITE);
	g.draw(component, rc.getRendererPane(), 0, 0, d.width, d.height, true);
	g.setTransform(old);
}
 
开发者ID:rapidminer,项目名称:rapidminer-studio,代码行数:56,代码来源:TreeModelEdgeLabelRenderer.java

示例5: labelEdge

import edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator; //导入方法依赖的package包/类
public void labelEdge(RenderContext<V,E> rc, Layout<V,E> layout, E e, String label) {
	if(label == null || label.length() == 0) return;
	
	Graph<V,E> graph = layout.getGraph();
    // 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.getEdgeIncludePredicate().evaluate(Context.<Graph<V,E>,E>getInstance(graph,e)))
        return;

    if (!rc.getVertexIncludePredicate().evaluate(Context.<Graph<V,E>,V>getInstance(graph,v1)) || 
        !rc.getVertexIncludePredicate().evaluate(Context.<Graph<V,E>,V>getInstance(graph,v2)))
        return;

    Point2D p1 = layout.transform(v1);
    Point2D p2 = layout.transform(v2);
    p1 = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, p1);
    p2 = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, p2);
    float x1 = (float) p1.getX();
    float y1 = (float) p1.getY();
    float x2 = (float) p2.getX();
    float y2 = (float) p2.getY();

    GraphicsDecorator g = rc.getGraphicsContext();
    float distX = x2 - x1;
    float distY = y2 - y1;
    double totalLength = Math.sqrt(distX * distX + distY * distY);

    double closeness = rc.getEdgeLabelClosenessTransformer().transform(Context.<Graph<V,E>,E>getInstance(graph, e)).doubleValue();

    int posX = (int) (x1 + (closeness) * distX);
    int posY = (int) (y1 + (closeness) * distY);

    int xDisplacement = (int) (rc.getLabelOffset() * (distY / totalLength));
    int yDisplacement = (int) (rc.getLabelOffset() * (-distX / totalLength));
    
    Component component = prepareRenderer(rc, rc.getEdgeLabelRenderer(), label, 
            rc.getPickedEdgeState().isPicked(e), e);
    
    Dimension d = component.getPreferredSize();

    Shape edgeShape = rc.getEdgeShapeTransformer().transform(Context.<Graph<V,E>,E>getInstance(graph, e));
    
    double parallelOffset = 1;

    parallelOffset += rc.getParallelEdgeIndexFunction().getIndex(graph, e);

    parallelOffset *= d.height;
    if(edgeShape instanceof Ellipse2D) {
        parallelOffset += edgeShape.getBounds().getHeight();
        parallelOffset = -parallelOffset;
    }
    
    
    AffineTransform old = g.getTransform();
    AffineTransform xform = new AffineTransform(old);
    xform.translate(posX+xDisplacement, posY+yDisplacement);
    double dx = x2 - x1;
    double dy = y2 - y1;
    if(rc.getEdgeLabelRenderer().isRotateEdgeLabels()) {
        double theta = Math.atan2(dy, dx);
        if(dx < 0) {
            theta += Math.PI;
        }
        xform.rotate(theta);
    }
    if(dx < 0) {
        parallelOffset = -parallelOffset;
    }
    
    xform.translate(-d.width/2, -(d.height/2-parallelOffset));
    g.setTransform(xform);
    g.draw(component, rc.getRendererPane(), 0, 0, d.width, d.height, true);

    g.setTransform(old);
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:78,代码来源:BasicEdgeLabelRenderer.java


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