use of java.awt.BasicStroke in project knime-core by knime.
the class ParallelCoordinateDrawingPane method drawLine.
/**
* Draws the line between the mapped data points of one
* {@link org.knime.base.node.viz.plotter.parcoord.LineInfo}.
*
* @param g graphics object
* @param line one line / row
*/
private void drawLine(final Graphics g, final LineInfo line) {
if (m_fade && !line.isHilite()) {
if (line.isSelected()) {
g.setColor(ColorAttr.INACTIVE_SELECTED);
} else {
g.setColor(ColorAttr.INACTIVE);
}
} else if (!m_hide && !m_fade) {
g.setColor(line.getColor().getColor(line.isSelected(), line.isHilite()));
} else {
// bugfix : 1278
g.setColor(line.getColor().getColor(line.isSelected(), false));
}
int lineSize = getStrokeSize(line.getSize());
Stroke selectionStroke = new BasicStroke(lineSize, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 1.0f, new float[] { DASH }, 0);
((Graphics2D) g).setStroke(new BasicStroke(lineSize));
List<Point> points = line.getPoints();
for (int i = 0; i < points.size() - 1; i++) {
Point p1 = points.get(i);
Point p2 = points.get(i + 1);
if ((p1.y == ParallelCoordinatesPlotter.MISSING || p2.y == ParallelCoordinatesPlotter.MISSING)) {
if (m_skipValues) {
continue;
}
if (m_showMissingVals) {
int pointPos = getHeight() - (2 * g.getFontMetrics().getHeight());
if (p1.y == ParallelCoordinatesPlotter.MISSING) {
p1.y = pointPos;
}
if (p2.y == ParallelCoordinatesPlotter.MISSING) {
p2.y = pointPos;
}
}
}
// backup
Color backupColor = g.getColor();
if (line.isHilite() && !m_hide && !m_fade) {
// draw additional "hilite" line#
Stroke backupStroke = ((Graphics2D) g).getStroke();
((Graphics2D) g).setStroke(new BasicStroke(2 * lineSize));
g.setColor(ColorAttr.HILITE);
g.drawLine(p1.x, p1.y, p2.x, p2.y);
g.setColor(backupColor);
((Graphics2D) g).setStroke(backupStroke);
}
// draw the line
g.drawLine(p1.x, p1.y, p2.x, p2.y);
if (line.isSelected()) {
// draw dotted line
Stroke backupStroke = ((Graphics2D) g).getStroke();
((Graphics2D) g).setStroke(selectionStroke);
g.setXORMode(Color.white);
g.drawLine(p1.x, p1.y, p2.x, p2.y);
((Graphics2D) g).setStroke(backupStroke);
g.setPaintMode();
}
// draw the point
if (m_showDots) {
paintDot(g, p1, line, lineSize);
}
}
if (m_showDots) {
// draw the points of the last axis
Point p = line.getPoints().get(line.getPoints().size() - 1);
paintDot(g, p, line, lineSize);
}
((Graphics2D) g).setStroke(new BasicStroke(1));
}
use of java.awt.BasicStroke in project knime-core by knime.
the class HierarchicalClusterNodeView method modelChanged.
/**
* {@inheritDoc}
*/
@Override
public void modelChanged() {
if (getNodeModel() == null || ((DataProvider) getNodeModel()).getDataArray(0) == null || ((DataProvider) getNodeModel()).getDataArray(0).size() == 0) {
return;
}
NodeModel model = getNodeModel();
m_dendroPlotter.reset();
m_distancePlotter.reset();
m_dendroPlotter.setHiLiteHandler(model.getInHiLiteHandler(0));
m_dendroPlotter.setAntialiasing(false);
m_dendroPlotter.setDataProvider((DataProvider) model);
m_distancePlotter.setDataProvider((DataProvider) model);
m_distancePlotter.setHiLiteHandler(model.getInHiLiteHandler(0));
DendrogramNode rootNode = getNodeModel().getRootNode();
DataArray distanceTable = ((DataProvider) getNodeModel()).getDataArray(0);
m_dendroPlotter.setRootNode(rootNode);
m_distancePlotter.createXCoordinate(((DoubleValue) distanceTable.getDataTableSpec().getColumnSpec(0).getDomain().getLowerBound()).getDoubleValue(), ((DoubleValue) distanceTable.getDataTableSpec().getColumnSpec(0).getDomain().getUpperBound()).getDoubleValue());
m_distancePlotter.createYCoordinate(((DoubleValue) distanceTable.getDataTableSpec().getColumnSpec(1).getDomain().getLowerBound()).getDoubleValue(), ((DoubleValue) distanceTable.getDataTableSpec().getColumnSpec(1).getDomain().getUpperBound()).getDoubleValue());
((BasicDrawingPane) m_distancePlotter.getDrawingPane()).clearPlot();
m_distancePlotter.addLine(distanceTable, 0, 1, Color.BLACK, new BasicStroke(m_thickness));
// m_distancePlotter.getXAxis().getCoordinate().setPolicy(
// DescendingNumericTickPolicyStrategy.getInstance());
m_distancePlotter.updatePaintModel();
m_dendroPlotter.updatePaintModel();
}
use of java.awt.BasicStroke in project knime-core by knime.
the class HierarchicalGraphView method paintNode.
/**
* Draw the node, its background and border to the graphics object.
*/
private void paintNode(final Component c, final DefaultMutableTreeNode node, final Graphics2D g) {
K k = (K) node.getUserObject();
NodeWidget<K> widget = getWidgets().get(k);
widget.setScaleFactor(m_scale);
Rectangle bounds = getVisible().get(k);
boolean selected = m_selected == k;
boolean hilited = m_hilited.contains(k);
if (selected && hilited) {
g.setPaint(ColorAttr.SELECTED_HILITE);
g.fillRoundRect(bounds.x, bounds.y, bounds.width, bounds.height, 5, 5);
} else if (selected) {
g.setPaint(ColorAttr.SELECTED);
} else if (hilited) {
g.setPaint(ColorAttr.HILITE);
} else {
g.setPaint(ColorAttr.BACKGROUND);
}
g.fillRoundRect(bounds.x, bounds.y, bounds.width, bounds.height, 8, 8);
widget.paint(c, g, bounds);
if (selected) {
g.setStroke(new BasicStroke(2f));
} else {
g.setStroke(new BasicStroke(1f));
}
g.setPaint(ColorAttr.BORDER);
g.drawRoundRect(bounds.x, bounds.y, bounds.width - 1, bounds.height - 1, 8, 8);
g.setStroke(new BasicStroke(1f));
}
use of java.awt.BasicStroke in project knime-core by knime.
the class DrawingUtils method paintHorizontalLine.
/**
* Draws a horizontal line starting at the given x/y offset with
* the given length.
* @param g2 the graphics object to use
* @param xOffset the x offset of the line
* @param yOffset the y offset of the line
* @param lineWidth the width of the line
* @param color the drawing color
* @param stroke the stroke to use
*/
public static void paintHorizontalLine(final Graphics2D g2, final int xOffset, final int yOffset, final int lineWidth, final Color color, final BasicStroke stroke) {
// save the original settings
final Stroke origStroke = g2.getStroke();
final Color origColor = g2.getColor();
g2.setColor(color);
g2.setStroke(stroke);
g2.drawLine(xOffset, yOffset, lineWidth, yOffset);
// set the original settings
g2.setStroke(origStroke);
g2.setColor(origColor);
}
use of java.awt.BasicStroke in project knime-core by knime.
the class DrawingUtils method drawArc.
/**
* Draws the outline of the given arc.
* @param g2 the graphic object
* @param arc the arc to draw
* @param paint the filling color or TexturePaint
* @param stroke the {@link Stroke} to use
*/
public static void drawArc(final Graphics2D g2, final Arc2D arc, final Paint paint, final BasicStroke stroke) {
if (arc == null) {
return;
}
final Arc2D outlineArc = calculateBorderArc(arc, stroke);
// save the original settings
final Paint origPaint = g2.getPaint();
final Stroke origStroke = g2.getStroke();
g2.setStroke(stroke);
g2.setPaint(paint);
g2.draw(outlineArc);
// set the old settings
g2.setPaint(origPaint);
g2.setStroke(origStroke);
}
Aggregations