use of java.awt.BasicStroke in project knime-core by knime.
the class BoxPlotDrawingPane method paintContent.
/**
* {@inheritDoc}
*/
@Override
public void paintContent(final Graphics g) {
if (m_boxes == null || m_boxes.size() == 0) {
return;
}
super.paintContent(g);
Stroke backupStroke = ((Graphics2D) g).getStroke();
for (Box box : m_boxes) {
int x = box.getX();
((Graphics2D) g).setStroke(new BasicStroke(3, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER));
// paint lower whisker stroke
g.drawLine(x - (m_boxWidth / 2) + 1, box.getLowerWhisker(), x + m_boxWidth / 2, box.getLowerWhisker());
// paint upper whisker stroke
g.drawLine(x - (m_boxWidth / 2) + 1, box.getUpperWhisker(), x + m_boxWidth / 2, box.getUpperWhisker());
// paint median stroke (add one pixel because of the bigger stroke
g.drawLine(x - (m_boxWidth / 2) + 1, box.getMedian(), x + m_boxWidth / 2, box.getMedian());
// paint the rectangle
((Graphics2D) g).setStroke(backupStroke);
g.drawRect(// x
x - m_boxWidth / 2, // bugfix 1380
Math.min(box.getUpperQuartile(), box.getLowerQuartile()), m_boxWidth, // bugfix 1380
Math.abs(box.getLowerQuartile() - box.getUpperQuartile()));
// draw the dotted vertical line to the quartiles
((Graphics2D) g).setStroke(DASHED);
// lower
g.drawLine(x, box.getLowerWhisker(), x, box.getLowerQuartile());
// upper
g.drawLine(x, box.getUpperWhisker(), x, box.getUpperQuartile());
((Graphics2D) g).setStroke(backupStroke);
paintLabels(g, box);
}
paintOutlierLabels(g);
}
use of java.awt.BasicStroke in project knime-core by knime.
the class AbstractDrawingPane method paintCursor.
private synchronized void paintCursor(final Graphics g) {
Graphics2D g2 = (Graphics2D) g;
Stroke oldStroke = g2.getStroke();
g2.setStroke(new BasicStroke(1.0f));
// Now check if we have a new selection rectangle to paint
if (dragCoordSet()) {
int x, y;
int w, h;
if (m_mouseDownX < m_dragX) {
x = m_mouseDownX;
w = m_dragX - m_mouseDownX;
// it's actually the width+1
} else {
// which is fine for drawRect!!
x = m_dragX;
w = m_mouseDownX - m_dragX;
}
if (m_mouseDownY < m_dragY) {
y = m_mouseDownY;
h = m_dragY - m_mouseDownY;
// it's actually the heigth+1
} else {
// which is fine for drawRect!!
y = m_dragY;
h = m_mouseDownY - m_dragY;
}
// and therefore the intended operation
if (m_rightMouseDown) {
g2.setColor(Color.lightGray);
g2.setXORMode(Color.blue);
} else {
g2.setColor(Color.lightGray);
g2.setXORMode(Color.darkGray);
}
g2.drawRect(x, y, w, h);
g2.setPaintMode();
}
// Now paint a nice cursor - that is a crosshair for now
if (cursorCoordSet()) {
g2.setColor(Color.darkGray);
g2.setXORMode(Color.black);
// draw the new ones
g2.drawLine(0, m_cursorY, getWidth(), m_cursorY);
g2.drawLine(m_cursorX, 0, m_cursorX, getHeight());
g2.setPaintMode();
}
g2.setStroke(oldStroke);
}
use of java.awt.BasicStroke in project litiengine by gurkenlabs.
the class MapComponent method render.
@Override
public void render(Graphics2D g) {
if (Game.getEnvironment() == null) {
return;
}
this.renderGrid(g);
final BasicStroke shapeStroke = new BasicStroke(1 / Game.getCamera().getRenderScale());
if (this.renderMapObjectBounds) {
this.renderMapObjectBounds(g);
}
switch(this.currentEditMode) {
case EDITMODE_CREATE:
this.renderNewObjectArea(g, shapeStroke);
break;
case EDITMODE_EDIT:
this.renderMouseSelectionArea(g, shapeStroke);
break;
default:
break;
}
this.renderSelection(g);
this.renderFocus(g);
super.render(g);
}
use of java.awt.BasicStroke in project litiengine by gurkenlabs.
the class MapComponent method renderGrid.
private void renderGrid(Graphics2D g) {
// render the grid
if (this.renderGrid && Game.getCamera().getRenderScale() >= 1) {
g.setColor(new Color(255, 255, 255, 70));
final Stroke stroke = new BasicStroke(1 / Game.getCamera().getRenderScale());
final double viewPortX = Math.max(0, Game.getCamera().getViewPort().getX());
final double viewPortMaxX = Math.min(Game.getEnvironment().getMap().getSizeInPixels().getWidth(), Game.getCamera().getViewPort().getMaxX());
final double viewPortY = Math.max(0, Game.getCamera().getViewPort().getY());
final double viewPortMaxY = Math.min(Game.getEnvironment().getMap().getSizeInPixels().getHeight(), Game.getCamera().getViewPort().getMaxY());
final int startX = Math.max(0, (int) (viewPortX / gridSize) * gridSize);
final int startY = Math.max(0, (int) (viewPortY / gridSize) * gridSize);
for (int x = startX; x <= viewPortMaxX; x += gridSize) {
Game.getRenderEngine().renderOutline(g, new Line2D.Double(x, viewPortY, x, viewPortMaxY), stroke);
}
for (int y = startY; y <= viewPortMaxY; y += gridSize) {
Game.getRenderEngine().renderOutline(g, new Line2D.Double(viewPortX, y, viewPortMaxX, y), stroke);
}
}
}
use of java.awt.BasicStroke in project JWildfire by thargor6.
the class FlamePanel method initPropertiesFromPrefs.
private void initPropertiesFromPrefs() {
strokeGuides = new BasicStroke((float) prefs.getTinaEditorGuidesLineWidth());
colorGuideCenter = prefs.getTinaEditorGuidesCenterPointColor();
colorGuideThirds = prefs.getTinaEditorGuidesRuleOfThirdsColor();
colorGuideGoldenRatio = prefs.getTinaEditorGuidesGoldenRatioColor();
}
Aggregations