Search in sources :

Example 1 with Cy2DGraphicLayer

use of org.cytoscape.view.presentation.customgraphics.Cy2DGraphicLayer 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);
}
Also used : PaintedShape(org.cytoscape.view.presentation.customgraphics.PaintedShape) DiamondNodeShape(org.cytoscape.graph.render.immed.nodeshape.DiamondNodeShape) RoundedRectangleNodeShape(org.cytoscape.graph.render.immed.nodeshape.RoundedRectangleNodeShape) Shape(java.awt.Shape) HexagonNodeShape(org.cytoscape.graph.render.immed.nodeshape.HexagonNodeShape) NodeShape(org.cytoscape.graph.render.immed.nodeshape.NodeShape) PaintedShape(org.cytoscape.view.presentation.customgraphics.PaintedShape) LegacyCustomNodeShape(org.cytoscape.graph.render.immed.nodeshape.LegacyCustomNodeShape) VeeNodeShape(org.cytoscape.graph.render.immed.nodeshape.VeeNodeShape) ParallelogramNodeShape(org.cytoscape.graph.render.immed.nodeshape.ParallelogramNodeShape) EllipseNodeShape(org.cytoscape.graph.render.immed.nodeshape.EllipseNodeShape) OctagonNodeShape(org.cytoscape.graph.render.immed.nodeshape.OctagonNodeShape) ArrowShape(org.cytoscape.view.presentation.property.values.ArrowShape) RectangleNodeShape(org.cytoscape.graph.render.immed.nodeshape.RectangleNodeShape) TriangleNodeShape(org.cytoscape.graph.render.immed.nodeshape.TriangleNodeShape) Cy2DGraphicLayer(org.cytoscape.view.presentation.customgraphics.Cy2DGraphicLayer) ImageCustomGraphicLayer(org.cytoscape.view.presentation.customgraphics.ImageCustomGraphicLayer) Rectangle(java.awt.Rectangle) Rectangle2D(java.awt.geom.Rectangle2D) Paint(java.awt.Paint) TexturePaint(java.awt.TexturePaint) View(org.cytoscape.view.model.View) CyNetworkView(org.cytoscape.view.model.CyNetworkView) BufferedImage(java.awt.image.BufferedImage)

Aggregations

Paint (java.awt.Paint)1 Rectangle (java.awt.Rectangle)1 Shape (java.awt.Shape)1 TexturePaint (java.awt.TexturePaint)1 Rectangle2D (java.awt.geom.Rectangle2D)1 BufferedImage (java.awt.image.BufferedImage)1 DiamondNodeShape (org.cytoscape.graph.render.immed.nodeshape.DiamondNodeShape)1 EllipseNodeShape (org.cytoscape.graph.render.immed.nodeshape.EllipseNodeShape)1 HexagonNodeShape (org.cytoscape.graph.render.immed.nodeshape.HexagonNodeShape)1 LegacyCustomNodeShape (org.cytoscape.graph.render.immed.nodeshape.LegacyCustomNodeShape)1 NodeShape (org.cytoscape.graph.render.immed.nodeshape.NodeShape)1 OctagonNodeShape (org.cytoscape.graph.render.immed.nodeshape.OctagonNodeShape)1 ParallelogramNodeShape (org.cytoscape.graph.render.immed.nodeshape.ParallelogramNodeShape)1 RectangleNodeShape (org.cytoscape.graph.render.immed.nodeshape.RectangleNodeShape)1 RoundedRectangleNodeShape (org.cytoscape.graph.render.immed.nodeshape.RoundedRectangleNodeShape)1 TriangleNodeShape (org.cytoscape.graph.render.immed.nodeshape.TriangleNodeShape)1 VeeNodeShape (org.cytoscape.graph.render.immed.nodeshape.VeeNodeShape)1 CyNetworkView (org.cytoscape.view.model.CyNetworkView)1 View (org.cytoscape.view.model.View)1 Cy2DGraphicLayer (org.cytoscape.view.presentation.customgraphics.Cy2DGraphicLayer)1