Search in sources :

Example 81 with Stroke

use of java.awt.Stroke in project knime-core by knime.

the class DendrogramDrawingPane method paintContent.

/**
 * Paints a dendrogram such that the leaf nodes are painted at the border
 * (with distance 0) and on the nominal x axis and the cluster nodes are
 * drawn with increasing distance to the top (that is the distance is
 * plotted on the y axis). Each cluster node has exactly two subnodes,
 * a horizontal line on the height of the distance between these two
 * subnodes and two vertical lines from the end points of the
 * horizontal line to the subnodes.
 *
 * <p>
 * Hilited (sub)nodes are colored with the hilite color and hilited and
 * selected clusteres are visualized through color and emphasized line
 * thickness.
 *
 * {@inheritDoc}
 */
@Override
public void paintContent(final Graphics g) {
    if (m_rootNode == null) {
        return;
    }
    Stroke backupStroke = ((Graphics2D) g).getStroke();
    Color backupColor = g.getColor();
    List<BinaryTreeNode<DendrogramPoint>> nodes = m_rootNode.getNodes(BinaryTree.Traversal.IN);
    for (BinaryTreeNode<DendrogramPoint> node : nodes) {
        DendrogramPoint dendroPoint = node.getContent();
        // set the correct stroke and color
        g.setColor(ColorAttr.DEFAULT.getColor(node.getContent().isSelected(), node.getContent().isHilite()));
        if (node.getContent().isSelected() || node.getContent().isHilite()) {
            ((Graphics2D) g).setStroke(new BasicStroke((m_lineThickness * EMPH)));
        } else {
            ((Graphics2D) g).setStroke(new BasicStroke(m_lineThickness));
        }
        if (node.getLeftChild() != null || node.getRightChild() != null) {
            // draw horizontal line
            Point leftPoint = node.getLeftChild().getContent().getPoint();
            Point rightPoint = node.getRightChild().getContent().getPoint();
            g.drawLine(leftPoint.x, node.getContent().getPoint().y, rightPoint.x, node.getContent().getPoint().y);
        }
        // draw vertical line
        if (node.getParent() != null) {
            g.setColor(ColorAttr.DEFAULT.getColor(node.getParent().getContent().isSelected(), node.getParent().getContent().isHilite()));
            // if yes bold line, else normal line
            if (!node.getParent().getContent().isSelected() && !node.getParent().getContent().isHilite()) {
                ((Graphics2D) g).setStroke(new BasicStroke(m_lineThickness));
            } else {
                ((Graphics2D) g).setStroke(new BasicStroke((m_lineThickness * EMPH)));
            }
            g.drawLine(node.getContent().getPoint().x, node.getContent().getPoint().y, node.getContent().getPoint().x, node.getParent().getContent().getPoint().y);
        }
        if (m_showDots) {
            Point p = node.getContent().getPoint();
            ShapeFactory.Shape shape = node.getContent().getShape();
            int size = (int) (node.getContent().getRelativeSize() * m_dotSize);
            shape.paint(g, p.x, p.y, size, node.getContent().getColor().getColor(), dendroPoint.isHilite(), dendroPoint.isSelected(), false);
        }
        ((Graphics2D) g).setStroke(backupStroke);
        g.setColor(backupColor);
    }
}
Also used : BasicStroke(java.awt.BasicStroke) Stroke(java.awt.Stroke) BasicStroke(java.awt.BasicStroke) Color(java.awt.Color) ShapeFactory(org.knime.core.data.property.ShapeFactory) Point(java.awt.Point) Point(java.awt.Point) Graphics2D(java.awt.Graphics2D)

Example 82 with Stroke

use of java.awt.Stroke in project knime-core by knime.

the class SpreadsheetTable method paint.

/**
 * {@inheritDoc}
 */
@Override
public void paint(final Graphics g) {
    super.paint(g);
    Graphics2D g2 = (Graphics2D) g;
    Stroke prevStroke = g2.getStroke();
    Color prevColor = g2.getColor();
    g2.setStroke(new BasicStroke(2f));
    g2.setColor(FOCUS_BORDER_COLOR);
    Rectangle cell = getCellRect(m_focusedRow, m_focusedColumn, false);
    g2.draw(cell);
    g2.setStroke(prevStroke);
    g2.setColor(prevColor);
}
Also used : BasicStroke(java.awt.BasicStroke) Stroke(java.awt.Stroke) KeyStroke(javax.swing.KeyStroke) BasicStroke(java.awt.BasicStroke) Color(java.awt.Color) Rectangle(java.awt.Rectangle) Graphics2D(java.awt.Graphics2D)

Example 83 with Stroke

use of java.awt.Stroke in project knime-core by knime.

the class ParallelCoordinatesViewPanel method drawScrollRectangle.

/**
 */
public void drawScrollRectangle() {
    Graphics2D g2d = (Graphics2D) this.getGraphics();
    // saving properties of g2d
    Color oldColor = g2d.getColor();
    Stroke oldStroke = g2d.getStroke();
    // seting dawing color
    g2d.setXORMode(Color.gray);
    // A dashed stroke
    float miterLimit = 3f;
    float[] dashPattern = { 3f };
    float dashPhase = 2f;
    float strokeThickness = 1.0f;
    Stroke stroke = new BasicStroke(strokeThickness, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, miterLimit, dashPattern, dashPhase);
    g2d.setStroke(stroke);
    // drawing
    int x = Math.min(m_dragStartX, m_dragStopX);
    int y = Math.min(m_dragStartY, m_dragStopY);
    int width = Math.abs(m_dragStopX - m_dragStartX);
    int height = Math.abs(m_dragStopY - m_dragStartY);
    g2d.drawRect(x, y, width, height);
    // reseting properties of g2d
    g2d.setXORMode(oldColor);
    g2d.setStroke(oldStroke);
}
Also used : BasicStroke(java.awt.BasicStroke) Stroke(java.awt.Stroke) BasicStroke(java.awt.BasicStroke) Color(java.awt.Color) Graphics2D(java.awt.Graphics2D)

Aggregations

Stroke (java.awt.Stroke)83 BasicStroke (java.awt.BasicStroke)74 Paint (java.awt.Paint)36 Color (java.awt.Color)34 Graphics2D (java.awt.Graphics2D)30 Point (java.awt.Point)23 GradientPaint (java.awt.GradientPaint)11 Shape (java.awt.Shape)11 Line2D (java.awt.geom.Line2D)11 Point2D (java.awt.geom.Point2D)11 Ellipse2D (java.awt.geom.Ellipse2D)9 Rectangle (java.awt.Rectangle)8 RoundRectangle2D (java.awt.geom.RoundRectangle2D)7 LayoutlibDelegate (com.android.tools.layoutlib.annotations.LayoutlibDelegate)6 Font (java.awt.Font)6 RadialGradientPaint (java.awt.RadialGradientPaint)6 AffineTransform (java.awt.geom.AffineTransform)6 Arc2D (java.awt.geom.Arc2D)5 Rectangle2D (java.awt.geom.Rectangle2D)5 GeneralPath (java.awt.geom.GeneralPath)4