Ejemplo n.º 1
0
  @SuppressWarnings("deprecation")
  public final void runOneComponent(
      Component comp, Rectangle bounds, Graphics g, Shape clip, int weightFlags) {
    if (comp == null || comp.getPeer() == null || !comp.isVisible()) {
      return;
    }
    boolean lightweight = comp.isLightweight();
    if ((lightweight && (weightFlags & LIGHTWEIGHTS) == 0)
        || (!lightweight && (weightFlags & HEAVYWEIGHTS) == 0)) {
      return;
    }

    if (bounds == null) {
      bounds = comp.getBounds();
    }

    if (clip == null || clip.intersects(bounds)) {
      Graphics cg = g.create();
      try {
        constrainGraphics(cg, bounds);
        cg.setFont(comp.getFont());
        cg.setColor(comp.getForeground());
        if (cg instanceof Graphics2D) {
          ((Graphics2D) cg).setBackground(comp.getBackground());
        } else if (cg instanceof Graphics2Delegate) {
          ((Graphics2Delegate) cg).setBackground(comp.getBackground());
        }
        run(comp, cg);
      } finally {
        cg.dispose();
      }
    }
  }
Ejemplo n.º 2
0
 /**
  * @see prefuse.render.Renderer#locatePoint(java.awt.geom.Point2D, prefuse.visual.VisualItem)
  */
 @Override
 public boolean locatePoint(Point2D p, VisualItem item) {
   Shape s = getShape(item);
   if (s == null) {
     return false;
   } else if (s == m_box && m_box.contains(p)) {
     return true;
   } else {
     double width = Math.max(2, item.getSize());
     double halfWidth = width / 2.0;
     return s.intersects(p.getX() - halfWidth, p.getY() - halfWidth, width, width);
   }
 }