本文整理匯總了Java中com.intellij.util.ui.UIUtil.drawImage方法的典型用法代碼示例。如果您正苦於以下問題:Java UIUtil.drawImage方法的具體用法?Java UIUtil.drawImage怎麽用?Java UIUtil.drawImage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.util.ui.UIUtil
的用法示例。
在下文中一共展示了UIUtil.drawImage方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: paint
import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
public void paint(Graphics g) {
if (myCachedImage != null && myMagnificationPoint != null && myMagnification != 0) {
double scale = magnificationToScale(myMagnification);
int xoffset = (int)(myMagnificationPoint.x - myMagnificationPoint.x * scale);
int yoffset = (int)(myMagnificationPoint.y - myMagnificationPoint.y * scale);
Rectangle clip = g.getClipBounds();
g.setColor(Gray._120);
g.fillRect(clip.x, clip.y, clip.width, clip.height);
Graphics2D translated = (Graphics2D)g.create();
translated.translate(xoffset, yoffset);
translated.scale(scale, scale);
UIUtil.drawImage(translated, myCachedImage, 0, 0, null);
}
}
示例2: paintComponent
import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
if (myRefs != null) {
int paddingX = (myGraphImage != null ? myGraphImage.getWidth() : 0) + PrintParameters.LABEL_PADDING;
Map<String, Color> labelsForReferences = collectLabelsForRefs(myRefs);
for (Map.Entry<String, Color> entry : labelsForReferences.entrySet()) {
Dimension size = myTextLabelPainter.calculateSize(entry.getKey(), g.getFontMetrics(TextLabelPainter.getFont()));
int paddingY = (myGraphTable.getRowHeight() - size.height) / 2;
myTextLabelPainter.paint((Graphics2D)g, entry.getKey(), paddingX, paddingY, entry.getValue());
paddingX += size.width + PrintParameters.LABEL_PADDING;
}
}
if (myGraphImage != null) {
UIUtil.drawImage(g, myGraphImage.getImage(), 0, 0, null);
}
else { // TODO temporary diagnostics: why does graph sometimes disappear
LOG.error("Image is null");
}
}
示例3: paintClipped
import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
/** Paints a rendered device image into the given graphics context */
public static void paintClipped(@NotNull Graphics2D g,
@NotNull BufferedImage image,
@Nullable Device device,
int x,
int y,
boolean withRetina) {
Shape prevClip = null;
Shape clip = getClip(device, x, y, image.getWidth(), image.getHeight());
if (clip != null) {
prevClip = g.getClip();
g.setClip(clip);
}
if (withRetina) {
//noinspection ConstantConditions
UIUtil.drawImage(g, image, x, y, null);
} else {
g.drawImage(image, x, y, null);
}
if (clip != null) {
g.setClip(prevClip);
}
}
示例4: createRectangularDropShadow
import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
/**
* Draws a rectangular drop shadow (of size {@link #SHADOW_SIZE} by
* {@link #SHADOW_SIZE} around the given source and returns a new image with
* both combined
*
* @param source the source image
* @return the source image with a drop shadow on the bottom and right
*/
public static BufferedImage createRectangularDropShadow(BufferedImage source) {
int type = source.getType();
if (type == BufferedImage.TYPE_CUSTOM) {
type = BufferedImage.TYPE_INT_ARGB;
}
int width = source.getWidth();
int height = source.getHeight();
BufferedImage image;
if (ImageUtils.isRetinaImage(source)) {
image = ImageUtils.createDipImage(width + SHADOW_SIZE, height + SHADOW_SIZE, type);
} else {
//noinspection UndesirableClassUsage
image = new BufferedImage(width + SHADOW_SIZE, height + SHADOW_SIZE, type);
}
Graphics g = image.getGraphics();
//noinspection ConstantConditions
UIUtil.drawImage(g, source, 0, 0, null);
drawRectangleShadow(image, 0, 0, width, height);
g.dispose();
return image;
}
示例5: createSmallRectangularDropShadow
import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
/**
* Draws a small rectangular drop shadow (of size {@link #SMALL_SHADOW_SIZE} by
* {@link #SMALL_SHADOW_SIZE} around the given source and returns a new image with
* both combined
*
* @param source the source image
* @return the source image with a drop shadow on the bottom and right
*/
public static BufferedImage createSmallRectangularDropShadow(BufferedImage source) {
int type = source.getType();
if (type == BufferedImage.TYPE_CUSTOM) {
type = BufferedImage.TYPE_INT_ARGB;
}
int width = source.getWidth();
int height = source.getHeight();
BufferedImage image;
if (ImageUtils.isRetinaImage(source)) {
image = ImageUtils.createDipImage(width + SMALL_SHADOW_SIZE, height + SMALL_SHADOW_SIZE, type);
} else {
//noinspection UndesirableClassUsage
image = new BufferedImage(width + SMALL_SHADOW_SIZE, height + SMALL_SHADOW_SIZE, type);
}
Graphics g = image.getGraphics();
//noinspection ConstantConditions
UIUtil.drawImage(g, source, 0, 0, null);
drawSmallRectangleShadow(image, 0, 0, width, height);
g.dispose();
return image;
}
示例6: paintComponent
import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
@Override
protected void paintComponent(Graphics g) {
Rectangle r = getBounds();
Graphics2D g2d = (Graphics2D)g;
Shape clip = g2d.getClip();
ToolWindowType type = myToolWindow.getType();
Image image;
if (isActive()) {
if (myActiveImage == null || /*myActiveImage.getHeight() != r.height ||*/ type != myImageType) {
myActiveImage = drawToBuffer(true, r.height, myToolWindow.getType() == ToolWindowType.FLOATING);
}
image = myActiveImage;
} else {
if (myImage == null || /*myImage.getHeight() != r.height ||*/ type != myImageType) {
myImage = drawToBuffer(false, r.height, myToolWindow.getType() == ToolWindowType.FLOATING);
}
image = myImage;
}
myImageType = myToolWindow.getType();
Rectangle clipBounds = clip.getBounds();
for (int x = clipBounds.x; x < clipBounds.x + clipBounds.width; x+=150) {
UIUtil.drawImage(g, image, x, 0, null);
}
}
示例7: paintComponent
import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
@Override
public void paintComponent(Graphics g) {
if (!isToDrawCombo()) return;
Rectangle r = myComboLabel.getBounds();
if (UIUtil.isUnderDarcula()) {
g.setColor(ColorUtil.toAlpha(UIUtil.getLabelForeground(), 20));
g.drawLine(r.width, 0, r.width, r.height);
g.setColor(ColorUtil.toAlpha(UIUtil.getBorderColor(), 50));
g.drawLine(r.width-1, 0, r.width-1, r.height);
return;
}
if (myImage == null || myImage.getHeight() != r.height || myImage.getWidth() != r.width) {
myImage = UIUtil.createImage(r.width, r.height, BufferedImage.TYPE_INT_ARGB);
final Graphics2D g2d = myImage.createGraphics();
final GraphicsConfig c = new GraphicsConfig(g);
c.setAntialiasing(true);
g2d.setPaint(UIUtil.getGradientPaint(0, 0, new Color(0, 0, 0, 10), 0, r.height, new Color(0, 0, 0, 30)));
g2d.fillRect(0, 0, r.width, r.height);
g2d.setColor(new Color(0, 0, 0, 60));
g2d.drawLine(0, 0, 0, r.height);
g2d.drawLine(r.width - 1, 0, r.width - 1, r.height);
g2d.setColor(new Color(255, 255, 255, 80));
g2d.drawRect(1, 0, r.width - 3, r.height - 1);
g2d.dispose();
}
UIUtil.drawImage(g, myImage, isIdVisible() ? r.x : r.x - 2, r.y, null);
}
示例8: paintComponent
import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
@Override
public void paintComponent(Graphics g) {
if (!isToDrawTabs()) return;
boolean prevSelected = false;
for (int i = 0; i < myTabs.size(); i++) {
boolean last = (i == myTabs.size() - 1) || ((i + 1 < myTabs.size() && myTabs.get(i + 1).getBounds().width == 0));
ContentTabLabel each = myTabs.get(i);
Rectangle r = each.getBounds();
StringBuilder key = new StringBuilder().append(i);
if (each.isSelected()) key.append('s');
if (prevSelected) key.append('p');
if (last) key.append('l');
if (myUi.myWindow.isActive()) key.append('a');
BufferedImage image = myCached.get(key.toString());
if (image == null || image.getWidth() != r.width || image.getHeight() != r.height) {
image = drawToBuffer(r, each.isSelected(), last, prevSelected, myUi.myWindow.isActive());
myCached.put(key.toString(), image);
}
if (image != null) {
UIUtil.drawImage(g, image, isIdVisible() ? r.x : r.x - 2, r.y, null);
}
prevSelected = each.isSelected();
}
}
示例9: paintComponent
import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
@Override
protected void paintComponent(final Graphics g) {
final Graphics2D g2 = (Graphics2D) g;
if (shadow != null) {
UIUtil.drawImage(g2, shadow, 0, 0, null);
}
super.paintComponent(g);
}
示例10: doPaintTrack
import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
@Override
protected void doPaintTrack(@NotNull Graphics g, @NotNull JComponent c, @NotNull Rectangle bounds) {
if (isMacScrollbarHiddenAndXcodeLikeScrollbar()) {
paintTrackBasement(g, bounds);
return;
}
Rectangle clip = g.getClipBounds().intersection(bounds);
if (clip.height == 0) return;
Rectangle componentBounds = c.getBounds();
ProperTextRange docRange = ProperTextRange.create(0, componentBounds.height);
if (myCachedTrack == null || myCachedHeight != componentBounds.height) {
myCachedTrack = UIUtil.createImage(componentBounds.width, componentBounds.height, BufferedImage.TYPE_INT_ARGB);
myCachedHeight = componentBounds.height;
myDirtyYPositions = docRange;
paintTrackBasement(myCachedTrack.getGraphics(), new Rectangle(0, 0, componentBounds.width, componentBounds.height));
}
if (myDirtyYPositions == WHOLE_DOCUMENT) {
myDirtyYPositions = docRange;
}
if (myDirtyYPositions != null) {
final Graphics2D imageGraphics = myCachedTrack.createGraphics();
((ApplicationImpl)ApplicationManager.getApplication()).editorPaintStart();
try {
myDirtyYPositions = myDirtyYPositions.intersection(docRange);
if (myDirtyYPositions == null) myDirtyYPositions = docRange;
repaint(imageGraphics, componentBounds.width, myDirtyYPositions);
myDirtyYPositions = null;
}
finally {
((ApplicationImpl)ApplicationManager.getApplication()).editorPaintFinish();
}
}
UIUtil.drawImage(g, myCachedTrack, null, 0, 0);
}
示例11: updatePipette
import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
private void updatePipette() {
Dialog pickerDialog = getPickerDialog();
if (pickerDialog != null && pickerDialog.isShowing()) {
Point mouseLoc = updateLocation();
if (mouseLoc == null) return;
final Color c = myRobot.getPixelColor(mouseLoc.x, mouseLoc.y);
if (!c.equals(getColor()) || !mouseLoc.equals(myPreviousLocation)) {
setColor(c);
myPreviousLocation.setLocation(mouseLoc);
myCaptureRect.setLocation(mouseLoc.x - 2, mouseLoc.y - 2);
myCaptureRect.setBounds(mouseLoc.x - 2, mouseLoc.y - 2, 5, 5);
BufferedImage capture = myRobot.createScreenCapture(myCaptureRect);
// Clear the cursor graphics
myGraphics.setComposite(AlphaComposite.Src);
myGraphics.setColor(UIUtil.TRANSPARENT_COLOR);
myGraphics.fillRect(0, 0, myImage.getWidth(), myImage.getHeight());
myGraphics.drawImage(capture, myZoomRect.x, myZoomRect.y, myZoomRect.width, myZoomRect.height, this);
// cropping round image
myGraphics.setComposite(AlphaComposite.getInstance(AlphaComposite.DST_OUT));
myGraphics.drawImage(myMaskImage, myZoomRect.x, myZoomRect.y, myZoomRect.width, myZoomRect.height, this);
// paint magnifier
myGraphics.setComposite(AlphaComposite.SrcOver);
UIUtil.drawImage(myGraphics, myPipetteImage, SIZE - AllIcons.Ide.Pipette.getIconWidth(), 0, this);
pickerDialog.setCursor(myParent.getToolkit().createCustomCursor(myImage, HOT_SPOT, "ColorPicker"));
notifyListener(c, 300);
}
}
}
示例12: doPaintNavBarItem
import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
@Override
public void doPaintNavBarItem(Graphics2D g, NavBarItem item, NavBarPanel navbar) {
final boolean floating = navbar.isInFloatingMode();
boolean toolbarVisible = UISettings.getInstance().SHOW_MAIN_TOOLBAR;
final boolean selected = item.isSelected() && item.isFocused();
boolean nextSelected = item.isNextSelected() && navbar.hasFocus();
Map<ImageType, BufferedImage> cached = myCache.get(item);
ImageType type;
if (floating) {
type = selected ? ImageType.ACTIVE_FLOATING : nextSelected ? ImageType.NEXT_ACTIVE_FLOATING : ImageType.INACTIVE_FLOATING;
} else {
if (toolbarVisible) {
type = selected ? ImageType.ACTIVE : nextSelected ? ImageType.NEXT_ACTIVE : ImageType.INACTIVE;
} else {
type = selected ? ImageType.ACTIVE_NO_TOOLBAR : nextSelected ? ImageType.NEXT_ACTIVE_NO_TOOLBAR : ImageType.INACTIVE_NO_TOOLBAR;
}
}
if (cached == null) {
cached = new HashMap<ImageType, BufferedImage>();
myCache.put(item, cached);
}
BufferedImage image = cached.get(type);
if (image == null) {
image = drawToBuffer(item, floating, toolbarVisible, selected, navbar);
cached.put(type, image);
}
UIUtil.drawImage(g, image, 0, 0, null);
Icon icon = item.getIcon();
final int offset = item.isFirstElement() ? getFirstElementLeftOffset() : 0;
final int iconOffset = getElementPadding().left + offset;
icon.paintIcon(item, g, iconOffset, (item.getHeight() - icon.getIconHeight()) / 2);
final int textOffset = icon.getIconWidth() + getElementPadding().width() + offset;
item.doPaintText(g, textOffset);
}
示例13: paintComponent
import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
@Override
protected void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D)g;
Image image = drawToBuffer(getBounds().height);
Rectangle clipBounds = g2d.getClip().getBounds();
for (int x = clipBounds.x; x < clipBounds.x + clipBounds.width; x += 150) {
//noinspection ConstantConditions
UIUtil.drawImage(g, image, x, 0, null);
}
}
示例14: paint
import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
public final void paint(final Graphics g) {
final Rectangle bounds = getBounds();
if (myAnchor == ToolWindowAnchor.LEFT) {
if (myDirection == 1) {
g.setClip(null);
g.clipRect(myOffset, 0, bounds.width - myOffset, bounds.height);
UIUtil.drawImage(g, myBottomImage, 0, 0, null);
g.setClip(null);
g.clipRect(0, 0, myOffset, bounds.height);
UIUtil.drawImage(g, myTopImage, myOffset - bounds.width, 0, null);
}
else {
g.setClip(null);
g.clipRect(bounds.width - myOffset, 0, myOffset, bounds.height);
UIUtil.drawImage(g, myBottomImage, 0, 0, null);
g.setClip(null);
g.clipRect(0, 0, bounds.width - myOffset, bounds.height);
UIUtil.drawImage(g, myTopImage, -myOffset, 0, null);
}
myTopImage.flush();
}
else if (myAnchor == ToolWindowAnchor.RIGHT) {
if (myDirection == 1) {
g.setClip(null);
g.clipRect(0, 0, bounds.width - myOffset, bounds.height);
UIUtil.drawImage(g, myBottomImage, 0, 0, null);
g.setClip(null);
g.clipRect(bounds.width - myOffset, 0, myOffset, bounds.height);
UIUtil.drawImage(g, myTopImage, bounds.width - myOffset, 0, null);
}
else {
g.setClip(null);
g.clipRect(0, 0, myOffset, bounds.height);
UIUtil.drawImage(g, myBottomImage, 0, 0, null);
g.setClip(null);
g.clipRect(myOffset, 0, bounds.width - myOffset, bounds.height);
UIUtil.drawImage(g, myTopImage, myOffset, 0, null);
}
}
else if (myAnchor == ToolWindowAnchor.TOP) {
if (myDirection == 1) {
g.setClip(null);
g.clipRect(0, myOffset, bounds.width, bounds.height - myOffset);
UIUtil.drawImage(g, myBottomImage, 0, 0, null);
g.setClip(null);
g.clipRect(0, 0, bounds.width, myOffset);
UIUtil.drawImage(g, myTopImage, 0, -bounds.height + myOffset, null);
}
else {
g.setClip(null);
g.clipRect(0, bounds.height - myOffset, bounds.width, myOffset);
UIUtil.drawImage(g, myBottomImage, 0, 0, null);
g.setClip(null);
g.clipRect(0, 0, bounds.width, bounds.height - myOffset);
UIUtil.drawImage(g, myTopImage, 0, -myOffset, null);
}
}
else if (myAnchor == ToolWindowAnchor.BOTTOM) {
if (myDirection == 1) {
g.setClip(null);
g.clipRect(0, 0, bounds.width, bounds.height - myOffset);
UIUtil.drawImage(g, myBottomImage, 0, 0, null);
g.setClip(null);
g.clipRect(0, bounds.height - myOffset, bounds.width, myOffset);
UIUtil.drawImage(g, myTopImage, 0, bounds.height - myOffset, null);
}
else {
g.setClip(null);
g.clipRect(0, 0, bounds.width, myOffset);
UIUtil.drawImage(g, myBottomImage, 0, 0, null);
g.setClip(null);
g.clipRect(0, myOffset, bounds.width, bounds.height - myOffset);
UIUtil.drawImage(g, myTopImage, 0, myOffset, null);
}
}
}
示例15: paintComponent
import com.intellij.util.ui.UIUtil; //導入方法依賴的package包/類
@Override
protected void paintComponent(Graphics g) {
Insets insets = getInsets();
UIUtil.drawImage(g, myImage, insets.left, insets.top, null);
}