Question

i am using jung (java) try to draw circles to the Background. I dont get any output and wondering why it is not working.

Iam using PreRenderPaintable and PostRenderPaintable but still get no results.

        vv.addPreRenderPaintable(new VisualizationViewer.Paintable() {

        public void paint(Graphics g) 
        {
               System.out.println("PRE RENDER");
               System.out.println("vv.getComponentCount()= " + vv.getComponentCount());

            Graphics2D      g2d         = (Graphics2D)g;
            AffineTransform oldXform    = g2d.getTransform();
            AffineTransform lat         = vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.LAYOUT).getTransform();
            AffineTransform vat         = vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW).getTransform();
            AffineTransform at          = new AffineTransform();
            at.concatenate(g2d.getTransform());
            at.concatenate(vat);
            at.concatenate(lat);
            g2d.setTransform(at);

            g.drawOval(100, 100, 150, 150);

            g.drawString("adsadd", 200, 200);

            g2d.setTransform(oldXform);
        }

        public boolean useTransform() { return false; }
    });

vv.addPostRenderPaintable(new VisualizationViewer.Paintable()
    {
        public void paint(Graphics g)
        {
            System.out.println("POST RENDER");
            System.out.println("vv.getComponentCount()= " + vv.getComponentCount());
            Component comp = vv.getComponent(0);
            System.out.println(comp);
            System.out.println(comp.getClass());

            g.drawString("adasasdsadasdsadsadasdasdsadd", 300, 300);
        }

        public boolean useTransform() 
        {
            return false;
        }
    });
Was it helpful?

Solution

The Problem was not setting the color of the output. For Example:

  g.setFont(font);
  Color oldColor = g.getColor();
  g.setColor(Color.lightGray);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top