• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Context类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: transform

import edu.uci.ics.jung.graph.util.Context; //导入依赖的package包/类
@Override
public Shape transform(Context<Graph<V, E>, E> context) {

	// --- Get the shape for this edge, returning either the --------------
	// --- shared instance or, in the case of self-loop edges, the --------
	// --- SimpleLoop shared instance.
	
	Graph<V,E> graph = context.graph;
   	E e = context.element;
       
       Pair<V> endpoints = graph.getEndpoints(e);
       if(endpoints != null) {
       	boolean isLoop = endpoints.getFirst().equals(endpoints.getSecond());
       	if (isLoop) {
       		return this.getLoop().transform(context);
       	}
       }
       // --- Return the edge shape ------------------------------------------
       if (e instanceof GraphEdge) {
       	return this.getGeneralPath((GraphEdge)e);
       } else {
       	return this.getLine();
       }
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:25,代码来源:EdgeShapePolyline.java


示例2: transform

import edu.uci.ics.jung.graph.util.Context; //导入依赖的package包/类
public Paint transform( Exit exit ) {
    Layout<Room, Exit> layout = vv.getGraphLayout();
    Pair<Room> pair = layout.getGraph().getEndpoints( exit );
    Room begin = pair.getFirst();
    Room end = pair.getSecond();
    Point2D beginPoint = transformer.transform( layout.transform( begin ) );
    Point2D endPoint = transformer.transform( layout.transform( end ) );
    float xFirst = (float) beginPoint.getX();
    float yFirst = (float) beginPoint.getY();
    float xEnd = (float) endPoint.getX();
    float yEnd = (float) endPoint.getY();

    if (selfLoop.evaluate( Context.<Graph<Room, Exit>, Exit>getInstance( layout.getGraph(), exit ) )) {
        xEnd += 50;
        yEnd += 50;
    }

    return new GradientPaint( xFirst, yFirst, getColorFor( begin ), xEnd, yEnd, getColorFor( end ), true );
}
 
开发者ID:lauriholmas,项目名称:batmapper,代码行数:20,代码来源:ExitPaintTransformer.java


示例3: getEdgeShapeTransformer

import edu.uci.ics.jung.graph.util.Context; //导入依赖的package包/类
public Transformer<Context<Graph<Object, JobGraphLink>, JobGraphLink>, Shape> getEdgeShapeTransformer() {
    final String edgeStyle = _userPreferences.getAdditionalProperties().get(USER_PREFERENCES_PROPERTY_EDGE_STYLE);
    final Transformer<Context<Graph<Object, JobGraphLink>, JobGraphLink>, Shape> baseTransformer =
            getBaseEdgeShapeTransformer(edgeStyle);

    return input -> {
        final Shape result = baseTransformer.transform(input);
        final JobGraphLink link = input.element;
        if (isCompoundRequirementLink(link)) {
            // make a double link (actually a wedge, but close
            // enough) to show that there are more than one filter
            // outcome coming from this source
            return new EdgeShape.Wedge<Object, JobGraphLink>(10).transform(input);
        }
        return result;
    };

}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:19,代码来源:JobGraphTransformers.java


示例4: getBaseEdgeShapeTransformer

import edu.uci.ics.jung.graph.util.Context; //导入依赖的package包/类
private Transformer<Context<Graph<Object, JobGraphLink>, JobGraphLink>, Shape> getBaseEdgeShapeTransformer(
        final String edgeStyle) {
    if (edgeStyle == null) {
        return new EdgeShape.QuadCurve<>();
    }
    switch (edgeStyle) {
    case EDGE_STYLE_NAME_STRAIGHT:
        return new EdgeShape.Line<>();
    case EDGE_STYLE_NAME_CURVED:
        return new EdgeShape.QuadCurve<>();
    case EDGE_STYLE_NAME_ORTOGHONAL:
        return new EdgeShape.Orthogonal<>();
    default:
        return new EdgeShape.QuadCurve<>();
    }
}
 
开发者ID:datacleaner,项目名称:DataCleaner,代码行数:17,代码来源:JobGraphTransformers.java


示例5: newEdgeStrokeArrowTransformers

import edu.uci.ics.jung.graph.util.Context; //导入依赖的package包/类
public static <V, E> Pair<Transformer<E, Stroke>, Transformer<Context<Graph<V, E>, E>, Shape>> newEdgeStrokeArrowTransformers(
		int thickness, Integer maxThickness, Map<E, Double> thicknessValues) {
	double denom = getDenominator(thicknessValues);
	int max = maxThickness != null ? maxThickness : thickness + 10;

	Transformer<E, Stroke> strokeTransformer = edge -> {
		Double factor = thicknessValues != null ? thicknessValues.get(edge) : null;
		double width = factor != null ? thickness + (max - thickness) * factor / denom : thickness;

		return new BasicStroke((float) width);
	};
	Transformer<Context<Graph<V, E>, E>, Shape> arrowTransformer = edge -> {
		BasicStroke stroke = (BasicStroke) strokeTransformer.transform(edge.element);

		return ArrowFactory.getNotchedArrow(stroke.getLineWidth() + 8, 2 * stroke.getLineWidth() + 10, 4);
	};

	return new Pair<>(strokeTransformer, arrowTransformer);
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:20,代码来源:JungUtils.java


示例6: getVertices

import edu.uci.ics.jung.graph.util.Context; //导入依赖的package包/类
@Override
public Collection<V> getVertices(Layout<V, E> layout, Shape shape) {
	Set<V> pickedVertices = new HashSet<>();
	Shape iShape = vv.getRenderContext().getMultiLayerTransformer().inverseTransform(Layer.VIEW, shape);

	for (V v : layout.getGraph().getVertices()) {
		if (!vv.getRenderContext().getVertexIncludePredicate()
				.evaluate(Context.<Graph<V, E>, V>getInstance(layout.getGraph(), v))) {
			continue;
		}

		Point2D p = layout.transform(v);

		if (p == null) {
			continue;
		}

		p = vv.getRenderContext().getMultiLayerTransformer().transform(Layer.LAYOUT, p);

		if (iShape.contains(p)) {
			pickedVertices.add(v);
		}
	}

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


示例7: isEdgeRendered

import edu.uci.ics.jung.graph.util.Context; //导入依赖的package包/类
/**
 * Returns <code>true</code> if this edge and its endpoints
 * in this graph are all included in the collections of
 * elements to be rendered, and <code>false</code> otherwise.
 * @param context the edge and graph to be queried
 * @return <code>true</code> if this edge and its endpoints are all
 * included in the collections of elements to be rendered, <code>false</code>
 * otherwise.
 */
protected boolean isEdgeRendered(Context<Graph<V,E>,E> context) {
	Predicate<Context<Graph<V,E>,V>> vertexIncludePredicate =
		vv.getRenderContext().getVertexIncludePredicate();
	Predicate<Context<Graph<V,E>,E>> edgeIncludePredicate =
		vv.getRenderContext().getEdgeIncludePredicate();
	Graph<V,E> g = context.graph;
	E e = context.element;
	boolean edgeTest = edgeIncludePredicate == null || edgeIncludePredicate.evaluate(context);
	Pair<V> endpoints = g.getEndpoints(e);
	V v1 = endpoints.getFirst();
	V v2 = endpoints.getSecond();
	boolean endpointsTest = vertexIncludePredicate == null ||
		(vertexIncludePredicate.evaluate(Context.<Graph<V,E>,V>getInstance(g,v1)) && 
				vertexIncludePredicate.evaluate(Context.<Graph<V,E>,V>getInstance(g,v2)));
	return edgeTest && endpointsTest;
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:26,代码来源:ShapePickSupport.java


示例8: transform

import edu.uci.ics.jung.graph.util.Context; //导入依赖的package包/类
/**
       * Get the shape for this edge, returning either the
       * shared instance or, in the case of self-loop edges, the
       * Loop shared instance.
       */
      @SuppressWarnings("unchecked")
public Shape transform(Context<Graph<V,E>,E> context) {
      	Graph<V,E> graph = context.graph;
      	E e = context.element;
          Pair<V> endpoints = graph.getEndpoints(e);
          if(endpoints != null) {
          	boolean isLoop = endpoints.getFirst().equals(endpoints.getSecond());
          	if (isLoop) {
          		return loop.transform(context);
          	}
          }
          
          int index = 1;
          if(parallelEdgeIndexFunction != null) {
              index = parallelEdgeIndexFunction.getIndex(graph, e);
          }
          float controlY = control_offset_increment + control_offset_increment*index;
          instance.reset();
          instance.moveTo(0.0f, 0.0f);
          instance.lineTo(0.5f, controlY);
          instance.lineTo(1.0f, 1.0f);
          return instance;
      }
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:29,代码来源:EdgeShape.java


示例9: transform

import edu.uci.ics.jung.graph.util.Context; //导入依赖的package包/类
public Paint transform(E e)
{
    Layout<V, E> layout = vv.getGraphLayout();
    Pair<V> p = layout.getGraph().getEndpoints(e);
    V b = p.getFirst();
    V f = p.getSecond();
    Point2D pb = transformer.transform(layout.transform(b));
    Point2D pf = transformer.transform(layout.transform(f));
    float xB = (float) pb.getX();
    float yB = (float) pb.getY();
    float xF = (float) pf.getX();
    float yF = (float) pf.getY();
    if ((layout.getGraph().getEdgeType(e)) == EdgeType.UNDIRECTED)  {
        xF = (xF + xB) / 2;
        yF = (yF + yB) / 2;
    } 
    if(selfLoop.evaluate(Context.<Graph<V,E>,E>getInstance(layout.getGraph(), e))) {
    	yF += 50;
    	xF += 50;
    }

    return new GradientPaint(xB, yB, getColor1(e), xF, yF, getColor2(e), true);
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:24,代码来源:GradientEdgePaintTransformer.java


示例10: paintEdge

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


示例11: labelVertex

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


示例12: setConnectionEdgeShape

import edu.uci.ics.jung.graph.util.Context; //导入依赖的package包/类
/**
 * Set the object which creates Shape objects for edges when using
 * JungConnectionWidget. JUNG's class EdgeShape contains a number of useful
 * implementations.
 *
 * @param transformer An thing which makes line shapes
 */
@SuppressWarnings(value = "unchecked")
public void setConnectionEdgeShape(Transformer<Context<Graph<N, E>, E>, Shape> transformer) {
    Set<Widget> parents = new HashSet<>();
    for (E edge : getEdges()) {
        Widget w = findWidget(edge);
        if (w instanceof JungConnectionWidget) {
            parents.add(w.getParentWidget());
            ((JungConnectionWidget<N, E>) w).setTransformer(transformer);
            w.revalidate();
        }
    }
    if (!parents.isEmpty()) {
        for (Widget connectionLayer : parents) { //typically there is only one
            connectionLayer.revalidate();
            connectionLayer.repaint();
        }
    }
    repaint();
}
 
开发者ID:timboudreau,项目名称:vl-jung,代码行数:27,代码来源:JungScene.java


示例13: paintVertex

import edu.uci.ics.jung.graph.util.Context; //导入依赖的package包/类
@Override
public void paintVertex(RenderContext<V, E> rc, Layout<V, E> layout, V v) {
	Graph<V, E> graph = layout.getGraph();
	if (rc.getVertexIncludePredicate().evaluate(Context.<Graph<V, E>, V> getInstance(graph, v))) {
		paintIconForVertex(rc, v, layout);
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:8,代码来源:TreeModelNodeRenderer.java


示例14: paintVertex

import edu.uci.ics.jung.graph.util.Context; //导入依赖的package包/类
@Override
public void paintVertex(RenderContext<ViwnNode, ViwnEdge> rc,
                        Layout<ViwnNode, ViwnEdge> layout, ViwnNode v) {
    Graph<ViwnNode, ViwnEdge> graph = layout.getGraph();
    if (rc.getVertexIncludePredicate().evaluate(Context.<Graph<ViwnNode, ViwnEdge>, ViwnNode>getInstance(graph, v))) {
        paintVertex(rc, v, layout);
    }
}
 
开发者ID:CLARIN-PL,项目名称:WordnetLoom,代码行数:9,代码来源:ViwnVertexRenderer.java


示例15: evaluate

import edu.uci.ics.jung.graph.util.Context; //导入依赖的package包/类
public boolean evaluate(Context<Graph<V,E>,E> context)
{
	Graph<V,E> graph = context.graph;
	E e = context.element;
    if (graph.getEdgeType(e) == EdgeType.DIRECTED && show_d) {
        return true;
    }
    if (graph.getEdgeType(e) == EdgeType.UNDIRECTED && show_u) {
        return true;
    }
    return false;
}
 
开发者ID:marcvanzee,项目名称:mdp-plan-revision,代码行数:13,代码来源:PluggableRendererDemo.java


示例16: evaluate

import edu.uci.ics.jung.graph.util.Context; //导入依赖的package包/类
@Override
public boolean evaluate(Context<Graph<V, E>, E> context) {
    Graph<V, E> graph = context.graph;
    E edge = context.element;
    if (graph.getEdgeType(edge) == EdgeType.DIRECTED) {
        return true;
    }
    if (graph.getEdgeType(edge) == EdgeType.UNDIRECTED) {
        return true;
    }
    return true;
}
 
开发者ID:datapoet,项目名称:hubminer,代码行数:13,代码来源:ImageHubExplorer.java


示例17: evaluate

import edu.uci.ics.jung.graph.util.Context; //导入依赖的package包/类
@Override
public boolean evaluate(Context<Graph<String, String>, String> context) {
	Graph<String,String> g = context.graph;
	
	return nodes.get(context.element).getThreshold() >= threshold
			&& (g.inDegree(context.element) > 0 || 
			g.outDegree(context.element) > 0);		
}
 
开发者ID:gems-uff,项目名称:dominoes,代码行数:9,代码来源:GraphPane.java


示例18: applyEdgeHighlights

import edu.uci.ics.jung.graph.util.Context; //导入依赖的package包/类
public static <V extends Node> void applyEdgeHighlights(RenderContext<V, Edge<V>> renderContext,
		Collection<Edge<V>> edges, HighlightConditionList edgeHighlightConditions, int edgeThickness,
		Integer edgeMaxThickness) {
	HighlightResult<Edge<V>> result = getResult(edges, edgeHighlightConditions);
	Pair<Transformer<Edge<V>, Stroke>, Transformer<Context<Graph<V, Edge<V>>, Edge<V>>, Shape>> strokeAndArrowTransformers = JungUtils
			.newEdgeStrokeArrowTransformers(edgeThickness, edgeMaxThickness, result.thicknessValues);

	renderContext.setEdgeFillPaintTransformer(JungUtils.newEdgeFillTransformer(renderContext, result.colors));
	renderContext.setEdgeStrokeTransformer(strokeAndArrowTransformers.getFirst());
	renderContext.setEdgeArrowTransformer(strokeAndArrowTransformers.getSecond());
	renderContext.setEdgeLabelTransformer(edge -> result.labels.get(edge));
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:13,代码来源:CanvasUtils.java


示例19: getTransformedEdgeShape

import edu.uci.ics.jung.graph.util.Context; //导入依赖的package包/类
static <V, E> Shape getTransformedEdgeShape(RenderContext<V, E> rc, Layout<V, E> layout, E e) {
	Graph<V, E> graph = layout.getGraph();
	edu.uci.ics.jung.graph.util.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))
			|| !rc.getVertexIncludePredicate().evaluate(Context.<Graph<V, E>, V>getInstance(graph, v1))
			|| !rc.getVertexIncludePredicate().evaluate(Context.<Graph<V, E>, V>getInstance(graph, v2))) {
		return null;
	}

	Point2D p1 = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, layout.transform(v1));
	Point2D p2 = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, layout.transform(v2));
	float x1 = (float) p1.getX();
	float y1 = (float) p1.getY();
	float x2 = (float) p2.getX();
	float y2 = (float) p2.getY();
	Shape edgeShape = rc.getEdgeShapeTransformer().transform(Context.getInstance(graph, e));
	AffineTransform edgeShapeTransform = AffineTransform.getTranslateInstance(x1, y1);

	if (v1.equals(v2)) {
		Rectangle2D bounds = rc.getVertexShapeTransformer().transform(v1).getBounds2D();

		edgeShapeTransform.scale(bounds.getWidth(), bounds.getHeight());
		edgeShapeTransform.translate(0, -edgeShape.getBounds2D().getWidth() / 2);
	} else {
		float dx = x2 - x1;
		float dy = y2 - y1;

		edgeShapeTransform.rotate(Math.atan2(dy, dx));
		edgeShapeTransform.scale(Math.sqrt(dx * dx + dy * dy), 1.0);
	}

	return edgeShapeTransform.createTransformedShape(edgeShape);
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:37,代码来源:JungUtils.java


示例20: transform

import edu.uci.ics.jung.graph.util.Context; //导入依赖的package包/类
@Override
public Shape transform(Context<Graph<V, E>, E> context) {
	Pair<V> endpoints = context.graph.getEndpoints(context.element);
	int index = edgeIndexFunction != null ? edgeIndexFunction.getIndex(context.graph, context.element) : 1;

	if (endpoints != null && endpoints.getFirst().equals(endpoints.getSecond())) {
		float diam = 1.0f + index * fontSize / 40.0f;

		return new Ellipse2D.Float(-diam / 2.0f, -diam / 2.0f, diam, diam);
	} else {
		float controlY = 10.0f + 1.7f * fontSize * index;

		return new QuadCurve2D.Float(0.0f, 0.0f, 0.5f, controlY, 1.0f, 0.0f);
	}
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:16,代码来源:BetterEdgeShapeTransformer.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ZoneRulesProvider类代码示例发布时间:2022-05-21
下一篇:
Java BasicHeader类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap