Skip to content

Commit bb02d31

Browse files
committed
Taking scrolling into account when exporting images. Fixes igvteam#1033
1 parent d58f22a commit bb02d31

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

src/main/java/org/broad/igv/ui/panel/DataPanelContainer.java

+1
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ public int compare(Component component, Component component1) {
138138
if (c instanceof DataPanel) {
139139
Graphics2D g2d = (Graphics2D) g.create();
140140
Rectangle clipRect = new Rectangle(c.getBounds());
141+
clipRect.y = rect.y;
141142
clipRect.height = rect.height;
142143
g2d.setClip(clipRect);
143144
g2d.translate(c.getX(), 0);

src/main/java/org/broad/igv/ui/panel/TrackPanel.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,7 @@ public void paintOffscreen(Graphics2D g, Rectangle rect, boolean batch) {
503503
g.translate(mainPanel.getNamePanelX(), 0);
504504

505505
Rectangle nameRect = new Rectangle(children[0].getBounds());
506+
nameRect.y = rect.y;
506507
nameRect.height = h;
507508
if (nameRect.width > 0) {
508509
Graphics2D nameGraphics = (Graphics2D) g.create();
@@ -513,7 +514,7 @@ public void paintOffscreen(Graphics2D g, Rectangle rect, boolean batch) {
513514

514515
int dx = mainPanel.getAttributePanelX() - mainPanel.getNamePanelX();
515516
g.translate(dx, 0);
516-
Rectangle attRect = new Rectangle(0, 0, children[1].getWidth(), h);
517+
Rectangle attRect = new Rectangle(0, rect.y, children[1].getWidth(), h);
517518
if (attRect.width > 0) {
518519
Graphics2D attGraphics = (Graphics2D) g.create();
519520
attGraphics.setClip(attRect);
@@ -523,7 +524,7 @@ public void paintOffscreen(Graphics2D g, Rectangle rect, boolean batch) {
523524

524525
dx = mainPanel.getDataPanelX() - mainPanel.getAttributePanelX();
525526
g.translate(dx, 0);
526-
Rectangle dataRect = new Rectangle(0, 0, mainPanel.getDataPanelWidth(), h);
527+
Rectangle dataRect = new Rectangle(0, rect.y, mainPanel.getDataPanelWidth(), h);
527528
Graphics2D dataGraphics = (Graphics2D) g.create();
528529
dataGraphics.setClip(dataRect);
529530
((Paintable) children[2]).paintOffscreen(dataGraphics, dataRect, batch);

src/main/java/org/broad/igv/ui/panel/TrackPanelScrollPane.java

+3
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ public TrackNamePanel getNamePanel() {
127127

128128
@Override
129129
public void paintOffscreen(Graphics2D g, Rectangle tspRect, boolean batch) {
130+
int yOffset = getViewport().getViewPosition().y;
131+
tspRect.y = yOffset;
132+
g.translate(0, -yOffset);
130133
trackPanel.paintOffscreen(g, tspRect, batch);
131134
}
132135

0 commit comments

Comments
 (0)