use of java.awt.Toolkit in project adempiere by adempiere.
the class Env method getImage.
// getParent
/**************************************************************************
* Get Image with File name
*
* @param fileNameInImageDir full file name in imgaes folder (e.g. Bean16.gif)
* @return image
*/
public static Image getImage(String fileNameInImageDir) {
URL url = Adempiere.class.getResource("images/" + fileNameInImageDir);
if (url == null) {
s_log.log(Level.SEVERE, "Not found: " + fileNameInImageDir);
return null;
}
Toolkit tk = Toolkit.getDefaultToolkit();
return tk.getImage(url);
}
use of java.awt.Toolkit in project adempiere by adempiere.
the class MPrintTableFormat method getImage.
// get
/**
* Get the Image
* @return image
*/
public Image getImage() {
if (m_image != null) {
return m_image;
}
//
if (isImageIsAttached()) {
MAttachment attachment = MAttachment.get(getCtx(), Table_ID, get_ID());
if (attachment == null) {
log.log(Level.WARNING, "No Attachment - ID=" + get_ID());
return null;
}
if (attachment.getEntryCount() != 1) {
log.log(Level.WARNING, "Need just 1 Attachment Entry = " + attachment.getEntryCount());
return null;
}
byte[] imageData = attachment.getEntryData(0);
if (imageData != null) {
m_image = Toolkit.getDefaultToolkit().createImage(imageData);
}
if (m_image != null) {
log.fine(attachment.getEntryName(0) + " - Size=" + imageData.length);
} else {
log.log(Level.WARNING, attachment.getEntryName(0) + " - not loaded (must be gif or jpg) - ID=" + get_ID());
}
} else if (getImageURL() != null) {
URL url;
try {
url = new URL(getImageURL());
Toolkit tk = Toolkit.getDefaultToolkit();
m_image = tk.getImage(url);
} catch (MalformedURLException e) {
log.log(Level.WARNING, "Malformed URL - " + getImageURL(), e);
}
}
return m_image;
}
use of java.awt.Toolkit in project adempiere by adempiere.
the class Adempiere method getImageLogoSmall.
// getImage16
/**
* Get 28*15 Logo Image.
* @param hr high resolution
* @return Image Icon
*/
public static Image getImageLogoSmall(boolean hr) {
if (s_image48x15 == null) {
Toolkit tk = Toolkit.getDefaultToolkit();
URL url = null;
if (hr)
url = org.compiere.Adempiere.class.getResource(s_file48x15HR);
else
url = org.compiere.Adempiere.class.getResource(s_file48x15);
// System.out.println(url);
if (url == null)
return null;
s_image48x15 = tk.getImage(url);
}
return s_image48x15;
}
use of java.awt.Toolkit in project adempiere by adempiere.
the class PrintElement method waitForLoad.
// imageUpdate
/**
* Wait until Image is loaded.
* @param image image
* @return true if loaded
*/
public boolean waitForLoad(Image image) {
long start = System.currentTimeMillis();
Thread.yield();
int count = 0;
try {
Toolkit toolkit = Toolkit.getDefaultToolkit();
while (// ImageObserver calls imageUpdate
!toolkit.prepareImage(image, -1, -1, this)) {
// Timeout
if (// about 20+ sec overall
count > 1000) {
log.severe(this + " - Timeout - " + (System.currentTimeMillis() - start) + "ms - #" + count);
return false;
}
try {
if (count < 10)
Thread.sleep(10);
else if (count < 100)
Thread.sleep(15);
else
Thread.sleep(20);
} catch (InterruptedException ex) {
log.log(Level.SEVERE, "", ex);
break;
}
count++;
}
} catch (// java.lang.SecurityException
Exception e) {
log.log(Level.SEVERE, "", e);
return false;
}
if (count > 0)
log.fine((System.currentTimeMillis() - start) + "ms - #" + count);
return true;
}
use of java.awt.Toolkit in project bigbluebutton by bigbluebutton.
the class WindowlessFrame method centerOnScreen.
public final void centerOnScreen() {
Toolkit kit = mLeftBorder.getToolkit();
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gs = ge.getScreenDevices();
Insets in = kit.getScreenInsets(gs[0].getDefaultConfiguration());
Dimension d = kit.getScreenSize();
int maxWidth = (d.width - in.left - in.right);
int maxHeight = (d.height - in.top - in.bottom);
setLocation((int) (maxWidth - mOverallSize.width) / 2, (int) (maxHeight - mOverallSize.height) / 2);
}
Aggregations