Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjusted zoom #16

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ public Dimension computeFlameGraphDimension(Graphics2D g2, Rectangle visibleRect

var visibleWidth = visibleRect.width - insets.left - insets.right;

int widthZoomAdjustment = zoomFactor > 1d ? (int) (10 * 2 * zoomFactor) : 0;


// compute the canvas height for the flamegraph width
if (this.visibleWidth != visibleWidth) {
var preferredFlameGraphWidth = ((int) (zoomFactor * visibleWidth)) - insets.left - insets.right;
Expand Down Expand Up @@ -151,6 +154,9 @@ private void paint(Graphics2D g2, Rectangle visibleRect, boolean minimapMode) {

identifyDisplayScale(g2);

int widthZoomAdjustment = zoomFactor > 1d ? 10 * 2 : 0;


{
var rootFrame = frames.get(0);
rectOnCanvas.x = (int) (flameGraphWidth * rootFrame.startX) + internalPadding;
Expand Down Expand Up @@ -372,15 +378,18 @@ public Optional<Point> zoomToFrameAt(Graphics2D g2, Point point) {
this.selectedFrame = frame;

var frameWidthX = frame.endX - frame.startX;
flameGraphWidth = (int) Math.max(visibleWidth / Math.min(1, frameWidthX), visibleWidth);

var flameGraphWidth = (int) Math.max(visibleWidth / Math.min(1, frameWidthX), visibleWidth);
zoomFactor = (double) flameGraphWidth / visibleWidth;
int widthZoomAdjustment = zoomFactor > 1d ? (int) (10 * 2 * zoomFactor) : 0;
this.flameGraphWidth = flameGraphWidth - widthZoomAdjustment;

var frameBoxHeight = getFrameBoxHeight(g2);
int y = frameBoxHeight * frame.stackDepth;

// Change offset to center the flame from this frame
return new Point(
(int) (frame.startX * flameGraphWidth),
(int) (frame.startX * this.flameGraphWidth) - (zoomFactor > 1d ? 10 : 0),
Math.max(0, y)
);
});
Expand Down