use of org.gephi.preview.presets.DefaultPreset in project gephi by gephi.
the class PresetUtils method readXML.
private PreviewPreset readXML(Document document) {
// For retrieving property class if it is not in the xml (old serialization)
DefaultPreset defaultPreset = new DefaultPreset();
Element presetE = document.getDocumentElement();
Map<String, Object> propertiesMap = new HashMap<>();
String presetName = presetE.getAttribute("name");
NodeList propertyList = presetE.getElementsByTagName("previewproperty");
for (int i = 0; i < propertyList.getLength(); i++) {
Node n = propertyList.item(i);
if (n.getNodeType() == Node.ELEMENT_NODE) {
Element propertyE = (Element) n;
String name = propertyE.getAttribute("name");
String valueClassName = propertyE.hasAttribute(name) ? propertyE.getAttribute("class") : null;
String stringValue = propertyE.getTextContent();
Class valueClass = null;
if (valueClassName != null) {
try {
valueClass = Class.forName(valueClassName);
} catch (ClassNotFoundException ex) {
Exceptions.printStackTrace(ex);
}
} else {
Object defaultValue = defaultPreset.getProperties().get(name);
if (defaultValue != null) {
valueClass = defaultValue.getClass();
}
}
if (valueClass != null) {
Object value = PreviewProperties.readValueFromText(stringValue, valueClass);
if (value != null) {
propertiesMap.put(name, value);
}
}
}
}
return new PreviewPreset(presetName, propertiesMap);
}
use of org.gephi.preview.presets.DefaultPreset in project gephi by gephi.
the class PreviewModelImpl method initProperties.
private synchronized void initProperties() {
if (properties == null) {
properties = new PreviewProperties();
// Properties from renderers
for (Renderer renderer : getManagedEnabledRenderers()) {
PreviewProperty[] props = renderer.getProperties();
for (PreviewProperty p : props) {
properties.addProperty(p);
}
}
// Default preset
properties.applyPreset(new DefaultPreset());
// Defaut values
properties.putValue(PreviewProperty.VISIBILITY_RATIO, 1f);
}
}
Aggregations