Examples of GraphicsObject


Examples of graphics.common.GraphicsObject

            curTime = System.nanoTime() / 1000000;

            theWindow.clear();

            for( int i = 0; i < allGraphics.size(); i++ ) {
                GraphicsObject go = allGraphics.get( i );
                Point goP = go.getPoints()[ 0 ];
                goP.modify( moveValX[ i ], moveValY[ i ], 0.0 );
                if( goP.getRealX() < 0.0 ) {
                    goP.setX( 5.0 );
                    moveValX[ i ] = -moveValX[ i ];
                }
                if( goP.getRealX() > theWindow.getWidth() ) {
                    goP.setX( theWindow.getWidth() - 5.0 );
                    moveValX[ i ] = -moveValX[ i ];
                }
                if( goP.getRealY() < 0.0 ) {
                    goP.setY( 5.0 );
                    moveValY[ i ] = -moveValY[ i ];
                }
                if( goP.getRealY() > theWindow.getHeight() ) {
                    goP.setY( theWindow.getHeight() - 5.0 );
                    moveValY[ i ] = -moveValY[ i ];
                }
                tree.update( go );
                /*List< GraphicsObject > list = tree.findColliding( go );
                for( GraphicsObject graphics : list ) {
                    JavaSprite js = (JavaSprite)graphics;
                    Graphics2D g = js.getGraphics();
                    g.setColor( new Color( 0, 100, 0, 200 ) );
                    g.drawRect( 0, 0, js.getSize()[ 0 ].getWidth(), js.getSize()[ 0 ].getHeight() );
                    g.dispose();
                }*/
                go.draw( JavaWindow.getGraphics2D(), delta );
            }
            tree.drawTree( JavaWindow.getGraphics2D() );
           
            theWindow.update();

View Full Code Here

Examples of graphics.common.GraphicsObject

    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 );
      }
      window.clear();
     
View Full Code Here

Examples of org.apache.fop.afp.modca.GraphicsObject

        if (log.isDebugEnabled()) {
            log.debug("drawString() str=" + str + ", x=" + x + ", y=" + y);
        }
        if (g instanceof AFPGraphics2D) {
            AFPGraphics2D g2d = (AFPGraphics2D)g;
            GraphicsObject graphicsObj = g2d.getGraphicsObject();
            Color color = g2d.getColor();

            // set the color
            AFPPaintingState paintingState = g2d.getPaintingState();
            if (paintingState.setColor(color)) {
                graphicsObj.setColor(color);
            }

            // set the character set
            int fontReference = 0;
            int fontSize;
            String internalFontName;
            AFPPageFonts pageFonts = paintingState.getPageFonts();
            if (overrideFont != null) {
                internalFontName = overrideFont.getFontName();
                fontSize = overrideFont.getFontSize();
            } else {
                java.awt.Font awtFont = g2d.getFont();
                Font fopFont = fontInfo.getFontInstanceForAWTFont(awtFont);
                internalFontName = fopFont.getFontName();
                fontSize = fopFont.getFontSize();
            }
            fontSize = (int)Math.round(
                    g2d.convertToAbsoluteLength(fontSize));
            fontReference = registerPageFont(pageFonts, internalFontName, fontSize);
            graphicsObj.setCharacterSet(fontReference);

            // add the character string
            graphicsObj.addString(str, Math.round(x), Math.round(y));
        } else {
            //Inside Batik's SVG filter operations, you won't get an AFPGraphics2D
            g.drawString(str, x, y);
        }
    }
View Full Code Here

Examples of org.apache.fop.afp.modca.GraphicsObject

     * @param graphicsObjectInfo the graphics object info
     * @return a new graphics object
     */
    public GraphicsObject createGraphic(AFPGraphicsObjectInfo graphicsObjectInfo) {
        // set newly created graphics object in g2d
        GraphicsObject graphicsObj = factory.createGraphicsObject();

        // set data object viewport (i.e. position, rotation, dimension, resolution)
        graphicsObj.setViewport(graphicsObjectInfo);

        AFPGraphics2D g2d = graphicsObjectInfo.getGraphics2D();
        g2d.setGraphicsObject(graphicsObj);

        //set color converter (i.e. an rgb to grayscale converter)
        graphicsObj.setColorConverter(g2d.getPaintingState().getColorConverter());

        // paint to graphics object
        Graphics2DImagePainter painter = graphicsObjectInfo.getPainter();
        Rectangle2D area = graphicsObjectInfo.getArea();
        g2d.scale(1, -1);
        g2d.translate(0, -area.getHeight());

        painter.paint(g2d, area);

        graphicsObj.setComplete(true);

        // return painted graphics object
        return graphicsObj;
    }
View Full Code Here

Examples of org.apache.fop.afp.modca.GraphicsObject

        if (log.isDebugEnabled()) {
            log.debug("drawString() str=" + str + ", x=" + x + ", y=" + y);
        }
        if (g instanceof AFPGraphics2D) {
            AFPGraphics2D g2d = (AFPGraphics2D)g;
            GraphicsObject graphicsObj = g2d.getGraphicsObject();
            Color color = g2d.getColor();

            // set the color
            AFPPaintingState paintingState = g2d.getPaintingState();
            if (paintingState.setColor(color)) {
                graphicsObj.setColor(color);
            }

            // set the character set
            int fontReference = 0;
            int fontSize;
            String internalFontName;
            AFPPageFonts pageFonts = paintingState.getPageFonts();
            if (overrideFont != null) {
                internalFontName = overrideFont.getFontName();
                fontSize = overrideFont.getFontSize();
                if (log.isDebugEnabled()) {
                    log.debug("  with overriding font: " + internalFontName + ", " + fontSize);
                }
            } else {
                java.awt.Font awtFont = g2d.getFont();
                Font fopFont = fontInfo.getFontInstanceForAWTFont(awtFont);
                if (log.isDebugEnabled()) {
                    log.debug("  with font: " + fopFont);
                }
                internalFontName = fopFont.getFontName();
                fontSize = fopFont.getFontSize();
            }
            fontSize = (int)Math.round(
                    g2d.convertToAbsoluteLength(fontSize));
            fontReference = registerPageFont(pageFonts, internalFontName, fontSize);
            // TODO: re-think above registerPageFont code...
            AFPFont afpFont = (AFPFont) fontInfo.getFonts().get(internalFontName);
            final CharacterSet charSet = afpFont.getCharacterSet(fontSize);
            // Work-around for InfoPrint's AFP which loses character set state
            // over Graphics Data
            // boundaries.
            graphicsObj.setCharacterSet(fontReference);
            // add the character string
            graphicsObj.addString(str, Math.round(x), Math.round(y), charSet);
        } else {
            //Inside Batik's SVG filter operations, you won't get an AFPGraphics2D
            g.drawString(str, x, y);
        }
    }
View Full Code Here

Examples of org.apache.fop.afp.modca.GraphicsObject

     * @return a new {@link GraphicsObject}
     */
    public GraphicsObject createGraphicsObject() {
        String name = GRAPHIC_NAME_PREFIX
        + StringUtils.lpad(String.valueOf(++graphicCount), '0', 5);
        GraphicsObject graphicsObj = new GraphicsObject(this, name);
        return graphicsObj;
    }
View Full Code Here

Examples of org.apache.fop.afp.modca.GraphicsObject

     * @return a new {@link GraphicsObject}
     */
    public GraphicsObject createGraphicsObject() {
        String name = GRAPHIC_NAME_PREFIX
        + StringUtils.lpad(String.valueOf(++graphicCount), '0', 5);
        GraphicsObject graphicsObj = new GraphicsObject(this, name);
        return graphicsObj;
    }
View Full Code Here

Examples of org.apache.fop.afp.modca.GraphicsObject

     * @param graphicsObjectInfo the graphics object info
     * @return a new graphics object
     */
    public GraphicsObject createGraphic(AFPGraphicsObjectInfo graphicsObjectInfo) {
        // set newly created graphics object in g2d
        GraphicsObject graphicsObj = factory.createGraphicsObject();

        // set data object viewport (i.e. position, rotation, dimension, resolution)
        graphicsObj.setViewport(graphicsObjectInfo);

        AFPGraphics2D g2d = graphicsObjectInfo.getGraphics2D();
        g2d.setGraphicsObject(graphicsObj);

        //set color converter (i.e. an rgb to grayscale converter)
        graphicsObj.setColorConverter(g2d.getPaintingState().getColorConverter());
       
        // paint to graphics object
        Graphics2DImagePainter painter = graphicsObjectInfo.getPainter();
        Rectangle2D area = graphicsObjectInfo.getArea();
        g2d.scale(1, -1);
        g2d.translate(0, -area.getHeight());

        painter.paint(g2d, area);

        graphicsObj.setComplete(true);

        // return painted graphics object
        return graphicsObj;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.