use of de.lmu.ifi.dbs.elki.math.scales.LinearScale in project elki by elki-project.
the class Parallel3DRenderer method drawParallelPlot.
protected void drawParallelPlot(GLAutoDrawable drawable, GL2 gl) {
// Sort axes by sq. distance from camera, front-to-back:
sortAxes();
// Sort edges by the maximum (foreground) index.
IntIntPair[] edgesort = sortEdges(dindex);
if (textures != null) {
gl.glShadeModel(GL2.GL_FLAT);
// Render spider web:
// outside glBegin!
gl.glLineWidth(shared.settings.linewidth);
gl.glBegin(GL.GL_LINES);
gl.glColor4f(0f, 0f, 0f, 1f);
for (Layout.Edge edge : shared.layout.edges) {
Node n1 = shared.layout.getNode(edge.dim1), n2 = shared.layout.getNode(edge.dim2);
gl.glVertex3d(n1.getX(), n1.getY(), 0f);
gl.glVertex3d(n2.getX(), n2.getY(), 0f);
}
gl.glEnd();
// Draw axes and 3DPC:
for (int i = 0; i < shared.dim; i++) {
final int d = axes[i].second;
final Node node1 = shared.layout.getNode(d);
// Draw edge textures
for (IntIntPair pair : edgesort) {
// Not yet available?
if (pair.second >= completedTextures) {
continue;
}
// Other axis must have a smaller index.
if (pair.first >= i) {
continue;
}
Layout.Edge edge = shared.layout.edges.get(pair.second);
// Must involve the current axis.
if (edge.dim1 != d && edge.dim2 != d) {
continue;
}
int od = axes[pair.first].second;
gl.glEnable(GL.GL_TEXTURE_2D);
gl.glColor4f(1f, 1f, 1f, 1f);
final Node node2 = shared.layout.getNode(od);
gl.glBindTexture(GL.GL_TEXTURE_2D, textures[pair.second]);
gl.glBegin(GL2.GL_QUADS);
gl.glTexCoord2d((edge.dim1 == d) ? 0f : 1f, 0f);
gl.glVertex3d(node1.getX(), node1.getY(), 0f);
gl.glTexCoord2d((edge.dim1 == d) ? 0f : 1f, 1f);
gl.glVertex3d(node1.getX(), node1.getY(), 1f);
gl.glTexCoord2d((edge.dim1 != d) ? 0f : 1f, 1f);
gl.glVertex3d(node2.getX(), node2.getY(), 1f);
gl.glTexCoord2d((edge.dim1 != d) ? 0f : 1f, 0f);
gl.glVertex3d(node2.getX(), node2.getY(), 0f);
gl.glEnd();
gl.glDisable(GL.GL_TEXTURE_2D);
}
// Draw axis
// outside glBegin!
gl.glLineWidth(shared.settings.linewidth);
gl.glBegin(GL.GL_LINES);
gl.glColor4f(0f, 0f, 0f, 1f);
gl.glVertex3d(node1.getX(), node1.getY(), 0f);
gl.glVertex3d(node1.getX(), node1.getY(), 1f);
gl.glEnd();
// Draw ticks.
LinearScale scale = shared.proj.getAxisScale(d);
gl.glPointSize(shared.settings.linewidth * 2f);
gl.glBegin(GL.GL_POINTS);
for (double tick = scale.getMin(); tick <= scale.getMax() + scale.getRes() / 10; tick += scale.getRes()) {
gl.glVertex3d(node1.getX(), node1.getY(), scale.getScaled(tick));
}
gl.glEnd();
}
}
// Render labels
renderLabels(gl, edgesort);
}
use of de.lmu.ifi.dbs.elki.math.scales.LinearScale in project elki by elki-project.
the class AbstractObjDynamicHistogram method materialize.
/**
* Materialize the histogram from the cache.
*/
@SuppressWarnings("unchecked")
void materialize() {
// already materialized?
if (cachefill <= 0) {
return;
}
// Compute minimum and maximum
double min = Double.MAX_VALUE, max = Double.MIN_VALUE;
for (int i = 0; i < cachefill; i++) {
min = MathUtil.min(min, cacheposs[i]);
max = MathUtil.max(max, cacheposs[i]);
}
// use the LinearScale magic to round to "likely suitable" step sizes.
// TODO: extract into a reusable function?
LinearScale scale = new LinearScale(min, max);
min = scale.getMin();
max = scale.getMax();
this.base = min;
this.max = max;
this.binsize = (max - min) / this.destsize;
// initialize array
this.data = new Object[this.destsize << 1];
for (int i = 0; i < this.destsize; i++) {
this.data[i] = makeObject();
}
size = destsize;
// re-insert data we have
final int end = cachefill;
// So reinsert works!
cachefill = -1;
for (int i = 0; i < end; i++) {
putData(cacheposs[i], (T) cachevals[i]);
}
// delete cache, signal that we're initialized
cacheposs = null;
cachevals = null;
}
use of de.lmu.ifi.dbs.elki.math.scales.LinearScale in project elki by elki-project.
the class FloatDynamicHistogram method materialize.
/**
* Materialize the histogram from the cache.
*/
void materialize() {
// already materialized?
if (cachefill < 0) {
return;
}
// Compute minimum and maximum
double min = Double.MAX_VALUE, max = Double.MIN_VALUE;
for (int i = 0; i < cachefill; i++) {
min = Math.min(min, cachec[i]);
max = Math.max(max, cachec[i]);
}
// use the LinearScale magic to round to "likely suiteable" step sizes.
// TODO: extract into a reusable function?
LinearScale scale = new LinearScale(min, max);
min = scale.getMin();
max = scale.getMax();
this.base = min;
this.max = max;
this.binsize = (max - min) / this.destsize;
// initialize array
this.data = new float[this.destsize << 1];
size = destsize;
// re-insert data we have
final int end = cachefill;
// So reinsert works!
cachefill = -1;
for (int i = 0; i < end; i++) {
increment(cachec[i], cachev[i]);
}
// delete cache, signal that we're initialized
cachec = null;
cachev = null;
}
use of de.lmu.ifi.dbs.elki.math.scales.LinearScale in project elki by elki-project.
the class ShortDynamicHistogram method materialize.
/**
* Materialize the histogram from the cache.
*/
void materialize() {
// already materialized?
if (cachefill < 0) {
return;
}
// Compute minimum and maximum
double min = Double.MAX_VALUE, max = Double.MIN_VALUE;
for (int i = 0; i < cachefill; i++) {
min = Math.min(min, cachec[i]);
max = Math.max(max, cachec[i]);
}
// use the LinearScale magic to round to "likely suiteable" step sizes.
// TODO: extract into a reusable function?
LinearScale scale = new LinearScale(min, max);
min = scale.getMin();
max = scale.getMax();
this.base = min;
this.max = max;
this.binsize = (max - min) / this.destsize;
// initialize array
this.data = new short[this.destsize << 1];
size = destsize;
// re-insert data we have
final int end = cachefill;
// So reinsert works!
cachefill = -1;
for (int i = 0; i < end; i++) {
increment(cachec[i], cachev[i]);
}
// delete cache, signal that we're initialized
cachec = null;
cachev = null;
}
Aggregations