From 0356b86c22eac3382d5253180794d7ab03d794bd Mon Sep 17 00:00:00 2001 From: Hannes Wellmann Date: Tue, 13 Aug 2024 14:42:29 +0200 Subject: [PATCH] Replace Guava's collection factories by standard Java - Replace LinkedList with ArrayList or ArrayDeque Part of https://github.com/kieler/KLighD/issues/199 --- .../text/ui/internal/TextActivator.java | 4 +- .../text/grandom/RandomGraphGenerator.java | 8 +- .../incremental/merge/KGraphMerger.java | 12 ++- .../kgraph/util/DefaultSelectionIterator.java | 5 +- .../klighd/kgraph/util/KGraphDataUtil.java | 5 +- .../kieler/klighd/kgraph/util/KGraphUtil.java | 5 +- .../cs/kieler/klighd/krendering/Colors.java | 4 +- .../freehep/SemanticSVGGraphics2D.java | 5 +- .../export/KlighdAbstractSVGGraphics.java | 5 +- .../internal/KlighdSWTGraphicsImpl.java | 5 +- .../AbstractKGERenderingController.java | 5 +- .../controller/DiagramController.java | 12 +-- .../controller/DiagramControllerHelper.java | 3 +- .../DiagramZoomControllerBoundsComputer.java | 5 +- .../KGERenderingControllerHelper.java | 5 +- .../events/KlighdSelectionEventHandler.java | 5 +- .../piccolo/internal/nodes/KlighdImage.java | 5 +- .../piccolo/internal/nodes/KlighdPath.java | 5 +- .../piccolo/internal/util/PolylineUtil.java | 3 +- .../klighd/piccolo/internal/util/Styles.java | 6 +- .../cs/kieler/klighd/ui/view/DiagramView.java | 10 +-- .../ViewUpdateControllerFactory.java | 26 +++--- .../ui/wizard/KlighdProjectContributor.xtend | 2 +- .../ui/wizard/KlighdProjectCreator.java | 10 +-- .../kieler/klighd/ui/DiagramViewManager.java | 7 +- .../internal/handlers/ExportKGraphHelper.java | 13 ++- .../internal/handlers/SaveKGraphHandler.java | 9 +-- .../options/ActionControlFactory.java | 5 +- .../SynthesisOptionControlFactory.java | 11 ++- .../KlighdPlatformPreferenceStore.java | 5 +- .../ModelModificationHandlerProvider.java | 5 +- .../cs/kieler/klighd/IViewChangeListener.java | 9 +-- .../cs/kieler/klighd/KlighdDataManager.java | 36 +++++---- .../kieler/klighd/LightDiagramServices.java | 4 +- .../de/cau/cs/kieler/klighd/ViewContext.java | 13 ++- .../klighd/actions/FocusAndContextAction.java | 5 +- .../KlighdDiagramLayoutConnector.java | 4 +- .../KlighdPlainPreferenceStore.java | 6 +- .../util/SourceModelTrackingAdapter.java | 4 +- .../KCustomRenderingWrapperFactory.java | 3 +- .../krendering/SimpleUpdateStrategy.java | 5 +- .../LabelDecorationConfigurator.java | 5 +- .../labels/management/ListLabelManager.java | 5 +- .../klighd/microlayout/GridPlacementUtil.java | 7 +- .../klighd/microlayout/PlacementUtil.java | 16 ++-- .../ReinitializingDiagramSynthesisProxy.java | 4 +- .../cau/cs/kieler/klighd/util/Iterables2.java | 4 +- .../util/KlighdSemanticDiagramData.java | 7 +- .../util/KlighdSynthesisProperties.java | 7 +- .../kieler/klighd/viewers/AbstractViewer.java | 4 +- .../kieler/klighd/viewers/ContextViewer.java | 3 +- .../test/ApplyBendPointsActivityTest.java | 5 +- ...lipGlobalPortLabelVisiblityConfigTest.java | 4 +- .../DiagramClipPortLabelVisibilityTest.java | 3 +- .../klighd/piccolo/test/DiagramClipTest.java | 4 +- ...agramZoomControllerBoundsComputerTest.java | 3 +- ...iewChangedNotificationSuppressionTest.java | 81 +++++++++---------- .../runners/ModelCollectionTestRunner.java | 7 +- 58 files changed, 217 insertions(+), 256 deletions(-) diff --git a/plugins/de.cau.cs.kieler.kgraph.text.ui/src-gen/de/cau/cs/kieler/kgraph/text/ui/internal/TextActivator.java b/plugins/de.cau.cs.kieler.kgraph.text.ui/src-gen/de/cau/cs/kieler/kgraph/text/ui/internal/TextActivator.java index 0a41903c9..ef12d2e1c 100644 --- a/plugins/de.cau.cs.kieler.kgraph.text.ui/src-gen/de/cau/cs/kieler/kgraph/text/ui/internal/TextActivator.java +++ b/plugins/de.cau.cs.kieler.kgraph.text.ui/src-gen/de/cau/cs/kieler/kgraph/text/ui/internal/TextActivator.java @@ -3,7 +3,6 @@ */ package de.cau.cs.kieler.kgraph.text.ui.internal; -import com.google.common.collect.Maps; import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.Module; @@ -12,6 +11,7 @@ import de.cau.cs.kieler.kgraph.text.ui.GRandomUiModule; import de.cau.cs.kieler.kgraph.text.ui.KGraphUiModule; import java.util.Collections; +import java.util.HashMap; import java.util.Map; import org.apache.log4j.Logger; import org.eclipse.ui.plugin.AbstractUIPlugin; @@ -32,7 +32,7 @@ public class TextActivator extends AbstractUIPlugin { private static TextActivator INSTANCE; - private Map injectors = Collections.synchronizedMap(Maps. newHashMapWithExpectedSize(1)); + private Map injectors = Collections.synchronizedMap(new HashMap<>(2)); @Override public void start(BundleContext context) throws Exception { diff --git a/plugins/de.cau.cs.kieler.kgraph.text/src/de/cau/cs/kieler/kgraph/text/grandom/RandomGraphGenerator.java b/plugins/de.cau.cs.kieler.kgraph.text/src/de/cau/cs/kieler/kgraph/text/grandom/RandomGraphGenerator.java index a6c2f191c..d58e1ee5a 100644 --- a/plugins/de.cau.cs.kieler.kgraph.text/src/de/cau/cs/kieler/kgraph/text/grandom/RandomGraphGenerator.java +++ b/plugins/de.cau.cs.kieler.kgraph.text/src/de/cau/cs/kieler/kgraph/text/grandom/RandomGraphGenerator.java @@ -22,6 +22,7 @@ import java.util.Collections; import java.util.Comparator; import java.util.Deque; +import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.ListIterator; @@ -36,9 +37,6 @@ import org.eclipse.elk.core.util.Pair; import org.eclipse.elk.graph.properties.IProperty; -import com.google.common.collect.Lists; -import com.google.common.collect.Sets; - import de.cau.cs.kieler.kgraph.text.grandom.GeneratorOptions.RandVal; import de.cau.cs.kieler.klighd.kgraph.KEdge; import de.cau.cs.kieler.klighd.kgraph.KGraphFactory; @@ -132,7 +130,7 @@ private List> addHierarchicalNodes(final KNode parent) { private void connectAtomicNodesOnDifferentLevels(final List> atomicNodes) { int numCrossHier; if (get(EXACT_RELATIVE_HIER) != null) { - Set newHashSet = Sets.newHashSet(); + Set newHashSet = new HashSet<>(); for (List level : atomicNodes) { for (KNode node : level) { newHashSet.addAll(node.getIncomingEdges()); @@ -1208,7 +1206,7 @@ private KPort retrievePort(final KNode node, final boolean source) { float reusePortsChance = get(USE_EXISTING_PORTS_CHANCE).floatVal(random); if (reusePortsChance > 0.0f && random.nextFloat() < reusePortsChance) { // Collect candidate ports for reuse - List reuseCandidates = Lists.newLinkedList(); + List reuseCandidates = new ArrayList<>(); for (KPort port : node.getPorts()) { // Two flags indicating whether the port already has edges pointing in the right diff --git a/plugins/de.cau.cs.kieler.klighd.incremental/src/de/cau/cs/kieler/klighd/incremental/merge/KGraphMerger.java b/plugins/de.cau.cs.kieler.klighd.incremental/src/de/cau/cs/kieler/klighd/incremental/merge/KGraphMerger.java index 3d1e9a538..d3f044688 100644 --- a/plugins/de.cau.cs.kieler.klighd.incremental/src/de/cau/cs/kieler/klighd/incremental/merge/KGraphMerger.java +++ b/plugins/de.cau.cs.kieler.klighd.incremental/src/de/cau/cs/kieler/klighd/incremental/merge/KGraphMerger.java @@ -19,7 +19,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; -import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -32,7 +31,6 @@ import org.eclipse.emf.common.util.EMap; import org.eclipse.emf.ecore.util.EcoreUtil; -import com.google.common.collect.Lists; import com.google.common.collect.MapDifference.ValueDifference; import com.google.common.collect.Sets; @@ -362,9 +360,9 @@ private void handleLabels(final KLabeledGraphElement baseElement, final KLabeledGraphElement newElement) { Set oldLabels = null; if (baseElement != null) { - oldLabels = new HashSet(baseElement.getLabels()); + oldLabels = new HashSet<>(baseElement.getLabels()); } - for (KLabel newLabel : Lists.newLinkedList(newElement.getLabels())) { + for (KLabel newLabel : new ArrayList<>(newElement.getLabels())) { KLabel baseLabel = comparison.lookupBaseLabel(newLabel); if (baseLabel == null) { baseLabel = EcoreUtil.copy(newLabel); @@ -425,9 +423,9 @@ private void updateLabel(final KLabel baseLabel, final KLabel newLabel) { private void handlePorts(final KNode baseNode, final KNode newNode) { Set oldPorts = null; if (baseNode != null) { - oldPorts = new HashSet(baseNode.getPorts()); + oldPorts = new HashSet<>(baseNode.getPorts()); } - for (KPort newPort : Lists.newLinkedList(newNode.getPorts())) { + for (KPort newPort : new ArrayList<>(newNode.getPorts())) { KPort basePort = comparison.lookupBasePort(newPort); if (basePort == null) { basePort = EcoreUtil.copy(newPort); @@ -487,7 +485,7 @@ private void updateGraphElement(final KGraphElement baseElement, baseData.addAll(newData); baseElement.copyProperties(newElement); EMap, Object> baseProperties = baseElement.getProperties(); - LinkedList> removedProperties = Lists.newLinkedList( + List> removedProperties = new ArrayList<>( Sets.difference(baseProperties.keySet(), newElement.getProperties().keySet())); for (IProperty property : removedProperties) { diff --git a/plugins/de.cau.cs.kieler.klighd.kgraph/src/de/cau/cs/kieler/klighd/kgraph/util/DefaultSelectionIterator.java b/plugins/de.cau.cs.kieler.klighd.kgraph/src/de/cau/cs/kieler/klighd/kgraph/util/DefaultSelectionIterator.java index fed530941..3428114eb 100644 --- a/plugins/de.cau.cs.kieler.klighd.kgraph/src/de/cau/cs/kieler/klighd/kgraph/util/DefaultSelectionIterator.java +++ b/plugins/de.cau.cs.kieler.klighd.kgraph/src/de/cau/cs/kieler/klighd/kgraph/util/DefaultSelectionIterator.java @@ -17,12 +17,11 @@ package de.cau.cs.kieler.klighd.kgraph.util; import java.util.Collections; +import java.util.HashSet; import java.util.Iterator; import com.google.common.base.Predicate; import com.google.common.collect.Iterators; -import com.google.common.collect.Sets; - import de.cau.cs.kieler.klighd.kgraph.KEdge; import de.cau.cs.kieler.klighd.kgraph.KGraphElement; import de.cau.cs.kieler.klighd.kgraph.KPort; @@ -67,7 +66,7 @@ public DefaultSelectionIterator(final KEdge edge, final boolean addPorts, protected Iterator getChildren(final Object object) { // Ensure that the visited set is properly initialized if (visited == null) { - visited = Sets.newHashSet(); + visited = new HashSet<>(); } if (object instanceof KEdge) { diff --git a/plugins/de.cau.cs.kieler.klighd.kgraph/src/de/cau/cs/kieler/klighd/kgraph/util/KGraphDataUtil.java b/plugins/de.cau.cs.kieler.klighd.kgraph/src/de/cau/cs/kieler/klighd/kgraph/util/KGraphDataUtil.java index 3e7127e3e..966926f08 100644 --- a/plugins/de.cau.cs.kieler.klighd.kgraph/src/de/cau/cs/kieler/klighd/kgraph/util/KGraphDataUtil.java +++ b/plugins/de.cau.cs.kieler.klighd.kgraph/src/de/cau/cs/kieler/klighd/kgraph/util/KGraphDataUtil.java @@ -17,6 +17,7 @@ package de.cau.cs.kieler.klighd.kgraph.util; import java.util.Collections; +import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -33,8 +34,6 @@ import org.eclipse.emf.ecore.util.EContentsEList.FeatureIteratorImpl; import com.google.common.base.Predicate; -import com.google.common.collect.Maps; - import de.cau.cs.kieler.klighd.kgraph.EMapPropertyHolder; import de.cau.cs.kieler.klighd.kgraph.KGraphPackage; import de.cau.cs.kieler.klighd.kgraph.KLayoutData; @@ -207,7 +206,7 @@ public static KNode loadDataElements(final KNode graph, final Predicate handledTypes, final boolean clearProperties, final IProperty... knownProps) { - Map> knowPropsMap = Maps.newHashMap(); + Map> knowPropsMap = new HashMap<>(); for (IProperty p : knownProps) { knowPropsMap.put(p.getId(), p); } diff --git a/plugins/de.cau.cs.kieler.klighd.kgraph/src/de/cau/cs/kieler/klighd/kgraph/util/KGraphUtil.java b/plugins/de.cau.cs.kieler.klighd.kgraph/src/de/cau/cs/kieler/klighd/kgraph/util/KGraphUtil.java index cc4255e94..d32a15e0e 100644 --- a/plugins/de.cau.cs.kieler.klighd.kgraph/src/de/cau/cs/kieler/klighd/kgraph/util/KGraphUtil.java +++ b/plugins/de.cau.cs.kieler.klighd.kgraph/src/de/cau/cs/kieler/klighd/kgraph/util/KGraphUtil.java @@ -17,6 +17,7 @@ package de.cau.cs.kieler.klighd.kgraph.util; import java.util.ArrayList; +import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Set; @@ -43,8 +44,6 @@ import com.google.common.base.Strings; import com.google.common.collect.Iterators; import com.google.common.collect.Lists; -import com.google.common.collect.Sets; - import de.cau.cs.kieler.klighd.kgraph.EMapPropertyHolder; import de.cau.cs.kieler.klighd.kgraph.KEdge; import de.cau.cs.kieler.klighd.kgraph.KGraphElement; @@ -710,7 +709,7 @@ public static Iterator getConnectedElements(final KEdge kedge, // get a singleton iterator offering 'kedge' final Iterator kedgeIt = Iterators.singletonIterator((KGraphElement) kedge); // Keep a set of visited elements for the tree iterators - final Set visited = Sets.newHashSet(); + final Set visited = new HashSet<>(); // Grab source iterator if edge has a source final SelectionIterator sourceSideIt = diff --git a/plugins/de.cau.cs.kieler.klighd.krendering/src-custom/de/cau/cs/kieler/klighd/krendering/Colors.java b/plugins/de.cau.cs.kieler.klighd.krendering/src-custom/de/cau/cs/kieler/klighd/krendering/Colors.java index 8098a4ce3..c9ac5f4cc 100644 --- a/plugins/de.cau.cs.kieler.klighd.krendering/src-custom/de/cau/cs/kieler/klighd/krendering/Colors.java +++ b/plugins/de.cau.cs.kieler.klighd.krendering/src-custom/de/cau/cs/kieler/klighd/krendering/Colors.java @@ -18,8 +18,6 @@ import java.util.HashMap; -import com.google.common.collect.Maps; - /** * An color library containing a huge collection named colors.
* The list of literals have been extracted from @@ -1755,7 +1753,7 @@ public String toStringWithComponents() { return super.toString() + "(" + redComponent + "," + greenComponent + "," + blueComponent + ")"; } - private static HashMap fastColorLookup = Maps.newHashMap(); + private static HashMap fastColorLookup = new HashMap<>(); /** * Provides the color with the name name. Besides it builds up a {@link HashMap} of diff --git a/plugins/de.cau.cs.kieler.klighd.piccolo.freehep/src/de/cau/cs/kieler/klighd/piccolo/freehep/SemanticSVGGraphics2D.java b/plugins/de.cau.cs.kieler.klighd.piccolo.freehep/src/de/cau/cs/kieler/klighd/piccolo/freehep/SemanticSVGGraphics2D.java index 8a518d1b2..4e07902de 100644 --- a/plugins/de.cau.cs.kieler.klighd.piccolo.freehep/src/de/cau/cs/kieler/klighd/piccolo/freehep/SemanticSVGGraphics2D.java +++ b/plugins/de.cau.cs.kieler.klighd.piccolo.freehep/src/de/cau/cs/kieler/klighd/piccolo/freehep/SemanticSVGGraphics2D.java @@ -37,6 +37,7 @@ import java.util.Arrays; import java.util.Date; import java.util.Enumeration; +import java.util.HashMap; import java.util.Hashtable; import java.util.Locale; import java.util.Map; @@ -66,8 +67,6 @@ import org.freehep.util.io.WriterOutputStream; import com.google.common.base.Strings; -import com.google.common.collect.Maps; - import de.cau.cs.kieler.klighd.Klighd; import de.cau.cs.kieler.klighd.KlighdConstants; import de.cau.cs.kieler.klighd.microlayout.PlacementUtil; @@ -227,7 +226,7 @@ public static void setDefaultProperties(Properties newProperties) { private final float pointToPxFactor = KlighdConstants.DEFAULT_DISPLAY_DPI / 72f; /** A mapping of awt fonts to swt fonts. The latter are used for font size calculations. */ - private Map awtSwtFontCache = Maps.newHashMap(); + private Map awtSwtFontCache = new HashMap<>(); /* * ================================================================================ | diff --git a/plugins/de.cau.cs.kieler.klighd.piccolo/src/de/cau/cs/kieler/klighd/piccolo/export/KlighdAbstractSVGGraphics.java b/plugins/de.cau.cs.kieler.klighd.piccolo/src/de/cau/cs/kieler/klighd/piccolo/export/KlighdAbstractSVGGraphics.java index 020828993..39cb76f8b 100644 --- a/plugins/de.cau.cs.kieler.klighd.piccolo/src/de/cau/cs/kieler/klighd/piccolo/export/KlighdAbstractSVGGraphics.java +++ b/plugins/de.cau.cs.kieler.klighd.piccolo/src/de/cau/cs/kieler/klighd/piccolo/export/KlighdAbstractSVGGraphics.java @@ -47,6 +47,7 @@ import java.io.IOException; import java.io.OutputStream; import java.text.AttributedCharacterIterator; +import java.util.HashMap; import java.util.Map; import org.eclipse.elk.core.util.Pair; @@ -62,8 +63,6 @@ import org.eclipse.swt.graphics.RGB; import com.google.common.base.Objects; -import com.google.common.collect.Maps; - import de.cau.cs.kieler.klighd.KlighdConstants; import de.cau.cs.kieler.klighd.krendering.KTextUtil; import de.cau.cs.kieler.klighd.piccolo.internal.KlighdSWTGraphicsEx; @@ -100,7 +99,7 @@ public abstract class KlighdAbstractSVGGraphics extends Graphics2D implements Kl private FontData fontData = KlighdConstants.DEFAULT_FONT; - private final Map imageBuffer = Maps.newHashMap(); + private final Map imageBuffer = new HashMap<>(); private final Rectangle2D imageBoundsRect = new Rectangle2D.Double(); // the dash constants in the following definitions are copied diff --git a/plugins/de.cau.cs.kieler.klighd.piccolo/src/de/cau/cs/kieler/klighd/piccolo/internal/KlighdSWTGraphicsImpl.java b/plugins/de.cau.cs.kieler.klighd.piccolo/src/de/cau/cs/kieler/klighd/piccolo/internal/KlighdSWTGraphicsImpl.java index fd2bad6b5..5ac262891 100644 --- a/plugins/de.cau.cs.kieler.klighd.piccolo/src/de/cau/cs/kieler/klighd/piccolo/internal/KlighdSWTGraphicsImpl.java +++ b/plugins/de.cau.cs.kieler.klighd.piccolo/src/de/cau/cs/kieler/klighd/piccolo/internal/KlighdSWTGraphicsImpl.java @@ -42,6 +42,7 @@ import java.awt.image.renderable.RenderableImage; import java.lang.ref.WeakReference; import java.text.AttributedCharacterIterator; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -65,8 +66,6 @@ import org.eclipse.swt.graphics.Transform; import org.eclipse.swt.widgets.Display; -import com.google.common.collect.Lists; - import de.cau.cs.kieler.klighd.Klighd; import de.cau.cs.kieler.klighd.KlighdConstants; import de.cau.cs.kieler.klighd.piccolo.internal.nodes.KlighdPaths; @@ -488,7 +487,7 @@ public void setFont(final FontData fontData, final int maxLineWidth) { } else { if (temporaryFonts == null) { - temporaryFonts = Lists.newArrayList(); + temporaryFonts = new ArrayList<>(); } curFont = new org.eclipse.swt.graphics.Font( fontCreationDevice != null ? fontCreationDevice : device, fontData); diff --git a/plugins/de.cau.cs.kieler.klighd.piccolo/src/de/cau/cs/kieler/klighd/piccolo/internal/controller/AbstractKGERenderingController.java b/plugins/de.cau.cs.kieler.klighd.piccolo/src/de/cau/cs/kieler/klighd/piccolo/internal/controller/AbstractKGERenderingController.java index 533b41933..03cacef94 100644 --- a/plugins/de.cau.cs.kieler.klighd.piccolo/src/de/cau/cs/kieler/klighd/piccolo/internal/controller/AbstractKGERenderingController.java +++ b/plugins/de.cau.cs.kieler.klighd.piccolo/src/de/cau/cs/kieler/klighd/piccolo/internal/controller/AbstractKGERenderingController.java @@ -24,6 +24,7 @@ import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; +import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Iterator; @@ -796,7 +797,7 @@ private boolean isSelected(final KText kText) { */ protected List determinePropagationStyles(final List renderingStyles, final List propagatedStyles, final boolean isRenderingRef) { - final List result = Lists.newLinkedList(); + final List result = new ArrayList<>(); for (final KStyle style : isRenderingRef ? propagatedStyles : concat( propagatedStyles, renderingStyles)) { @@ -1255,7 +1256,7 @@ protected void addListener(final String property, final IKlighdNode parent, @SuppressWarnings("unchecked") List listeners = (List) nodeAsPNode.getAttribute(PROPERTY_LISTENER_KEY); if (listeners == null) { - listeners = Lists.newLinkedList(); + listeners = new ArrayList<>(); nodeAsPNode.addAttribute(PROPERTY_LISTENER_KEY, listeners); } listeners.add(new Pair(property, listener)); diff --git a/plugins/de.cau.cs.kieler.klighd.piccolo/src/de/cau/cs/kieler/klighd/piccolo/internal/controller/DiagramController.java b/plugins/de.cau.cs.kieler.klighd.piccolo/src/de/cau/cs/kieler/klighd/piccolo/internal/controller/DiagramController.java index 07f121a05..e11041307 100644 --- a/plugins/de.cau.cs.kieler.klighd.piccolo/src/de/cau/cs/kieler/klighd/piccolo/internal/controller/DiagramController.java +++ b/plugins/de.cau.cs.kieler.klighd.piccolo/src/de/cau/cs/kieler/klighd/piccolo/internal/controller/DiagramController.java @@ -19,6 +19,9 @@ import java.awt.geom.Point2D; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; @@ -45,9 +48,6 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import com.google.common.collect.Iterators; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; - import de.cau.cs.kieler.klighd.Klighd; import de.cau.cs.kieler.klighd.KlighdOptions; import de.cau.cs.kieler.klighd.ViewContext; @@ -156,7 +156,7 @@ public class DiagramController { private boolean record = false; /** the layout changes to graph elements while recording. */ - private final Map recordedChanges = Maps.newLinkedHashMap(); + private final Map recordedChanges = new LinkedHashMap<>(); /** indicates whether scheduled diagram element updates must be executed via this display. */ private final Display display; @@ -835,9 +835,9 @@ void recordChange(final IKGraphElementNode node, final Object change) { recordedChanges.put(node, change); } - private final Set> dirtyDiagramElements = Sets.newHashSet(); + private final Set> dirtyDiagramElements = new HashSet<>(); private final Map, ElementMovement> dirtyDiagramElementStyles = - Maps.newHashMap(); + new HashMap<>(); void scheduleRenderingUpdate(final AbstractKGERenderingController controller) { renderingUpdater.cancel(); diff --git a/plugins/de.cau.cs.kieler.klighd.piccolo/src/de/cau/cs/kieler/klighd/piccolo/internal/controller/DiagramControllerHelper.java b/plugins/de.cau.cs.kieler.klighd.piccolo/src/de/cau/cs/kieler/klighd/piccolo/internal/controller/DiagramControllerHelper.java index c12361a29..b00040a0b 100644 --- a/plugins/de.cau.cs.kieler.klighd.piccolo/src/de/cau/cs/kieler/klighd/piccolo/internal/controller/DiagramControllerHelper.java +++ b/plugins/de.cau.cs.kieler.klighd.piccolo/src/de/cau/cs/kieler/klighd/piccolo/internal/controller/DiagramControllerHelper.java @@ -19,6 +19,7 @@ import java.awt.geom.Point2D; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; +import java.util.ArrayList; import java.util.List; import org.eclipse.emf.ecore.EObject; @@ -133,7 +134,7 @@ public void propertyChange(final PropertyChangeEvent event) { edgeNode.addAttribute(EDGE_OFFSET_LISTENER_KEY, listener); // calculate the offset and register the update offset listener - List listenedNodes = Lists.newLinkedList(); + List listenedNodes = new ArrayList<>(); Point2D offset = new Point2D.Double(0, 0); PNode currentNode = relativeChildArea; while (currentNode != null && currentNode != edgeNodeParent) { diff --git a/plugins/de.cau.cs.kieler.klighd.piccolo/src/de/cau/cs/kieler/klighd/piccolo/internal/controller/DiagramZoomControllerBoundsComputer.java b/plugins/de.cau.cs.kieler.klighd.piccolo/src/de/cau/cs/kieler/klighd/piccolo/internal/controller/DiagramZoomControllerBoundsComputer.java index 341a1b66f..95b954247 100644 --- a/plugins/de.cau.cs.kieler.klighd.piccolo/src/de/cau/cs/kieler/klighd/piccolo/internal/controller/DiagramZoomControllerBoundsComputer.java +++ b/plugins/de.cau.cs.kieler.klighd.piccolo/src/de/cau/cs/kieler/klighd/piccolo/internal/controller/DiagramZoomControllerBoundsComputer.java @@ -16,6 +16,7 @@ */ package de.cau.cs.kieler.klighd.piccolo.internal.controller; +import java.util.HashSet; import java.util.Set; import org.eclipse.elk.core.math.Spacing; @@ -23,8 +24,6 @@ import com.google.common.base.Predicate; import com.google.common.collect.Iterables; -import com.google.common.collect.Sets; - import de.cau.cs.kieler.klighd.kgraph.KEdge; import de.cau.cs.kieler.klighd.kgraph.KGraphElement; import de.cau.cs.kieler.klighd.kgraph.KInsets; @@ -293,7 +292,7 @@ public PBounds toPBoundsIncludingPortsAndLabels(final KNode node, public PBounds getContainedSubDiagramsBoundingBox(final KNode node, final Predicate isDisplayedFilter) { final PBounds nodeBounds = new PBounds(); - final Set visitedEdges = Sets.newHashSet(); + final Set visitedEdges = new HashSet<>(); for (final KNode childNode : Iterables.filter(node.getChildren(), isDisplayedFilter)) { nodeBounds.add(toPBoundsIncludingPortsAndLabels(childNode, false, null, false)); diff --git a/plugins/de.cau.cs.kieler.klighd.piccolo/src/de/cau/cs/kieler/klighd/piccolo/internal/controller/KGERenderingControllerHelper.java b/plugins/de.cau.cs.kieler.klighd.piccolo/src/de/cau/cs/kieler/klighd/piccolo/internal/controller/KGERenderingControllerHelper.java index be1c3e07d..c10612320 100644 --- a/plugins/de.cau.cs.kieler.klighd.piccolo/src/de/cau/cs/kieler/klighd/piccolo/internal/controller/KGERenderingControllerHelper.java +++ b/plugins/de.cau.cs.kieler.klighd.piccolo/src/de/cau/cs/kieler/klighd/piccolo/internal/controller/KGERenderingControllerHelper.java @@ -20,6 +20,7 @@ import java.awt.geom.Point2D; import java.awt.geom.RectangularShape; import java.net.URL; +import java.util.ArrayList; import java.util.List; import org.eclipse.core.runtime.IStatus; @@ -406,7 +407,7 @@ static PNodeController createLine( // handle children if (line.getChildren().size() > 0) { - final List restChildren = Lists.newLinkedList(); + final List restChildren = new ArrayList<>(); for (final KRendering rendering : line.getChildren()) { if (DecoratorPlacementUtil.getDecoratorPlacementData(rendering) != null) { controller.handleDecoratorPlacementRendering(rendering, propagatedStyles, path); @@ -502,7 +503,7 @@ static PNodeController createPolygon( // handle children if (polygon.getChildren().size() > 0) { - final List restChildren = Lists.newLinkedList(); + final List restChildren = new ArrayList<>(); for (final KRendering rendering : polygon.getChildren()) { if (DecoratorPlacementUtil.getDecoratorPlacementData(rendering) != null) { controller.handleDecoratorPlacementRendering(rendering, propagatedStyles, path); diff --git a/plugins/de.cau.cs.kieler.klighd.piccolo/src/de/cau/cs/kieler/klighd/piccolo/internal/events/KlighdSelectionEventHandler.java b/plugins/de.cau.cs.kieler.klighd.piccolo/src/de/cau/cs/kieler/klighd/piccolo/internal/events/KlighdSelectionEventHandler.java index ed32c28ee..c35eb25bf 100644 --- a/plugins/de.cau.cs.kieler.klighd.piccolo/src/de/cau/cs/kieler/klighd/piccolo/internal/events/KlighdSelectionEventHandler.java +++ b/plugins/de.cau.cs.kieler.klighd.piccolo/src/de/cau/cs/kieler/klighd/piccolo/internal/events/KlighdSelectionEventHandler.java @@ -22,6 +22,7 @@ import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.util.Collections; +import java.util.HashSet; import java.util.Iterator; import java.util.ListIterator; import java.util.Set; @@ -29,8 +30,6 @@ import org.eclipse.emf.ecore.EObject; import com.google.common.collect.Iterators; -import com.google.common.collect.Sets; - import de.cau.cs.kieler.klighd.IViewer; import de.cau.cs.kieler.klighd.kgraph.KEdge; import de.cau.cs.kieler.klighd.kgraph.KGraphElement; @@ -340,7 +339,7 @@ protected void performSelection(final PInputEvent event) { protected Set performEdgeSelection(final Set selectedElements, final KEdge edge) { final Set returnedElements = - selectedElements == null ? Sets.newHashSet() : selectedElements; + selectedElements == null ? new HashSet<>() : selectedElements; // add the currently found edge and its connected ones // to the set of elements to be selected, diff --git a/plugins/de.cau.cs.kieler.klighd.piccolo/src/de/cau/cs/kieler/klighd/piccolo/internal/nodes/KlighdImage.java b/plugins/de.cau.cs.kieler.klighd.piccolo/src/de/cau/cs/kieler/klighd/piccolo/internal/nodes/KlighdImage.java index 9d2fef737..7d58f1290 100644 --- a/plugins/de.cau.cs.kieler.klighd.piccolo/src/de/cau/cs/kieler/klighd/piccolo/internal/nodes/KlighdImage.java +++ b/plugins/de.cau.cs.kieler.klighd.piccolo/src/de/cau/cs/kieler/klighd/piccolo/internal/nodes/KlighdImage.java @@ -21,6 +21,7 @@ import java.io.IOException; import java.io.InputStream; import java.net.URL; +import java.util.ArrayList; import java.util.List; import org.eclipse.core.runtime.IStatus; @@ -30,8 +31,6 @@ import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.ImageData; -import com.google.common.collect.Lists; - import de.cau.cs.kieler.klighd.Klighd; import de.cau.cs.kieler.klighd.krendering.KImage; import de.cau.cs.kieler.klighd.piccolo.KlighdNode; @@ -221,7 +220,7 @@ public InputStream setImage(final InputStream input) { public void setImage(final URL url) { if (imageKey != null) { if (formerImages == null) { - formerImages = Lists.newArrayList(); + formerImages = new ArrayList<>(); } formerImages.add(imageKey); } diff --git a/plugins/de.cau.cs.kieler.klighd.piccolo/src/de/cau/cs/kieler/klighd/piccolo/internal/nodes/KlighdPath.java b/plugins/de.cau.cs.kieler.klighd.piccolo/src/de/cau/cs/kieler/klighd/piccolo/internal/nodes/KlighdPath.java index 3b38a39eb..bccfaa1e2 100644 --- a/plugins/de.cau.cs.kieler.klighd.piccolo/src/de/cau/cs/kieler/klighd/piccolo/internal/nodes/KlighdPath.java +++ b/plugins/de.cau.cs.kieler.klighd.piccolo/src/de/cau/cs/kieler/klighd/piccolo/internal/nodes/KlighdPath.java @@ -33,6 +33,7 @@ import java.awt.geom.Rectangle2D; import java.awt.geom.RoundRectangle2D; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import java.util.function.Supplier; import org.eclipse.swt.graphics.Device; @@ -41,8 +42,6 @@ import org.eclipse.swt.graphics.RGB; import com.google.common.base.Objects; -import com.google.common.collect.Maps; - import de.cau.cs.kieler.klighd.Klighd; import de.cau.cs.kieler.klighd.KlighdConstants; import de.cau.cs.kieler.klighd.krendering.KRendering; @@ -85,7 +84,7 @@ public class KlighdPath extends KlighdNode.KlighdFigureNode implemen private static final long serialVersionUID = 8034306769936734586L; - private static final Map RGB_CACHE = Maps.newConcurrentMap(); + private static final Map RGB_CACHE = new ConcurrentHashMap<>(); // in order to fix the windows specific issue with the monitor zoom related line width scaling // (KIPRA-1925) but avoid additional effort on other platforms, diff --git a/plugins/de.cau.cs.kieler.klighd.piccolo/src/de/cau/cs/kieler/klighd/piccolo/internal/util/PolylineUtil.java b/plugins/de.cau.cs.kieler.klighd.piccolo/src/de/cau/cs/kieler/klighd/piccolo/internal/util/PolylineUtil.java index 7c80d5fbd..641990047 100644 --- a/plugins/de.cau.cs.kieler.klighd.piccolo/src/de/cau/cs/kieler/klighd/piccolo/internal/util/PolylineUtil.java +++ b/plugins/de.cau.cs.kieler.klighd.piccolo/src/de/cau/cs/kieler/klighd/piccolo/internal/util/PolylineUtil.java @@ -25,7 +25,6 @@ import org.eclipse.swt.widgets.Display; import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; import de.cau.cs.kieler.klighd.piccolo.internal.nodes.KlighdPath; import de.cau.cs.kieler.klighd.piccolo.internal.nodes.KlighdPaths; @@ -221,7 +220,7 @@ public static Path2D createSplinePath(final Path2D thePath, final Point2D[] poin public static Point2D[] createSplineApproximationPath(final Path2D path) { final float[] coords = new float[2]; - final ArrayList approxPoints2 = Lists.newArrayList(); + final ArrayList approxPoints2 = new ArrayList<>(); final PathIterator pi = path.getPathIterator(null, MAX_APPROX_DISTANCE); while (!pi.isDone()) { diff --git a/plugins/de.cau.cs.kieler.klighd.piccolo/src/de/cau/cs/kieler/klighd/piccolo/internal/util/Styles.java b/plugins/de.cau.cs.kieler.klighd.piccolo/src/de/cau/cs/kieler/klighd/piccolo/internal/util/Styles.java index 857e4d731..a64394cf6 100644 --- a/plugins/de.cau.cs.kieler.klighd.piccolo/src/de/cau/cs/kieler/klighd/piccolo/internal/util/Styles.java +++ b/plugins/de.cau.cs.kieler.klighd.piccolo/src/de/cau/cs/kieler/klighd/piccolo/internal/util/Styles.java @@ -16,12 +16,12 @@ */ package de.cau.cs.kieler.klighd.piccolo.internal.util; +import java.util.ArrayList; import java.util.Collections; import java.util.List; import com.google.common.base.Predicate; import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; import de.cau.cs.kieler.klighd.KlighdConstants; import de.cau.cs.kieler.klighd.krendering.KBackground; @@ -235,7 +235,7 @@ private static List getDefaultNonTextSelectionStyles() { return defaultNonTextSelectionStyles; } - defaultNonTextSelectionStyles = Lists.newArrayList(); + defaultNonTextSelectionStyles = new ArrayList<>(); final KColor c = KlighdConstants.DEFAULT_SELECTION_HIGHLIGHTING_BACKGROUND_COLOR; final KBackground bg = KRenderingFactory.eINSTANCE.createKBackground().setColor( @@ -258,7 +258,7 @@ private static List getDefaultTextSelectionStyles() { return defaultTextSelectionStyles; } - defaultTextSelectionStyles = Lists.newArrayList(); + defaultTextSelectionStyles = new ArrayList<>(); final KColor c = KlighdConstants.DEFAULT_SELECTION_HIGHLIGHTING_BACKGROUND_COLOR; final KBackground bg = KRenderingFactory.eINSTANCE.createKBackground().setColor( diff --git a/plugins/de.cau.cs.kieler.klighd.ui.view/src/de/cau/cs/kieler/klighd/ui/view/DiagramView.java b/plugins/de.cau.cs.kieler.klighd.ui.view/src/de/cau/cs/kieler/klighd/ui/view/DiagramView.java index 3e62ef77c..fa0441f65 100644 --- a/plugins/de.cau.cs.kieler.klighd.ui.view/src/de/cau/cs/kieler/klighd/ui/view/DiagramView.java +++ b/plugins/de.cau.cs.kieler.klighd.ui.view/src/de/cau/cs/kieler/klighd/ui/view/DiagramView.java @@ -26,7 +26,6 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; - import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; @@ -69,9 +68,6 @@ import com.google.common.base.Predicate; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; - import de.cau.cs.kieler.klighd.Klighd; import de.cau.cs.kieler.klighd.KlighdDataManager; import de.cau.cs.kieler.klighd.LightDiagramLayoutConfig; @@ -148,10 +144,10 @@ public final class DiagramView extends DiagramViewPart implements ISelectionChan /** Stores used synthesis options. */ private final Map recentSynthesisOptions = - Collections.synchronizedMap(Maps.newHashMap()); + Collections.synchronizedMap(new HashMap<>()); /** Stores displayed syntheses. */ - private final Set usedSyntheses = Collections.synchronizedSet(Sets.newHashSet()); + private final Set usedSyntheses = Collections.synchronizedSet(new HashSet<>()); /** The responsible controller performing model updates. */ private AbstractViewUpdateController controller = null; @@ -220,7 +216,7 @@ public boolean apply(final DiagramView view) { * @return List of all {@link DiagramView}s */ public static List getAllDiagramViews() { - return Lists.newArrayList(views); + return new ArrayList<>(views); } // -- Constructor and Initialization diff --git a/plugins/de.cau.cs.kieler.klighd.ui.view/src/de/cau/cs/kieler/klighd/ui/view/controller/ViewUpdateControllerFactory.java b/plugins/de.cau.cs.kieler.klighd.ui.view/src/de/cau/cs/kieler/klighd/ui/view/controller/ViewUpdateControllerFactory.java index 40f4052ad..1369966fe 100644 --- a/plugins/de.cau.cs.kieler.klighd.ui.view/src/de/cau/cs/kieler/klighd/ui/view/controller/ViewUpdateControllerFactory.java +++ b/plugins/de.cau.cs.kieler.klighd.ui.view/src/de/cau/cs/kieler/klighd/ui/view/controller/ViewUpdateControllerFactory.java @@ -16,11 +16,11 @@ */ package de.cau.cs.kieler.klighd.ui.view.controller; -import java.util.Collections; import java.util.Comparator; import java.util.HashMap; -import java.util.List; import java.util.Map; +import java.util.Optional; +import java.util.Set; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IStatus; @@ -30,7 +30,6 @@ import com.google.common.base.Predicate; import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; import de.cau.cs.kieler.klighd.Klighd; import de.cau.cs.kieler.klighd.ui.view.DiagramView; @@ -358,18 +357,15 @@ public boolean apply(final Class supportedEditorClass) { */ private static String getFallbackController(final IEditorPart editor) { final Class editorClass = editor.getClass(); - List> validControllers = - Lists.newArrayList(Iterables.filter( - ViewUpdateControllerFactory.getInstance().fallbackControllerMapping.keySet(), - new Predicate>() { - public boolean apply(final Class supportedEditorClass) { - return supportedEditorClass.isAssignableFrom(editorClass); - } - })); - if (!validControllers.isEmpty()) { - Collections.sort(validControllers, TYPE_SORTER); - // Return most specific controller - return ViewUpdateControllerFactory.getInstance().fallbackControllerMapping.get(validControllers.get(0)); + Set> allClasses = + ViewUpdateControllerFactory.getInstance().fallbackControllerMapping.keySet(); + Optional> firstValidController = allClasses.stream() + .filter(supportedEditorClass -> supportedEditorClass.isAssignableFrom(editorClass)) + .min(TYPE_SORTER); + if (firstValidController.isPresent()) { + // Return most specific controller + return ViewUpdateControllerFactory.getInstance().fallbackControllerMapping + .get(firstValidController.get()); } else { return null; } diff --git a/plugins/de.cau.cs.kieler.klighd.ui.wizard/src/de/cau/cs/kieler/klighd/ui/wizard/KlighdProjectContributor.xtend b/plugins/de.cau.cs.kieler.klighd.ui.wizard/src/de/cau/cs/kieler/klighd/ui/wizard/KlighdProjectContributor.xtend index 627559a0f..3c3db23b0 100644 --- a/plugins/de.cau.cs.kieler.klighd.ui.wizard/src/de/cau/cs/kieler/klighd/ui/wizard/KlighdProjectContributor.xtend +++ b/plugins/de.cau.cs.kieler.klighd.ui.wizard/src/de/cau/cs/kieler/klighd/ui/wizard/KlighdProjectContributor.xtend @@ -456,7 +456,7 @@ class KlighdProjectContributor implements IProjectFactoryContributor { }; } - private static final Map selectionListeners = Maps.newHashMap(); + private static final Map selectionListeners = new HashMap<>(); /** diff --git a/plugins/de.cau.cs.kieler.klighd.ui.wizard/src/de/cau/cs/kieler/klighd/ui/wizard/KlighdProjectCreator.java b/plugins/de.cau.cs.kieler.klighd.ui.wizard/src/de/cau/cs/kieler/klighd/ui/wizard/KlighdProjectCreator.java index b2d003168..7937a1b37 100644 --- a/plugins/de.cau.cs.kieler.klighd.ui.wizard/src/de/cau/cs/kieler/klighd/ui/wizard/KlighdProjectCreator.java +++ b/plugins/de.cau.cs.kieler.klighd.ui.wizard/src/de/cau/cs/kieler/klighd/ui/wizard/KlighdProjectCreator.java @@ -17,6 +17,7 @@ package de.cau.cs.kieler.klighd.ui.wizard; import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -39,7 +40,6 @@ import com.google.common.base.Predicate; import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; import com.google.inject.Inject; import com.google.inject.Provider; @@ -191,7 +191,7 @@ protected ProjectFactory createAndConfigureProjectFactory() { ppf.addProjectNatures(getProjectNatures()); ppf.addBuilderIds(getBuilders()); if (info.isCreateXtendFile()) { - ppf.addFolders(Lists.newArrayList("xtend-gen")); + ppf.addFolders(List.of("xtend-gen")); } ppf.setBreeToUse(info.getExecutionEnvironment()); @@ -253,9 +253,9 @@ protected List getImportedPackages() { info.getSourceModelClassFullyQualified().substring(0, info.getSourceModelClassFullyQualified().lastIndexOf('.')); if (packageString.startsWith("java.")) { - return Lists.newArrayList(); + return new ArrayList<>(); } else { - return Lists.newArrayList(packageString); + return List.of(packageString); } } @@ -294,7 +294,7 @@ protected List getRequiredBundles() { * @return the folders being created within the project */ protected List getAllFolders() { - return Lists.newArrayList(KlighdWizardSetup.SRC_FOLDER); + return List.of(KlighdWizardSetup.SRC_FOLDER); } /** diff --git a/plugins/de.cau.cs.kieler.klighd.ui/src/de/cau/cs/kieler/klighd/ui/DiagramViewManager.java b/plugins/de.cau.cs.kieler.klighd.ui/src/de/cau/cs/kieler/klighd/ui/DiagramViewManager.java index d68fec7d4..ddafb730f 100644 --- a/plugins/de.cau.cs.kieler.klighd.ui/src/de/cau/cs/kieler/klighd/ui/DiagramViewManager.java +++ b/plugins/de.cau.cs.kieler.klighd.ui/src/de/cau/cs/kieler/klighd/ui/DiagramViewManager.java @@ -16,6 +16,7 @@ */ package de.cau.cs.kieler.klighd.ui; +import java.util.HashMap; import java.util.Map; import org.eclipse.core.runtime.IStatus; @@ -30,8 +31,6 @@ import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; -import com.google.common.collect.Maps; - import de.cau.cs.kieler.klighd.IDiagramWorkbenchPart; import de.cau.cs.kieler.klighd.Klighd; import de.cau.cs.kieler.klighd.LightDiagramLayoutConfig; @@ -58,10 +57,10 @@ public final class DiagramViewManager implements IPartListener { private boolean registered = false; /** the mapping of diagram view identifiers on workbench parts. */ - private Map idPartMapping = Maps.newHashMap(); + private Map idPartMapping = new HashMap<>(); /** the mapping of diagram view identifiers on view contexts. */ - private Map idContextMapping = Maps.newHashMap(); + private Map idContextMapping = new HashMap<>(); /** * Returns the singleton instance. diff --git a/plugins/de.cau.cs.kieler.klighd.ui/src/de/cau/cs/kieler/klighd/ui/internal/handlers/ExportKGraphHelper.java b/plugins/de.cau.cs.kieler.klighd.ui/src/de/cau/cs/kieler/klighd/ui/internal/handlers/ExportKGraphHelper.java index 400ad1963..40f598fe0 100644 --- a/plugins/de.cau.cs.kieler.klighd.ui/src/de/cau/cs/kieler/klighd/ui/internal/handlers/ExportKGraphHelper.java +++ b/plugins/de.cau.cs.kieler.klighd.ui/src/de/cau/cs/kieler/klighd/ui/internal/handlers/ExportKGraphHelper.java @@ -17,6 +17,8 @@ package de.cau.cs.kieler.klighd.ui.internal.handlers; import java.io.IOException; +import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; import java.util.Map; import java.util.Map.Entry; @@ -38,9 +40,6 @@ import org.eclipse.emf.ecore.util.EcoreUtil.Copier; import com.google.common.collect.Iterators; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; - import de.cau.cs.kieler.klighd.Klighd; import de.cau.cs.kieler.klighd.internal.util.KlighdInternalProperties; import de.cau.cs.kieler.klighd.kgraph.KEdge; @@ -147,7 +146,7 @@ public static void export(final KNode graph, final URI fileOutputURI, final bool try { // We need to sanitize the graph a bit - Set populatedNodes = Sets.newHashSet(); + Set populatedNodes = new HashSet<>(); // Remove transient KlighD state // Care: do not iterate over the elements of the 'copy' as the subgraph // was already removed from its original containment @@ -287,7 +286,7 @@ public static void export(final KNode graph, final URI fileOutputURI, final bool // remove any edges that do not have a target anymore recursivelyRemoveInvalidEdges((KNode) copier.get(graph)); - Map saveOpts = Maps.newHashMap(); + Map saveOpts = new HashMap<>(); // we have to drop several elements if only a subgraph // is exported ... just let the emf deal with it. // FIXME use constants @@ -331,9 +330,9 @@ private static void removeNonLayoutProperties(final KGraphElement kge) { private static boolean isLayoutProperty(final IProperty prop) { Set> goodProperties = - Sets.newHashSet(KlighdProperties.EXPAND, KlighdProperties.MINIMAL_NODE_SIZE); + Set.of(KlighdProperties.EXPAND, KlighdProperties.MINIMAL_NODE_SIZE); Set> badProperties = - Sets.newHashSet(CoreOptions.LABEL_MANAGER, LabelManagementOptions.LABEL_MANAGER); + Set.of(CoreOptions.LABEL_MANAGER, LabelManagementOptions.LABEL_MANAGER); return (prop.getId().startsWith("org.eclipse.elk") && !badProperties.contains(prop)) || goodProperties.contains(prop); } diff --git a/plugins/de.cau.cs.kieler.klighd.ui/src/de/cau/cs/kieler/klighd/ui/internal/handlers/SaveKGraphHandler.java b/plugins/de.cau.cs.kieler.klighd.ui/src/de/cau/cs/kieler/klighd/ui/internal/handlers/SaveKGraphHandler.java index ae6922f9c..97bb233f4 100644 --- a/plugins/de.cau.cs.kieler.klighd.ui/src/de/cau/cs/kieler/klighd/ui/internal/handlers/SaveKGraphHandler.java +++ b/plugins/de.cau.cs.kieler.klighd.ui/src/de/cau/cs/kieler/klighd/ui/internal/handlers/SaveKGraphHandler.java @@ -17,6 +17,7 @@ package de.cau.cs.kieler.klighd.ui.internal.handlers; import java.io.File; +import java.util.ArrayDeque; import java.util.Arrays; import java.util.Queue; @@ -37,8 +38,6 @@ import org.eclipse.ui.dialogs.ContainerSelectionDialog; import org.eclipse.ui.handlers.HandlerUtil; -import com.google.common.collect.Lists; - import de.cau.cs.kieler.klighd.IDiagramWorkbenchPart; import de.cau.cs.kieler.klighd.IViewer; import de.cau.cs.kieler.klighd.Klighd; @@ -214,8 +213,8 @@ private void exportRecursivelyChunky(final KNode subgraph, final String destinat final ViewContext viewContext) { // collect all subgraph s - final Queue flatNodes = Lists.newLinkedList(); - final Queue expandedNodes = Lists.newLinkedList(); + final Queue flatNodes = new ArrayDeque<>(); + final Queue expandedNodes = new ArrayDeque<>(); String path = destination + File.separator; flatNodes.add(subgraph); @@ -261,7 +260,7 @@ private void exportRecursivelyChunky(final KNode subgraph, final String destinat viewContext.getViewer().collapse(node); } } - final Queue increaseHierarchy = Lists.newLinkedList(); + final Queue increaseHierarchy = new ArrayDeque<>(); increaseHierarchy.add(subgraph); new LightDiagramLayoutConfig(viewContext).animate(false).performLayout(); int i = 0; diff --git a/plugins/de.cau.cs.kieler.klighd.ui/src/de/cau/cs/kieler/klighd/ui/internal/options/ActionControlFactory.java b/plugins/de.cau.cs.kieler.klighd.ui/src/de/cau/cs/kieler/klighd/ui/internal/options/ActionControlFactory.java index e512e140f..90ac857fb 100644 --- a/plugins/de.cau.cs.kieler.klighd.ui/src/de/cau/cs/kieler/klighd/ui/internal/options/ActionControlFactory.java +++ b/plugins/de.cau.cs.kieler.klighd.ui/src/de/cau/cs/kieler/klighd/ui/internal/options/ActionControlFactory.java @@ -17,6 +17,7 @@ package de.cau.cs.kieler.klighd.ui.internal.options; import java.util.Collection; +import java.util.HashMap; import java.util.LinkedList; import java.util.Map; @@ -32,8 +33,6 @@ import org.eclipse.swt.widgets.Control; import org.eclipse.ui.forms.widgets.FormToolkit; -import com.google.common.collect.Maps; - import de.cau.cs.kieler.klighd.DisplayedActionData; import de.cau.cs.kieler.klighd.IAction; import de.cau.cs.kieler.klighd.IAction.ActionContext; @@ -95,7 +94,7 @@ public void clear() { actionDataControlMap.clear(); } - private Map actionDataControlMap = Maps.newHashMap(); + private Map actionDataControlMap = new HashMap<>(); /** * Factory method for creating a check button related to a 'check' option. diff --git a/plugins/de.cau.cs.kieler.klighd.ui/src/de/cau/cs/kieler/klighd/ui/internal/options/SynthesisOptionControlFactory.java b/plugins/de.cau.cs.kieler.klighd.ui/src/de/cau/cs/kieler/klighd/ui/internal/options/SynthesisOptionControlFactory.java index 30c5fff6e..dbb8229bc 100644 --- a/plugins/de.cau.cs.kieler.klighd.ui/src/de/cau/cs/kieler/klighd/ui/internal/options/SynthesisOptionControlFactory.java +++ b/plugins/de.cau.cs.kieler.klighd.ui/src/de/cau/cs/kieler/klighd/ui/internal/options/SynthesisOptionControlFactory.java @@ -16,8 +16,10 @@ */ package de.cau.cs.kieler.klighd.ui.internal.options; +import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -49,9 +51,6 @@ import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.Section; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; - import de.cau.cs.kieler.klighd.IAction; import de.cau.cs.kieler.klighd.IAction.ActionContext; import de.cau.cs.kieler.klighd.IAction.ActionResult; @@ -78,18 +77,18 @@ public class SynthesisOptionControlFactory { /** the form toolkit used to create controls. */ private FormToolkit formToolkit; /** The set of controls to be disposed when {@link #clear()} is called. */ - private final Collection controls = Lists.newArrayList(); + private final Collection controls = new ArrayList<>(); /** This flag is true if this factory is factory for options of a subordinate synthesis. */ private boolean isSubFactory = false; /** The title text of the parent form. */ private final String parentTitle; /** The list of {SynthesisOptionControlFactory} for synthesis specific sections. */ - private final List subFactories = Lists.newArrayList(); + private final List subFactories = new ArrayList<>(); /** If set, the category this factory is responsible for. */ private SynthesisOption factoryCategory = null; /** The list of {SynthesisOptionControlFactory} for categories directly nested. */ private final Map subCategoryFactories = - Maps.newHashMap(); + new HashMap<>(); /** Preference prefix for sub-factory. */ private static final String SUB_FACTORY_PREFIX = "sidebar.synthesis.expansion."; diff --git a/plugins/de.cau.cs.kieler.klighd.ui/src/de/cau/cs/kieler/klighd/ui/internal/preferences/KlighdPlatformPreferenceStore.java b/plugins/de.cau.cs.kieler.klighd.ui/src/de/cau/cs/kieler/klighd/ui/internal/preferences/KlighdPlatformPreferenceStore.java index 7bbc2445b..9c5085484 100644 --- a/plugins/de.cau.cs.kieler.klighd.ui/src/de/cau/cs/kieler/klighd/ui/internal/preferences/KlighdPlatformPreferenceStore.java +++ b/plugins/de.cau.cs.kieler.klighd.ui/src/de/cau/cs/kieler/klighd/ui/internal/preferences/KlighdPlatformPreferenceStore.java @@ -13,6 +13,7 @@ */ package de.cau.cs.kieler.klighd.ui.internal.preferences; +import java.util.HashMap; import java.util.Map; import org.eclipse.core.runtime.preferences.IEclipsePreferences; @@ -22,8 +23,6 @@ import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.ui.preferences.ScopedPreferenceStore; -import com.google.common.collect.Maps; - import de.cau.cs.kieler.klighd.IKlighdPreferenceStore; import de.cau.cs.kieler.klighd.Klighd; @@ -250,7 +249,7 @@ public void setDefault(String name, String defaultObject) { delegate.setDefault(name, defaultObject); } - private final Map listeners = Maps.newHashMap(); + private final Map listeners = new HashMap<>(); /** * {@inheritDoc} diff --git a/plugins/de.cau.cs.kieler.klighd.ui/src/de/cau/cs/kieler/klighd/ui/modifymodel/ModelModificationHandlerProvider.java b/plugins/de.cau.cs.kieler.klighd.ui/src/de/cau/cs/kieler/klighd/ui/modifymodel/ModelModificationHandlerProvider.java index 6c117ccf7..0de7c3411 100644 --- a/plugins/de.cau.cs.kieler.klighd.ui/src/de/cau/cs/kieler/klighd/ui/modifymodel/ModelModificationHandlerProvider.java +++ b/plugins/de.cau.cs.kieler.klighd.ui/src/de/cau/cs/kieler/klighd/ui/modifymodel/ModelModificationHandlerProvider.java @@ -16,6 +16,7 @@ */ package de.cau.cs.kieler.klighd.ui.modifymodel; +import java.util.ArrayList; import java.util.List; import org.eclipse.core.runtime.CoreException; @@ -23,8 +24,6 @@ import org.eclipse.core.runtime.RegistryFactory; import org.eclipse.ui.IWorkbenchPart; -import com.google.common.collect.Lists; - import de.cau.cs.kieler.klighd.IModelModificationHandler; /** @@ -79,7 +78,7 @@ public IModelModificationHandler getFittingHandler(final IWorkbenchPart part) { * Parse the extension point and generate handler instances. */ private void readHandlerExtensionPoint() { - handlers = Lists.newLinkedList(); + handlers = new ArrayList<>(); // read extension point IConfigurationElement[] elements = RegistryFactory.getRegistry().getConfigurationElementsFor( diff --git a/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/IViewChangeListener.java b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/IViewChangeListener.java index 99948d893..c45a5259f 100644 --- a/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/IViewChangeListener.java +++ b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/IViewChangeListener.java @@ -17,14 +17,13 @@ package de.cau.cs.kieler.klighd; import java.awt.geom.Rectangle2D; +import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; - import de.cau.cs.kieler.klighd.kgraph.KGraphElement; import de.cau.cs.kieler.klighd.kgraph.KNode; @@ -251,7 +250,7 @@ public ViewChange suppressSubsequentNotifications(final Iterable */ public ViewChange suppressSubsequentNotifications(final int durationInMS, final ViewChangeType... changeTypes) { - return suppressSubsequentNotifications(durationInMS, Lists.newArrayList(changeTypes)); + return suppressSubsequentNotifications(durationInMS, Arrays.asList(changeTypes)); } /** @@ -274,7 +273,7 @@ public ViewChange suppressSubsequentNotifications(final int durationInMS, final Iterable changeTypes) { if (notificationSuppressions == null) { - notificationSuppressions = Maps.newHashMap(); + notificationSuppressions = new HashMap<>(); } for (final ViewChangeType type : changeTypes) { diff --git a/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/KlighdDataManager.java b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/KlighdDataManager.java index 5e7e5f8dd..3f2de9f39 100644 --- a/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/KlighdDataManager.java +++ b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/KlighdDataManager.java @@ -18,10 +18,13 @@ import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Comparator; +import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -50,7 +53,6 @@ import com.google.common.collect.ImmutableList.Builder; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; -import com.google.common.collect.Maps; import com.google.common.collect.Multimap; import de.cau.cs.kieler.klighd.internal.ISynthesis; @@ -193,7 +195,7 @@ public static KlighdDataManager getInstance() { } /** the mapping of ids to the corresponding instances of {@link ISynthesis}. */ - private final Map idSynthesisMapping = Maps.newLinkedHashMap(); + private final Map idSynthesisMapping = new LinkedHashMap<>(); /** the mapping of types to the corresponding instances of {@link ISynthesis}. */ private final Multimap, ISynthesis> typeSynthesisMapping = ArrayListMultimap.create(); @@ -201,48 +203,48 @@ public static KlighdDataManager getInstance() { /** * A caching map that avoids the effort of determining the correct syntheses for a given type * each time. */ - private final Map, Iterable> concreteTypeSynthesisMapping = Maps.newHashMap(); + private final Map, Iterable> concreteTypeSynthesisMapping = new HashMap<>(); /** the mapping of ids on the associated viewer providers. */ - private Map idViewerProviderMapping = Maps.newHashMap(); + private Map idViewerProviderMapping = new HashMap<>(); /** the mapping of ids on the associated update strategies. */ - private Map idUpdateStrategyMapping = Maps.newHashMap(); + private Map idUpdateStrategyMapping = new HashMap<>(); /** the mapping of priorities on the associated update strategies, sorted by priority. */ - private TreeMap priorityUpdateStrategyMapping = Maps.newTreeMap(); + private TreeMap priorityUpdateStrategyMapping = new TreeMap<>(); private IUpdateStrategy highestPriorityUpdateStrategy = null; /** the mapping of ids to the associated style modifiers. */ - private final Map idStyleModifierMapping = Maps.newHashMap(); + private final Map idStyleModifierMapping = new HashMap<>(); /** the mapping of ids to the associated actions. */ private final BiMap idActionMapping = HashBiMap.create(); /** the mapping of ids to the associated configuration elements describing the exporters. */ - private final Map exportersMap = Maps.newHashMap(); + private final Map exportersMap = new HashMap<>(); /** the list of the available exporters' descriptors. */ - private final List descriptors = Lists.newArrayList(); + private final List descriptors = new ArrayList<>(); /** the mapping of ids to the associated export branding descriptors. */ - private final Map idExportBrandingMapping = Maps.newHashMap(); + private final Map idExportBrandingMapping = new HashMap<>(); /** the mapping of ids to the associated off-screen renderer descriptors. */ - private final Map idOffscreenRendererMapping = Maps.newHashMap(); + private final Map idOffscreenRendererMapping = new HashMap<>(); /** the mapping of custom figure types to wrapper figure type being supported by KLighD. */ - private final List customFigureWrapperMapping = Lists.newArrayList(); + private final List customFigureWrapperMapping = new ArrayList<>(); /** the properties that shall be preserved from the layout graph to the kgraph */ - private final List> preservedProperties = Lists.newArrayList(); + private final List> preservedProperties = new ArrayList<>(); /** the properties that are not allowed to be preserved when sending the skgraph to the client */ - private final List> blacklistedProperties = Lists.newArrayList(); + private final List> blacklistedProperties = new ArrayList<>(); /** the properties that are outside the klighd/elk namespace that are explicitly allowed to be sent to the client */ - private final List> whitelistedProperties = Lists.newArrayList(); + private final List> whitelistedProperties = new ArrayList<>(); /** * A private constructor to prevent instantiation. @@ -1117,7 +1119,7 @@ public Set getActionIds() { * @return return a copy of the original list */ public List getAvailableExporters() { - return Lists.newLinkedList(descriptors); + return new ArrayList<>(descriptors); } /** @@ -1162,7 +1164,7 @@ public Iterable getExportBrandingByFormat(final String format, descr -> descr.supportedFormats.contains(format) ); - final List result = Lists.newArrayList(); + final List result = new ArrayList<>(); for (final ExportBrandingDescriptor descr : descriptors) { final IExportBranding branding = descr.supplier.get(); diff --git a/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/LightDiagramServices.java b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/LightDiagramServices.java index 18fd28191..cab05b525 100644 --- a/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/LightDiagramServices.java +++ b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/LightDiagramServices.java @@ -40,8 +40,6 @@ import com.google.common.base.Predicates; import com.google.common.collect.Collections2; import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; - import de.cau.cs.kieler.klighd.KlighdDataManager.OffscreenRendererDescriptor; import de.cau.cs.kieler.klighd.internal.ILayoutConfigProvider; import de.cau.cs.kieler.klighd.internal.ILayoutRecorder; @@ -58,7 +56,7 @@ public final class LightDiagramServices { private static final List> GLOBALOPTIONS = - Lists.newArrayList(CoreOptions.ANIMATE, CoreOptions.ANIM_TIME_FACTOR, + List.of(CoreOptions.ANIMATE, CoreOptions.ANIM_TIME_FACTOR, CoreOptions.MIN_ANIM_TIME, CoreOptions.MAX_ANIM_TIME); /** diff --git a/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/ViewContext.java b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/ViewContext.java index cbce20a6d..68ed9f8e9 100644 --- a/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/ViewContext.java +++ b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/ViewContext.java @@ -16,8 +16,10 @@ */ package de.cau.cs.kieler.klighd; +import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -36,9 +38,6 @@ import com.google.common.base.Function; import com.google.common.base.Predicate; import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; - import de.cau.cs.kieler.klighd.internal.ILayoutRecorder; import de.cau.cs.kieler.klighd.internal.ISynthesis; import de.cau.cs.kieler.klighd.internal.util.KlighdInternalProperties; @@ -746,10 +745,10 @@ public T getTargetElement(final Object element, final Class< // ---------------------------------------------------------------------------------- // // Synthesis option handling - private List synthesisOptions = Lists.newLinkedList(); + private List synthesisOptions = new ArrayList<>(); /** Memory of the configured transformation options to be evaluated by the transformation. */ - private Map synthesisOptionConfig = Maps.newHashMap(); + private Map synthesisOptionConfig = new HashMap<>(); /** @@ -874,7 +873,7 @@ public List getAdditionalLayoutConfigs() { // ---------------------------------------------------------------------------------- // // Child ViewContext handling - private final List childViewContexts = Lists.newLinkedList(); + private final List childViewContexts = new ArrayList<>(); /** * Returns the list of registered child {@link ViewContext}.
@@ -889,7 +888,7 @@ public List getAdditionalLayoutConfigs() { */ public List getChildViewContexts(final boolean recursive) { if (recursive) { - List recursiveVCs = Lists.newLinkedList(); + List recursiveVCs = new ArrayList<>(); for (ViewContext vc : childViewContexts) { recursiveVCs.add(vc); recursiveVCs.addAll(vc.getChildViewContexts(true)); diff --git a/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/actions/FocusAndContextAction.java b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/actions/FocusAndContextAction.java index 691df7732..e30de92fb 100644 --- a/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/actions/FocusAndContextAction.java +++ b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/actions/FocusAndContextAction.java @@ -16,12 +16,11 @@ */ package de.cau.cs.kieler.klighd.actions; +import java.util.ArrayList; import java.util.List; import org.eclipse.elk.core.options.CoreOptions; -import com.google.common.collect.Lists; - import de.cau.cs.kieler.klighd.IAction; import de.cau.cs.kieler.klighd.KlighdOptions; import de.cau.cs.kieler.klighd.kgraph.KEdge; @@ -128,7 +127,7 @@ protected List determineFocussedElements(final KGraphElement elem if (element instanceof KNode) { KNode node = (KNode) element; - List result = Lists.newArrayList(); + List result = new ArrayList<>(); // Include all ports result.addAll(node.getPorts()); diff --git a/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/internal/macrolayout/KlighdDiagramLayoutConnector.java b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/internal/macrolayout/KlighdDiagramLayoutConnector.java index eae0affb3..bc00f53bb 100644 --- a/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/internal/macrolayout/KlighdDiagramLayoutConnector.java +++ b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/internal/macrolayout/KlighdDiagramLayoutConnector.java @@ -16,6 +16,7 @@ */ package de.cau.cs.kieler.klighd.internal.macrolayout; +import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import java.util.ListIterator; @@ -54,7 +55,6 @@ import com.google.common.collect.BiMap; import com.google.common.collect.Iterables; import com.google.common.collect.Iterators; -import com.google.common.collect.Lists; import de.cau.cs.kieler.klighd.IDiagramWorkbenchPart; import de.cau.cs.kieler.klighd.IViewer; @@ -682,7 +682,7 @@ private void applyLayout(final LayoutMapping mapping, final boolean suppressEdge // We need to process labels after the edges because during edge handling // the insets are handled and the source data adjusted accordingly. // We store the labels here to have them ready after the main switch. - List graphLabels = Lists.newArrayList(); + List graphLabels = new ArrayList<>(); // apply the layout of all mapped layout elements back to the associated element for (final Entry elementMapping : elementMappings) { diff --git a/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/internal/preferences/KlighdPlainPreferenceStore.java b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/internal/preferences/KlighdPlainPreferenceStore.java index 4b5a667ee..be9df549e 100644 --- a/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/internal/preferences/KlighdPlainPreferenceStore.java +++ b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/internal/preferences/KlighdPlainPreferenceStore.java @@ -17,15 +17,13 @@ import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener; -import com.google.common.collect.Maps; - import de.cau.cs.kieler.klighd.IKlighdPreferenceStore; public class KlighdPlainPreferenceStore implements IKlighdPreferenceStore { - private final HashMap values = Maps.newHashMap(); + private final HashMap values = new HashMap<>(); - private final HashMap defaults = Maps.newHashMap(); + private final HashMap defaults = new HashMap<>(); public KlighdPlainPreferenceStore() { new PreferenceInitializer().initializeDefaultPreferences(this); diff --git a/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/internal/util/SourceModelTrackingAdapter.java b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/internal/util/SourceModelTrackingAdapter.java index b3117f26d..8385dc79a 100644 --- a/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/internal/util/SourceModelTrackingAdapter.java +++ b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/internal/util/SourceModelTrackingAdapter.java @@ -18,6 +18,7 @@ import java.util.Collection; import java.util.Collections; +import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -32,7 +33,6 @@ import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.Iterables; import com.google.common.collect.Iterators; -import com.google.common.collect.Maps; import com.google.common.collect.Multimap; import de.cau.cs.kieler.klighd.kgraph.EMapPropertyHolder; @@ -57,7 +57,7 @@ public class SourceModelTrackingAdapter extends EContentAdapter { private Object mapsMonitor = this; private Multimap sourceTargetsMap = ArrayListMultimap.create(); - private Map targetSourceMap = Maps.newHashMap(); + private Map targetSourceMap = new HashMap<>(); /** diff --git a/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/krendering/KCustomRenderingWrapperFactory.java b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/krendering/KCustomRenderingWrapperFactory.java index bf97ed5ce..5fc1ff3a5 100644 --- a/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/krendering/KCustomRenderingWrapperFactory.java +++ b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/krendering/KCustomRenderingWrapperFactory.java @@ -18,6 +18,7 @@ import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; +import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; @@ -56,7 +57,7 @@ public final class KCustomRenderingWrapperFactory { * The wrapper look-up dictionary: * The keys are the wrapped types, the values are the concrete wrapping implementations. */ - private final Map, Class> typeWrapperMap = Maps.newHashMap(); + private final Map, Class> typeWrapperMap = new HashMap<>(); /** * Provides the single instance of the class. diff --git a/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/krendering/SimpleUpdateStrategy.java b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/krendering/SimpleUpdateStrategy.java index 72e604833..8088cb1aa 100644 --- a/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/krendering/SimpleUpdateStrategy.java +++ b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/krendering/SimpleUpdateStrategy.java @@ -16,6 +16,7 @@ */ package de.cau.cs.kieler.klighd.krendering; +import java.util.ArrayList; import java.util.List; import com.google.common.collect.Iterables; @@ -63,8 +64,8 @@ public boolean requiresDiagramSynthesisReRun(final ViewContext viewContext) { */ public void update(final KNode baseModel, final KNode newModel, final ViewContext viewContext) { - final List newChildren = Lists.newArrayList(newModel.getChildren()); - final List newData = Lists.newArrayList(newModel.getData()); + final List newChildren = new ArrayList<>(newModel.getChildren()); + final List newData = new ArrayList<>(newModel.getData()); newModel.getChildren().clear(); newModel.getData().clear(); diff --git a/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/labels/decoration/LabelDecorationConfigurator.java b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/labels/decoration/LabelDecorationConfigurator.java index 0a48c533a..797edca67 100644 --- a/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/labels/decoration/LabelDecorationConfigurator.java +++ b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/labels/decoration/LabelDecorationConfigurator.java @@ -16,6 +16,7 @@ */ package de.cau.cs.kieler.klighd.labels.decoration; +import java.util.ArrayList; import java.util.List; import java.util.ListIterator; import java.util.Objects; @@ -25,8 +26,6 @@ import org.eclipse.elk.core.options.CoreOptions; import org.eclipse.elk.core.options.EdgeLabelPlacement; -import com.google.common.collect.Lists; - import de.cau.cs.kieler.klighd.kgraph.KEdge; import de.cau.cs.kieler.klighd.kgraph.KGraphData; import de.cau.cs.kieler.klighd.kgraph.KLabel; @@ -118,7 +117,7 @@ public final class LabelDecorationConfigurator { /** The layout mode to use. */ private LayoutMode layoutMode = LayoutMode.BOTH; /** Rendering providers that contribute decorations. */ - private List decoratorRenderingProviders = Lists.newArrayList(); + private List decoratorRenderingProviders = new ArrayList<>(); /** Default decoration if there's nothing else available. */ private IDecoratorRenderingProvider defaultDecorator = RectangleDecorator.create(); /** Rendering provider for the actual label text. */ diff --git a/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/labels/management/ListLabelManager.java b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/labels/management/ListLabelManager.java index 0c86fbd72..a243ba59b 100644 --- a/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/labels/management/ListLabelManager.java +++ b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/labels/management/ListLabelManager.java @@ -16,13 +16,12 @@ */ package de.cau.cs.kieler.klighd.labels.management; +import java.util.ArrayList; import java.util.List; import java.util.Objects; import org.eclipse.elk.graph.ElkLabel; -import com.google.common.collect.Lists; - /** * Takes a list of label managers that do the work of resizing labels. The label managers are asked * to manage a given label in the order they appear in in the list. If a label manager actually does @@ -40,7 +39,7 @@ public class ListLabelManager extends AbstractKlighdLabelManager { /** The label managers used to manage the labels in the graph. */ - private final List labelManagers = Lists.newArrayList(); + private final List labelManagers = new ArrayList<>(); /** Whether only the first label manager that actually changes the label's text is executed. */ private boolean stopOnFirstHit = true; diff --git a/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/microlayout/GridPlacementUtil.java b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/microlayout/GridPlacementUtil.java index de9b593ab..8269eb6a6 100644 --- a/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/microlayout/GridPlacementUtil.java +++ b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/microlayout/GridPlacementUtil.java @@ -21,8 +21,9 @@ import static de.cau.cs.kieler.klighd.krendering.KRenderingUtil.getPlacementData; import static de.cau.cs.kieler.klighd.microlayout.PlacementUtil.basicEstimateSize; +import java.util.ArrayDeque; import java.util.Arrays; -import java.util.LinkedList; +import java.util.Deque; import java.util.List; import org.eclipse.elk.core.math.ElkMath; @@ -30,8 +31,6 @@ import org.eclipse.elk.graph.properties.IProperty; import org.eclipse.elk.graph.properties.Property; -import com.google.common.collect.Lists; - import de.cau.cs.kieler.klighd.krendering.KContainerRendering; import de.cau.cs.kieler.klighd.krendering.KGridPlacement; import de.cau.cs.kieler.klighd.krendering.KGridPlacementData; @@ -478,7 +477,7 @@ public static Bounds estimateGridSize(final KContainerRendering container, final int row = k / numColumns; final int col = k - row * numColumns; - final LinkedList path = Lists.newLinkedList(); + final Deque path = new ArrayDeque<>(); if (PlacementUtil.findChildArea(currentChild, path)) { // if a childArea is contained in the current child (or the child itself is a childarea) // remember the position of the area to be able to calculate diff --git a/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/microlayout/PlacementUtil.java b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/microlayout/PlacementUtil.java index 43d400f9f..20c9aca07 100644 --- a/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/microlayout/PlacementUtil.java +++ b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/microlayout/PlacementUtil.java @@ -29,8 +29,11 @@ import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; +import java.util.ArrayDeque; +import java.util.ArrayList; +import java.util.Deque; +import java.util.HashMap; import java.util.Iterator; -import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -48,8 +51,6 @@ import com.google.common.base.Strings; import com.google.common.collect.Iterables; import com.google.common.collect.Iterators; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; import de.cau.cs.kieler.klighd.Klighd; import de.cau.cs.kieler.klighd.KlighdConstants; @@ -843,7 +844,7 @@ private static FontData fontDataFor(final KText kText, final KGraphElement graph if (kText != null) { // the following lines look for font styles propagated from parents // TODO also make allowance of styles propagated via KRenderingRefs - final List styles = Lists.newLinkedList(kText.getStyles()); + final List styles = new ArrayList<>(kText.getStyles()); for (final KRendering k : Iterables2.toIterable(Iterators.filter( ModelingUtil.eAllContainers(kText), KRendering.class))) { Iterables.addAll(styles, Iterables.filter(k.getStyles(), FILTER)); @@ -1017,7 +1018,7 @@ public static Bounds getTestingTextSize(final KText kText) { * A font cache preserving requested font configurations in order to avoid re-instantiation of * {@link Font}, which is assumed to be much more expensive than {@link FontData}. */ - private static final Map FONT_CACHE = Maps.newHashMap(); + private static final Map FONT_CACHE = new HashMap<>(); /** * Two instances of {@link GC} that the text size estimation is delegated to. @@ -1520,7 +1521,7 @@ public static void calculateInsets(final KRendering rootRendering, final KInsets } // find the path to the child area - final LinkedList path = Lists.newLinkedList(); + final Deque path = new ArrayDeque<>(); if (!findChildArea(rootRendering, path)) { // no child area so the whole node is the child area @@ -1683,8 +1684,7 @@ private static Bounds evaluatePolylineBounds(final KPolyline line, final Bounds * the list of renderings which will contain the path of renderings to the child area * @return true if a child area has been found; false else */ - public static boolean findChildArea(final KRendering rendering, - final LinkedList path) { + public static boolean findChildArea(final KRendering rendering, final Deque path) { path.addLast(rendering); if (rendering instanceof KChildArea) { return true; diff --git a/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/syntheses/ReinitializingDiagramSynthesisProxy.java b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/syntheses/ReinitializingDiagramSynthesisProxy.java index 2d0f293ec..9559966d9 100644 --- a/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/syntheses/ReinitializingDiagramSynthesisProxy.java +++ b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/syntheses/ReinitializingDiagramSynthesisProxy.java @@ -16,6 +16,7 @@ */ package de.cau.cs.kieler.klighd.syntheses; +import java.util.HashSet; import java.util.List; import java.util.Set; @@ -28,7 +29,6 @@ import com.google.common.base.Function; import com.google.common.collect.Iterables; -import com.google.common.collect.Sets; import com.google.inject.Binder; import com.google.inject.Guice; import com.google.inject.Key; @@ -143,7 +143,7 @@ private class ViewSynthesisScope implements Scope { } private Class> mainTransformationClazz = null; - private Set instances = Sets.newHashSet(); + private Set instances = new HashSet<>(); private void clear() { this.instances.clear(); diff --git a/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/util/Iterables2.java b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/util/Iterables2.java index c9c526398..1510cdd16 100644 --- a/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/util/Iterables2.java +++ b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/util/Iterables2.java @@ -16,6 +16,7 @@ */ package de.cau.cs.kieler.klighd.util; +import java.util.ArrayDeque; import java.util.Iterator; import java.util.List; import java.util.Queue; @@ -26,7 +27,6 @@ import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterators; -import com.google.common.collect.Lists; /** * This class provides some convenience methods that I miss in @@ -212,7 +212,7 @@ private boolean initialize() { srcIterator = src.iterator(); } - queue = Lists.newLinkedList(); + queue = new ArrayDeque<>(); int i = count; while ((i--) != 0) { diff --git a/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/util/KlighdSemanticDiagramData.java b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/util/KlighdSemanticDiagramData.java index 8b74007a0..e37936ee9 100644 --- a/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/util/KlighdSemanticDiagramData.java +++ b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/util/KlighdSemanticDiagramData.java @@ -18,6 +18,7 @@ import java.util.Collections; import java.util.Iterator; +import java.util.LinkedHashMap; import java.util.Map; import org.eclipse.emf.ecore.EObject; @@ -208,7 +209,7 @@ public KlighdSemanticDiagramData put(final String key, final String value) { } if (strStr == null && value != null) { - strStr = Maps.newLinkedHashMap(); + strStr = new LinkedHashMap<>(); } if (strFun != null && strFun.containsKey(key)) { @@ -259,7 +260,7 @@ public KlighdSemanticDiagramData put(final String key, final Function(); } if (strStr != null && strStr.containsKey(key)) { @@ -319,7 +320,7 @@ public KlighdSemanticDiagramData putAtTextLine( } if (strFunTextLine == null && fun != null) { - strFunTextLine = Maps.newLinkedHashMap(); + strFunTextLine = new LinkedHashMap<>(); } if (strFunTextLine != null) { diff --git a/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/util/KlighdSynthesisProperties.java b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/util/KlighdSynthesisProperties.java index 015037e21..ff86391e7 100644 --- a/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/util/KlighdSynthesisProperties.java +++ b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/util/KlighdSynthesisProperties.java @@ -16,6 +16,7 @@ */ package de.cau.cs.kieler.klighd.util; +import java.util.HashMap; import java.util.Map; import org.eclipse.elk.graph.properties.IProperty; @@ -23,8 +24,6 @@ import org.eclipse.elk.graph.properties.MapPropertyHolder; import org.eclipse.elk.graph.properties.Property; -import com.google.common.collect.Maps; - import de.cau.cs.kieler.klighd.SynthesisOption; import de.cau.cs.kieler.klighd.krendering.SimpleUpdateStrategy; @@ -359,7 +358,7 @@ public KlighdSynthesisProperties configureSynthesisOptionValue( final SynthesisOption option, final Object value) { Map optionConfig = this.getProperty(SYNTHESIS_OPTION_CONFIG); if (optionConfig == null) { - optionConfig = Maps.newHashMap(); + optionConfig = new HashMap<>(); this.setProperty(SYNTHESIS_OPTION_CONFIG, optionConfig); } optionConfig.put(option, value); @@ -378,7 +377,7 @@ public KlighdSynthesisProperties configureSynthesisOptionValues( final Map options) { Map optionConfig = this.getProperty(SYNTHESIS_OPTION_CONFIG); if (optionConfig == null) { - optionConfig = Maps.newHashMap(); + optionConfig = new HashMap<>(); this.setProperty(SYNTHESIS_OPTION_CONFIG, optionConfig); } optionConfig.putAll(options); diff --git a/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/viewers/AbstractViewer.java b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/viewers/AbstractViewer.java index db7e06b34..1d25d2359 100644 --- a/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/viewers/AbstractViewer.java +++ b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/viewers/AbstractViewer.java @@ -19,6 +19,7 @@ import java.awt.geom.Rectangle2D; import java.util.Arrays; import java.util.EnumSet; +import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Set; @@ -28,7 +29,6 @@ import com.google.common.base.Predicates; import com.google.common.collect.HashMultimap; import com.google.common.collect.Iterables; -import com.google.common.collect.Maps; import com.google.common.collect.Multimap; import com.google.common.collect.Multimaps; import com.google.common.collect.SetMultimap; @@ -133,7 +133,7 @@ private void addViewChangeListener(final IViewChangeListener listener, // implemented by HashMultiMap. // It is guaranteed in the API and clients rely on that! viewChangeListeners = HashMultimap.create(); - notificationSuppressions = Maps.newHashMap(); + notificationSuppressions = new HashMap<>(); } for (final ViewChangeType t : eventTypes) { diff --git a/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/viewers/ContextViewer.java b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/viewers/ContextViewer.java index f1eb247e3..f2598b498 100644 --- a/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/viewers/ContextViewer.java +++ b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/viewers/ContextViewer.java @@ -28,6 +28,7 @@ import java.util.Collections; import java.util.EnumSet; import java.util.Iterator; +import java.util.LinkedHashSet; import java.util.List; import java.util.Set; @@ -948,7 +949,7 @@ protected void createSelection(final Collection elements) { /** the selection listeners registered on this view. */ // don't change the type to a collection type violating the Set property // see doc of 'ISelectionProvider.addSelectionChangedListener(...)' - private Set selectionListeners = Sets.newLinkedHashSet(); + private Set selectionListeners = new LinkedHashSet<>(); /** * Notifies the registered {@link ISelectionChangedListener ISelectionChangedListeners}. Such diff --git a/test/de.cau.cs.kieler.klighd.piccolo.test/src/de/cau/cs/kieler/klighd/piccolo/test/ApplyBendPointsActivityTest.java b/test/de.cau.cs.kieler.klighd.piccolo.test/src/de/cau/cs/kieler/klighd/piccolo/test/ApplyBendPointsActivityTest.java index 3ef0ac00f..412c3a593 100644 --- a/test/de.cau.cs.kieler.klighd.piccolo.test/src/de/cau/cs/kieler/klighd/piccolo/test/ApplyBendPointsActivityTest.java +++ b/test/de.cau.cs.kieler.klighd.piccolo.test/src/de/cau/cs/kieler/klighd/piccolo/test/ApplyBendPointsActivityTest.java @@ -18,12 +18,11 @@ import java.awt.geom.Point2D; import java.util.Arrays; +import java.util.List; import org.junit.Assert; import org.junit.Test; -import com.google.common.collect.Lists; - import de.cau.cs.kieler.klighd.kgraph.KEdge; import de.cau.cs.kieler.klighd.kgraph.KNode; import de.cau.cs.kieler.klighd.kgraph.util.KGraphUtil; @@ -49,7 +48,7 @@ private KEdgeNode prepareEdge(final Point2D[] currentBends) { KNode node0 = KGraphUtil.createInitializedNode(); KNode node1 = KGraphUtil.createInitializedNode(); KNode node2 = KGraphUtil.createInitializedNode(); - node0.getChildren().addAll(Lists.newArrayList(node1, node2)); + node0.getChildren().addAll(List.of(node1, node2)); KEdge edge = KGraphUtil.createInitializedEdge(); edge.setSource(node1); diff --git a/test/de.cau.cs.kieler.klighd.piccolo.test/src/de/cau/cs/kieler/klighd/piccolo/test/DiagramClipGlobalPortLabelVisiblityConfigTest.java b/test/de.cau.cs.kieler.klighd.piccolo.test/src/de/cau/cs/kieler/klighd/piccolo/test/DiagramClipGlobalPortLabelVisiblityConfigTest.java index 6aea78f73..e3fb969b4 100644 --- a/test/de.cau.cs.kieler.klighd.piccolo.test/src/de/cau/cs/kieler/klighd/piccolo/test/DiagramClipGlobalPortLabelVisiblityConfigTest.java +++ b/test/de.cau.cs.kieler.klighd.piccolo.test/src/de/cau/cs/kieler/klighd/piccolo/test/DiagramClipGlobalPortLabelVisiblityConfigTest.java @@ -53,8 +53,6 @@ import org.junit.runners.Parameterized.Parameters; import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; - import de.cau.cs.kieler.klighd.IDiagramWorkbenchPart; import de.cau.cs.kieler.klighd.IViewer; import de.cau.cs.kieler.klighd.ViewContext; @@ -136,7 +134,7 @@ public static Iterable getParameters() { final KNode orOp = circuitGraph.getChildren().get(0).getChildren().get(0).getChildren().get(1); final KNode notOp = circuitGraph.getChildren().get(0).getChildren().get(1); - final List clips = Lists.newArrayList( + final List clips = List.of( /** in circuit content ports are set invisible by default in view model */ clip(circuitContent, EXPECT_PORTS_INVISIBLE), clip(circuitContent, SHOW_PORTS, EXPECT_PORTS_VISIBLE), diff --git a/test/de.cau.cs.kieler.klighd.piccolo.test/src/de/cau/cs/kieler/klighd/piccolo/test/DiagramClipPortLabelVisibilityTest.java b/test/de.cau.cs.kieler.klighd.piccolo.test/src/de/cau/cs/kieler/klighd/piccolo/test/DiagramClipPortLabelVisibilityTest.java index 6c2a25f62..a18202acf 100644 --- a/test/de.cau.cs.kieler.klighd.piccolo.test/src/de/cau/cs/kieler/klighd/piccolo/test/DiagramClipPortLabelVisibilityTest.java +++ b/test/de.cau.cs.kieler.klighd.piccolo.test/src/de/cau/cs/kieler/klighd/piccolo/test/DiagramClipPortLabelVisibilityTest.java @@ -53,7 +53,6 @@ import org.junit.runners.Parameterized.Parameters; import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; import de.cau.cs.kieler.klighd.IDiagramWorkbenchPart; import de.cau.cs.kieler.klighd.IViewer; @@ -136,7 +135,7 @@ public static Iterable getParameters() { compoundOp.setProperty(SHOW_CLIPPED_LABELS, false); andOp.setProperty(SHOW_CLIPPED_PORTS, false); - final List clips = Lists.newArrayList( + final List clips = List.of( clip(circuitGraph), /** in circuit content ports are set invisible by default in view model */ diff --git a/test/de.cau.cs.kieler.klighd.piccolo.test/src/de/cau/cs/kieler/klighd/piccolo/test/DiagramClipTest.java b/test/de.cau.cs.kieler.klighd.piccolo.test/src/de/cau/cs/kieler/klighd/piccolo/test/DiagramClipTest.java index e18909ecb..49597ba45 100644 --- a/test/de.cau.cs.kieler.klighd.piccolo.test/src/de/cau/cs/kieler/klighd/piccolo/test/DiagramClipTest.java +++ b/test/de.cau.cs.kieler.klighd.piccolo.test/src/de/cau/cs/kieler/klighd/piccolo/test/DiagramClipTest.java @@ -40,8 +40,6 @@ import com.google.common.base.Function; import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; - import de.cau.cs.kieler.klighd.IDiagramWorkbenchPart; import de.cau.cs.kieler.klighd.IViewer; import de.cau.cs.kieler.klighd.ViewContext; @@ -108,7 +106,7 @@ public static Iterable getParameters() { final KNode notOp = circuitGraph.getChildren().get(0).getChildren().get(1); final List clips = - Lists.newArrayList(andOp, orOp, notOp, circuitGraph, notOp, andOp, orOp, notOp, + List.of(andOp, orOp, notOp, circuitGraph, notOp, andOp, orOp, notOp, circuitGraph, notOp, orOp, andOp, circuitGraph, FINISH); final Iterable result = Iterables.transform(clips, new Function() { diff --git a/test/de.cau.cs.kieler.klighd.piccolo.test/src/de/cau/cs/kieler/klighd/piccolo/test/DiagramZoomControllerBoundsComputerTest.java b/test/de.cau.cs.kieler.klighd.piccolo.test/src/de/cau/cs/kieler/klighd/piccolo/test/DiagramZoomControllerBoundsComputerTest.java index 4fb68707c..3d669732b 100644 --- a/test/de.cau.cs.kieler.klighd.piccolo.test/src/de/cau/cs/kieler/klighd/piccolo/test/DiagramZoomControllerBoundsComputerTest.java +++ b/test/de.cau.cs.kieler.klighd.piccolo.test/src/de/cau/cs/kieler/klighd/piccolo/test/DiagramZoomControllerBoundsComputerTest.java @@ -22,6 +22,7 @@ import java.awt.Rectangle; import java.awt.geom.Rectangle2D; +import java.util.List; import org.eclipse.elk.core.math.KVector; import org.eclipse.elk.core.util.Maybe; @@ -109,7 +110,7 @@ public static Iterable getParameters() { final KNode compoundOp = circuitGraph.getChildren().get(0).getChildren().get(0); // x=94.0, y=22.0 width=111.0, height=122.0, label at y=127.0, height=10.0 final KNode andOp = circuitGraph.getChildren().get(0).getChildren().get(0).getChildren().get(0); // x=46.0, y=76.67, width=40.0, height=30.0 - final Iterable clips = Lists.newArrayList( + final Iterable clips = List.of( // node instruction bb fit content bb fit entirely // the andOp has no children and and no node labels, // so clipping with ports + labels yields the ports' bounding box for 'fit content', and an enlarged bb for 'fit entirely' diff --git a/test/de.cau.cs.kieler.klighd.test/src/de/cau/cs/kieler/klighd/test/ViewChangedNotificationSuppressionTest.java b/test/de.cau.cs.kieler.klighd.test/src/de/cau/cs/kieler/klighd/test/ViewChangedNotificationSuppressionTest.java index bac718844..0cbf737f3 100644 --- a/test/de.cau.cs.kieler.klighd.test/src/de/cau/cs/kieler/klighd/test/ViewChangedNotificationSuppressionTest.java +++ b/test/de.cau.cs.kieler.klighd.test/src/de/cau/cs/kieler/klighd/test/ViewChangedNotificationSuppressionTest.java @@ -18,6 +18,7 @@ import java.util.ArrayList; import java.util.Collections; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -41,8 +42,6 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.common.collect.Iterators; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; import de.cau.cs.kieler.klighd.IDiagramWorkbenchPart; import de.cau.cs.kieler.klighd.IViewChangeListener; @@ -146,13 +145,13 @@ public void run() { } - private Map> suppressNotificationConfig01 = - Maps.newHashMap(); - private ArrayList expectedNotifications01 = null; + private Map> suppressNotificationConfig01 = + new HashMap<>(); + private List expectedNotifications01 = null; private Map> suppressNotificationConfig02 = - Maps.newHashMap(); - private ArrayList expectedNotifications02 = null; + new HashMap<>(); + private List expectedNotifications02 = null; private Iterable observedNotifications01 = null; private Iterable observedNotifications02 = null; @@ -164,7 +163,7 @@ public void run() { private final List changes; /* Constructor */ { - this.changes = Collections.synchronizedList(Lists.newArrayList()); + this.changes = Collections.synchronizedList(new ArrayList<>()); ViewChangedNotificationSuppressionTest.this.observedNotifications01 = Iterables.unmodifiableIterable(changes); } @@ -172,7 +171,7 @@ public void run() { public void viewChanged(final ViewChange change) { changes.add(change.getType()); - final ArrayList suppressed = + final List suppressed = suppressNotificationConfig01.get(change.getType()); if (suppressed != null) { change.suppressSubsequentNotifications(suppressed.toArray(new ViewChangeType[0])); @@ -190,7 +189,7 @@ public void viewChanged(final ViewChange change) { private final List changes; /* Constructor */ { - this.changes = Collections.synchronizedList(Lists.newArrayList()); + this.changes = Collections.synchronizedList(new ArrayList<>()); ViewChangedNotificationSuppressionTest.this.observedNotifications02 = Iterables.unmodifiableIterable(changes); } @@ -255,7 +254,7 @@ public Object apply(final ViewContext input) { public void test00() { employFirstListener(); - expectedNotifications01 = Lists.newArrayList(ViewChangeType.COLLAPSE, + expectedNotifications01 = List.of(ViewChangeType.COLLAPSE, ViewChangeType.VIEW_PORT, ViewChangeType.EXPAND, ViewChangeType.VIEW_PORT); expectedNotifications02 = expectedNotifications01; @@ -279,9 +278,9 @@ public void test01a() { employFirstListener(); suppressNotificationConfig01.put( - ViewChangeType.COLLAPSE, Lists.newArrayList(ViewChangeType.VIEW_PORT)); + ViewChangeType.COLLAPSE, List.of(ViewChangeType.VIEW_PORT)); - expectedNotifications01 = Lists.newArrayList( + expectedNotifications01 = List.of( ViewChangeType.COLLAPSE, ViewChangeType.EXPAND, ViewChangeType.VIEW_PORT); final Object modelElement = MODEL_QUERY.apply(viewContext); @@ -303,8 +302,8 @@ public void test01b() { employFirstListener(); suppressNotificationConfig01.put( - ViewChangeType.EXPAND, Lists.newArrayList(ViewChangeType.VIEW_PORT)); - expectedNotifications01 = Lists.newArrayList( + ViewChangeType.EXPAND, List.of(ViewChangeType.VIEW_PORT)); + expectedNotifications01 = List.of( ViewChangeType.COLLAPSE, ViewChangeType.VIEW_PORT, ViewChangeType.EXPAND); final Object modelElement = MODEL_QUERY.apply(viewContext); @@ -327,10 +326,10 @@ public void test01c() { employFirstListener(); suppressNotificationConfig01.put( - ViewChangeType.COLLAPSE, Lists.newArrayList(ViewChangeType.VIEW_PORT)); + ViewChangeType.COLLAPSE, List.of(ViewChangeType.VIEW_PORT)); suppressNotificationConfig01.put( - ViewChangeType.EXPAND, Lists.newArrayList(ViewChangeType.VIEW_PORT)); - expectedNotifications01 = Lists.newArrayList( + ViewChangeType.EXPAND, List.of(ViewChangeType.VIEW_PORT)); + expectedNotifications01 = List.of( ViewChangeType.COLLAPSE, ViewChangeType.EXPAND); final Object modelElement = MODEL_QUERY.apply(viewContext); @@ -384,7 +383,7 @@ public void test02base() { public void test02a() { employFirstListener(); - expectedNotifications01 = Lists.newArrayList(ViewChangeType.VIEW_PORT, + expectedNotifications01 = List.of(ViewChangeType.VIEW_PORT, ViewChangeType.COLLAPSE, ViewChangeType.VIEW_PORT, ViewChangeType.CLIP, ViewChangeType.VIEW_PORT, ViewChangeType.EXPAND, ViewChangeType.VIEW_PORT, @@ -398,11 +397,11 @@ public void test02b() { employFirstListener(); suppressNotificationConfig01.put( - ViewChangeType.COLLAPSE, Lists.newArrayList(ViewChangeType.VIEW_PORT)); + ViewChangeType.COLLAPSE, List.of(ViewChangeType.VIEW_PORT)); suppressNotificationConfig01.put( - ViewChangeType.EXPAND, Lists.newArrayList(ViewChangeType.VIEW_PORT)); + ViewChangeType.EXPAND, List.of(ViewChangeType.VIEW_PORT)); - expectedNotifications01 = Lists.newArrayList(ViewChangeType.VIEW_PORT, + expectedNotifications01 = List.of(ViewChangeType.VIEW_PORT, ViewChangeType.COLLAPSE, ViewChangeType.CLIP, ViewChangeType.VIEW_PORT, ViewChangeType.EXPAND, ViewChangeType.CLIP, ViewChangeType.VIEW_PORT); @@ -414,13 +413,13 @@ public void test02c() { employFirstListener(); suppressNotificationConfig01.put( - ViewChangeType.CLIP, Lists.newArrayList(ViewChangeType.VIEW_PORT)); + ViewChangeType.CLIP, List.of(ViewChangeType.VIEW_PORT)); suppressNotificationConfig01.put( - ViewChangeType.COLLAPSE, Lists.newArrayList(ViewChangeType.VIEW_PORT)); + ViewChangeType.COLLAPSE, List.of(ViewChangeType.VIEW_PORT)); suppressNotificationConfig01.put( - ViewChangeType.EXPAND, Lists.newArrayList(ViewChangeType.VIEW_PORT)); + ViewChangeType.EXPAND, List.of(ViewChangeType.VIEW_PORT)); - expectedNotifications01 = Lists.newArrayList(ViewChangeType.VIEW_PORT, + expectedNotifications01 = List.of(ViewChangeType.VIEW_PORT, ViewChangeType.COLLAPSE, ViewChangeType.CLIP, ViewChangeType.EXPAND, ViewChangeType.CLIP); @@ -432,13 +431,13 @@ public void test02d() { employFirstListener(); suppressNotificationConfig01.put(ViewChangeType.CLIP, - Lists.newArrayList(ViewChangeType.VIEW_PORT, ViewChangeType.EXPAND)); + List.of(ViewChangeType.VIEW_PORT, ViewChangeType.EXPAND)); suppressNotificationConfig01.put( - ViewChangeType.COLLAPSE, Lists.newArrayList(ViewChangeType.VIEW_PORT)); + ViewChangeType.COLLAPSE, List.of(ViewChangeType.VIEW_PORT)); suppressNotificationConfig01.put( - ViewChangeType.EXPAND, Lists.newArrayList(ViewChangeType.VIEW_PORT)); + ViewChangeType.EXPAND, List.of(ViewChangeType.VIEW_PORT)); - expectedNotifications01 = Lists.newArrayList(ViewChangeType.VIEW_PORT, + expectedNotifications01 = List.of(ViewChangeType.VIEW_PORT, ViewChangeType.COLLAPSE, ViewChangeType.CLIP, ViewChangeType.CLIP); test02base(); @@ -455,11 +454,11 @@ public void test03base() { } suppressNotificationConfig01.put( - ViewChangeType.COLLAPSE, Lists.newArrayList(ViewChangeType.VIEW_PORT)); + ViewChangeType.COLLAPSE, List.of(ViewChangeType.VIEW_PORT)); suppressNotificationConfig01.put( - ViewChangeType.EXPAND, Lists.newArrayList(ViewChangeType.VIEW_PORT)); + ViewChangeType.EXPAND, List.of(ViewChangeType.VIEW_PORT)); - expectedNotifications01 = Lists.newArrayList(ViewChangeType.VIEW_PORT, + expectedNotifications01 = List.of(ViewChangeType.VIEW_PORT, ViewChangeType.COLLAPSE, ViewChangeType.CLIP, ViewChangeType.VIEW_PORT, ViewChangeType.EXPAND, @@ -473,7 +472,7 @@ public void test03a() { suppressNotificationConfig02.put( ViewChangeType.COLLAPSE, ImmutableMap.of(ViewChangeType.VIEW_PORT, LONG_WAIT_DELAY)); - expectedNotifications02 = Lists.newArrayList(ViewChangeType.VIEW_PORT, + expectedNotifications02 = List.of(ViewChangeType.VIEW_PORT, ViewChangeType.COLLAPSE, ViewChangeType.CLIP, ViewChangeType.VIEW_PORT, ViewChangeType.EXPAND, ViewChangeType.VIEW_PORT, @@ -493,7 +492,7 @@ public void test03c() { suppressNotificationConfig02.put( ViewChangeType.COLLAPSE, ImmutableMap.of(ViewChangeType.VIEW_PORT, 2 * LONG_WAIT_DELAY)); - expectedNotifications02 = Lists.newArrayList(ViewChangeType.VIEW_PORT, + expectedNotifications02 = List.of(ViewChangeType.VIEW_PORT, ViewChangeType.COLLAPSE, ViewChangeType.CLIP, ViewChangeType.EXPAND, ViewChangeType.VIEW_PORT, @@ -513,7 +512,7 @@ public void test03e() { suppressNotificationConfig02.put( ViewChangeType.COLLAPSE, ImmutableMap.of(ViewChangeType.VIEW_PORT, 4 * LONG_WAIT_DELAY)); - expectedNotifications02 = Lists.newArrayList(ViewChangeType.VIEW_PORT, + expectedNotifications02 = List.of(ViewChangeType.VIEW_PORT, ViewChangeType.COLLAPSE, ViewChangeType.CLIP, ViewChangeType.EXPAND, @@ -533,7 +532,7 @@ public void test03g() { suppressNotificationConfig02.put( ViewChangeType.CLIP, ImmutableMap.of(ViewChangeType.VIEW_PORT, LONG_WAIT_DELAY)); - expectedNotifications02 = Lists.newArrayList(ViewChangeType.VIEW_PORT, + expectedNotifications02 = List.of(ViewChangeType.VIEW_PORT, ViewChangeType.COLLAPSE, ViewChangeType.VIEW_PORT, ViewChangeType.CLIP, ViewChangeType.EXPAND, ViewChangeType.VIEW_PORT, @@ -553,7 +552,7 @@ public void test03i() { suppressNotificationConfig02.put( ViewChangeType.CLIP, ImmutableMap.of(ViewChangeType.VIEW_PORT, 2 * LONG_WAIT_DELAY)); - expectedNotifications02 = Lists.newArrayList(ViewChangeType.VIEW_PORT, + expectedNotifications02 = List.of(ViewChangeType.VIEW_PORT, ViewChangeType.COLLAPSE, ViewChangeType.VIEW_PORT, ViewChangeType.CLIP, ViewChangeType.EXPAND, @@ -574,7 +573,7 @@ public void test03k() { ViewChangeType.CLIP, ImmutableMap.of( ViewChangeType.VIEW_PORT, 2 * LONG_WAIT_DELAY, ViewChangeType.EXPAND, 0)); - expectedNotifications02 = Lists.newArrayList(ViewChangeType.VIEW_PORT, + expectedNotifications02 = List.of(ViewChangeType.VIEW_PORT, ViewChangeType.COLLAPSE, ViewChangeType.VIEW_PORT, ViewChangeType.CLIP, @@ -598,7 +597,7 @@ public void test03m() { // COLLAPSE to EXPAND takes more than 2sec ... ViewChangeType.CLIP, 0)); - expectedNotifications02 = Lists.newArrayList(ViewChangeType.VIEW_PORT, + expectedNotifications02 = List.of(ViewChangeType.VIEW_PORT, ViewChangeType.COLLAPSE, ViewChangeType.EXPAND, // ... hence the notification must occur @@ -621,7 +620,7 @@ public void test03o() { ViewChangeType.EXPAND, 3 * LONG_WAIT_DELAY, ViewChangeType.CLIP, 0)); - expectedNotifications02 = Lists.newArrayList(ViewChangeType.VIEW_PORT, + expectedNotifications02 = List.of(ViewChangeType.VIEW_PORT, ViewChangeType.COLLAPSE, // because of the 3 seconds the EXPAND notification is blocked here diff --git a/test/de.cau.cs.kieler.klighd.test/src/de/cau/cs/kieler/klighd/test/runners/ModelCollectionTestRunner.java b/test/de.cau.cs.kieler.klighd.test/src/de/cau/cs/kieler/klighd/test/runners/ModelCollectionTestRunner.java index 0a961f84e..c5ff72a23 100644 --- a/test/de.cau.cs.kieler.klighd.test/src/de/cau/cs/kieler/klighd/test/runners/ModelCollectionTestRunner.java +++ b/test/de.cau.cs.kieler.klighd.test/src/de/cau/cs/kieler/klighd/test/runners/ModelCollectionTestRunner.java @@ -24,6 +24,7 @@ import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.net.URL; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -123,7 +124,7 @@ * * @Models * public static Iterable<?> getModels() { - * List<Object> models = Lists.newLinkedList(); + * List<Object> models = new ArrayList<>(); * return models; * } * @@ -365,7 +366,7 @@ public ModelCollectionTestRunner(final Class clazz) throws Throwable { // for each of the revealed model objects determine a name (the fragmentURI in case of // EObjects) and create a related child test runner - final List childRunners = Lists.newLinkedList(); + final List childRunners = new ArrayList<>(); for (Object o : models) { final String modelName; @@ -515,7 +516,7 @@ private Iterable getModelsByPathMethods() { ? (org.eclipse.emf.ecore.resource.ResourceSet) resourceSetMethod .invokeExplosively(null) : new ResourceSetImpl(); - List urls = Lists.newArrayList(); + List urls = new ArrayList<>(); // for all provided model paths ... for (String modelPath : modelPaths) {