本文整理汇总了Java中org.eclipse.draw2d.Graphics.drawLine方法的典型用法代码示例。如果您正苦于以下问题:Java Graphics.drawLine方法的具体用法?Java Graphics.drawLine怎么用?Java Graphics.drawLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.draw2d.Graphics
的用法示例。
在下文中一共展示了Graphics.drawLine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: outlineShape
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected void outlineShape(Graphics graphics) {
Rectangle r = getBounds();
int x = r.x + getLineWidth() / 2;
int y = r.y + getLineWidth() / 2;
int w = r.width - Math.max(1, getLineWidth());
int h = r.height - Math.max(1, getLineWidth());
Rectangle bounds = new Rectangle(x, y, w, h);
Point topRight1 = bounds.getTopRight().translate(0, RETURN_WIDTH);
Point topRight2 = bounds.getTopRight().translate(-RETURN_WIDTH, 0);
Point topRight3 = bounds.getTopRight().translate(-RETURN_WIDTH,
RETURN_WIDTH);
graphics.drawLine(bounds.getTopLeft(), bounds.getBottomLeft());
graphics.drawLine(bounds.getBottomLeft(), bounds.getBottomRight());
graphics.drawLine(bounds.getBottomRight(), topRight1);
graphics.drawLine(topRight1, topRight2);
graphics.drawLine(topRight2, bounds.getTopLeft());
graphics.drawLine(topRight2, topRight3);
graphics.drawLine(topRight3, topRight1);
}
示例2: paintFigure
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
protected void paintFigure(Graphics graphics) {
super.paintFigure(graphics);
graphics.pushState();
if(axis.isShowMajorGrid()){
graphics.setLineStyle(axis.isDashGridLine()? SWTConstants.LINE_DASH : SWTConstants.LINE_SOLID);
graphics.setForegroundColor(axis.getMajorGridColor());
graphics.setLineWidth(1);
for(int pos: axis.getScaleTickLabels().getTickLabelPositions()){
if(axis.isHorizontal())
graphics.drawLine(axis.getBounds().x + pos, bounds.y + bounds.height,
axis.getBounds().x + pos, bounds.y);
else
graphics.drawLine(bounds.x, axis.getBounds().y + axis.getBounds().height - pos, bounds.x + bounds.width,
axis.getBounds().y + axis.getBounds().height - pos);
}
}
graphics.popState();
}
示例3: paintFigure
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
* @see nexcore.tool.uml.ui.core.diagram.figure.AbstractNotationNodeFigure#paintFigure(org.eclipse.draw2d.Graphics)
*/
@Override
protected void paintFigure(Graphics graphics) {
super.paintFigure(graphics);
graphics.drawRectangle(getLocation().x, getLocation().y, getSize().width - 1, getSize().height - 1);
graphics.setAntialias(SWT.ON);
Rectangle bounds = getBounds();
if(isDangling()){
graphics.setForegroundColor(ColorConstants.red);
graphics.drawOval(bounds.x, bounds.y, 12, 12);
graphics.drawLine(bounds.x + 2, bounds.y + 2, bounds.x + 10, bounds.y + 10);
graphics.drawLine(bounds.x + 10, bounds.y + 2, bounds.x + 2, bounds.y + 10);
}
}
示例4: paintFigure
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
protected void paintFigure(Graphics g) {
super.paintFigure(g);
final int LEG = 5;
Rectangle r = getBounds();
g.setLineWidth(1);
g.setForegroundColor(valid ? ColorConstants.black : PandionJConstants.Colors.ERROR);
g.drawLine(r.x, r.y, r.x, r.y+r.height-1);
g.drawLine(r.x, r.y, r.x+LEG, r.y);
g.drawLine(r.x, r.y+r.height-1, r.x+LEG, r.y+r.height-1);
g.drawLine(r.x+r.width-1, r.y, r.x+r.width-1, r.y+r.height);
g.drawLine(r.x+r.width-1, r.y, r.x+r.width-1-LEG, r.y);
g.drawLine(r.x+r.width-1, r.y+r.height-1, r.x+r.width-1-LEG, r.y+r.height-1);
if(!valid) {
g.setForegroundColor(PandionJConstants.Colors.ERROR);
String text = "Invalid matrix";
int textWidth = FigureUtilities.getTextWidth(text, g.getFont());
Point p = r.getLocation().translate(r.width/2 - textWidth/2, 5);
g.drawText(text, p);
}
}
示例5: paintFigure
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
protected void paintFigure(Graphics g) {
super.paintFigure(g);
Rectangle r = getBounds();
Rectangle square = new Rectangle(r.getLocation().getTranslated(0, r.height/4), new Dimension(r.width/2, r.height/2));
center = new Point(square.x + square.width/2, square.y + square.height/2);
g.setBackgroundColor(dirty ? PandionJConstants.Colors.HIGHLIGHT : PandionJConstants.Colors.VARIABLE_BOX);
g.fillRectangle(square);
g.setForegroundColor(ref.getRole() == Role.FIXED_VALUE ? PandionJConstants.Colors.CONSTANT : ColorConstants.black);
g.drawRectangle(square);
g.setBackgroundColor(error ? PandionJConstants.Colors.ERROR : ColorConstants.black);
g.fillOval(center.x-3, center.y-3, 7, 7);
if(isnull) {
g.setForegroundColor(error ? PandionJConstants.Colors.ERROR : ColorConstants.black);
Point dest = center.getTranslated(20, 0);
g.drawLine(center, dest);
g.drawLine(dest.getTranslated(-3, 5), dest.getTranslated(3, -5));
}
}
示例6: outlineShape
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected void outlineShape(final Graphics graphics) {
final Rectangle r = getBounds();
final int x = r.x + getLineWidth() / 2;
final int y = r.y + getLineWidth() / 2;
final int w = r.width - Math.max(1, getLineWidth());
final int h = r.height - Math.max(1, getLineWidth());
final Rectangle bounds = new Rectangle(x, y, w, h);
final Point topRight1 = bounds.getTopRight().translate(0, RETURN_WIDTH);
final Point topRight2 = bounds.getTopRight().translate(-RETURN_WIDTH, 0);
final Point topRight3 = bounds.getTopRight().translate(-RETURN_WIDTH, RETURN_WIDTH);
graphics.drawLine(bounds.getTopLeft(), bounds.getBottomLeft());
graphics.drawLine(bounds.getBottomLeft(), bounds.getBottomRight());
graphics.drawLine(bounds.getBottomRight(), topRight1);
graphics.drawLine(topRight1, topRight2);
graphics.drawLine(topRight2, bounds.getTopLeft());
graphics.drawLine(topRight2, topRight3);
graphics.drawLine(topRight3, topRight1);
}
示例7: outlineShape
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
protected void outlineShape(Graphics graphics) {
final Rectangle r = getBounds();
final int x = r.x + getLineWidth() / 2;
final int y = r.y + getLineWidth() / 2;
final int w = r.width - Math.max(1, getLineWidth());
final int h = r.height - Math.max(1, getLineWidth());
final Rectangle bounds = new Rectangle(x, y, w, h);
final Point topRight1 = bounds.getTopRight().translate(0, RETURN_WIDTH);
final Point topRight2 = bounds.getTopRight().translate(-RETURN_WIDTH, 0);
final Point topRight3 = bounds.getTopRight().translate(-RETURN_WIDTH, RETURN_WIDTH);
graphics.drawLine(bounds.getTopLeft(), bounds.getBottomLeft());
graphics.drawLine(bounds.getBottomLeft(), bounds.getBottomRight());
graphics.drawLine(bounds.getBottomRight(), topRight1);
graphics.drawLine(topRight1, topRight2);
graphics.drawLine(topRight2, bounds.getTopLeft());
graphics.drawLine(topRight2, topRight3);
graphics.drawLine(topRight3, topRight1);
}
示例8: paintFigure
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
* Paints this Figure's primary representation, or background
*
* @param graphics
* The Graphics used to paint
*/
protected void paintFigure(Graphics graphics) {
Rectangle rect = getBounds().getCopy();
graphics.setXORMode(true);
graphics.setForegroundColor(ColorConstants.white);
graphics.setBackgroundColor(CustomColorRegistry.INSTANCE.getColorFromRegistry( 31, 31, 31));
graphics.translate(getLocation());
PointList outline = new PointList();
outline.addPoint(0, 0);
outline.addPoint(rect.width - getCornerSize(), 0);
outline.addPoint(rect.width - 1, getCornerSize());
outline.addPoint(rect.width - 1, rect.height - 1);
outline.addPoint(0, rect.height - 1);
graphics.fillPolygon(outline);
// draw the inner outline
PointList innerLine = new PointList();
innerLine.addPoint(rect.width - getCornerSize() - 1, 0);
innerLine.addPoint(rect.width - getCornerSize() - 1, getCornerSize());
innerLine.addPoint(rect.width - 1, getCornerSize());
innerLine.addPoint(rect.width - getCornerSize() - 1, 0);
innerLine.addPoint(0, 0);
innerLine.addPoint(0, rect.height - 1);
innerLine.addPoint(rect.width - 1, rect.height - 1);
innerLine.addPoint(rect.width - 1, getCornerSize());
graphics.drawPolygon(innerLine);
graphics.drawLine(rect.width - getCornerSize() - 1, 0, rect.width - 1, getCornerSize());
graphics.translate(getLocation().getNegated());
}
示例9: paintFigure
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
protected void paintFigure(Graphics g) {
super.paintFigure(g);
g.setForegroundColor(ColorConstants.gray);
Rectangle r = getBounds();
g.drawLine(r.getTopLeft(), r.getBottomRight());
}
示例10: drawArrow
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
private void drawArrow(Graphics g, Point from, Point to) {
g.setLineStyle(Graphics.LINE_SOLID);
g.drawLine(from, to);
int yy = from.y < to.y ? -ARROW_EDGE : ARROW_EDGE;
g.drawLine(to, to.getTranslated(-ARROW_EDGE, yy));
g.drawLine(to, to.getTranslated(ARROW_EDGE, yy));
}
示例11: drawBar
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
private void drawBar(Graphics g, Integer boundVal, IBound bound, Direction direction) {
if(direction != Direction.NONE) {
Point origin = getIndexLocation(boundVal);
int s;
boolean b = direction == Direction.FORWARD && bound.getType() == BoundType.CLOSE ||
direction == Direction.BACKWARD && bound.getType() == BoundType.OPEN;
if(horizontal){
s = firstLabelBounds.width/2 + PandionJConstants.ARRAY_POSITION_SPACING;
if(!b)
s = -s;
}else{
s = firstPositionBounds.height/2 + PandionJConstants.ARRAY_POSITION_SPACING;
if(!b)
s = -s;
}
origin.translate(horizontal ? s : 0, horizontal ? 0 : s);
Point from = origin.getTranslated(horizontal ? 0 : -BAR_HEIGHT, horizontal ? -BAR_HEIGHT : 0);;
Point to = origin.getTranslated(horizontal ? 0 : BAR_HEIGHT, horizontal ? BAR_HEIGHT : 0);
setIllustrationStyle(g);
g.drawLine(from, to);
}
}
示例12: drawArrow
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
private void drawArrow(Point from, Point to, int pWidth, boolean right, Graphics graphics) {
Point arrowTo = to.getTranslated(right ? 0 : pWidth/2, 0);
graphics.drawLine(from.getTranslated(right ? pWidth : 0, pWidth), arrowTo);
Point a = arrowTo.getTranslated(right ? -ARROW_EDGE : ARROW_EDGE, -ARROW_EDGE);
graphics.drawLine(arrowTo, a);
a = a.getTranslated(0, ARROW_EDGE*2);
graphics.drawLine(arrowTo, a);
}
示例13: paintBorder
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
@Override
protected void paintBorder(Graphics graphics) {
super.paintBorder(graphics);
for(IArrayIndexModel v : vars.values()) {
if(v.getBound() != null) {
Point origin = getIndexLocation(v.getBound().getValue());
Point from = origin.getTranslated(0, -100);
Point to = origin.getTranslated(0, 100);
graphics.drawLine(from, to);
}
}
}
示例14: paintConnection
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
protected void paintConnection(Graphics graphics, HyVersion superseded) {
Date date = ((DwGraphicalFeatureModelViewer)editor).getCurrentSelectedDate();
HyFeature feature = superseded.getFeature();
DwVersionTreeLayouter versionTreeLayouter = DwVersionLayouterManager.getLayouter(feature, date);
for(HyVersion superseding : HyEvolutionUtil.getValidTemporalElements(superseded.getSupersedingVersions(), date)){
Rectangle sb = versionTreeLayouter.getBounds(superseded);
Rectangle ss = versionTreeLayouter.getBounds(superseding);
Point supersedeedLocation = sb.getCenter();
Point supersedingLocation = ss.getCenter();
supersedeedLocation.x += sb.width / 2;
supersedingLocation.x -= sb.width / 2;
DEGraphicalEditorTheme theme = DEGraphicalEditor.getTheme();
graphics.setForegroundColor(theme.getLineColor());
graphics.setLineWidth(theme.getLineWidth());
graphics.setLineWidth(2);
Point start = new Point(supersedeedLocation.x + getLocation().x, supersedeedLocation.y + getLocation().y);
Point end = new Point(supersedingLocation.x + this.getLocation().x, supersedingLocation.y + getLocation().y);
graphics.drawLine(start, end);
paintConnection(graphics, superseding);
}
}
示例15: paintFigure
import org.eclipse.draw2d.Graphics; //导入方法依赖的package包/类
/**
* Override to render the circle without background and with dotted outline
*/
@Override
protected void paintFigure(Graphics graphics) {
Rectangle bounds = getBounds().getCopy();
Rectangle realBounds = bounds.getCopy();
int offset = (int)(HIDDEN_CHILDREN_INDICATOR_SIZE * 0.5);
bounds.setY(bounds.y + offset);
bounds.setHeight(bounds.width);
//Compensate for line width
int lineWidth = outlineWidth / 2;
bounds.expand(-lineWidth, -lineWidth);
DEGraphicalEditorTheme theme = DEGraphicalEditor.getTheme();
graphics.setLineStyle(SWT.LINE_CUSTOM);
graphics.setLineDash(new int[] {4});
graphics.setLineWidth(theme.getLineWidth());
graphics.setForegroundColor(theme.getLineColor());
Point topLeft = realBounds.getTopLeft();
Point bottomLeft = realBounds.getBottomLeft();
graphics.drawLine(new Point(topLeft.x+offset-theme.getLineWidth() / 2, topLeft.y),
new Point(bottomLeft.x+offset-theme.getLineWidth() / 2, bottomLeft.y-HIDDEN_CHILDREN_INDICATOR_SIZE));
DEDrawingUtil.outlineEllipsis(graphics, bounds, outlineColor);
}