本文整理汇总了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);
}
}
示例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);
}
}
示例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();
}
示例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();
}
示例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);
}
示例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)
};
}
示例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);
}
示例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();
}
}
示例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));
}
示例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.
}
}
}
示例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);
}
示例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);
}
示例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;
}
}
}
示例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;
}
}
}
示例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;
}