java中getimag什么意思_Java ImageIcon.getImage方法代碼示例

本文整理匯總了Java中javax.swing.ImageIcon.getImage方法的典型用法代碼示例。如果您正苦於以下問題:Java ImageIcon.getImage方法的具體用法?Java ImageIcon.getImage怎麽用?Java ImageIcon.getImage使用的例子?那麽恭喜您, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.ImageIcon的用法示例。

在下文中一共展示了ImageIcon.getImage方法的19個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼示例。

示例1: getLogo

​點讚 4

import javax.swing.ImageIcon; //導入方法依賴的package包/類

/**

* Returns the JFreeChart logo (a picture of a gorilla).

*

* @return the JFreeChart logo.

*/

public Image getLogo() {

Image logo = super.getLogo();

if (logo == null) {

URL imageURL = ClassLoader.getSystemResource("org/jfree/chart/gorilla.jpg");

if (imageURL != null) {

ImageIcon temp = new ImageIcon(imageURL); // use ImageIcon because it waits for

// the image to load...

logo = temp.getImage();

setLogo(logo);

}

}

return logo;

}

開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:21,

示例2: aplicaTransparencia

​點讚 3

import javax.swing.ImageIcon; //導入方法依賴的package包/類

/**

* Aplica transparência a uma determinada cor

*

* @param image imagem a ser editada

* @param keyColor cor a se tornar transparente

* @return imagem editada

*/

public static ImageIcon aplicaTransparencia(ImageIcon image, Color keyColor) {

try {

Image img = image.getImage();

int w = img.getWidth(null);

int h = img.getHeight(null);

int[] pxls = getPixels(img);

for (int i = 0; i < pxls.length; i++) {

if (pxls[i] == keyColor.getRGB()) {

pxls[i] = 0x00ffffff;

}

}

return new ImageIcon(getImage(pxls, w, h));

} catch (Exception e) {

e.printStackTrace();

return image;

}

}

開發者ID:limagiran,項目名稱:hearthstone,代碼行數:25,

示例3: ImageLabel

​點讚 2

import javax.swing.ImageIcon; //導入方法依賴的package包/類

public ImageLabel( String url, ImageIcon img, String description ) {

super( new MaxSizeImageIcon(img.getImage()) );

this.url = url;

if( null != description )

setToolTipText( "" + description ); //NOI18N

setOpaque( false );

setBorder( BorderFactory.createEmptyBorder(1,1,1,1) );

addMouseListener( this );

setCursor( Cursor.getPredefinedCursor(Cursor.HAND_CURSOR) );

}

開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:11,

示例4: loadImageAwt

​點讚 2

import javax.swing.ImageIcon; //導入方法依賴的package包/類

/** Loads the image from this directory, please put all images in the class

* package.

*

* @param imageName string containing the image name

* @return the image

*/

public static Image loadImageAwt(String imageName) {

ImageIcon img = imageLoader.loadIcon(imageName);

if (img != null) {

return img.getImage();

} else {

return null;

}

}

開發者ID:max6cn,項目名稱:jmt,代碼行數:15,

示例5: loadIcon

​點讚 2

import javax.swing.ImageIcon; //導入方法依賴的package包/類

/**

* Loads an icon with specified name and caches it, then resizes it.

* @param iconName name of the icon to be loaded. Extensions are automatically added, if needed.

* @param size target dimension of image. a negative number means to maintain aspect ratio on that dimension

* @return icon if found, null otherwise

*/

public ImageIcon loadIcon(String iconName, Dimension size) {

ImageIcon im = loadIcon(iconName);

if (im != null) {

Image scaled = im.getImage();

scaled = scaled.getScaledInstance(size.width, size.height, Image.SCALE_SMOOTH);

return new ImageIcon(scaled);

} else {

return im;

}

}

開發者ID:max6cn,項目名稱:jmt,代碼行數:17,

示例6: convertToBufferedImage

​點讚 2

import javax.swing.ImageIcon; //導入方法依賴的package包/類

/**

* Converts the icon in labelMap in a buffered image.

*

* @param labelMap

* @return

*/

private static BufferedImage convertToBufferedImage(JLabel labelMap) {

ImageIcon imgIcon = ((ImageIcon) labelMap.getIcon());

Image image = imgIcon.getImage();

BufferedImage newImage = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_ARGB);

Graphics2D g = newImage.createGraphics();

g.drawImage(image, 0, 0, null);

g.dispose();

return newImage;

}

開發者ID:IngSW-unipv,項目名稱:Progetto-B,代碼行數:16,

示例7: afficheRune

​點讚 2

import javax.swing.ImageIcon; //導入方法依賴的package包/類

private void afficheRune(String url){

java.net.URL imageURL = Main.class.getResource(url);

ImageIcon icon = new ImageIcon(imageURL);

if (url.equals("/images/stele.png")){

java.awt.Image imagePhoto=icon.getImage();

imagePhoto=imagePhoto.getScaledInstance(88,112,java.awt.Image.SCALE_SMOOTH);

icon.setImage(imagePhoto);

}

runeLbl.setIcon(icon);

}

開發者ID:Denis-Bonnot-project,項目名稱:Jeu-de-runes,代碼行數:11,

示例8: colorize

​點讚 2

import javax.swing.ImageIcon; //導入方法依賴的package包/類

private ImageIcon colorize(ImageIcon icon, Color color) {

int[] pixels = new int[icon.getIconHeight() * icon.getIconWidth()];

try {

PixelGrabber grabber = new PixelGrabber(icon.getImage(), 0, 0, icon.getIconWidth(),

icon.getIconHeight(), pixels, 0,

icon.getIconWidth());

grabber.grabPixels();

int r = color.getRed();

int g = color.getGreen();

int b = color.getBlue();

int pixel;

for (int i = 0, acm; i < pixels.length; i++) {

pixel = pixels[i];

int alpha = (pixel >> 24) & 0xff;

int red = (pixel >> 16) & 0xff;

int green = (pixel >> 8) & 0xff;

int blue = pixel & 0xff;

acm = (blue + green + red) / 3;

int max = 255;

pixels[i] = (((acm * r)/max) << 16) + (((acm * g)/max) << 8) + ((acm * b)/max) + (alpha << 24);

}

} catch (InterruptedException ex) {

ex.printStackTrace();

}

MemoryImageSource mis = new MemoryImageSource(icon.getIconWidth(),

icon.getIconHeight(),

pixels, 0,

icon.getIconWidth());

return new ImageIcon(component.createImage(mis));

}

開發者ID:adbenitez,項目名稱:jNotifyOSD,代碼行數:32,

示例9: attachIcon

​點讚 2

import javax.swing.ImageIcon; //導入方法依賴的package包/類

public static void attachIcon(Window frame) {

if (ICONS == null) {

List loadedIcons = new ArrayList();

ClassLoader loader = LFrame.class.getClassLoader();

for (int size : SIZES) {

URL url = loader.getResource(PATH + size + ".png");

if (url != null) {

ImageIcon icon = new ImageIcon(url);

loadedIcons.add(icon.getImage());

if (size == DEFAULT_SIZE) {

DEFAULT_ICON = icon.getImage();

}

}

}

ICONS = loadedIcons;

}

boolean success = false;

try {

if (ICONS != null && !ICONS.isEmpty()) {

Method set = frame.getClass().getMethod("setIconImages", List.class);

set.invoke(frame, ICONS);

success = true;

}

} catch (Exception e) {

}

if (!success && frame instanceof JFrame && DEFAULT_ICON != null) {

((JFrame) frame).setIconImage(DEFAULT_ICON);

}

}

開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:32,

示例10: createCursor

​點讚 2

import javax.swing.ImageIcon; //導入方法依賴的package包/類

/** Creates a named cursor from a given file. */

static private Cursor createCursor(String name, ImageIcon icon) {

if (GraphicsEnvironment.isHeadless()) {

// The environtment variable DISPLAY is not set. We can't call

// createCustomCursor from the awt toolkit because this causes

// a java.awt.HeadlessException. In any case we don't need the

// cursor because we are running without GUI, so we just abort.

return null;

} else {

Toolkit tk = Toolkit.getDefaultToolkit();

Image cursorImage = icon.getImage();

return tk.createCustomCursor(cursorImage, new Point(0, 0), name);

}

}

開發者ID:meteoorkip,項目名稱:JavaGraph,代碼行數:15,

示例11: returnBoxImage

​點讚 2

import javax.swing.ImageIcon; //導入方法依賴的package包/類

public Image returnBoxImage() {

ImageIcon i = new ImageIcon(getClass().getResource(imagePathBox));

return i.getImage();

}

開發者ID:dviol,項目名稱:Project15,代碼行數:6,

示例12: returnBlueImage

​點讚 2

import javax.swing.ImageIcon; //導入方法依賴的package包/類

public Image returnBlueImage() {

ImageIcon i = new ImageIcon(getClass().getResource(imagePathBlueKey));

return i.getImage();

}

開發者ID:dviol,項目名稱:Project15,代碼行數:6,

示例13: returnYellowImage

​點讚 2

import javax.swing.ImageIcon; //導入方法依賴的package包/類

public Image returnYellowImage() {

ImageIcon i = new ImageIcon(getClass().getResource(imagePathYellowKey));

return i.getImage();

}

開發者ID:dviol,項目名稱:Project15,代碼行數:6,

示例14: returnGreenImage

​點讚 2

import javax.swing.ImageIcon; //導入方法依賴的package包/類

public Image returnGreenImage() {

ImageIcon i = new ImageIcon(getClass().getResource(imagePathGreenKey));

return i.getImage();

}

開發者ID:dviol,項目名稱:Project15,代碼行數:6,

示例15: returnPinkImage

​點讚 2

import javax.swing.ImageIcon; //導入方法依賴的package包/類

public Image returnPinkImage() {

ImageIcon i = new ImageIcon(getClass().getResource(imagePathPinkKey));

return i.getImage();

}

開發者ID:dviol,項目名稱:Project15,代碼行數:6,

示例16: returnSilverImage

​點讚 2

import javax.swing.ImageIcon; //導入方法依賴的package包/類

public Image returnSilverImage() {

ImageIcon i = new ImageIcon(getClass().getResource(imagePathSilverKey));

return i.getImage();

}

開發者ID:dviol,項目名稱:Project15,代碼行數:6,

示例17: returnOrangeImage

​點讚 2

import javax.swing.ImageIcon; //導入方法依賴的package包/類

public Image returnOrangeImage() {

ImageIcon i = new ImageIcon(getClass().getResource(imagePathOrangeKey));

return i.getImage();

}

開發者ID:dviol,項目名稱:Project15,代碼行數:6,

示例18: getObstacleImage

​點讚 1

import javax.swing.ImageIcon; //導入方法依賴的package包/類

public Image getObstacleImage() {

ImageIcon i = new ImageIcon(getClass().getResource(imagePath));

return i.getImage();

}

開發者ID:dviol,項目名稱:Project15,代碼行數:7,

示例19: getImage

​點讚 1

import javax.swing.ImageIcon; //導入方法依賴的package包/類

public Image getImage() {

ImageIcon i = new ImageIcon(getClass().getResource(imagePath));

return i.getImage();

}

開發者ID:dviol,項目名稱:Project15,代碼行數:7,

注:本文中的javax.swing.ImageIcon.getImage方法示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Java的复数类可以用来进行复数运算和处理。以下是Java复数类的总结: 1. Java自带的复数类:Java自带了Complex类,可以通过导入java.util.Complex包来使用。 2. 复数类的定义:复数类通常由实部和虚部组成,可以定义一个复数类来表示这两个部分。例如: ```java public class Complex { private double real; private double imag; // 构造方法 public Complex(double real, double imag) { this.real = real; this.imag = imag; } // getter和setter方法 public double getReal() { return real; } public void setReal(double real) { this.real = real; } public double getImag() { return imag; } public void setImag(double imag) { this.imag = imag; } } ``` 3. 复数类的运算:复数类可以进行加、减、乘、除等运算,例如: ```java public Complex add(Complex other) { double real = this.real + other.real; double imag = this.imag + other.imag; return new Complex(real, imag); } public Complex subtract(Complex other) { double real = this.real - other.real; double imag = this.imag - other.imag; return new Complex(real, imag); } public Complex multiply(Complex other) { double real = this.real * other.real - this.imag * other.imag; double imag = this.real * other.imag + this.imag * other.real; return new Complex(real, imag); } public Complex divide(Complex other) { double real = (this.real * other.real + this.imag * other.imag) / (Math.pow(other.real, 2) + Math.pow(other.imag, 2)); double imag = (this.imag * other.real - this.real * other.imag) / (Math.pow(other.real, 2) + Math.pow(other.imag, 2)); return new Complex(real, imag); } ``` 4. 复数类的常用方法:复数类还可以实现一些常用方法,例如获取模长和相角,例如: ```java public double getModulus() { return Math.sqrt(Math.pow(this.real, 2) + Math.pow(this.imag, 2)); } public double getArgument() { return Math.atan2(this.imag, this.real); } ``` 5. 复数类的使用:定义好复数类后,就可以通过实例化对象来进行复数运算,例如: ```java Complex c1 = new Complex(2, 3); Complex c2 = new Complex(4, -2); Complex sum = c1.add(c2); Complex difference = c1.subtract(c2); Complex product = c1.multiply(c2); Complex quotient = c1.divide(c2); double modulus = c1.getModulus(); double argument = c1.getArgument(); ``` 以上就是Java复数类的总结。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值