use of java.awt.Toolkit in project yyl_example by Relucent.
the class ThumbnailatorExample method display.
private static void display(Image original, Image processed) {
@SuppressWarnings("serial")
class ImageCanvas extends Canvas {
private final Image image;
public ImageCanvas(Image image) {
this.image = image;
}
@Override
public void paint(Graphics g) {
super.paint(g);
g.drawImage(image, 0, 0, this);
}
}
Frame frame = new Frame();
frame.setLayout(new GridLayout(1, 2));
frame.add(new ImageCanvas(original));
frame.add(new ImageCanvas(processed));
frame.setTitle("Thumbnailator");
frame.setResizable(false);
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
int width = 520;
int height = 300;
Toolkit kit = Toolkit.getDefaultToolkit();
Dimension screen = kit.getScreenSize();
frame.setBounds((screen.width - width) / 2, (screen.height - height) / 2, 520, 300);
frame.setVisible(true);
}
use of java.awt.Toolkit in project sulky by huxi.
the class TaskManagerTest method setUp.
@Before
public void setUp() {
Toolkit tk = Toolkit.getDefaultToolkit();
if (logger.isDebugEnabled())
logger.debug("Toolkit: {}", tk);
instance = new TaskManager<>();
taskName = "TaskName";
}
use of java.awt.Toolkit in project ginkgo-jdbc by georgeworld.
the class JdbcMain method setWindowCenter.
/*
* 使窗口居中显示
*/
public static void setWindowCenter(Window window) {
Toolkit kit = Toolkit.getDefaultToolkit();
Dimension screenSize = kit.getScreenSize();
int width = (int) screenSize.getWidth();
int height = (int) screenSize.getHeight();
int w = window.getWidth();
int h = window.getHeight();
window.setLocation((width - w) / 2, (height - h) / 2);
}
use of java.awt.Toolkit in project beast-mcmc by beast-dev.
the class BeagleSequenceSimulatorApp method CreateImage.
// END: main
private Image CreateImage(String path) {
URL imgURL = this.getClass().getResource(path);
Toolkit kit = Toolkit.getDefaultToolkit();
Image img = kit.createImage(imgURL);
if (img != null) {
return img;
} else {
System.out.println("Couldn't find file: " + path + "\n");
return null;
}
}
use of java.awt.Toolkit in project triplea by triplea-game.
the class HeadedUiContext method internalSetMapDir.
@Override
protected void internalSetMapDir(final String dir, final GameData data) {
final Stopwatch stopWatch = new Stopwatch(logger, Level.FINE, "Loading UI Context");
resourceLoader = ResourceLoader.getMapResourceLoader(dir);
if (mapData != null) {
mapData.close();
}
mapData = new MapData(resourceLoader);
// DiceImageFactory needs loader and game data
diceImageFactory = new DiceImageFactory(resourceLoader, data.getDiceSides());
final double unitScale = getPreferencesMapOrSkin(dir).getDouble(UNIT_SCALE_PREF, mapData.getDefaultUnitScale());
scale = getPreferencesMapOrSkin(dir).getDouble(MAP_SCALE_PREF, 1);
if (scale < 1) {
setDrawTerritoryBordersAgainToMedium();
}
unitImageFactory.setResourceLoader(resourceLoader, unitScale, mapData.getDefaultUnitWidth(), mapData.getDefaultUnitHeight(), mapData.getDefaultUnitCounterOffsetWidth(), mapData.getDefaultUnitCounterOffsetHeight());
// TODO: separate scale for resources
resourceImageFactory.setResourceLoader(resourceLoader);
territoryEffectImageFactory.setResourceLoader(resourceLoader);
flagIconImageFactory.setResourceLoader(resourceLoader);
puImageFactory.setResourceLoader(resourceLoader);
tileImageFactory.setMapDir(resourceLoader);
tileImageFactory.setScale(scale);
// load map data
mapImage.loadMaps(resourceLoader);
mapDir = dir;
drawTerritoryEffects = mapData.useTerritoryEffectMarkers();
// load the sounds in a background thread,
// avoids the pause where sounds dont load right away
// change the resource loader (this allows us to play sounds the map folder, rather than just default sounds)
new Thread(() -> ClipPlayer.getInstance(resourceLoader), "Triplea sound loader").start();
// load a new cursor
cursor = Cursor.getDefaultCursor();
final Toolkit toolkit = Toolkit.getDefaultToolkit();
// URL's use "/" not "\"
final URL cursorUrl = resourceLoader.getResource("misc" + "/" + "cursor.gif");
if (cursorUrl != null) {
try {
final Image image = ImageIO.read(cursorUrl);
if (image != null) {
final Point hotSpot = new Point(mapData.getMapCursorHotspotX(), mapData.getMapCursorHotspotY());
cursor = toolkit.createCustomCursor(image, hotSpot, data.getGameName() + " Cursor");
}
} catch (final Exception e) {
ClientLogger.logQuietly("Failed to create cursor from: " + cursorUrl, e);
}
}
stopWatch.done();
}
Aggregations