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);
}
}
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);
}
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);
}
Aggregations