当前位置: 首页>>代码示例>>Java>>正文


Java Dimension.getWidth方法代码示例

本文整理汇总了Java中java.awt.Dimension.getWidth方法的典型用法代码示例。如果您正苦于以下问题:Java Dimension.getWidth方法的具体用法?Java Dimension.getWidth怎么用?Java Dimension.getWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.Dimension的用法示例。


在下文中一共展示了Dimension.getWidth方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCanonicalForm

import java.awt.Dimension; //导入方法依赖的package包/类
/**
 * Get the canonical form of this request.
 *
 * @See http://iiif.io/api/image/2.1/#canonical-uri-syntax
 */
public String getCanonicalForm(Dimension nativeSize, ImageApiProfile profile) {
  Dimension resolved = this.resolve(nativeSize, profile);
  // "w," requests are already canonical
  double nativeRatio = nativeSize.getWidth() / nativeSize.getHeight();
  double resolvedRatio = resolved.getWidth() / resolved.getHeight();
  if (resolved.equals(nativeSize)) {
    return "full";
  } else if (this.width != null && this.height == null) {
    return this.toString();
  } else if (Math.floor(resolvedRatio * nativeSize.getHeight()) == nativeSize.getWidth() ||
             Math.ceil(resolvedRatio * nativeSize.getHeight()) == nativeSize.getWidth()) {
    return String.format("%d,", resolved.width);
  } else {
    return String.format("%d,%d", resolved.width, resolved.height);
  }
}
 
开发者ID:dbmdz,项目名称:iiif-apis,代码行数:22,代码来源:SizeRequest.java

示例2: setFitZoom

import java.awt.Dimension; //导入方法依赖的package包/类
public void setFitZoom(Dimension size) {
    Dimension2D pageSize = getPageSize();
    int pageCount = printable.getPageCount();
    if (pageCount == 0)
        return;
    double xy = (pageSize.getWidth() + W_SPACE)
            * (pageSize.getHeight() + W_SPACE) * (pageCount + 1);
    double mxy = size.getWidth() * size.getHeight();
    double zoom = Math.sqrt(mxy / xy);
    int columnCount = (int) (size.getWidth() / ((pageSize.getWidth() + W_SPACE
            / zoom) * zoom));
    if (columnCount <= 0)
        columnCount = 1;
    if (columnCount > pageCount)
        columnCount = pageCount;
    setup(columnCount, zoom);
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:18,代码来源:PrintPreviewComponent.java

示例3: getPreferredSize

import java.awt.Dimension; //导入方法依赖的package包/类
public Dimension getPreferredSize() {
    if (isPreferredSizeSet()) {
        return super.getPreferredSize();
    }
    
    int height = Math.max(500, currentCustomizer.getPreferredSize().height + 50);
    int width = Math.max(800, currentCustomizer.getPreferredSize().width + 240);
    
    Dimension dim = super.getPreferredSize();
    if (dim == null) {
        return new Dimension(width, height);
    }
    if (dim.getWidth() < width || dim.getHeight() < height) {
        return new Dimension(width, height);
    }
    
    if (dim.getWidth() > MAX_WIDTH) {
        dim.width = MAX_WIDTH;
    }
    if (dim.getHeight() > MAX_HEIGHT) {
        dim.height = MAX_HEIGHT;
    }
    return dim;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:CustomizerPane.java

示例4: createContentImage

import java.awt.Dimension; //导入方法依赖的package包/类
private BufferedImage createContentImage( Component c, Dimension contentSize ) {
    GraphicsConfiguration config = GraphicsEnvironment.getLocalGraphicsEnvironment()
                .getDefaultScreenDevice().getDefaultConfiguration();

    BufferedImage res = config.createCompatibleImage(contentSize.width, contentSize.height);
    Graphics2D g = res.createGraphics();
    //some components may be non-opaque so just black rectangle would be painted then
    g.setColor( Color.white );
    g.fillRect(0, 0, contentSize.width, contentSize.height);
    if( WinSysPrefs.HANDLER.getBoolean(WinSysPrefs.DND_SMALLWINDOWS, true) && c.getWidth() > 0 && c.getHeight() > 0 ) {
        double xScale = contentSize.getWidth() / c.getWidth();
        double yScale = contentSize.getHeight() / c.getHeight();
        g.setTransform(AffineTransform.getScaleInstance(xScale, yScale) );
    }
    c.paint(g);
    return res;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:DragWindow.java

示例5: startEditingAtCell

import java.awt.Dimension; //导入方法依赖的package包/类
/**
 * Selects the specified cell and initiates editing.
 * The edit-attempt fails if the <code>CellEditor</code>
 * does not allow
 * editing for the specified item.
 */
public void startEditingAtCell(Object cell) {
	graph.startEditingAtCell(cell);
	if ((cell != null) && (cell instanceof JmtCell)) {
		JmtCell jcell = (JmtCell) cell;
		showStationParameterPanel(((CellComponent) jcell.getUserObject()).getKey(),
				StationParameterPanel.INPUT_SECTION, null);
		// Updates cell dimensions if name was changed too much...
		Hashtable<Object, Map> nest = new Hashtable<Object, Map>();
		Dimension cellDimension = jcell.getSize(graph);
		Map attr = jcell.getAttributes();
		Rectangle2D oldBounds = GraphConstants.getBounds(attr);
		if (oldBounds.getWidth() != cellDimension.getWidth()) {
			GraphConstants.setBounds(attr, new Rectangle2D.Double(oldBounds.getX(), oldBounds.getY(),
					cellDimension.getWidth(), cellDimension.getHeight()));
			nest.put(cell, attr);
			jcell.updatePortPositions(nest, GraphConstants.getIcon(attr), cellDimension);
			graph.getGraphLayoutCache().edit(nest);
		}
	}
	// Blocking region editing
	else if ((cell != null) && (cell instanceof BlockingRegion)) {
		showBlockingRegionParameterPanel(((BlockingRegion) cell).getKey());
	}
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:31,代码来源:Mediator.java

示例6: rescale

import java.awt.Dimension; //导入方法依赖的package包/类
/**
 * Rescales an icon.
 * @param src the original icon.
 * @param newMinSize the minimum size of the new icon. The width and height of
 *                   the returned icon will be at least the width and height
 *                   respectively of newMinSize.
 * @param an ImageObserver.
 * @return the rescaled icon.
 */
public static ImageIcon rescale(ImageIcon src, Dimension newMinSize, ImageObserver observer) {
    double widthRatio =  newMinSize.getWidth() / (double) src.getIconWidth();
    double heightRatio = newMinSize.getHeight() / (double) src.getIconHeight();
    double scale = widthRatio > heightRatio ? widthRatio : heightRatio;
    
    int w = (int) Math.round(scale * src.getIconWidth());
    int h = (int) Math.round(scale * src.getIconHeight());
    BufferedImage dst = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
    Graphics2D g2 = dst.createGraphics();
    g2.drawImage(src.getImage(), 0, 0, w, h, observer);
    g2.dispose();
    return new ImageIcon(dst);
}
 
开发者ID:Esri,项目名称:defense-solutions-proofs-of-concept,代码行数:23,代码来源:Utilities.java

示例7: releayout

import java.awt.Dimension; //导入方法依赖的package包/类
public void releayout() {
	mxHierarchicalLayout layout = new mxHierarchicalLayout(graph, SwingConstants.NORTH);
	layout.execute(graph.getDefaultParent());

	mxRectangle graphSize = graph.getGraphBounds();
	Dimension viewPortSize = graphComponent.getViewport().getSize();

	double ratiox = viewPortSize.getWidth() / graphSize.getWidth();
	double ratioy = viewPortSize.getHeight() / graphSize.getHeight();
	double ratio = ratiox < ratioy ? ratiox : ratioy;

	graphComponent.zoom(ratio);
}
 
开发者ID:roscisz,项目名称:KernelHive,代码行数:14,代码来源:InfrastructureGraphPanel.java

示例8: getSizeRelatedToScreenSize

import java.awt.Dimension; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:17,代码来源:MainWindow.java

示例9: initialize

import java.awt.Dimension; //导入方法依赖的package包/类
/**
 * This method initializes this.
 * @return void
 */
private void initialize() {
	
	String title = Language.translate("Letzte Änderungen") + " - ";
	title += Application.getGlobalInfo().getVersionInfo().getFullVersionInfo(true, null);
	this.setTitle(title);
	
	this.setIconImage(GlobalInfo.getInternalImage("AgentGUI.png"));
	this.setSize(850, 550);
	this.setModal(true);
	this.setResizable(true);
	this.setContentPane(getJContentPane());
	this.registerEscapeKeyStroke();
	
	// --- Set the Look and Feel of the Dialog ------------------
	this.setLookAndFeel();

	// --- Center dialog ----------------------------------------
	Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); 
	Double newWidth  = screenSize.getWidth()  * 0.7;
	Double newHeight = screenSize.getHeight() * 0.8;
	int top  = (screenSize.height - newHeight.intValue()) / 2; 
    int left = (screenSize.width  - newWidth.intValue()) / 2;
    this.setSize(newWidth.intValue(), newHeight.intValue());
    this.setLocation(left, top);
	
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:31,代码来源:ChangeDialog.java

示例10: startEditingAtCell

import java.awt.Dimension; //导入方法依赖的package包/类
/**
 * Selects the specified cell and initiates editing.
 * The edit-attempt fails if the <code>CellEditor</code>
 * does not allow
 * editing for the specified item.
 */
public void startEditingAtCell(Object cell) {
	graph.startEditingAtCell(cell);
	if ((cell != null) && (cell instanceof JmtCell)) {
		JmtCell jcell = (JmtCell) cell;
		StationParameterPanel stationPanel = new jmt.gui.common.panels.StationParameterPanel(model, model,
				((CellComponent) jcell.getUserObject()).getKey());
		// Adds on the top a panel to change station name
		stationPanel.add(new StationNamePanel(model, ((CellComponent) jcell.getUserObject()).getKey()), BorderLayout.NORTH);
		dialogFactory.getDialog(stationPanel, "Editing " + jcell.getUserObject().toString() + " Properties...");

		// Updates cell dimensions if name was changed too much...
		Hashtable<Object, Map> nest = new Hashtable<Object, Map>();
		Dimension cellDimension = jcell.getSize(graph);
		Map attr = jcell.getAttributes();
		Rectangle2D oldBounds = GraphConstants.getBounds(attr);
		if (oldBounds.getWidth() != cellDimension.getWidth()) {
			GraphConstants.setBounds(attr, new Rectangle2D.Double(oldBounds.getX(), oldBounds.getY(), cellDimension.getWidth(), cellDimension
					.getHeight()));
			nest.put(cell, attr);
			jcell.updatePortPositions(nest, GraphConstants.getIcon(attr), cellDimension);
			graph.getGraphLayoutCache().edit(nest);
		}
	}
	// Blocking region editing
	else if ((cell != null) && (cell instanceof BlockingRegion)) {
		Object regionKey = ((BlockingRegion) cell).getKey();
		dialogFactory.getDialog(new BlockingRegionParameterPanel(model, model, regionKey), "Editing " + model.getRegionName(regionKey)
				+ " Properties...");
	}
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:37,代码来源:Mediator.java

示例11: ensureWidth

import java.awt.Dimension; //导入方法依赖的package包/类
/**
 * Ensures that the process is at least width wide.
 *
 * @param executionUnit
 *            the process to ensure the minimum width
 * @param width
 *            the mininum width
 */
void ensureWidth(final ExecutionUnit executionUnit, final int width) {
	Dimension old = new Dimension((int) model.getProcessWidth(executionUnit),
			(int) model.getProcessHeight(executionUnit));
	if (width > old.getWidth()) {
		model.setProcessWidth(executionUnit, width);
		balance();
		model.fireProcessSizeChanged();
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:18,代码来源:ProcessRendererController.java

示例12: paintComponent

import java.awt.Dimension; //导入方法依赖的package包/类
/**
 * Draws the sample.
 *
 * @param g  the graphics device.
 */
public void paintComponent(Graphics g) {

    Graphics2D g2 = (Graphics2D) g;
    g2.setRenderingHint(
        RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF
    );
    Dimension size = getSize();
    Insets insets = getInsets();
    double ww = size.getWidth() - insets.left - insets.right;
    double hh = size.getHeight() - insets.top - insets.bottom;

    g2.setStroke(new BasicStroke(1.0f));

    double y1 = insets.top;
    double y2 = y1 + hh;
    double xx = insets.left;
    Line2D line = new Line2D.Double();
    int count = 0;
    while (xx <= insets.left + ww) {
        count++;
        line.setLine(xx, y1, xx, y2);
        g2.setPaint(this.palette.getColor(count));
        g2.draw(line);
        xx += 1;
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:32,代码来源:PaletteSample.java

示例13: showStatusToolTip

import java.awt.Dimension; //导入方法依赖的package包/类
private void showStatusToolTip(org.eclipse.swt.graphics.Point location) {

		if (!componentCanvas.isFocused())
			return;

		componentCanvas = getComponentCanvas();
		if (componentCanvas.getComponentTooltip() == null) {
			componentToolTip = getStatusToolTip(componentCanvas.getCanvasControl().getShell(), location);
			componentBounds = getComponentBounds();
			componentCanvas.issueToolTip(componentToolTip, componentBounds);

			componentToolTip.setVisible(true);
			setStatusToolTipFocusListener();
			org.eclipse.swt.graphics.Point tooltipSize = componentToolTip.computeSizeHint();
			// componentToolTip.setSizeConstraints(300, 100);
			if (tooltipSize.x > 300) {
				tooltipSize.x = 300;
			}
			componentToolTip.setSize(tooltipSize.x, tooltipSize.y);

			Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
			double width = screenSize.getWidth();
			double height = screenSize.getHeight();

			int newX, newY;
			int offset = 10;
			if ((componentToolTip.getBounds().x + componentToolTip.getBounds().width) > width) {
				newX = componentToolTip.getBounds().x
						- (int) ((componentToolTip.getBounds().x + componentToolTip.getBounds().width) - width)
						- offset;
			} else {
				newX = componentToolTip.getBounds().x;
			}

			if ((componentToolTip.getBounds().y + componentToolTip.getBounds().height) > height) {
				newY = componentToolTip.getBounds().y - getBounds().height - componentToolTip.getBounds().height
						- offset;
			} else {
				newY = componentToolTip.getBounds().y;
			}
			org.eclipse.swt.graphics.Point newLocation = new org.eclipse.swt.graphics.Point(newX, newY);
			componentToolTip.setLocation(newLocation);

		}
	}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:46,代码来源:ComponentFigure.java

示例14: initCamera

import java.awt.Dimension; //导入方法依赖的package包/类
static WebcamData initCamera(String cc, String camName)
{
	LinkedHashMap<String, Webcam> detectedCameras = new LinkedHashMap<String, Webcam>();
	List<Webcam> cams = Webcam.getWebcams();
	Webcam webcam = null;
	for (Webcam cam : cams)
	{
		detectedCameras.put(cam.getName(), cam);
		if (cam.getName().startsWith(camName))
		{
			webcam = cam;
		}
	}
	if (webcam == null)
	{
		throw new WebcamInitException("Webcam listed in config was not found: " + camName);
	}
	WebcamData data = new WebcamData(cc, webcam);
	webcam.setImageTransformer(new WebcamTransformer());
	log.info("Initializing webcam: " + camName);
	Dimension[] sizes = webcam.getViewSizes();
	Dimension dimension = null;
	for (Dimension d : sizes)
	{
		log.info("Found image dimension: " + d.getWidth() + "x" + d.getHeight());
		if (d.getWidth() == 320)
		{
			dimension = d;
		}
	}
	if (dimension == null)
	{
		dimension = sizes[0];
	}
	log.info("Selected image dimension: " + dimension.getWidth() + "x" + dimension.getHeight());
	if (!webcam.getViewSize().equals(dimension))
	{
		webcam.setViewSize(dimension);
	}
	webcam.open(true);
	webcam.addWebcamListener(data);
	System.out.println(webcam.getViewSize());
	((WebcamDefaultDevice) webcam.getDevice()).FAULTY = false;
	return data;
}
 
开发者ID:PolyphasicDevTeam,项目名称:NoMoreOversleeps,代码行数:46,代码来源:WebcamCapture.java

示例15: Frame

import java.awt.Dimension; //导入方法依赖的package包/类
public Frame() throws HeadlessException {

		super("Symulacja Efektu Fizeau");

		try {
			UIManager.setLookAndFeel(
					UIManager.getSystemLookAndFeelClassName());

		} catch (Exception e1) {

			e1.printStackTrace();
			System.out.println("błąd LF");
		}
		SwingUtilities.updateComponentTreeUI(Frame.this);

		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		WIDTH = screenSize.getWidth();
		HEIGHT = screenSize.getHeight();

		setExtendedState(MAXIMIZED_BOTH); 
		setUndecorated(false);
		setPreferredSize(new Dimension((int)WIDTH,(int)HEIGHT));
		//setResizable(false);
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setBackground(Color.WHITE);
		setLayout(new BorderLayout());

		chooser = new JFileChooser();

		this.animation = new AnimationPanel(200,500,5000,WIDTH,HEIGHT);
		this.bottom = new BottomPanel();

		this.add(this.animation, BorderLayout.CENTER);
		this.add(this.bottom, BorderLayout.SOUTH);
		pack();

		this.bottom.runButtonPanel.runButton.addActionListener(new RunButtonListener(this));
		this.bottom.settings.velSlider.addChangeListener(new SliderListener(this));
		this.bottom.runButtonPanel.fizeauButton.addActionListener(new FizeauButtonListener(this));
		this.bottom.settings.distance.addItemListener(new DistanceListener(this));
		this.bottom.settings.nTeeth.addItemListener(new ToothListener(this));
		this.bottom.runButtonPanel.saveButton.addActionListener(new SaveButtonListener(this));
	}
 
开发者ID:Tosbert,项目名称:FizeauExperimentSimulation,代码行数:44,代码来源:Frame.java


注:本文中的java.awt.Dimension.getWidth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。