Search in sources :

Example 56 with BasicStroke

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

Example 57 with BasicStroke

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

Example 58 with BasicStroke

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

Example 59 with BasicStroke

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);
        }
    }
}
Also used : BasicStroke(java.awt.BasicStroke) BasicStroke(java.awt.BasicStroke) Stroke(java.awt.Stroke) Color(java.awt.Color) Line2D(java.awt.geom.Line2D) Blueprint(de.gurkenlabs.litiengine.environment.tilemap.xml.Blueprint)

Example 60 with BasicStroke

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

Aggregations

BasicStroke (java.awt.BasicStroke)571 Graphics2D (java.awt.Graphics2D)179 Color (java.awt.Color)164 Stroke (java.awt.Stroke)141 GradientPaint (java.awt.GradientPaint)96 Test (org.junit.Test)93 Rectangle2D (java.awt.geom.Rectangle2D)71 Paint (java.awt.Paint)64 Font (java.awt.Font)61 Point (java.awt.Point)47 Line2D (java.awt.geom.Line2D)47 BufferedImage (java.awt.image.BufferedImage)43 Shape (java.awt.Shape)39 Point2D (java.awt.geom.Point2D)38 AffineTransform (java.awt.geom.AffineTransform)34 JFreeChart (org.jfree.chart.JFreeChart)34 Rectangle (java.awt.Rectangle)27 Ellipse2D (java.awt.geom.Ellipse2D)27 RectangleInsets (org.jfree.ui.RectangleInsets)27 NumberAxis (org.jfree.chart.axis.NumberAxis)25