Skip to content
This repository was archived by the owner on Apr 2, 2023. It is now read-only.

Styling

Rainer Simon edited this page Jul 12, 2013 · 3 revisions
val nodePainter = (nodes: Seq[Node2D], g2d: Graphics2D) => {
  nodes.foreach(n2d => {
    // For the sake of the demo, just use the number of links as size
    val size = n2d.node.links.size

    // Use the group value to pick a color from the palette
    g2d.setColor(ColorPalette.getColor(n2d.node.group))

    // Paint a node with an outline
    g2d.fill(new Ellipse2D.Double(n2d.x - size / 2, n2d.y - size / 2, size, size))
    g2d.setStroke(new BasicStroke(2));
    g2d.setColor(Color.WHITE)
    g2d.draw(new Ellipse2D.Double(n2d.x - size / 2, n2d.y - size / 2, size, size))
  })
})    
Clone this wiki locally