java.awt.Dimension#setSize ( )源码实例Demo

下面列出了java.awt.Dimension#setSize ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: MeteoInfo   文件: Axis.java
/**
 * Get maximum tick label dimension
 * @param g Graphics2D
 * @return Maximum tick label dimension
 */
public Dimension getMaxTickDim(Graphics2D g) {
    this.updateTickLabels();
    Dimension dim = new Dimension();
    if (this.tickLabels.isEmpty()) {
        return dim;
    }
    
    Dimension dim1;
    double width = dim.getWidth(), height = dim.getHeight();
    for (int i = 0; i < this.tickLabels.size(); i++) {
        ChartText ct = this.tickLabels.get(i);
        ct.setAngle(this.tickLabelAngle);
        dim1 = ct.getTrueDimension(g);
        if (width < dim1.getWidth()){
            width = dim1.getWidth();
        }
        if (height < dim1.getHeight()) {
            height = dim1.getHeight();
        }
    }
    
    dim.setSize(width, height);
    return dim;
}
 
源代码2 项目: littleluck   文件: LuckMenuItemUI.java
/**
 * <p>
 * 重写方法,设置菜单的最小高度为20, 否则会出现菜单项大小不一致的情况。
 * </p>
 *
 * <p>
 * Rewrite method, set the minimum height of the menu is 20, otherwise the
 * menu item size will be inconsistent situation.
 * </p>
 */
@Override
protected Dimension getPreferredMenuItemSize(JComponent c,
                                             Icon checkIcon,
                                             Icon arrowIcon,
                                             int defaultTextIconGap)
{

    Dimension dimension = super.getPreferredMenuItemSize(c, checkIcon,
            arrowIcon, defaultTextIconGap);

    if (dimension != null && dimension.height < 20)
    {
        dimension.setSize(dimension.width, 20);
    }

    return dimension;
}
 
源代码3 项目: openjdk-8-source   文件: GraphicsTests.java
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));
}
 
源代码4 项目: bigtable-sql   文件: SQLPanel.java
CopyLastButton(IApplication app)
{
	super();
	final SquirrelResources rsrc = app.getResources();
	final ImageIcon icon = rsrc.getIcon(SquirrelResources.IImageNames.COPY_SELECTED);
	setIcon(icon);
          // i18n[SQLPanel.copylastbutton.hint=Copy current SQL history to entry area]
	String hint = s_stringMgr.getString("SQLPanel.copylastbutton.hint");
          setToolTipText(hint);
	Dimension dm = getPreferredSize();
	dm.setSize(dm.height, dm.height);
	setPreferredSize(dm);
	addActionListener(new ActionListener()
	{
		public void actionPerformed(ActionEvent e)
		{
			copySelectedItemToEntryArea();
		}
	});
}
 
源代码5 项目: littleluck   文件: LuckRadioBtnMenuItemUI.java
/**
 * <p>
 * 重写方法,设置菜单的最小高度为20, 否则会出现菜单项大小不一致的情况。
 * </p>
 *
 * <p>
 * Rewrite method, set the minimum height of the menu is 20, otherwise the
 * menu item size will be inconsistent situation.
 * </p>
 */
protected Dimension getPreferredMenuItemSize(JComponent c,
                                             Icon checkIcon,
                                             Icon arrowIcon,
                                             int defaultTextIconGap)
{
    Dimension dimension = super.getPreferredMenuItemSize(c, checkIcon,
            arrowIcon, defaultTextIconGap);

    if (dimension != null && dimension.height < 20)
    {
        dimension.setSize(dimension.width, 20);
    }

    return dimension;
}
 
源代码6 项目: VanetSim   文件: MainControlPanel.java
public void tooglePanel(){
	Dimension size = simulatePanel_.getPreferredSize();
	hideBar_ = !hideBar_;
	if(hideBar_){
		//simulatePanel_.getHideBar_().setText("<");
		size.setSize(0, size.height < 800? 800: size.height);
	}
	else{
		//simulatePanel_.getHideBar_().setText(">");
		size.setSize(size.width+155, size.height < 800? 800: size.height);
	}
	setMinimumSize(new Dimension(size.width+50,400));
	editPanel_.setMinimumSize(new Dimension(size.width, size.height));
	//editPanel_.setSize(new Dimension(size.width, size.height));
	this.revalidate();
	this.repaint();
}
 
源代码7 项目: openjdk-jdk8u-backup   文件: GraphicsTests.java
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));
}
 
源代码8 项目: RepDev   文件: TextLineNumber.java
/**
 *  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 );
	}
}
 
源代码9 项目: jdk8u-dev-jdk   文件: GraphicsTests.java
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));
}
 
源代码10 项目: jdk8u-jdk   文件: GraphicsTests.java
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;
}
 
源代码11 项目: dragonwell8_jdk   文件: GraphicsTests.java
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);
}
 
源代码12 项目: openjdk-8-source   文件: GraphicsTests.java
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));
}
 
源代码13 项目: TencentKona-8   文件: GraphicsTests.java
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;
}
 
源代码14 项目: jdk8u60   文件: GraphicsTests.java
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;
}
 
源代码15 项目: openjdk-jdk8u   文件: GraphicsTests.java
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;
}
 
源代码16 项目: jdk8u_jdk   文件: GIFImageWriter.java
/**
 * Compute the source region and destination dimensions taking any
 * parameter settings into account.
 */
private static void computeRegions(Rectangle sourceBounds,
                                   Dimension destSize,
                                   ImageWriteParam p) {
    ImageWriteParam param;
    int periodX = 1;
    int periodY = 1;
    if (p != null) {
        int[] sourceBands = p.getSourceBands();
        if (sourceBands != null &&
            (sourceBands.length != 1 ||
             sourceBands[0] != 0)) {
            throw new IllegalArgumentException("Cannot sub-band image!");
        }

        // Get source region and subsampling factors
        Rectangle sourceRegion = p.getSourceRegion();
        if (sourceRegion != null) {
            // Clip to actual image bounds
            sourceRegion = sourceRegion.intersection(sourceBounds);
            sourceBounds.setBounds(sourceRegion);
        }

        // Adjust for subsampling offsets
        int gridX = p.getSubsamplingXOffset();
        int gridY = p.getSubsamplingYOffset();
        sourceBounds.x += gridX;
        sourceBounds.y += gridY;
        sourceBounds.width -= gridX;
        sourceBounds.height -= gridY;

        // Get subsampling factors
        periodX = p.getSourceXSubsampling();
        periodY = p.getSourceYSubsampling();
    }

    // Compute output dimensions
    destSize.setSize((sourceBounds.width + periodX - 1)/periodX,
                     (sourceBounds.height + periodY - 1)/periodY);
    if (destSize.width <= 0 || destSize.height <= 0) {
        throw new IllegalArgumentException("Empty source region!");
    }
}
 
源代码17 项目: dragonwell8_jdk   文件: GIFImageWriter.java
/**
 * Compute the source region and destination dimensions taking any
 * parameter settings into account.
 */
private static void computeRegions(Rectangle sourceBounds,
                                   Dimension destSize,
                                   ImageWriteParam p) {
    ImageWriteParam param;
    int periodX = 1;
    int periodY = 1;
    if (p != null) {
        int[] sourceBands = p.getSourceBands();
        if (sourceBands != null &&
            (sourceBands.length != 1 ||
             sourceBands[0] != 0)) {
            throw new IllegalArgumentException("Cannot sub-band image!");
        }

        // Get source region and subsampling factors
        Rectangle sourceRegion = p.getSourceRegion();
        if (sourceRegion != null) {
            // Clip to actual image bounds
            sourceRegion = sourceRegion.intersection(sourceBounds);
            sourceBounds.setBounds(sourceRegion);
        }

        // Adjust for subsampling offsets
        int gridX = p.getSubsamplingXOffset();
        int gridY = p.getSubsamplingYOffset();
        sourceBounds.x += gridX;
        sourceBounds.y += gridY;
        sourceBounds.width -= gridX;
        sourceBounds.height -= gridY;

        // Get subsampling factors
        periodX = p.getSourceXSubsampling();
        periodY = p.getSourceYSubsampling();
    }

    // Compute output dimensions
    destSize.setSize((sourceBounds.width + periodX - 1)/periodX,
                     (sourceBounds.height + periodY - 1)/periodY);
    if (destSize.width <= 0 || destSize.height <= 0) {
        throw new IllegalArgumentException("Empty source region!");
    }
}
 
源代码18 项目: JDKSourceCode1.8   文件: GIFImageWriter.java
/**
 * Compute the source region and destination dimensions taking any
 * parameter settings into account.
 */
private static void computeRegions(Rectangle sourceBounds,
                                   Dimension destSize,
                                   ImageWriteParam p) {
    ImageWriteParam param;
    int periodX = 1;
    int periodY = 1;
    if (p != null) {
        int[] sourceBands = p.getSourceBands();
        if (sourceBands != null &&
            (sourceBands.length != 1 ||
             sourceBands[0] != 0)) {
            throw new IllegalArgumentException("Cannot sub-band image!");
        }

        // Get source region and subsampling factors
        Rectangle sourceRegion = p.getSourceRegion();
        if (sourceRegion != null) {
            // Clip to actual image bounds
            sourceRegion = sourceRegion.intersection(sourceBounds);
            sourceBounds.setBounds(sourceRegion);
        }

        // Adjust for subsampling offsets
        int gridX = p.getSubsamplingXOffset();
        int gridY = p.getSubsamplingYOffset();
        sourceBounds.x += gridX;
        sourceBounds.y += gridY;
        sourceBounds.width -= gridX;
        sourceBounds.height -= gridY;

        // Get subsampling factors
        periodX = p.getSourceXSubsampling();
        periodY = p.getSourceYSubsampling();
    }

    // Compute output dimensions
    destSize.setSize((sourceBounds.width + periodX - 1)/periodX,
                     (sourceBounds.height + periodY - 1)/periodY);
    if (destSize.width <= 0 || destSize.height <= 0) {
        throw new IllegalArgumentException("Empty source region!");
    }
}
 
源代码19 项目: azure-devops-intellij   文件: SwingHelper.java
public static void setPreferredHeight(final JComponent component, final int height) {
    final Dimension size = component.getPreferredSize();
    size.setSize(size.getWidth(), JBUI.scale(height));
    component.setPreferredSize(size);
}
 
源代码20 项目: rapidminer-studio   文件: FancyDropDownButton.java
@Override
public Dimension getPreferredSize() {
	Dimension prefSize = super.getPreferredSize();
	prefSize.setSize(prefSize.getWidth() + 75, prefSize.getHeight() + 20);
	return prefSize;
}