use of org.eclipse.elk.core.options.CoreOptions in project elk by eclipse.
the class ElkUtil method applyConfiguredNodeScaling.
/**
* Applies the scaling factor configured in terms of {@link CoreOptions#SCALE_FACTOR} to {@code node}'s
* size data, and updates the layout data of {@code node}'s ports and labels accordingly.<br>
* <b>Note:</b> The scaled layout data won't be reverted during the layout process, see
* {@link CoreOptions#SCALE_FACTOR}.
*
* @param node
* the node to be scaled
*/
public static void applyConfiguredNodeScaling(final ElkNode node) {
final double scalingFactor = node.getProperty(CoreOptions.SCALE_FACTOR);
if (scalingFactor == 1) {
return;
}
node.setDimensions(scalingFactor * node.getWidth(), scalingFactor * node.getHeight());
final Iterable<ElkLabel> portLabels = Iterables.concat(Iterables.transform(node.getPorts(), p -> p.getLabels()));
for (ElkShape shape : Iterables.concat(node.getLabels(), node.getPorts(), portLabels)) {
shape.setLocation(scalingFactor * shape.getX(), scalingFactor * shape.getY());
shape.setDimensions(scalingFactor * shape.getWidth(), scalingFactor * shape.getHeight());
final KVector anchor = shape.getProperty(CoreOptions.PORT_ANCHOR);
if (anchor != null) {
anchor.x *= scalingFactor;
anchor.y *= scalingFactor;
}
}
}
use of org.eclipse.elk.core.options.CoreOptions in project elk by eclipse.
the class LayoutMetaDataService method getInstance.
/**
* Returns the singleton instance of the layout data service.
*
* @param loader
* The class loader object. This is not explicitly a class loader since elkjs cannot handle it.
*
* @return the singleton instance
*/
public static synchronized LayoutMetaDataService getInstance(final Object loader) {
if (instance == null) {
instance = new LayoutMetaDataService();
// Be sure to load CoreOptions first
instance.registerLayoutMetaDataProviders(new CoreOptions());
// running on Equinox since this will only find services in the realm of this class's class loader)
for (ILayoutMetaDataProvider provider : java.util.ServiceLoader.load(ILayoutMetaDataProvider.class, (ClassLoader) loader)) {
instance.registerLayoutMetaDataProviders(provider);
}
// Try to make the ELK service plug-in load our services
try {
Class.forName("org.eclipse.elk.core.service.ElkServicePlugin");
} catch (Exception e) {
// If the service plug-in is not available, that's no problem; we'll simply use our default factory
}
// elkjs-exclude-end
}
return instance;
}
Aggregations