当前位置: 首页>>代码示例>>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;未经允许,请勿转载。