use of org.gephi.preview.types.DependantOriginalColor in project gephi by gephi.
the class BasicDependantOriginalColorPropertyEditor method setAsText.
@Override
public void setAsText(String s) {
if (matchColorMode(s, DependantOriginalColor.Mode.CUSTOM.name().toLowerCase())) {
Pattern p = Pattern.compile("\\w+\\s*\\[\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*\\]");
Matcher m = p.matcher(s);
if (m.lookingAt()) {
int r = Integer.valueOf(m.group(1));
int g = Integer.valueOf(m.group(2));
int b = Integer.valueOf(m.group(3));
setValue(new DependantOriginalColor(new Color(r, g, b)));
}
} else if (matchColorMode(s, DependantOriginalColor.Mode.ORIGINAL.name().toLowerCase())) {
setValue(new DependantOriginalColor(DependantOriginalColor.Mode.ORIGINAL));
} else if (matchColorMode(s, DependantOriginalColor.Mode.PARENT.name().toLowerCase())) {
setValue(new DependantOriginalColor(DependantOriginalColor.Mode.PARENT));
}
}
use of org.gephi.preview.types.DependantOriginalColor 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.DependantOriginalColor 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);
}
}
use of org.gephi.preview.types.DependantOriginalColor in project gephi by gephi.
the class DependantOriginalColorPanel method itemStateChanged.
@Override
public void itemStateChanged(ItemEvent e) {
if (customRadio.isSelected()) {
colorButton.setEnabled(true);
} else {
colorButton.setEnabled(false);
}
DependantOriginalColor.Mode selectedMode = null;
if (originalRadio.isSelected()) {
selectedMode = DependantOriginalColor.Mode.ORIGINAL;
} else if (parentRadio.isSelected()) {
selectedMode = DependantOriginalColor.Mode.PARENT;
} else if (customRadio.isSelected()) {
selectedMode = DependantOriginalColor.Mode.CUSTOM;
}
propertyEditor.setValue(new DependantOriginalColor(selectedMode));
}
use of org.gephi.preview.types.DependantOriginalColor in project gephi by gephi.
the class DependantOriginalColorPanel method setup.
public void setup(DependantOriginalColorPropertyEditor propertyEditor) {
this.propertyEditor = propertyEditor;
DependantOriginalColor dependantOriginalColor = (DependantOriginalColor) propertyEditor.getValue();
if (dependantOriginalColor.getMode().equals(DependantOriginalColor.Mode.CUSTOM)) {
customRadio.setSelected(true);
((JColorButton) colorButton).setColor(dependantOriginalColor.getCustomColor());
} else if (dependantOriginalColor.getMode().equals(DependantOriginalColor.Mode.ORIGINAL)) {
originalRadio.setSelected(true);
} else if (dependantOriginalColor.getMode().equals(DependantOriginalColor.Mode.PARENT)) {
parentRadio.setSelected(true);
}
}
Aggregations