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


Java Graphics2D.fillPolygon方法代码示例

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


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

示例1: paintComponent

import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D) g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    int w = getWidth(), h = getHeight(), h2 = h / 2;
    x[0] = w - 6;
    x[1] = w - 9;
    x[2] = w - 12;
    y[0] = y[2] = h2 - 1;
    y[1] = h2 + 2;
    g2.setColor(Color.black);
    g2.fillPolygon(x, y, 3);

    g2.setColor(Color.gray);
    g2.drawLine(w - 18, 3, w - 18, h - 4);

    paintSelection(g2, w - 18, h);
}
 
开发者ID:iapafoto,项目名称:DicomViewer,代码行数:21,代码来源:SelectorButton.java

示例2: drawDragArea

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * Draw a semi-trasparet area
 * @param g The graphic object
 * @param dragPoint The first point
 * @param beginPoint The second point
 * @param c The color of the area
 */
public void drawDragArea(Graphics2D g, Point dragPoint, Point beginPoint, Color c) {
	g.setColor(c);

	Polygon poly = new Polygon();

	poly.addPoint((int) beginPoint.getX(), (int) beginPoint.getY());
	poly.addPoint((int) beginPoint.getX(), (int) dragPoint.getY());
	poly.addPoint((int) dragPoint.getX(), (int) dragPoint.getY());
	poly.addPoint((int) dragPoint.getX(), (int) beginPoint.getY());

	//Set the widths of the shape's outline
	Stroke oldStro = g.getStroke();
	Stroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
	g.setStroke(stroke);
	g.drawPolygon(poly);
	g.setStroke(oldStro);

	//Set the trasparency of the iside of the rectangle
	Composite oldComp = g.getComposite();
	Composite alphaComp = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.4f);
	g.setComposite(alphaComp);
	g.fillPolygon(poly);
	g.setComposite(oldComp);

}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:33,代码来源:PainterConvex2D.java

示例3: DrawComplexPath

import java.awt.Graphics2D; //导入方法依赖的package包/类
private boolean DrawComplexPath(Graphics2D g, int l, int t) {
        String[] dist = getPath().split(",");
        int dl = dist.length;
        if (dl < 3) {
            g.drawString("?", l, t);
            return false;
        }
        if (dl % 2 > 0) {
            String[] tmp = new String[dl + 1];
            tmp[dl] = "0";
            dist = tmp;
            dl = dist.length;
        }
        int tam = dl / 2;
        int xPoints[] = new int[tam];
        int yPoints[] = new int[tam];
        try {
            int y = 0;
            for (int i = 0; i < tam; i++) {
                xPoints[i] = Expr(dist[y++].trim());
                yPoints[i] = Expr(dist[y++].trim());
//                xPoints[i] = l + Integer.valueOf(dist[y++].trim());
//                yPoints[i] = t + Integer.valueOf(dist[y++].trim());
            }
        } catch (Exception x) {
            g.drawString("?", l, t);
            return false;
        }
        if (isFill()) {
            g.fillPolygon(xPoints, yPoints, tam);
        } else {
            g.drawPolygon(xPoints, yPoints, tam);
        }
        return true;
    }
 
开发者ID:chcandido,项目名称:brModelo,代码行数:36,代码来源:baseDrawerItem.java

示例4: drawArrow

import java.awt.Graphics2D; //导入方法依赖的package包/类
public void drawArrow(Graphics g1, int x1, int y1, int x2, int y2) {
    Graphics2D g = (Graphics2D) g1.create();

    double dx = x2 - x1, dy = y2 - y1;
    double angle = Math.atan2(dy, dx);
    int len = (int) Math.sqrt(dx*dx + dy*dy);
    AffineTransform at = AffineTransform.getTranslateInstance(x1, y1);
    at.concatenate(AffineTransform.getRotateInstance(angle));
    g.transform(at);

    g.drawLine(0, 0, len, 0);
    g.fillPolygon(new int[] {len+2, len-(ARR_SIZE*2+1), len-(ARR_SIZE*2+1), len+2},
                  new int[] {0, -(ARR_SIZE-1), ARR_SIZE-1, 0}, 4);
}
 
开发者ID:kevingilboy,项目名称:COE1186,代码行数:15,代码来源:TrackRenderWindow.java

示例5: drawMaskedOffRectangle

import java.awt.Graphics2D; //导入方法依赖的package包/类
public void drawMaskedOffRectangle(Graphics2D g, Point2D point, Color color) {
	Polygon poly = new Polygon();

	poly.addPoint(plane.getTrueX(0), plane.getTrueY(0));
	poly.addPoint(plane.getTrueX(0), plane.getTrueY(point.getY()));
	poly.addPoint(plane.getTrueX(point.getX()),
			plane.getTrueY(point.getY()));
	poly.addPoint(plane.getTrueX(point.getX()), plane.getTrueY(0));

	g.setStroke(LINES);
	g.setColor(color);
	g.fillPolygon(poly);
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:14,代码来源:Convex2DGraph.java

示例6: paintComponent

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * paint the text area
 * @param arg0 iwas
 */
@Override
protected void paintComponent(Graphics arg0) {
    super.paintComponent(arg0);
    Graphics2D graphics = (Graphics2D) arg0;
    if(inTheTriangleZone) {
        graphics.setColor(new Color(0.5f, 0.5f, 0.5f, 0.75f));
    } else {
        graphics.setColor(new Color(0.5f, 0.5f, 0.5f, 0.2f));
    }
    graphics.fillPolygon(getTriangle());
}
 
开发者ID:Panzer1119,项目名称:JAddOn,代码行数:16,代码来源:JExpandableTextArea.java

示例7: paintComponent

import java.awt.Graphics2D; //导入方法依赖的package包/类
protected void paintComponent(Graphics g) {  
            super.paintComponent(g);  
            Graphics2D g2 = (Graphics2D) g;  
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,  
                    RenderingHints.VALUE_ANTIALIAS_ON);  
            int h = getHeight();  
            int width = getWidth();
        	Polygon arrow = new Polygon();
//        	Polygon leftArrow = new Polygon();

//                g2.drawImage(closed, PAD, 0, h, h, this); 
            g2.setFont(font);  
            FontRenderContext frc = g2.getFontRenderContext();  
            LineMetrics lm = font.getLineMetrics(title, frc);  
            float height = lm.getAscent() + lm.getDescent();  
            float x = OFFSET;  
            float y = (h + height) / 2 - lm.getDescent();  
            g2.drawString(title, x, y);
            int th = ((int)height)-2;
            if (selected) {
            	arrow.addPoint(width - 3*th/2 + 1, h/2 - th/4);
            	arrow.addPoint(width - th/2 - 1, h/2 - th/4);
            	arrow.addPoint(width - th, h/2 + th/4 );
            	g2.fillPolygon(arrow);
            }
//                g2.drawImage(open, PAD, 0, h, h, this); 
            else { 
            	arrow.addPoint(width - 3*th/4, h/2 - (th-2)/2);
            	arrow.addPoint(width - 3*th/4, h/2 + (th-2)/2);
            	arrow.addPoint(width - 5*th/4, h /2);
            	g2.fillPolygon(arrow);
            }
        }
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:34,代码来源:CollapsablePanel.java

示例8: test

import java.awt.Graphics2D; //导入方法依赖的package包/类
private static void test(final Graphics2D g, final int[] arr) {
    g.drawPolygon(arr, arr, arr.length);
    g.drawPolygon(new Polygon(arr, arr, arr.length));
    g.fillPolygon(arr, arr, arr.length);
    g.fillPolygon(new Polygon(arr, arr, arr.length));
    g.drawPolyline(arr, arr, arr.length);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:Test8004821.java

示例9: paintWidget

import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
public void paintWidget() {   
    ObjectState os = this.getState();       
    if(!os.isHovered() && !os.isSelected()) return; //all previewEdges visible and not hovering, 
                                                    //no need to paint the switch         
    float hw = width/2;    
    Polygon pol = new Polygon();
    pol.addPoint(0,(int) -height/2); 
    pol.addPoint((int)hw,(int) height/2);
    pol.addPoint((int)-hw,(int) height/2);  
    Graphics2D gr = getGraphics();
    gr.setColor(this.getForeground());
    BasicStroke bs = new BasicStroke(2.0f, BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND);
    gr.setStroke(bs);
    AffineTransform previousTransform;
    previousTransform = gr.getTransform ();
    if(output) {
        if(os.isSelected() ){//hidden
             gr.scale(1.0, -1.0);
        }
    } else { //input switch
        if(os.isHovered() && !os.isSelected()){
             gr.scale(1.0, -1.0);
        }     
    }            
    gr.fillPolygon(pol);
    gr.setTransform(previousTransform);
    
}
 
开发者ID:arodchen,项目名称:MaxSim,代码行数:30,代码来源:EdgeSwitchWidget.java

示例10: paintComponent

import java.awt.Graphics2D; //导入方法依赖的package包/类
public void paintComponent(Graphics g) {
    Graphics2D g2d = (Graphics2D)g.create();

    int w = getWidth();
    int h = getHeight();
    g2d.setColor(Color.black);
    g2d.fillRect(0, 0, w, h);

    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                         antialiasHint);
    g2d.setRenderingHint(RenderingHints.KEY_RENDERING,
                         renderHint);

    g2d.transform(transform);
    g2d.setPaint(paint);

    switch (shapeType) {
    default:
    case RECT:
        g2d.fillRect(0, 0, w, h);
        break;

    case ELLIPSE:
        g2d.fillOval(0, 0, w, h);
        break;

    case MULTIPLE:
        g2d.fillRect(0, 0, w/2, h/2);
        g2d.fillOval(w/2, 0, w/2, h/2);
        g2d.drawOval(0, h/2, w/2, h/2);
        g2d.drawLine(0, h/2, w/2, h);
        g2d.drawLine(0, h, w/2, h/2);
        Polygon p = new Polygon();
        p.addPoint(w/2, h);
        p.addPoint(w, h);
        p.addPoint(3*w/4, h/2);
        g2d.fillPolygon(p);
        break;
    }

    switch (paintType) {
    default:
    case BASIC:
    case LINEAR:
        g2d.setColor(Color.white);
        g2d.fillRect(startX-1, startY-1, 2, 2);
        g2d.drawString("1", startX, startY + 12);
        g2d.fillRect(endX-1, endY-1, 2, 2);
        g2d.drawString("2", endX, endY + 12);
        break;

    case RADIAL:
        g2d.setColor(Color.white);
        g2d.fillRect(ctrX-1, ctrY-1, 2, 2);
        g2d.drawString("C", ctrX, ctrY + 12);
        g2d.fillRect(focusX-1, focusY-1, 2, 2);
        g2d.drawString("F", focusX, focusY + 12);
        break;
    }

    g2d.dispose();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:63,代码来源:MultiGradientTest.java

示例11: drawCond

import java.awt.Graphics2D; //导入方法依赖的package包/类
public static void drawCond(
		Graphics2D g2d,
		int circleCondX, int circleCondY,
		int triangleCondX, int triangleCondY,
		int lineCondStartX, int lineCondEndX,
		char trianglePos, int addToLineX, int addToLineY) {
		
	g2d.setColor(Constants.CONDITION_RELATION_COLOR);
	
	// circle
	g2d.fillOval(circleCondX - Constants.DOT_SIZE / 2, circleCondY - Constants.DOT_SIZE /2, Constants.DOT_SIZE, Constants.DOT_SIZE);
	
	// triangle
	Point pCond1 = new Point(triangleCondX, triangleCondY);
	int pResp2X = 0;
	int pResp3X = 0;
	int pResp2Y = 0;
	int pResp3Y = 0;
	
	switch(trianglePos) {
	  	case 'U':
			pResp2X = pCond1.x - Constants.TRIANGLE_HEIGHT / 2;
			pResp3X = pCond1.x + Constants.TRIANGLE_HEIGHT / 2;
			pResp2Y = pCond1.y + Constants.TRIANGLE_HEIGHT;
			pResp3Y = pCond1.y + Constants.TRIANGLE_HEIGHT;
			break;
	  	case 'D':
			pResp2X = pCond1.x - Constants.TRIANGLE_HEIGHT / 2;
			pResp3X = pCond1.x + Constants.TRIANGLE_HEIGHT / 2;
			pResp2Y = pCond1.y - Constants.TRIANGLE_HEIGHT;
			pResp3Y = pCond1.y - Constants.TRIANGLE_HEIGHT;
			break;
		case 'L':
			pResp2X = pCond1.x + Constants.TRIANGLE_HEIGHT;
			pResp3X = pCond1.x + Constants.TRIANGLE_HEIGHT;
			pResp2Y = pCond1.y - Constants.TRIANGLE_HEIGHT / 2;
			pResp3Y = pCond1.y + Constants.TRIANGLE_HEIGHT / 2;
			break;
		case 'R':
	  		pResp2X = pCond1.x - Constants.TRIANGLE_HEIGHT;
	  		pResp3X = pCond1.x - Constants.TRIANGLE_HEIGHT;
	  		pResp2Y = pCond1.y - Constants.TRIANGLE_HEIGHT / 2;
	  		pResp3Y = pCond1.y + Constants.TRIANGLE_HEIGHT / 2;
	  		break;
	}
	  
	Point pCond2 = new Point(pResp2X, pResp2Y);
	Point pCond3 = new Point(pResp3X, pResp3Y);
	int[] xsCond = {pCond1.x, pCond2.x, pCond3.x};
	int[] ysCond = {pCond1.y, pCond2.y, pCond3.y};
	g2d.fillPolygon(xsCond, ysCond, 3);
	
	// line
    g2d.drawLine(circleCondX + addToLineX, circleCondY + addToLineY, lineCondStartX, lineCondEndX);
}
 
开发者ID:tslaats,项目名称:SE2017-Team1,代码行数:56,代码来源:TestUtil.java

示例12: paintBox

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * Draws the combobox itself.
 */
private void paintBox(Graphics g, JComponent c) {
	int w = c.getWidth();
	int h = c.getHeight() - 1;
	if (w <= 0 || h <= 0) {
		return;
	}

	Graphics2D g2 = (Graphics2D) g;
	g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

	if (c.isEnabled()) {
		if (Boolean.parseBoolean(String.valueOf(c.getClientProperty(RapidLookTools.PROPERTY_INPUT_BACKGROUND_DARK)))) {
			g2.setColor(Colors.COMBOBOX_BACKGROUND_DARK);
		} else {
			g2.setColor(Colors.COMBOBOX_BACKGROUND);
		}
	} else {
		g2.setColor(Colors.COMBOBOX_BACKGROUND_DISABLED);
	}

	g2.fillRoundRect(0, 0, w - 1, h, RapidLookAndFeel.CORNER_DEFAULT_RADIUS, RapidLookAndFeel.CORNER_DEFAULT_RADIUS);

	// arrow
	int ny = c.getSize().height / 2 - 3;
	int nx = c.getWidth() - 15;

	if (isDown && c.isEnabled()) {
		nx++;
		ny++;
	}
	g2.translate(nx, ny);

	if (c.isEnabled()) {
		g2.setColor(Colors.COMBOBOX_ARROW);
	} else {
		g2.setColor(Colors.COMBOBOX_ARROW_DISABLED);
	}

	w = 14;
	Polygon arrow = new Polygon(new int[] { 0, 4, 8 }, new int[] { 0, 6, 0 }, 3);
	g2.fillPolygon(arrow);

	g2.translate(-nx, -ny);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:48,代码来源:ComboBoxUI.java

示例13: drawResp

import java.awt.Graphics2D; //导入方法依赖的package包/类
public static void drawResp(
		Graphics2D g2d,
		int circleRespX, int circleRespY,
		int triangleRespX, int triangleRespY,
		char trianglePos, int addToLineX, int addToLineY) {
		  
	g2d.setColor(Constants.RESPONSE_RELATION_COLOR);
		  
	// circle
	g2d.fillOval(circleRespX - Constants.DOT_SIZE / 2, circleRespY - Constants.DOT_SIZE /2, Constants.DOT_SIZE, Constants.DOT_SIZE);
	
	// triangle
	Point pResp1 = new Point(triangleRespX, triangleRespY);
	int pResp2X = 0;
	int pResp3X = 0;
	int pResp2Y = 0;
	int pResp3Y = 0;
	  
	switch(trianglePos) {
	  	case 'U':
	  		pResp2X = pResp1.x - Constants.TRIANGLE_HEIGHT / 2;
	  		pResp3X = pResp1.x + Constants.TRIANGLE_HEIGHT / 2;
	  		pResp2Y = pResp1.y + Constants.TRIANGLE_HEIGHT;
	  		pResp3Y = pResp1.y + Constants.TRIANGLE_HEIGHT;
	  		break;
	  	case 'D':
	  		pResp2X = pResp1.x - Constants.TRIANGLE_HEIGHT / 2;
	  		pResp3X = pResp1.x + Constants.TRIANGLE_HEIGHT / 2;
	  		pResp2Y = pResp1.y - Constants.TRIANGLE_HEIGHT;
	  		pResp3Y = pResp1.y - Constants.TRIANGLE_HEIGHT;
	  		break;
	  	case 'L':
	  		pResp2X = pResp1.x + Constants.TRIANGLE_HEIGHT;
	  		pResp3X = pResp1.x + Constants.TRIANGLE_HEIGHT;
	  		pResp2Y = pResp1.y - Constants.TRIANGLE_HEIGHT / 2;
	  		pResp3Y = pResp1.y + Constants.TRIANGLE_HEIGHT / 2;
	  		break;
	  	case 'R':
	  		pResp2X = pResp1.x - Constants.TRIANGLE_HEIGHT;
	  		pResp3X = pResp1.x - Constants.TRIANGLE_HEIGHT;
	  		pResp2Y = pResp1.y - Constants.TRIANGLE_HEIGHT / 2;
	  		pResp3Y = pResp1.y + Constants.TRIANGLE_HEIGHT / 2;
	  		break;
	}
	
	Point pResp2 = new Point(pResp2X, pResp2Y);
	Point pResp3 = new Point(pResp3X, pResp3Y);
	int[] xsResp = {pResp1.x, pResp2.x, pResp3.x};
	int[] ysResp = {pResp1.y, pResp2.y, pResp3.y};
	g2d.fillPolygon(xsResp, ysResp, 3);
	  
	// line
	g2d.drawLine(circleRespX + addToLineX, circleRespY + addToLineY, triangleRespX, triangleRespY);
}
 
开发者ID:tslaats,项目名称:SE2017-Team1,代码行数:55,代码来源:TestUtil.java

示例14: paintComponent

import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
public void paintComponent(Graphics g1){
	if(Main.config.showGraph){
		try{
			Graphics2D g = (Graphics2D)g1;
			g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
			g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC));
			if(ColorManager.transparency){
				g.setColor(ColorManager.transparent);
				g.fillRect(0, 0, this.getWidth(), this.getHeight());
				g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, Main.config.getBackgroundOpacity()));
				g.setColor(Main.config.getBackgroundColor());
				g.fillRect(0, 0, this.getWidth(), this.getHeight());
				g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, Main.config.getBackgroundOpacity()));
			}else{
				g.setColor(Main.config.getBackgroundColor());
				g.fillRect(0, 0, this.getWidth(), this.getHeight());
				g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0F));
			}
			Polygon poly = new Polygon();
			poly.addPoint(this.getWidth() - SizeManager.graphOffset - 2, this.getHeight() - SizeManager.graphOffset);
			for(int i = 1; i <= values.size(); i++){
				int px = (int) (SizeManager.graphOffset + 2 + ((double)(this.getWidth() - SizeManager.graphOffset * 2 - 4) / (double)(Main.config.backlog - 1)) * (Main.config.backlog - i));
				int py = (int) (this.getHeight() - SizeManager.graphOffset - ((float)(this.getHeight() - SizeManager.graphOffset * 2) * ((float)values.get(i - 1) / (float)maxval)));
				poly.addPoint(px, py);
				if(i == values.size()){
					poly.addPoint(px, this.getHeight() - SizeManager.graphOffset);
				}
			}
			g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, Main.config.getForegroundOpacity()));
			if(Main.config.graphAvg){
				int y = (int) (this.getHeight() - SizeManager.graphOffset - ((float)(this.getHeight() - SizeManager.graphOffset * 2) * (Main.avg / (float)maxval)));
				g.setColor(Main.config.getForegroundColor().darker());
				g.setStroke(avgstroke);
				g.drawLine(SizeManager.graphOffset + 2, y, this.getWidth() - SizeManager.graphOffset - 2, y);
			}
			g.setStroke(line);
			g.setColor(ColorManager.alphaAqua);
			g.fillPolygon(poly);
			g.setColor(Main.config.getForegroundColor());
			g.drawPolygon(poly);
			g.drawImage(ColorManager.graph_upper_left,   2, 2, 2 + SizeManager.graphImageSize, 2 + SizeManager.graphImageSize, 0, 0, 4, 4, this);
			g.drawImage(ColorManager.graph_lower_left,   2, this.getHeight() - 3 - SizeManager.graphImageSize, 2 + SizeManager.graphImageSize, this.getHeight() - 3, 0, 0, 4, 4, this);
			g.drawImage(ColorManager.graph_upper_right,  this.getWidth() - 3 - SizeManager.graphImageSize, 2, this.getWidth() - 3, 2 + SizeManager.graphImageSize, 0, 0, 4, 4, this);
			g.drawImage(ColorManager.graph_lower_right,  this.getWidth() - 3 - SizeManager.graphImageSize, this.getHeight() - 3 - SizeManager.graphImageSize, this.getWidth() - 3, this.getHeight() - 3, 0, 0, 4, 4, this);
			g.drawImage(ColorManager.graph_side_left,    2, 2 + SizeManager.graphImageSize, 2 + SizeManager.graphImageSize, this.getHeight() - 3 - SizeManager.graphImageSize, 0, 0, 4, 56, this);
			g.drawImage(ColorManager.graph_upper_middle, 2 + SizeManager.graphImageSize, 2, this.getWidth() - 3 - SizeManager.graphImageSize, 2 + SizeManager.graphImageSize, 0, 0, 46, 4, this);
			g.drawImage(ColorManager.graph_lower_middle, 2 + SizeManager.graphImageSize, this.getHeight() - 3 - SizeManager.graphImageSize, this.getWidth() - 3 - SizeManager.graphImageSize, this.getHeight() - 3, 0, 0, 46, 4, this);
			g.drawImage(ColorManager.graph_side_right,   this.getWidth() - 3 - SizeManager.graphImageSize, 2 + SizeManager.graphImageSize, this.getWidth() - 3, this.getHeight() - 3 - SizeManager.graphImageSize, 0, 0, 4, 56, this);
		}catch(NullPointerException e){
			//catch but do not solve, this is caused by the race
			//condition. However adding synchronisation would impact
			//performance more then it is worth
		}
	}
}
 
开发者ID:RoanH,项目名称:KeysPerSecond,代码行数:57,代码来源:GraphPanel.java

示例15: paint

import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
public void paint(Graphics2D g) {
    DataPlugin dp = ((NFunction) function).getDataPlugin();

    Row row = dp.findRowByGlobalId(function.getLink());
    final class PolygonD extends Polygon {
        /**
         *
         */
        private static final long serialVersionUID = 113232131232134523L;

        public void addPoint(final double x, final double y) {
            super.addPoint((int) x, (int) y);
        }
    }

    g.setColor(function.getBackground());
    final Rectangle2D rect = movingArea.getBounds(getBounds());
    g.fill(rect);
    g.setFont(function.getFont());
    paintText(g);

    if (row != null) {
        String string = row.getKod();

        movingArea.paintText(g, string,
                new FRectangle(myBounds.getX() + 3, myBounds.getY() + 3,
                        myBounds.getWidth() - 3, myBounds.getHeight() - 3),
                Line.LEFT_ALIGN, 0, true);
    }

    paintBorder(g);

    final Stroke tmp = g.getStroke();
    g.draw(rect);

    double zm = movingArea.getIDoubleOrdinate(2);

    g.draw(new Line2D.Double(rect.getX() + zm, rect.getY() + zm, rect
            .getX() + zm, rect.getY() + rect.getHeight()));
    g.draw(new Line2D.Double(rect.getX() + zm, rect.getY() + zm, rect
            .getX() + rect.getWidth(), rect.getY() + zm));

    if (paintTriangle >= 0) {
        final PolygonD p = new PolygonD();
        p.addPoint(rect.getX() + rect.getWidth() / 2,
                rect.getY() + rect.getHeight() / 2);
        int standoff2 = -1;
        switch (paintTriangle) {
            case Point.TOP: {
                p.addPoint(rect.getX() + standoff2, rect.getY() + standoff2);
                p.addPoint(rect.getX() + rect.getWidth() - standoff2,
                        rect.getY() + standoff2);
            }
            break;
            case Point.LEFT: {
                p.addPoint(rect.getX() + standoff2, rect.getY() + standoff2);
                p.addPoint(rect.getX() + standoff2,
                        rect.getY() + rect.getHeight() - standoff2);
            }
            break;
            case Point.RIGHT: {
                p.addPoint(rect.getX() + rect.getWidth() - standoff2,
                        rect.getY() + standoff2);
                p.addPoint(rect.getX() + rect.getWidth() - standoff2,
                        rect.getY() + rect.getHeight() - standoff2);
            }
            break;
            case Point.BOTTOM: {
                p.addPoint(rect.getX() + standoff2,
                        rect.getY() + rect.getHeight() - standoff2);
                p.addPoint(rect.getX() + rect.getWidth() - standoff2,
                        rect.getY() + rect.getHeight() - standoff2);
            }
            break;
        }
        if (p.npoints > 1)
            g.fillPolygon(p);
    }
    g.setStroke(tmp);
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:82,代码来源:External.java


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