Search in sources :

Example 1 with BasicStroke

use of java.awt.BasicStroke in project screenbird by adamhub.

the class JRoundedPanel method paintComponent.

//    public JRoundedPanel(CardLayout cardLayout) {
//        super(cardLayout);
//        setOpaque(false);
//        Color backgrnd = new Color(Color.darkGray.getRed(),Color.darkGray.getGreen(), Color.darkGray.getBlue(),180);
//        this.setBackground(backgrnd);
//    }
@Override
protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    int width = getWidth();
    int height = getHeight();
    int shadowGap = this.shadowGap;
    Color shadowColorA = new Color(shadowColor.getRed(), shadowColor.getGreen(), shadowColor.getBlue(), shadowAlpha);
    Graphics2D graphics = (Graphics2D) g;
    //Sets antialiasing if HQ.
    if (highQuality) {
        graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    }
    //Draws shadow borders if any.
    if (shady) {
        graphics.setColor(shadowColorA);
        graphics.fillRoundRect(// X position
        shadowOffset, // Y position
        shadowOffset, // width
        width - strokeSize - shadowOffset, // height
        height - strokeSize - shadowOffset, arcs.width, // arc Dimension
        arcs.height);
    } else {
        shadowGap = 1;
    }
    //Draws the rounded opaque panel with borders.
    graphics.setColor(getBackground());
    graphics.fillRoundRect(0, 0, width - shadowGap, height - shadowGap, arcs.width, arcs.height);
    graphics.setColor(getForeground());
    //graphics.setStroke(new BasicStroke(strokeSize));
    //graphics.drawRoundRect(0, 0, width - shadowGap, height - shadowGap, arcs.width, arcs.height);
    //Sets strokes to default, is better.
    graphics.setStroke(new BasicStroke());
}
Also used : BasicStroke(java.awt.BasicStroke) Color(java.awt.Color) Graphics2D(java.awt.Graphics2D)

Example 2 with BasicStroke

use of java.awt.BasicStroke in project EnrichmentMapApp by BaderLab.

the class JRangeSlider method paintComponent.

/**
	 * @see javax.swing.JComponent#paintComponent(java.awt.Graphics)
	 */
public void paintComponent(Graphics g) {
    Rectangle bounds = getBounds();
    int width = (int) bounds.getWidth() - 1;
    int height = (int) bounds.getHeight() - 1;
    int min = toScreen(getLowValue());
    int max = toScreen(getHighValue());
    // Paint the full slider if the slider is marked as empty
    if (empty) {
        if (direction == LEFTRIGHT_TOPBOTTOM) {
            min = ARROW_SZ;
            max = (orientation == VERTICAL) ? (height - ARROW_SZ) : (width - ARROW_SZ);
        } else {
            min = (orientation == VERTICAL) ? (height - ARROW_SZ) : (width - ARROW_SZ);
            max = ARROW_SZ;
        }
    }
    Graphics2D g2 = (Graphics2D) g;
    g2.setColor(getBackground());
    g2.fillRect(0, 0, width, height);
    g2.setColor(getForeground());
    g2.drawRect(0, 0, width, height);
    customPaint(g2, width, height);
    // Draw arrow and thumb backgrounds
    g2.setStroke(new BasicStroke(1));
    if (orientation == VERTICAL) {
        if (direction == LEFTRIGHT_TOPBOTTOM) {
            g2.setColor(getForeground());
            g2.fillRect(0, min - ARROW_SZ, width, ARROW_SZ - 1);
            paint3DRectLighting(g2, 0, min - ARROW_SZ, width, ARROW_SZ - 1);
            if (thumbColor != null) {
                g2.setColor(thumbColor);
                g2.fillRect(0, min, width, max - min - 1);
                paint3DRectLighting(g2, 0, min, width, max - min - 1);
            }
            g2.setColor(getForeground());
            g2.fillRect(0, max, width, ARROW_SZ - 1);
            paint3DRectLighting(g2, 0, max, width, ARROW_SZ - 1);
            // Draw arrows          
            g2.setColor(Color.black);
            paintArrow(g2, (width - ARROW_WIDTH) / 2.0, min - ARROW_SZ + ((ARROW_SZ - ARROW_HEIGHT) / 2.0), ARROW_WIDTH, ARROW_HEIGHT, true);
            paintArrow(g2, (width - ARROW_WIDTH) / 2.0, max + ((ARROW_SZ - ARROW_HEIGHT) / 2.0), ARROW_WIDTH, ARROW_HEIGHT, false);
        } else {
            g2.setColor(getForeground());
            g2.fillRect(0, min, width, ARROW_SZ - 1);
            paint3DRectLighting(g2, 0, min, width, ARROW_SZ - 1);
            if (thumbColor != null) {
                g2.setColor(thumbColor);
                g2.fillRect(0, max, width, min - max - 1);
                paint3DRectLighting(g2, 0, max, width, min - max - 1);
            }
            g2.setColor(getForeground());
            g2.fillRect(0, max - ARROW_SZ, width, ARROW_SZ - 1);
            paint3DRectLighting(g2, 0, max - ARROW_SZ, width, ARROW_SZ - 1);
            // Draw arrows          
            g2.setColor(Color.black);
            paintArrow(g2, (width - ARROW_WIDTH) / 2.0, min + ((ARROW_SZ - ARROW_HEIGHT) / 2.0), ARROW_WIDTH, ARROW_HEIGHT, false);
            paintArrow(g2, (width - ARROW_WIDTH) / 2.0, max - ARROW_SZ + ((ARROW_SZ - ARROW_HEIGHT) / 2.0), ARROW_WIDTH, ARROW_HEIGHT, true);
        }
    } else {
        if (direction == LEFTRIGHT_TOPBOTTOM) {
            g2.setColor(getForeground());
            g2.fillRect(min - ARROW_SZ, 0, ARROW_SZ - 1, height);
            paint3DRectLighting(g2, min - ARROW_SZ, 0, ARROW_SZ - 1, height);
            if (thumbColor != null) {
                g2.setColor(thumbColor);
                g2.fillRect(min, 0, max - min - 1, height);
                paint3DRectLighting(g2, min, 0, max - min - 1, height);
            }
            g2.setColor(getForeground());
            g2.fillRect(max, 0, ARROW_SZ - 1, height);
            paint3DRectLighting(g2, max, 0, ARROW_SZ - 1, height);
            // Draw arrows          
            g2.setColor(Color.black);
            paintArrow(g2, min - ARROW_SZ + ((ARROW_SZ - ARROW_HEIGHT) / 2.0), (height - ARROW_WIDTH) / 2.0, ARROW_HEIGHT, ARROW_WIDTH, true);
            paintArrow(g2, max + ((ARROW_SZ - ARROW_HEIGHT) / 2.0), (height - ARROW_WIDTH) / 2.0, ARROW_HEIGHT, ARROW_WIDTH, false);
        } else {
            g2.setColor(getForeground());
            g2.fillRect(min, 0, ARROW_SZ - 1, height);
            paint3DRectLighting(g2, min, 0, ARROW_SZ - 1, height);
            if (thumbColor != null) {
                g2.setColor(thumbColor);
                g2.fillRect(max, 0, min - max - 1, height);
                paint3DRectLighting(g2, max, 0, min - max - 1, height);
            }
            g2.setColor(getForeground());
            g2.fillRect(max - ARROW_SZ, 0, ARROW_SZ - 1, height);
            paint3DRectLighting(g2, max - ARROW_SZ, 0, ARROW_SZ - 1, height);
            // Draw arrows          
            g2.setColor(Color.black);
            paintArrow(g2, min + ((ARROW_SZ - ARROW_HEIGHT) / 2.0), (height - ARROW_WIDTH) / 2.0, ARROW_HEIGHT, ARROW_WIDTH, true);
            paintArrow(g2, max - ARROW_SZ + ((ARROW_SZ - ARROW_HEIGHT) / 2.0), (height - ARROW_WIDTH) / 2.0, ARROW_HEIGHT, ARROW_WIDTH, false);
        }
    }
}
Also used : BasicStroke(java.awt.BasicStroke) Rectangle(java.awt.Rectangle) Graphics2D(java.awt.Graphics2D)

Example 3 with BasicStroke

use of java.awt.BasicStroke in project Activiti by Activiti.

the class DefaultProcessDiagramCanvas method drawNoneEndEvent.

public void drawNoneEndEvent(GraphicInfo graphicInfo, double scaleFactor) {
    Paint originalPaint = g.getPaint();
    Stroke originalStroke = g.getStroke();
    g.setPaint(EVENT_COLOR);
    Ellipse2D circle = new Ellipse2D.Double(graphicInfo.getX(), graphicInfo.getY(), graphicInfo.getWidth(), graphicInfo.getHeight());
    g.fill(circle);
    g.setPaint(EVENT_BORDER_COLOR);
    if (scaleFactor == 1.0) {
        g.setStroke(END_EVENT_STROKE);
    } else {
        g.setStroke(new BasicStroke(2.0f));
    }
    g.draw(circle);
    g.setStroke(originalStroke);
    g.setPaint(originalPaint);
}
Also used : BasicStroke(java.awt.BasicStroke) Stroke(java.awt.Stroke) BasicStroke(java.awt.BasicStroke) Paint(java.awt.Paint) Ellipse2D(java.awt.geom.Ellipse2D)

Example 4 with BasicStroke

use of java.awt.BasicStroke in project adempiere by adempiere.

the class BoxElement method paint.

//	calculateSize
/**
	 * 	Paint
	 *	@param g2D graphics
	 *	@param pageNo page
	 *	@param pageStart page start
	 *	@param ctx context
	 *	@param isView true if Java
	 */
public void paint(Graphics2D g2D, int pageNo, Point2D pageStart, Properties ctx, boolean isView) {
    if (m_item == null)
        return;
    //
    g2D.setColor(m_color);
    BasicStroke s = new BasicStroke(m_item.getLineWidth());
    g2D.setStroke(s);
    //
    Point2D.Double location = getAbsoluteLocation(pageStart);
    int x = (int) location.x;
    int y = (int) location.y;
    int width = m_item.getMaxWidth();
    int height = m_item.getMaxHeight();
    if (m_item.getPrintFormatType().equals(MPrintFormatItem.PRINTFORMATTYPE_Line))
        g2D.drawLine(x, y, x + width, y + height);
    else {
        String type = m_item.getShapeType();
        if (type == null)
            type = "";
        if (m_item.isFilledRectangle()) {
            if (type.equals(MPrintFormatItem.SHAPETYPE_3DRectangle))
                g2D.fill3DRect(x, y, width, height, true);
            else if (type.equals(MPrintFormatItem.SHAPETYPE_Oval))
                g2D.fillOval(x, y, width, height);
            else if (type.equals(MPrintFormatItem.SHAPETYPE_RoundRectangle))
                g2D.fillRoundRect(x, y, width, height, m_item.getArcDiameter(), m_item.getArcDiameter());
            else
                g2D.fillRect(x, y, width, height);
        } else {
            if (type.equals(MPrintFormatItem.SHAPETYPE_3DRectangle))
                g2D.draw3DRect(x, y, width, height, true);
            else if (type.equals(MPrintFormatItem.SHAPETYPE_Oval))
                g2D.drawOval(x, y, width, height);
            else if (type.equals(MPrintFormatItem.SHAPETYPE_RoundRectangle))
                g2D.drawRoundRect(x, y, width, height, m_item.getArcDiameter(), m_item.getArcDiameter());
            else
                g2D.drawRect(x, y, width, height);
        }
    }
}
Also used : BasicStroke(java.awt.BasicStroke) Point2D(java.awt.geom.Point2D)

Example 5 with BasicStroke

use of java.awt.BasicStroke in project poi by apache.

the class DummyGraphics2d method setStroke.

public void setStroke(Stroke s) {
    String l;
    if (s instanceof BasicStroke) {
        BasicStroke bs = (BasicStroke) s;
        l = "setStroke(Stoke):" + "\n  s = BasicStroke(" + "\n    dash[]: " + Arrays.toString(bs.getDashArray()) + "\n    dashPhase: " + bs.getDashPhase() + "\n    endCap: " + bs.getEndCap() + "\n    lineJoin: " + bs.getLineJoin() + "\n    width: " + bs.getLineWidth() + "\n    miterLimit: " + bs.getMiterLimit() + "\n  )";
    } else {
        l = "setStroke(Stoke):" + "\n  s = " + s;
    }
    log.println(l);
    g2D.setStroke(s);
}
Also used : BasicStroke(java.awt.BasicStroke)

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