The actual painting function. Draws the groups.

@param paintable
A {@link RasterTile} object.
@param group
The group where the object resides in (optional).
@param context
A MapContext object, responsible for actual drawing.
7233
public void paint(Paintable paintable, Object group, MapContext context) {
		RasterTile tile = (RasterTile) paintable;
		context.getRasterContext().drawImage(tile.getStore().getLayer(), 
				tile.getCode().toString(), tile.getUrl(), tile.getBounds(), new PictureStyle(1.0));
	}
86521
public void accept(PainterVisitor visitor, Object group, Bbox bounds, boolean recursive) {
		map.getVectorContext().drawGroup(group, this);

		// Draw a dummy at 0,0 so that Internet Explorer knows where coordinate 0,0 is. If this is not drawn, the text
		// will disappear, because the parent group will have coordinate 0,0 at the upper left corner of the union of
		// all the rectangles that are drawn here.
		map.getVectorContext().drawRectangle(this, dummy.getId(), dummy.getBounds(), dummy.getStyle());

		image.getBounds().setX(getUpperLeftCorner().getX());
		image.getBounds().setY(getUpperLeftCorner().getY());

		map.getVectorContext().drawRectangle(this, getId() + "-bg", image.getBounds(),
				new ShapeStyle("#FFFFFF", 0.6f, "#FFFFFF", 0, 0));
		map.getVectorContext().drawImage(this, image.getId(), image.getHref(), image.getBounds(),
				(PictureStyle) image.getStyle());
	}
19290
void paintBackground(SeaGlassContext context, Graphics g, JComponent c) {
        if (((AbstractButton) c).isContentAreaFilled()) {
            context.getPainter().paintButtonBackground(context, g, 0, 0, c.getWidth(), c.getHeight());
        }
    }
977041
public void accept(PainterVisitor visitor, Object group, Bbox bounds, boolean recursive) {
		map.getVectorContext().drawGroup(group, this);

		Coordinate c = getUpperLeftCorner();
		PictureStyle pictureStyle = new PictureStyle(1);
		pictureStyle.setClassName("gm-ZoomToRectangleControl");
		map.getVectorContext().drawImage(this, "zoom-rect-img",
				Geomajas.getIsomorphicDir() + "geomajas/mapaddon/zoom_rectangle.png",
				new Bbox(c.getX(), c.getY(), 20, 20), pictureStyle);

		if (firstTime) {
			map.getVectorContext().setController(this, "zoom-rect-img", new ActivateRectangleController(map),
					Event.MOUSEEVENTS);
			map.getVectorContext().setCursor(this, "zoom-rect-img", Cursor.POINTER.getValue());
		}
		firstTime = false;
	}
1341234
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		WComponentGroup group = (WComponentGroup) component;
		XmlStringBuilder xml = renderContext.getWriter();
		List<WComponent> components = group.getComponents();

		if (components != null && !components.isEmpty()) {
			xml.appendTagOpen("ui:componentGroup");
			xml.appendAttribute("id", component.getId());
			xml.appendOptionalAttribute("track", component.isTracking(), "true");
			xml.appendClose();

			for (WComponent comp : components) {
				xml.appendTagOpen("ui:component");
				xml.appendAttribute("id", comp.getId());
				xml.appendEnd();
			}

			xml.appendEndTag("ui:componentGroup");
		}
	}
199166
function drawToContext(){
      startTime = +new Date;
      var nodes = r.getCachedNodes(); var edges = r.getCachedEdges();
      var coreStyle = cy.style()._private.coreStyle;
      
      // if( !forcedContext ){
      //   r.matchCanvasSize(data.container);
      // }

      var zoom = cy.zoom();
      var effectiveZoom = forcedZoom !== undefined ? forcedZoom : zoom;
      var pan = cy.pan();
      var effectivePan = {
        x: pan.x,
        y: pan.y
      };

      if( forcedPan ){
        effectivePan = forcedPan;
      }

      // apply pixel ratio

      effectiveZoom *= pixelRatio;
      effectivePan.x *= pixelRatio;
      effectivePan.y *= pixelRatio;
      
      var eles = {
        drag: {
          nodes: [],
          edges: []
        },
        nondrag: {
          nodes: [],
          edges: []
        }
      };

      function setContextTransform(context, clear){
        context.setTransform(1, 0, 0, 1, 0, 0);
        !forcedContext && (clear === undefined || clear) && context.clearRect(0, 0, r.canvasWidth, r.canvasHeight);
        
        if( !drawAllLayers ){
          context.translate(effectivePan.x, effectivePan.y);
          context.scale(effectiveZoom, effectiveZoom);
        }
        if( forcedPan ){
          context.translate(forcedPan.x, forcedPan.y);
        } 
        if( forcedZoom ){
          context.scale(forcedZoom, forcedZoom);
        }
      }

      var textureDraw = r.textureOnViewport && !forcedContext && (r.pinching || r.hoverData.dragging || r.swipePanning || r.data.wheelZooming);
      var scale;

      if( textureDraw ){

        var bb;

        if( !r.textureCache ){
          r.textureCache = {};

          bb = r.textureCache.bb = cy.boundingBox();

          var canvas = r.textureCache.texture = r.data.bufferCanvases[0];

          var cxt = canvas.getContext('2d');

          cxt.setTransform(1, 0, 0, 1, 0, 0);
          cxt.clearRect(0, 0, r.canvasWidth, r.canvasHeight);
          
          r.redraw({
            forcedContext: cxt,
            drawOnlyNodeLayer: true
          });

          var vp = r.textureCache.viewport = {
            zoom: cy.zoom(),
            pan: cy.pan(),
            width: r.canvasWidth,
            height: r.canvasHeight
          };

          vp.mpan = {
            x: (0 - vp.pan.x)/vp.zoom,
            y: (0 - vp.pan.y)/vp.zoom
          };
        }

        needDraw[CanvasRenderer.DRAG] = false;
        needDraw[CanvasRenderer.NODE] = false;

        var context = data.canvases[CanvasRenderer.NODE].getContext('2d');

        var texture = r.textureCache.texture;
        var z = cy.zoom();
        var p = cy.pan();
        var buffCanvas = r.textureCache.buffCanvas;
        var buffCxt = r.textureCache.buffCxt;
        var texture = r.textureCache.texture;
        var vp = r.textureCache.viewport;
        bb = r.textureCache.bb;

        context.setTransform(1, 0, 0, 1, 0, 0);
        context.clearRect(0, 0, vp.width, vp.height);

        var outsideBgColor = coreStyle['outside-texture-bg-color'].value;
        var outsideBgOpacity = coreStyle['outside-texture-bg-opacity'].value;
        r.fillStyle( context, outsideBgColor[0], outsideBgColor[1], outsideBgColor[2], outsideBgOpacity );
        context.fillRect( 0, 0, vp.width, vp.height );

        var pan = cy.pan();
        var zoom = cy.zoom();
        
        setContextTransform( context, false );

        context.clearRect( vp.mpan.x, vp.mpan.y, vp.width/vp.zoom/pixelRatio, vp.height/vp.zoom/pixelRatio );
        context.drawImage( texture, vp.mpan.x, vp.mpan.y, vp.width/vp.zoom/pixelRatio, vp.height/vp.zoom/pixelRatio );

      } else if( !forcedContext ){ // clear the cache since we don't need it
        r.textureCache = null;
      }

      var vpManip = (r.pinching || r.hoverData.dragging || r.swipePanning || r.data.wheelZooming || r.hoverData.draggingEles);
      var hideEdges = r.hideEdgesOnViewport && vpManip;
      var hideLabels = r.hideLabelsOnViewport && vpManip;

      if (needDraw[CanvasRenderer.DRAG] || needDraw[CanvasRenderer.NODE] || drawAllLayers || drawOnlyNodeLayer) {
        //NB : VERY EXPENSIVE
        //console.time('edgectlpts'); for( var looper = 0; looper <= looperMax; looper++ ){

        if( hideEdges ){ 
        } else {
          r.findEdgeControlPoints(edges);
        }

        //} console.timeEnd('edgectlpts')

        // console.time('sort'); for( var looper = 0; looper <= looperMax; looper++ ){
        var zEles = r.getCachedZSortedEles();
        // } console.timeEnd('sort')

        for (var i = 0; i < zEles.length; i++) {
          var ele = zEles[i];
          var list;

          if ( ele._private.rscratch.inDragLayer ) {
            list = eles.drag;
          } else {
            list = eles.nondrag;
          }

          list[ ele._private.group ].push( ele );
        }

        // console.time('updatecompounds'); for( var looper = 0; looper <= looperMax; looper++ ){
        // no need to update graph if there is no compound node
        // if ( cy.hasCompoundNodes() )
        // {
        //   r.updateAllCompounds(elements);
        // }
        // } console.timeEnd('updatecompounds')
      }
      
      
      function drawElements( list, context ){
        var edges = list.edges;
        var nodes = list.nodes;

        for (var i = 0; i < edges.length && !hideEdges; i++) {
          ele = edges[i];
          
          r.drawEdge(context, ele);
        }

        for (var i = 0; i < edges.length && !hideEdges && !hideLabels; i++) {
          ele = edges[i];
          
          r.drawEdgeText(context, ele);
        }

        for (var i = 0; i < edges.length && !hideEdges; i++) {
          ele = edges[i];
          
          r.drawEdge(context, ele, true);
        }

        for( var i = 0; i < nodes.length; i++ ){
          var ele = nodes[i];

          r.drawNode(context, ele);
          
          if( !hideLabels ){
            r.drawNodeText(context, ele);
          }
          
          r.drawNode(context, ele, true);
        }

      }


      // console.time('drawing'); for( var looper = 0; looper <= looperMax; looper++ ){
      if (needDraw[CanvasRenderer.NODE] || drawAllLayers || drawOnlyNodeLayer) {
        // console.log('redrawing node layer');
        
        var context = forcedContext || data.canvases[CanvasRenderer.NODE].getContext('2d');

        setContextTransform( context );
        drawElements(eles.nondrag, context);
        
        if( !drawAllLayers ){
          needDraw[CanvasRenderer.NODE] = false; 
        }
      }
      
      if ( !drawOnlyNodeLayer && (needDraw[CanvasRenderer.DRAG] || drawAllLayers) ) {
        
        var context = forcedContext || data.canvases[CanvasRenderer.DRAG].getContext('2d');
        
        setContextTransform( context );
        drawElements(eles.drag, context);
        
        if( !drawAllLayers ){
          needDraw[CanvasRenderer.DRAG] = false;
        }
      }
      
      if ( !drawOnlyNodeLayer && (needDraw[CanvasRenderer.SELECT_BOX] && !drawAllLayers) ) {
        // console.log('redrawing selection box');
        
        var context = forcedContext || data.canvases[CanvasRenderer.SELECT_BOX].getContext('2d');
        
        setContextTransform( context );

        if (data.select[4] == 1) {
          var zoom = data.cy.zoom();
          var borderWidth = coreStyle['selection-box-border-width'].value / zoom;
          
          context.lineWidth = borderWidth;
          context.fillStyle = "rgba(" 
            + coreStyle['selection-box-color'].value[0] + ","
            + coreStyle['selection-box-color'].value[1] + ","
            + coreStyle['selection-box-color'].value[2] + ","
            + coreStyle['selection-box-opacity'].value + ")";
          
          context.fillRect(
            data.select[0],
            data.select[1],
            data.select[2] - data.select[0],
            data.select[3] - data.select[1]);
          
          if (borderWidth > 0) {
            context.strokeStyle = "rgba(" 
              + coreStyle['selection-box-border-color'].value[0] + ","
              + coreStyle['selection-box-border-color'].value[1] + ","
              + coreStyle['selection-box-border-color'].value[2] + ","
              + coreStyle['selection-box-opacity'].value + ")";
            
            context.strokeRect(
              data.select[0],
              data.select[1],
              data.select[2] - data.select[0],
              data.select[3] - data.select[1]);
          }
        }

        if( data.bgActivePosistion ){
          var zoom = data.cy.zoom();
          var pos = data.bgActivePosistion;

          context.fillStyle = "rgba(" 
            + coreStyle['active-bg-color'].value[0] + ","
            + coreStyle['active-bg-color'].value[1] + ","
            + coreStyle['active-bg-color'].value[2] + ","
            + coreStyle['active-bg-opacity'].value + ")";

          context.beginPath();
          context.arc(pos.x, pos.y, coreStyle['active-bg-size'].pxValue / zoom, 0, 2 * Math.PI); 
          context.fill();
        }
        
        if( !drawAllLayers ){
          needDraw[CanvasRenderer.SELECT_BOX] = false; 
        }
      }

      // } console.timeEnd('drawing')

      var endTime = +new Date;

      if( r.averageRedrawTime === undefined ){
        r.averageRedrawTime = endTime - startTime;
      }

      if( r.redrawCount === undefined ){
        r.redrawCount = 0;
      }

      r.redrawCount++;

      if( r.redrawTotalTime === undefined ){
        r.redrawTotalTime = 0;
      }

      r.redrawTotalTime += endTime - startTime;

      // use a weighted average with a bias from the previous average so we don't spike so easily
      r.averageRedrawTime = r.averageRedrawTime/2 + (endTime - startTime)/2;
      //console.log('actual: %i, average: %i', endTime - startTime, this.averageRedrawTime);

      r.currentlyDrawing = false;
    }
459225
protected void paint(SeaGlassContext context, Graphics g) {
        JSeparator separator = (JSeparator) context.getComponent();

        context.getPainter().paintSeparatorForeground(context, g, 0, 0, separator.getWidth(), separator.getHeight(),
                                                      separator.getOrientation());
    }
129643
@Override
	public void paint(final RenderContext renderContext) {
		WebXmlRenderContext webRenderContext = (WebXmlRenderContext) renderContext;
		PrintWriter writer = webRenderContext.getWriter();

		beforePaint(writer);
		getBackingComponent().paint(renderContext);
		afterPaint(writer);
	}
80989
@Override
	public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
		WTabGroup group = (WTabGroup) component;
		paintChildren(group, renderContext);
	}
1032127
private void paintCells(SeaGlassContext context, Graphics g, int rMin, int rMax, int cMin, int cMax) {
        JTableHeader header        = table.getTableHeader();
        TableColumn  draggedColumn = (header == null) ? null : header.getDraggedColumn();

        TableColumnModel cm           = table.getColumnModel();
        int              columnMargin = cm.getColumnMargin();

        Rectangle   cellRect;
        TableColumn aColumn;
        int         columnWidth;

        if (table.getComponentOrientation().isLeftToRight()) {
            for (int row = rMin; row <= rMax; row++) {
                cellRect = table.getCellRect(row, cMin, false);
                for (int column = cMin; column <= cMax; column++) {
                    aColumn        = cm.getColumn(column);
                    columnWidth    = aColumn.getWidth();
                    cellRect.width = columnWidth - columnMargin;
                    if (aColumn != draggedColumn) {
                        paintCell(context, g, cellRect, row, column);
                    }

                    cellRect.x += columnWidth;
                }
            }
        } else {
            for (int row = rMin; row <= rMax; row++) {
                cellRect = table.getCellRect(row, cMin, false);
                aColumn  = cm.getColumn(cMin);
                if (aColumn != draggedColumn) {
                    columnWidth    = aColumn.getWidth();
                    cellRect.width = columnWidth - columnMargin;
                    paintCell(context, g, cellRect, row, cMin);
                }

                for (int column = cMin + 1; column <= cMax; column++) {
                    aColumn        =  cm.getColumn(column);
                    columnWidth    =  aColumn.getWidth();
                    cellRect.width =  columnWidth - columnMargin;
                    cellRect.x     -= columnWidth;
                    if (aColumn != draggedColumn) {
                        paintCell(context, g, cellRect, row, column);
                    }
                }
            }
        }

        // Paint the dragged column if we are dragging.
        if (draggedColumn != null) {
            paintDraggedArea(context, g, rMin, rMax, draggedColumn, header.getDraggedDistance());
        }

        // Remove any renderers that may be left in the rendererPane.
        rendererPane.removeAll();
    }
789615
protected void paint(SynthContext context, Graphics g) {
        JToolTip tip = (JToolTip) context.getComponent();

        Insets insets = tip.getInsets();
        View v = (View) tip.getClientProperty(BasicHTML.propertyKey);
        if (v != null) {
            Rectangle paintTextR = new Rectangle(insets.left, insets.top, tip.getWidth() - (insets.left + insets.right), tip.getHeight()
                    - (insets.top + insets.bottom));
            v.paint(g, paintTextR);
        } else {
            g.setColor(context.getStyle().getColor(context, ColorType.TEXT_FOREGROUND));
            g.setFont(style.getFont(context));
            context.getStyle().getGraphicsUtils(context).paintText(context, g, tip.getTipText(), insets.left, insets.top, -1);
        }
    }
101725
@Override
	protected void paintComponent(final RenderContext renderContext) {
		if (getState() == DISPLAY_STATE) {
			setState(ACTIVE_STATE);
			showWindow(renderContext);
		} else if (getState() == ACTIVE_STATE && isTargeted()) {
			getComponentModel().wrappedContent.paint(renderContext);
		}
	}
1349566
@Override
	public void paint(final RenderContext renderContext) {
		AjaxOperation operation = AjaxHelper.getCurrentOperation();
		if (operation == null) {
			// the request attribute that we place in the ui context in the action phase can't be null
			throw new SystemException(
					"Can't paint AJAX response. Couldn't find the expected reference to the AjaxOperation.");
		}

		if (operation.getTargetContainerId() != null) {
			paintContainerResponse(renderContext, operation);
		} else {
			paintResponse(renderContext, operation);
		}
	}
708452
public void accept(final PainterVisitor visitor, final Object group, final Bbox bounds, boolean recursive) {
		// Draw layer-specific stuff (see VectorLayerPainter)
		visitor.visit(this, group);

		// When visible, take care of fetching through an queryAndSync:
		if (recursive && isShowing()) {
			TileFunction<VectorTile> onDelete = new TileFunction<VectorTile>() {

				// When deleting a tile, delete selected features from the paint !
				public void execute(final VectorTile tile) {
					visitor.remove(tile, group);
				}
			};
			TileFunction<VectorTile> onUpdate = new TileFunction<VectorTile>() {

				// Updating a tile, re-rendering it:
				public void execute(VectorTile tile) {
					tile.accept(visitor, group, bounds, true);
				}
			};
			cache.queryAndSync(bounds, filter, onDelete, onUpdate);
			// also re-render the selected features !
			for (Feature feature : selectedFeatures.values()) {
				visitor.visit(feature, group);
			}

		}
	}
305860
private void paint(SeaGlassContext context, Graphics g) {
        String title = getTitle();

        if (title != null) {
            SynthStyle style = context.getStyle();

            Color color = style.getColor(context, ColorType.TEXT_FOREGROUND);

            // TODO style.getColor returns improper color for state? Why?
            if ((context.getComponentState() & 512) != 0) {
                Object obj = style.get(context, "[WindowFocused].textForeground");

                if (obj != null && obj instanceof Color) {
                    color = (Color) obj;
                }

                // FIXME The state *still* doesn't get the color right!!!
                color = Color.BLACK;
            }

            g.setColor(color);
            g.setFont(style.getFont(context));

            // Center text vertically.
            FontMetrics fm         = SwingUtilities2.getFontMetrics(rootPane, g);
            int         baseline   = (getHeight() + fm.getAscent() - fm.getLeading() - fm.getDescent()) / 2;
            JButton     lastButton = null;

            if (isParentIconifiable()) {
                lastButton = iconButton;
            } else if (isParentMaximizable()) {
                lastButton = maxButton;
            } else if (isParentClosable()) {
                lastButton = closeButton;
            }

            int     maxX;
            int     minX;
            boolean ltr = isParentLeftToRight();

            if (ltr) {

                if (lastButton != null) {
                    maxX = lastButton.getX() - titleSpacing;
                } else {
                    maxX = getParentWidth() - getParentInsets().right - titleSpacing;
                }

                minX = menuButton.getX() + menuButton.getWidth() + titleSpacing;
            } else {

                if (lastButton != null) {
                    minX = lastButton.getX() + lastButton.getWidth() + titleSpacing;
                } else {
                    minX = getParentInsets().left + titleSpacing;
                }

                maxX = getParentWidth() - getParentInsets().right - menuButton.getX() - titleSpacing;
            }

            String clippedTitle = getTitle(title, fm, maxX - minX);

            if (clippedTitle == title) {
                int width = style.getGraphicsUtils(context).computeStringWidth(context, g.getFont(), fm, title);

                minX = Math.max(minX, (getWidth() - width) / 2);
                minX = Math.min(maxX - width, minX);
            }

            // style.getGraphicsUtils(context).paintText(context, g,
            // clippedTitle, minX, baseline - fm.getAscent(), -1);
            ((SeaGlassGraphicsUtils) style.getGraphicsUtils(context)).drawEmphasizedText(g, color, DEFAULT_EMPHASIS_COLOR, clippedTitle,
                                                                                         minX, baseline); // - fm.getAscent());
        }
    }
823110
private void init(Context context) {
    try {
      if (FrescoSystrace.isTracing()) {
        FrescoSystrace.beginSection("DraweeView#init");
      }
      if (mInitialised) {
        return;
      }
      mInitialised = true;
      mDraweeHolder = DraweeHolder.create(null, context);
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        ColorStateList imageTintList = getImageTintList();
        if (imageTintList == null) {
          return;
        }
        setColorFilter(imageTintList.getDefaultColor());
      }
      // In Android N and above, visibility handling for Drawables has been changed, which breaks
      // activity transitions with DraweeViews.
      mLegacyVisibilityHandlingEnabled =
          sGlobalLegacyVisibilityHandlingEnabled
              && context.getApplicationInfo().targetSdkVersion >= 24; // Build.VERSION_CODES.N
    } finally {
      if (FrescoSystrace.isTracing()) {
        FrescoSystrace.endSection();
      }
    }
  }
244596
public void paint(Paintable paintable, Object group, MapContext context) {
		FeatureTransaction featureTransaction = (FeatureTransaction) paintable;

		Feature[] features = featureTransaction.getNewFeatures();
		if (features == null) {
			return;
		}
		context.getVectorContext().drawGroup(mapWidget.getGroup(RenderGroup.VECTOR), featureTransaction);
		for (int i = 0; i < features.length; i++) {
			Geometry geometry = mapWidget.getMapModel().getMapView().getWorldViewTransformer().worldToPan(
					features[i].getGeometry());
			context.getVectorContext().drawGroup(featureTransaction, features[i]);
			if (geometry instanceof Point) {
				paint(features[i], "featureTransaction.feature" + i, (Point) geometry, context.getVectorContext());
			} else if (geometry instanceof MultiPoint) {
				paint(features[i], "featureTransaction.feature" + i, (MultiPoint) geometry, context.getVectorContext());
			} else if (geometry instanceof LineString) {
				paint(features[i], "featureTransaction.feature" + i, (LineString) geometry, context.getVectorContext());
			} else if (geometry instanceof MultiLineString) {
				paint(features[i], "featureTransaction.feature" + i, (MultiLineString) geometry, context
						.getVectorContext());
			} else if (geometry instanceof Polygon) {
				paint(features[i], "featureTransaction.feature" + i, (Polygon) geometry, context.getVectorContext());
			} else if (geometry instanceof MultiPolygon) {
				paint(features[i], "featureTransaction.feature" + i, (MultiPolygon) geometry, context
						.getVectorContext());
			}
		}
	}