public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setPaint(BACKGROUND); g2.fill( new Rectangle2D.Float( 0f, 0f, (float) g2.getClipBounds().width, (float) g2.getClipBounds().height)); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); canvas.paint(g2); }
private void paintString( Graphics g, int x, int y, int width, int height, int fillStart, int amountFull, Insets b) { if (!(g instanceof Graphics2D)) { return; } Graphics2D g2D = (Graphics2D) g; String progressString = progressBar.getString(); g2D.setFont(progressBar.getFont()); Point renderLocation = getStringPlacement(g2D, progressString, x, y, width, height); Rectangle savedClip = g2D.getClipBounds(); if (progressBar.getOrientation() == JProgressBar.HORIZONTAL) { g2D.setColor(getSelectionBackground()); Utilities.drawString(progressBar, g2D, progressString, renderLocation.x, renderLocation.y); g2D.setColor(getSelectionForeground()); g2D.clipRect(fillStart, y, amountFull, height); Utilities.drawString(progressBar, g2D, progressString, renderLocation.x, renderLocation.y); } else { // VERTICAL g2D.setColor(getSelectionBackground()); AffineTransform rotate = AffineTransform.getRotateInstance(Math.PI / 2); g2D.setFont(progressBar.getFont().deriveFont(rotate)); renderLocation = getStringPlacement(g2D, progressString, x, y, width, height); Utilities.drawString(progressBar, g2D, progressString, renderLocation.x, renderLocation.y); g2D.setColor(getSelectionForeground()); g2D.clipRect(x, fillStart, width, amountFull); Utilities.drawString(progressBar, g2D, progressString, renderLocation.x, renderLocation.y); } g2D.setClip(savedClip); }
private void setGraphicsCenter(Graphics2D graphics2D, SpriteLocation center) { Rectangle screen = graphics2D.getClipBounds(); SpriteLocation screenCenter = new SpriteLocation( screen.getX() + screen.getWidth() * 0.5, screen.getY() + screen.getHeight() * 0.5); center = screenCenter.sub(center); graphics2D.translate(center.getX(), center.getY()); }
public void draw(Graphics2D g) { Rectangle2D clipBounds = g.getClipBounds(); if (clipBounds != null) { Collection<Figure> c = quadTree.findIntersects(clipBounds); Collection<Figure> toDraw = sort(c); draw(g, toDraw); } else { draw(g, children); } }
@Override protected void paintPopulatedComponent(Graphics2D graphics2D) { Rectangle clipBounds = graphics2D.getClipBounds(); LogInterval visibleInterval = visibleIntervalFor(clipBounds); List<ThreadModel> fullThreadList = fullThreadList(); getTimelineCursor().paintHighlightOn(this, graphics2D); paint( fullThreadList, minThreadIndexFor(clipBounds, fullThreadList), maxThreadIndexFor(clipBounds, fullThreadList), visibleInterval, graphics2D); getTimelineCursor().paintCursorOn(this, graphics2D); }
@Override public void draw(Graphics2D g) { double opacity = get(OPACITY); opacity = Math.min(Math.max(0d, opacity), 1d); if (opacity != 0d) { if (opacity != 1d) { Rectangle2D.Double drawingArea = getDrawingArea(); Rectangle2D clipBounds = g.getClipBounds(); if (clipBounds != null) { Rectangle2D.intersect(drawingArea, clipBounds, drawingArea); } if (!drawingArea.isEmpty()) { BufferedImage buf = new BufferedImage( (int) ((2 + drawingArea.width) * g.getTransform().getScaleX()), (int) ((2 + drawingArea.height) * g.getTransform().getScaleY()), BufferedImage.TYPE_INT_ARGB); Graphics2D gr = buf.createGraphics(); gr.scale(g.getTransform().getScaleX(), g.getTransform().getScaleY()); gr.translate((int) -drawingArea.x, (int) -drawingArea.y); gr.setRenderingHints(g.getRenderingHints()); drawFigure(gr); gr.dispose(); Composite savedComposite = g.getComposite(); g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float) opacity)); g.drawImage( buf, (int) drawingArea.x, (int) drawingArea.y, 2 + (int) drawingArea.width, 2 + (int) drawingArea.height, null); g.setComposite(savedComposite); } } else { drawFigure(g); } } }
@Override protected void paintComponent(Graphics g) { java.util.List<Network> networks = getNetworkParts(); positions = new int[networks.size()]; Graphics2D g2 = (Graphics2D) g; g2.setFont(SMALL_BOLD_FONT); g2.setPaint(addressGradientPaint); g2.fill(g2.getClipBounds()); // g2.drawImage(addressGradient, 0, 0, getWidth(), 26, null); int x = 14; for (int i = 0; i < networks.size(); i++) { Network part = networks.get(i); if (i == armed) { g2.setColor(TEXT_ARMED_COLOR); } else { g2.setColor(TEXT_NORMAL_COLOR); } String displayName = part.getDisplayName(); SwingUtils.drawShadowText(g2, displayName, x, 16); int width = (int) g2.getFontMetrics().stringWidth(displayName); x += width + 5; positions[i] = x + 10; g2.drawImage(addressArrow, x, 0, null); x += 15; } String version = Application.getInstance().getVersion(); int versionX = getWidth() - g2.getFontMetrics().stringWidth(version) - 10; SwingUtils.drawShadowText(g2, version, versionX, 16); if (renderException != null) { g2.drawImage(addressExclamation, versionX - 30, 0, null); } }
void paint(Graphics2D g) { Rectangle clip = g.getClipBounds(); if (myEditor.getContentComponent().isOpaque()) { g.setColor(myEditor.getBackgroundColor()); g.fillRect(clip.x, clip.y, clip.width, clip.height); } if (paintPlaceholderText(g)) { paintCaret(g); return; } int startLine = myView.yToVisualLine(Math.max(clip.y, 0)); int endLine = myView.yToVisualLine(Math.max(clip.y + clip.height, 0)); int startOffset = myView.visualPositionToOffset(new VisualPosition(startLine, 0)); int endOffset = myView.visualPositionToOffset(new VisualPosition(endLine + 1, 0, true)); ClipDetector clipDetector = new ClipDetector(myEditor, clip); paintBackground(g, clip, startLine, endLine); paintRightMargin(g, clip); paintCustomRenderers(g, startOffset, endOffset); MarkupModelEx docMarkup = (MarkupModelEx) DocumentMarkupModel.forDocument(myDocument, myEditor.getProject(), true); paintLineMarkersSeparators(g, clip, docMarkup, startOffset, endOffset); paintLineMarkersSeparators(g, clip, myEditor.getMarkupModel(), startOffset, endOffset); paintTextWithEffects(g, clip, startLine, endLine); paintHighlightersAfterEndOfLine(g, docMarkup, startOffset, endOffset); paintHighlightersAfterEndOfLine(g, myEditor.getMarkupModel(), startOffset, endOffset); paintBorderEffect(g, clipDetector, myEditor.getHighlighter(), startOffset, endOffset); paintBorderEffect(g, clipDetector, docMarkup, startOffset, endOffset); paintBorderEffect(g, clipDetector, myEditor.getMarkupModel(), startOffset, endOffset); paintCaret(g); paintComposedTextDecoration(g); }
/* * (non-Javadoc) * * @see * org.jvnet.flamingo.common.ui.BasicCommandButtonUI#paint(java.awt.Graphics * , javax.swing.JComponent) */ @Override public void paint(Graphics g, JComponent c) { Graphics2D g2d = (Graphics2D) g.create(); g2d.setFont( FlamingoUtilities.getFont(this.commandButton, "Ribbon.font", "Button.font", "Panel.font")); this.layoutInfo = this.layoutManager.getLayoutInfo(this.commandButton, g); commandButton.putClientProperty("icon.bounds", layoutInfo.iconRect); commandButton.putClientProperty("icon", commandButton.getIcon()); if (this.isPaintingBackground()) { this.paintButtonBackground(g2d, new Rectangle(0, 0, c.getWidth(), c.getHeight())); } // decide which command button model should be used to // compute the foreground color of the command button's text boolean useActionAreaForFg = layoutInfo.isTextInActionArea; StateTransitionTracker transitionTrackerForFg = useActionAreaForFg ? this.getActionTransitionTracker() : this.getPopupTransitionTracker(); ModelStateInfo modelStateInfoForFg = transitionTrackerForFg.getModelStateInfo(); ComponentState currStateForFg = modelStateInfoForFg.getCurrModelState(); Color fgColor = this.commandButton.getForeground(); if (fgColor instanceof UIResource) { float buttonAlpha = SubstanceColorSchemeUtilities.getAlpha(this.commandButton, currStateForFg); fgColor = SubstanceTextUtilities.getForegroundColor( this.commandButton, this.commandButton.getText(), modelStateInfoForFg, buttonAlpha); } if (layoutInfo.textLayoutInfoList != null) { for (CommandButtonLayoutManager.TextLayoutInfo mainTextLayoutInfo : layoutInfo.textLayoutInfoList) { if (mainTextLayoutInfo.text != null) { SubstanceTextUtilities.paintText( g2d, c, mainTextLayoutInfo.textRect, mainTextLayoutInfo.text, -1, g2d.getFont(), fgColor, g2d.getClipBounds()); } } } if (layoutInfo.extraTextLayoutInfoList != null) { Color disabledFgColor = SubstanceColorSchemeUtilities.getColorScheme( this.commandButton, ComponentState.DISABLED_UNSELECTED) .getForegroundColor(); float buttonAlpha = SubstanceColorSchemeUtilities.getAlpha( this.commandButton, ComponentState.DISABLED_UNSELECTED); if (buttonAlpha < 1.0f) { Color bgFillColor = SubstanceColorUtilities.getBackgroundFillColor(this.commandButton); disabledFgColor = SubstanceColorUtilities.getInterpolatedColor(disabledFgColor, bgFillColor, buttonAlpha); } if (currStateForFg.isDisabled()) { disabledFgColor = SubstanceColorUtilities.getInterpolatedColor( disabledFgColor, SubstanceColorUtilities.getBackgroundFillColor(c), 0.5); } for (CommandButtonLayoutManager.TextLayoutInfo extraTextLayoutInfo : layoutInfo.extraTextLayoutInfoList) { if (extraTextLayoutInfo.text != null) { SubstanceTextUtilities.paintText( g2d, c, extraTextLayoutInfo.textRect, extraTextLayoutInfo.text, -1, g2d.getFont(), disabledFgColor, g2d.getClipBounds()); } } } if (layoutInfo.iconRect != null) { this.paintButtonIcon(g2d, layoutInfo.iconRect); } if (layoutInfo.popupActionRect.getWidth() > 0) { paintPopupActionIcon(g2d, layoutInfo.popupActionRect); } if (this.isPaintingSeparators() && (layoutInfo.separatorArea != null)) { if (layoutInfo.separatorOrientation == CommandButtonSeparatorOrientation.HORIZONTAL) { this.paintButtonHorizontalSeparator(g2d, layoutInfo.separatorArea); } else { this.paintButtonVerticalSeparator(g2d, layoutInfo.separatorArea); } } // g2d.setColor(Color.red); // g2d.draw(layoutInfo.iconRect); // g2d.setColor(Color.blue); // if (layoutInfo.textLayoutInfoList != null) { // for (CommandButtonLayoutManager.TextLayoutInfo mainTextLayoutInfo : // layoutInfo.textLayoutInfoList) { // if (mainTextLayoutInfo.text != null) { // g2d.draw(mainTextLayoutInfo.textRect); // } // } // } // g2d.setColor(Color.magenta); // if (layoutInfo.extraTextLayoutInfoList != null) { // for (CommandButtonLayoutManager.TextLayoutInfo extraTextLayoutInfo : // layoutInfo.extraTextLayoutInfoList) { // if (extraTextLayoutInfo.text != null) { // g2d.draw(extraTextLayoutInfo.textRect); // } // } // } // g2d.setColor(Color.green); // g2d.draw(layoutInfo.popupActionRect); g2d.dispose(); }
protected void paintComponent(Graphics graphics) { if (justShown) { if (!paintTimer.isRunning()) paintTimer.start(); return; } if (!isWidthInitialized) { // Only paint if the component size has been initialized. Layout // jumps are typical the first time this component is displayed, // because the preferred height depends on the component width. return; } Graphics2D g = (Graphics2D) graphics; Rectangle clip = g.getClipBounds(); // Figure out which ImageDatums fall within the clip bounds. List<ImageDatum> datums = getAllImageData(); int[] indices = getIndices(datums.size(), clip); // Iterate backwards through indices, so repaints get enqueued // in a visually pleasing order. for (int i = indices.length - 1; i >= 0; i--) { int index = indices[i]; if (index < 0) { continue; } ImageDatum datum = datums.get(index); if (datum == null) { // A race; the image disappeared during painting. continue; } RenderedImage image = datum.getImage(this); // This queue prevents GC of recently painted images: recentImages.add(image); Rectangle rect = getBounds(index); g.setClip(clip.intersection(rect)); File file = datum.getFile(); String label = file.getName(); ImageDatumType type = datum.getType(); String tag = type.toString(); ImageMetadata meta = datum.getMetadata(true); int rating = meta.getRating(); boolean selected = selection.isSelected(datum); renderer.paint(g, image, label, tag, rating, rect, selected); ImageGroup group = datum.getGroup(); if (group.isNonTrivial()) { ImageGroupCountRenderer.paint(g, rect, datum); } } g.setClip(clip); // The control is drawn as an overlay. if (controller.isEnabled()) { Rectangle ctrlRect = controller.getRect(); if (ctrlRect != null) { if (ctrlRect.intersects(clip)) { controller.paint(g); } } } }