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


Java Graphics.create方法代码示例

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


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

示例1: paintIcon

import java.awt.Graphics; //导入方法依赖的package包/类
@Override
public void paintIcon(java.awt.Component c, Graphics g, int x, int y) {
	// draw tool icon
	Graphics gIcon = g.create();
	ComponentDrawContext context = new ComponentDrawContext(c, null, null, g, gIcon);
	comp.getFactory().paintIcon(context, x, y, comp.getAttributeSet());
	gIcon.dispose();

	if (triangleState != TRIANGLE_NONE) {
		int[] xp;
		int[] yp;
		if (triangleState == TRIANGLE_CLOSED) {
			xp = new int[] { x + 13, x + 13, x + 17 };
			yp = new int[] { y + 11, y + 19, y + 15 };
		} else {
			xp = new int[] { x + 11, x + 19, x + 15 };
			yp = new int[] { y + 13, y + 13, y + 17 };
		}
		g.setColor(Color.LIGHT_GRAY);
		g.fillPolygon(xp, yp, 3);
		g.setColor(Color.DARK_GRAY);
		g.drawPolygon(xp, yp, 3);
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:25,代码来源:ComponentIcon.java

示例2: print

import java.awt.Graphics; //导入方法依赖的package包/类
@Override public int print(Graphics default_graphics, PageFormat pageFormat, int pageIndex) throws PrinterException {
	List<Image> images = getPrintPages(pageFormat);
	if(pageIndex>=images.size())
		return NO_SUCH_PAGE;
	Graphics2D graphics = (Graphics2D)default_graphics.create();
	graphics.translate(pageFormat.getImageableX(),
			pageFormat.getImageableY());
	graphics.drawImage(images.get(pageIndex), 0, 0, null);
	Thread.yield(); //yield shortly, so that the image is painted
	return PAGE_EXISTS;
}
 
开发者ID:kristian,项目名称:JDigitalSimulator,代码行数:12,代码来源:Simulation.java

示例3: paintIcon

import java.awt.Graphics; //导入方法依赖的package包/类
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
    int w = getIconWidth();
    int h = getIconHeight();

    GeneralPath path = new GeneralPath();
    path.moveTo(0, h / 2);
    double segment = w / 3d;
    path.curveTo(segment, -h * 0.3, 2 * segment, h * 1.3, w, h / 2);

    Graphics2D g2 = (Graphics2D) g.create();
    g2.translate(x, y);
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
    g2.setColor(c.getForeground());
    g2.setStroke(new BasicStroke(thickness));
    g2.draw(path);
    g2.dispose();
}
 
开发者ID:iapafoto,项目名称:DicomViewer,代码行数:20,代码来源:ThicknessIcon.java

示例4: paintConstraints

import java.awt.Graphics; //导入方法依赖的package包/类
/**
 * Paints additional information about component constraints.
 * 
 * @param g graphics to use for painting.
 */
private void paintConstraints(Graphics g) {
    Point shift = fromComponentPane(new Point());
    Graphics gClip = g.create();
    Rectangle paneRect = fromComponentPane(new Rectangle(new Point(), componentPane.getSize()));
    gClip.clipRect(paneRect.x, paneRect.y, paneRect.width, paneRect.height);
    gClip.translate(shift.x, shift.y);
    for (Component comp : componentPane.getComponents()) {
        if (GridUtils.isPaddingComponent(comp)) {
            continue;
        }
        boolean selected = selection.contains(comp);
        gridInfo.paintConstraints(gClip, comp, selected);
    }
    gClip.dispose();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:GlassPane.java

示例5: paintRotated

import java.awt.Graphics; //导入方法依赖的package包/类
public static void paintRotated(Graphics g, int x, int y, Direction dir, Icon icon, Component dest) {
	if (!(g instanceof Graphics2D) || dir == Direction.EAST) {
		icon.paintIcon(dest, g, x, y);
		return;
	}

	Graphics2D g2 = (Graphics2D) g.create();
	double cx = x + icon.getIconWidth() / 2.0;
	double cy = y + icon.getIconHeight() / 2.0;
	if (dir == Direction.WEST) {
		g2.rotate(Math.PI, cx, cy);
	} else if (dir == Direction.NORTH) {
		g2.rotate(-Math.PI / 2.0, cx, cy);
	} else if (dir == Direction.SOUTH) {
		g2.rotate(Math.PI / 2.0, cx, cy);
	} else {
		g2.translate(-x, -y);
	}
	icon.paintIcon(dest, g2, x, y);
	g2.dispose();
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:22,代码来源:Icons.java

示例6: paintSubcircuit

import java.awt.Graphics; //导入方法依赖的package包/类
public void paintSubcircuit(Graphics g, Direction facing) {
	Direction defaultFacing = getFacing();
	double rotate = 0.0;
	if (facing != defaultFacing && g instanceof Graphics2D) {
		rotate = defaultFacing.toRadians() - facing.toRadians();
		((Graphics2D) g).rotate(rotate);
	}
	Location offset = findAnchorLocation();
	g.translate(-offset.getX(), -offset.getY());
	for (CanvasObject shape : getObjectsFromBottom()) {
		if (!(shape instanceof AppearanceElement)) {
			Graphics dup = g.create();
			shape.paint(dup, null);
			dup.dispose();
		}
	}
	g.translate(offset.getX(), offset.getY());
	if (rotate != 0.0) {
		((Graphics2D) g).rotate(-rotate);
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:22,代码来源:CircuitAppearance.java

示例7: paintBorder

import java.awt.Graphics; //导入方法依赖的package包/类
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
    int thick = getThickness();
    if (!(g instanceof Graphics2D)) {
        return;
    }
    
    Graphics2D g2d = (Graphics2D)g.create();
    if (thick >= 1) {
        g2d.setColor(this.lineColor);
        int x2 = x + width - ((thick +1) / 2);
        g2d.drawLine(x2 - SIDEBAR_GAP_WIDTH, 
                0, x2 - SIDEBAR_GAP_WIDTH, y + height - 1);
    }
    g2d.setColor(textBkColor);
    int gap = width - SIDEBAR_GAP_WIDTH;
    g2d.drawRect(gap, 0, width - gap, height);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:CustomizableSideBar.java

示例8: paintIcon

import java.awt.Graphics; //导入方法依赖的package包/类
public void paintIcon(Component c, Graphics g, int x, int y) {
    Graphics2D g2d = (Graphics2D) g.create();
    
    g2d.setColor(Color.WHITE);
    g2d.fillRect(x +1 ,y + 1,width -2 ,height -2);
    
    g2d.setColor(Color.BLACK);
    g2d.drawRect(x +1 ,y + 1,width -2 ,height -2);
    
    g2d.setColor(Color.RED);
    
    g2d.setStroke(stroke);
    g2d.drawLine(x +10, y + 10, x + width -10, y + height -10);
    g2d.drawLine(x +10, y + height -10, x + width -10, y + 10);
    
    g2d.dispose();
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:18,代码来源:MissingIcon.java

示例9: paintComponent

import java.awt.Graphics; //导入方法依赖的package包/类
@Override
public void paintComponent(Graphics graphics) {
	super.paintComponent(graphics);

	int pixWidth = getWidth() - 2 * MARGIN;
	int pixHeight = getHeight() - 2 * MARGIN - this.updatePanelHeight - 50;
	Graphics2D translated = (Graphics2D) graphics.create();
	translated.translate(MARGIN, MARGIN);
	paintGraph(translated, pixWidth, pixHeight);

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

示例10: criaQuadrado

import java.awt.Graphics; //导入方法依赖的package包/类
public BufferedImage criaQuadrado(BufferedImage img, PosicoesDTO posicoes) {
	Graphics graphics = img.getGraphics();
	Graphics2D graphics2d = (Graphics2D) graphics.create();
	graphics2d.setStroke(new BasicStroke(4));
	graphics2d.setColor(Color.BLUE);

	int x1 = posicoes.getX1();
	int x2 = posicoes.getX2();
	int y1 = posicoes.getY1();
	int y2 = posicoes.getY2();

	graphics2d.drawPolygon(new int[] { x1, x1, x2, x2 }, new int[] { y1, y2, y2, y1 }, 4);
	graphics2d.dispose();
	return img;
}
 
开发者ID:nbfontana,项目名称:pdi,代码行数:16,代码来源:Quadrado.java

示例11: paintComponent

import java.awt.Graphics; //导入方法依赖的package包/类
@Override
protected void paintComponent(Graphics g) {
    Graphics2D g2 = (Graphics2D)g.create();
    g2.setPaint(new GradientPaint(new Point(0, 0), Color.WHITE, new Point(0, getHeight()), isEnabled() ? getBackground() : Color.LIGHT_GRAY));
    g2.fillRect(0, 0, getWidth(), getHeight());
    g2.dispose();

    super.paintComponent(g);
}
 
开发者ID:Entwicklerpages,项目名称:school-game,代码行数:10,代码来源:MetalGradientButton.java

示例12: paintIcon

import java.awt.Graphics; //导入方法依赖的package包/类
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
    Dimension size = c.getSize();
    Graphics g2 = g.create(size.width / 2 - 5, size.height / 2 - 5, 10, 10);
    g2.setColor(Color.GRAY);
    g2.drawPolygon(xPoints, yPoints, 3);
    if (c.isEnabled()) {
        g2.setColor(Color.BLACK);
        g2.fillPolygon(xPoints, yPoints, 3);
    }
    g2.dispose();
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:13,代码来源:MenuScroller.java

示例13: paintBorder

import java.awt.Graphics; //导入方法依赖的package包/类
@Override
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
	Graphics2D g2d = (Graphics2D) g.create();
	g2d.setRenderingHints(ProcessDrawer.HI_QUALITY_HINTS);
	g2d.setStroke(new BasicStroke(2f));

	// clear edges, otherwise they will be in the color of the component background
	if (drawRoundFrame && !c.getBackground().equals(c.getParent().getBackground())) {
		Shape frame = new Rectangle2D.Float(x + 2, y + 2, width - 4, height - 4);
		g2d.setPaint(c.getParent().getBackground());
		g2d.draw(frame);
	}

	g2d.setPaint(paint);
	g2d.setFont(new Font("Dialog", Font.BOLD, 21));

	if (drawRoundFrame) {
		Shape roundFrame = new RoundRectangle2D.Float(x + 2, y + 2, width - 4, height - 4, 10, 10);
		g2d.draw(roundFrame);
	}

	if (number > 0) {
		Shape circle = new Ellipse2D.Float(20, 20, 34, 34);
		g2d.fill(circle);
		g2d.setPaint(Color.WHITE);
		g2d.drawString(String.valueOf(number), 29, 44);
	}

	if (key != null) {
		g2d.setPaint(paint);
		g2d.drawString(key, 60, 44);
	}

	g2d.dispose();
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:36,代码来源:RoundTitledBorder.java

示例14: paint

import java.awt.Graphics; //导入方法依赖的package包/类
@Override
public void paint(Graphics g, Selection selection) {
	Set<CanvasObject> suppressed = selection.getDrawsSuppressed();
	for (CanvasObject shape : getObjectsFromBottom()) {
		Graphics dup = g.create();
		if (suppressed.contains(shape)) {
			selection.drawSuppressed(dup, shape);
		} else {
			shape.paint(dup, null);
		}
		dup.dispose();
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:14,代码来源:Drawing.java

示例15: print

import java.awt.Graphics; //导入方法依赖的package包/类
/**
 * 
 * @param g
 *            the graphics object
 * @param pageFormat
 *            the page format
 * @param width
 *            the downscaled width
 * @param height
 *            the downscaled height
 * @param pageIndex
 *            the page index that should be printed
 */
public int print(Graphics g, double x, double y, double width, double height, int pageIndex) {
	if (pageIndex >= components.length) {
		return NO_SUCH_PAGE;
	}

	String title = components[pageIndex].getExportName();
	if (title == null) {
		title = LicenseTools.translateProductName(ProductConstraintManager.INSTANCE.getActiveLicense());
	}
	Rectangle2D rect = TITLE_FONT.getStringBounds(title, ((Graphics2D) g).getFontRenderContext());
	g.setFont(TITLE_FONT);
	int stringX = (int) (x + width / 2 - rect.getWidth() / 2);
	int stringY = (int) (y - rect.getY());
	g.drawString(title, stringX, stringY);

	// remove string rect height from graphic pane
	height = height - rect.getHeight() * 2;

	Graphics2D translated = (Graphics2D) g.create((int) x, (int) (y + rect.getHeight() * 2), (int) width, (int) height);

	double widthFactor = width / components[pageIndex].getExportComponent().getWidth();
	double heightFactor = height / components[pageIndex].getExportComponent().getHeight();
	double scaleFactor = Math.min(widthFactor, heightFactor);
	translated.scale(scaleFactor, scaleFactor);
	components[pageIndex].getExportComponent().print(translated);
	translated.dispose();
	return PAGE_EXISTS;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:42,代码来源:ComponentPrinter.java


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