本文整理匯總了Java中java.awt.Rectangle.setSize方法的典型用法代碼示例。如果您正苦於以下問題:Java Rectangle.setSize方法的具體用法?Java Rectangle.setSize怎麽用?Java Rectangle.setSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.awt.Rectangle
的用法示例。
在下文中一共展示了Rectangle.setSize方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: showConfigurationDialog
import java.awt.Rectangle; //導入方法依賴的package包/類
private void showConfigurationDialog(ITopologyGenerator generator) {
JDialog dialog = new JDialog();
dialog.setModalityType(Dialog.ModalityType.APPLICATION_MODAL);
dialog.setLayout(new BorderLayout());
dialog.setTitle(generator.getName());
dialog.add(generator.getConfigurationDialog(), BorderLayout.CENTER);
Rectangle tbounds = this.getBounds();
Rectangle bounds = new Rectangle();
bounds.setSize(generator.getConfigurationDialog().getPreferredSize());
bounds.x = (int) (tbounds.x + 0.5 * tbounds.width - 0.5 * bounds.width);
bounds.y = (int) (tbounds.y + 0.5 * tbounds.height - 0.5 * bounds.height);
dialog.setBounds(bounds);
dialog.setResizable(false);
dialog.setVisible(true);
}
示例2: 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);
}
示例3: computePopupBounds
import java.awt.Rectangle; //導入方法依賴的package包/類
private void computePopupBounds (Rectangle result, JLayeredPane lPane, int modelSize) {
Point location =
new Point(
comboBar.getIssueComponent().getX(),
comboBar.getIssueComponent().getY() + comboBar.getIssueComponent().getHeight() - 1);
location = SwingUtilities.convertPoint(comboBar, location, lPane); // XXX terrible hack! fix this
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 = comboBar.getIssueComponent().getWidth();
preferredSize.height += statusPanel.getPreferredSize().height + 3;
if(preferredSize.height > 150) {
preferredSize.height = 150;
}
result.setSize(preferredSize);
}
示例4: boundingBox
import java.awt.Rectangle; //導入方法依賴的package包/類
public Rectangle boundingBox(GamePiece p) {
final Rectangle r = p.getShape().getBounds();
r.translate(-thickness, -thickness);
r.setSize(r.width + 2 * thickness, r.height + 2 * thickness);
for (Highlighter h : highlighters) r.add(h.boundingBox(p));
return r;
}
示例5: getScreenBounds
import java.awt.Rectangle; //導入方法依賴的package包/類
/**
* Get size of screen accounting for the screen insets (i.e. Windows taskbar)
*
* @return
*/
public static Rectangle getScreenBounds(Component c) {
final Rectangle bounds =
new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
final GraphicsConfiguration config = c.getGraphicsConfiguration();
final Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(config);
bounds.translate(insets.left, insets.top);
bounds.setSize(bounds.width - insets.left - insets.right,
bounds.height - insets.top - insets.bottom);
return bounds;
}
示例6: boundingBox
import java.awt.Rectangle; //導入方法依賴的package包/類
public Rectangle boundingBox(GamePiece p) {
final Rectangle r = p.getShape().getBounds();
if (accept(p)) {
if (useImage) {
r.add(ImageUtils.getBounds(imagePainter.getImageSize()));
}
else {
r.translate(-thickness, -thickness);
r.setSize(r.width + 2 * thickness, r.height + 2 * thickness);
}
}
return r;
}
示例7: getEditorBounds
import java.awt.Rectangle; //導入方法依賴的package包/類
/**
* Returns the bounds to be used for the editor.
*/
public Rectangle getEditorBounds(mxCellState state, double scale) {
mxIGraphModel model = state.getView().getGraph().getModel();
Rectangle bounds = null;
if (useLabelBounds(state)) {
bounds = state.getLabelBounds().getRectangle();
bounds.height += 10;
} else {
bounds = state.getRectangle();
}
// Applies the horizontal and vertical label positions
if (model.isVertex(state.getCell())) {
String horizontal = mxUtils.getString(state.getStyle(), mxConstants.STYLE_LABEL_POSITION,
mxConstants.ALIGN_CENTER);
if (horizontal.equals(mxConstants.ALIGN_LEFT)) {
bounds.x -= state.getWidth();
} else if (horizontal.equals(mxConstants.ALIGN_RIGHT)) {
bounds.x += state.getWidth();
}
String vertical = mxUtils.getString(state.getStyle(),
mxConstants.STYLE_VERTICAL_LABEL_POSITION, mxConstants.ALIGN_MIDDLE);
if (vertical.equals(mxConstants.ALIGN_TOP)) {
bounds.y -= state.getHeight();
} else if (vertical.equals(mxConstants.ALIGN_BOTTOM)) {
bounds.y += state.getHeight();
}
}
bounds.setSize((int) Math.max(bounds.getWidth(), Math.round(minimumWidth * scale)),
(int) Math.max(bounds.getHeight(), Math.round(minimumHeight * scale)));
return bounds;
}
示例8: repaint
import java.awt.Rectangle; //導入方法依賴的package包/類
/**
* Repaint the given area, specified in map coordinates
*/
public void repaint(Rectangle r) {
r.setLocation(componentCoordinates(new Point(r.x, r.y)));
r.setSize((int) (r.width * getZoom()), (int) (r.height * getZoom()));
theMap.repaint(r.x, r.y, r.width, r.height);
}
示例9: getEditorBounds
import java.awt.Rectangle; //導入方法依賴的package包/類
/**
* Returns the bounds to be used for the editor.
*/
public Rectangle getEditorBounds(mxCellState state, double scale)
{
mxIGraphModel model = state.getView().getGraph().getModel();
Rectangle bounds = null;
if (useLabelBounds(state))
{
bounds = state.getLabelBounds().getRectangle();
bounds.height += 10;
}
else
{
bounds = state.getRectangle();
}
// Applies the horizontal and vertical label positions
if (model.isVertex(state.getCell()))
{
String horizontal = mxUtils.getString(state.getStyle(),
mxConstants.STYLE_LABEL_POSITION, mxConstants.ALIGN_CENTER);
if (horizontal.equals(mxConstants.ALIGN_LEFT))
{
bounds.x -= state.getWidth();
}
else if (horizontal.equals(mxConstants.ALIGN_RIGHT))
{
bounds.x += state.getWidth();
}
String vertical = mxUtils.getString(state.getStyle(),
mxConstants.STYLE_VERTICAL_LABEL_POSITION,
mxConstants.ALIGN_MIDDLE);
if (vertical.equals(mxConstants.ALIGN_TOP))
{
bounds.y -= state.getHeight();
}
else if (vertical.equals(mxConstants.ALIGN_BOTTOM))
{
bounds.y += state.getHeight();
}
}
bounds.setSize(
(int) Math.max(bounds.getWidth(),
Math.round(minimumWidth * scale)),
(int) Math.max(bounds.getHeight(),
Math.round(minimumHeight * scale)));
return bounds;
}