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


Java GraphicsDecorator.draw方法代码示例

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


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

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

示例3: labelVertex

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

示例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();
    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

示例5: paintIconForVertex

import edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator; //导入方法依赖的package包/类
/**
 * Paint <code>v</code>'s icon on <code>g</code> at <code>(x,y)</code>.
 */
protected void paintIconForVertex(RenderContext<V, E> rc, V v, Layout<V, E> layout) {
	GraphicsDecorator g = rc.getGraphicsContext();
	boolean vertexHit = true;
	// get the shape to be rendered
	Shape shape = rc.getVertexShapeTransformer().transform(v);

	Point2D p = layout.transform(v);
	p = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, p);
	float x = (float) p.getX();
	float y = (float) p.getY();
	// create a transform that translates to the location of
	// the vertex to be rendered
	AffineTransform xform = AffineTransform.getTranslateInstance(x, y);
	// transform the vertex shape with xtransform
	shape = xform.createTransformedShape(shape);

	vertexHit = vertexHit(rc, shape);
	// rc.getViewTransformer().transform(shape).intersects(deviceRectangle);

	if (vertexHit) {
		if (rc.getVertexIconTransformer() != null) {
			Icon icon = rc.getVertexIconTransformer().transform(v);
			if (icon != null) {

				g.draw(icon, rc.getScreenDevice(), shape, (int) x, (int) y);

			} else {
				paintShapeForVertex(rc, v, shape);
			}
		} else {
			paintShapeForVertex(rc, v, shape);
		}
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:38,代码来源:TreeModelNodeRenderer.java

示例6: drawVertexArea

import edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator; //导入方法依赖的package包/类
private void drawVertexArea(ViwnNodeSynset.State state, Shape shape, boolean horiz, GraphicsDecorator g) {
    switch (state) {
        case NOT_EXPANDED:
            g.setColor(Color.blue);
            g.fill(shape);
            break;

        case EXPANDED:
            g.setColor(Color.red);
            g.fill(shape);
            break;

        case SEMI_EXPANDED:
            Rectangle old_clip = g.getClipBounds();
            Rectangle rect = shape.getBounds();

            g.clipRect(rect.x, rect.y, rect.width, rect.height);
            g.setColor(Color.red);
            g.fill(shape);

            if (horiz) {
                g.clipRect(rect.x + rect.width / 2, rect.y,
                        rect.width, rect.height);
            } else {
                g.clipRect(rect.x, rect.y + rect.height / 2,
                        rect.width, rect.height);
            }
            g.setColor(Color.blue);
            g.fill(shape);
            g.setClip(old_clip);
            break;
    }
    g.setColor(Color.black);
    g.draw(shape);
}
 
开发者ID:CLARIN-PL,项目名称:WordnetLoom,代码行数:36,代码来源:ViwnVertexRenderer.java

示例7: renderLexiconMarker

import edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator; //导入方法依赖的package包/类
private void renderLexiconMarker(ViwnNodeSynset node, Point2D.Float pos,
                                 GraphicsDecorator g) {

    Shape lexicon = new Area(new RoundRectangle2D.Float(pos.x - 40, pos.y - 17, 23, 10, 12.5f, 5));
    g.setColor(ViwnNodeSynset.PosBgColors.get(node.getPos()));
    g.fillRoundRect(Math.round(pos.x - 40), Math.round(pos.y - 17), 23, 10, 12, 5);
    g.setColor(Color.black);
    g.draw(lexicon);
    Font smallFont = new Font("Tahoma", Font.BOLD, 6);
    g.setFont(smallFont);
    g.drawString(node.getLexiconLabel(), pos.x - 38, pos.y - 10);

}
 
开发者ID:CLARIN-PL,项目名称:WordnetLoom,代码行数:14,代码来源:ViwnVertexRenderer.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();
    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

示例9: paintIconForVertex

import edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator; //导入方法依赖的package包/类
/**
 * Paint <code>v</code>'s icon on <code>g</code> at <code>(x,y)</code>.
 */
protected void paintIconForVertex(RenderContext<V,E> rc, V v, Layout<V,E> layout) {
    GraphicsDecorator g = rc.getGraphicsContext();
    boolean vertexHit = true;
    // get the shape to be rendered
    Shape shape = rc.getVertexShapeTransformer().transform(v);
    
    Point2D p = layout.transform(v);
    p = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, p);
    float x = (float)p.getX();
    float y = (float)p.getY();
    // create a transform that translates to the location of
    // the vertex to be rendered
    AffineTransform xform = AffineTransform.getTranslateInstance(x,y);
    // transform the vertex shape with xtransform
    shape = xform.createTransformedShape(shape);
    
    vertexHit = vertexHit(rc, shape);
        //rc.getViewTransformer().transform(shape).intersects(deviceRectangle);

    if (vertexHit) {
    	if(rc.getVertexIconTransformer() != null) {
    		Icon icon = rc.getVertexIconTransformer().transform(v);
    		if(icon != null) {
    		
       			g.draw(icon, rc.getScreenDevice(), shape, (int)x, (int)y);

    		} else {
    			paintShapeForVertex(rc, v, shape);
    		}
    	} else {
    		paintShapeForVertex(rc, v, shape);
    	}
    }
}
 
开发者ID:SiLeBAT,项目名称:BfROpenLab,代码行数:38,代码来源:BasicVertexRenderer.java

示例10: paintIconForVertex

import edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator; //导入方法依赖的package包/类
/**
 * Paint <code>v</code>'s icon on <code>g</code> at <code>(x,y)</code>.
 */
protected void paintIconForVertex(RenderContext<V,E> rc, V v, Layout<V,E> layout) {
    GraphicsDecorator g = rc.getGraphicsContext();
    boolean vertexHit = true;
    // get the shape to be rendered
    Shape shape = rc.getVertexShapeTransformer().transform(v);
    
    Point2D p = layout.transform(v);
    p = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, p);
    float x = (float)p.getX();
    float y = (float)p.getY();
    // create a transform that translates to the location of
    // the vertex to be rendered
    AffineTransform xform = AffineTransform.getTranslateInstance(x,y);
    // transform the vertex shape with xtransform
    shape = xform.createTransformedShape(shape);
    
    vertexHit = vertexHit(rc, shape);
        //rc.getViewTransformer().transform(shape).intersects(deviceRectangle);

    if (vertexHit) {
            if(rc.getVertexIconTransformer() != null) {
                    Icon icon = rc.getVertexIconTransformer().transform(v);
                    if(icon != null) {
                    
                               g.draw(icon, rc.getScreenDevice(), shape, (int)x, (int)y);

                    } else {
                            paintShapeForVertex(rc, v, shape);
                    }
            } else {
                    paintShapeForVertex(rc, v, shape);
            }
    }
}
 
开发者ID:rapidminer,项目名称:rapidminer-5,代码行数:38,代码来源:TreeModelNodeRenderer.java

示例11: 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

示例12: 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

示例13: labelVertex

import edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator; //导入方法依赖的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.
 */
@Override
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;
	}
	Point2D pt = layout.transform(v);
	pt = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, pt);

	float x = (float) pt.getX();
	float y = (float) pt.getY();

	Component component = prepareRenderer(rc, rc.getVertexLabelRenderer(), label, rc.getPickedVertexState().isPicked(v),
			v);
	GraphicsDecorator g = rc.getGraphicsContext();
	Dimension d = component.getPreferredSize();
	AffineTransform xform = AffineTransform.getTranslateInstance(x, y);

	Shape shape = rc.getVertexShapeTransformer().transform(v);
	shape = xform.createTransformedShape(shape);
	if (rc.getGraphicsContext() instanceof TransformingGraphics) {
		BidirectionalTransformer transformer = ((TransformingGraphics) rc.getGraphicsContext()).getTransformer();
		if (transformer instanceof ShapeTransformer) {
			ShapeTransformer shapeTransformer = (ShapeTransformer) transformer;
			shape = shapeTransformer.transform(shape);
		}
	}
	Rectangle2D bounds = shape.getBounds2D();

	Point p = null;
	if (position == Position.AUTO) {
		Dimension vvd = rc.getScreenDevice().getSize();
		if (vvd.width == 0 || vvd.height == 0) {
			vvd = rc.getScreenDevice().getPreferredSize();
		}
		p = getAnchorPoint(bounds, d, positioner.getPosition(x, y, vvd));
	} else {
		p = getAnchorPoint(bounds, d, position);
	}

	if (graphCreator.isLeaf((String) v)) {
		p.setLocation(p.x, p.y + LABEL_OFFSET_Y);
	}
	g.draw(component, rc.getRendererPane(), p.x, p.y, d.width, d.height, true);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:52,代码来源:TreeModelNodeLabelRenderer.java

示例14: 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

示例15: 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


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