use of java.awt.Stroke in project vcell by virtualcell.
the class SpeciesToolShapeIcon method paintIcon.
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
if (c == null) {
return;
}
if (!(c instanceof JToolBarToggleButton)) {
return;
}
JToolBarToggleButton b = (JToolBarToggleButton) c;
Graphics2D g2 = (Graphics2D) g;
Color colorOld = g2.getColor();
Paint paintOld = g2.getPaint();
Stroke strokeOld = g2.getStroke();
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
// (diameter-circleDiameter) / 2
int xx = 2;
int yy = 2;
Color exterior, interior;
if (state == State.normal) {
exterior = Color.green.darker().darker();
interior = Color.white;
xx += x;
yy += y;
} else {
exterior = Color.green.darker();
interior = Color.white;
// button moves a little bit to simulate 3D pressing of a button
xx += x + 1;
yy += y + 1;
}
Ellipse2D e = new Ellipse2D.Double(xx, yy, circleDiameter, circleDiameter);
Point2D center = new Point2D.Float(xx + circleDiameter / 2, yy + circleDiameter / 2);
float radius = circleDiameter * 0.5f;
Point2D focus = new Point2D.Float(xx + circleDiameter / 2 - 2, yy + circleDiameter / 2 - 2);
float[] dist = { 0.1f, 1.0f };
Color[] colors = { interior, exterior };
RadialGradientPaint p = new RadialGradientPaint(center, radius, focus, dist, colors, CycleMethod.NO_CYCLE);
g2.setPaint(p);
g2.fill(e);
g.setColor(Color.black);
g2.draw(e);
g2.setStroke(strokeOld);
g2.setColor(colorOld);
g2.setPaint(paintOld);
}
use of java.awt.Stroke in project vcell by virtualcell.
the class UngroupToolShapeIcon method paintIcon.
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
if (c == null) {
return;
}
if (!(c instanceof JToolBarToggleButton)) {
return;
}
JToolBarToggleButton b = (JToolBarToggleButton) c;
Graphics2D g2 = (Graphics2D) g;
Color colorOld = g2.getColor();
Paint paintOld = g2.getPaint();
Stroke strokeOld = g2.getStroke();
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
Color c1;
Color c2;
Color c3;
Color c4;
// offset from upper left corner
int init;
switch(state) {
case normal:
init = 0;
c1 = Color.red.darker();
c2 = Color.lightGray;
c3 = Color.gray;
c4 = AbstractComponentShape.componentMediumPalePink;
break;
case selected:
init = 1;
c1 = Color.red.darker().darker();
c2 = Color.darkGray;
c3 = Color.gray;
c4 = AbstractComponentShape.componentPalePink;
break;
case disabled:
default:
init = 0;
c1 = Color.lightGray;
c2 = Color.lightGray;
c3 = Color.lightGray;
c4 = AbstractComponentShape.componentMediumPalePink;
break;
}
Rectangle2D rect;
g2.setStroke(new BasicStroke(0.8f));
final int delta2 = 10;
// the lower small rectangle
int xx1 = x + init + 5;
int yy1 = y + init + 6;
rect = new Rectangle2D.Double(xx1, yy1, delta2 + 1, delta2);
g2.setPaint(c3);
g2.draw(rect);
int m = 3;
// upper right corner small red square
g2.setStroke(new BasicStroke(1.0f));
g2.setPaint(c1);
int xx = xx1 + delta2;
int yy = yy1 - 1;
rect = new Rectangle2D.Double(xx, yy, m, m);
g2.fill(rect);
xx = xx1 - 1;
yy = yy1 + delta2 - 1;
rect = new Rectangle2D.Double(xx, yy, m, m);
g2.fill(rect);
xx = xx1 + delta2;
yy = yy1 + delta2 - 1;
rect = new Rectangle2D.Double(xx, yy, m, m);
g2.fill(rect);
// ------------------------------------------------------------------------
g2.setStroke(new BasicStroke(0.8f));
// the upper small rectangle
int xx2 = x + init + 1;
int yy2 = y + init + 2;
rect = new Rectangle2D.Double(xx2, yy2, delta2 + 1, delta2);
g2.setPaint(c4);
// overwrite some of the smaller rectangle
g2.fill(rect);
g2.setPaint(c3);
g2.draw(rect);
// upper left corner small red square
g2.setStroke(new BasicStroke(1.0f));
g2.setPaint(c1);
xx = xx2 - 1;
yy = yy2 - 1;
rect = new Rectangle2D.Double(xx, yy, m, m);
g2.fill(rect);
xx = xx2 + delta2;
yy = yy2 - 1;
rect = new Rectangle2D.Double(xx, yy, m, m);
g2.fill(rect);
xx = xx2 - 1;
yy = yy2 + delta2 - 1;
rect = new Rectangle2D.Double(xx, yy, m, m);
g2.fill(rect);
xx = xx2 + delta2;
yy = yy2 + delta2 - 1;
rect = new Rectangle2D.Double(xx, yy, m, m);
g2.fill(rect);
g2.setStroke(strokeOld);
g2.setColor(colorOld);
g2.setPaint(paintOld);
}
use of java.awt.Stroke in project vcell by virtualcell.
the class BioPaxGroupNeighborShape method paintSelf.
@Override
public void paintSelf(Graphics2D g2d, int xAbs, int yAbs) {
// TODO Auto-generated method stub
Point startPos = bioPaxShape.getSpaceManager().getAbsCenter();
Point endPos = groupShape.getSpaceManager().getAbsCenter();
if (getType().equals(Type.CONTROLLER) || getType().equals(Type.COFACTOR)) {
Stroke previousStroke = g2d.getStroke();
g2d.setStroke(CATALYST_STROKE);
g2d.drawLine(startPos.x, startPos.y, endPos.x, endPos.y);
g2d.setStroke(previousStroke);
} else {
g2d.drawLine(startPos.x, startPos.y, endPos.x, endPos.y);
}
if (getType().equals(Type.LEFT)) {
ArrowPainter.paintArrow(g2d, endPos, startPos, ARROW_LENGTH, ARROW_WIDTH);
} else if (getType().equals(Type.RIGHT)) {
ArrowPainter.paintArrow(g2d, startPos, endPos, ARROW_LENGTH, ARROW_WIDTH);
}
String label = getLabel();
if (label != null) {
g2d.drawString(label, xAbs + labelPos.x, yAbs + labelPos.y);
}
}
use of java.awt.Stroke in project vcell by virtualcell.
the class BioPaxInteractionParticipantShape method paintSelf.
@Override
public void paintSelf(Graphics2D g2d, int xAbs, int yAbs) {
RenderingHints oldRenderingHints = g2d.getRenderingHints();
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
Color oldColor = g2d.getColor();
g2d.setColor(forgroundColor);
CubicCurve2D.Double cubicCurve = getCurve();
if (participant.getType().equals(Type.CONTROLLER) || participant.getType().equals(Type.COFACTOR)) {
Stroke previousStroke = g2d.getStroke();
// g2d.setStroke(DASHED_STROKE); CATALYST_STROKE
g2d.setStroke(DASHED_STROKE);
g2d.draw(cubicCurve);
g2d.setStroke(previousStroke);
} else {
g2d.draw(cubicCurve);
}
int arrowDirection = 0;
if (participant.getType().equals(Type.LEFT)) {
arrowDirection = -1;
} else if (participant.getType().equals(Type.RIGHT)) {
arrowDirection = 1;
}
if (arrowDirection == 1) {
double arcLength = integrateArcLength(cubicCurve, 0.0, 1.0, 10);
double centerT = getParameterAtArcLength(cubicCurve, 0.0, 1.0, arcLength / 2, 20);
Point2D center = evaluate(cubicCurve, centerT);
double backT = intersectWithCircle(cubicCurve, centerT, 1.0, center.getX(), center.getY(), 4);
Point2D back = evaluate(cubicCurve, backT);
double frontT = intersectWithCircle(cubicCurve, centerT, 0.0, center.getX(), center.getY(), 4);
Point2D front = evaluate(cubicCurve, frontT);
GeneralPath arrow = getArrow(front, back, 7);
g2d.fill(arrow);
}
if (arrowDirection == -1) {
double arcLength = integrateArcLength(cubicCurve, 0.0, 1.0, 10);
double centerT = getParameterAtArcLength(cubicCurve, 0.0, 1.0, arcLength / 2 + 2, 20);
Point2D center = evaluate(cubicCurve, centerT);
double backT = intersectWithCircle(cubicCurve, centerT, 0.0, center.getX(), center.getY(), 4);
Point2D back = evaluate(cubicCurve, backT);
double frontT = intersectWithCircle(cubicCurve, centerT, 1.0, center.getX(), center.getY(), 4);
Point2D front = evaluate(cubicCurve, frontT);
GeneralPath arrow = getArrow(front, back, 7);
g2d.fill(arrow);
}
// draw label (nothing expected, we don't have stoichiometry around here)
if (getLabel() != null && getLabel().length() > 0) {
int x = start.x + (int) (start.x * correctionFactor);
int y = start.y + (int) (start.y * correctionFactor);
g2d.drawString(getLabel(), (x + end.x) / 2, (y + end.y) / 2);
}
// TODO: there are types other than LEFT, RIGHT, CONTROLLER, COFACTOR, we need to draw something for them too
// we'll add code for that as we find them
//
// Keeping below the simple code that only draws straight line
//
// Point startPos = interactionShape.getSpaceManager().getAbsCenter();
// Point endPos = physicalEntityShape.getSpaceManager().getAbsCenter();
//
// if(participant.getType().equals(Type.CONTROLLER) || participant.getType().equals(Type.COFACTOR)) {
// Stroke previousStroke = g2d.getStroke();
// g2d.setStroke(CATALYST_STROKE);
// g2d.drawLine(startPos.x, startPos.y, endPos.x, endPos.y);
// g2d.setStroke(previousStroke);
// } else {
// g2d.drawLine(startPos.x, startPos.y, endPos.x, endPos.y);
//
// }
// if(participant.getType().equals(Type.LEFT)) {
// ArrowPainter.paintArrow(g2d, endPos, startPos, ARROW_LENGTH, ARROW_WIDTH);
// } else if(participant.getType().equals(Type.RIGHT)) {
// ArrowPainter.paintArrow(g2d, startPos, endPos, ARROW_LENGTH, ARROW_WIDTH);
// }
// String label = getLabel();
// if(label != null) {
// g2d.drawString(label, xAbs + labelPos.x, yAbs + labelPos.y);
// }
g2d.setColor(oldColor);
g2d.setRenderingHints(oldRenderingHints);
}
use of java.awt.Stroke in project vcell by virtualcell.
the class EdgeShape method paint0.
private void paint0(Graphics2D g2D, int xPos, int yPos) {
// render curve (make CatalystShapes draw with a dashed line)
g2D.setColor(forgroundColor);
if (getLineStyle() == LINE_STYLE_DASHED) {
Stroke oldStroke = g2D.getStroke();
g2D.setStroke(DASHED_STROKE);
g2D.draw(getCurve());
g2D.setStroke(oldStroke);
} else {
g2D.draw(getCurve());
}
// draw label
if (getLabel() != null && getLabel().length() > 0) {
g2D.drawString(getLabel(), (start.x + end.x) / 2, (start.y + end.y) / 2);
}
return;
}
Aggregations