Java Code Examples for java.awt.Rectangle.setSize()

The following are Jave code examples for showing how to use setSize() of the java.awt.Rectangle class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: alevin-svn2   File: MultiAlgoScenarioWizard.java   View Source Code Vote up 6 votes
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);
}
 
Example 2
Project: incubator-netbeans   File: QuickSearchPopup.java   View Source Code Vote up 6 votes
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);
}
 
Example 3
Project: incubator-netbeans   File: QuickSearchPopup.java   View Source Code Vote up 6 votes
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);
}
 
Example 4
Project: VASSAL-src   File: ColoredBorder.java   View Source Code Vote up 5 votes
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;
}
 
Example 5
Project: VASSAL-src   File: Info.java   View Source Code Vote up 5 votes
/**
 * 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;
}
 
Example 6
Project: VASSAL-src   File: SelectionHighlighter.java   View Source Code Vote up 5 votes
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;
}
 
Example 7
Project: Tarski   File: mxCellEditor.java   View Source Code Vote up 5 votes
/**
 * 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;
}
 
Example 8
Project: VASSAL-src   File: Map.java   View Source Code Vote up 4 votes
/**
 * 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);
}
 
Example 9
Project: TrabalhoFinalEDA2   File: mxCellEditor.java   View Source Code Vote up 4 votes
/**
 * 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;
}