Commit 347f3d53 authored by Alina Hinzmann's avatar Alina Hinzmann

-fixed problem with marginFactor: margin parameter and its sliders in

GUI are now working correctly
-added comments here and there
parent 72277d76
......@@ -12,14 +12,20 @@ public abstract class AbstractLabelPosition implements LabelPosition {
protected double marginFactor = 1.0;
/**
* Gives the converted absolute margin factor.
*/
public double getMarginFactor(){
return marginFactor*getDefaultMargin();
}
public void setMarginFactor(double marginFactor){
this.marginFactor = marginFactor/getDefaultMargin();
this.marginFactor = marginFactor;//getDefaultMargin();
}
/**
* Gives the standard default margin fitting best for this LabelPosition class.
*/
public abstract double getDefaultMargin();
@Override
......
......@@ -47,7 +47,6 @@ public class AlongEdgeLabelPosition extends ZUpLabelPosition {
double[] edgeCenter = as.getD(BaryCenter3d.class, e);
// double[] faceCenter = as.getD(BaryCenter3d.class, e.getLeftFace());
// Rn.linearCombination(edgeCenter, 0.95, edgeCenter, 0.05, faceCenter);
Rn.add(edgeCenter, edgeCenter, Rn.times(null, marginFactor, edgeCoordinateSystem[1])); //add a bit margin by "translating" edgeCenter
double[] anchorPoint = new double[3];
......@@ -104,7 +103,9 @@ public class AlongEdgeLabelPosition extends ZUpLabelPosition {
// return M;
}
/**
* Gives the standard default margin fitting best for this LabelPosition class.
*/
@Override
public double getDefaultMargin() {
return 0.03;
......
......@@ -69,7 +69,8 @@ public class LabelVisualizer extends DataVisualizerPlugin implements ActionListe
private SpinnerNumberModel
decimalsModel = new SpinnerNumberModel(3.0, 0.0, 100.0, 1.0),
fontSizeModel = new SpinnerNumberModel(0.05, 0.0, 100, 0.01),
marginFactorModel = new SpinnerNumberModel(0.03, -1, 1, 0.01); //TODO Problem:Startwert des Sliders setzen
marginFactorModel = new SpinnerNumberModel(1, -10, 10, 0.1); ////factor moving the Label away from its corresponding edge, here 1 as default value in order to have one GUI-element for different LabelPosition classes, but in computation of the matrixTrafo this will be converted to an absolute value using standard-margin (getDefaultMargin()) of the current LabelPosition-class
private JSpinner
decimalsSpinner = new JSpinner(decimalsModel),
......@@ -445,7 +446,7 @@ public class LabelVisualizer extends DataVisualizerPlugin implements ActionListe
private double
fontSize = 0.05, //font size of the label resp. the lineset
marginFactor = 0.03; //absolute factor moving the Label away from its corresponding edge
marginFactor = 1; //factor moving the Label away from its corresponding edge, here 1 as default value but in computation of the matrixTrafo this will be converted to an absolute value using standard-margin (getDefaultMargin()) of the current LabelPosition-class
private Color
color = Color.BLACK;
......
......@@ -47,14 +47,17 @@ public class ZUpLabelPosition extends AbstractLabelPosition {
double[] labelbbCenter = labelBoundingBox.getCenter();
double[] edgeVector = as.getD(EdgeVector.class, e); //get edge as vector
Face<?,?,?> face = e.getLeftFace();
double marginFactor = getMarginFactor();
double marginFactor = getMarginFactor(); //get the absolute marginFactor for this LabelPosition which will be used to translate the label away from the edge to make it fit better
//if the corresponding left face is null (e.g. if the corresp. edge is a boundary edge) then take the right face to place the label
if(face == null) {
face = e.getRightFace();
marginFactor *= -1.0;
marginFactor *= -1.0; //in this case negate the factor in order to still place the label on the correct side of the edge
}
if(face == null) {
return null;
if(face == null) { //if right face is also null, return
return null; //TODO find a solution for the case that the edge has no incident faces!!
}
double[][] localCoordinateSystem = getFacesCoordinateSystem(face,as);
double[] anchorPoint = getAnchorPoint(edgeVector, localCoordinateSystem, labelBoundingBox);
......@@ -167,6 +170,9 @@ public class ZUpLabelPosition extends AbstractLabelPosition {
return anchorPoint;
}
/**
* Gives the standard default margin fitting best for this LabelPosition class.
*/
@Override
public double getDefaultMargin() {
return 0.05;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment