/** * Paint this window. This method should not generally be overridden by subclasses. This method * carefully stores the clip, translation, and color before calling into subclasses. The graphics * context should be translated such that it is in this window's coordinate space (0,0 is the top * left corner of this window). * * @param g The graphics object to use to paint this window. * @param refreshQ The custom queue which holds the set of refresh regions needing to be blitted * to the screen */ public void paint(Graphics g, CGraphicsQ refreshQ) { // We reset our dirty flag first. Any layers that become // dirty in the duration of this method will then cause it // to toggle back to true for the subsequent pass. // IMPL NOTE: when layers start to do complex animation, there will // likely need to be better atomic handling of the dirty state, // and layers becoming dirty and getting painted this.dirty = false; // Store the clip, translate, font, color cX = g.getClipX(); cY = g.getClipY(); cW = g.getClipWidth(); cH = g.getClipHeight(); tranX = g.getTranslateX(); tranY = g.getTranslateY(); font = g.getFont(); color = g.getColor(); // We set the basic clip to the size of this window g.setClip(bounds[X], bounds[Y], bounds[W], bounds[H]); synchronized (layers) { sweepAndMarkLayers(); copyAndCleanDirtyLayers(); } paintLayers(g, refreshQ); // We restore the original clip. The original font, color, etc. // have already been restored g.setClip(cX, cY, cW, cH); }
/** ********************************************************************** */ public void paintComponent(Graphics g) { for (int i = 0; i < model.size(); i++) { int y = i * cell_height; if (y + cell_height < g.getClipY()) continue; else if (y > g.getClipY() + g.getClipHeight()) break; // g.translate(0, y); IComponent c = renderer.getListCellRendererComponent( this, model.elementAt(i), i, selection.isSelectedIndex(i), (rollover == i)); c.setBounds(0, 0, bounds.width, cell_height); c.setFont(font); c.setEnabled(enabled); c.paint(g); g.translate(0, -y); } }