use of org.gephi.preview.types.DependantColor in project gephi by gephi.
the class DependantColorPanel method setup.
public void setup(DependantColorPropertyEditor propertyEditor) {
this.propertyEditor = propertyEditor;
DependantColor dependantColor = (DependantColor) propertyEditor.getValue();
if (dependantColor.getMode().equals(DependantColor.Mode.CUSTOM)) {
customRadio.setSelected(true);
((JColorButton) colorButton).setColor(dependantColor.getCustomColor());
} else if (dependantColor.getMode().equals(DependantColor.Mode.PARENT)) {
parentRadio.setSelected(true);
}
}
use of org.gephi.preview.types.DependantColor in project gephi by gephi.
the class DependantColorPanel method itemStateChanged.
@Override
public void itemStateChanged(ItemEvent e) {
if (customRadio.isSelected()) {
colorButton.setEnabled(true);
} else {
colorButton.setEnabled(false);
}
DependantColor.Mode selectedMode = null;
if (parentRadio.isSelected()) {
selectedMode = DependantColor.Mode.PARENT;
} else if (customRadio.isSelected()) {
selectedMode = DependantColor.Mode.CUSTOM;
}
propertyEditor.setValue(new DependantColor(selectedMode));
}
use of org.gephi.preview.types.DependantColor in project gephi by gephi.
the class NodeRenderer method renderPDF.
public void renderPDF(Item item, PDFTarget target, PreviewProperties properties) {
Float x = item.getData(NodeItem.X);
Float y = item.getData(NodeItem.Y);
Float size = item.getData(NodeItem.SIZE);
size /= 2f;
Color color = item.getData(NodeItem.COLOR);
Color borderColor = ((DependantColor) properties.getValue(PreviewProperty.NODE_BORDER_COLOR)).getColor(color);
float borderSize = properties.getFloatValue(PreviewProperty.NODE_BORDER_WIDTH);
float alpha = properties.getBooleanValue(PreviewProperty.NODE_PER_NODE_OPACITY) ? color.getAlpha() / 255f : properties.getFloatValue(PreviewProperty.NODE_OPACITY) / 100f;
PdfContentByte cb = target.getContentByte();
cb.setRGBColorStroke(borderColor.getRed(), borderColor.getGreen(), borderColor.getBlue());
cb.setLineWidth(borderSize);
cb.setRGBColorFill(color.getRed(), color.getGreen(), color.getBlue());
if (alpha < 1f) {
cb.saveState();
PdfGState gState = new PdfGState();
gState.setFillOpacity(alpha);
gState.setStrokeOpacity(alpha);
cb.setGState(gState);
}
cb.circle(x, -y, size);
if (borderSize > 0) {
cb.fillStroke();
} else {
cb.fill();
}
if (alpha < 1f) {
cb.restoreState();
}
}
use of org.gephi.preview.types.DependantColor in project gephi by gephi.
the class EdgeLabelRenderer method render.
@Override
public void render(Item item, RenderTarget target, PreviewProperties properties) {
Edge edge = (Edge) item.getSource();
// Label
Color edgeColor = item.getData(EDGE_COLOR);
Color color = item.getData(EdgeLabelItem.COLOR);
DependantOriginalColor propColor = properties.getValue(PreviewProperty.EDGE_LABEL_COLOR);
color = propColor.getColor(edgeColor, color);
String label = item.getData(EdgeLabelItem.LABEL);
Float x = item.getData(LABEL_X);
Float y = item.getData(LABEL_Y);
// Skip if empty
if (label == null || label.trim().isEmpty()) {
return;
}
// Outline
DependantColor outlineDependantColor = properties.getValue(PreviewProperty.EDGE_LABEL_OUTLINE_COLOR);
Float outlineSize = properties.getFloatValue(PreviewProperty.EDGE_LABEL_OUTLINE_SIZE);
outlineSize = outlineSize * (font.getSize() / 32f);
int outlineAlpha = (int) ((properties.getFloatValue(PreviewProperty.EDGE_LABEL_OUTLINE_OPACITY) / 100f) * 255f);
if (outlineAlpha < 0) {
outlineAlpha = 0;
}
if (outlineAlpha > 255) {
outlineAlpha = 255;
}
Color outlineColor = outlineDependantColor.getColor(edgeColor);
outlineColor = new Color(outlineColor.getRed(), outlineColor.getGreen(), outlineColor.getBlue(), outlineAlpha);
if (target instanceof G2DTarget) {
renderG2D((G2DTarget) target, label, x, y, color, outlineSize, outlineColor);
} else if (target instanceof SVGTarget) {
renderSVG((SVGTarget) target, edge, label, x, y, color, outlineSize, outlineColor);
} else if (target instanceof PDFTarget) {
renderPDF(((PDFTarget) target), label, x, y, color, outlineSize, outlineColor);
}
}
use of org.gephi.preview.types.DependantColor in project gephi by gephi.
the class NodeLabelRenderer method render.
@Override
public void render(Item item, RenderTarget target, PreviewProperties properties) {
Node node = (Node) item.getSource();
// Label
Color nodeColor = item.getData(NODE_COLOR);
Color color = item.getData(NodeLabelItem.COLOR);
DependantOriginalColor propColor = properties.getValue(PreviewProperty.NODE_LABEL_COLOR);
color = propColor.getColor(nodeColor, color);
String label = item.getData(NodeLabelItem.LABEL);
Integer fontSize = item.getData(FONT_SIZE);
Float x = item.getData(NODE_X);
Float y = item.getData(NODE_Y);
// Skip if empty
if (label == null || label.trim().isEmpty()) {
return;
}
// Outline
DependantColor outlineDependantColor = properties.getValue(PreviewProperty.NODE_LABEL_OUTLINE_COLOR);
Float outlineSize = properties.getFloatValue(PreviewProperty.NODE_LABEL_OUTLINE_SIZE);
outlineSize = outlineSize * (fontSize / 32f);
int outlineAlpha = (int) ((properties.getFloatValue(PreviewProperty.NODE_LABEL_OUTLINE_OPACITY) / 100f) * 255f);
if (outlineAlpha < 0) {
outlineAlpha = 0;
}
if (outlineAlpha > 255) {
outlineAlpha = 255;
}
Color outlineColor = outlineDependantColor.getColor(nodeColor);
outlineColor = new Color(outlineColor.getRed(), outlineColor.getGreen(), outlineColor.getBlue(), outlineAlpha);
// Box
Boolean showBox = properties.getValue(PreviewProperty.NODE_LABEL_SHOW_BOX);
DependantColor boxDependantColor = properties.getValue(PreviewProperty.NODE_LABEL_BOX_COLOR);
Color boxColor = boxDependantColor.getColor(nodeColor);
int boxAlpha = (int) ((properties.getFloatValue(PreviewProperty.NODE_LABEL_BOX_OPACITY) / 100f) * 255f);
if (boxAlpha < 0) {
boxAlpha = 0;
}
if (boxAlpha > 255) {
boxAlpha = 255;
}
boxColor = new Color(boxColor.getRed(), boxColor.getGreen(), boxColor.getBlue(), boxAlpha);
if (target instanceof G2DTarget) {
renderG2D((G2DTarget) target, label, x, y, fontSize, color, outlineSize, outlineColor, showBox, boxColor);
} else if (target instanceof SVGTarget) {
renderSVG((SVGTarget) target, node, label, x, y, fontSize, color, outlineSize, outlineColor, showBox, boxColor);
} else if (target instanceof PDFTarget) {
renderPDF((PDFTarget) target, node, label, x, y, fontSize, color, outlineSize, outlineColor, showBox, boxColor);
}
}
Aggregations