Commit 05fc4904 authored by Alina Hinzmann's avatar Alina Hinzmann

new comments

parent 567ff4e8
......@@ -74,7 +74,7 @@ public class LabelVisualizer extends DataVisualizerPlugin implements ActionListe
sizeSpinner = new JSpinner(fontSizeModel);
private JTextField
prefixTextField = new JTextField();
prefixTextField = new JTextField(); //a textfield allowing to set a prefix to all labels of a visualization
private JCheckBox
flipLabelChecker = new JCheckBox("Flip direction"); //gives the possibility to flip the labels (if normals are in the "wrong" direction for it)
......@@ -88,7 +88,7 @@ public class LabelVisualizer extends DataVisualizerPlugin implements ActionListe
private LabelVisualization
activeVisualization = null; // a field holding the current Visualization, needed for interplay with the UI
private boolean listenersDisabled;
private boolean listenersDisabled; //boolean to let the update of the active visualization wait until data exchange with the UI is finished
public LabelVisualizer() {
optionsPanel.setLayout(new GridBagLayout());
......@@ -112,7 +112,7 @@ public class LabelVisualizer extends DataVisualizerPlugin implements ActionListe
sizeSpinner.addChangeListener(this);
// lc.gridwidth = 2;
labelColorButton.setColor(Color.BLACK);
labelColorButton.setColor(Color.BLACK); //set the initial color to black
optionsPanel.add(new JLabel("Color"), lc);
optionsPanel.add(labelColorButton, rc);
labelColorButton.addColorChangedListener(this);
......@@ -120,7 +120,7 @@ public class LabelVisualizer extends DataVisualizerPlugin implements ActionListe
@Override
public boolean canRead(Adapter<?> a, NodeType type) {
return true;
return true; //right now all adapters can be chosen as a source for what the labels show
}
@Override
......@@ -136,13 +136,20 @@ public class LabelVisualizer extends DataVisualizerPlugin implements ActionListe
}
@Override
/**
* Generates a String from given Data with chosen options. If the data is a Double it is rounded to have the chosen decimals.
* @param layer the corresponding layer
* @param type the NodeType the labels shall be created for
* @param source giving the data which shall be represented in a label
* @return the corresponding labels as a visualization
*/
public DataVisualization createVisualization(HalfedgeLayer layer, NodeType type, Adapter<?> source) {
LabelVisualization vis = new LabelVisualization(layer,source, this, type);
// copy last values
// vis.decimals = decimalsModel.getNumber().intValue();
// vis.prefix = prefixTextField.getText();
vis.setFontSize(fontSizeModel.getNumber().doubleValue());
vis.labelFlip = flipLabelChecker.isSelected();
vis.setFontSize(fontSizeModel.getNumber().doubleValue()); //stay with the fontsize previously chosen
vis.labelFlip = flipLabelChecker.isSelected(); //if labels were flipped in the previous visualization than go on with doing so
// vis.setColor(getLabelColor());
// vis.update();
......@@ -175,13 +182,18 @@ public class LabelVisualizer extends DataVisualizerPlugin implements ActionListe
}
private void updateLabelColor() {
//when we are just connecting with the UI we don't want to update but first hand all values of the current visualization to the UI with connectUserInterfaceFor
if(listenersDisabled) {
return;
}
activeVisualization.setColor(getLabelColor());
}
/**
* Hands over the current values chosen in the UI to the active visualization and updates it accordingly.
*/
private void updateVisualization() {
//when we are just connecting with the UI we don't want to update but first hand all values of the current visualization to the UI with connectUserInterfaceFor
if(listenersDisabled) {
return;
}
......@@ -194,8 +206,11 @@ public class LabelVisualizer extends DataVisualizerPlugin implements ActionListe
}
@Override
/**
* Connects the active visualization with the UI by handing over all values to the UI.
*/
public JPanel connectUserInterfaceFor(DataVisualization visualization) {
listenersDisabled = true;
listenersDisabled = true; //in order to let the update wait until all values are handed to the UI
activeVisualization = (LabelVisualization) visualization;
decimalsModel.setValue(activeVisualization.getDecimals());
prefixTextField.setText(activeVisualization.getPrefix());
......@@ -215,7 +230,8 @@ public class LabelVisualizer extends DataVisualizerPlugin implements ActionListe
private class LabelVisualization extends AbstractDataVisualization {
private SceneGraphComponent visualizationRoot = new SceneGraphComponent("Label visualization root"); // the root-component all labels will be attached to as SceneGraphComponents
private SceneGraphComponent
visualizationRoot = new SceneGraphComponent("Label visualization root"); // the root-component all labels will be attached to as SceneGraphComponents
private double[]
upDirection = new double[]{0,0,1};
......@@ -224,12 +240,12 @@ public class LabelVisualizer extends DataVisualizerPlugin implements ActionListe
ttfLineSetFactory = new TTFLineSetFactory(); // a factory which generates text as lineset from a corresponding string
private int
decimals = 3;
decimals = 3; //the number of decimals that will be shown in the labels
public String
prefix = new String();
prefix = new String(); //a possible prefix for all labels
private boolean labelFlip;
private boolean labelFlip; //labels are flipped if true (to make them readable both from in- and outside of the corresponding geometry)
private Appearance
labelAppearance = null;
......@@ -250,7 +266,6 @@ public class LabelVisualizer extends DataVisualizerPlugin implements ActionListe
super(layer, source, visualizer, type);
visualizationRoot.setName("Label for " + source.toString());
//set initial type and size of labels font
ttfLineSetFactory.setTTFFont(LabelVisualizer.class.getResource("Raleway-Thin.ttf").getPath());
ttfLineSetFactory.setSingleLineFont(false);
......@@ -258,7 +273,6 @@ public class LabelVisualizer extends DataVisualizerPlugin implements ActionListe
labelAppearance = ttfLineSetFactory.getStandardAppearance();
labelAppearance.setAttribute(CommonAttributes.EDGE_DRAW, true);
}
/* (non-Javadoc)
......
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