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


Java GraphicsDecorator.setStroke方法代码示例

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


在下文中一共展示了GraphicsDecorator.setStroke方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: paintEdge

import edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator; //导入方法依赖的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

示例3: paintShapeForVertex

import edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator; //导入方法依赖的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

示例4: paintShapeForVertex

import edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator; //导入方法依赖的package包/类
protected void paintShapeForVertex(RenderContext<V,E> rc, V v, Shape shape) {
    GraphicsDecorator g = rc.getGraphicsContext();
    Paint oldPaint = g.getPaint();
    Rectangle r = shape.getBounds();
    float y2 = (float)r.getMaxY();
    if(cyclic) {
    	y2 = (float)(r.getMinY()+r.getHeight()/2);
    }
    
    Paint fillPaint = null;
    if(pickedState != null && pickedState.isPicked(v)) {
    	fillPaint = new GradientPaint((float)r.getMinX(), (float)r.getMinY(), pickedColorOne,
        		(float)r.getMinX(), y2, pickedColorTwo, cyclic);
    } else {
    	fillPaint = new GradientPaint((float)r.getMinX(), (float)r.getMinY(), colorOne,
    		(float)r.getMinX(), y2, colorTwo, cyclic);
    }
    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,代码行数:36,代码来源:GradientVertexRenderer.java

示例5: paintShapeForVertex

import edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator; //导入方法依赖的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);
	}

	// leaf: draw frequency colors
	if (graphCreator.isLeaf((String) v)) {
		Tree tree = graphCreator.getTree((String) v);
		Map<String, Integer> countMap = tree.getCounterMap();
		int numberOfLabels = countMap.size();
		int frequencySum = tree.getFrequencySum();

		double height = tree.getFrequencySum() / (double) maxLeafSize
				* (FREQUENCY_BAR_MAX_HEIGHT - FREQUENCY_BAR_MIN_HEIGHT) + FREQUENCY_BAR_MIN_HEIGHT;
		double width = shape.getBounds().getWidth() - 2 * FREQUENCY_BAR_OFFSET_X - 1;
		double xPos = shape.getBounds().getX() + FREQUENCY_BAR_OFFSET_X;
		double yPos = shape.getBounds().getY() + shape.getBounds().getHeight() - FREQUENCY_BAR_OFFSET_Y - height;
		ColorProvider colorProvider = new ColorProvider();
		for (String labelValue : countMap.keySet()) {
			int count = tree.getCount(labelValue);
			double currentWidth = ((double) count / (double) frequencySum) * width;
			Rectangle2D.Double frequencyRect = new Rectangle2D.Double(xPos, yPos, currentWidth, height);
			Attribute label = model.getTrainingHeader().getAttributes().getLabel();
               if (label.isNominal()) {
               	int counter = label.getMapping().mapString(labelValue);
				g.setColor(colorProvider.getPointColor((double) counter / (double) (numberOfLabels - 1)));
				g.fill(frequencyRect);
				g.setColor(Color.BLACK);
				xPos += currentWidth;
			}
		}
		g.setColor(Color.BLACK);
		g.draw(new Rectangle2D.Double(shape.getBounds().getX() + FREQUENCY_BAR_OFFSET_X, yPos, width, height));

		g.setPaint(oldPaint);
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:55,代码来源:TreeModelNodeRenderer.java

示例6: paintShapeForVertex

import edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator; //导入方法依赖的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);

	}

	// leaf: draw frequency colors if nominal
	if (graphCreator.isLeaf((String) v)) {
		Attribute label = model.getTrainingHeader().getAttributes().getLabel();
		if (label.isNominal()) {
			Tree tree = graphCreator.getTree((String) v);
			Map<String, Integer> countMap = tree.getCounterMap();
			int numberOfLabels = countMap.size();
			int frequencySum = tree.getFrequencySum();

			double height = tree.getFrequencySum() / (double) maxLeafSize
					* (FREQUENCY_BAR_MAX_HEIGHT - FREQUENCY_BAR_MIN_HEIGHT) + FREQUENCY_BAR_MIN_HEIGHT;
			double width = shape.getBounds().getWidth() - 2 * FREQUENCY_BAR_OFFSET_X - 1;
			double xPos = shape.getBounds().getX() + FREQUENCY_BAR_OFFSET_X;
			double yPos = shape.getBounds().getY() + shape.getBounds().getHeight() - FREQUENCY_BAR_OFFSET_Y - height;
			ColorProvider colorProvider = new ColorProvider();
			for (String labelValue : countMap.keySet()) {
				int count = tree.getCount(labelValue);
				double currentWidth = (double) count / (double) frequencySum * width;
				Rectangle2D.Double frequencyRect = new Rectangle2D.Double(xPos, yPos, currentWidth, height);
				int counter = label.getMapping().mapString(labelValue);
				g.setColor(colorProvider.getPointColor((double) counter / (double) (numberOfLabels - 1)));
				g.fill(frequencyRect);

				g.setColor(Color.BLACK);
				xPos += currentWidth;
			}

			g.setPaint(oldPaint);
		}
	}
}
 
开发者ID:rapidminer,项目名称:rapidminer-studio,代码行数:55,代码来源:TreeModelNodeRenderer.java

示例7: paintEdge

import edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public void paintEdge(RenderContext<V, E> rc, Layout<V, E> layout, E e) {
	GraphicsDecorator g = rc.getGraphicsContext();
	Graph<V, E> graph = layout.getGraph();

	if (!rc.getEdgeIncludePredicate().evaluate(Context.<Graph<V, E>, E>getInstance(graph, e))) {
		return;
	}

	Pair<V> endpoints = graph.getEndpoints(e);

	if (!rc.getVertexIncludePredicate().evaluate(Context.<Graph<V, E>, V>getInstance(graph, endpoints.getFirst()))
			|| !rc.getVertexIncludePredicate()
					.evaluate(Context.<Graph<V, E>, V>getInstance(graph, endpoints.getSecond()))) {
		return;
	}

	Point2D p1 = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, layout.transform(endpoints.getFirst()));
	Point2D p2 = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, layout.transform(endpoints.getSecond()));
	Shape edgeShape = rc.getEdgeShapeTransformer().transform(Context.<Graph<V, E>, E>getInstance(graph, e));
	Rectangle deviceRectangle = new Rectangle(rc.getScreenDevice().getSize());
	AffineTransform edgeTransform = AffineTransform.getTranslateInstance(p1.getX(), p1.getY());

	if (endpoints.getFirst().equals(endpoints.getSecond())) {
		Rectangle2D bounds = rc.getVertexShapeTransformer().transform(endpoints.getFirst()).getBounds2D();

		edgeTransform.scale(bounds.getWidth(), bounds.getHeight());
		edgeTransform.translate(0, -edgeShape.getBounds2D().getWidth() / 2);
	} else {
		double dx = p2.getX() - p1.getX();
		double dy = p2.getY() - p1.getY();

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

	edgeShape = edgeTransform.createTransformedShape(edgeShape);

	if (rc.getMultiLayerTransformer().getTransformer(Layer.VIEW).transform(edgeShape).intersects(deviceRectangle)) {
		Paint oldPaint = g.getPaint();
		Stroke oldStroke = g.getStroke();

		BasicStroke stroke = (BasicStroke) rc.getEdgeStrokeTransformer().transform(e);
		Paint drawPaint = rc.getEdgeDrawPaintTransformer().transform(e);

		if (drawPaint != null) {
			g.setStroke(new BasicStroke(stroke.getLineWidth() + 4, stroke.getEndCap(), stroke.getLineJoin(),
					stroke.getMiterLimit(), stroke.getDashArray(), stroke.getDashPhase()));
			g.setPaint(drawPaint);
			g.draw(edgeShape);
		}

		g.setStroke(stroke);
		g.setPaint(rc.getEdgeFillPaintTransformer().transform(e));
		g.draw(edgeShape);

		if (rc.getEdgeArrowPredicate().evaluate(Context.<Graph<V, E>, E>getInstance(graph, e))) {
			AffineTransform destVertexTransform = AffineTransform.getTranslateInstance(p2.getX(), p2.getY());
			Shape destVertexShape = destVertexTransform.createTransformedShape(
					rc.getVertexShapeTransformer().transform(graph.getEndpoints(e).getSecond()));

			if (rc.getMultiLayerTransformer().getTransformer(Layer.VIEW).transform(destVertexShape)
					.intersects(deviceRectangle)) {
				AffineTransform arrowTransform = edgeArrowRenderingSupport.getArrowTransform(rc, edgeShape,
						destVertexShape);
				Shape arrow = arrowTransform.createTransformedShape(
						rc.getEdgeArrowTransformer().transform(Context.<Graph<V, E>, E>getInstance(graph, e)));

				g.setStroke(rc.getEdgeArrowStrokeTransformer().transform(e));
				g.setPaint(rc.getArrowFillPaintTransformer().transform(e));
				g.fill(arrow);
				g.setPaint(rc.getArrowDrawPaintTransformer().transform(e));
				g.draw(arrow);
			}
		}

		g.setPaint(oldPaint);
		g.setStroke(oldStroke);
	}
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:82,代码来源:BetterEdgeRenderer.java

示例8: paintShapeForVertex

import edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator; //导入方法依赖的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);
    }
    
    // leaf: draw frequency colors
    if (graphCreator.isLeaf((String)v)) {
        Tree tree = graphCreator.getTree((String)v);
        Map<String,Integer> countMap = tree.getCounterMap();
        int numberOfLabels = countMap.size();
        int frequencySum = tree.getFrequencySum();
        
        double height = tree.getFrequencySum() / (double)maxLeafSize * (FREQUENCY_BAR_MAX_HEIGHT - FREQUENCY_BAR_MIN_HEIGHT) + FREQUENCY_BAR_MIN_HEIGHT;
        double width = shape.getBounds().getWidth() - 2 * FREQUENCY_BAR_OFFSET_X - 1;
        double xPos = shape.getBounds().getX() + FREQUENCY_BAR_OFFSET_X;
        double yPos = shape.getBounds().getY() + shape.getBounds().getHeight() - FREQUENCY_BAR_OFFSET_Y - height;
        ColorProvider colorProvider = new ColorProvider();
        for (String labelValue: countMap.keySet()) {
        	int count = tree.getCount(labelValue);
            double currentWidth = ((double)count / (double)frequencySum) * width;
            Rectangle2D.Double frequencyRect = 
                new Rectangle2D.Double(xPos, 
                                       yPos,
                                       currentWidth,
                                       height);
            int counter = model.getTrainingHeader().getAttributes().getLabel().getMapping().mapString(labelValue);
            g.setColor(colorProvider.getPointColor((double) counter / (double) (numberOfLabels - 1)));
            g.fill(frequencyRect);
            g.setColor(Color.BLACK);
            xPos += currentWidth;
        }
        g.setColor(Color.BLACK);
        g.draw(new Rectangle2D.Double(shape.getBounds().getX() + FREQUENCY_BAR_OFFSET_X, yPos, width, height));

        g.setPaint(oldPaint);
    }
}
 
开发者ID:rapidminer,项目名称:rapidminer-5,代码行数:55,代码来源:TreeModelNodeRenderer.java


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