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


Java GraphicsDecorator类代码示例

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


GraphicsDecorator类属于edu.uci.ics.jung.visualization.transform.shape包,在下文中一共展示了GraphicsDecorator类的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: renderSet

import edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator; //导入依赖的package包/类
private void renderSet(
        RenderContext<ViwnNode, ViwnEdge> rc,
        Point2D p,
        ViwnNodeSet node) {
    GraphicsDecorator g = rc.getGraphicsContext();
    String text = "" + node.getSynsets().size();

    Font f = new Font("Sansserif", Font.BOLD, 14);
    Font old_font = g.getFont();
    g.setFont(f);

    FontMetrics metrics = g.getFontMetrics(g.getFont());
    int width = metrics.stringWidth(text);
    int height = metrics.getHeight();

    g.setColor(Color.black);
    g.drawString(text,
            (int) p.getX() - width / 2,
            (int) p.getY());

    width = metrics.stringWidth("...");
    g.drawString("...",
            (int) p.getX() - width / 2,
            (int) p.getY() + 0.25f * height);
    g.setFont(old_font);
}
 
开发者ID:CLARIN-PL,项目名称:WordnetLoom,代码行数:27,代码来源:ViwnVertexRenderer.java

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

示例4: paintVertex

import edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator; //导入依赖的package包/类
@Override public void paintVertex(RenderContext<String, String> rc,
    Layout<String, String> layout, String vertex) {
  GraphicsDecorator graphicsContext = rc.getGraphicsContext();
  Point2D center = layout.transform(vertex);
  Shape shape = null;
  Color color = null;
  if(vertex.equals("Square")) {
    shape = new Rectangle((int)center.getX()-10, (int)center.getY()-10, 20, 20);
    color = new Color(127, 127, 0);
  } else if(vertex.equals("Rectangle")) {
    shape = new Rectangle((int)center.getX()-10, (int)center.getY()-20, 20, 40);
    color = new Color(127, 0, 127);
  } else if(vertex.equals("Circle")) {
    shape = new Ellipse2D.Double(center.getX()-10, center.getY()-10, 20, 20);
    color = new Color(0, 127, 127);
  }
  graphicsContext.setPaint(color);
  graphicsContext.fill(shape);
}
 
开发者ID:marcvanzee,项目名称:mdp-plan-revision,代码行数:20,代码来源:VertexShapes.java

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

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

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

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

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

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

示例11: renderWord

import edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator; //导入依赖的package包/类
private void renderWord(
        RenderContext<ViwnNode, ViwnEdge> rc,
        Point2D p,
        ViwnNodeWord node) {
    GraphicsDecorator g = rc.getGraphicsContext();
    String text = node.getLabel();

    FontMetrics metrics = g.getFontMetrics(g.getFont());
    int width = metrics.stringWidth(text);

    g.setColor(Color.black);
    g.drawString(text,
            (int) p.getX() - width / 2,
            (int) p.getY() + 5);
}
 
开发者ID:CLARIN-PL,项目名称:WordnetLoom,代码行数:16,代码来源:ViwnVertexRenderer.java

示例12: paintIconForVertex

import edu.uci.ics.jung.visualization.transform.shape.GraphicsDecorator; //导入依赖的package包/类
public void paintIconForVertex(RenderContext<V,E> rc, V v, Layout<V,E> layout) {
	
    Point2D p = layout.transform(v);
    p = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, p);
    float x = (float)p.getX();
    float y = (float)p.getY();

    GraphicsDecorator g = rc.getGraphicsContext();
    boolean outlineImages = false;
    Transformer<V,Icon> vertexIconFunction = rc.getVertexIconTransformer();
    
    if(vertexIconFunction instanceof DemoVertexIconTransformer) {
        outlineImages = ((DemoVertexIconTransformer<V>)vertexIconFunction).isOutlineImages();
    }
    Icon icon = vertexIconFunction.transform(v);
    if(icon == null || outlineImages) {
        
        Shape s = AffineTransform.getTranslateInstance(x,y).
            createTransformedShape(rc.getVertexShapeTransformer().transform(v));
        paintShapeForVertex(rc, v, s);
    }
    if(icon != null) {
        int xLoc = (int) (x - icon.getIconWidth()/2);
        int yLoc = (int) (y - icon.getIconHeight()/2);
        icon.paintIcon(rc.getScreenDevice(), g.getDelegate(), xLoc, yLoc);
    }
}
 
开发者ID:marcvanzee,项目名称:mdp-plan-revision,代码行数:28,代码来源:VertexImageShaperDemo.java

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

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

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


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