use of java.awt.BasicStroke in project gephi by gephi.
the class EquationDisplay method drawVerticalGrid.
private void drawVerticalGrid(Graphics2D g2) {
double minorSpacing = majorX / minorX;
double axisH = yPositionToPixel(originY);
Stroke gridStroke = new BasicStroke(STROKE_GRID);
Stroke axisStroke = new BasicStroke(STROKE_AXIS);
for (double x = originX + majorX; x < maxX + majorX; x += majorX) {
g2.setStroke(gridStroke);
g2.setColor(COLOR_MINOR_GRID);
for (int i = 0; i < minorX; i++) {
int position = (int) xPositionToPixel(x - i * minorSpacing);
g2.drawLine(position, 0, position, getHeight());
}
int position = (int) xPositionToPixel(x);
g2.setColor(COLOR_MAJOR_GRID);
g2.drawLine(position, 0, position, getHeight());
g2.setStroke(axisStroke);
g2.setColor(COLOR_AXIS);
g2.drawLine(position, (int) axisH - 3, position, (int) axisH + 3);
}
for (double x = originX - majorX; x > minX - majorX; x -= majorX) {
g2.setStroke(gridStroke);
g2.setColor(COLOR_MINOR_GRID);
for (int i = 0; i < minorX; i++) {
int position = (int) xPositionToPixel(x + i * minorSpacing);
g2.drawLine(position, 0, position, getHeight());
}
int position = (int) xPositionToPixel(x);
g2.setColor(COLOR_MAJOR_GRID);
g2.drawLine(position, 0, position, getHeight());
g2.setStroke(axisStroke);
g2.setColor(COLOR_AXIS);
g2.drawLine(position, (int) axisH - 3, position, (int) axisH + 3);
}
}
use of java.awt.BasicStroke in project gephi by gephi.
the class EquationDisplay method drawAxis.
private void drawAxis(Graphics2D g2) {
double axisH = yPositionToPixel(originY);
double axisV = xPositionToPixel(originX);
g2.setColor(COLOR_AXIS);
Stroke stroke = g2.getStroke();
g2.setStroke(new BasicStroke(STROKE_AXIS));
g2.drawLine(0, (int) axisH, getWidth(), (int) axisH);
g2.drawLine((int) axisV, 0, (int) axisV, getHeight());
FontMetrics metrics = g2.getFontMetrics();
g2.drawString(formatter.format(0.0), (int) axisV + 5, (int) axisH + metrics.getHeight());
g2.setStroke(stroke);
}
use of java.awt.BasicStroke in project gephi by gephi.
the class SplineDisplay method paintControlPoint.
private void paintControlPoint(Graphics2D g2, Point2D control) {
double origin_x = xPositionToPixel(control.getX());
double origin_y = yPositionToPixel(control.getY());
double pos = control == control1 ? 0.0 : 1.0;
Ellipse2D outer = getDraggableArea(control);
Ellipse2D inner = new Ellipse2D.Double(origin_x + 2.0 - CONTROL_POINT_SIZE / 2.0, origin_y + 2.0 - CONTROL_POINT_SIZE / 2.0, 8.0, 8.0);
Area circle = new Area(outer);
circle.subtract(new Area(inner));
Stroke stroke = g2.getStroke();
g2.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 5, new float[] { 5, 5 }, 0));
g2.setColor(new Color(1.0f, 0.0f, 0.0f, 0.4f));
g2.drawLine(0, (int) origin_y, (int) origin_x, (int) origin_y);
g2.drawLine((int) origin_x, (int) origin_y, (int) origin_x, getHeight());
g2.setStroke(stroke);
if (selected == control) {
g2.setColor(new Color(1.0f, 1.0f, 1.0f, 1.0f));
} else {
g2.setColor(new Color(0.8f, 0.8f, 0.8f, 0.6f));
}
g2.fill(inner);
g2.setColor(new Color(0.0f, 0.0f, 0.5f, 0.5f));
g2.fill(circle);
g2.drawLine((int) origin_x, (int) origin_y, (int) xPositionToPixel(pos), (int) yPositionToPixel(pos));
}
use of java.awt.BasicStroke in project gephi by gephi.
the class EquationDisplay method drawHorizontalGrid.
private void drawHorizontalGrid(Graphics2D g2) {
double minorSpacing = majorY / minorY;
double axisV = xPositionToPixel(originX);
Stroke gridStroke = new BasicStroke(STROKE_GRID);
Stroke axisStroke = new BasicStroke(STROKE_AXIS);
for (double y = originY + majorY; y < maxY + majorY; y += majorY) {
g2.setStroke(gridStroke);
g2.setColor(COLOR_MINOR_GRID);
for (int i = 0; i < minorY; i++) {
int position = (int) yPositionToPixel(y - i * minorSpacing);
g2.drawLine(0, position, getWidth(), position);
}
int position = (int) yPositionToPixel(y);
g2.setColor(COLOR_MAJOR_GRID);
g2.drawLine(0, position, getWidth(), position);
g2.setStroke(axisStroke);
g2.setColor(COLOR_AXIS);
g2.drawLine((int) axisV - 3, position, (int) axisV + 3, position);
}
for (double y = originY - majorY; y > minY - majorY; y -= majorY) {
g2.setStroke(gridStroke);
g2.setColor(COLOR_MINOR_GRID);
for (int i = 0; i < minorY; i++) {
int position = (int) yPositionToPixel(y + i * minorSpacing);
g2.drawLine(0, position, getWidth(), position);
}
int position = (int) yPositionToPixel(y);
g2.setColor(COLOR_MAJOR_GRID);
g2.drawLine(0, position, getWidth(), position);
g2.setStroke(axisStroke);
g2.setColor(COLOR_AXIS);
g2.drawLine((int) axisV - 3, position, (int) axisV + 3, position);
}
}
use of java.awt.BasicStroke in project processing by processing.
the class ColorControlBox method draw.
public void draw(Graphics2D g2d) {
if (!visible) {
return;
}
AffineTransform trans = g2d.getTransform();
g2d.translate(x, y);
// draw current color
g2d.setColor(color);
g2d.fillRoundRect(0, 0, width, height, 5, 5);
// draw black outline
g2d.setStroke(new BasicStroke(1));
g2d.setColor(Color.BLACK);
g2d.drawRoundRect(0, 0, width, height, 5, 5);
if (ilegalColor) {
g2d.setColor(Color.RED);
g2d.setStroke(new BasicStroke(2));
g2d.drawLine(width - 3, 3, 3, height - 3);
}
g2d.setTransform(trans);
}
Aggregations