Search in sources :

Example 11 with BasicStroke

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);
    }
}
Also used : BasicStroke(java.awt.BasicStroke) Stroke(java.awt.Stroke) BasicStroke(java.awt.BasicStroke) Point(java.awt.Point)

Example 12 with BasicStroke

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);
}
Also used : BasicStroke(java.awt.BasicStroke) Stroke(java.awt.Stroke) BasicStroke(java.awt.BasicStroke) FontMetrics(java.awt.FontMetrics)

Example 13 with BasicStroke

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));
}
Also used : BasicStroke(java.awt.BasicStroke) Area(java.awt.geom.Area) Stroke(java.awt.Stroke) BasicStroke(java.awt.BasicStroke) Color(java.awt.Color) Ellipse2D(java.awt.geom.Ellipse2D)

Example 14 with BasicStroke

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);
    }
}
Also used : BasicStroke(java.awt.BasicStroke) Stroke(java.awt.Stroke) BasicStroke(java.awt.BasicStroke) Point(java.awt.Point)

Example 15 with BasicStroke

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);
}
Also used : BasicStroke(java.awt.BasicStroke) AffineTransform(java.awt.geom.AffineTransform)

Aggregations

BasicStroke (java.awt.BasicStroke)563 Graphics2D (java.awt.Graphics2D)179 Color (java.awt.Color)160 Stroke (java.awt.Stroke)137 GradientPaint (java.awt.GradientPaint)95 Test (org.junit.Test)93 Rectangle2D (java.awt.geom.Rectangle2D)67 Paint (java.awt.Paint)64 Font (java.awt.Font)61 Line2D (java.awt.geom.Line2D)46 Point (java.awt.Point)45 BufferedImage (java.awt.image.BufferedImage)43 Shape (java.awt.Shape)38 Point2D (java.awt.geom.Point2D)38 JFreeChart (org.jfree.chart.JFreeChart)34 AffineTransform (java.awt.geom.AffineTransform)33 Rectangle (java.awt.Rectangle)27 RectangleInsets (org.jfree.ui.RectangleInsets)27 Ellipse2D (java.awt.geom.Ellipse2D)25 NumberAxis (org.jfree.chart.axis.NumberAxis)25