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


Java Context类代码示例

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


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


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