diff options
Diffstat (limited to 'src/de/lmu/ifi/dbs/elki/result')
62 files changed, 358 insertions, 151 deletions
diff --git a/src/de/lmu/ifi/dbs/elki/result/AbstractHierarchicalResult.java b/src/de/lmu/ifi/dbs/elki/result/AbstractHierarchicalResult.java index f5e89e13..0eba9564 100644 --- a/src/de/lmu/ifi/dbs/elki/result/AbstractHierarchicalResult.java +++ b/src/de/lmu/ifi/dbs/elki/result/AbstractHierarchicalResult.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/AprioriResult.java b/src/de/lmu/ifi/dbs/elki/result/AprioriResult.java index cbd1acfa..6b289f11 100644 --- a/src/de/lmu/ifi/dbs/elki/result/AprioriResult.java +++ b/src/de/lmu/ifi/dbs/elki/result/AprioriResult.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/BasicResult.java b/src/de/lmu/ifi/dbs/elki/result/BasicResult.java index 4aa46d0f..0e3bc571 100644 --- a/src/de/lmu/ifi/dbs/elki/result/BasicResult.java +++ b/src/de/lmu/ifi/dbs/elki/result/BasicResult.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/CollectionResult.java b/src/de/lmu/ifi/dbs/elki/result/CollectionResult.java index 1ce10063..a43c6fd6 100644 --- a/src/de/lmu/ifi/dbs/elki/result/CollectionResult.java +++ b/src/de/lmu/ifi/dbs/elki/result/CollectionResult.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/DBIDSelection.java b/src/de/lmu/ifi/dbs/elki/result/DBIDSelection.java index 41c50bb1..d504ecbc 100644 --- a/src/de/lmu/ifi/dbs/elki/result/DBIDSelection.java +++ b/src/de/lmu/ifi/dbs/elki/result/DBIDSelection.java @@ -3,7 +3,7 @@ package de.lmu.ifi.dbs.elki.result; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures -Copyright (C) 2011 +Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/DiscardResultHandler.java b/src/de/lmu/ifi/dbs/elki/result/DiscardResultHandler.java index 486a47a9..2499ff6a 100644 --- a/src/de/lmu/ifi/dbs/elki/result/DiscardResultHandler.java +++ b/src/de/lmu/ifi/dbs/elki/result/DiscardResultHandler.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/HierarchicalResult.java b/src/de/lmu/ifi/dbs/elki/result/HierarchicalResult.java index 4b5245b4..695ba1aa 100644 --- a/src/de/lmu/ifi/dbs/elki/result/HierarchicalResult.java +++ b/src/de/lmu/ifi/dbs/elki/result/HierarchicalResult.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/HistogramResult.java b/src/de/lmu/ifi/dbs/elki/result/HistogramResult.java index 7a6da96b..406eeffc 100644 --- a/src/de/lmu/ifi/dbs/elki/result/HistogramResult.java +++ b/src/de/lmu/ifi/dbs/elki/result/HistogramResult.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/IterableResult.java b/src/de/lmu/ifi/dbs/elki/result/IterableResult.java index b8bd27db..b53b4bb0 100644 --- a/src/de/lmu/ifi/dbs/elki/result/IterableResult.java +++ b/src/de/lmu/ifi/dbs/elki/result/IterableResult.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/KMLOutputHandler.java b/src/de/lmu/ifi/dbs/elki/result/KMLOutputHandler.java index 112ec7b8..7939d0a2 100644 --- a/src/de/lmu/ifi/dbs/elki/result/KMLOutputHandler.java +++ b/src/de/lmu/ifi/dbs/elki/result/KMLOutputHandler.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team @@ -138,7 +138,10 @@ public class KMLOutputHandler implements ResultHandler, Parameterizable { XMLOutputFactory factory = XMLOutputFactory.newInstance(); ZipOutputStream out = new ZipOutputStream(new FileOutputStream(filename)); out.putNextEntry(new ZipEntry("doc.kml")); - writeKMLData(factory.createXMLStreamWriter(out), ors.get(0), database); + final XMLStreamWriter xmlw = factory.createXMLStreamWriter(out); + writeKMLData(xmlw, ors.get(0), database); + xmlw.flush(); + xmlw.close(); out.closeEntry(); out.flush(); out.close(); @@ -336,7 +339,13 @@ public class KMLOutputHandler implements ResultHandler, Parameterizable { } } - private static final Color getColorForValue(double val) { + /** + * Get color from a simple heatmap. + * + * @param val Score value + * @return Color in heatmap + */ + public static final Color getColorForValue(double val) { // Color positions double[] pos = new double[] { 0.0, 0.6, 0.8, 1.0 }; // Colors at these positions diff --git a/src/de/lmu/ifi/dbs/elki/result/KNNDistanceOrderResult.java b/src/de/lmu/ifi/dbs/elki/result/KNNDistanceOrderResult.java index 1f62c7bc..0e5782bc 100644 --- a/src/de/lmu/ifi/dbs/elki/result/KNNDistanceOrderResult.java +++ b/src/de/lmu/ifi/dbs/elki/result/KNNDistanceOrderResult.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/OrderingFromDataStore.java b/src/de/lmu/ifi/dbs/elki/result/OrderingFromDataStore.java index 537f04d8..27178fe5 100644 --- a/src/de/lmu/ifi/dbs/elki/result/OrderingFromDataStore.java +++ b/src/de/lmu/ifi/dbs/elki/result/OrderingFromDataStore.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team @@ -23,7 +23,6 @@ package de.lmu.ifi.dbs.elki.result; along with this program. If not, see <http://www.gnu.org/licenses/>. */ -import java.util.Collections; import java.util.Comparator; import de.lmu.ifi.dbs.elki.database.datastore.DataStore; @@ -122,10 +121,10 @@ public class OrderingFromDataStore<T extends Comparable<T>> extends BasicResult public IterableIterator<DBID> iter(DBIDs ids) { ArrayModifiableDBIDs sorted = DBIDUtil.newArray(ids); if(comparator != null) { - Collections.sort(sorted, new DerivedComparator()); + sorted.sort(new DerivedComparator()); } else { - Collections.sort(sorted, new ImpliedComparator()); + sorted.sort(new ImpliedComparator()); } return IterableUtil.fromIterable(sorted); } diff --git a/src/de/lmu/ifi/dbs/elki/result/OrderingResult.java b/src/de/lmu/ifi/dbs/elki/result/OrderingResult.java index 043ec618..4cd01721 100644 --- a/src/de/lmu/ifi/dbs/elki/result/OrderingResult.java +++ b/src/de/lmu/ifi/dbs/elki/result/OrderingResult.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/PixmapResult.java b/src/de/lmu/ifi/dbs/elki/result/PixmapResult.java index ca832ecf..776753e2 100644 --- a/src/de/lmu/ifi/dbs/elki/result/PixmapResult.java +++ b/src/de/lmu/ifi/dbs/elki/result/PixmapResult.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/RangeSelection.java b/src/de/lmu/ifi/dbs/elki/result/RangeSelection.java index 87da7a4b..f70c1771 100644 --- a/src/de/lmu/ifi/dbs/elki/result/RangeSelection.java +++ b/src/de/lmu/ifi/dbs/elki/result/RangeSelection.java @@ -3,7 +3,7 @@ package de.lmu.ifi.dbs.elki.result; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures -Copyright (C) 2011 +Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/ReferencePointsResult.java b/src/de/lmu/ifi/dbs/elki/result/ReferencePointsResult.java index 5ec78478..3964c418 100644 --- a/src/de/lmu/ifi/dbs/elki/result/ReferencePointsResult.java +++ b/src/de/lmu/ifi/dbs/elki/result/ReferencePointsResult.java @@ -3,7 +3,7 @@ package de.lmu.ifi.dbs.elki.result; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures -Copyright (C) 2011 +Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/Result.java b/src/de/lmu/ifi/dbs/elki/result/Result.java index 3a90b7ce..ebd0bed1 100644 --- a/src/de/lmu/ifi/dbs/elki/result/Result.java +++ b/src/de/lmu/ifi/dbs/elki/result/Result.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/ResultAdapter.java b/src/de/lmu/ifi/dbs/elki/result/ResultAdapter.java index bdadd2d9..be81a508 100644 --- a/src/de/lmu/ifi/dbs/elki/result/ResultAdapter.java +++ b/src/de/lmu/ifi/dbs/elki/result/ResultAdapter.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/ResultHandler.java b/src/de/lmu/ifi/dbs/elki/result/ResultHandler.java index 04532ec9..1fef628f 100644 --- a/src/de/lmu/ifi/dbs/elki/result/ResultHandler.java +++ b/src/de/lmu/ifi/dbs/elki/result/ResultHandler.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/ResultHierarchy.java b/src/de/lmu/ifi/dbs/elki/result/ResultHierarchy.java index 0ecf6f82..bf2eefe6 100644 --- a/src/de/lmu/ifi/dbs/elki/result/ResultHierarchy.java +++ b/src/de/lmu/ifi/dbs/elki/result/ResultHierarchy.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team @@ -76,8 +76,8 @@ public class ResultHierarchy extends HierarchyHashmapList<Result> { @Override public void remove(Result parent, Result child) { - // TODO: unlink from hierarchy, fire event - throw new UnsupportedOperationException(); + super.remove(parent, child); + fireResultRemoved(child, parent); } @Override @@ -149,7 +149,6 @@ public class ResultHierarchy extends HierarchyHashmapList<Result> { * @param child result that has been removed * @param parent Parent result that has been removed */ - @SuppressWarnings("unused") private void fireResultRemoved(Result child, Result parent) { if(logger.isDebugging()) { logger.debug("Result removed: " + child + " <- " + parent); diff --git a/src/de/lmu/ifi/dbs/elki/result/ResultListener.java b/src/de/lmu/ifi/dbs/elki/result/ResultListener.java index 9dca067f..d675af28 100644 --- a/src/de/lmu/ifi/dbs/elki/result/ResultListener.java +++ b/src/de/lmu/ifi/dbs/elki/result/ResultListener.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/ResultProcessor.java b/src/de/lmu/ifi/dbs/elki/result/ResultProcessor.java index 6590b736..47273b89 100644 --- a/src/de/lmu/ifi/dbs/elki/result/ResultProcessor.java +++ b/src/de/lmu/ifi/dbs/elki/result/ResultProcessor.java @@ -1,10 +1,12 @@ package de.lmu.ifi.dbs.elki.result; +import de.lmu.ifi.dbs.elki.utilities.InspectionUtilFrequentlyScanned; + /* This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team @@ -32,7 +34,7 @@ package de.lmu.ifi.dbs.elki.result; * * @apiviz.uses Result oneway - - processes */ -public interface ResultProcessor { +public interface ResultProcessor extends InspectionUtilFrequentlyScanned { /** * Process a result. * diff --git a/src/de/lmu/ifi/dbs/elki/result/ResultUtil.java b/src/de/lmu/ifi/dbs/elki/result/ResultUtil.java index 96cfe9f4..1666d6fc 100644 --- a/src/de/lmu/ifi/dbs/elki/result/ResultUtil.java +++ b/src/de/lmu/ifi/dbs/elki/result/ResultUtil.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team @@ -33,6 +33,7 @@ import de.lmu.ifi.dbs.elki.algorithm.clustering.ClusteringAlgorithm; import de.lmu.ifi.dbs.elki.algorithm.clustering.trivial.ByLabelHierarchicalClustering; import de.lmu.ifi.dbs.elki.algorithm.clustering.trivial.TrivialAllInOne; import de.lmu.ifi.dbs.elki.data.Clustering; +import de.lmu.ifi.dbs.elki.data.NumberVector; import de.lmu.ifi.dbs.elki.data.model.Model; import de.lmu.ifi.dbs.elki.data.type.NoSupportedDataTypeException; import de.lmu.ifi.dbs.elki.database.Database; @@ -41,7 +42,6 @@ import de.lmu.ifi.dbs.elki.result.outlier.OutlierResult; import de.lmu.ifi.dbs.elki.utilities.ClassGenericsUtil; import de.lmu.ifi.dbs.elki.utilities.iterator.EmptyIterator; import de.lmu.ifi.dbs.elki.utilities.iterator.IterableIterator; -import de.lmu.ifi.dbs.elki.utilities.iterator.IterableUtil; import de.lmu.ifi.dbs.elki.utilities.iterator.MergedIterator; import de.lmu.ifi.dbs.elki.utilities.iterator.OneItemIterator; import de.lmu.ifi.dbs.elki.utilities.iterator.TypeFilterIterator; @@ -191,20 +191,14 @@ public class ResultUtil { @SuppressWarnings("unchecked") public static <C> ArrayList<C> filterResults(Result r, Class<?> restrictionClass) { ArrayList<C> res = new ArrayList<C>(); - try { + if(restrictionClass.isInstance(r)) { res.add((C) restrictionClass.cast(r)); } - catch(ClassCastException e) { - // ignore - } if(r instanceof HierarchicalResult) { for(Result result : ((HierarchicalResult) r).getHierarchy().iterDescendants(r)) { - try { + if(restrictionClass.isInstance(result)) { res.add((C) restrictionClass.cast(result)); } - catch(ClassCastException e) { - // ignore - } } } return res; @@ -215,21 +209,21 @@ public class ResultUtil { final Class<C> rc = (Class<C>) restrictionClass; // Include the current item IterableIterator<C> curIter; - try { + if(rc.isInstance(r)) { curIter = new OneItemIterator<C>(rc.cast(r)); } - catch(ClassCastException e) { + else { curIter = null; } if(r instanceof HierarchicalResult) { ResultHierarchy hier = ((HierarchicalResult) r).getHierarchy(); final Iterable<Result> iterDescendants = hier.iterDescendants(r); - final Iterator<C> others = new TypeFilterIterator<Result, C>(rc, iterDescendants); + final IterableIterator<C> others = new TypeFilterIterator<Result, C>(rc, iterDescendants); if(curIter != null) { - return IterableUtil.fromIterator(new MergedIterator<C>(curIter, others)); + return new MergedIterator<C>(curIter, others); } else { - return IterableUtil.fromIterator(others); + return others; } } else { @@ -268,13 +262,48 @@ public class ResultUtil { * Ensure that there also is a selection container object. * * @param db Database - * @param result Result + * @return selection result */ - public static void ensureSelectionResult(final Database db, final Result result) { - Collection<SelectionResult> selections = ResultUtil.filterResults(result, SelectionResult.class); + public static SelectionResult ensureSelectionResult(final Database db) { + Iterator<SelectionResult> selections = ResultUtil.filteredResults(db, SelectionResult.class); + if(selections.hasNext()) { + return selections.next(); + } + SelectionResult sel = new SelectionResult(); + addChildResult(db, sel); + return sel; + } + + /** + * Get the sampling result attached to a relation + * + * @param rel Relation + * @return Sampling result. + */ + public static SamplingResult getSamplingResult(final Relation<?> rel) { + Collection<SamplingResult> selections = ResultUtil.filterResults(rel, SamplingResult.class); if(selections.size() == 0) { - addChildResult(db, new SelectionResult()); + final SamplingResult newsam = new SamplingResult(rel); + addChildResult(rel, newsam); + return newsam; + } + return selections.iterator().next(); + } + + /** + * Get (or create) a scales result for a relation. + * + * @param rel Relation + * @return associated scales result + */ + public static ScalesResult getScalesResult(final Relation<? extends NumberVector<?, ?>> rel) { + Collection<ScalesResult> scas = ResultUtil.filterResults(rel, ScalesResult.class); + if(scas.size() == 0) { + final ScalesResult newsca = new ScalesResult(rel); + addChildResult(rel, newsca); + return newsca; } + return scas.iterator().next(); } /** @@ -302,4 +331,19 @@ public class ResultUtil { return null; } } + + /** + * Recursively remove a result and its children. + * + * @param hierarchy Result hierarchy + * @param child Result to remove + */ + public static void removeRecursive(ResultHierarchy hierarchy, Result child) { + for(Result parent : hierarchy.getParents(child)) { + hierarchy.remove(parent, child); + } + for(Result sub : hierarchy.getChildren(child)) { + removeRecursive(hierarchy, sub); + } + } }
\ No newline at end of file diff --git a/src/de/lmu/ifi/dbs/elki/result/ResultWriter.java b/src/de/lmu/ifi/dbs/elki/result/ResultWriter.java index 14e64269..ed8934a6 100644 --- a/src/de/lmu/ifi/dbs/elki/result/ResultWriter.java +++ b/src/de/lmu/ifi/dbs/elki/result/ResultWriter.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/SamplingResult.java b/src/de/lmu/ifi/dbs/elki/result/SamplingResult.java new file mode 100644 index 00000000..5e6c3df2 --- /dev/null +++ b/src/de/lmu/ifi/dbs/elki/result/SamplingResult.java @@ -0,0 +1,77 @@ +package de.lmu.ifi.dbs.elki.result; + +import de.lmu.ifi.dbs.elki.database.ids.DBIDs; +import de.lmu.ifi.dbs.elki.database.relation.Relation; + +/* + This file is part of ELKI: + Environment for Developing KDD-Applications Supported by Index-Structures + + Copyright (C) 2012 + Ludwig-Maximilians-Universität München + Lehr- und Forschungseinheit für Datenbanksysteme + ELKI Development Team + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +/** + * Wrapper for storing the current database sample. + * + * @author Erich Schubert + * + * @apiviz.composedOf DBIDs + */ +public class SamplingResult implements Result { + /** + * The actual selection + */ + DBIDs sample = null; + + /** + * Constructor. + * + * @param rel Relation + */ + public SamplingResult(Relation<?> rel) { + super(); + sample = rel.getDBIDs(); + } + + /** + * @return the current sample + */ + public DBIDs getSample() { + return sample; + } + + /** + * Note: trigger a resultchanged event! + * + * @param sample the new sample + */ + public void setSample(DBIDs sample) { + this.sample = sample; + } + + @Override + public String getLongName() { + return "Sample"; + } + + @Override + public String getShortName() { + return "sample"; + } +}
\ No newline at end of file diff --git a/src/de/lmu/ifi/dbs/elki/result/ScalesResult.java b/src/de/lmu/ifi/dbs/elki/result/ScalesResult.java new file mode 100644 index 00000000..89cd4af2 --- /dev/null +++ b/src/de/lmu/ifi/dbs/elki/result/ScalesResult.java @@ -0,0 +1,85 @@ +package de.lmu.ifi.dbs.elki.result; + +/* + This file is part of ELKI: + Environment for Developing KDD-Applications Supported by Index-Structures + + Copyright (C) 2012 + Ludwig-Maximilians-Universität München + Lehr- und Forschungseinheit für Datenbanksysteme + ELKI Development Team + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +import de.lmu.ifi.dbs.elki.data.NumberVector; +import de.lmu.ifi.dbs.elki.database.relation.Relation; +import de.lmu.ifi.dbs.elki.math.scales.LinearScale; +import de.lmu.ifi.dbs.elki.math.scales.Scales; + +/** + * Class to keep shared scales across visualizers. + * + * @author Erich Schubert + * + * @apiviz.composedOf LinearScale + */ +public class ScalesResult extends BasicResult { + /** + * The scales in use. + */ + private LinearScale[] scales; + + /** + * Constructor. + * + * @param relation + */ + public ScalesResult(Relation<? extends NumberVector<?, ?>> relation) { + super("scales", "scales"); + scales = Scales.calcScales(relation); + } + + /** + * Get the scale for dimension dim (starting at 1!). + * + * @param dim Dimension + * @return Scale + */ + public LinearScale getScale(int dim) { + return scales[dim - 1]; + } + + /** + * Set the scale for dimension dim (starting at 1!). + * + * Note: you still need to trigger an event. This is not done automatically, + * as you might want to set more than one scale! + * + * @param dim Dimension + * @param scale New scale + */ + public void setScale(int dim, LinearScale scale) { + scales[dim - 1] = scale; + } + + /** + * Get all scales. Note: you must not modify the array. + * + * @return Scales array. + */ + public LinearScale[] getScales() { + return scales; + } +}
\ No newline at end of file diff --git a/src/de/lmu/ifi/dbs/elki/result/SelectionResult.java b/src/de/lmu/ifi/dbs/elki/result/SelectionResult.java index d3bb2fd4..a8fb4ed5 100644 --- a/src/de/lmu/ifi/dbs/elki/result/SelectionResult.java +++ b/src/de/lmu/ifi/dbs/elki/result/SelectionResult.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team @@ -23,8 +23,6 @@ package de.lmu.ifi.dbs.elki.result; along with this program. If not, see <http://www.gnu.org/licenses/>. */ - - /** * Selection result wrapper. * diff --git a/src/de/lmu/ifi/dbs/elki/result/SettingsResult.java b/src/de/lmu/ifi/dbs/elki/result/SettingsResult.java index 044ceaf4..0d0dc34d 100644 --- a/src/de/lmu/ifi/dbs/elki/result/SettingsResult.java +++ b/src/de/lmu/ifi/dbs/elki/result/SettingsResult.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/optics/ClusterOrderEntry.java b/src/de/lmu/ifi/dbs/elki/result/optics/ClusterOrderEntry.java index 62d54045..06e4766f 100644 --- a/src/de/lmu/ifi/dbs/elki/result/optics/ClusterOrderEntry.java +++ b/src/de/lmu/ifi/dbs/elki/result/optics/ClusterOrderEntry.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result.optics; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/optics/ClusterOrderResult.java b/src/de/lmu/ifi/dbs/elki/result/optics/ClusterOrderResult.java index 4a5a9636..6eea3415 100644 --- a/src/de/lmu/ifi/dbs/elki/result/optics/ClusterOrderResult.java +++ b/src/de/lmu/ifi/dbs/elki/result/optics/ClusterOrderResult.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result.optics; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/optics/DoubleDistanceClusterOrderEntry.java b/src/de/lmu/ifi/dbs/elki/result/optics/DoubleDistanceClusterOrderEntry.java index 018c1d4f..8f42e1eb 100644 --- a/src/de/lmu/ifi/dbs/elki/result/optics/DoubleDistanceClusterOrderEntry.java +++ b/src/de/lmu/ifi/dbs/elki/result/optics/DoubleDistanceClusterOrderEntry.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result.optics; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/optics/GenericClusterOrderEntry.java b/src/de/lmu/ifi/dbs/elki/result/optics/GenericClusterOrderEntry.java index 8813a82a..c9ff0564 100644 --- a/src/de/lmu/ifi/dbs/elki/result/optics/GenericClusterOrderEntry.java +++ b/src/de/lmu/ifi/dbs/elki/result/optics/GenericClusterOrderEntry.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result.optics; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/optics/package-info.java b/src/de/lmu/ifi/dbs/elki/result/optics/package-info.java index 8cb59763..a61eb417 100644 --- a/src/de/lmu/ifi/dbs/elki/result/optics/package-info.java +++ b/src/de/lmu/ifi/dbs/elki/result/optics/package-info.java @@ -5,7 +5,7 @@ This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures -Copyright (C) 2011 +Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/outlier/BasicOutlierScoreMeta.java b/src/de/lmu/ifi/dbs/elki/result/outlier/BasicOutlierScoreMeta.java index 09aa8dbf..5d56117c 100644 --- a/src/de/lmu/ifi/dbs/elki/result/outlier/BasicOutlierScoreMeta.java +++ b/src/de/lmu/ifi/dbs/elki/result/outlier/BasicOutlierScoreMeta.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result.outlier; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/outlier/InvertedOutlierScoreMeta.java b/src/de/lmu/ifi/dbs/elki/result/outlier/InvertedOutlierScoreMeta.java index 2c978bf2..8658c938 100644 --- a/src/de/lmu/ifi/dbs/elki/result/outlier/InvertedOutlierScoreMeta.java +++ b/src/de/lmu/ifi/dbs/elki/result/outlier/InvertedOutlierScoreMeta.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result.outlier; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/outlier/OrderingFromRelation.java b/src/de/lmu/ifi/dbs/elki/result/outlier/OrderingFromRelation.java index ff211f30..5d35c74a 100644 --- a/src/de/lmu/ifi/dbs/elki/result/outlier/OrderingFromRelation.java +++ b/src/de/lmu/ifi/dbs/elki/result/outlier/OrderingFromRelation.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result.outlier; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team @@ -23,7 +23,6 @@ package de.lmu.ifi.dbs.elki.result.outlier; along with this program. If not, see <http://www.gnu.org/licenses/>. */ -import java.util.Collections; import java.util.Comparator; import de.lmu.ifi.dbs.elki.database.ids.ArrayModifiableDBIDs; @@ -82,7 +81,7 @@ public class OrderingFromRelation implements OrderingResult { @Override public IterableIterator<DBID> iter(DBIDs ids) { ArrayModifiableDBIDs sorted = DBIDUtil.newArray(ids); - Collections.sort(sorted, new ImpliedComparator()); + sorted.sort(new ImpliedComparator()); return new IterableIteratorAdapter<DBID>(sorted); } diff --git a/src/de/lmu/ifi/dbs/elki/result/outlier/OutlierResult.java b/src/de/lmu/ifi/dbs/elki/result/outlier/OutlierResult.java index 4389c7c8..5c4a58ae 100644 --- a/src/de/lmu/ifi/dbs/elki/result/outlier/OutlierResult.java +++ b/src/de/lmu/ifi/dbs/elki/result/outlier/OutlierResult.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result.outlier; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/outlier/OutlierScoreMeta.java b/src/de/lmu/ifi/dbs/elki/result/outlier/OutlierScoreMeta.java index fa7fb796..c71f20ce 100644 --- a/src/de/lmu/ifi/dbs/elki/result/outlier/OutlierScoreMeta.java +++ b/src/de/lmu/ifi/dbs/elki/result/outlier/OutlierScoreMeta.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result.outlier; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/outlier/ProbabilisticOutlierScore.java b/src/de/lmu/ifi/dbs/elki/result/outlier/ProbabilisticOutlierScore.java index 65ef6f82..844bb919 100644 --- a/src/de/lmu/ifi/dbs/elki/result/outlier/ProbabilisticOutlierScore.java +++ b/src/de/lmu/ifi/dbs/elki/result/outlier/ProbabilisticOutlierScore.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result.outlier; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/outlier/QuotientOutlierScoreMeta.java b/src/de/lmu/ifi/dbs/elki/result/outlier/QuotientOutlierScoreMeta.java index 2cf9875e..e0dc36ec 100644 --- a/src/de/lmu/ifi/dbs/elki/result/outlier/QuotientOutlierScoreMeta.java +++ b/src/de/lmu/ifi/dbs/elki/result/outlier/QuotientOutlierScoreMeta.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result.outlier; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/outlier/package-info.java b/src/de/lmu/ifi/dbs/elki/result/outlier/package-info.java index c6b61bfe..f72e5366 100644 --- a/src/de/lmu/ifi/dbs/elki/result/outlier/package-info.java +++ b/src/de/lmu/ifi/dbs/elki/result/outlier/package-info.java @@ -6,7 +6,7 @@ This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures -Copyright (C) 2011 +Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/package-info.java b/src/de/lmu/ifi/dbs/elki/result/package-info.java index aba3dec6..70894b93 100644 --- a/src/de/lmu/ifi/dbs/elki/result/package-info.java +++ b/src/de/lmu/ifi/dbs/elki/result/package-info.java @@ -12,7 +12,7 @@ This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures -Copyright (C) 2011 +Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/textwriter/MultipleFilesOutput.java b/src/de/lmu/ifi/dbs/elki/result/textwriter/MultipleFilesOutput.java index 51eb5f8e..d891f1ee 100644 --- a/src/de/lmu/ifi/dbs/elki/result/textwriter/MultipleFilesOutput.java +++ b/src/de/lmu/ifi/dbs/elki/result/textwriter/MultipleFilesOutput.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result.textwriter; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/textwriter/SingleStreamOutput.java b/src/de/lmu/ifi/dbs/elki/result/textwriter/SingleStreamOutput.java index 1e4e5773..46472f52 100644 --- a/src/de/lmu/ifi/dbs/elki/result/textwriter/SingleStreamOutput.java +++ b/src/de/lmu/ifi/dbs/elki/result/textwriter/SingleStreamOutput.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result.textwriter; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/textwriter/StreamFactory.java b/src/de/lmu/ifi/dbs/elki/result/textwriter/StreamFactory.java index 1656d76d..0f27b354 100644 --- a/src/de/lmu/ifi/dbs/elki/result/textwriter/StreamFactory.java +++ b/src/de/lmu/ifi/dbs/elki/result/textwriter/StreamFactory.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result.textwriter; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/textwriter/TextWriteable.java b/src/de/lmu/ifi/dbs/elki/result/textwriter/TextWriteable.java index ffc522eb..a8de4c46 100644 --- a/src/de/lmu/ifi/dbs/elki/result/textwriter/TextWriteable.java +++ b/src/de/lmu/ifi/dbs/elki/result/textwriter/TextWriteable.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result.textwriter; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/textwriter/TextWriter.java b/src/de/lmu/ifi/dbs/elki/result/textwriter/TextWriter.java index bbe3212b..d947547f 100644 --- a/src/de/lmu/ifi/dbs/elki/result/textwriter/TextWriter.java +++ b/src/de/lmu/ifi/dbs/elki/result/textwriter/TextWriter.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result.textwriter; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team @@ -29,8 +29,8 @@ import java.io.PrintStream; import java.util.BitSet; import java.util.Collection; import java.util.HashMap; -import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -51,7 +51,6 @@ import de.lmu.ifi.dbs.elki.datasource.bundle.SingleObjectBundle; import de.lmu.ifi.dbs.elki.distance.distancevalue.Distance; import de.lmu.ifi.dbs.elki.math.linearalgebra.Vector; import de.lmu.ifi.dbs.elki.result.CollectionResult; -import de.lmu.ifi.dbs.elki.result.HierarchicalResult; import de.lmu.ifi.dbs.elki.result.IterableResult; import de.lmu.ifi.dbs.elki.result.OrderingResult; import de.lmu.ifi.dbs.elki.result.Result; @@ -225,63 +224,57 @@ public class TextWriter { * @throws IOException on IO error */ public void output(Database db, Result r, StreamFactory streamOpener) throws UnableToComplyException, IOException { - List<Relation<?>> ra = null; - List<OrderingResult> ro = null; - List<Clustering<? extends Model>> rc = null; - List<IterableResult<?>> ri = null; - List<SettingsResult> rs = null; - HashSet<Result> otherres = null; + List<Relation<?>> ra = new LinkedList<Relation<?>>(); + List<OrderingResult> ro = new LinkedList<OrderingResult>(); + List<Clustering<?>> rc = new LinkedList<Clustering<?>>(); + List<IterableResult<?>> ri = new LinkedList<IterableResult<?>>(); + List<SettingsResult> rs = new LinkedList<SettingsResult>(); + List<Result> otherres = new LinkedList<Result>(); - ra = ResultUtil.getRelations(r); - ro = ResultUtil.getOrderingResults(r); - rc = ResultUtil.getClusteringResults(r); - ri = ResultUtil.getIterableResults(r); - rs = ResultUtil.getSettingsResults(r); // collect other results - if(r instanceof HierarchicalResult) { - final List<Result> resultList = ResultUtil.filterResults((HierarchicalResult) r, Result.class); - otherres = new HashSet<Result>(resultList); - otherres.removeAll(ra); - otherres.removeAll(ro); - otherres.removeAll(rc); - otherres.removeAll(ri); - otherres.removeAll(rs); - otherres.remove(db); - Iterator<Result> it = otherres.iterator(); - while(it.hasNext()) { - if(it.next() instanceof HierarchicalResult) { - it.remove(); + { + for(Result res : ResultUtil.filteredResults(r, Result.class)) { + if(res instanceof Database) { + continue; + } + if(res instanceof Relation) { + ra.add((Relation<?>) res); + continue; + } + if(res instanceof OrderingResult) { + ro.add((OrderingResult) res); + continue; + } + if(res instanceof Clustering) { + rc.add((Clustering<?>) res); + continue; + } + if(res instanceof IterableResult) { + ri.add((IterableResult<?>) res); + continue; + } + if(res instanceof SettingsResult) { + rs.add((SettingsResult) res); + continue; } + otherres.add(res); } } - if(ra == null && ro == null && rc == null && ri == null) { - throw new UnableToComplyException("No printable result found."); + for(IterableResult<?> rii : ri) { + writeIterableResult(streamOpener, rii, rs); } - - if(ri != null && ri.size() > 0) { - // TODO: associations are not passed to ri results. - for(IterableResult<?> rii : ri) { - writeIterableResult(streamOpener, rii, rs); - } - } - if(rc != null && rc.size() > 0) { - for(Clustering<?> c : rc) { - NamingScheme naming = new SimpleEnumeratingScheme(c); - for(Cluster<?> clus : c.getAllClusters()) { - writeClusterResult(db, streamOpener, clus, ra, naming, rs); - } + for(Clustering<?> c : rc) { + NamingScheme naming = new SimpleEnumeratingScheme(c); + for(Cluster<?> clus : c.getAllClusters()) { + writeClusterResult(db, streamOpener, clus, ra, naming, rs); } } - if(ro != null && ro.size() > 0) { - for(OrderingResult ror : ro) { - writeOrderingResult(db, streamOpener, ror, ra, rs); - } + for(OrderingResult ror : ro) { + writeOrderingResult(db, streamOpener, ror, ra, rs); } - if(otherres != null && otherres.size() > 0) { - for(Result otherr : otherres) { - writeOtherResult(streamOpener, otherr, rs); - } + for(Result otherr : otherres) { + writeOtherResult(streamOpener, otherr, rs); } } @@ -290,16 +283,18 @@ public class TextWriter { // Write database element itself. for(int i = 0; i < bundle.metaLength(); i++) { Object obj = bundle.data(i); - TextWriterWriterInterface<?> owriter = out.getWriterFor(obj); - if(owriter == null) { - throw new UnableToComplyException("No handler for database object itself: " + obj.getClass().getSimpleName()); - } - String lbl = null; - // TODO: ugly compatibility hack... - if(TypeUtil.DBID.isAssignableFromType(bundle.meta(i))) { - lbl = "ID"; + if(obj != null) { + TextWriterWriterInterface<?> owriter = out.getWriterFor(obj); + if(owriter == null) { + throw new UnableToComplyException("No handler for database object itself: " + obj.getClass().getSimpleName()); + } + String lbl = null; + // TODO: ugly compatibility hack... + if(TypeUtil.DBID.isAssignableFromType(bundle.meta(i))) { + lbl = "ID"; + } + owriter.writeObject(out, lbl, obj); } - owriter.writeObject(out, lbl, obj); } Collection<Relation<?>> dbrels = db.getRelations(); @@ -307,7 +302,7 @@ public class TextWriter { if(ra != null) { for(Relation<?> a : ra) { // Avoid duplicated output. - if (dbrels.contains(a)) { + if(dbrels.contains(a)) { continue; } String label = a.getShortName(); @@ -357,7 +352,7 @@ public class TextWriter { // Write cluster information out.commentPrintLn("Cluster: " + naming.getNameFor(clus)); Model model = clus.getModel(); - if (model != ClusterModel.CLUSTER) { + if(model != ClusterModel.CLUSTER && model != null) { TextWriterWriterInterface<?> mwri = writers.getHandler(model); mwri.writeObject(out, null, model); } diff --git a/src/de/lmu/ifi/dbs/elki/result/textwriter/TextWriterStream.java b/src/de/lmu/ifi/dbs/elki/result/textwriter/TextWriterStream.java index b59a09e9..ce60c856 100644 --- a/src/de/lmu/ifi/dbs/elki/result/textwriter/TextWriterStream.java +++ b/src/de/lmu/ifi/dbs/elki/result/textwriter/TextWriterStream.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result.textwriter; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/textwriter/TextWriterWriterInterface.java b/src/de/lmu/ifi/dbs/elki/result/textwriter/TextWriterWriterInterface.java index ab572896..cfaa3373 100644 --- a/src/de/lmu/ifi/dbs/elki/result/textwriter/TextWriterWriterInterface.java +++ b/src/de/lmu/ifi/dbs/elki/result/textwriter/TextWriterWriterInterface.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result.textwriter; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/textwriter/naming/NamingScheme.java b/src/de/lmu/ifi/dbs/elki/result/textwriter/naming/NamingScheme.java index c5d9cf72..4b2c099f 100644 --- a/src/de/lmu/ifi/dbs/elki/result/textwriter/naming/NamingScheme.java +++ b/src/de/lmu/ifi/dbs/elki/result/textwriter/naming/NamingScheme.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result.textwriter.naming; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/textwriter/naming/SimpleEnumeratingScheme.java b/src/de/lmu/ifi/dbs/elki/result/textwriter/naming/SimpleEnumeratingScheme.java index 2341f258..baff04e2 100644 --- a/src/de/lmu/ifi/dbs/elki/result/textwriter/naming/SimpleEnumeratingScheme.java +++ b/src/de/lmu/ifi/dbs/elki/result/textwriter/naming/SimpleEnumeratingScheme.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result.textwriter.naming; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/textwriter/naming/package-info.java b/src/de/lmu/ifi/dbs/elki/result/textwriter/naming/package-info.java index 8d10da45..600e731e 100644 --- a/src/de/lmu/ifi/dbs/elki/result/textwriter/naming/package-info.java +++ b/src/de/lmu/ifi/dbs/elki/result/textwriter/naming/package-info.java @@ -5,7 +5,7 @@ This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures -Copyright (C) 2011 +Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/textwriter/package-info.java b/src/de/lmu/ifi/dbs/elki/result/textwriter/package-info.java index b2abeb5b..872df780 100644 --- a/src/de/lmu/ifi/dbs/elki/result/textwriter/package-info.java +++ b/src/de/lmu/ifi/dbs/elki/result/textwriter/package-info.java @@ -6,7 +6,7 @@ This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures -Copyright (C) 2011 +Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/textwriter/writers/TextWriterDoubleDoublePair.java b/src/de/lmu/ifi/dbs/elki/result/textwriter/writers/TextWriterDoubleDoublePair.java index b8f25b6a..4af9d8a4 100644 --- a/src/de/lmu/ifi/dbs/elki/result/textwriter/writers/TextWriterDoubleDoublePair.java +++ b/src/de/lmu/ifi/dbs/elki/result/textwriter/writers/TextWriterDoubleDoublePair.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result.textwriter.writers; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/textwriter/writers/TextWriterObjectArray.java b/src/de/lmu/ifi/dbs/elki/result/textwriter/writers/TextWriterObjectArray.java index bec183d8..3a73d52a 100644 --- a/src/de/lmu/ifi/dbs/elki/result/textwriter/writers/TextWriterObjectArray.java +++ b/src/de/lmu/ifi/dbs/elki/result/textwriter/writers/TextWriterObjectArray.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result.textwriter.writers; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/textwriter/writers/TextWriterObjectComment.java b/src/de/lmu/ifi/dbs/elki/result/textwriter/writers/TextWriterObjectComment.java index ddb753ac..d4da18f5 100644 --- a/src/de/lmu/ifi/dbs/elki/result/textwriter/writers/TextWriterObjectComment.java +++ b/src/de/lmu/ifi/dbs/elki/result/textwriter/writers/TextWriterObjectComment.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result.textwriter.writers; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/textwriter/writers/TextWriterObjectInline.java b/src/de/lmu/ifi/dbs/elki/result/textwriter/writers/TextWriterObjectInline.java index 12717da7..a621ab4b 100644 --- a/src/de/lmu/ifi/dbs/elki/result/textwriter/writers/TextWriterObjectInline.java +++ b/src/de/lmu/ifi/dbs/elki/result/textwriter/writers/TextWriterObjectInline.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result.textwriter.writers; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/textwriter/writers/TextWriterPair.java b/src/de/lmu/ifi/dbs/elki/result/textwriter/writers/TextWriterPair.java index c8bd83b2..3c1440bc 100644 --- a/src/de/lmu/ifi/dbs/elki/result/textwriter/writers/TextWriterPair.java +++ b/src/de/lmu/ifi/dbs/elki/result/textwriter/writers/TextWriterPair.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result.textwriter.writers; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/textwriter/writers/TextWriterTextWriteable.java b/src/de/lmu/ifi/dbs/elki/result/textwriter/writers/TextWriterTextWriteable.java index 491f803d..87a3661b 100644 --- a/src/de/lmu/ifi/dbs/elki/result/textwriter/writers/TextWriterTextWriteable.java +++ b/src/de/lmu/ifi/dbs/elki/result/textwriter/writers/TextWriterTextWriteable.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result.textwriter.writers; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/textwriter/writers/TextWriterTriple.java b/src/de/lmu/ifi/dbs/elki/result/textwriter/writers/TextWriterTriple.java index ce3c3d70..55dd7106 100644 --- a/src/de/lmu/ifi/dbs/elki/result/textwriter/writers/TextWriterTriple.java +++ b/src/de/lmu/ifi/dbs/elki/result/textwriter/writers/TextWriterTriple.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result.textwriter.writers; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/textwriter/writers/TextWriterVector.java b/src/de/lmu/ifi/dbs/elki/result/textwriter/writers/TextWriterVector.java index 0ebf4ae4..1452c432 100644 --- a/src/de/lmu/ifi/dbs/elki/result/textwriter/writers/TextWriterVector.java +++ b/src/de/lmu/ifi/dbs/elki/result/textwriter/writers/TextWriterVector.java @@ -4,7 +4,7 @@ package de.lmu.ifi.dbs.elki.result.textwriter.writers; This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures - Copyright (C) 2011 + Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team diff --git a/src/de/lmu/ifi/dbs/elki/result/textwriter/writers/package-info.java b/src/de/lmu/ifi/dbs/elki/result/textwriter/writers/package-info.java index 66c5f706..c83dd767 100644 --- a/src/de/lmu/ifi/dbs/elki/result/textwriter/writers/package-info.java +++ b/src/de/lmu/ifi/dbs/elki/result/textwriter/writers/package-info.java @@ -6,7 +6,7 @@ This file is part of ELKI: Environment for Developing KDD-Applications Supported by Index-Structures -Copyright (C) 2011 +Copyright (C) 2012 Ludwig-Maximilians-Universität München Lehr- und Forschungseinheit für Datenbanksysteme ELKI Development Team |