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


Java Area.intersect方法代码示例

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


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

示例1: paintTopLine

import java.awt.geom.Area; //导入方法依赖的package包/类
private static final void paintTopLine(Graphics g,
                                       WinXPEditorTabCellRenderer ren,
                                       TabPainter p) {
    Polygon poly = p.getInteriorPolygon(ren);
    ((Graphics2D) g).setPaint(getHighlightColor());
    g.setColor(getHighlightColor());
    Shape clip = g.getClip();
    Insets ins = p.getBorderInsets(ren);
    try {
        if (clip != null) {
            Area a = new Area(clip);
            a.intersect(new Area(poly));
            g.setClip(a);
        } else {
            g.setClip(poly);
        }
        g.fillRect(0, ins.top, ren.getWidth(), 3);
    } finally {
        g.setClip(clip);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:WinXPEditorTabCellRenderer.java

示例2: draw

import java.awt.geom.Area; //导入方法依赖的package包/类
public void draw(Graphics g, Rectangle bounds, Rectangle visibleRect, double scale, boolean reversed) {
  if ((getGrid() != null && getGrid().isVisible()) || highlighter != null) {
    final Graphics2D g2d = (Graphics2D) g;
    final Shape oldClip = g2d.getClip();
    final Area newClip = new Area(visibleRect);
    final Shape s = getCachedShape(myPolygon, bounds.x, bounds.y, scale);
    newClip.intersect(new Area(s));
    g2d.setClip(newClip);
    if (getGrid() != null && getGrid().isVisible()) {
      getGrid().draw(g, bounds, visibleRect, scale, reversed);
    }
    if (highlighter != null) {
      highlighter.draw(g2d, s, scale);
    }
    g2d.setClip(oldClip);
  }
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:18,代码来源:Zone.java

示例3: paintIcon

import java.awt.geom.Area; //导入方法依赖的package包/类
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
	Graphics2D g2d = (Graphics2D) g.create();
	g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
			RenderingHints.VALUE_ANTIALIAS_ON);
	g2d.translate(x, y);
					
	Area clip = new Area(new Rectangle(0, 0, this.width, this.height));		
	if (g2d.getClip() != null) clip.intersect(new Area(g2d.getClip()));		
	g2d.setClip(clip);

	double coef1 = (double) this.width / (double) getOrigWidth();
	double coef2 = (double) this.height / (double) getOrigHeight();
	double coef = Math.min(coef1, coef2);
	g2d.scale(coef, coef);
	paint(g2d);
	g2d.dispose();
}
 
开发者ID:victorward,项目名称:recruitervision,代码行数:19,代码来源:JapePlusIcon.java

示例4: hit

import java.awt.geom.Area; //导入方法依赖的package包/类
/**
 * Returns <code>true</code> if the rectangle (in device space) intersects
 * with the shape (the interior, if <code>onStroke</code> is false, 
 * otherwise the stroked outline of the shape).
 * 
 * @param rect  a rectangle (in device space).
 * @param s the shape.
 * @param onStroke  test the stroked outline only?
 * 
 * @return A boolean. 
 */
@Override
public boolean hit(Rectangle rect, Shape s, boolean onStroke) {
    AffineTransform transform = getTransform();
    Shape ts;
    if (onStroke) {
        Stroke stroke = getStroke();
        ts = transform.createTransformedShape(stroke.createStrokedShape(s));
    } else {
        ts = transform.createTransformedShape(s);
    }
    if (!rect.getBounds2D().intersects(ts.getBounds2D())) {
        return false;
    }
    Area a1 = new Area(rect);
    Area a2 = new Area(ts);
    a1.intersect(a2);
    return !a1.isEmpty();
}
 
开发者ID:mdzio,项目名称:ccu-historian,代码行数:30,代码来源:SWTGraphics2D.java

示例5: paintShapes

import java.awt.geom.Area; //导入方法依赖的package包/类
@Override
protected void paintShapes(Graphics g, int barRectWidth, int barRectHeight, Insets insets) {
    Graphics2D g2 = this.prepareAdapter(g);
    int iconX = barRectWidth - barRectHeight;
    int iconY = 0;
    float sectorWidth = (barRectWidth - tracker.getHeight()) * tracker.getPercentComplete();
    Shape outer = new Rectangle2D.Double(0, 0, barRectWidth - barRectHeight, barRectHeight);
    Shape sector = new Rectangle2D.Double(insets.left, insets.top, sectorWidth - insets.right * 2, barRectHeight - insets.bottom * 2);
    try {
        BufferedImage read = ImageIO.read(this.config.getIcon(descriptor.getIconPath()));
        g2.drawImage(read, iconX, iconY, tracker.getHeight(), tracker.getHeight(), null);
    } catch (IOException e) {
        e.printStackTrace();
    }
    Area foreground = new Area(sector);
    Area background = new Area(outer);

    foreground.intersect(background);
    g2.setPaint(descriptor.getForegroundColor());
    g2.fill(foreground);
    g2.dispose();
    this.paintString(g, 0, 0, barRectWidth - barRectHeight, barRectHeight, 0);
}
 
开发者ID:Exslims,项目名称:MercuryTrade,代码行数:24,代码来源:RIconHProgressBarTrackerUI.java

示例6: getInstructions

import java.awt.geom.Area; //导入方法依赖的package包/类
@Override
public Transition2DInstruction[] getInstructions(float progress,
		Dimension size) {
	
	int multiplier2 = -1;
	if(type==COUNTER_CLOCKWISE) 
		multiplier2 = 1;
	//for a good time, don't make multiplier1 = 0
	int multiplier1 = 0; //multiplier2;
	int k = Math.max(size.width,size.height);
	Area area = new Area(new Arc2D.Double(new Rectangle2D.Double(size.width/2-2*k,size.height/2-2*k,k*4,k*4),
			90+multiplier1*progress*360, multiplier2*progress*360,Arc2D.PIE));
	area.intersect(new Area(new Rectangle(0,0,size.width,size.height)));
	
	return new ImageInstruction[] {
			new ImageInstruction(true),
			new ImageInstruction(false, null, area)
	};
}
 
开发者ID:teddyted,项目名称:iSeleda,代码行数:20,代码来源:RadialWipeTransition2D.java

示例7: paintShapes

import java.awt.geom.Area; //导入方法依赖的package包/类
@Override
protected void paintShapes(Graphics g, int barRectWidth, int barRectHeight, Insets insets) {
    Graphics2D g2 = this.prepareAdapter(g);
    int iconX = 0;
    int iconY = 0;
    float sectorWidth = (barRectWidth - tracker.getHeight()) * tracker.getPercentComplete();
    Shape outer = new Rectangle2D.Double(tracker.getHeight(), 0, barRectWidth, barRectHeight);
    Shape sector = new Rectangle2D.Double(tracker.getHeight() + insets.left, insets.top, sectorWidth - insets.right * 2, barRectHeight - insets.bottom * 2);
    try {
        BufferedImage read = ImageIO.read(this.config.getIcon(descriptor.getIconPath()));
        g2.drawImage(read, iconX, iconY, tracker.getHeight(), tracker.getHeight(), null);
    } catch (IOException e) {
        e.printStackTrace();
    }
    Area foreground = new Area(sector);
    Area background = new Area(outer);

    foreground.intersect(background);
    g2.setPaint(descriptor.getForegroundColor());
    g2.fill(foreground);
    g2.dispose();
    this.paintString(g, barRectHeight / 2, 0, barRectWidth, barRectHeight, 0);
}
 
开发者ID:Exslims,项目名称:MercuryTrade,代码行数:24,代码来源:LIconHProgressBarTrackerUI.java

示例8: clip

import java.awt.geom.Area; //导入方法依赖的package包/类
/**
 * Clips to the intersection of the current clipping region and the
 * specified shape. 
 * 
 * According to the Oracle API specification, this method will accept a 
 * {@code null} argument, but there is an open bug report (since 2004) 
 * that suggests this is wrong:
 * <p>
 * <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6206189">
 * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6206189</a>
 * 
 * In this implementation, a {@code null} argument is not permitted.
 * 
 * @param s  the clip shape ({@code null} not permitted). 
 */
@Override
public void clip(Shape s) {
    if (this.clip == null) {
        setClip(s);
        return;
    }
    Shape ts = this.transform.createTransformedShape(s);
    Shape clipNew;
    if (!ts.intersects(this.clip.getBounds2D())) {
        clipNew = new Rectangle2D.Double();
    } else {
        Area a1 = new Area(ts);
        Area a2 = new Area(this.clip);
        a1.intersect(a2);
        clipNew = new Path2D.Double(a1);
    }
    this.clip = clipNew;
    if (!this.clippingDisabled) {
        this.gc.save();
        this.saveCount++;
        shapeToPath(this.clip);
        this.gc.clip();
    }
}
 
开发者ID:nick-paul,项目名称:aya-lang,代码行数:40,代码来源:FXGraphics2D.java

示例9: paint

import java.awt.geom.Area; //导入方法依赖的package包/类
public void paint( Graphics2D graphics2D ) {
        //        Shape leftViewShape=getTransform().createTransformedShape(leftPath);
//        clipGraphic.setModelClip(leftViewShape);
        Area a = new Area( leftPath );
        a.add( new Area( rightPath ) );
//        a.intersect( new Area( bandSet.getBounds() ) );
        a.intersect( new Area( getViewport() ) );
//        clipGraphic.setModelClip(leftPath);
        clipGraphic.setModelClip( a );
//        clipGraphic.setModelClip(bandRect);
        super.paint( graphics2D );

        //        BasicGraphicsSetup bgs=new BasicGraphicsSetup();
//        bgs.setup(graphics2D);
//
        graphics2D.setColor( Color.black );
        graphics2D.setStroke( new BasicStroke( 1 ) );
        Shape s = rightTear.getPath().getGeneralPath();
        Shape trf = getTransform().createTransformedShape( s );
        graphics2D.draw( trf );
        graphics2D.draw( getTransform().createTransformedShape( leftTear.getPath().getGeneralPath() ) );
//        graphics2D.setColor(Color.red);
//        graphics2D.draw(getTransform().createTransformedShape(leftPath));
    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:25,代码来源:JaggedSplitBandGraphic.java

示例10: getVoltage

import java.awt.geom.Area; //导入方法依赖的package包/类
public double getVoltage( Shape leftTip, Shape rightTip ) {
    Area tipIntersection = new Area( leftTip );
    tipIntersection.intersect( new Area( rightTip ) );
    if ( !tipIntersection.isEmpty() ) {
        return 0;
    }
    else {
        Connection red = getConnection( leftTip );
        Connection black = getConnection( rightTip );

        //Ignore wires & components loaded into a black box.
        if ( red != null && red.isBlackBox() ) {
            red = null;
        }
        if ( black != null && black.isBlackBox() ) {
            black = null;
        }

        if ( red == null || black == null ) {
            return Double.NaN;
        }
        else {
            return getVoltage( red, black );//dfs from one branch to the other, counting the voltage drop.
        }
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:27,代码来源:Circuit.java

示例11: blitBitmap

import java.awt.geom.Area; //导入方法依赖的package包/类
/**
 * Paint a backing bitmap into the specified rectangle of the passed
 * Graphics object.  Sets the clipping rectangle to match the coordinates
 * and loops until the rectangle has been filled with the texture.
 */
private static void blitBitmap(Graphics g, Icon icon, int x, int y, int w,
                               int h) {
    //Store the current clip to reset it after
    Shape clip = g.getClip();

    if (clip == null) {
        //Limit it to the space we're requested to paint
        g.setClip(x, y, w, h);
    } else {
        //If there is an existing clip, get the intersection with the
        //rectangle we want to paint and set that

        scratch.setBounds(x, y, w, h);
        Area area = new Area(clip);
        area.intersect(new Area(scratch));
        g.setClip(area);
    }
    int iwidth = icon.getIconWidth();
    int widthPainted = 0;
    while (widthPainted < w) {
        //Loop until we've covered the entire area
        icon.paintIcon(null, g, x + widthPainted, y);
        widthPainted += iwidth;
    }

    //restore the clip
    g.setClip(clip);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:34,代码来源:ColorUtil.java

示例12: drawOutline

import java.awt.geom.Area; //导入方法依赖的package包/类
private void drawOutline(Graphics2D g) {
       Shape s = getClipShape();
       g.setColor(dark());
       g.setStroke(new BasicStroke(0.95f));
       Rectangle r = getBounds();
       r.height += 1;

       Shape clip = g.getClip();
       if (clip != null) {
           Area a = new Area(clip);
           a.intersect(new Area(r));
           g.setClip(a);
       } else {
           g.setClip(r);
       }

       g.draw(s);
       g.setColor(getOutlineDark());

       r = getBounds();
       g.setStroke(new BasicStroke(0.70f));
if (getLowerRightArc() != 0) {
    g.drawLine(Math.max(r.x, r.x + getLowerLeftArc() - 3),
	r.y + r.height - 1, 
	Math.min(r.x + r.width - getLowerRightArc() + 3, r.x + r.width) - 1,
	r.y + r.height- 1);
} else {
    g.drawLine(Math.max(r.x, r.x + getLowerLeftArc() - 3),
	r.y + r.height - 1, 
	Math.min(r.x + r.width - getLowerRightArc() + 3, r.x + r.width),
	r.y + r.height- 1);
}
       g.setClip(clip);
   }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:35,代码来源:GenericGlowingChiclet.java

示例13: SynsetNodeShape

import java.awt.geom.Area; //导入方法依赖的package包/类
SynsetNodeShape() {
    Polygon p = new Polygon();
    p.addPoint(-50, 10);
    p.addPoint(-10, 15);
    p.addPoint(10, 15);
    p.addPoint(50, 10);
    p.addPoint(50, -10);
    p.addPoint(10, -15);
    p.addPoint(-10, -15);
    p.addPoint(-50, -10);

    shape = p;
    Rectangle rec = shape.getBounds();

    int left = rec.x;
    int top = rec.y;
    int width = rec.width;
    int height = rec.height;

    buttons[0] = new Area(new Polygon(new int[]{left, left, left + 10},
            new int[]{top, top + height + 10, 0}, 3));

    buttons[1] = new Area(new Polygon(new int[]{left + width,
            left + width, left + width - 10}, new int[]{top,
            top + height, 0}, 3));

    buttons[2] = new Area(new Polygon(new int[]{-10, 10, 0}, new int[]{
            top + height, top + height, 5}, 3));

    buttons[3] = new Area(new Polygon(new int[]{-10, 10, 0}, new int[]{
            top, top, -5}, 3));

    for (NodeDirection dir : NodeDirection.values()) {
        if (dir.ordinal() != 0) { // jeżeli IGNORE nic nie dodajemy
            Area tmp = new Area(buttons[dir.ordinal() - 1]);
            tmp.intersect(new Area(shape));
            buttons[dir.ordinal() - 1] = tmp;
        }
    }
}
 
开发者ID:CLARIN-PL,项目名称:WordnetLoom,代码行数:41,代码来源:SynsetNodeShape.java

示例14: SynsetNodeShape

import java.awt.geom.Area; //导入方法依赖的package包/类
SynsetNodeShape() {
    Polygon p = new Polygon();
    p.addPoint(-50, 10);
    p.addPoint(-10, 15);
    p.addPoint(10, 15);
    p.addPoint(50, 10);
    p.addPoint(50, -10);
    p.addPoint(10, -15);
    p.addPoint(-10, -15);
    p.addPoint(-50, -10);

    shape = p;
    Rectangle rec = shape.getBounds();

    int left = rec.x;
    int top = rec.y;
    int width = rec.width;
    int height = rec.height;

    buttons[0] = new Area(new Polygon(new int[]{left, left, left + 10},
            new int[]{top, top + height + 10, 0}, 3));

    buttons[1] = new Area(new Polygon(new int[]{left + width,
            left + width, left + width - 10}, new int[]{top,
            top + height, 0}, 3));

    buttons[2] = new Area(new Polygon(new int[]{-10, 10, 0}, new int[]{
            top + height, top + height, 5}, 3));

    buttons[3] = new Area(new Polygon(new int[]{-10, 10, 0}, new int[]{
            top, top, -5}, 3));

    for (NodeDirection dir : NodeDirection.values()) {
        if(dir.ordinal() !=  0){ // jeżeli IGNORE nic nie dodajemy
            Area tmp = new Area(buttons[dir.ordinal()-1]);
            tmp.intersect(new Area(shape));
            buttons[dir.ordinal()-1] = tmp;
        }
    }
}
 
开发者ID:CLARIN-PL,项目名称:WordnetLoom,代码行数:41,代码来源:SynsetNodeShape.java

示例15: doIntersectCAG

import java.awt.geom.Area; //导入方法依赖的package包/类
static MultiPolygon doIntersectCAG(MultiPolygon p1, MultiPolygon p2) {
    Area a1 = toArea(p1);
    Area a2 = toArea(p2);
    a1.intersect(a2);
    MultiPolygon ret = toMultiPolygon(a1);
    if (ret.getVertices().isEmpty()) {
        return null;
    }
    return ret;
}
 
开发者ID:opencadc,项目名称:caom2,代码行数:11,代码来源:PolygonUtil.java


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