- int totalHeight = (int)Math.round(rowHeight * labels.size());
- g.fillRect(-(W1 + PAD + W2 + 5), -(totalHeight + (int)Math.round(rowHeight)), (W1 + PAD + W2 + width + 10), totalHeight + 5);
-
- g.setColor(Color.BLACK);
-
- for (Tuple3 t : labels) {
- g.translate(0.f, -rowHeight);
-
- if (t.c0 != null) {
- g.drawString((String) t.c0, -(W1 + PAD + W2), 0.f);
- }
-
- if (t.c1 != null) {
- int width1 = g.getFontMetrics().stringWidth((String) t.c1);
- g.drawString((String) t.c1, - width1, 0.f);
- }
-
- if (t.c2 != null) {
- g.drawString((String) t.c2, PAD, 0.f);
- }
- }
- }
-
- @Override
- public Rectangle2D getBoundsInLocal() {
- return null;
- }
-
- @SuppressWarnings("unchecked")
- public void setLabels(List<Tuple3> list) {
- this.labels = Lists.reverse(list);
- }
-
- public void setOrigin(Point2D origin) {
- this.origin = origin;
- }
-
- @Override
- public boolean hover(boolean hover, boolean isConnectionTool) {
- hover = hover && activeNode.updateAndGet(current -> current == null ? this : current) == this;
- boolean changed = hover != this.hover;
- this.hover = hover;
-
- if (changed) {
- if (!hover) activeNode.updateAndGet(current -> current == this ? null : current);
- repaint();
- }
-
- return changed;
- }
-
- @Override
- public void delete() {
- super.delete();
- activeNode.getAndUpdate(current -> current == this ? null : current);
- }
+ g.fill(bgRect);
+
+ g.setColor(Color.DARK_GRAY);
+ g.draw(bgRect);
+
+ g.setColor(Color.BLACK);
+ g.translate(bgRect.getMinX() - minX, bgRect.getMinY() - minY);
+
+ int rows = values.size();
+ double y = -rowHeight;
+
+ float labelX = -(maxLabelWidth + PAD + maxValueWidth + PAD);
+ float unitX = 0;
+
+ for (int i = 0; i < rows; ++i) {
+ Tuple3 t = values.get(i);
+ float ty = (float) y;
+
+ if (t.c0 != null && ((String) t.c0).length() > 0) {
+ g.drawString((String) t.c0, labelX, ty);
+ }
+ if (t.c1 != null && ((String) t.c1).length() > 0) {
+ g.drawString((String) t.c1, -(valueWidths[i] + PAD), ty);
+ }
+ if (t.c2 != null && ((String) t.c2).length() > 0) {
+ g.drawString((String) t.c2, unitX, ty);
+ }
+
+ y -= rowHeight;
+ }
+
+ if (!titleString.trim().isEmpty()) {
+ int titleX = (int) (labelX - PAD + (bgRect.getWidth() - titleWidth) * 0.5);
+ g.drawString(titleString, titleX, (float) y);
+ }
+ }
+
+ private Rectangle2D confineIn(Rectangle2D r, Rectangle2D bounds) {
+ // Handle right/bottom overrun
+ double maxX = Math.min(r.getMaxX(), bounds.getMaxX());
+ double maxY = Math.min(r.getMaxY(), bounds.getMaxY());
+ r.setFrame(
+ maxX - r.getWidth(),
+ maxY - r.getHeight(),
+ r.getWidth(),
+ r.getHeight());
+
+ // Handle left/top overrun
+ r.setFrame(
+ Math.max(r.getMinX(), bounds.getMinX()),
+ Math.max(r.getMinY(), bounds.getMinY()),
+ r.getWidth(),
+ r.getHeight());
+
+ return r;
+ }
+
+ @Override
+ public Rectangle2D getBoundsInLocal() {
+ return null;
+ }
+
+ @SuppressWarnings("unchecked")
+ public void setLabels(List<Tuple3> list) {
+ this.labels = Lists.reverse(list);
+ }
+
+ public void setOrigin(Point2D origin) {
+ this.origin = origin;
+ }
+
+ @Override
+ public boolean hover(boolean hover, boolean isConnectionTool) {
+ boolean changed = hover != this.hover;
+ this.hover = hover;
+ return changed;
+ }
+
+ @Override
+ public void setMousePosition(Point2D p) {
+ mousePosition = p;
+ }
+
+ @Override
+ public void delete() {
+ super.delete();
+ activeNode.set(null);
+ }
+
+ public void setHoveredNode(INode hoveredNode) {
+ ParentNode<?> root = (ParentNode<?>) NodeUtil.getNearestParentOfType(parent, RTreeNode.class);
+ if (root != null) {
+
+ INode child = ProfileVariables.browseChild(root, "");
+ if(child == null) {
+ throw new NullPointerException("Scenegraph child node was not found: " + "");
+ }
+
+ INode existing = NodeUtil.getChildById(child, HOVER_INFO_DEFERRED);
+ if (existing == null) {
+ if (child instanceof ParentNode<?>) {
+ existing = ((ParentNode<?>) child).addNode(HOVER_INFO_DEFERRED, DeferredRenderingNode.class);
+ ((DeferredRenderingNode)existing).setZIndex(Integer.MAX_VALUE);
+ } else {
+ throw new NodeException("Cannot claim child node for non-parent-node " + child);
+ }
+ }
+ }
+
+ activeNode.set(hoveredNode);
+ repaint();
+ }
+