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

The following are Jave code examples for showing how to use setSize() of the java.awt.Dimension 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: incubator-netbeans   File: ReferencesBrowserController.java   View Source Code Vote up 6 votes
Dialog createProgressPanel(final String message, BoundedRangeModel model) {
    Dialog dialog;
    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout(10, 10));
    panel.setBorder(new EmptyBorder(15, 15, 15, 15));
    panel.add(new JLabel(message), BorderLayout.NORTH);

    final Dimension ps = panel.getPreferredSize();
    ps.setSize(Math.max(ps.getWidth(), DEFAULT_WIDTH), Math.max(ps.getHeight(), DEFAULT_HEIGHT));
    panel.setPreferredSize(ps);

    final JProgressBar progress = new JProgressBar();
    if (model == null) {
        progress.setIndeterminate(true);
    } else {
        progress.setStringPainted(true);
        progress.setModel(model);
    }
    panel.add(progress, BorderLayout.SOUTH);
    dialog = DialogDisplayer.getDefault().createDialog(new DialogDescriptor(panel, Bundle.ReferencesBrowserController_ProgressDialogCaption(), true, new Object[] {  },
                                                       DialogDescriptor.CANCEL_OPTION, DialogDescriptor.RIGHT_ALIGN,
                                                       null, null));

    return dialog;
}
 
Example 2
Project: Mujeed-Arabic-Prolog   File: TextLineNumber.java   View Source Code Vote up 6 votes
/**
 *  Calculate the width needed to display the maximum line number
 */
private void setPreferredWidth()
{
	Element root = component.getDocument().getDefaultRootElement();
	int lines = root.getElementCount();
	int digits = Math.max(String.valueOf(lines).length(), minimumDisplayDigits);

	//  Update sizes when number of digits in the line number changes

	if (lastDigits != digits)
	{
		lastDigits = digits;
		FontMetrics fontMetrics = getFontMetrics( getFont() );
		int width = fontMetrics.charWidth( '0' ) * digits;
		Insets insets = getInsets();
		int preferredWidth = insets.left + insets.right + width;

		Dimension d = getPreferredSize();
		d.setSize(preferredWidth, HEIGHT);
		setPreferredSize( d );
		setSize( d );
	}
}
 
Example 3
Project: OpenJSharp   File: GraphicsTests.java   View Source Code Vote up 6 votes
public void init(Graphics2D g2d, Context ctx, Dimension dim) {
    int w = dim.width;
    int h = dim.height;
    double theta = Math.toRadians(15);
    double cos = Math.cos(theta);
    double sin = Math.sin(theta);
    double xsize = sin * h + cos * w;
    double ysize = sin * w + cos * h;
    double scale = Math.min(w / xsize, h / ysize);
    xsize *= scale;
    ysize *= scale;
    AffineTransform at = new AffineTransform();
    at.translate((w - xsize) / 2.0, (h - ysize) / 2.0);
    at.translate(sin * h * scale, 0.0);
    at.rotate(theta);
    g2d.transform(at);
    dim.setSize(scaleForTransform(at, dim));
}
 
Example 4
Project: OpenJSharp   File: GraphicsTests.java   View Source Code Vote up 5 votes
public void init(Graphics2D g2d, Context ctx, Dimension dim) {
    int w = dim.width;
    int h = dim.height;
    AffineTransform at = new AffineTransform();
    at.translate(0.0, (h - (w*h)/(w + h*0.1)) / 2);
    at.shear(0.1, 0.0);
    g2d.transform(at);
    dim.setSize(scaleForTransform(at, dim));
}
 
Example 5
Project: jdk8u-jdk   File: GraphicsTests.java   View Source Code Vote up 5 votes
public void init(Graphics2D g2d, Context ctx, Dimension dim) {
    int w = dim.width;
    int h = dim.height;
    AffineTransform at = new AffineTransform();
    at.translate((w - (w*h)/(h + w*0.1)) / 2, 0.0);
    at.shear(0.0, 0.1);
    g2d.transform(at);
    dim.setSize(scaleForTransform(at, dim));
}
 
Example 6
Project: AgentWorkbench   File: MainWindow.java   View Source Code Vote up 5 votes
/**
 * Return the size in relation (scaled) to the screen size.
 */
private Dimension getSizeRelatedToScreenSize() {
	// --- Default size ---------------------
	Dimension frameSize = new Dimension(1150, 640);

	// --- Scale relative to screen ---------
	double scale = 0.9;
	Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize();
	int frameWidth = (int) (screenDimension.getWidth() * scale);
	int frameHeight = (int) (screenDimension.getHeight() * scale);
	frameSize.setSize(frameWidth, frameHeight);

	return frameSize;
}
 
Example 7
Project: jdk8u-jdk   File: GraphicsTests.java   View Source Code Vote up 5 votes
public void init(Graphics2D g2d, Context ctx, Dimension dim) {
    int w = dim.width;
    int h = dim.height;
    AffineTransform at = new AffineTransform();
    at.translate(0.0, (h - (w*h)/(w + h*0.1)) / 2);
    at.shear(0.1, 0.0);
    g2d.transform(at);
    dim.setSize(scaleForTransform(at, dim));
}
 
Example 8
Project: openjdk-jdk10   File: GraphicsTests.java   View Source Code Vote up 5 votes
public void init(Graphics2D g2d, Context ctx, Dimension dim) {
    int w = dim.width;
    int h = dim.height;
    AffineTransform at = new AffineTransform();
    at.translate(0.0, (h - (w*h)/(w + h*0.1)) / 2);
    at.shear(0.1, 0.0);
    g2d.transform(at);
    dim.setSize(scaleForTransform(at, dim));
}
 
Example 9
Project: openjdk-jdk10   File: GraphicsTests.java   View Source Code Vote up 5 votes
public void init(Graphics2D g2d, Context ctx, Dimension dim) {
    int w = dim.width;
    int h = dim.height;
    AffineTransform at = new AffineTransform();
    at.scale(2.0, 2.0);
    g2d.transform(at);
    dim.setSize(w/2, h/2);
    ctx.pixscale = 4;
}
 
Example 10
Project: rapidminer   File: ProcessRendererModel.java   View Source Code Vote up 5 votes
/**
 * Sets the height for the given process. If {@link #getProcessSize(ExecutionUnit)} returns
 * {@code null} for the specified process, does nothing.
 *
 * @param process
 *            the process for which the height should be set
 * @param height
 *            the new height
 */
public void setProcessHeight(ExecutionUnit process, double height) {
	if (process == null) {
		throw new IllegalArgumentException("process must not be null!");
	}
	Dimension dim = processSizes.get(process);
	if (dim == null) {
		return;
	}
	dim.setSize(dim.getWidth(), height);
}
 
Example 11
Project: openjdk-jdk10   File: GraphicsTests.java   View Source Code Vote up 5 votes
public void init(Graphics2D g2d, Context ctx, Dimension dim) {
    int w = dim.width;
    int h = dim.height;
    AffineTransform at = new AffineTransform();
    at.translate(1.5, 1.5);
    g2d.transform(at);
    dim.setSize(w-3, h-3);
}
 
Example 12
Project: openjdk-jdk10   File: GraphicsTests.java   View Source Code Vote up 5 votes
public void init(Graphics2D g2d, Context ctx, Dimension dim) {
    int w = dim.width;
    int h = dim.height;
    AffineTransform at = new AffineTransform();
    at.translate((w - (w*h)/(h + w*0.1)) / 2, 0.0);
    at.shear(0.0, 0.1);
    g2d.transform(at);
    dim.setSize(scaleForTransform(at, dim));
}
 
Example 13
Project: jmt   File: SteppedComboBoxUI.java   View Source Code Vote up 5 votes
@Override
protected ComboPopup createPopup() {
	BasicComboPopup popup = new BasicComboPopup(comboBox) {

		/**
		 * 
		 */
		private static final long serialVersionUID = 1L;

		@Override
		public void show() {
			Dimension popupSize = ((SteppedComboBox) comboBox).getPopupSize();
			popupSize.setSize(popupSize.width, getPopupHeightForRowCount(comboBox.getMaximumRowCount()));
			Rectangle popupBounds = computePopupBounds(0, comboBox.getBounds().height, popupSize.width, popupSize.height);
			scroller.setMaximumSize(popupBounds.getSize());
			scroller.setPreferredSize(popupBounds.getSize());
			scroller.setMinimumSize(popupBounds.getSize());
			list.invalidate();
			int selectedIndex = comboBox.getSelectedIndex();
			if (selectedIndex == -1) {
				list.clearSelection();
			} else {
				list.setSelectedIndex(selectedIndex);
			}
			list.ensureIndexIsVisible(list.getSelectedIndex());
			setLightWeightPopupEnabled(comboBox.isLightWeightPopupEnabled());

			show(comboBox, popupBounds.x, popupBounds.y);
		}
	};
	popup.getAccessibleContext().setAccessibleParent(comboBox);
	return popup;
}
 
Example 14
Project: QN-ACTR-Release   File: SteppedComboBoxUI.java   View Source Code Vote up 5 votes
@Override
protected ComboPopup createPopup() {
	BasicComboPopup popup = new BasicComboPopup(comboBox) {

		/**
		 * 
		 */
		private static final long serialVersionUID = 1L;

		@Override
		public void show() {
			Dimension popupSize = ((SteppedComboBox) comboBox).getPopupSize();
			popupSize.setSize(popupSize.width, getPopupHeightForRowCount(comboBox.getMaximumRowCount()));
			Rectangle popupBounds = computePopupBounds(0, comboBox.getBounds().height, popupSize.width, popupSize.height);
			scroller.setMaximumSize(popupBounds.getSize());
			scroller.setPreferredSize(popupBounds.getSize());
			scroller.setMinimumSize(popupBounds.getSize());
			list.invalidate();
			int selectedIndex = comboBox.getSelectedIndex();
			if (selectedIndex == -1) {
				list.clearSelection();
			} else {
				list.setSelectedIndex(selectedIndex);
			}
			list.ensureIndexIsVisible(list.getSelectedIndex());
			setLightWeightPopupEnabled(comboBox.isLightWeightPopupEnabled());

			show(comboBox, popupBounds.x, popupBounds.y);
		}
	};
	popup.getAccessibleContext().setAccessibleParent(comboBox);
	return popup;
}
 
Example 15
Project: Equella   File: FlatterButtonUI.java   View Source Code Vote up 5 votes
@Override
public Dimension getPreferredSize(JComponent c)
{
	Dimension d = super.getPreferredSize(c);
	if( mBorder != null )
	{
		Insets ins = mBorder.getBorderInsets(c);
		d.setSize(d.width + ins.left + ins.right, d.height + ins.top + ins.bottom);
	}
	return d;
}
 
Example 16
Project: jaer   File: EyeTarget.java   View Source Code Vote up 5 votes
/** Creates a new instance of EyeTarget */
public EyeTarget() {
	super(caps);
	addGLEventListener(this);
	setAutoSwapBufferMode(true);
	glu=new GLU();
	glut=new GLUT();
	Dimension ss=Toolkit.getDefaultToolkit().getScreenSize();
	ss.setSize(ss.width/2,ss.height/2);
	setSize(ss);
	target=new Target();
}
 
Example 17
Project: cuttlefish   File: SlightMarginTransformer.java   View Source Code Vote up 5 votes
/**
     * @see samples.preview_new_graphdraw.transform.LayoutTransformer#adjustSize(java.awt.Dimension)
     */
    public void adjustSize(Dimension d) {
//        System.out.println("Incoming size = " + d);
        d.setSize(d.getWidth() * percentage, d.getHeight() * percentage);
        this.d = d;
//        System.out.println("    Out size = " + d);
    }
 
Example 18
Project: OpenJSharp   File: GraphicsTests.java   View Source Code Vote up 5 votes
public void init(Graphics2D g2d, Context ctx, Dimension dim) {
    int w = dim.width;
    int h = dim.height;
    AffineTransform at = new AffineTransform();
    at.scale(2.0, 2.0);
    g2d.transform(at);
    dim.setSize(w/2, h/2);
    ctx.pixscale = 4;
}
 
Example 19
Project: rapidminer   File: FancyDropDownButton.java   View Source Code Vote up 4 votes
@Override
public Dimension getMinimumSize() {
	Dimension minSize = super.getMinimumSize();
	minSize.setSize(75, minSize.getHeight());
	return minSize;
}
 
Example 20
Project: jaer   File: FilterPanel.java   View Source Code Vote up 4 votes
public Dimension getMaximumSize() {
    Dimension d = getPreferredSize();
    d.setSize(1000, d.getHeight());
    return d;
}