當前位置: 首頁>>代碼示例>>Java>>正文


Java Dimension2D.getWidth方法代碼示例

本文整理匯總了Java中java.awt.geom.Dimension2D.getWidth方法的典型用法代碼示例。如果您正苦於以下問題:Java Dimension2D.getWidth方法的具體用法?Java Dimension2D.getWidth怎麽用?Java Dimension2D.getWidth使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.geom.Dimension2D的用法示例。


在下文中一共展示了Dimension2D.getWidth方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setFitZoom

import java.awt.geom.Dimension2D; //導入方法依賴的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

示例2: toImage

import java.awt.geom.Dimension2D; //導入方法依賴的package包/類
/** @return A MultiResolution image created from nsImagePtr, or null. */
private Image toImage() {
    if (ptr == 0) return null;

    final Dimension2D size = nativeGetNSImageSize(ptr);
    final int w = (int)size.getWidth();
    final int h = (int)size.getHeight();

    Dimension2D[] sizes
            = nativeGetNSImageRepresentationSizes(ptr,
                    size.getWidth(), size.getHeight());

    return sizes == null || sizes.length < 2 ?
            new MultiResolutionCachedImage(w, h, (width, height)
                    -> toImage(w, h, width, height))
            : new MultiResolutionCachedImage(w, h, sizes, (width, height)
                    -> toImage(w, h, width, height));
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:19,代碼來源:CImage.java

示例3: setGraphicsNode

import java.awt.geom.Dimension2D; //導入方法依賴的package包/類
public void setGraphicsNode(GraphicsNode gn, boolean createDispatcher) {
    Dimension2D dim = bridgeContext.getDocumentSize();
    Dimension   mySz = new Dimension((int)dim.getWidth(),
                                     (int)dim.getHeight());
    JSVGComponent.this.setMySize(mySz);
    SVGSVGElement elt = svgDocument.getRootElement();
    prevComponentSize = getSize();
    AffineTransform at = calculateViewingTransform
        (fragmentIdentifier, elt);
    CanvasGraphicsNode cgn = getCanvasGraphicsNode(gn);
    if (cgn != null) {
        cgn.setViewingTransform(at);
    }
    viewingTransform = null;
    initialTransform = new AffineTransform();
    setRenderingTransform(initialTransform, false);
    jsvgComponentListener.updateMatrix(initialTransform);
    addJGVTComponentListener(jsvgComponentListener);
    addComponentListener(jsvgComponentListener);
    super.setGraphicsNode(gn, createDispatcher);
}
 
開發者ID:git-moss,項目名稱:Push2Display,代碼行數:22,代碼來源:JSVGComponent.java

示例4: createEdgeNode

import java.awt.geom.Dimension2D; //導入方法依賴的package包/類
private PPath createEdgeNode(Dimension2D size, Color color){
	
	GeneralPath path = new GeneralPath();
	
	float width = (float)size.getWidth();
	float height = (float)size.getHeight();

	path.moveTo(-width / 2, height / 4);
	path.curveTo(-width / 2, height / 2, width / 2, height / 2, width / 2, height / 4);
	path.lineTo(width / 2, -height / 4);
	path.curveTo(width / 2, -height / 2, -width / 2, -height / 2, -width / 2, -height / 4);
	path.closePath();

	PPath edgeNode = new PPath(path);
	edgeNode.setPaint(color);
	edgeNode.setStrokePaint(ColorUtils.darkerColor(color, 0.3));
	
	return edgeNode;
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:20,代碼來源:MembraneChannelNode.java

示例5: updateLayout

import java.awt.geom.Dimension2D; //導入方法依賴的package包/類
@Override
protected void updateLayout() {
    super.updateLayout();
    Dimension2D worldSize = getWorldSize();
    if ( worldSize.getWidth() > 0 && worldSize.getHeight() > 0 ) {

        // make the reward fill the play area
        PBounds newBounds = new PBounds( 0, 0, worldSize.getWidth(), worldSize.getHeight() );
        rewardNode.setBounds( newBounds );

        // center nodes in the play area
        centerNode( gameSettingsNode );
        centerNode( gameOverNode );
        centerNode( parentNode );
    }
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:17,代碼來源:GameCanvas.java

示例6: updateAutoSize

import java.awt.geom.Dimension2D; //導入方法依賴的package包/類
/**
 * Overwritten to freeze nodes to their center on
 * size changes.
 */
@Override
public void updateAutoSize(CellView view) {
    if (view != null && !isEditing()) {
        Rectangle2D bounds =
            (view.getAttributes() != null) ? GraphConstants.getBounds(view.getAttributes())
                : null;
        AttributeMap attrs = getModel().getAttributes(view.getCell());
        if (bounds == null) {
            bounds = GraphConstants.getBounds(attrs);
        }
        if (bounds != null) {
            boolean autosize = GraphConstants.isAutoSize(view.getAllAttributes());
            boolean resize = GraphConstants.isResize(view.getAllAttributes());
            if (autosize || resize) {
                Dimension2D d = getPreferredSize(view);
                int inset = 2 * GraphConstants.getInset(view.getAllAttributes());
                // adjust the x,y corner so that the center stays in place
                double shiftX = (bounds.getWidth() - d.getWidth() - inset) / 2;
                double shiftY = (bounds.getHeight() - d.getHeight() - inset) / 2;
                bounds.setFrame(bounds.getX() + shiftX, bounds.getY() + shiftY, d.getWidth(),
                    d.getHeight());
                // Remove resize attribute
                snap(bounds);
                if (resize) {
                    if (view.getAttributes() != null) {
                        view.getAttributes().remove(GraphConstants.RESIZE);
                    }
                    attrs.remove(GraphConstants.RESIZE);
                }
                view.refresh(getGraphLayoutCache(), getGraphLayoutCache(), false);
            }
        }
    }
}
 
開發者ID:meteoorkip,項目名稱:JavaGraph,代碼行數:39,代碼來源:JGraph.java

示例7: newInstance

import java.awt.geom.Dimension2D; //導入方法依賴的package包/類
/**
 * Factory method to construct a new nod layout out of an attribute map.
 * Parameters not provided in the attribute map receive a default value.
 * @param visuals the visual attribute map
 * @return a new node layout based on <code>jAttr</code>
 */
static public JVertexLayout newInstance(VisualMap visuals) {
    Dimension2D size = visuals.getNodeSize();
    Point2D pos = visuals.getNodePos();
    return new JVertexLayout(new Rectangle2D.Double(pos.getX() - size.getWidth() / 2,
        pos.getY() - size.getHeight() / 2, size.getWidth(), size.getHeight()));
}
 
開發者ID:meteoorkip,項目名稱:JavaGraph,代碼行數:13,代碼來源:JVertexLayout.java

示例8: setOnePageZoom

import java.awt.geom.Dimension2D; //導入方法依賴的package包/類
public void setOnePageZoom(Dimension size) {
    Dimension2D pageSize = getPageSize();
    int pageCount = printable.getPageCount();
    if (pageCount == 0)
        return;
    double zoom = size.getWidth() / (pageSize.getWidth());
    int columnCount = 1;
    setup(columnCount, zoom);
}
 
開發者ID:Vitaliy-Yakovchuk,項目名稱:ramus,代碼行數:10,代碼來源:PrintPreviewComponent.java

示例9: toImage

import java.awt.geom.Dimension2D; //導入方法依賴的package包/類
/** @return A MultiResolution image created from nsImagePtr, or null. */
private Image toImage() {
    if (ptr == 0) {
        return null;
    }

    AtomicReference<Dimension2D> sizeRef = new AtomicReference<>();
    execute(ptr -> {
        sizeRef.set(nativeGetNSImageSize(ptr));
    });
    final Dimension2D size = sizeRef.get();
    if (size == null) {
        return null;
    }
    final int w = (int)size.getWidth();
    final int h = (int)size.getHeight();
    AtomicReference<Dimension2D[]> repRef = new AtomicReference<>();
    execute(ptr -> {
        repRef.set(nativeGetNSImageRepresentationSizes(ptr, size.getWidth(),
                                                       size.getHeight()));
    });
    Dimension2D[] sizes = repRef.get();

    return sizes == null || sizes.length < 2 ?
            new MultiResolutionCachedImage(w, h, (width, height)
                    -> toImage(w, h, width, height))
            : new MultiResolutionCachedImage(w, h, sizes, (width, height)
                    -> toImage(w, h, width, height));
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:30,代碼來源:CImage.java

示例10: asDimension

import java.awt.geom.Dimension2D; //導入方法依賴的package包/類
public static Dimension asDimension (Dimension2D dim)
{
  if (dim instanceof Dimension || dim == null)
    return (Dimension) dim;
  else
    return new Dimension((int) (dim.getWidth() + 0.5),
                         (int) (dim.getHeight() + 0.5));
}
 
開發者ID:spurious,項目名稱:kawa-mirror,代碼行數:9,代碼來源:Display.java

示例11: updateLayout

import java.awt.geom.Dimension2D; //導入方法依賴的package包/類
@Override
protected void updateLayout() {
    Dimension2D worldSize = getWorldSize();
    if ( worldSize.getWidth() <= 0 || worldSize.getHeight() <= 0 ) {
        // canvas hasn't been sized, blow off layout
        return;
    }
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:9,代碼來源:BuildAMoleculeCanvas.java

示例12: BackgroundCellNode

import java.awt.geom.Dimension2D; //導入方法依賴的package包/類
public BackgroundCellNode( Point2D centerLocation, Dimension2D size, double rotationAngle, int seed ) {
    PPath cellBody = new PhetPPath( BioShapeUtils.createEColiLikeShape( centerLocation, size.getWidth(), DEFAULT_SIZE.getHeight(), 0, seed ),
                                    new BasicStroke( 500f ), // This is big because the cell is only ever shown when zoomed way out.
                                    Color.WHITE );
    cellBody.rotateAboutPoint( rotationAngle, centerLocation );
    Paint cellInteriorPaint = new GradientPaint( (float) ( centerLocation.getX() - size.getWidth() * 0.1 ),
                                                 (float) ( centerLocation.getY() - size.getHeight() * 0.5 ),
                                                 ColorUtils.darkerColor( CELL_INTERIOR_COLOR, 0.25 ),
                                                 (float) ( centerLocation.getX() + size.getWidth() * 0.1 ),
                                                 (float) ( centerLocation.getY() + size.getHeight() * 0.5 ),
                                                 ColorUtils.brighterColor( CELL_INTERIOR_COLOR, 0.25 ) );
    cellBody.setPaint( cellInteriorPaint );
    addChild( cellBody );
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:15,代碼來源:BackgroundCellNode.java

示例13: createRandomShape

import java.awt.geom.Dimension2D; //導入方法依賴的package包/類
public static Shape createRandomShape( Dimension2D size, int seed ) {
    Random rand = new Random( seed );
    List<Point2D> pointList = new ArrayList<Point2D>();
    // Create a series of points that will enclose a space.
    for ( double angle = 0; angle < 1.9 * Math.PI; angle += Math.PI / 10 + rand.nextDouble() * Math.PI / 10 ) {
        pointList.add( Vector2D.createPolar( 0.5 + rand.nextDouble(), angle ).toPoint2D() );
    }

    Shape unscaledShape = createRandomShapeFromPoints( pointList, seed );

    // Scale the shape to the specified size.
    double horizontalScale = size.getWidth() / unscaledShape.getBounds2D().getWidth();
    double verticalScale = size.getHeight() / unscaledShape.getBounds2D().getHeight();
    return AffineTransform.getScaleInstance( horizontalScale, verticalScale ).createTransformedShape( unscaledShape );
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:16,代碼來源:BioShapeUtils.java

示例14: updateLayout

import java.awt.geom.Dimension2D; //導入方法依賴的package包/類
@Override protected void updateLayout() {
    super.updateLayout();

    Dimension2D worldSize = getWorldSize();
    if ( worldSize.getWidth() <= 0 || worldSize.getHeight() <= 0 ) {
        // canvas hasn't been sized, blow off layout
        return;
    }

    // adjust the world bounds
    Point3D p = mvt.viewToModelDelta( worldSize.getWidth(), worldSize.getHeight() );
    model.getWorldBounds().setBounds( 0, 0, p.getX(), p.getY() );
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:14,代碼來源:CLCanvas.java

示例15: updateLayout

import java.awt.geom.Dimension2D; //導入方法依賴的package包/類
@Override
protected void updateLayout() {

    Dimension2D worldSize = getWorldSize();
    if ( worldSize.getWidth() <= 0 || worldSize.getHeight() <= 0 ) {
        // canvas hasn't been sized, blow off layout
        return;
    }
    else if ( BuildAnAtomConstants.DEBUG_CANVAS_UPDATE_LAYOUT ) {
        System.out.println( "ExampleCanvas.updateLayout worldSize=" + worldSize );//XXX
    }

    //XXX lay out nodes
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:15,代碼來源:BuildAnAtomGameCanvas.java


注:本文中的java.awt.geom.Dimension2D.getWidth方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。