Skip to content
Snippets Groups Projects
Commit 7f1992d1 authored by Daniel Schramm's avatar Daniel Schramm
Browse files

Variable sizes of drawable feature points

parent 1f62d3d3
No related branches found
No related tags found
No related merge requests found
......@@ -14,10 +14,12 @@ import java.util.Map;
* Drawable feature points.
*
* @author Radek Oslejsek
* @author Daniel Schramm
*/
public class DrawableFeaturePoints extends Drawable {
public static final Color DEFAULT_COLOR = Color.LIGHT_GRAY;
public static final double DEFAULT_SIZE = 3f;
private static final GLU GLU_CONTEXT = new GLU();
......@@ -27,7 +29,12 @@ public class DrawableFeaturePoints extends Drawable {
/**
* feature points with color different from the default color
*/
private Map<Integer, Color> specialColors = new HashMap<>();
private final Map<Integer, Color> specialColors = new HashMap<>();
/**
* feature points with size different from the default size
*/
private final Map<Integer, Double> specialSizes = new HashMap<>();
/**
* Constructor.
......@@ -84,6 +91,36 @@ public class DrawableFeaturePoints extends Drawable {
this.specialColors.clear();
}
public Double getSize(int index) {
if (index < 0 || index >= featurePoints.size()) {
return null;
}
if (specialSizes.containsKey(index)) {
return specialSizes.get(index);
} else {
return DEFAULT_SIZE;
}
}
public void setSize(int index, double size) {
if (index < 0 || index >= featurePoints.size()) {
return;
}
if (size == DEFAULT_SIZE) {
specialSizes.remove(index);
} else {
specialSizes.put(index, size);
}
}
public void resetSizeToDefault(int index) {
setSize(index, DEFAULT_SIZE);
}
public void resetAllSizesToDefault() {
specialSizes.clear();
}
@Override
protected void renderObject(GL2 gl) {
float[] rgba = {
......@@ -108,7 +145,7 @@ public class DrawableFeaturePoints extends Drawable {
GLU_CONTEXT.gluQuadricDrawStyle(center, GLU.GLU_FILL);
GLU_CONTEXT.gluQuadricNormals(center, GLU.GLU_FLAT);
GLU_CONTEXT.gluQuadricOrientation(center, GLU.GLU_OUTSIDE);
GLU_CONTEXT.gluSphere(center, 3f, 16, 16);
GLU_CONTEXT.gluSphere(center, specialSizes.getOrDefault(i, DEFAULT_SIZE), 16, 16);
GLU_CONTEXT.gluDeleteQuadric(center);
gl.glPopMatrix();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment