Logo Search packages:      
Sourcecode: javamorph version File versions  Download package

void javamorph::CMeshDecorator::paint ( Graphics  g  )  [inline]

Decorator API. Draw this mesh to the graphics context of the CFrame.

Implements javamorph::IDecorator.

Definition at line 81 of file CMeshDecorator.java.

References clip(), javamorph::CFrame::getImageBounds(), image, index, mesh, parent, pos, and javamorph::CFrame::scaleMarkSize().

Referenced by javamorph::CFrame::paint().

                                 {
        int m = parent.scaleMarkSize();
        clip();
        Graphics2D g2 = (Graphics2D)g;
        g2.setColor(CMeshDecorator.MESH_COLOR);
        Rectangle bounds = parent.getImageBounds();
        /* Transform coordinates depending on screen & image sizes. */
        g2.translate(bounds.x, bounds.y);
        g2.scale((double)bounds.width / image.getWidth(), 
                (double)bounds.height / image.getHeight());
        /* Draw mesh points. */
        for(Point p: mesh){
            g2.drawLine(p.x - m, p.y, p.x + m, p.y);
            g2.drawLine(p.x, p.y - m, p.x, p.y + m);
        }
        g2.setColor(CMeshDecorator.CURSOR_COLOR);
        Point q = mesh.get(index);
        /* Branch if moving points. */
        if(CConfig.EDIT_MESH_OFF == CConfig.edit_state){
            g2.drawLine(q.x - m, q.y - m, q.x + m, q.y + m);
            g2.drawLine(q.x - m, q.y + m, q.x + m, q.y - m);
            g2.drawOval(q.x - 2 * m, q.y - 2 * m, 4 * m, 4 * m);
        }
        /* Branch if adding points. */
        if(CConfig.EDIT_MESH_ADD == CConfig.edit_state){
            g2.drawOval(pos.x - 2 * m, pos.y - 2 * m, 4 * m, 4 * m);
        }
        /* Branch if removing points. */
        if(CConfig.EDIT_MESH_SUB == CConfig.edit_state){
            g2.drawLine(q.x, q.y - m, q.x, q.y + m);
            g2.drawLine(q.x - m, q.y, q.x + m, q.y);
            g2.drawOval(q.x - 2 * m, q.y - 2 * m, 4 * m, 4 * m);
        }
        /* Reset transformation of coordinates. */
        g2.setTransform(new AffineTransform());
    }


Generated by  Doxygen 1.6.0   Back to index