use of de.lmu.ifi.dbs.elki.visualization.VisualizationTask in project elki by elki-project.
the class DetailView method refresh.
/**
* Do a refresh (when visibilities have changed).
*/
private synchronized void refresh() {
// Clear
pendingRefresh.set(null);
if (LOG.isDebuggingFine()) {
LOG.debugFine("Refresh in thread " + Thread.currentThread().getName());
}
boolean updateStyle = false;
Iterator<Map.Entry<VisualizationTask, Visualization>> it = taskmap.entrySet().iterator();
while (it.hasNext()) {
Entry<VisualizationTask, Visualization> ent = it.next();
VisualizationTask task = ent.getKey();
Visualization vis = ent.getValue();
if (vis == null) {
vis = instantiateVisualization(task);
ent.setValue(vis);
}
Element prevlayer = layermap.get(vis);
Element layer = vis.getLayer();
if (prevlayer == layer) {
// Unchanged:
// Current visibility ("not hidden")
boolean isVisible = !SVGConstants.CSS_HIDDEN_VALUE.equals(layer.getAttribute(SVGConstants.CSS_VISIBILITY_PROPERTY));
if (task.isVisible() != isVisible) {
// scheduleUpdate(new AttributeModifier(
//
layer.setAttribute(//
SVGConstants.CSS_VISIBILITY_PROPERTY, task.isVisible() ? SVGConstants.CSS_VISIBLE_VALUE : SVGConstants.CSS_HIDDEN_VALUE);
}
} else {
if (task.has(RenderFlag.NO_EXPORT)) {
layer.setAttribute(NO_EXPORT_ATTRIBUTE, NO_EXPORT_ATTRIBUTE);
}
if (prevlayer == null) {
if (LOG.isDebuggingFine()) {
LOG.debugFine("New layer: " + task);
}
// Insert new!
// TODO: insert position!
getRoot().appendChild(layer);
} else {
if (LOG.isDebuggingFine()) {
LOG.debugFine("Updated layer: " + task);
}
// Replace
final Node parent = prevlayer.getParentNode();
if (parent != null) {
parent.replaceChild(/* new! */
layer, /* old */
prevlayer);
}
}
layermap.put(vis, layer);
updateStyle = true;
}
}
if (updateStyle) {
updateStyleElement();
}
}
use of de.lmu.ifi.dbs.elki.visualization.VisualizationTask in project elki by elki-project.
the class DetailView method initialize.
private void initialize() {
// Try to keep the area approximately 1.0
width = Math.sqrt(getRatio());
height = 1.0 / width;
ArrayList<Visualization> layers = new ArrayList<>();
// TODO: center/arrange visualizations?
for (Iterator<VisualizationTask> tit = item.tasks.iterator(); tit.hasNext(); ) {
VisualizationTask task = tit.next();
if (task.isVisible()) {
Visualization v = instantiateVisualization(task);
if (v != null) {
layers.add(v);
taskmap.put(task, v);
layermap.put(v, v.getLayer());
}
}
}
// Arrange
for (Visualization layer : layers) {
if (layer.getLayer() != null) {
getRoot().appendChild(layer.getLayer());
} else {
LOG.warning("NULL layer seen.");
}
}
double ratio = width / height;
getRoot().setAttribute(SVGConstants.SVG_WIDTH_ATTRIBUTE, "20cm");
getRoot().setAttribute(SVGConstants.SVG_HEIGHT_ATTRIBUTE, (20 / ratio) + "cm");
getRoot().setAttribute(SVGConstants.SVG_VIEW_BOX_ATTRIBUTE, "0 0 " + width + " " + height);
updateStyleElement();
}
use of de.lmu.ifi.dbs.elki.visualization.VisualizationTask in project elki by elki-project.
the class DetailView method visualizationChanged.
@Override
public void visualizationChanged(VisualizationItem current) {
// Make sure we are affected:
if (!(current instanceof VisualizationTask)) {
return;
}
final VisualizationTask task = (VisualizationTask) current;
// Get the layer
Visualization vis = taskmap.get(task);
if (vis == null) {
// Unknown only.
boolean include = false;
for (It<Projector> it = context.getVisHierarchy().iterAncestors(current).filter(Projector.class); it.valid(); it.advance()) {
if ((item.proj != null && item.proj.getProjector() == it.get()) || taskmap.containsKey(it.get())) {
include = true;
break;
}
}
if (!include) {
// Attached to different projection.
return;
}
}
if (vis == null) {
// New visualization
taskmap.put(task, null);
lazyRefresh();
} else {
Element prevlayer = layermap.get(vis);
Element layer = vis.getLayer();
if (prevlayer != layer) {
lazyRefresh();
} else {
boolean isVisible = !SVGConstants.CSS_HIDDEN_VALUE.equals(layer.getAttribute(SVGConstants.CSS_VISIBILITY_PROPERTY));
if (task.isVisible() != isVisible) {
// Visibility has changed.
lazyRefresh();
}
}
}
}
use of de.lmu.ifi.dbs.elki.visualization.VisualizationTask in project elki by elki-project.
the class OverviewPlot method refresh.
/**
* Do a refresh (when visibilities have changed).
*/
synchronized void refresh() {
if (reinitOnRefresh) {
LOG.debug("Reinitialize in thread " + Thread.currentThread().getName());
reinitialize();
reinitOnRefresh = false;
return;
}
synchronized (plot) {
boolean refreshcss = false;
if (plotmap == null) {
LOG.warning("Plotmap is null", new Throwable());
}
final int thumbsize = (int) Math.max(screenwidth / plotmap.getWidth(), screenheight / plotmap.getHeight());
for (PlotItem pi : plotmap.keySet()) {
for (Iterator<PlotItem> iter = pi.itemIterator(); iter.hasNext(); ) {
PlotItem it = iter.next();
for (Iterator<VisualizationTask> tit = it.tasks.iterator(); tit.hasNext(); ) {
VisualizationTask task = tit.next();
Pair<Element, Visualization> pair = vistoelem.get(it, task);
// New task?
if (pair == null) {
if (visibleInOverview(task)) {
pair = new Pair<>(null, null);
pair.first = plot.svgElement(SVGConstants.SVG_G_TAG);
pair.second = embedOrThumbnail(thumbsize, it, task, pair.first);
vistoelem.get(it, null).first.appendChild(pair.first);
vistoelem.put(it, task, pair);
refreshcss = true;
}
} else {
if (visibleInOverview(task)) {
// unhide if hidden.
if (pair.first.hasAttribute(SVGConstants.CSS_VISIBILITY_PROPERTY)) {
pair.first.removeAttribute(SVGConstants.CSS_VISIBILITY_PROPERTY);
}
} else {
// hide if there is anything to hide.
if (pair.first != null && pair.first.hasChildNodes()) {
pair.first.setAttribute(SVGConstants.CSS_VISIBILITY_PROPERTY, SVGConstants.CSS_HIDDEN_VALUE);
}
}
// TODO: unqueue pending thumbnails
}
}
}
}
if (refreshcss) {
plot.updateStyleElement();
}
}
}
use of de.lmu.ifi.dbs.elki.visualization.VisualizationTask in project elki by elki-project.
the class OPTICSProjector method arrange.
@Override
public Collection<PlotItem> arrange(VisualizerContext context) {
List<PlotItem> col = new ArrayList<>(1);
List<VisualizationTask> tasks = context.getVisTasks(this);
if (!tasks.isEmpty()) {
final PlotItem it = new PlotItem(4., 1., new OPTICSProjection(this));
it.tasks = tasks;
col.add(it);
}
return col;
}
Aggregations