本文整理汇总了Java中prefuse.util.GraphicsLib.intersectLineRectangle方法的典型用法代码示例。如果您正苦于以下问题:Java GraphicsLib.intersectLineRectangle方法的具体用法?Java GraphicsLib.intersectLineRectangle怎么用?Java GraphicsLib.intersectLineRectangle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类prefuse.util.GraphicsLib
的用法示例。
在下文中一共展示了GraphicsLib.intersectLineRectangle方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: paintLink
import prefuse.util.GraphicsLib; //导入方法依赖的package包/类
private void paintLink(Point2D start, Point2D end, Color color, Graphics2D g2d, RowBrowser tableBrowser, boolean pbg, boolean intersect,
Set<Long> lineHashes, boolean dotted) {
g2d.setColor(color);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
BasicStroke stroke = new BasicStroke(!intersect ? (pbg ? 3 : 1) : (pbg ? 5 : 3));
g2d.setStroke(dotted ? new BasicStroke(stroke.getLineWidth(), stroke.getEndCap(), stroke.getLineJoin(), stroke.getMiterLimit(), new float[] { 2f, 6f },
1.0f) : stroke);
AffineTransform t = new AffineTransform();
t.setToRotation(Math.PI / 4);
Point2D p = new Point2D.Double(), shift = new Point2D.Double();
double d = start.distance(end) / 3.0;
p.setLocation((end.getX() - start.getX()) / d, (end.getY() - start.getY()) / d);
t.transform(p, shift);
start.setLocation(start.getX() + shift.getX(), start.getY() + shift.getY());
end.setLocation(end.getX() + shift.getX(), end.getY() + shift.getY());
// compute the intersection with the target bounding box
if (intersect) {
Point2D[] sect = new Point2D[10];
int i = GraphicsLib.intersectLineRectangle(start, end, tableBrowser.internalFrame.getBounds(), sect);
if (i == 0)
return;
end = sect[0];
}
if (start.distance(end) < 2)
return;
long lineHash = ((long) start.hashCode()) + (((long) Integer.MAX_VALUE) + 1) * ((long) end.hashCode());
if (lineHashes.contains(lineHash)) {
return;
}
lineHashes.add(lineHash);
// create the arrow head shape
m_arrowHead = new Polygon();
double ws = 0.5;
double hs = 2.0 / 3.0;
double w = !intersect ? (pbg ? 3 : 3) : (pbg ? 3 : 3), h = w;
m_arrowHead.addPoint(0, 0);
m_arrowHead.addPoint((int) (ws * -w), (int) (hs * (-h)));
// m_arrowHead.addPoint(0, (int) (hs * (-2 * h)));
m_arrowHead.addPoint((int) (ws * w), (int) (hs * (-h)));
m_arrowHead.addPoint(0, 0);
AffineTransform at = getArrowTrans(start, end, 10);
Shape m_curArrow = at.createTransformedShape(m_arrowHead);
Point2D lineEnd = end;
lineEnd.setLocation(0, -2);
at.transform(lineEnd, lineEnd);
g2d.drawLine((int) start.getX(), (int) start.getY(), (int) end.getX(), (int) end.getY());
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setStroke(new BasicStroke(1));
g2d.fill(m_curArrow);
if (pbg) {
g2d.draw(m_curArrow);
}
}
示例2: getRawShape
import prefuse.util.GraphicsLib; //导入方法依赖的package包/类
@Override
protected Shape getRawShape(VisualItem item) {
EdgeItem edge = (EdgeItem)item;
VisualItem item1 = edge.getSourceItem();
VisualItem item2 = edge.getTargetItem();
int type = m_edgeType;
getAlignedPoint(m_tmpPoints[0], item1.getBounds(),
m_xAlign1, m_yAlign1);
getAlignedPoint(m_tmpPoints[1], item2.getBounds(),
m_xAlign2, m_yAlign2);
m_curWidth = (float)(m_width * getLineWidth(item));
// create the arrow head, if needed
EdgeItem e = (EdgeItem)item;
if ( e.isDirected() && m_edgeArrow != Constants.EDGE_ARROW_NONE ) {
// get starting and ending edge endpoints
boolean forward = (m_edgeArrow == Constants.EDGE_ARROW_FORWARD);
Point2D start = null, end = null;
start = m_tmpPoints[forward?0:1];
end = m_tmpPoints[forward?1:0];
// compute the intersection with the target bounding box
VisualItem dest = forward ? e.getTargetItem() : e.getSourceItem();
int i = GraphicsLib.intersectLineRectangle(start, end,
dest.getBounds(), m_isctPoints);
if ( i > 0 ) end = m_isctPoints[0];
// create the arrow head shape
AffineTransform at = getArrowTrans(start, end, m_curWidth);
m_curArrow = at.createTransformedShape(m_arrowHead);
// update the endpoints for the edge shape
// need to bias this by arrow head size
Point2D lineEnd = m_tmpPoints[forward?1:0];
lineEnd.setLocation(0, -m_arrowHeight);
at.transform(lineEnd, lineEnd);
} else {
m_curArrow = null;
}
// create the edge shape
Shape shape = null;
double n1x = m_tmpPoints[0].getX();
double n1y = m_tmpPoints[0].getY();
double n2x = m_tmpPoints[1].getX();
double n2y = m_tmpPoints[1].getY();
switch ( type ) {
case Constants.EDGE_TYPE_LINE:
m_line.setLine(n1x, n1y, n2x, n2y);
shape = m_line;
break;
case Constants.EDGE_TYPE_CURVE:
getCurveControlPoints(edge, m_ctrlPoints,n1x,n1y,n2x,n2y);
m_cubic.setCurve(n1x, n1y,
m_ctrlPoints[0].getX(), m_ctrlPoints[0].getY(),
m_ctrlPoints[1].getX(), m_ctrlPoints[1].getY(),
n2x, n2y);
shape = m_cubic;
break;
default:
throw new IllegalStateException("Unknown edge type");
}
// return the edge shape
return shape;
}
示例3: getRawShape
import prefuse.util.GraphicsLib; //导入方法依赖的package包/类
/**
* @see prefuse.render.AbstractShapeRenderer#getRawShape(prefuse.visual.VisualItem)
*/
protected Shape getRawShape(VisualItem item) {
EdgeItem edge = (EdgeItem)item;
VisualItem item1 = edge.getSourceItem();
VisualItem item2 = edge.getTargetItem();
int type = m_edgeType;
getAlignedPoint(m_tmpPoints[0], item1.getBounds(),
m_xAlign1, m_yAlign1);
getAlignedPoint(m_tmpPoints[1], item2.getBounds(),
m_xAlign2, m_yAlign2);
m_curWidth = (float)(m_width * getLineWidth(item));
// create the arrow head, if needed
EdgeItem e = (EdgeItem)item;
if ( e.isDirected() && m_edgeArrow != Constants.EDGE_ARROW_NONE ) {
// get starting and ending edge endpoints
boolean forward = (m_edgeArrow == Constants.EDGE_ARROW_FORWARD);
Point2D start = null, end = null;
start = m_tmpPoints[forward?0:1];
end = m_tmpPoints[forward?1:0];
// compute the intersection with the target bounding box
VisualItem dest = forward ? e.getTargetItem() : e.getSourceItem();
int i = GraphicsLib.intersectLineRectangle(start, end,
dest.getBounds(), m_isctPoints);
if ( i > 0 ) end = m_isctPoints[0];
// create the arrow head shape
AffineTransform at = getArrowTrans(start, end, m_curWidth);
m_curArrow = at.createTransformedShape(m_arrowHead);
// update the endpoints for the edge shape
// need to bias this by arrow head size
Point2D lineEnd = m_tmpPoints[forward?1:0];
lineEnd.setLocation(0, -m_arrowHeight);
at.transform(lineEnd, lineEnd);
} else {
m_curArrow = null;
}
// create the edge shape
Shape shape = null;
double n1x = m_tmpPoints[0].getX();
double n1y = m_tmpPoints[0].getY();
double n2x = m_tmpPoints[1].getX();
double n2y = m_tmpPoints[1].getY();
switch ( type ) {
case Constants.EDGE_TYPE_LINE:
m_line.setLine(n1x, n1y, n2x, n2y);
shape = m_line;
break;
case Constants.EDGE_TYPE_CURVE:
getCurveControlPoints(edge, m_ctrlPoints,n1x,n1y,n2x,n2y);
m_cubic.setCurve(n1x, n1y,
m_ctrlPoints[0].getX(), m_ctrlPoints[0].getY(),
m_ctrlPoints[1].getX(), m_ctrlPoints[1].getY(),
n2x, n2y);
shape = m_cubic;
break;
default:
throw new IllegalStateException("Unknown edge type");
}
// return the edge shape
return shape;
}