import org.simantics.db.service.ClusterUID;
import org.simantics.db.service.EventSupport;
import org.simantics.db.service.LifecycleSupport;
-import org.simantics.utils.DataContainer;
import org.simantics.utils.datastructures.Pair;
import org.simantics.utils.logging.TimeLogger;
import org.slf4j.Logger;
LOGGER.info("performUndo " + ccsid);
performUndo(ccsid, clusterChanges, support);
} catch (DatabaseException e) {
- e.printStackTrace();
+ LOGGER.error("failed to perform undo for cluster change set {}", ccsid, e);
}
}
}
}
}
+ @SuppressWarnings("unchecked")
MainProgram(GraphClientImpl2 client, ClusterManager clusters) {
this.client = client;
try {
swapChunks();
} catch (AcornAccessVerificationException | IllegalAcornStateException e) {
- e.printStackTrace();
+ LOGGER.error("cluster chunk swapping failed", e);
} finally {
clusters.streamLRU.releaseMutex();
}
}
} catch (Throwable t) {
- t.printStackTrace();
+ LOGGER.error("FATAL: MainProgram died unexpectedly", t);
} finally {
deathBarrier.release();
}
executor.awaitTermination(500, TimeUnit.MILLISECONDS);
clusterUpdateThreads[i] = null;
} catch (InterruptedException e) {
- e.printStackTrace();
+ LOGGER.error("clusterUpdateThread[{}] termination interrupted", i, e);
}
}
}
protected final ConnectionStyle style;
+ private static class Cache {
+ Path2D path = new Path2D.Double();
+ THashSet<RoutePoint> branchPoints = new THashSet<>();
+ }
+
// Caches to avoid creating new objects all the time during rendering
- protected transient Path2D path;
- protected transient THashSet<RoutePoint> branchPoints;
+ protected static ThreadLocal<Cache> caches = ThreadLocal.withInitial(() -> new Cache());
public StyledRouteGraphRenderer(ConnectionStyle style) {
if (style == null)
@Override
public void render(Graphics2D g, RouteGraph rg) {
- if (path == null)
- path = new Path2D.Double();
+ Cache cache = caches.get();
+ Path2D path = cache.path;
+ THashSet<RoutePoint> branchPoints = cache.branchPoints;
+
path.reset();
rg.getPath2D(path);
style.drawPath(g, path, false);
- if (branchPoints == null)
- branchPoints = new THashSet<RoutePoint>();
branchPoints.clear();
for(RouteLine line : rg.getLines()) {
renderLine(g, line, false);