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());
}
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);
}
}
}
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);
}
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);
}
}
}
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);
}
Aggregations