Jung 2 - Come impostare il colore del bordo personalizzato / trasformatore spesso
Domanda
Nella mia app voglio impostare ogni EGDE con stile diffrente.Può essere il colore del bordo o lo spessore del bordo. Ho letto sui trasformatori a Jung, ma non ho trovato alcun effetto utile.
Conosci qualche modo per impostare specifici colori o spessore della linea a un bordo specifico?Può essere una specie di trasformatore o classe avente metodi come SetWidth () o SetColour ().Esempio sarebbe bello;)
Soluzione
Grazie, e qui sta funzionando ESEMPIO:
private Transformer<String, Paint> edgePaint = new Transformer<String, Paint>() {
public Paint transform(String s) {
return Color.RED;
}
};
private Transformer<String, Stroke> edgeStroke = new Transformer<String, Stroke>() {
float dash[] = { 10.0f };
public Stroke transform(String s) {
return new BasicStroke(1.0f, BasicStroke.CAP_BUTT,
BasicStroke.JOIN_MITER, 10.0f, dash, 0.0f);
}
};
(...)
vv.getRenderContext().setEdgeDrawPaintTransformer(edgePaint);
vv.getRenderContext().setEdgeStrokeTransformer(edgeStroke);
. Altri suggerimenti
The class you want is PluggableRendererContext. There is an example that uses it extensively (PluggableRendererDemo) whose source code is in the distribution and which is demonstrated in applet form on the JUNG website.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow