use of org.cytoscape.view.presentation.customgraphics.PaintedShape in project cytoscape-impl by cytoscape.
the class GraphGraphics method drawCustomGraphicFull.
/**
* Fills an arbitrary graphical shape with high detail.
* <p>
* This method will not work unless clear() has been called at least once
* previously.
*
* @param nodeShape
* the node shape
* @param cg
* the CustomGraphicLayer
* @param xOffset
* in node coordinates, a value to add to the X coordinates of
* the shape's definition.
* @param yOffset
* in node coordinates, a value to add to the Y coordinates of
* the shape's definition.
*/
public final void drawCustomGraphicFull(final CyNetworkView netView, final CyNode node, final Shape nodeShape, final CustomGraphicLayer cg, final float xOffset, final float yOffset) {
if (m_debug) {
checkDispatchThread();
checkCleared();
}
m_g2d.translate(xOffset, yOffset);
if (cg instanceof PaintedShape) {
PaintedShape ps = (PaintedShape) cg;
Shape shape = ps.getShape();
if (ps.getStroke() != null) {
Paint strokePaint = ps.getStrokePaint();
if (strokePaint == null)
strokePaint = Color.BLACK;
m_g2d.setPaint(strokePaint);
m_g2d.setStroke(ps.getStroke());
m_g2d.draw(shape);
}
m_g2d.setPaint(ps.getPaint());
m_g2d.fill(shape);
} else if (cg instanceof Cy2DGraphicLayer) {
Cy2DGraphicLayer layer = (Cy2DGraphicLayer) cg;
final View<CyNode> view = (netView != null && node != null) ? netView.getNodeView(node) : null;
layer.draw(m_g2d, nodeShape, netView, view);
} else if (cg instanceof ImageCustomGraphicLayer) {
Rectangle bounds = cg.getBounds2D().getBounds();
final BufferedImage bImg = ((ImageCustomGraphicLayer) cg).getPaint(bounds).getImage();
m_g2d.drawImage(bImg, bounds.x, bounds.y, bounds.width, bounds.height, null);
} else {
Rectangle2D bounds = nodeShape.getBounds2D();
m_g2d.setPaint(cg.getPaint(bounds));
m_g2d.fill(nodeShape);
}
m_g2d.setTransform(m_currNativeXform);
}
Aggregations