Package graphics.common

Examples of graphics.common.Point2D


    Random rand = new Random( System.nanoTime() );
    final int listSize = 400;
    GraphicsObject[] objList = new GraphicsObject[ listSize ];
    List< GraphicsObject > objList2 = new LinkedList< GraphicsObject >();
    for( int i = 0; i < listSize; i++ ) {
      Point2D tempPoint = new Point2D( rand.nextInt( window.getWidth() - 30 ) + 30, rand.nextInt( window.getHeight() - 30 ) + 30 );
      Size2D tempSize = new Size2D( rand.nextInt( 30 ) + 21, rand.nextInt( 30 ) + 21 );
      GraphicsObject obj = new JavaSprite( "fenceright",
          tempPoint, tempSize );
      objList[ i ] = obj;
      objList2.add( obj );
    }
    GraphicsObject obj = new JavaSprite( "fenceright",
        new Point2D( 15, 31 ), new Size2D( 80, 80 ) );
   
    GraphicsObject elp1 = new Oval( new Point2D( 50, 50 ), new Size2D( 30, 16 ) );
    ((Oval)elp1).setColor( new Color( 255, 0, 0 ) );
    GraphicsObject elp2 = new Oval( new Point2D( 300, 300 ), new Size2D( 30, 16 ),
                      new Color( 255, 0, 0 ) );
    GraphicsObject cur = new BezierCurve( new Point2D( 65, 58 ), new Point2D( 315, 108 ),
                  new Point2D( 315, 208 ), new Point2D( 315, 308 ),
                  new Color( 255, 255, 0 ), 100 );
   
    Network network = new Network();
    Network.Node n1 = network.new Node( new Oval( new Point2D( 100, 100 ), new Size2D( 30, 15 ) ) );
    Network.Node n2 = network.new Node( new Oval( new Point2D( 200, 450 ), new Size2D( 30, 15 ) ) );
    Network.Node n3 = network.new Node( new Oval( new Point2D( 30, 200 ), new Size2D( 30, 15 ) ) );
    Network.Node n4 = network.new Node( new Oval( new Point2D( 500, 40 ), new Size2D( 30, 15 ) ) );
    network.addNode( n1 );
    network.addNode( n2 );
    network.addNode( n3 );
    network.addNode( n4 );
    network.addEdge( n1, n2 );
    network.addEdge( n1, n4 );
    //network.addEdge( n2, n3 );
    //network.addEdge( n4, n3 );
   
    Timer timer = new Timer();
    int frames = 0, prevFrames = 0;
    int timePassed = 0;
    timer.start();
    while( true ) {
      kb.poll();
      if( kb.keyDown( KeyEvent.VK_Q ) ) {
        break;
      }
      if( kb.keyDown( KeyEvent.VK_A ) ) {
        Point2D tempPoint = new Point2D( rand.nextInt( window.getWidth() ), rand.nextInt( window.getHeight() ) );
        Size2D tempSize = new Size2D( rand.nextInt( 30 ) + 21, rand.nextInt( 30 ) + 21 );
        GraphicsObject obj2 = new JavaSprite( "fenceright",
            tempPoint, tempSize );
        objList2.add( obj2 );
      }
View Full Code Here


    private static final int INTENSITY_MAX = 100;
    private static final int CURVE_GRANULARITY = 50;
    private static final Size OVAL_SIZE = new Size2D( 30, 15 );

    public Network() {
        mNetworkTranslation = new Point2D( 0, 0 ); //not using this yet
        mNodes = new LinkedList<Node>();
    }
View Full Code Here

            mEdges.add( other );
            generateLine( other );
        }

        private void generateLine( Node other ) {
            Point p1 = new Point2D(), p2 = new Point2D(), p3 = new Point2D(), p4 = new Point2D();
            placeAnchors( other, p1, p2, p3, p4 );
            mEdgeLines.add( new BezierCurve( new Point2D( p1 ), new Point2D( p2 ), new Point2D( p3 ), new Point2D( p4 ),
                    new Color( 150, 0, 150 ), CURVE_GRANULARITY ) );
            randomizeAnchors( p1, p2, p3, p4 );
            mEdgeLines.add( new BezierCurve( p1, p2, p3, p4,
                    new Color( 150, 0, 150 ), CURVE_GRANULARITY ) );
        }
View Full Code Here

            Point[] tpoints = mGraphic.getPoints();
            Size[] tsize = mGraphic.getSize();
            Point[] opoints = other.getPoints();
            Size[] osize = other.getSize();

            p1.modify( new Point2D( tpoints[ 0].getX() + tsize[ 0].getWidth() / 2,
                    tpoints[ 0].getY() + tsize[ 0].getHeight() / 2 ) );
            p4.modify( new Point2D( opoints[ 0].getX() + osize[ 0].getWidth() / 2,
                    opoints[ 0].getY() + osize[ 0].getHeight() / 2 ) );
            p2.modify( new Point2D( p1.getX() + (opoints[ 0].getX() - tpoints[ 0].getX()) / 3,
                    p1.getY() + (opoints[ 0].getY() - tpoints[ 0].getY()) / 3 ) );
            p3.modify( new Point2D( p4.getX() - (opoints[ 0].getX() - tpoints[ 0].getX()) / 3,
                    p4.getY() - (opoints[ 0].getY() - tpoints[ 0].getY()) / 3 ) );
        }
View Full Code Here

            int curveIntensity = mGenerator.nextInt( INTENSITY_MAX );

            if ( p1.getX() < p4.getX() ) {
                if ( p1.getY() < p4.getY() ) {
                    if ( mGenerator.nextInt( 5000 ) < 2500 ) {
                        p2.modify( new Point2D( curveIntensity, curveIntensity ) );
                        p3.modify( new Point2D( curveIntensity, -curveIntensity ) );
                    } else {
                        p2.modify( new Point2D( -curveIntensity, curveIntensity ) );
                        p3.modify( new Point2D( -curveIntensity, -curveIntensity ) );
                    }
                } else {
                    p2.modify( new Point2D( 0, curveIntensity ) );
                    p3.modify( new Point2D( curveIntensity, 0 ) );
                }
            } else if ( p1.getY() < p4.getY() ) {
                p2.modify( new Point2D( 0, -curveIntensity ) );
                p3.modify( new Point2D( -curveIntensity, 0 ) );
            } else {
                p2.modify( new Point2D( 0, curveIntensity ) );
                p3.modify( new Point2D( -curveIntensity, 0 ) );
            }
        }
View Full Code Here

    }

    private static class Get2D implements GetPoint {
        @Override
        public Point get( double x, double y, double z ) {
                return new Point2D( x, y );
        }
View Full Code Here

    private Point mPoint;
    private Size mSize;
    private Color mColor;

    public Oval() {
        mPoint = new Point2D( 0.0, 0.0 );
        mSize = new Size2D( 0.0, 0.0 );
        mColor = new Color( 0, 0, 0 );
    }
View Full Code Here

TOP

Related Classes of graphics.common.Point2D

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.