本文整理了Java中edu.uci.ics.jung.visualization.RenderContext.getGraphicsContext
方法的一些代码示例,展示了RenderContext.getGraphicsContext
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RenderContext.getGraphicsContext
方法的具体详情如下:
包路径:edu.uci.ics.jung.visualization.RenderContext
类名称:RenderContext
方法名:getGraphicsContext
暂无
代码示例来源:origin: jrtom/jung
@Override
public void paintIconForNode(
RenderContext
Point p = model.getLayoutModel().apply(v);
Point2D p2d =
renderContext
.getMultiLayerTransformer()
.transform(Layer.LAYOUT, new Point2D.Double(p.x, p.y));
float x = (float) p2d.getX();
float y = (float) p2d.getY();
GraphicsDecorator g = renderContext.getGraphicsContext();
boolean outlineImages = false;
Function
if (nodeIconFunction instanceof DemoNodeIconTransformer) {
outlineImages = ((DemoNodeIconTransformer
}
Icon icon = nodeIconFunction.apply(v);
if (icon == null || outlineImages) {
Shape s =
AffineTransform.getTranslateInstance(x, y)
.createTransformedShape(renderContext.getNodeShapeFunction().apply(v));
paintShapeForNode(renderContext, model, v, s);
}
if (icon != null) {
int xLoc = (int) (x - icon.getIconWidth() / 2);
int yLoc = (int) (y - icon.getIconHeight() / 2);
icon.paintIcon(renderContext.getScreenDevice(), g.getDelegate(), xLoc, yLoc);
}
}
}
代码示例来源:origin: net.sf.jung/jung-visualization
/**
* Paint v
's icon on g
at (x,y)
.
*/
protected void paintIconForVertex(RenderContext
GraphicsDecorator g = rc.getGraphicsContext();
boolean vertexHit = true;
int[] coords = new int[2];
Shape shape = vertexShapeMap.get(v);
if(shape == null || dirtyVertices.contains(v)) {
shape = prepareFinalVertexShape(rc, v, layout, coords);
vertexShapeMap.put(v, shape);
dirtyVertices.remove(v);
}
vertexHit = vertexHit(rc, shape);
if (vertexHit) {
if(rc.getVertexIconTransformer() != null) {
Icon icon = rc.getVertexIconTransformer().apply(v);
if(icon != null) {
g.draw(icon, rc.getScreenDevice(), shape, coords[0], coords[1]);
} else {
paintShapeForVertex(rc, v, shape);
}
} else {
paintShapeForVertex(rc, v, shape);
}
}
}
代码示例来源:origin: net.sf.jung/jung-visualization
/**
* Labels the specified vertex with the specified label.
* Uses the font specified by this instance's
* VertexFontFunction
. (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
Graph
if (rc.getVertexIncludePredicate().apply(Context.
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.apply(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);
}
代码示例来源:origin: jrtom/jung
@Override
public void paintEdge(
RenderContext
GraphicsDecorator g2d = renderContext.getGraphicsContext();
if (!renderContext.getEdgeIncludePredicate().test(e)) {
return;
}
// don't draw edge if either incident node is not drawn
EndpointPair
N u = endpoints.nodeU();
N v = endpoints.nodeV();
Predicate
if (!nodeIncludePredicate.test(u) || !nodeIncludePredicate.test(v)) {
return;
}
Stroke new_stroke = renderContext.edgeStrokeFunction().apply(e);
Stroke old_stroke = g2d.getStroke();
if (new_stroke != null) {
g2d.setStroke(new_stroke);
}
drawSimpleEdge(renderContext, visualizationModel, e);
// restore paint and stroke
if (new_stroke != null) {
g2d.setStroke(old_stroke);
}
}
代码示例来源:origin: jrtom/jung
/**
* Paint v
's icon on g
at (x,y)
.
*
* @param v the node to be painted
*/
protected void paintIconForNode(
RenderContext
GraphicsDecorator g = renderContext.getGraphicsContext();
int[] coords = new int[2];
Shape shape = prepareFinalNodeShape(renderContext, visualizationModel, v, coords);
if (renderContext.getNodeIconFunction() != null) {
Icon icon = renderContext.getNodeIconFunction().apply(v);
if (icon != null) {
g.draw(icon, renderContext.getScreenDevice(), shape, coords[0], coords[1]);
} else {
paintShapeForNode(renderContext, visualizationModel, v, shape);
}
} else {
paintShapeForNode(renderContext, visualizationModel, v, shape);
}
}
代码示例来源:origin: net.sf.jung/jung-visualization
public void paintEdge(RenderContext
GraphicsDecorator g2d = rc.getGraphicsContext();
Graph
if (!rc.getEdgeIncludePredicate().apply(Context.
return;
// don't draw edge if either incident vertex is not drawn
Pair
V v1 = endpoints.getFirst();
V v2 = endpoints.getSecond();
if (!rc.getVertexIncludePredicate().apply(Context.
!rc.getVertexIncludePredicate().apply(Context.
return;
Stroke new_stroke = rc.getEdgeStrokeTransformer().apply(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);
}
代码示例来源:origin: net.sf.jung/jung-visualization
protected void paintShapeForVertex(RenderContext
GraphicsDecorator g = rc.getGraphicsContext();
Paint oldPaint = g.getPaint();
Paint fillPaint = rc.getVertexFillPaintTransformer().apply(v);
if(fillPaint != null) {
g.setPaint(fillPaint);
g.fill(shape);
g.setPaint(oldPaint);
}
Paint drawPaint = rc.getVertexDrawPaintTransformer().apply(v);
if(drawPaint != null) {
g.setPaint(drawPaint);
Stroke oldStroke = g.getStroke();
Stroke stroke = rc.getVertexStrokeTransformer().apply(v);
if(stroke != null) {
g.setStroke(stroke);
}
g.draw(shape);
g.setPaint(oldPaint);
g.setStroke(oldStroke);
}
}
}
代码示例来源:origin: com.github.fburato/highwheel-core
public void labelVertex(final RenderContext
final Layout
final String label) {
final Graph
if (rc.getVertexIncludePredicate().evaluate(
Context.
graph, v)) == false) {
return;
}
final GraphicsDecorator g = rc.getGraphicsContext();
final Component compOnent= prepareRenderer(rc,
rc.getVertexLabelRenderer(), label,
rc.getPickedVertexState().isPicked(v), v);
final Dimension d = component.getPreferredSize();
final int h_offset = -d.width / 2;
final int v_offset = -d.height / 2;
Point2D p = layout.transform(v);
p = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, p);
final int x = (int) p.getX();
final int y = (int) p.getY();
g.draw(component, rc.getRendererPane(), x + h_offset, y + v_offset,
d.width, d.height, true);
}
代码示例来源:origin: org.pitest/highwheel-core
public void labelVertex(final RenderContext
final Layout
final String label) {
final Graph
if (rc.getVertexIncludePredicate().evaluate(
Context.
graph, v)) == false) {
return;
}
final GraphicsDecorator g = rc.getGraphicsContext();
final Component compOnent= prepareRenderer(rc,
rc.getVertexLabelRenderer(), label,
rc.getPickedVertexState().isPicked(v), v);
final Dimension d = component.getPreferredSize();
final int h_offset = -d.width / 2;
final int v_offset = -d.height / 2;
Point2D p = layout.transform(v);
p = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, p);
final int x = (int) p.getX();
final int y = (int) p.getY();
g.draw(component, rc.getRendererPane(), x + h_offset, y + v_offset,
d.width, d.height, true);
}
代码示例来源:origin: org.apache.batchee/batchee-maven-plugin
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();
代码示例来源:origin: jrtom/jung
public MagnifyImageLensSupport(
VisualizationViewer
LensTransformer lensTransformer,
ModalGraphMouse lensGraphMouse) {
super(vv, lensGraphMouse);
this.renderCOntext= vv.getRenderContext();
this.pickSupport = renderContext.getPickSupport();
this.renderer = vv.getRenderer();
this.transformingRenderer = new BasicRenderer<>();
this.savedGraphicsDecorator = renderContext.getGraphicsContext();
this.lensTransformer = lensTransformer;
Dimension d = vv.getSize();
if (d.width == 0 || d.height == 0) {
d = vv.getPreferredSize();
}
this.lensGraphicsDecorator = new MagnifyIconGraphics(lensTransformer);
}
代码示例来源:origin: net.sf.jung/jung-visualization
/**
* Paint v
's icon on g
at (x,y)
.
*
* @param rc the render context used for rendering the vertex
* @param v the vertex to be painted
* @param layout the layout algorithm that provides coordinates for the vertex
*/
protected void paintIconForVertex(RenderContext
GraphicsDecorator g = rc.getGraphicsContext();
boolean vertexHit = true;
int[] coords = new int[2];
Shape shape = prepareFinalVertexShape(rc, v, layout, coords);
vertexHit = vertexHit(rc, shape);
if (vertexHit) {
if(rc.getVertexIconTransformer() != null) {
Icon icon = rc.getVertexIconTransformer().apply(v);
if(icon != null) {
g.draw(icon, rc.getScreenDevice(), shape, coords[0], coords[1]);
} else {
paintShapeForVertex(rc, v, shape);
}
} else {
paintShapeForVertex(rc, v, shape);
}
}
}
代码示例来源:origin: hcoles/highwheel
public void labelVertex(final RenderContext
final Layout
final String label) {
final Graph
if (rc.getVertexIncludePredicate().evaluate(
Context.
graph, v)) == false) {
return;
}
final GraphicsDecorator g = rc.getGraphicsContext();
final Component compOnent= prepareRenderer(rc,
rc.getVertexLabelRenderer(), label,
rc.getPickedVertexState().isPicked(v), v);
final Dimension d = component.getPreferredSize();
final int h_offset = -d.width / 2;
final int v_offset = -d.height / 2;
Point2D p = layout.transform(v);
p = rc.getMultiLayerTransformer().transform(Layer.LAYOUT, p);
final int x = (int) p.getX();
final int y = (int) p.getY();
g.draw(component, rc.getRendererPane(), x + h_offset, y + v_offset,
d.width, d.height, true);
}
代码示例来源:origin: jrtom/jung
public ViewLensSupport(
VisualizationViewer
LensTransformer lensTransformer,
ModalGraphMouse lensGraphMouse) {
super(vv, lensGraphMouse);
this.renderCOntext= vv.getRenderContext();
this.pickSupport = renderContext.getPickSupport();
this.savedGraphicsDecorator = renderContext.getGraphicsContext();
this.lensTransformer = lensTransformer;
LayoutModel layoutModel = vv.getModel().getLayoutModel();
Dimension d = new Dimension(layoutModel.getWidth(), layoutModel.getHeight());
lensTransformer.getLens().setSize(d);
this.lensGraphicsDecorator = new TransformingFlatnessGraphics(lensTransformer);
this.savedEdgeRenderer = vv.getRenderer().getEdgeRenderer();
}
代码示例来源:origin: jrtom/jung
protected void paintShapeForNode(
RenderContext
VisualizationModel
N v,
Shape shape) {
GraphicsDecorator g = renderContext.getGraphicsContext();
Paint oldPaint = g.getPaint();
Paint fillPaint = renderContext.getNodeFillPaintFunction().apply(v);
if (fillPaint != null) {
g.setPaint(fillPaint);
g.fill(shape);
g.setPaint(oldPaint);
}
Paint drawPaint = renderContext.getNodeDrawPaintFunction().apply(v);
if (drawPaint != null) {
g.setPaint(drawPaint);
Stroke oldStroke = g.getStroke();
Stroke stroke = renderContext.getNodeStrokeFunction().apply(v);
if (stroke != null) {
g.setStroke(stroke);
}
g.draw(shape);
g.setPaint(oldPaint);
g.setStroke(oldStroke);
}
}
}
代码示例来源:origin: net.sf.jung/jung-jai
public PerspectiveViewTransformSupport(VisualizationViewer
super(vv);
this.renderer = vv.getRenderer();
this.renderCOntext= vv.getRenderContext();
this.pickSupport = renderContext.getPickSupport();
this.perspectiveTransformer =
new PerspectiveShapeTransformer(new PerspectiveTransform(),
vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW));
this.savedGraphicsDecorator = renderContext.getGraphicsContext();
this.lensGraphicsDecorator = new TransformingGraphics(perspectiveTransformer);
}
代码示例来源:origin: net.sf.jung/jung-visualization
public ViewLensSupport(VisualizationViewer
LensTransformer lensTransformer,
ModalGraphMouse lensGraphMouse) {
super(vv, lensGraphMouse);
this.renderCOntext= vv.getRenderContext();
this.pickSupport = renderContext.getPickSupport();
this.savedGraphicsDecorator = renderContext.getGraphicsContext();
this.lensTransformer = lensTransformer;
Dimension d = vv.getSize();
lensTransformer.setViewRadius(d.width/5);
this.lensGraphicsDecorator = new TransformingFlatnessGraphics(lensTransformer);
this.savedEdgeRenderer = vv.getRenderer().getEdgeRenderer();
this.reshapingEdgeRenderer = new ReshapingEdgeRenderer
this.reshapingEdgeRenderer.setEdgeArrowRenderingSupport(savedEdgeRenderer.getEdgeArrowRenderingSupport());
}
public void activate() {
代码示例来源:origin: net.sf.jung/jung-jai
/**
* @param vv the VisualizationViewer to work on
*/
public PerspectiveImageLensSupport(VisualizationViewer
super(vv);
this.renderCOntext= vv.getRenderContext();
this.pickSupport = renderContext.getPickSupport();
this.renderer = vv.getRenderer();
this.transformingRenderer = new BasicRenderer
this.perspectiveTransformer =
new PerspectiveShapeTransformer(new PerspectiveTransform(), vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW));
this.transformingRenderer.setVertexRenderer(new TransformingImageVertexIconRenderer
this.lensGraphicsDecorator = new TransformingGraphics(perspectiveTransformer);
this.savedGraphicsDecorator = renderContext.getGraphicsContext();
this.renderer = vv.getRenderer();
}
代码示例来源:origin: net.sf.jung/jung-visualization
public MagnifyImageLensSupport(VisualizationViewer
ModalGraphMouse lensGraphMouse) {
super(vv, lensGraphMouse);
this.renderCOntext= vv.getRenderContext();
this.pickSupport = renderContext.getPickSupport();
this.renderer = vv.getRenderer();
this.transformingRenderer = new BasicRenderer
this.savedGraphicsDecorator = renderContext.getGraphicsContext();
this.lensTransformer = lensTransformer;
this.savedEdgeRenderer = vv.getRenderer().getEdgeRenderer();
this.reshapingEdgeRenderer = new ReshapingEdgeRenderer
this.reshapingEdgeRenderer.setEdgeArrowRenderingSupport(savedEdgeRenderer.getEdgeArrowRenderingSupport());
Dimension d = vv.getSize();
if(d.width == 0 || d.height == 0) {
d = vv.getPreferredSize();
}
lensTransformer.setViewRadius(d.width/5);
this.lensGraphicsDecorator = new MagnifyIconGraphics(lensTransformer);
}
代码示例来源:origin: net.sf.jung/jung-jai
/**
* create the base class, setting common members and creating
* a custom GraphMouse
* @param vv the VisualizationViewer to work on
*/
public HyperbolicImageLensSupport(VisualizationViewer
ModalGraphMouse lensGraphMouse) {
super(vv, lensGraphMouse);
this.renderCOntext= vv.getRenderContext();
this.pickSupport = renderContext.getPickSupport();
this.renderer = vv.getRenderer();
this.transformingRenderer = new BasicRenderer
this.transformingRenderer.setVertexRenderer(new TransformingImageVertexIconRenderer
this.savedGraphicsDecorator = renderContext.getGraphicsContext();
this.lensTransformer = lensTransformer;
this.savedEdgeRenderer = vv.getRenderer().getEdgeRenderer();
this.reshapingEdgeRenderer = new ReshapingEdgeRenderer
this.reshapingEdgeRenderer.setEdgeArrowRenderingSupport(savedEdgeRenderer.getEdgeArrowRenderingSupport());
Dimension d = vv.getSize();
// if(d.width == 0 || d.height == 0) {
// d = vv.getPreferredSize();
// }
lensTransformer.setViewRadius(d.width/5);
this.lensGraphicsDecorator = new TransformingFlatnessGraphics(lensTransformer);
}