Java 类com.intellij.openapi.ui.Painter 实例源码

项目:intellij-ce-playground    文件:IdeGlassPaneUtil.java   
public static void installPainter(final JComponent target, final Painter painter, final Disposable parent) {
  final UiNotifyConnector connector = new UiNotifyConnector(target, new Activatable() {

    IdeGlassPane myPane;

    public void showNotify() {
      IdeGlassPane pane = find(target);
      if (myPane != null && myPane != pane) {
        myPane.removePainter(painter);
      }
      myPane = pane;
      myPane.addPainter(target, painter, parent);
    }

    public void hideNotify() {
      if (myPane != null) {
        myPane.removePainter(painter);
      }
    }
  });
  Disposer.register(parent, connector);
}
项目:tools-idea    文件:IdeGlassPaneUtil.java   
public static void installPainter(final JComponent target, final Painter painter, final Disposable parent) {
  final UiNotifyConnector connector = new UiNotifyConnector(target, new Activatable() {

    IdeGlassPane myPane;

    public void showNotify() {
      IdeGlassPane pane = find(target);
      if (myPane != null && myPane != pane) {
        myPane.removePainter(painter);
      }
      myPane = pane;
      myPane.addPainter(target, painter, parent);
    }

    public void hideNotify() {
      if (myPane != null) {
        myPane.removePainter(painter);
      }
    }
  });
  Disposer.register(parent, connector);
}
项目:tools-idea    文件:IdeGlassPaneImpl.java   
protected void paintComponent(final Graphics g) {
  if (myPainters.isEmpty()) return;

  Graphics2D g2d = (Graphics2D)g;
  for (Painter painter : myPainters) {
    final Rectangle clip = g.getClipBounds();

    final Component component = myPainter2Component.get(painter);
    if (component.getParent() == null) continue;
    final Rectangle componentBounds = SwingUtilities.convertRectangle(component.getParent(), component.getBounds(), this);

    if (!painter.needsRepaint()) {
      continue;
    }

    if (clip.contains(componentBounds) || clip.intersects(componentBounds)) {
      final Point targetPoint = SwingUtilities.convertPoint(this, 0, 0, component);
      final Rectangle targetRect = new Rectangle(targetPoint, component.getSize());
      g2d.translate(-targetRect.x, -targetRect.y);
      painter.paint(component, g2d);
      g2d.translate(targetRect.x, targetRect.y);
    }
  }
}
项目:consulo    文件:IdeGlassPaneUtil.java   
public static void installPainter(final JComponent target, final Painter painter, final Disposable parent) {
  final UiNotifyConnector connector = new UiNotifyConnector(target, new Activatable() {

    IdeGlassPane myPane;

    public void showNotify() {
      IdeGlassPane pane = find(target);
      if (myPane != null && myPane != pane) {
        myPane.removePainter(painter);
      }
      myPane = pane;
      myPane.addPainter(target, painter, parent);
    }

    public void hideNotify() {
      if (myPane != null) {
        myPane.removePainter(painter);
      }
    }
  });
  Disposer.register(parent, connector);
}
项目:consulo    文件:PaintersHelper.java   
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);
}
项目:intellij-ce-playground    文件:PaintersHelper.java   
public void clear() {
  for (Painter painter : myPainters) {
    painter.removeListener(this);
  }
  myPainters.clear();
  myPainter2Component.clear();
}
项目:intellij-ce-playground    文件:PaintersHelper.java   
public void paint(Graphics g, JComponent current) {
  if (myPainters.isEmpty()) return;
  Graphics2D g2d = (Graphics2D)g;
  Rectangle clip = ObjectUtils.notNull(g.getClipBounds(), current.getBounds());

  Component component = null;
  Rectangle componentBounds = null;
  boolean clipMatched = false;
  for (Painter painter : myPainters) {
    if (!painter.needsRepaint()) continue;

    Component cur = myPainter2Component.get(painter);
    if (cur != component || componentBounds == null) {
      Container parent = (component = cur).getParent();
      if (parent == null) continue;
      componentBounds = SwingUtilities.convertRectangle(parent, component.getBounds(), current);
      clipMatched = clip.contains(componentBounds) || clip.intersects(componentBounds);
    }
    if (!clipMatched) continue;

    Point targetPoint = SwingUtilities.convertPoint(current, 0, 0, component);
    Rectangle targetRect = new Rectangle(targetPoint, component.getSize());
    g2d.setClip(clip.intersection(componentBounds));
    g2d.translate(-targetRect.x, -targetRect.y);
    painter.paint(component, g2d);
    g2d.translate(targetRect.x, targetRect.y);
  }

}
项目:intellij-ce-playground    文件:PaintersHelper.java   
@Override
public void onNeedsRepaint(Painter painter, JComponent dirtyComponent) {
  if (dirtyComponent != null && dirtyComponent.isShowing()) {
    Rectangle rec = SwingUtilities.convertRectangle(dirtyComponent, dirtyComponent.getBounds(), myRootComponent);
    myRootComponent.repaint(rec);
  }
  else {
    myRootComponent.repaint();
  }
}
项目:intellij-ce-playground    文件:IdeGlassPaneImpl.java   
public void addPainter(final Component component, final Painter painter, final Disposable parent) {
  getPainters().addPainter(painter, component);
  activateIfNeeded();
  Disposer.register(parent, new Disposable() {
    public void dispose() {
      SwingUtilities.invokeLater(new Runnable() {
        public void run() {
          removePainter(painter);
        }
      });
    }
  });
}
项目:tools-idea    文件:IdeGlassPaneImpl.java   
public void addPainter(final Component component, final Painter painter, final Disposable parent) {
  myPainters.add(painter);
  myPainter2Component.put(painter, component == null ? this : component);
  painter.addListener(this);
  activateIfNeeded();
  Disposer.register(parent, new Disposable() {
    public void dispose() {
      SwingUtilities.invokeLater(new Runnable() {
        public void run() {
          removePainter(painter);
        }
      });
    }
  });
}
项目:tools-idea    文件:IdeGlassPaneImpl.java   
public void onNeedsRepaint(final Painter painter, final JComponent dirtyComponent) {
  if (dirtyComponent != null && dirtyComponent.isShowing()) {
    final Rectangle rec = SwingUtilities.convertRectangle(dirtyComponent, dirtyComponent.getBounds(), this);
    if (rec != null) {
      repaint(rec);
      return;
    }
  }

  repaint();
}
项目:consulo    文件:PaintersHelper.java   
public void clear() {
  for (Painter painter : myPainters) {
    painter.removeListener(this);
  }
  myPainters.clear();
  myPainter2Component.clear();
}
项目:consulo    文件:PaintersHelper.java   
@Nonnull
int[] computeOffsets(Graphics gg, @Nonnull 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;
}
项目:consulo    文件:PaintersHelper.java   
@Override
public void onNeedsRepaint(Painter painter, JComponent dirtyComponent) {
  if (dirtyComponent != null && dirtyComponent.isShowing()) {
    Rectangle rec = SwingUtilities.convertRectangle(dirtyComponent, dirtyComponent.getBounds(), myRootComponent);
    myRootComponent.repaint(rec);
  }
  else {
    myRootComponent.repaint();
  }
}
项目:consulo    文件:IdeGlassPaneImpl.java   
public void addPainter(final Component component, final Painter painter, final Disposable parent) {
  getPainters().addPainter(painter, component);
  activateIfNeeded();
  Disposer.register(parent, new Disposable() {
    public void dispose() {
      SwingUtilities.invokeLater(() -> removePainter(painter));
    }
  });
}
项目:intellij-ce-playground    文件:PaintersHelper.java   
public void addPainter(@NotNull Painter painter, @Nullable Component component) {
  myPainters.add(painter);
  myPainter2Component.put(painter, component == null ? myRootComponent : component);
  painter.addListener(this);
}
项目:intellij-ce-playground    文件:PaintersHelper.java   
public void removePainter(@NotNull Painter painter) {
  painter.removeListener(this);
  myPainters.remove(painter);
  myPainter2Component.remove(painter);
}
项目:intellij-ce-playground    文件:IdeGlassPaneImpl.java   
public void removePainter(final Painter painter) {
  getPainters().removePainter(painter);
  deactivateIfNeeded();
}
项目:tools-idea    文件:IdeGlassPaneImpl.java   
public void removePainter(final Painter painter) {
  myPainters.remove(painter);
  myPainter2Component.remove(painter);
  painter.removeListener(this);
  deactivateIfNeeded();
}
项目:consulo    文件:PaintersHelper.java   
public boolean needsRepaint() {
  for (Painter painter : myPainters) {
    if (painter.needsRepaint()) return true;
  }
  return false;
}
项目:consulo    文件:PaintersHelper.java   
public void addPainter(@Nonnull Painter painter, @Nullable Component component) {
  myPainters.add(painter);
  myPainter2Component.put(painter, component == null ? myRootComponent : component);
  painter.addListener(this);
}
项目:consulo    文件:PaintersHelper.java   
public void removePainter(@Nonnull Painter painter) {
  painter.removeListener(this);
  myPainters.remove(painter);
  myPainter2Component.remove(painter);
}
项目:consulo    文件:IdeGlassPaneImpl.java   
public void removePainter(final Painter painter) {
  getPainters().removePainter(painter);
  deactivateIfNeeded();
}
项目:intellij-ce-playground    文件:IdeGlassPane.java   
void addPainter(final Component component, Painter painter, Disposable parent);
项目:intellij-ce-playground    文件:IdeGlassPane.java   
void removePainter(final Painter painter);
项目:tools-idea    文件:IdeGlassPane.java   
void addPainter(final Component component, Painter painter, Disposable parent);
项目:tools-idea    文件:IdeGlassPane.java   
void removePainter(final Painter painter);
项目:jediterm    文件:IdeGlassPane.java   
void addPainter(final Component component, Painter painter, Disposable parent);
项目:jediterm    文件:IdeGlassPane.java   
void removePainter(final Painter painter);
项目:consulo    文件:IdeGlassPane.java   
void addPainter(final Component component, Painter painter, Disposable parent);
项目:consulo    文件:IdeGlassPane.java   
void removePainter(final Painter painter);