本文整理汇总了Java中java.awt.geom.Rectangle2D.equals方法的典型用法代码示例。如果您正苦于以下问题:Java Rectangle2D.equals方法的具体用法?Java Rectangle2D.equals怎么用?Java Rectangle2D.equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.geom.Rectangle2D
的用法示例。
在下文中一共展示了Rectangle2D.equals方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: intersectsWithAnyCollisionBox
import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
protected boolean intersectsWithAnyCollisionBox(final ICollisionEntity entity, final Point2D start, final Point2D target) {
final List<Rectangle2D> allCollisionBoxes = Game.getPhysicsEngine().getAllCollisionBoxes();
final Line2D line = new Line2D.Double(start, target);
for (final Rectangle2D collisionBox : allCollisionBoxes) {
if (collisionBox.equals(entity.getCollisionBox())) {
continue;
}
// apply a margin for the path calculation in order to take the entities
// collision box into consideration
final Rectangle2D rectangleWithMargin = this.applyPathMargin(entity, collisionBox);
// if the start is in the margin, the margin is not considered when
// checking for collision because this will always return true
Point2D intersection = GeometricUtilities.getIntersectionPoint(line, rectangleWithMargin.contains(start) ? collisionBox : rectangleWithMargin);
if (intersection != null) {
return true;
}
}
return false;
}
示例2: createContext
import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
public PaintContext createContext(ColorModel cm,
Rectangle deviceBounds,
Rectangle2D userBounds,
AffineTransform xform,
RenderingHints hints)
{
System.out.println("user bounds = "+userBounds);
if (!userBounds.equals(expectedBounds)) {
throw new RuntimeException("bounds fail to match");
}
return c.createContext(cm, deviceBounds, userBounds, xform, hints);
}
示例3: setArea
import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
public synchronized void setArea( Rectangle2D bounds, double zoom ) {
if (bounds.equals(rect)) return;
rect = bounds;
Vector<Integer> v = new Vector<Integer>();
int[] s = ds.dataT.getSelectedRows();
for (int i=0;i<s.length;i++)
s[i] = displayToDataIndex.get(s[i]);
displayToDataIndex.removeAllElements();
double xMin = bounds.getX();
double xMax = xMin+bounds.getWidth();
double yMin = bounds.getY();
double yMax = yMin+bounds.getHeight();
double wrap = ds.map.getWrap();
int z = 0;
for(int i=0 ; i<ds.data.size() ; i++) {
UnknownData d = ds.data.get(i);
boolean inBounds = checkDataBounds(d, xMin, xMax, yMin, yMax, wrap);
if (!inBounds) inBounds = checkPolygonBounds(d, bounds, wrap);
if (!inBounds) {
if (z<s.length&&i==s[z]) z++;
continue;
}
displayToDataIndex.add(i);
if (z<s.length&&i==s[z]) {
v.add(displayToDataIndex.size()-1);
z++;
}
}
displayToDataIndex.trimToSize();
ds.dataT.getSelectionModel().removeListSelectionListener(ds);
// Each time we change the displayIndex we need to update
// the sort as well
if (lastSortedCol != -1) {
ascent = !ascent;
sortByColumn(lastSortedCol);
}
else {
updateRowToDisplayIndex();
fireTableDataChanged();
}
for (int i=0;i<v.size();i++) {
z = v.get(i).intValue();
ds.dataT.getSelectionModel().addSelectionInterval(z, z);
}
ds.dataT.getSelectionModel().addListSelectionListener(ds);
}
示例4: scanDrop
import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
@Override
protected void scanDrop(DockEvent event, boolean drop) {
if (getParent() instanceof TabbedDockableContainer) {
if (drop) {
((DockDropEvent) event).rejectDrop();
} else {
((DockDragEvent) event).delegateDrag();
}
return;
}
if (event.getDragSource().getDockable() == dockable) {
if (drop) {
((DockDropEvent) event).rejectDrop();
} else {
((DockDragEvent) event).rejectDrag();
}
return;
}
if (event.getDragSource().getDockableContainer() instanceof TabbedDockableContainer) {
if (drop) {
((DockDropEvent) event).rejectDrop();
} else {
((DockDragEvent) event).rejectDrag();
}
return;
}
Rectangle bounds = getBounds();
DockGroup sourceGroup = event.getDragSource().getDockable().getDockKey().getDockGroup();
DockGroup destinationGroup = dockable.getDockKey().getDockGroup();
if (!DockGroup.areGroupsCompatible(destinationGroup, sourceGroup)) {
if (drop) {
((DockDropEvent) event).rejectDrop();
} else {
((DockDragEvent) event).rejectDrag();
}
return;
}
Dockable sourceDockable = event.getDragSource().getDockable();
DockableState.Location dockableLocation = sourceDockable.getDockKey().getLocation();
DockableState.Location viewLocation = dockable.getDockKey().getLocation();
if (drop) {
event.setDockingAction(new DockingActionCreateTabEvent(event.getDesktop(), sourceDockable, dockableLocation,
viewLocation, dockable, 0));
((DockDropEvent) event).acceptDrop(false);
desktop.createTab(dockable, event.getDragSource().getDockable(), 0, true);
} else {
Rectangle2D r2d = new Rectangle2D.Float(bounds.x, bounds.y, bounds.width, bounds.height);
event.setDockingAction(new DockingActionCreateTabEvent(event.getDesktop(), sourceDockable, dockableLocation,
viewLocation, dockable, 0));
if (r2d.equals(lastDropShape)) {
((DockDragEvent) event).acceptDrag(lastDropGeneralPath);
} else {
GeneralPath path = buildPathForTab(bounds);
;
lastDropShape = r2d;
lastDropGeneralPath = path;
((DockDragEvent) event).acceptDrag(lastDropGeneralPath);
}
}
}
示例5: runTest
import java.awt.geom.Rectangle2D; //导入方法依赖的package包/类
private static void runTest() {
im = new BufferedImage(W, H, BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = im.createGraphics();
g2d.setColor(Color.white);
g2d.fillRect(0, 0, W, H);
g2d.setColor(Color.black);
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
char[] chs = "Sample Text.".toCharArray();
int len = chs.length;
int x = 50, y = 100;
FontRenderContext frc = g2d.getFontRenderContext();
Font plain = new Font("Serif", Font.PLAIN, 48);
GlyphVector pgv = plain.layoutGlyphVector(frc, chs, 0, len, 0);
g2d.setFont(plain);
g2d.drawChars(chs, 0, len, x, y); y +=50;
g2d.drawGlyphVector(pgv, x, y); y += 50;
Rectangle2D plainStrBounds = plain.getStringBounds(chs, 0, len, frc);
Rectangle2D plainGVBounds = pgv.getLogicalBounds();
Font bold = new Font("Serif", Font.BOLD, 48);
GlyphVector bgv = bold.layoutGlyphVector(frc, chs, 0, len, 0);
Rectangle2D boldStrBounds = bold.getStringBounds(chs, 0, len, frc);
Rectangle2D boldGVBounds = bgv.getLogicalBounds();
g2d.setFont(bold);
g2d.drawChars(chs, 0, len, x, y); y +=50;
g2d.drawGlyphVector(bgv, x, y);
System.out.println("Plain String Bounds = " + plainStrBounds);
System.out.println("Bold String Bounds = " + boldStrBounds);
System.out.println("Plain GlyphVector Bounds = " + plainGVBounds);
System.out.println("Bold GlyphVector Bounds = " + boldGVBounds);
if (!plainStrBounds.equals(boldStrBounds) &&
plainGVBounds.equals(boldGVBounds))
{
System.out.println("Test failed: Plain GV bounds same as Bold");
if (!interactive) {
throw new RuntimeException("Plain GV bounds same as Bold");
}
}
}