code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
public static String format(float[] f) {
return (f == null) ? "null" : (f.length == 0) ? "" : //
formatTo(new StringBuilder(), f, ", ").toString();
} | java |
public static String format(int[] a, String sep) {
return (a == null) ? "null" : (a.length == 0) ? "" : //
formatTo(new StringBuilder(), a, sep).toString();
} | java |
public static String format(boolean[] b, final String sep) {
return (b == null) ? "null" : (b.length == 0) ? "" : //
formatTo(new StringBuilder(), b, ", ").toString();
} | java |
public static String format(double[][] d) {
return d == null ? "null" : (d.length == 0) ? "[]" : //
formatTo(new StringBuilder().append("[\n"), d, " [", "]\n", ", ", NF2).append(']').toString();
} | java |
public static String format(double[][] m, int w, int d, String pre, String pos, String csep) {
DecimalFormat format = new DecimalFormat();
format.setDecimalFormatSymbols(new DecimalFormatSymbols(Locale.US));
format.setMinimumIntegerDigits(1);
format.setMaximumFractionDigits(d);
format.setMinimumFrac... | java |
public static String format(double[][] m, NumberFormat nf) {
return formatTo(new StringBuilder().append("[\n"), m, " [", "]\n", ", ", nf).append("]").toString();
} | java |
public static String format(Collection<String> d, String sep) {
if(d == null) {
return "null";
}
if(d.isEmpty()) {
return "";
}
if(d.size() == 1) {
return d.iterator().next();
}
int len = sep.length() * (d.size() - 1);
for(String s : d) {
len += s.length();
}
... | java |
public static String format(String[] d, String sep) {
if(d == null) {
return "null";
}
if(d.length == 0) {
return "";
}
if(d.length == 1) {
return d[0];
}
int len = sep.length() * (d.length - 1);
for(String s : d) {
len += s.length();
}
StringBuilder buffe... | java |
public static int findSplitpoint(String s, int width) {
// the newline (or EOS) is the fallback split position.
int in = s.indexOf(NEWLINE);
in = in < 0 ? s.length() : in;
// Good enough?
if(in < width) {
return in;
}
// otherwise, search for whitespace
int iw = s.lastIndexOf(' ', ... | java |
public static List<String> splitAtLastBlank(String s, int width) {
List<String> chunks = new ArrayList<>();
String tmp = s;
while(tmp.length() > 0) {
int index = findSplitpoint(tmp, width);
// store first part
chunks.add(tmp.substring(0, index));
// skip whitespace at beginning of l... | java |
public static String pad(String o, int len) {
return o.length() >= len ? o : (o + whitespace(len - o.length()));
} | java |
public static String padRightAligned(String o, int len) {
return o.length() >= len ? o : (whitespace(len - o.length()) + o);
} | java |
public static String formatTimeDelta(long time, CharSequence sep) {
final StringBuilder sb = new StringBuilder();
final Formatter fmt = new Formatter(sb);
for(int i = TIME_UNIT_SIZES.length - 1; i >= 0; --i) {
// We do not include ms if we are in the order of minutes.
if(i == 0 && sb.length() >... | java |
public static StringBuilder appendZeros(StringBuilder buf, int zeros) {
for(int i = zeros; i > 0; i -= ZEROPADDING.length) {
buf.append(ZEROPADDING, 0, i < ZEROPADDING.length ? i : ZEROPADDING.length);
}
return buf;
} | java |
public static StringBuilder appendSpace(StringBuilder buf, int spaces) {
for(int i = spaces; i > 0; i -= SPACEPADDING.length) {
buf.append(SPACEPADDING, 0, i < SPACEPADDING.length ? i : SPACEPADDING.length);
}
return buf;
} | java |
protected void makeLayerElement() {
plotwidth = StyleLibrary.SCALE;
plotheight = StyleLibrary.SCALE / optics.getOPTICSPlot(context).getRatio();
final double margin = context.getStyleLibrary().getSize(StyleLibrary.MARGIN);
layer = SVGUtil.svgElement(svgp.getDocument(), SVGConstants.SVG_G_TAG);
final ... | java |
protected List<Centroid> computeCentroids(int dim, List<V> vectorcolumn, List<ClassLabel> keys, Map<ClassLabel, IntList> classes) {
final int numc = keys.size();
List<Centroid> centroids = new ArrayList<>(numc);
for(int i = 0; i < numc; i++) {
Centroid c = new Centroid(dim);
for(IntIterator it =... | java |
protected double kNNDistance() {
double knnDist = 0.;
for(int i = 0; i < getNumEntries(); i++) {
MkMaxEntry entry = getEntry(i);
knnDist = Math.max(knnDist, entry.getKnnDistance());
}
return knnDist;
} | java |
@Override
public boolean adjustEntry(MkMaxEntry entry, DBID routingObjectID, double parentDistance, AbstractMTree<O, MkMaxTreeNode<O>, MkMaxEntry, ?> mTree) {
super.adjustEntry(entry, routingObjectID, parentDistance, mTree);
// adjust knn distance
entry.setKnnDistance(kNNDistance());
return true; // T... | java |
@Override
protected void integrityCheckParameters(MkMaxEntry parentEntry, MkMaxTreeNode<O> parent, int index, AbstractMTree<O, MkMaxTreeNode<O>, MkMaxEntry, ?> mTree) {
super.integrityCheckParameters(parentEntry, parent, index, mTree);
// test if knn distance is correctly set
MkMaxEntry entry = parent.get... | java |
@Override
public void initialize() {
if(databaseConnection == null) {
return; // Supposedly we initialized already.
}
if(LOG.isDebugging()) {
LOG.debugFine("Loading data from database connection.");
}
MultipleObjectsBundle bundle = databaseConnection.loadData();
// Run at most once... | java |
protected void zSort(List<? extends SpatialComparable> objs, int start, int end, double[] mms, int[] dims, int depth) {
final int numdim = (dims != null) ? dims.length : (mms.length >> 1);
final int edim = (dims != null) ? dims[depth] : depth;
// Find the splitting points.
final double min = mms[2 * edi... | java |
public StringBuilder appendTo(StringBuilder buf) {
return buf.append(DBIDUtil.toString((DBIDRef) id)).append(" ").append(column).append(" ").append(score);
} | java |
protected Cluster<SubspaceModel> runDOC(Database database, Relation<V> relation, ArrayModifiableDBIDs S, final int d, int n, int m, int r, int minClusterSize) {
// Best cluster for the current run.
DBIDs C = null;
// Relevant attributes for the best cluster.
long[] D = null;
// Quality of the best c... | java |
protected DBIDs findNeighbors(DBIDRef q, long[] nD, ArrayModifiableDBIDs S, Relation<V> relation) {
// Weights for distance (= rectangle query)
DistanceQuery<V> dq = relation.getDistanceQuery(new SubspaceMaximumDistanceFunction(nD));
// TODO: add filtering capabilities into query API!
// Until then, us... | java |
protected Cluster<SubspaceModel> makeCluster(Relation<V> relation, DBIDs C, long[] D) {
DBIDs ids = DBIDUtil.newHashSet(C); // copy, also to lose distance values!
Cluster<SubspaceModel> cluster = new Cluster<>(ids);
cluster.setModel(new SubspaceModel(new Subspace(D), Centroid.make(relation, ids).getArrayRef... | java |
protected static <M extends Model> int[] findDepth(Clustering<M> c) {
final Hierarchy<Cluster<M>> hier = c.getClusterHierarchy();
int[] size = { 0, 0 };
for(It<Cluster<M>> iter = c.iterToplevelClusters(); iter.valid(); iter.advance()) {
findDepth(hier, iter.get(), size);
}
return size;
} | java |
private static <M extends Model> void findDepth(Hierarchy<Cluster<M>> hier, Cluster<M> cluster, int[] size) {
if(hier.numChildren(cluster) > 0) {
for(It<Cluster<M>> iter = hier.iterChildren(cluster); iter.valid(); iter.advance()) {
findDepth(hier, iter.get(), size);
}
size[0] += 1; // Dept... | java |
protected static int getPreferredColumns(double width, double height, int numc, double maxwidth) {
// Maximum width (compared to height) of labels - guess.
// FIXME: do we really need to do this three-step computation?
// Number of rows we'd use in a squared layout:
final double rows = Math.ceil(FastMat... | java |
public ELKIBuilder<T> with(String opt, Object value) {
p.addParameter(opt, value);
return this;
} | java |
@SuppressWarnings("unchecked")
public <C extends T> C build() {
if(p == null) {
throw new AbortException("build() may be called only once.");
}
final T obj = ClassGenericsUtil.parameterizeOrAbort(clazz, p);
if(p.hasUnusedParameters()) {
LOG.warning("Unused parameters: " + p.getRemainingPar... | java |
protected static double[][] randomInitialSolution(final int size, final int dim, Random random) {
double[][] sol = new double[size][dim];
for(int i = 0; i < size; i++) {
for(int j = 0; j < dim; j++) {
sol[i][j] = random.nextGaussian() * INITIAL_SOLUTION_SCALE;
}
}
return sol;
} | java |
protected double sqDist(double[] v1, double[] v2) {
assert (v1.length == v2.length) : "Lengths do not agree: " + v1.length + " " + v2.length;
double sum = 0;
for(int i = 0; i < v1.length; i++) {
final double diff = v1[i] - v2[i];
sum += diff * diff;
}
++projectedDistances;
return sum... | java |
protected void updateSolution(double[][] sol, double[] meta, int it) {
final double mom = (it < momentumSwitch && initialMomentum < finalMomentum) ? initialMomentum : finalMomentum;
final int dim3 = dim * 3;
for(int i = 0, off = 0; i < sol.length; i++, off += dim3) {
final double[] sol_i = sol[i];
... | java |
private int getOffset(int x, int y) {
return (y < x) ? (triangleSize(x) + y) : (triangleSize(y) + x);
} | java |
@Override
public double getWeight(double distance, double max, double stddev) {
if(stddev <= 0) {
return 1;
}
double scaleddistance = distance / (scaling * stddev);
// After this, the result would be negative.
if(scaleddistance >= 1.0) {
return 0.0;
}
return 1.0 - scaleddistanc... | java |
public OPTICSPlot getOPTICSPlot(VisualizerContext context) {
if(plot == null) {
plot = OPTICSPlot.plotForClusterOrder(clusterOrder, context);
}
return plot;
} | java |
public void setValue(boolean val) {
try {
super.setValue(Boolean.valueOf(val));
}
catch(ParameterException e) {
// We're pretty sure that any Boolean is okay, so this should never be
// reached.
throw new AbortException("Flag did not accept boolean value!", e);
}
} | java |
public OutlierResult run(Database database, Relation<O> relation) {
StepProgress stepprog = LOG.isVerbose() ? new StepProgress(5) : null;
Pair<KNNQuery<O>, KNNQuery<O>> pair = getKNNQueries(database, relation, stepprog);
KNNQuery<O> knnComp = pair.getFirst();
KNNQuery<O> knnReach = pair.getSecond();
... | java |
protected void computePDists(Relation<O> relation, KNNQuery<O> knn, WritableDoubleDataStore pdists) {
// computing PRDs
FiniteProgress prdsProgress = LOG.isVerbose() ? new FiniteProgress("pdists", relation.size(), LOG) : null;
for(DBIDIter iditer = relation.iterDBIDs(); iditer.valid(); iditer.advance()) {
... | java |
protected double computePLOFs(Relation<O> relation, KNNQuery<O> knn, WritableDoubleDataStore pdists, WritableDoubleDataStore plofs) {
FiniteProgress progressPLOFs = LOG.isVerbose() ? new FiniteProgress("PLOFs for objects", relation.size(), LOG) : null;
double nplof = 0.;
for(DBIDIter iditer = relation.iterD... | java |
@SuppressWarnings("unchecked")
public final void writeObject(TextWriterStream out, String label, Object object) throws IOException {
write(out, label, (O) object);
} | java |
@Override
public int filter(double[] eigenValues) {
// determine sum of eigenvalues
double totalSum = 0;
for(int i = 0; i < eigenValues.length; i++) {
totalSum += eigenValues[i];
}
double expectedVariance = totalSum / eigenValues.length * walpha;
// determine strong and weak eigenpairs
... | java |
public static List<OutlierResult> getOutlierResults(Result r) {
if(r instanceof OutlierResult) {
List<OutlierResult> ors = new ArrayList<>(1);
ors.add((OutlierResult) r);
return ors;
}
if(r instanceof HierarchicalResult) {
return ResultUtil.filterResults(((HierarchicalResult) r).getH... | java |
double evaluateBy(ScoreEvaluation eval) {
return eval.evaluate(new DBIDsTest(DBIDUtil.ensureSet(scores.getDBIDs())), new OutlierScoreAdapter(this));
} | java |
public double distance(double[] v1, double[] v2) {
final int dim1 = v1.length, dim2 = v2.length;
final int mindim = dim1 < dim2 ? dim1 : dim2;
double agg = preDistance(v1, v2, 0, mindim);
if(dim1 > mindim) {
agg += preNorm(v1, mindim, dim1);
}
else if(dim2 > mindim) {
agg += preNorm(... | java |
private void computeWeights(Node node) {
int wsum = 0;
for(Node child : node.children) {
computeWeights(child);
wsum += child.weight;
}
node.weight = Math.max(1, wsum);
} | java |
@Override
public void processNewResult(ResultHierarchy hier, Result result) {
// Get all new clusterings
// TODO: handle clusterings added later, too. Can we update the result?
List<Clustering<?>> clusterings = Clustering.getClusteringResults(result);
// Abort if not enough clusterings to compare
... | java |
public double getPartialMinDist(int dimension, int vp) {
final int qp = queryApprox.getApproximation(dimension);
if(vp < qp) {
return lookup[dimension][vp + 1];
}
else if(vp > qp) {
return lookup[dimension][vp];
}
else {
return 0.0;
}
} | java |
public double getMinDist(VectorApproximation vec) {
final int dim = lookup.length;
double minDist = 0;
for(int d = 0; d < dim; d++) {
final int vp = vec.getApproximation(d);
minDist += getPartialMinDist(d, vp);
}
return FastMath.pow(minDist, onebyp);
} | java |
public double getPartialMaxDist(int dimension, int vp) {
final int qp = queryApprox.getApproximation(dimension);
if(vp < qp) {
return lookup[dimension][vp];
}
else if(vp > qp) {
return lookup[dimension][vp + 1];
}
else {
return Math.max(lookup[dimension][vp], lookup[dimension][... | java |
private void initializeLookupTable(double[][] splitPositions, NumberVector query, double p) {
final int dimensions = splitPositions.length;
final int bordercount = splitPositions[0].length;
lookup = new double[dimensions][bordercount];
for(int d = 0; d < dimensions; d++) {
final double val = query... | java |
protected void makeStyleResult(StyleLibrary stylelib) {
final Database db = ResultUtil.findDatabase(hier);
stylelibrary = stylelib;
List<Clustering<? extends Model>> clusterings = Clustering.getClusteringResults(db);
if(!clusterings.isEmpty()) {
stylepolicy = new ClusterStylingPolicy(clusterings.g... | java |
@Override
public void contentChanged(DataStoreEvent e) {
for(int i = 0; i < listenerList.size(); i++) {
listenerList.get(i).contentChanged(e);
}
} | java |
private void notifyFactories(Object item) {
for(VisualizationProcessor f : factories) {
try {
f.processNewResult(this, item);
}
catch(Throwable e) {
LOG.warning("VisFactory " + f.getClass().getCanonicalName() + " failed:", e);
}
}
} | java |
protected int chooseBulkSplitPoint(int numEntries, int minEntries, int maxEntries) {
if(numEntries < minEntries) {
throw new IllegalArgumentException("numEntries < minEntries!");
}
if(numEntries <= maxEntries) {
return numEntries;
}
else if(numEntries < maxEntries + minEntries) {
... | java |
protected <T> List<List<T>> trivialPartition(List<T> objects, int minEntries, int maxEntries) {
// build partitions
final int size = objects.size();
final int numberPartitions = (int) Math.ceil(((double) size) / maxEntries);
List<List<T>> partitions = new ArrayList<>(numberPartitions);
int start = 0... | java |
protected Relation<?>[] alignColumns(ObjectBundle pack) {
// align representations.
Relation<?>[] targets = new Relation<?>[pack.metaLength()];
long[] used = BitsUtil.zero(relations.size());
for(int i = 0; i < targets.length; i++) {
SimpleTypeInformation<?> meta = pack.meta(i);
// TODO: aggr... | java |
private Relation<?> addNewRelation(SimpleTypeInformation<?> meta) {
@SuppressWarnings("unchecked")
SimpleTypeInformation<Object> ometa = (SimpleTypeInformation<Object>) meta;
Relation<?> relation = new MaterializedRelation<>(ometa, ids);
relations.add(relation);
getHierarchy().add(this, relation);
... | java |
private void doDelete(DBIDRef id) {
// Remove id
ids.remove(id);
// Remove from all representations.
for(Relation<?> relation : relations) {
// ID has already been removed, and this would loop...
if(relation == idrep) {
continue;
}
if(!(relation instanceof ModifiableRelat... | java |
private ArrayDBIDs greedy(DistanceQuery<V> distFunc, DBIDs sampleSet, int m, Random random) {
ArrayModifiableDBIDs medoids = DBIDUtil.newArray(m);
ArrayModifiableDBIDs s = DBIDUtil.newArray(sampleSet);
DBIDArrayIter iter = s.iter();
DBIDVar m_i = DBIDUtil.newVar();
int size = s.size();
// Move... | java |
private ArrayDBIDs initialSet(DBIDs sampleSet, int k, Random random) {
return DBIDUtil.ensureArray(DBIDUtil.randomSample(sampleSet, k, random));
} | java |
private ArrayDBIDs computeM_current(DBIDs m, DBIDs m_best, DBIDs m_bad, Random random) {
ArrayModifiableDBIDs m_list = DBIDUtil.newArray(m);
m_list.removeDBIDs(m_best);
DBIDArrayMIter it = m_list.iter();
ArrayModifiableDBIDs m_current = DBIDUtil.newArray();
for(DBIDIter iter = m_best.iter(); iter.v... | java |
private long[][] findDimensions(ArrayDBIDs medoids, Relation<V> database, DistanceQuery<V> distFunc, RangeQuery<V> rangeQuery) {
// get localities
DataStore<DBIDs> localities = getLocalities(medoids, distFunc, rangeQuery);
// compute x_ij = avg distance from points in l_i to medoid m_i
final int dim = ... | java |
private List<Pair<double[], long[]>> findDimensions(ArrayList<PROCLUSCluster> clusters, Relation<V> database) {
// compute x_ij = avg distance from points in c_i to c_i.centroid
final int dim = RelationUtil.dimensionality(database);
final int numc = clusters.size();
double[][] averageDistances = new dou... | java |
private List<DoubleIntInt> computeZijs(double[][] averageDistances, final int dim) {
List<DoubleIntInt> z_ijs = new ArrayList<>(averageDistances.length * dim);
for(int i = 0; i < averageDistances.length; i++) {
double[] x_i = averageDistances[i];
// y_i
double y_i = 0;
for(int j = 0; j <... | java |
private long[][] computeDimensionMap(List<DoubleIntInt> z_ijs, final int dim, final int numc) {
// mapping cluster index -> dimensions
long[][] dimensionMap = new long[numc][((dim - 1) >> 6) + 1];
int max = Math.max(k * l, 2);
for(int m = 0; m < max; m++) {
DoubleIntInt z_ij = z_ijs.get(m);
... | java |
private ArrayList<PROCLUSCluster> assignPoints(ArrayDBIDs m_current, long[][] dimensions, Relation<V> database) {
ModifiableDBIDs[] clusterIDs = new ModifiableDBIDs[dimensions.length];
for(int i = 0; i < m_current.size(); i++) {
clusterIDs[i] = DBIDUtil.newHashSet();
}
DBIDArrayIter m_i = m_curre... | java |
private List<PROCLUSCluster> finalAssignment(List<Pair<double[], long[]>> dimensions, Relation<V> database) {
Map<Integer, ModifiableDBIDs> clusterIDs = new HashMap<>();
for(int i = 0; i < dimensions.size(); i++) {
clusterIDs.put(i, DBIDUtil.newHashSet());
}
for(DBIDIter it = database.iterDBIDs()... | java |
private double manhattanSegmentalDistance(NumberVector o1, double[] o2, long[] dimensions) {
double result = 0;
int card = 0;
for(int d = BitsUtil.nextSetBit(dimensions, 0); d >= 0; d = BitsUtil.nextSetBit(dimensions, d + 1)) {
result += Math.abs(o1.doubleValue(d) - o2[d]);
++card;
}
ret... | java |
private double evaluateClusters(ArrayList<PROCLUSCluster> clusters, long[][] dimensions, Relation<V> database) {
double result = 0;
for(int i = 0; i < dimensions.length; i++) {
PROCLUSCluster c_i = clusters.get(i);
double[] centroid_i = c_i.centroid;
long[] dims_i = dimensions[i];
doubl... | java |
private double avgDistance(double[] centroid, DBIDs objectIDs, Relation<V> database, int dimension) {
Mean avg = new Mean();
for(DBIDIter iter = objectIDs.iter(); iter.valid(); iter.advance()) {
V o = database.get(iter);
avg.put(Math.abs(centroid[dimension] - o.doubleValue(dimension)));
}
re... | java |
private DBIDs computeBadMedoids(ArrayDBIDs m_current, ArrayList<PROCLUSCluster> clusters, int threshold) {
ModifiableDBIDs badMedoids = DBIDUtil.newHashSet(m_current.size());
int i = 0;
for(DBIDIter it = m_current.iter(); it.valid(); it.advance(), i++) {
PROCLUSCluster c_i = clusters.get(i);
if(... | java |
public static Bit valueOf(String bit) throws NumberFormatException {
final int i = ParseUtil.parseIntBase10(bit);
if(i != 0 && i != 1) {
throw new NumberFormatException("Input \"" + bit + "\" must be 0 or 1.");
}
return (i > 0) ? TRUE : FALSE;
} | java |
public ChangePoints run(Relation<DoubleVector> relation) {
if(!(relation.getDBIDs() instanceof ArrayDBIDs)) {
throw new AbortException("This implementation may only be used on static databases, with ArrayDBIDs to provide a clear order.");
}
return new Instance(rnd.getSingleThreadedRandom()).run(relati... | java |
public static void cusum(double[] data, double[] out, int begin, int end) {
assert (out.length >= data.length);
// Use Kahan summation for better precision!
// FIXME: this should be unit tested.
double m = 0., carry = 0.;
for(int i = begin; i < end; i++) {
double v = data[i] - carry; // Compen... | java |
public static DoubleIntPair bestChangeInMean(double[] sums, int begin, int end) {
final int len = end - begin, last = end - 1;
final double suml = begin > 0 ? sums[begin - 1] : 0.;
final double sumr = sums[last];
int bestpos = begin;
double bestscore = Double.NEGATIVE_INFINITY;
// Iterate eleme... | java |
public static void shuffle(double[] bstrap, int len, Random rnd) {
int i = len;
while(i > 0) {
final int r = rnd.nextInt(i);
--i;
// Swap
double tmp = bstrap[r];
bstrap[r] = bstrap[i];
bstrap[i] = tmp;
}
} | java |
@SuppressWarnings("unchecked")
public T get(double coord) {
if(coord == Double.NEGATIVE_INFINITY) {
return getSpecial(0);
}
if(coord == Double.POSITIVE_INFINITY) {
return getSpecial(1);
}
if(Double.isNaN(coord)) {
return getSpecial(2);
}
int bin = getBinNr(coord);
if(... | java |
protected void loadCache(int size, InputStream in) throws IOException {
// Expect a sparse matrix here
cache = new Long2FloatOpenHashMap(size * 20);
cache.defaultReturnValue(Float.POSITIVE_INFINITY);
min = Integer.MAX_VALUE;
max = Integer.MIN_VALUE;
parser.parse(in, new DistanceCacheWriter() {
... | java |
public Element svgElement(String name, String cssclass) {
Element elem = SVGUtil.svgElement(document, name);
if(cssclass != null) {
elem.setAttribute(SVGConstants.SVG_CLASS_ATTRIBUTE, cssclass);
}
return elem;
} | java |
public Element svgRect(double x, double y, double w, double h) {
return SVGUtil.svgRect(document, x, y, w, h);
} | java |
public Element svgCircle(double cx, double cy, double r) {
return SVGUtil.svgCircle(document, cx, cy, r);
} | java |
public Element svgLine(double x1, double y1, double x2, double y2) {
return SVGUtil.svgLine(document, x1, y1, x2, y2);
} | java |
public SVGPoint elementCoordinatesFromEvent(Element tag, Event evt) {
return SVGUtil.elementCoordinatesFromEvent(document, tag, evt);
} | java |
public void addCSSClassOrLogError(CSSClass cls) {
try {
cssman.addClass(cls);
}
catch(CSSNamingConflict e) {
LoggingUtil.exception(e);
}
} | java |
public void updateStyleElement() {
// TODO: this should be sufficient - why does Batik occasionally not pick up
// the changes unless we actually replace the style element itself?
// cssman.updateStyleElement(document, style);
Element newstyle = cssman.makeStyleElement(document);
style.getParentNode... | java |
public void saveAsSVG(File file) throws IOException, TransformerFactoryConfigurationError, TransformerException {
OutputStream out = new BufferedOutputStream(new FileOutputStream(file));
// TODO embed linked images.
javax.xml.transform.Result result = new StreamResult(out);
SVGDocument doc = cloneDocume... | java |
protected void transcode(File file, Transcoder transcoder) throws IOException, TranscoderException {
// Disable validation, performance is more important here (thumbnails!)
transcoder.addTranscodingHint(XMLAbstractTranscoder.KEY_XML_PARSER_VALIDATING, Boolean.FALSE);
SVGDocument doc = cloneDocument();
T... | java |
protected SVGDocument cloneDocument() {
return (SVGDocument) new CloneInlineImages() {
@Override
public Node cloneNode(Document doc, Node eold) {
// Skip elements with noexport attribute set
if(eold instanceof Element) {
Element eeold = (Element) eold;
String vis = ee... | java |
public void saveAsPDF(File file) throws IOException, TranscoderException, ClassNotFoundException {
try {
Object t = Class.forName("org.apache.fop.svg.PDFTranscoder").newInstance();
transcode(file, (Transcoder) t);
}
catch(InstantiationException | IllegalAccessException e) {
throw new Class... | java |
public void saveAsPNG(File file, int width, int height) throws IOException, TranscoderException {
PNGTranscoder t = new PNGTranscoder();
t.addTranscodingHint(PNGTranscoder.KEY_WIDTH, new Float(width));
t.addTranscodingHint(PNGTranscoder.KEY_HEIGHT, new Float(height));
transcode(file, t);
} | java |
public void saveAsANY(File file, int width, int height, float quality) throws IOException, TranscoderException, TransformerFactoryConfigurationError, TransformerException, ClassNotFoundException {
String extension = FileUtil.getFilenameExtension(file);
if("svg".equals(extension)) {
saveAsSVG(file);
}
... | java |
public BufferedImage makeAWTImage(int width, int height) throws TranscoderException {
ThumbnailTranscoder t = new ThumbnailTranscoder();
t.addTranscodingHint(PNGTranscoder.KEY_WIDTH, new Float(width));
t.addTranscodingHint(PNGTranscoder.KEY_HEIGHT, new Float(height));
// Don't clone. Assume this is used... | java |
public void dumpDebugFile() {
try {
File f = File.createTempFile("elki-debug", ".svg");
f.deleteOnExit();
this.saveAsSVG(f);
LoggingUtil.warning("Saved debug file to: " + f.getAbsolutePath());
}
catch(Throwable err) {
// Ignore.
}
} | java |
public void putIdElement(String id, Element obj) {
objWithId.put(id, new WeakReference<>(obj));
} | java |
public Element getIdElement(String id) {
WeakReference<Element> ref = objWithId.get(id);
return (ref != null) ? ref.get() : null;
} | java |
protected ScoreResult computeScore(DBIDs ids, DBIDs outlierIds, OutlierResult or) throws IllegalStateException {
if(scaling instanceof OutlierScaling) {
OutlierScaling oscaling = (OutlierScaling) scaling;
oscaling.prepare(or);
}
final ScalingFunction innerScaling;
// If we have useful (fini... | java |
@Override
protected Cluster<SubspaceModel> runDOC(Database database, Relation<V> relation, ArrayModifiableDBIDs S, int d, int n, int m, int r, int minClusterSize) {
// Relevant attributes of highest cardinality.
long[] D = null;
// The seed point for the best dimensions.
DBIDVar dV = DBIDUtil.newVar()... | java |
public static SVGPath drawDelaunay(Projection2D proj, List<SweepHullDelaunay2D.Triangle> delaunay, List<double[]> means) {
final SVGPath path = new SVGPath();
for(SweepHullDelaunay2D.Triangle del : delaunay) {
path.moveTo(proj.fastProjectDataToRenderSpace(means.get(del.a)));
path.drawTo(proj.fastPro... | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.