下面列出了java.awt.Rectangle#intersects ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public void renderLine (Graphics2D g)
{
Rectangle clip = g.getClipBounds();
if ((clip == null) || clip.intersects(getBounds())) {
checkLine(); // To make sure the line has been computed
if (line != null) {
///g.draw(line);
g.draw(
new Line2D.Double(
line.getX1(),
line.getY1() + 0.5,
line.getX2() + 1,
line.getY2() + 0.5));
}
}
}
void select(int x, int y) {
Rectangle selection = gp.getDotMarkRectangle();
GraphNode[] nodes = gp.getModel().nodesArray();
for(int i = 0; i < nodes.length; i++) {
Component c = (Component)nodes[i].get(gp.COMPONENT);
if(selection.intersects(c.getBounds(tmpRect)))
gp.getSelectionModel().add(nodes[i]);
}
iiuf.util.graph.GraphEdge[] edges = gp.getModel().edgesArray();
for(int i = 0; i < edges.length; i++) {
GraphEdge e = (GraphEdge)edges[i].get(gp.GRAPH_EDGE);
if(e.intersectsWith(selection))
gp.getSelectionModel().add(edges[i]);
}
gp.setDot(x, y);
gp.setMark(x, y);
}
/**
* Paint the sheet.
*/
public void process ()
{
sigPainter = getSigPainter();
if (!sheet.getSystems().isEmpty()) {
for (SystemInfo system : sheet.getSystems()) {
// Check whether this system is visible
Rectangle bounds = system.getBounds();
if ((bounds != null) && ((clip == null) || bounds.intersects(clip))) {
processSystem(system);
}
}
}
}
/**
* Prepare the entity views for drawing. Must be called only from the event
* dispatch thread.
*
* @param area visible area
* @param setVisibleArea inform the entities about the visible area. This
* should be only done when the whole screen is drawn
*/
void prepareViews(Rectangle area, boolean setVisibleArea) {
visibleViews.clear();
synchronized (views) {
for (EntityView<IEntity> view : views) {
view.applyChanges();
if (area.intersects(view.getArea())) {
visibleViews.add(view);
if (setVisibleArea) {
view.setVisibleScreenArea(area);
}
}
}
}
Collections.sort(visibleViews, entityViewComparator);
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g;
Rectangle clip = g2.getClipBounds();
Rectangle r = new Rectangle(boxSize);
for (int i = 0; i < elements.size(); i++) {
r.x = (i % elementsPerRow) * r.width;
r.y = (i / elementsPerRow) * r.height;
if (r.intersects(clip)) {
getThumbElement(i).paint(g2, r);
}
}
}
/**
* ���̃X�v���C�g�ƐڐG���Ă��邩
* @param sprite �X�v���C�g
*/
public boolean isCollision(Sprite sprite) {
Rectangle playerRect = new Rectangle((int)x, (int)y, width, height);
Rectangle spriteRect = new Rectangle((int)sprite.getX(), (int)sprite.getY(), sprite.getWidth(), sprite.getHeight());
// �����̋�`�Ƒ���̋�`���d�Ȃ��Ă��邩���ׂ�
if (playerRect.intersects(spriteRect)) {
return true;
}
return false;
}
public boolean visit (SystemInfo systemInfo)
{
try {
// Check that this system is visible
Rectangle bounds = systemInfo.getBounds();
if ((bounds == null) || !bounds.intersects(oldClip)) {
return false;
}
// Determine proper font size for the system
musicFont = MusicFont.getFont(scale.getInterline());
g.setColor(defaultColor);
// Ledgers
for (Glyph glyph : systemInfo.getGlyphs()) {
if ((glyph.getShape() == Shape.LEDGER) && glyph.isActive()) {
// For very short ledgers, glyph line is not reliable
renderLedger(g, glyph);
}
}
// Endings
for (Glyph ending : systemInfo.getEndings()) {
ending.renderLine(g);
}
} catch (ConcurrentModificationException ignored) {
} catch (Exception ex) {
logger.warn(
getClass().getSimpleName() + " Error visiting " + systemInfo,
ex);
}
return true;
}
/**
* Retrieve the gun at the given location.
* @param mx the mouse X
* @param my the mouse Y
* @return the gun or null if empty
*/
GroundwarGun gunAt(int mx, int my) {
Rectangle sel = new Rectangle(0, 0, commons.colony().selectionBoxLight.getWidth(), commons.colony().selectionBoxLight.getHeight());
for (GroundwarGun g : guns) {
Rectangle r = gunRectangle(g);
Rectangle drawRect = new Rectangle((int)(r.x + (r.width - sel.getWidth()) / 2) + offsetX,
(int)(r.y + (r.height - sel.getHeight()) / 2) + offsetY,
sel.width, sel.height);
if (drawRect.intersects(new Rectangle(mx, my, 1, 1))) {
return g;
}
}
return null;
}
@Override
public void renderLine (Graphics2D g,
boolean showPoints,
double pointWidth)
{
Rectangle clip = g.getClipBounds();
if ((clip != null) && !clip.intersects(getBounds())) {
return;
}
// The curved line itself
if (spline != null) {
g.draw(spline);
}
// Then the absolute defining points?
if (showPoints && (points != null)) {
// Point radius
double r = pointWidth / 2;
Ellipse2D ellipse = new Ellipse2D.Double();
for (Point2D p : points) {
ellipse.setFrame(p.getX() - r, p.getY() - r, 2 * r, 2 * r);
Color oldColor = null;
if (p.getClass() != Point2D.Double.class) {
oldColor = g.getColor();
g.setColor(Color.red);
}
g.fill(ellipse);
if (oldColor != null) {
g.setColor(oldColor);
}
}
}
}
/**
* Render the box area of a glyph, using inverted color.
*
* @param glyph the glyph whose area is to be rendered
* @param g the graphic context
*/
protected void renderGlyphArea (Glyph glyph,
Graphics2D g)
{
// Check the clipping
Rectangle box = glyph.getBounds();
if ((box != null) && box.intersects(g.getClipBounds())) {
g.fillRect(box.x, box.y, box.width, box.height);
}
}
/**
* ���̃X�v���C�g�ƐڐG���Ă��邩
* @param sprite �X�v���C�g
*/
public boolean isCollision(Sprite sprite) {
Rectangle playerRect = new Rectangle((int)x, (int)y, width, height);
Rectangle spriteRect = new Rectangle((int)sprite.getX(), (int)sprite.getY(), sprite.getWidth(), sprite.getHeight());
// �����̋�`�Ƒ���̋�`���d�Ȃ��Ă��邩���ׂ�
if (playerRect.intersects(spriteRect)) {
return true;
}
return false;
}
/**
* Paints the specified component.
*
* @param context context for the component being painted
* @param g the {@code Graphics} object used for painting
* @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
Rectangle clip = g.getClipBounds();
Rectangle bounds = table.getBounds();
// account for the fact that the graphics has already been translated
// into the table's bounds
bounds.x = bounds.y = 0;
if (table.getRowCount() <= 0 || table.getColumnCount() <= 0 ||
// this check prevents us from painting the entire table
// when the clip doesn't intersect our bounds at all
!bounds.intersects(clip)) {
paintDropLines(context, g);
return;
}
boolean ltr = table.getComponentOrientation().isLeftToRight();
Point upperLeft = clip.getLocation();
Point lowerRight = new Point(clip.x + clip.width - 1,
clip.y + clip.height - 1);
int rMin = table.rowAtPoint(upperLeft);
int rMax = table.rowAtPoint(lowerRight);
// This should never happen (as long as our bounds intersect the clip,
// which is why we bail above if that is the case).
if (rMin == -1) {
rMin = 0;
}
// If the table does not have enough rows to fill the view we'll get -1.
// (We could also get -1 if our bounds don't intersect the clip,
// which is why we bail above if that is the case).
// Replace this with the index of the last row.
if (rMax == -1) {
rMax = table.getRowCount()-1;
}
int cMin = table.columnAtPoint(ltr ? upperLeft : lowerRight);
int cMax = table.columnAtPoint(ltr ? lowerRight : upperLeft);
// This should never happen.
if (cMin == -1) {
cMin = 0;
}
// If the table does not have enough columns to fill the view we'll get -1.
// Replace this with the index of the last column.
if (cMax == -1) {
cMax = table.getColumnCount()-1;
}
// Paint the cells.
paintCells(context, g, rMin, rMax, cMin, cMax);
// Paint the grid.
// it is important to paint the grid after the cells, otherwise the grid will be overpainted
// because in Synth cell renderers are likely to be opaque
paintGrid(context, g, rMin, rMax, cMin, cMax);
paintDropLines(context, g);
}
/**
* Paints the specified component.
*
* @param context context for the component being painted
* @param g the {@code Graphics} object used for painting
* @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
Rectangle clip = g.getClipBounds();
Rectangle bounds = table.getBounds();
// account for the fact that the graphics has already been translated
// into the table's bounds
bounds.x = bounds.y = 0;
if (table.getRowCount() <= 0 || table.getColumnCount() <= 0 ||
// this check prevents us from painting the entire table
// when the clip doesn't intersect our bounds at all
!bounds.intersects(clip)) {
paintDropLines(context, g);
return;
}
boolean ltr = table.getComponentOrientation().isLeftToRight();
Point upperLeft = clip.getLocation();
Point lowerRight = new Point(clip.x + clip.width - 1,
clip.y + clip.height - 1);
int rMin = table.rowAtPoint(upperLeft);
int rMax = table.rowAtPoint(lowerRight);
// This should never happen (as long as our bounds intersect the clip,
// which is why we bail above if that is the case).
if (rMin == -1) {
rMin = 0;
}
// If the table does not have enough rows to fill the view we'll get -1.
// (We could also get -1 if our bounds don't intersect the clip,
// which is why we bail above if that is the case).
// Replace this with the index of the last row.
if (rMax == -1) {
rMax = table.getRowCount()-1;
}
int cMin = table.columnAtPoint(ltr ? upperLeft : lowerRight);
int cMax = table.columnAtPoint(ltr ? lowerRight : upperLeft);
// This should never happen.
if (cMin == -1) {
cMin = 0;
}
// If the table does not have enough columns to fill the view we'll get -1.
// Replace this with the index of the last column.
if (cMax == -1) {
cMax = table.getColumnCount()-1;
}
// Paint the cells.
paintCells(context, g, rMin, rMax, cMin, cMax);
// Paint the grid.
// it is important to paint the grid after the cells, otherwise the grid will be overpainted
// because in Synth cell renderers are likely to be opaque
paintGrid(context, g, rMin, rMax, cMin, cMax);
paintDropLines(context, g);
}
/**
* Paints the specified component.
*
* @param context context for the component being painted
* @param g the {@code Graphics} object used for painting
* @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
Rectangle clip = g.getClipBounds();
Rectangle bounds = table.getBounds();
// account for the fact that the graphics has already been translated
// into the table's bounds
bounds.x = bounds.y = 0;
if (table.getRowCount() <= 0 || table.getColumnCount() <= 0 ||
// this check prevents us from painting the entire table
// when the clip doesn't intersect our bounds at all
!bounds.intersects(clip)) {
paintDropLines(context, g);
return;
}
boolean ltr = table.getComponentOrientation().isLeftToRight();
Point upperLeft = clip.getLocation();
Point lowerRight = new Point(clip.x + clip.width - 1,
clip.y + clip.height - 1);
int rMin = table.rowAtPoint(upperLeft);
int rMax = table.rowAtPoint(lowerRight);
// This should never happen (as long as our bounds intersect the clip,
// which is why we bail above if that is the case).
if (rMin == -1) {
rMin = 0;
}
// If the table does not have enough rows to fill the view we'll get -1.
// (We could also get -1 if our bounds don't intersect the clip,
// which is why we bail above if that is the case).
// Replace this with the index of the last row.
if (rMax == -1) {
rMax = table.getRowCount()-1;
}
int cMin = table.columnAtPoint(ltr ? upperLeft : lowerRight);
int cMax = table.columnAtPoint(ltr ? lowerRight : upperLeft);
// This should never happen.
if (cMin == -1) {
cMin = 0;
}
// If the table does not have enough columns to fill the view we'll get -1.
// Replace this with the index of the last column.
if (cMax == -1) {
cMax = table.getColumnCount()-1;
}
// Paint the cells.
paintCells(context, g, rMin, rMax, cMin, cMax);
// Paint the grid.
// it is important to paint the grid after the cells, otherwise the grid will be overpainted
// because in Synth cell renderers are likely to be opaque
paintGrid(context, g, rMin, rMax, cMin, cMax);
paintDropLines(context, g);
}
/**
* Paints the specified component.
*
* @param context context for the component being painted
* @param g the {@code Graphics} object used for painting
* @see #update(Graphics,JComponent)
*/
protected void paint(SynthContext context, Graphics g) {
Rectangle clip = g.getClipBounds();
Rectangle bounds = table.getBounds();
// account for the fact that the graphics has already been translated
// into the table's bounds
bounds.x = bounds.y = 0;
if (table.getRowCount() <= 0 || table.getColumnCount() <= 0 ||
// this check prevents us from painting the entire table
// when the clip doesn't intersect our bounds at all
!bounds.intersects(clip)) {
paintDropLines(context, g);
return;
}
boolean ltr = table.getComponentOrientation().isLeftToRight();
Point upperLeft = clip.getLocation();
Point lowerRight = new Point(clip.x + clip.width - 1,
clip.y + clip.height - 1);
int rMin = table.rowAtPoint(upperLeft);
int rMax = table.rowAtPoint(lowerRight);
// This should never happen (as long as our bounds intersect the clip,
// which is why we bail above if that is the case).
if (rMin == -1) {
rMin = 0;
}
// If the table does not have enough rows to fill the view we'll get -1.
// (We could also get -1 if our bounds don't intersect the clip,
// which is why we bail above if that is the case).
// Replace this with the index of the last row.
if (rMax == -1) {
rMax = table.getRowCount()-1;
}
int cMin = table.columnAtPoint(ltr ? upperLeft : lowerRight);
int cMax = table.columnAtPoint(ltr ? lowerRight : upperLeft);
// This should never happen.
if (cMin == -1) {
cMin = 0;
}
// If the table does not have enough columns to fill the view we'll get -1.
// Replace this with the index of the last column.
if (cMax == -1) {
cMax = table.getColumnCount()-1;
}
// Paint the cells.
paintCells(context, g, rMin, rMax, cMin, cMax);
// Paint the grid.
// it is important to paint the grid after the cells, otherwise the grid will be overpainted
// because in Synth cell renderers are likely to be opaque
paintGrid(context, g, rMin, rMax, cMin, cMax);
paintDropLines(context, g);
}
/**
* Detect all cases where 2 Inters actually overlap while being in separate systems.
*
* @param aboves the collection of inters to process from system above
* @param belows the collection of inters to process from system below
*/
private void detectCrossOverlaps (List<Inter> aboves,
List<Inter> belows)
{
Collections.sort(aboves, Inters.byAbscissa);
Collections.sort(belows, Inters.byAbscissa);
NextLeft:
for (Inter above : aboves) {
if (above.isRemoved()) {
continue;
}
final Rectangle aboveBox = above.getBounds();
final double xMax = aboveBox.getMaxX();
for (Inter below : belows) {
if (below.isRemoved()) {
continue;
}
Rectangle belowBox = below.getBounds();
if (aboveBox.intersects(belowBox)) {
// Have a more precise look
try {
if (above.overlaps(below) && below.overlaps(above)) {
Inter removedInter = resolveConflict(above, below);
if (removedInter == above) {
continue NextLeft;
}
}
} catch (DeletedInterException diex) {
if (diex.inter == above) {
continue NextLeft;
}
}
} else if (belowBox.x > xMax) {
break; // Since below list is sorted by abscissa
}
}
}
}
/**
* Merge compatible clusters as much as possible.
*/
private void mergeClusters ()
{
// Sort clusters according to their ordinate in page
Collections.sort(clusters, ordinateComparator);
for (LineCluster current : clusters) {
LineCluster candidate = current;
// Keep on working while we do have a candidate to check for merge
CandidateLoop:
while (true) {
Wrapper<Integer> deltaPos = new Wrapper<>();
Rectangle candidateBox = candidate.getBounds();
candidateBox.grow(params.clusterXMargin, params.clusterYMargin);
// Check the candidate vs all clusters until current excluded
for (LineCluster head : clusters) {
if (head == current) {
break CandidateLoop; // Actual end of sub list
}
if ((head == candidate) || (head.getParent() != null)) {
continue;
}
// Check rough proximity
Rectangle headBox = head.getBounds();
if (headBox.intersects(candidateBox)) {
// Try a merge
if (canMerge(head, candidate, deltaPos)) {
logger.debug("Merging {} with {} delta:{}",
candidate, head, deltaPos.value);
// Do the merge
candidate.mergeWith(head, deltaPos.value);
break;
}
}
}
}
}
removeMergedClusters();
removeMergedFilaments();
}
/**
* Create a bunch of Note instances for one note pack glyph.
* A note pack is a glyph whose shape "contains" several notes, just like
* a NOTEHEAD_BLACK_3 shape represents a vertical sequence of 3 heads.
* Within a pack, notes are numbered by their vertical top down index,
* counted from 0.
*
* <p>If we have 0 or 1 stem attached to the provided glyph, no specific
* test is needed, all the note instances are created on the provided chord.
* </p>
*
* <p>When the underlying glyph is stuck to 2 stems, we have to decide
* which notes go to one stem (the left chord), which notes go to the other
* (the right chord) and which notes go to both.
* Every stem gets at least the vertically closest note.
* At the end, to make sure that all notes from the initial pack are
* actually assigned, we force the unassigned notes to the stem at hand.
* </p>
*
* <p>(On the diagram below with a note pack of 3, the two upper notes
* will go to the right stem, and the third note will go to the left stem).
* </p>
* <img src="doc-files/Note-Pack.png" alt="Pack of 3">
*
* <p>(On the diagram below with a note pack of 1, the "mirrored" note is
* duplicated, one instance goes to the left stem and the other to the
* right stem).
* </p>
* <img src="doc-files/Note-Pack-both.png" alt="Shared note">
*
* @param chord the containing chord
* @param glyph the underlying glyph of the note pack
* @param assigned (input/output) the set of note indices assigned so far
* @param completing true if all unassigned notes must be assigned now
*/
public static void createPack (Chord chord,
Glyph glyph,
Set<Integer> assigned,
boolean completing)
{
// Number of "notes" to create (not counting the duplicates)
final int card = packCardOf(glyph.getShape());
final Glyph stem = chord.getStem();
Rectangle stemBox = null;
Scale scale = chord.getScale();
// Variable stemSir exists only when we have a dual stem situation.
// It gives the direction of the stem at hand (-1:down, +1:up)
Integer stemDir = null;
if (glyph.getStemNumber() >= 2) {
stemBox = stem.getBounds();
stemBox.grow(
scale.toPixels(constants.maxStemDx),
scale.toPixels(constants.maxMultiStemDy));
stemDir = Integer.signum(glyph.getAreaCenter().y - stem.getAreaCenter().y);
}
// Index goes from top to bottom
for (int i = 0; i < card; i++) {
Rectangle itemBox = getItemBox(glyph, i, scale.getInterline());
if (stemDir != null) {
// Apply the stem test, except on the item closest to the stem
if ((stemDir == 1 && i > 0)
|| (stemDir == -1 && i < card - 1)) {
if (!itemBox.intersects(stemBox)) {
// Stem check failed.
// Force assignment if unassigned and this is the end.
if (assigned.contains(i) || !completing) {
continue;
}
}
}
}
Point center = new Point(
itemBox.x + (itemBox.width / 2),
itemBox.y + (itemBox.height / 2));
glyph.addTranslation(new Note(chord, glyph, center, card, i));
assigned.add(i);
}
}
/** If needed, visually rearrange dialogViewer and dlg on screen.
* If they overlap, try to make them not overlap.
* @param dlg the visible modal dialog
* @param dialogOrFrameViewer The viewer, a dialog of a frame.
*/
private void rearrange(Dialog dlg, Window dialogOrFrameViewer) {
Rectangle r1 = dlg.getBounds();
Rectangle r2 = dialogOrFrameViewer.getBounds();
if (r1.intersects(r2)) {
Installer.log.fine("modal dialog and dialog viewer overlap");
Dimension s = Toolkit.getDefaultToolkit().getScreenSize();
int xExtra = s.width - r1.width - r2.width;
int yExtra = s.height - r1.height - r2.height;
if(xExtra >= yExtra){
//compare y axes of r1 and r2 to know how to relocate them - horizontal relocation
int r1Yaxis = r1.x + (r1.width/2);
int r2Yaxis = r2.x + (r2.width/2);
if(r1Yaxis <= r2Yaxis) {
Installer.log.fine(" send help to the right");
if((r1.x + r1.width + r2.width) <= s.width) {
Installer.log.fine("there is enough place fo help");
r2.x = r1.x + r1.width;
} else {
Installer.log.fine("there is not enough place");
if((r1.width + r2.width) < s.width) {
Installer.log.fine("relocate both");
r2.x = s.width - r2.width;
r1.x = r2.x - r1.width;
} else {
Installer.log.fine("relocate both and resize help");
r1.x = 0;
r2.x = r1.width;
r2.width = s.width - r1.width;
}
}
} else {
Installer.log.fine("send help to the left");
if((r1.x - r2.width) > 0) {
Installer.log.fine("there is enough place for help");
r2.x = r1.x - r2.width;
} else {
Installer.log.fine("there is not enough place");
if((r1.width + r2.width) < s.width){
Installer.log.fine("relocate both");
r2.x = 0;
r1.x = r2.width;
} else {
Installer.log.fine("relocate both and resize help");
r1.x = s.width - r1.width;
r2.x = 0;
r2.width = r1.x;
}
}
}
} else {
//compare x axes of r1 and r2 to know how to relocate them
int r1Xaxis = r1.y + (r1.height/2);
int r2Xaxis = r2.y + (r2.height/2);
if(r1Xaxis <= r2Xaxis) {
Installer.log.fine(" send help to the bottom");
if((r1.y + r1.height + r2.height) <= s.height) {
Installer.log.fine("there is enough place fo help");
r2.y = r1.y + r1.height;
} else {
Installer.log.fine("there is not enough place");
if((r1.height + r2.height) < s.height) {
Installer.log.fine("relocate both");
r2.y = s.height - r2.height;
r1.y = r2.y - r1.height;
} else {
Installer.log.fine("relocate both and resize help");
r1.y = 0;
r2.y = r1.height;
r2.height = s.height - r1.height;
}
}
} else {
Installer.log.fine("send help to the top");
if((r1.y - r2.height) > 0){
Installer.log.fine("there is enough place for help");
r2.y = r1.y - r2.height;
} else {
Installer.log.fine("there is not enough place");
if((r1.height + r2.height) < s.height) {
Installer.log.fine("relocate both");
r2.y = 0;
r1.y = r2.height;
} else {
Installer.log.fine("relocate both and resize help");
r1.y = s.height - r1.height;
r2.y = 0; //or with -1
r2.height = r1.y;
}
}
}
}
dlg.setBounds(r1);
dialogOrFrameViewer.setBounds(r2);
}
}
protected boolean canDirectlyAccessGraphics() {
// TODO: what about popup windows / tooltips???
// TODO: some of the queries could be cached instead of polling,
// for example isShowing(), isOpaque(), getParent() etc.
////// // Shouldn't access graphics - no buffering would cause flickering
////// if (bufferType == BUFFER_NONE) return false;
// Cannot access graphics - there are some child components
if (getComponentCount() != 0) return false;
// Cannot access graphics - component doesn't fully control its area
if (!isOpaque()) return false;
// Cannot access graphics - not in Swing tree
if (!(getParent() instanceof JComponent)) return false;
// Cannot access graphics - component not showing, doesn't make sense
if (!isShowing()) return false;
// Cannot access graphics - component area is not up-to-date
Rectangle dirtyRegion = RepaintManager.currentManager(this).
getDirtyRegion((JComponent)getParent());
if (dirtyRegion != null && dirtyRegion.width > 0 &&
dirtyRegion.height > 0) return false;
// --- Reused from JViewport -------------------------------------------
Rectangle clip = new Rectangle(0, 0, getWidth(), getHeight());
Rectangle oldClip = new Rectangle();
Rectangle tmp2 = null;
Container parent;
Component lastParent = null;
int x, y, w, h;
for (parent = this; parent != null && isLightweightComponent(parent); parent = parent.getParent()) {
x = parent.getX();
y = parent.getY();
w = parent.getWidth();
h = parent.getHeight();
oldClip.setBounds(clip);
SwingUtilities.computeIntersection(0, 0, w, h, clip);
if (!clip.equals(oldClip)) return false;
if (lastParent != null && parent instanceof JComponent &&
!((JComponent)parent).isOptimizedDrawingEnabled()) {
Component comps[] = parent.getComponents();
int index = 0;
for (int i = comps.length - 1 ;i >= 0; i--) {
if (comps[i] == lastParent) {
index = i - 1;
break;
}
}
while (index >= 0) {
tmp2 = comps[index].getBounds(tmp2);
if (tmp2.intersects(clip)) return false;
index--;
}
}
clip.x += x;
clip.y += y;
lastParent = parent;
}
// No Window parent.
if (parent == null) return false;
return true;
}