本文整理汇总了Java中java.awt.Rectangle.setLocation方法的典型用法代码示例。如果您正苦于以下问题:Java Rectangle.setLocation方法的具体用法?Java Rectangle.setLocation怎么用?Java Rectangle.setLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.Rectangle
的用法示例。
在下文中一共展示了Rectangle.setLocation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mouseClicked
import java.awt.Rectangle; //导入方法依赖的package包/类
@Override
public void mouseClicked(MouseEvent e) {
JTree tree = (JTree) e.getSource();
Point p = e.getPoint();
int row = tree.getRowForLocation(e.getX(), e.getY());
TreePath path = tree.getPathForRow(row);
// if path exists and mouse is clicked exactly once
if (path != null) {
FileNode node = (FileNode) path.getLastPathComponent();
Rectangle chRect = DeletedListRenderer.getCheckBoxRectangle();
Rectangle rowRect = tree.getPathBounds(path);
chRect.setLocation(chRect.x + rowRect.x, chRect.y + rowRect.y);
if (e.getClickCount() == 1 && chRect.contains(p)) {
boolean isSelected = !(node.isSelected());
node.setSelected(isSelected);
((DefaultTreeModel) tree.getModel()).nodeChanged(node);
if (row == 0) {
tree.revalidate();
}
tree.repaint();
}
}
}
示例2: mouseExited
import java.awt.Rectangle; //导入方法依赖的package包/类
@Override
public void mouseExited(MouseEvent e) {
if (e.getSource() == listClasses && currentPopup != null) {
// check if hovering above the popup -> do not dismiss.
// the mouse exits the table, when it crosses the boudary to the
// tooltip.
Point screen = e.getLocationOnScreen();
Rectangle visibleRec = listClasses.getVisibleRect();
Point pt = visibleRec.getLocation();
SwingUtilities.convertPointToScreen(pt, listClasses);
visibleRec.setLocation(pt);
if (visibleRec.contains(screen)) {
return;
}
hidePopup();
} else if (e.getSource() == this.popupContents) {
// exit from the popup
hidePopup();
}
}
示例3: computePopupBounds
import java.awt.Rectangle; //导入方法依赖的package包/类
private void computePopupBounds (Rectangle result, JLayeredPane lPane, int modelSize) {
Dimension cSize = comboBar.getSize();
int width = getPopupWidth();
Point location = new Point(cSize.width - width - 1, comboBar.getBottomLineY() - 1);
if (SwingUtilities.getWindowAncestor(comboBar) != null) {
location = SwingUtilities.convertPoint(comboBar, location, lPane);
}
result.setLocation(location);
// hack to make jList.getpreferredSize work correctly
// JList is listening on ResultsModel same as us and order of listeners
// is undefined, so we have to force update of JList's layout data
jList1.setFixedCellHeight(15);
jList1.setFixedCellHeight(-1);
// end of hack
jList1.setVisibleRowCount(modelSize);
Dimension preferredSize = jList1.getPreferredSize();
preferredSize.width = width;
preferredSize.height += statusPanel.getPreferredSize().height + 3;
result.setSize(preferredSize);
}
示例4: refresh
import java.awt.Rectangle; //导入方法依赖的package包/类
/**Refreshes appearence of the image to be rendered. In facts, recalculates all of the jobs'
* new positions.*/
public void refresh() {
for (int i = 0; i < jobAnimations.size(); i++) {
JobAnimation ja = jobAnimations.get(i);
//update position as time*speed
ja.setPosition((System.currentTimeMillis() - ja.getTimeOfEntrance()) * ja.getSpeed());
Point p = convertPositionToCoord(ja.getPosition());
//tests if this job should be painted outside bounding box of this edge
if (p != null) {
boolean exceedsWidth = (p.getX() >= bounds.x + bounds.width), exceedsHeight = (p.getY() >= bounds.y + bounds.height);
if (exceedsWidth || exceedsHeight) {
routeJob(ja);
}
//set bounds of the job in order to be centered to the coords.
Rectangle r = ja.getBounds();
p.setLocation(p.getX() - r.getWidth() / 2, p.getY() - r.getHeight() / 2);
r.setLocation(p);
} else {
routeJob(ja);
}
}
}
示例5: mouseClicked
import java.awt.Rectangle; //导入方法依赖的package包/类
public void mouseClicked(MouseEvent e) {
// todo (#pf): we need to solve problem between click and double
// click - click should be possible only on the check box area
// and double click should be bordered by title text.
// we need a test how to detect where the mouse pointer is
JTree tree = (JTree) e.getSource();
Point p = e.getPoint();
int x = e.getX();
int y = e.getY();
int row = tree.getRowForLocation(x, y);
TreePath path = tree.getPathForRow(row);
// if path exists and mouse is clicked exactly once
if( null == path )
return;
Node node = Visualizer.findNode( path.getLastPathComponent() );
if( null == node )
return;
Rectangle chRect = CheckRenderer.getCheckBoxRectangle();
Rectangle rowRect = tree.getPathBounds(path);
chRect.setLocation(chRect.x + rowRect.x, chRect.y + rowRect.y);
if (e.getClickCount() == 1 && chRect.contains(p)) {
boolean isSelected = settings.isNodeVisible( node );
settings.setNodeVisible( node, !isSelected );
tree.repaint();
}
}
示例6: getToolbarRowAt
import java.awt.Rectangle; //导入方法依赖的package包/类
/**
* @param screenLocation
* @return Toolbar row at given screen location or null.
*/
ToolbarRow getToolbarRowAt( Point screenLocation ) {
Rectangle bounds = new Rectangle();
for( ToolbarRow row : rows ) {
bounds = row.getBounds(bounds);
if( row.isShowing() ) {
bounds.setLocation(row.getLocationOnScreen());
if( bounds.contains(screenLocation) )
return row;
}
}
return null;
}
示例7: setContentBounds
import java.awt.Rectangle; //导入方法依赖的package包/类
void setContentBounds(WindowDimensions dims) {
XToolkit.awtLock();
try {
// Bounds of content window are of the same size as bounds of Java window and with
// location as -(insets)
Rectangle newBounds = dims.getBounds();
Insets in = dims.getInsets();
if (in != null) {
newBounds.setLocation(-in.left, -in.top);
}
if (insLog.isLoggable(PlatformLogger.Level.FINE)) {
insLog.fine("Setting content bounds {0}, old bounds {1}",
newBounds, getBounds());
}
// Fix for 5023533:
// Change in the size of the content window means, well, change of the size
// Change in the location of the content window means change in insets
boolean needHandleResize = !(newBounds.equals(getBounds()));
boolean needPaint = width <= 0 || height <= 0;
reshape(newBounds);
if (needHandleResize) {
insLog.fine("Sending RESIZED");
handleResize(newBounds);
}
if (needPaint) {
postPaintEvent(target, 0, 0, newBounds.width, newBounds.height);
}
} finally {
XToolkit.awtUnlock();
}
}
示例8: findContainingWidget
import java.awt.Rectangle; //导入方法依赖的package包/类
/**
* Find widget that contains point <tt>center</tt>.
*
* @param center
* @return widget that contains the center or null if no such widget exists.
*/
private PoshWidget<? extends PoshElement> findContainingWidget(Point center) {
for (Widget widget : scene.getPoshWidgets()) {
Rectangle rect = (Rectangle) widget.getClientArea().clone();
rect.setLocation(widget.getLocation());
if (rect.contains(center) && widget instanceof PoshWidget) {
return (PoshWidget<? extends PoshElement>) widget;
}
}
return null;
}
示例9: repositionSons
import java.awt.Rectangle; //导入方法依赖的package包/类
private void repositionSons(JmtCell padre, List<Object> sons, int numero, int cont) {
inRepositionSons = true;
Object[] listEdges = null;
GraphModel graphmodel = graph.getModel();
flag1 = true;
int j = 0;
Rectangle boundspadre = GraphConstants.getBounds(padre.getAttributes()).getBounds();
int w = boundspadre.y + ((heightMax + 35) * (numero + 1)) - 38;
for (int i = cont; i < sons.size(); i++) {
if (((JmtCell) sons.get(i)).seen == false) {
Rectangle bounds = GraphConstants.getBounds(((JmtCell) sons.get(i)).getAttributes()).getBounds();
bounds.setLocation((int) (boundspadre.getCenterX()) + widthMax + 50 - (int) (bounds.getWidth() / 2),
w - (int) (bounds.getHeight() / 2) + 80);
GraphConstants.setBounds(((JmtCell) sons.get(i)).getAttributes(), bounds);
((JmtCell) sons.get(i)).seen = true;
listEdges = DefaultGraphModel.getOutgoingEdges(graphmodel, sons.get(i));
if (listEdges.length > 0) {
flag = true;
j = searchNext((JmtCell) sons.get(i));
inRepositionSons = true;
}
if (j > 0) {
j = j - 1;
}
listEdges = null;
}
w = w + (heightMax + ((heightMax + 15) * j) + 30);
j = 0;
}
inRepositionSons = false;
}
示例10: setContentBounds
import java.awt.Rectangle; //导入方法依赖的package包/类
void setContentBounds(WindowDimensions dims) {
XToolkit.awtLock();
try {
// Bounds of content window are of the same size as bounds of Java window and with
// location as -(insets)
Rectangle newBounds = dims.getBounds();
Insets in = dims.getInsets();
if (in != null) {
newBounds.setLocation(-in.left, -in.top);
}
if (insLog.isLoggable(PlatformLogger.Level.FINE)) {
insLog.fine("Setting content bounds {0}, old bounds {1}",
newBounds, getBounds());
}
// Fix for 5023533:
// Change in the size of the content window means, well, change of the size
// Change in the location of the content window means change in insets
boolean needHandleResize = !(newBounds.equals(getBounds()));
reshape(newBounds);
if (needHandleResize) {
insLog.fine("Sending RESIZED");
handleResize(newBounds);
}
} finally {
XToolkit.awtUnlock();
}
validateSurface();
}
示例11: hoverCheckRequired
import java.awt.Rectangle; //导入方法依赖的package包/类
public boolean hoverCheckRequired() {
Point mousePos = MouseInfo.getPointerInfo().getLocation();
Rectangle bounds = frame.getBounds();
try {
bounds.setLocation(frame.getLocationOnScreen());
}
catch(Exception e) {
return false;
}
return !bounds.contains(mousePos);
}
示例12: setThumbLocationAt
import java.awt.Rectangle; //导入方法依赖的package包/类
public void setThumbLocationAt(int x, int y, int index) {
Rectangle rect = thumbRects[index];
unionRect.setBounds(rect);
rect.setLocation(x, y);
SwingUtilities.computeUnion(rect.x, rect.y, rect.width, rect.height,
unionRect);
mSlider.repaint(unionRect.x, unionRect.y, unionRect.width,
unionRect.height);
}
示例13: computeTipVisibleBounds
import java.awt.Rectangle; //导入方法依赖的package包/类
/**
* Compute the bounds in which the user can move the mouse without the
* tip window disappearing.
*/
private void computeTipVisibleBounds() {
// Compute area that the mouse can move in without hiding the
// tip window. Note that Java 1.4 can only detect mouse events
// in Java windows, not globally.
Rectangle r = tipWindow.getBounds();
Point p = r.getLocation();
SwingUtilities.convertPointFromScreen(p, textArea);
r.setLocation(p);
tipVisibleBounds.setBounds(r.x,r.y-15, r.width,r.height+15*2);
}
示例14: getTabsArea
import java.awt.Rectangle; //导入方法依赖的package包/类
@Override
public Rectangle getTabsArea() {
Rectangle res = slideBar.getBounds();
res.setLocation( 0, 0 );
return res;
}
示例15: searchNext
import java.awt.Rectangle; //导入方法依赖的package包/类
private int searchNext(JmtCell prev) {
Rectangle boundspadre = GraphConstants.getBounds((prev).getAttributes()).getBounds();
Object[] listEdges = null;
GraphModel graphmodel = graph.getModel();
List<Object> next = new ArrayList<Object>();
if (flag1 == false && prev.seen == false) {
if (!flag2) {
boundspadre.setLocation(x, y + ((e + 1) * (42 + heightMax)) - (int) (boundspadre.getHeight() / 2) + 30);
} else {
boundspadre.setLocation(x - (int) (boundspadre.getWidth() / 2), y + ((e + 1) * (42 + heightMax))
- (int) (boundspadre.getHeight() / 2) + 30);
}
GraphConstants.setBounds(prev.getAttributes(), boundspadre);
x = (int) boundspadre.getCenterX() + widthMax + 50;
prev.seen = true;
flag2 = true;
}
listEdges = DefaultGraphModel.getOutgoingEdges(graphmodel, prev);
Vector<Object> listEdgestmp = new Vector<Object>();
for (Object listEdge : listEdges) {
JmtCell qq = (JmtCell) (graphmodel.getParent(graphmodel.getTarget(listEdge)));
if (!(qq).seen) {
listEdgestmp.add(listEdge);
}
}
listEdges = listEdgestmp.toArray();
int numTarget = listEdges.length;
if (numTarget == 0) {
return 1;
}
for (int k = 0; k < numTarget; k++) {
next.add((graphmodel.getParent(graphmodel.getTarget(listEdges[k]))));
}
int j = 1;
if (inRepositionSons == false && ((JmtCell) next.get(0)).seen == false) {
j = searchNext((JmtCell) next.get(0));
} else if (inRepositionSons == true && ((JmtCell) next.get(0)).seen == false) {
Rectangle bounds = GraphConstants.getBounds(((JmtCell) next.get(0)).getAttributes()).getBounds();
bounds.setLocation((int) (boundspadre.getCenterX()) + widthMax + 50 - (int) (bounds.getWidth() / 2),
(int) boundspadre.getCenterY() - (int) (bounds.getHeight() / 2));
GraphConstants.setBounds(((JmtCell) next.get(0)).getAttributes(), bounds);
((JmtCell) next.get(0)).seen = true;
j = searchNext((JmtCell) next.get(0));
}
if (numTarget > 0) {
if (!flag) {
repositionSons(prev, next, j - 1, 1);
} else {
repositionSons(prev, next, -1, 0);
}
flag = false;
}
(prev).sons = 0;
for (int w = 0; w < numTarget; w++) {
prev.sons += ((JmtCell) next.get(w)).sons;
}
return prev.sons;
}