当前位置: 首页>>代码示例>>Java>>正文


Java Graphics.drawLine方法代码示例

本文整理汇总了Java中java.awt.Graphics.drawLine方法的典型用法代码示例。如果您正苦于以下问题:Java Graphics.drawLine方法的具体用法?Java Graphics.drawLine怎么用?Java Graphics.drawLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.Graphics的用法示例。


在下文中一共展示了Graphics.drawLine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: drawMenuBezel

import java.awt.Graphics; //导入方法依赖的package包/类
private static void drawMenuBezel(Graphics g, Color background,
                                int x, int y,
                                int width, int height)
{
  // shadowed button region
  g.setColor(background);
  g.fillRect(x,y,width,height);

  g.setColor(background.brighter().brighter());
  g.drawLine(x+1,       y+height-1,  x+width-1, y+height-1);
  g.drawLine(x+width-1, y+height-2,  x+width-1, y+1);

  g.setColor(background.darker().darker());
  g.drawLine(x,   y,   x+width-2, y);
  g.drawLine(x,   y+1, x,         y+height-2);

}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:MotifGraphicsUtils.java

示例2: paintLoweredBevel

import java.awt.Graphics; //导入方法依赖的package包/类
protected void paintLoweredBevel(Component c, Graphics g, int x, int y, int width, int height) {
    Color oldColor = g.getColor();
    int h = height;
    int w = width;

    g.translate(x, y);

    g.setColor(getShadowInnerColor(c));
    g.drawLine(0, 0, 0, h - 1);
    g.drawLine(1, 0, w - 1, 0);

    g.setColor(getHighlightOuterColor(c));
    g.drawLine(1, h - 1, w - 1, h - 1);
    g.drawLine(w - 1, 1, w - 1, h - 2);

    g.translate(-x, -y);
    g.setColor(oldColor);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:ThinBevelBorder.java

示例3: drawGroove

import java.awt.Graphics; //导入方法依赖的package包/类
public static void drawGroove(Graphics g, int x, int y, int w, int h,
                              Color shadow, Color highlight)
{
    Color oldColor = g.getColor();  // Make no net change to g
    g.translate(x, y);

    g.setColor(shadow);
    g.drawRect(0, 0, w-2, h-2);

    g.setColor(highlight);
    g.drawLine(1, h-3, 1, 1);
    g.drawLine(1, 1, w-3, 1);

    g.drawLine(0, h-1, w-1, h-1);
    g.drawLine(w-1, h-1, w-1, 0);

    g.translate(-x, -y);
    g.setColor(oldColor);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:BasicGraphicsUtils.java

示例4: paintBorder

import java.awt.Graphics; //导入方法依赖的package包/类
/** This method is called by Swing to actually draw the borders. */
public void paintBorder(Component component, Graphics graphics, int x, int y, int width, int height) {
	if (width < 1 || height < 1)
		return;
	Color old = graphics.getColor();
	if (top != null) {
		graphics.setColor(top);
		graphics.drawLine(x, y, x + width - 1, y);
	}
	if (bottom != null) {
		graphics.setColor(bottom);
		graphics.drawLine(x, y + height - 1, x + width - 1, y + height - 1);
	}
	if (left != null) {
		graphics.setColor(left);
		graphics.drawLine(x, y, x, y + height - 1);
	}
	if (right != null) {
		graphics.setColor(right);
		graphics.drawLine(x + width - 1, y, x + width - 1, y + height - 1);
	}
	graphics.setColor(old);
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:24,代码来源:OurBorder.java

示例5: paintHorizontalSeparators

import java.awt.Graphics; //导入方法依赖的package包/类
protected void paintHorizontalSeparators(Graphics g, JComponent c) {
	Rectangle clipBounds = g.getClipBounds();

	int beginRow = getRowForPath(this.tree, getClosestPathForLocation(this.tree, 0, clipBounds.y));
	int endRow = getRowForPath(this.tree, getClosestPathForLocation(this.tree, 0, clipBounds.y + clipBounds.height - 1));

	if ((beginRow <= -1) || (endRow <= -1)) {
		return;
	}

	for (int i = beginRow; i <= endRow; ++i) {
		TreePath path = getPathForRow(this.tree, i);

		if ((path != null) && (path.getPathCount() == 2)) {
			Rectangle rowBounds = getPathBounds(this.tree, getPathForRow(this.tree, i));

			// Draw a line at the top
			if (rowBounds != null) {
				g.drawLine(clipBounds.x, rowBounds.y, clipBounds.x + clipBounds.width, rowBounds.y);
			}
		}
	}

}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:25,代码来源:TreeUI.java

示例6: drawLeftBorder

import java.awt.Graphics; //导入方法依赖的package包/类
/** Draws the FrameBorder's left border.
  */
protected boolean drawLeftBorder(Component c, Graphics g, int x, int y,
                       int width, int height) {
    Rectangle borderRect =
        new Rectangle(0, 0, getBorderInsets(c).left, height);
    if (!g.getClipBounds().intersects(borderRect)) {
        return false;
    }

    int startY = BORDER_SIZE;

    g.setColor(frameHighlight);
    g.drawLine(x, startY, x, height - 1);
    g.drawLine(x + 1, startY, x + 1, height - 2);

    g.setColor(frameColor);
    g.fillRect(x + 2, startY, x + 2, height - 3);

    g.setColor(frameShadow);
    g.drawLine(x + 4, startY, x + 4, height - 5);

    return true;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:MotifBorders.java

示例7: paint

import java.awt.Graphics; //导入方法依赖的package包/类
public void paint( Graphics g, JComponent c )
{
    Dimension s = c.getSize();

    if ( ((JSeparator)c).getOrientation() == JSeparator.VERTICAL )
    {
      g.setColor( c.getForeground() );
      g.drawLine( 0, 0, 0, s.height );

      g.setColor( c.getBackground() );
      g.drawLine( 1, 0, 1, s.height );
    }
    else  // HORIZONTAL
    {
      g.setColor( c.getForeground() );
      g.drawLine( 0, 0, s.width, 0 );

      g.setColor( c.getBackground() );
      g.drawLine( 0, 1, s.width, 1 );
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:22,代码来源:BasicSeparatorUI.java

示例8: markCenterOfMassAndBounds

import java.awt.Graphics; //导入方法依赖的package包/类
private static BufferedImage markCenterOfMassAndBounds(BufferedImage im, Point centerOfPixels, Rectangle bounds)
{
    Graphics g1 = im.createGraphics();
    g1.setColor(Color.RED);
    g1.drawOval(centerOfPixels.x, centerOfPixels.y, 5, 5);
    g1.drawRect(bounds.x, bounds.y, bounds.width, bounds.height);
    g1.setColor(Color.BLUE);
    g1.drawLine(centerOfPixels.x, centerOfPixels.y, im.getWidth() / 2, im.getHeight() / 2);
    return im;
}
 
开发者ID:mirkoruether,项目名称:DigitRecognizer,代码行数:11,代码来源:DigitManipulator.java

示例9: paint

import java.awt.Graphics; //导入方法依赖的package包/类
@Override public void paint(Graphics graphics) {
	if(input.isCharged()) {
		graphics.setColor(Color.RED);
		graphics.fillOval(5, 0, size.height, size.height);
	}
	graphics.setColor(Color.BLACK);
	graphics.drawOval(5, 0, size.height, size.height);
	int corner = (int)(Math.cos(Math.PI/4)*(size.height/2))-size.height/4+1;
	graphics.drawLine(5+corner, corner, 5+size.height-corner, size.height-corner);
	graphics.drawLine(5+corner, size.height-corner, 5+size.height-corner, corner);
	ContactUtilities.paintSolderingJoints(graphics, contacts);
}
 
开发者ID:kristian,项目名称:JDigitalSimulator,代码行数:13,代码来源:BinaryDisplay.java

示例10: paintBorder

import java.awt.Graphics; //导入方法依赖的package包/类
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
    int h = c.getHeight();
    Color col = g.getColor();
    g.setColor (UIManager.getColor("controlShadow")); //NOI18N
    if (left) {
        g.drawLine (x + 3, y, x + 3, y + h - 1);
    }
    if (right) {
        g.drawLine (x + width - 3, y, x + width - 3, y + h - 1);
    }
    g.drawLine (x, y, x + width - 1, y);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:InsetBorder.java

示例11: paintBorder

import java.awt.Graphics; //导入方法依赖的package包/类
public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
    g.translate( x, y );

    g.setColor( MetalLookAndFeel.getControlDarkShadow() );
    g.drawLine( w-1, 0, w-1, h-1 );
    g.drawLine( 1, h-1, w-1, h-1 );
    g.setColor( MetalLookAndFeel.getControlHighlight() );
    g.drawLine( 0, 0, w-2, 0 );
    g.drawLine( 0, 0, 0, h-2 );

    g.translate( -x, -y );
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:13,代码来源:MetalBorders.java

示例12: paintInstance

import java.awt.Graphics; //导入方法依赖的package包/类
@Override
public void paintInstance(InstancePainter painter) {
	Graphics g = painter.getGraphics();
	painter.drawRoundBounds(Color.WHITE);
	painter.drawPorts();

	GraphicsUtil.switchToWidth(g, 2);
	Location loc = painter.getLocation();
	int x = loc.getX() - 10;
	int y = loc.getY();
	g.drawLine(x - 2, y - 5, x - 2, y + 5);
	g.drawLine(x + 2, y - 5, x + 2, y + 5);
	g.drawLine(x - 5, y - 2, x + 5, y - 2);
	g.drawLine(x - 5, y + 2, x + 5, y + 2);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:16,代码来源:BitAdder.java

示例13: paintIcon

import java.awt.Graphics; //导入方法依赖的package包/类
@Override
public void paintIcon( Component c, Graphics g, int x, int y ) {
    g.setColor( Color.black );
    g.drawRect( x, y, size-1, size-1 );
    if( null == color ) {
        g.drawLine( x, y+size-1, x+size-1, y );
    } else {
        g.setColor( color );
        g.fillRect( x+1, y+1, size-2, size-2 );
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:ColorIcon.java

示例14: paintBorder

import java.awt.Graphics; //导入方法依赖的package包/类
public void paintBorder(Component c, Graphics g, int x, int y,
                        int width, int height) {
    g.setColor(shadow);
    g.drawLine(x,y, width-1,y); // draw top
    g.drawLine(x,y, x,height-1); // draw left
    g.setColor(highlight);
    g.drawLine(x,height-1, width-1,height-1); // draw bottom
    g.drawLine(width-1,y, width-1,height-1); // draw right
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:10,代码来源:WindowsBorders.java

示例15: print

import java.awt.Graphics; //导入方法依赖的package包/类
@Override
public void print(Graphics g, GraphicPanel f)
{
	if(highlight)
		g.setColor(ColorKraken.RED.color);
	else if(isBlocked())
		g.setColor(ColorKraken.NAVMESH_BLOCKED.color);
	g.drawLine(f.XtoWindow(points[0].position.getX()), f.YtoWindow(points[0].position.getY()), f.XtoWindow(points[1].position.getX()), f.YtoWindow(points[1].position.getY()));
}
 
开发者ID:PFGimenez,项目名称:The-Kraken-Pathfinding,代码行数:10,代码来源:NavmeshEdge.java


注:本文中的java.awt.Graphics.drawLine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。