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


Java Dimension2D类代码示例

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


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

示例1: applyTransforms

import java.awt.geom.Dimension2D; //导入依赖的package包/类
public void applyTransforms() {
    double scaleX = getScaleX();
    double scaleY = getScaleY();
    for (Bounds bounds : this.bounds) {
        if (bounds instanceof QBounds) {
            QBounds qBounds = (QBounds) bounds;
            Point2D point = qBounds.getLocation();
            qBounds.setLocation(new Point2D.Double(point.getX()
                    + translate.getX(), point.getY() + translate.getY()));
            Dimension2D d = qBounds.getSize();
            qBounds.setSize(new Dimension2DImpl(d.getWidth() * scaleX, d
                    .getHeight()
                    * scaleY));
        }
    }
    clear();
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:18,代码来源:Group.java

示例2: getPageSize

import java.awt.geom.Dimension2D; //导入依赖的package包/类
public Dimension2D getPageSize() {
    int pageCount = printable.getPageCount();
    double pageWidth = 0;
    double pageHeight = 0;
    PageFormat pageFormat = new PageFormat();
    for (int i = 0; i < pageCount; i++) {
        pageFormat = printable.getPageFormat(pageFormat, i);
        double w = pageFormat.getWidth();
        double h = pageFormat.getHeight();

        if (pageWidth < w)
            pageWidth = w;
        if (pageHeight < h)
            pageHeight = h;
    }

    final double fw = pageWidth;
    final double fh = pageHeight;
    return new Dimension2D() {

        @Override
        public void setSize(double width, double height) {
        }

        @Override
        public double getWidth() {
            return fw;
        }

        @Override
        public double getHeight() {
            return fh;
        }
    };
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:36,代码来源:PrintPreviewComponent.java

示例3: 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

示例4: 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

示例5: mouseDragged

import java.awt.geom.Dimension2D; //导入依赖的package包/类
public void mouseDragged( final PInputEvent event ) {
    //Some clients such as the LaserNode only pass messages through the mouseDragged function,
    //so check first and see if we need to get the initial location
    if ( lastLocation == null ) {
        mousePressed( event );
    }

    //Compute the global coordinate for where the drag is supposed to take the node
    Point2D newDragPosition = event.getPositionRelativeTo( node.getParent().getParent() );//see note in constructor
    newDragPosition = node.getParent().getParent().localToGlobal( newDragPosition );

    //Bound the desired point within the canvas, accounting for some insets (so some part will always be visible)
    final int inset = 10;
    final ImmutableRectangle2D immutableRectangle2D = new ImmutableRectangle2D( inset, inset, event.getSourceSwingEvent().getComponent().getWidth() - inset * 2, event.getSourceSwingEvent().getComponent().getHeight() - inset * 2 );
    Point2D constrained = immutableRectangle2D.getClosestPoint( newDragPosition );
    Dimension2D delta = new PDimension( constrained.getX() - lastLocation.getX(), constrained.getY() - lastLocation.getY() );

    //Convert from global to the node parent frame
    delta = node.globalToLocal( delta );
    delta = node.localToParent( delta );

    //Translate the node and get ready for next event
    dragNode( new DragEvent( event, new PDimension( delta.getWidth(), delta.getHeight() ) ) );
    lastLocation = constrained;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:26,代码来源:CanvasBoundedDragHandler.java

示例6: 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 animation fill the play area
        PBounds newBounds = new PBounds( 0, 0, worldSize.getWidth(), worldSize.getHeight() );
        gameRewardNode.setBounds( newBounds );

        // center top-level nodes
        centerNode( gameSettingsNode );
        centerNode( gameOverNode );
        centerNode( gamePlayParentNode );
    }
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:17,代码来源:GameCanvas.java

示例7: ProbeNode

import java.awt.geom.Dimension2D; //导入依赖的package包/类
public ProbeNode( Dimension2D size, Color color, String label, Color labelColor ) {

            PPath pathNode = new PPath( new Rectangle2D.Double( -size.getWidth() / 2, -size.getHeight(), size.getWidth(), Math.abs( size.getHeight() ) ) );
            pathNode.setStroke( PROBE_STROKE );
            pathNode.setStrokePaint( PROBE_STROKE_COLOR );
            pathNode.setPaint( color );
            addChild( pathNode );

            PText labelNode = new PText( label );
            labelNode.setTextPaint( labelColor );
            labelNode.setFont( PROBE_LABEL_FONT );
            addChild( labelNode );

            double x = pathNode.getFullBoundsReference().getCenterX() - ( labelNode.getFullBoundsReference().getWidth() / 2 );
            double y = pathNode.getFullBoundsReference().getMaxY() - labelNode.getFullBoundsReference().getHeight() - 3;
            labelNode.setOffset( x, y );
        }
 
开发者ID:mleoking,项目名称:PhET,代码行数:18,代码来源:ConductivityTesterNode.java

示例8: createRoundedEdgeNode

import java.awt.geom.Dimension2D; //导入依赖的package包/类
private PPath createRoundedEdgeNode( 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 * 0.6f, width / 2, height * 0.6f, width / 2, height / 4 );
        path.lineTo( width / 2, -height / 4 );
        path.curveTo( width / 2, -height * 0.6f, -width / 2, -height * 0.6f, -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

示例9: BodyGraphic

import java.awt.geom.Dimension2D; //导入依赖的package包/类
public BodyGraphic() {
    try {
        imageGraphic = new PImage( ImageLoader.loadBufferedImage( MEASURING_TAPE_IMAGE ) );
    }
    catch ( IOException e ) {
        e.printStackTrace();
    }
    addChild( imageGraphic );

    addInputEventListener( new PBasicInputEventHandler() {
        public void mouseDragged( PInputEvent event ) {
            Dimension2D dx = getDelta( event );
            translateAll( dx.getWidth(), dx.getHeight() );
        }
    } );

    int crossHairLength = 10;
    CrossHairGraphic crossHairGraphic = new CrossHairGraphic( crossHairLength );
    addChild( crossHairGraphic );
    crossHairGraphic.setOffset( imageGraphic.getWidth() - crossHairLength / 2, imageGraphic.getHeight() - crossHairLength / 2 );
    addInputEventListener( new CursorHandler( Cursor.HAND_CURSOR ) );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:23,代码来源:MeasuringTape.java

示例10: EndGraphic

import java.awt.geom.Dimension2D; //导入依赖的package包/类
public EndGraphic() {
    Ellipse2D.Double shape = new Ellipse2D.Double( 0, 0, 15, 15 );

    phetShapeGraphic = new PPath( shape );
    phetShapeGraphic.setPaint( Color.black );
    addChild( phetShapeGraphic );
    addInputEventListener( new PBasicInputEventHandler() {
        public void mouseDragged( PInputEvent event ) {
            Dimension2D dx = getDelta( event );
            MeasuringTape.this.translateEndPoint( dx.getWidth(), dx.getHeight() );
        }
    } );
    addInputEventListener( new CursorHandler( Cursor.HAND_CURSOR ) );

    int crossHairSize = 10;
    CrossHairGraphic crossHairGraphic = new CrossHairGraphic( crossHairSize );
    crossHairGraphic.setPaint( Color.yellow );
    addChild( crossHairGraphic );

    crossHairGraphic.setOffset( phetShapeGraphic.getWidth() / 2 - crossHairSize / 2, phetShapeGraphic.getHeight() / 2 - crossHairSize / 2 );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:22,代码来源:MeasuringTape.java

示例11: main

import java.awt.geom.Dimension2D; //导入依赖的package包/类
/**
 * Main routine that constructs a PhET Piccolo canvas in a window.
 *
 * @param args
 */
public static void main( String[] args ) {

    Dimension2D stageSize = new PDimension( 500, 300 );

    PhetPCanvas canvas = new PhetPCanvas();
    // Set up the canvas-screen transform.
    canvas.setWorldTransformStrategy( new PhetPCanvas.CenteredStage( canvas, stageSize ) );

    ModelViewTransform mvt = ModelViewTransform.createSinglePointScaleInvertedYMapping(
            new Point2D.Double( 0, 0 ),
            new Point( (int) Math.round( stageSize.getWidth() * 0.5 ), (int) Math.round( stageSize.getHeight() * 0.50 ) ),
            1 ); // "Zoom factor" - smaller zooms out, larger zooms in.

    canvas.getLayer().addChild( new TiltPredictionSelectorNode( new Property<BalanceGameModel.GameState>( BalanceGameModel.GameState.PRESENTING_INTERACTIVE_CHALLENGE ) ) );

    // Boiler plate app stuff.
    JFrame frame = new JFrame();
    frame.setContentPane( canvas );
    frame.setSize( (int) stageSize.getWidth(), (int) stageSize.getHeight() );
    frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
    frame.setLocationRelativeTo( null ); // Center.
    frame.setVisible( true );
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:29,代码来源:TiltPredictionSelectorNode.java

示例12: main

import java.awt.geom.Dimension2D; //导入依赖的package包/类
public static void main( String[] args ) {

        Dimension2D stageSize = new PDimension( 200, 100 );

        PhetPCanvas canvas = new PhetPCanvas();
        // Set up the canvas-screen transform.
        canvas.setWorldTransformStrategy( new PhetPCanvas.CenteredStage( canvas, stageSize ) );

        ModelViewTransform mvt = ModelViewTransform.createSinglePointScaleInvertedYMapping(
                new Point2D.Double( 0, 0 ),
                new Point( (int) Math.round( stageSize.getWidth() * 0.5 ), (int) Math.round( stageSize.getHeight() * 0.50 ) ),
                1 ); // "Zoom factor" - smaller zooms out, larger zooms in.

        canvas.getLayer().addChild( new EnergyChunkNode2( new EnergyChunk( EnergyType.ELECTRICAL, 0, 0, new BooleanProperty( true ) ), mvt ) );

        // Boiler plate app stuff.
        JFrame frame = new JFrame();
        frame.setContentPane( canvas );
        frame.setSize( (int) stageSize.getWidth(), (int) stageSize.getHeight() );
        frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
        frame.setLocationRelativeTo( null ); // Center.
        frame.setVisible( true );
    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:24,代码来源:EnergyChunkNode2.java

示例13: SettingsNode

import java.awt.geom.Dimension2D; //导入依赖的package包/类
public SettingsNode( final LineGameModel model, Dimension2D stageSize ) {

        // the standard game settings panel
        PNode panelNode = new PSwing( new GameSettingsPanel( model.settings,
                                                             new VoidFunction0() {
                                                                 public void apply() {
                                                                     model.phase.set( GamePhase.PLAY );
                                                                 }
                                                             },
                                                             LineGameConstants.BUTTON_COLOR ) );
        panelNode.scale( 1.5 );
        addChild( panelNode );

        // centered on stage
        setOffset( ( stageSize.getWidth() - getFullBoundsReference().getWidth() ) / 2,
                   ( stageSize.getHeight() - getFullBoundsReference().getHeight() ) / 2 );
    }
 
开发者ID:mleoking,项目名称:PhET,代码行数:18,代码来源:SettingsNode.java

示例14: getDimension

import java.awt.geom.Dimension2D; //导入依赖的package包/类
@Override
public Dimension2D getDimension(JasperReportsContext jasperReportsContext)
{
	if (rotation != null) 
	{
		switch(rotation)
		{
			case LEFT:
			case RIGHT:
				return new Dimension((int)barcode.getSize().getHeight(),(int)barcode.getSize().getWidth());
			default:
				return barcode.getSize();
		}
	} else 
	{
		return barcode.getSize();
	}
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:19,代码来源:BarbecueRendererImpl.java

示例15: 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


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