Skip to content

Commit

Permalink
move fuzziness property to ELK and calculate correct length of preview
Browse files Browse the repository at this point in the history
  • Loading branch information
Eddykasp committed Oct 22, 2024
1 parent 5471120 commit a3bf160
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,6 @@ public Boolean caseElkLabel(final ElkLabel layoutLabel) {
private void shapeLayoutToLayoutGraph(
final KShapeLayout sourceShapeLayout, final ElkShape targetShape) {

// Attention: Layout options are transfered by the {@link KGraphPropertyLayoutConfig}
targetShape.setLocation(sourceShapeLayout.getXpos(), sourceShapeLayout.getYpos());
targetShape.setDimensions(sourceShapeLayout.getWidth(), sourceShapeLayout.getHeight());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
*/
package de.cau.cs.kieler.klighd.labels.management;

import org.eclipse.elk.core.options.CoreOptions;
import org.eclipse.elk.graph.ElkLabel;
import org.eclipse.swt.graphics.FontData;

import de.cau.cs.kieler.klighd.microlayout.PlacementUtil;
import de.cau.cs.kieler.klighd.util.KlighdProperties;

/**
* Label manager which soft wraps the text so it fits a certain width. Soft wrapping only inserts
Expand All @@ -43,7 +43,7 @@ public class SoftWrappingLabelManager extends AbstractKlighdLabelManager {
* @return The fuzziness
*/
public double getFuzziness(final ElkLabel label) {
return label.getProperty(KlighdProperties.SOFTWRAPPING_FUZZINESS);
return label.getProperty(CoreOptions.SOFTWRAPPING_FUZZINESS);
}

@Override
Expand Down Expand Up @@ -95,6 +95,7 @@ public Result doResizeLabel(final ElkLabel label, final double targetWidth) {
}
lineWidth = PlacementUtil.estimateTextSize(font, testText).getWidth();
} while (lineWidth < effectiveTargetWidth && previewWordIndex < words.length);
lineWidth = PlacementUtil.estimateTextSize(font, previewLineText).getWidth();
if (lineWidth < effectiveTargetWidth * getFuzziness(label)) {
// next line would contain too much whitespace so append it to this line
currWordIndex = previewWordIndex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,13 +427,4 @@ public static boolean isSelectable(final EObject viewElement) {
*/
public static final IProperty<KVector> ROUNDED_RECTANGLE_AUTOPADDING =
new Property<KVector>("klighd.roundedRectangle.autopadding", null);

/**
* Determines the amount of fuzziness to be used when performing softwrapping on labels.
* The value expresses the percent of overhang that is permitted for each line.
* If the next line would take up less space than this threshold, it is appended to the
* current line instead of being placed in a new line.
*/
public static final IProperty<Double> SOFTWRAPPING_FUZZINESS =
new Property<Double>("klighd.softwrapping.fuzzyness",0.0);
}

0 comments on commit a3bf160

Please sign in to comment.