Commit bb50f2d0 authored by Alina Hinzmann's avatar Alina Hinzmann

implemented flip of labeldirection

set default color black

but: update with several visualizations not yet fixed!
parent f2827d17
......@@ -81,7 +81,7 @@ public class LabelVisualizer extends DataVisualizerPlugin implements ActionListe
prefixTextField = new JTextField();
private JCheckBox
flipLabelDirectionChecker = new JCheckBox("Flip direction"); //TODO include the possibility to flip the labels (if normals are in the "wrong" direction for it)
flipLabelChecker = new JCheckBox("Flip direction"); //TODO include the possibility to flip the labels (if normals are in the "wrong" direction for it)
//do this by rotating the label-lineset 180degree around its bb-center-axis (z axis resp. earlier y-axis)
private ColorChooseJButton
labelColorButton = new ColorChooseJButton(true); //cool color button, true = showing colors to choose in new window
......@@ -105,8 +105,8 @@ public class LabelVisualizer extends DataVisualizerPlugin implements ActionListe
optionsPanel.add(prefixTextField, rc);
prefixTextField.addActionListener(this);
optionsPanel.add(flipLabelDirectionChecker, rc);
flipLabelDirectionChecker.addActionListener(this);
optionsPanel.add(flipLabelChecker, rc);
flipLabelChecker.addActionListener(this);
optionsPanel.add(new JLabel("Font size"), lc);
// sizeSpinner.setPreferredSize(new Dimension(100, 32));
......@@ -114,6 +114,7 @@ public class LabelVisualizer extends DataVisualizerPlugin implements ActionListe
sizeSpinner.addChangeListener(this);
// lc.gridwidth = 2;
labelColorButton.setColor(Color.BLACK);
optionsPanel.add(new JLabel("Color"), lc);
optionsPanel.add(labelColorButton, rc);
labelColorButton.addColorChangedListener(this);
......@@ -143,6 +144,7 @@ public class LabelVisualizer extends DataVisualizerPlugin implements ActionListe
vis.decimals = decimalsModel.getNumber().intValue();
vis.prefix = prefixTextField.getText();
vis.fontSize = fontSizeModel.getNumber().doubleValue();
vis.labelFlip = flipLabelChecker.isSelected();
vis.color = getLabelColor();
// layer.addTemporaryGeometry(vis.visualizationRoot);
......@@ -188,6 +190,7 @@ public class LabelVisualizer extends DataVisualizerPlugin implements ActionListe
private void updateVisualization() {
activeVisualization.setDecimals(decimalsModel.getNumber().intValue());
activeVisualization.setPrefix(prefixTextField.getText());
activeVisualization.setLabelFlipped(flipLabelChecker.isSelected());
activeVisualization.setFontSize(fontSizeModel.getNumber().doubleValue());
activeVisualization.setColor(getLabelColor());
activeVisualization.update();
......@@ -196,9 +199,10 @@ public class LabelVisualizer extends DataVisualizerPlugin implements ActionListe
@Override
public JPanel connectUserInterfaceFor(DataVisualization visualization) {
activeVisualization = (LabelVisualization) visualization;
fontSizeModel.setValue(activeVisualization.getFontSize());
decimalsModel.setValue(activeVisualization.getDecimals());
prefixTextField.setText(activeVisualization.getPrefix());
flipLabelChecker.setSelected(activeVisualization.isLabelFlipped());
fontSizeModel.setValue(activeVisualization.getFontSize());
labelColorButton.setColor(activeVisualization.getColor());
return optionsPanel;
......@@ -220,13 +224,6 @@ public class LabelVisualizer extends DataVisualizerPlugin implements ActionListe
private TTFLineSetFactory
ttfLineSetFactory = new TTFLineSetFactory(); // a factory which generates text as lineset from a corresponding string
private Appearance
labelAppearance = null;
private double
fontSize = 0.03; // font size of the label resp. the lineset
private int
decimals = 3;
......@@ -234,6 +231,14 @@ public class LabelVisualizer extends DataVisualizerPlugin implements ActionListe
public String
prefix = null;
private boolean labelFlip;
private Appearance
labelAppearance = null;
private double
fontSize = 0.05; // font size of the label resp. the lineset
private Color
color = Color.BLACK;
......@@ -290,8 +295,12 @@ public class LabelVisualizer extends DataVisualizerPlugin implements ActionListe
Matrix M = MatrixBuilder.euclidean() //generate the trafo-matrix, done/to read from bottom to top
.translate(center) //translate the label to the vertex position
.rotateFromTo(upDirection, normal) //new double[]{0, 0,1}, normal) //rotate the updirection to the vertexnormal
.translate(Rn.negate(null, labelCenter)) //translate the labels center to the origin
.getMatrix();
if(labelFlip){
M.multiplyOnRight(MatrixBuilder.euclidean().rotateY(Math.PI).getMatrix());
}
M.multiplyOnRight(MatrixBuilder.euclidean().translate(Rn.negate(null, labelCenter)).getMatrix()); //translate the labels center to the origin
M.assignTo(sgc);
SceneGraphUtility.addChildNode(visualizationRoot, sgc);
}
......@@ -308,6 +317,8 @@ public class LabelVisualizer extends DataVisualizerPlugin implements ActionListe
SceneGraphComponent sgc = new SceneGraphComponent("E" + String.format("%0"+numDigits+"d",e.getIndex()));
sgc.setGeometry(ttfLineSetFactory.getIndexLineSet(prefix + label));
Rectangle3D labelBoundingBox = BoundingBoxUtility.calculateBoundingBox(ttfLineSetFactory.getIndexLineSet(label));
double[] bbCenter = labelBoundingBox.getCenter();
double[] edgeVector = a.getD(EdgeVector.class, e); //get edge as vector
double[][] localCoordinateSystem = getFacesCoordinateSystem(e.getLeftFace(),a);
......@@ -319,7 +330,13 @@ public class LabelVisualizer extends DataVisualizerPlugin implements ActionListe
Rn.linearCombination(edgeCenter, 0.95, edgeCenter, 0.05, faceCenter);
Matrix M = getTransformationMatrix(localCoordinateSystem, edgeCenter);
M.multiplyOnRight(MatrixBuilder.euclidean().translate(Rn.negate(null, anchorPoint)).getMatrix());
if(labelFlip){
M.multiplyOnRight(MatrixBuilder.euclidean().translate(bbCenter).getMatrix());
M.multiplyOnRight(MatrixBuilder.euclidean().rotateY(Math.PI).getMatrix());
M.multiplyOnRight(MatrixBuilder.euclidean().translate(Rn.negate(null, bbCenter)).getMatrix());
}
M.assignTo(sgc);
SceneGraphUtility.addChildNode(visualizationRoot, sgc);
......@@ -343,6 +360,9 @@ public class LabelVisualizer extends DataVisualizerPlugin implements ActionListe
double[] center = a.getD(BaryCenter3d.class, f);
double[][] localCoordinateSystem = getFacesCoordinateSystem(f,a);
Matrix M = getTransformationMatrix(localCoordinateSystem, center);
if(labelFlip){
M.multiplyOnRight(MatrixBuilder.euclidean().rotateY(Math.PI).getMatrix());
}
M.multiplyOnRight(MatrixBuilder.euclidean().translate(Rn.negate(null, bbCenter)).getMatrix());
M.assignTo(sgc);
SceneGraphUtility.addChildNode(visualizationRoot, sgc);
......@@ -483,6 +503,14 @@ public class LabelVisualizer extends DataVisualizerPlugin implements ActionListe
this.prefix = prefix;
}
public boolean isLabelFlipped() {
return labelFlip;
}
public void setLabelFlipped(boolean labelFlip) {
this.labelFlip = labelFlip;
}
public double getFontSize() {
return fontSize;
}
......
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