use of com.intellij.openapi.ui.Painter in project intellij-community by JetBrains.
the class PaintersHelper method computeOffsets.
@NotNull
int[] computeOffsets(Graphics gg, @NotNull JComponent component) {
if (myPainters.isEmpty())
return ArrayUtil.EMPTY_INT_ARRAY;
int i = 0;
int[] offsets = new int[2 + myPainters.size() * 2];
// store current graphics transform
Graphics2D g = (Graphics2D) gg;
AffineTransform tx = g.getTransform();
// graphics tx offsets include graphics scale
offsets[i++] = (int) tx.getTranslateX();
offsets[i++] = (int) tx.getTranslateY();
// calculate relative offsets for painters
Rectangle r = null;
Component prev = null;
for (Painter painter : myPainters) {
if (!painter.needsRepaint())
continue;
Component cur = myPainter2Component.get(painter);
if (cur != prev || r == null) {
Container curParent = cur.getParent();
if (curParent == null)
continue;
r = SwingUtilities.convertRectangle(curParent, cur.getBounds(), component);
prev = cur;
}
// component offsets don't include graphics scale, so compensate
offsets[i++] = (int) (r.x * tx.getScaleX());
offsets[i++] = (int) (r.y * tx.getScaleY());
}
return offsets;
}
use of com.intellij.openapi.ui.Painter in project intellij-community by JetBrains.
the class PaintersHelper method runAllPainters.
void runAllPainters(Graphics gg, int[] offsets) {
if (myPainters.isEmpty())
return;
Graphics2D g = (Graphics2D) gg;
AffineTransform orig = g.getTransform();
int i = 0;
// restore transform at the time of computeOffset()
AffineTransform t = new AffineTransform();
t.translate(offsets[i++], offsets[i++]);
for (Painter painter : myPainters) {
if (!painter.needsRepaint())
continue;
Component cur = myPainter2Component.get(painter);
g.setTransform(t);
g.translate(offsets[i++], offsets[i++]);
// paint in the orig graphics scale (note, the offsets are pre-scaled)
g.scale(orig.getScaleX(), orig.getScaleY());
painter.paint(cur, g);
}
g.setTransform(orig);
}
use of com.intellij.openapi.ui.Painter in project intellij-community by JetBrains.
the class PaintersHelper method clear.
public void clear() {
for (Painter painter : myPainters) {
painter.removeListener(this);
}
myPainters.clear();
myPainter2Component.clear();
}
Aggregations