use of com.b3dgs.lionengine.LionEngineException in project lionengine by b3dgs.
the class AdlMidiFormat method loadLibrary.
/**
* Load the library.
*
* @return The library binding.
* @throws LionEngineException If error on loading.
*/
private static AdlMidiBinding loadLibrary() {
try {
Verbose.info("Load library: ", LIBRARY_NAME);
final AdlMidiBinding binding = Native.loadLibrary(LIBRARY_NAME, AdlMidiBinding.class);
Verbose.info("Library ", LIBRARY_NAME, " loaded");
return binding;
} catch (final LinkageError exception) {
throw new LionEngineException(exception, ERROR_LOAD_LIBRARY + LIBRARY_NAME);
}
}
use of com.b3dgs.lionengine.LionEngineException in project lionengine by b3dgs.
the class AdPlugFormat method loadLibrary.
/**
* Load the library.
*
* @return The library binding.
* @throws LionEngineException If error on loading.
*/
private static AdPlugBinding loadLibrary() {
Verbose.info("Load library: ", LIBRARY_NAME);
try {
final AdPlugBinding binding = Native.loadLibrary(LIBRARY_NAME, AdPlugBinding.class);
Verbose.info("Library ", LIBRARY_NAME, " loaded");
return binding;
} catch (final LinkageError exception) {
throw new LionEngineException(exception, ERROR_LOAD_LIBRARY + LIBRARY_NAME);
}
}
use of com.b3dgs.lionengine.LionEngineException in project lionengine by b3dgs.
the class ScreenFullAwt method initFullscreen.
/**
* Prepare fullscreen mode.
*
* @param output The output resolution
* @param depth The bit depth color.
* @throws LionEngineException If unsupported resolution.
*/
private void initFullscreen(Resolution output, int depth) {
final java.awt.Window window = new java.awt.Window(frame, conf);
window.setBackground(Color.BLACK);
window.setIgnoreRepaint(true);
window.setPreferredSize(new Dimension(output.getWidth(), output.getHeight()));
dev.setFullScreenWindow(window);
final DisplayMode disp = isSupported(new DisplayMode(output.getWidth(), output.getHeight(), depth, output.getRate()));
if (disp == null) {
throw new LionEngineException(ScreenFullAwt.ERROR_UNSUPPORTED_FULLSCREEN + formatResolution(output, depth) + getSupportedResolutions());
}
if (!dev.isDisplayChangeSupported()) {
throw new LionEngineException(ScreenFullAwt.ERROR_SWITCH);
}
dev.setDisplayMode(disp);
window.validate();
ToolsAwt.createBufferStrategy(window, conf);
buf = window.getBufferStrategy();
// Set input listeners
componentForKeyboard = frame;
componentForMouse = window;
componentForCursor = window;
frame.validate();
}
use of com.b3dgs.lionengine.LionEngineException in project lionengine by b3dgs.
the class TextAwt method draw.
@Override
public void draw(Graphic g, int x, int y, Align alignment, String text) {
final Graphics2D g2d = (Graphics2D) g.getGraphic();
final FontRenderContext context = g2d.getFontRenderContext();
final Rectangle2D textSize = font.getStringBounds(text, context);
final int tx;
final int ty;
if (Align.LEFT == alignment) {
tx = x;
ty = (int) textSize.getHeight() + y;
} else if (Align.CENTER == alignment) {
tx = x - (int) textSize.getWidth() / 2;
ty = (int) textSize.getHeight() + y;
} else if (Align.RIGHT == alignment) {
tx = x - (int) textSize.getWidth();
ty = (int) textSize.getHeight() + y;
} else {
throw new LionEngineException(alignment);
}
final ColorRgba colorOld = g.getColor();
g.setColor(color);
final GlyphVector glyphVector = font.createGlyphVector(context, text);
g2d.drawGlyphVector(glyphVector, tx, ty - size / 2.0F);
g.setColor(colorOld);
}
use of com.b3dgs.lionengine.LionEngineException in project lionengine by b3dgs.
the class ToolsAwt method getTransparency.
/**
* Get the image transparency equivalence.
*
* @param transparency The transparency type (must not be <code>null</code>).
* @return The transparency value.
* @throws LionEngineException If invalid argument.
*/
public static int getTransparency(Transparency transparency) {
Check.notNull(transparency);
final int value;
if (Transparency.OPAQUE == transparency) {
value = java.awt.Transparency.OPAQUE;
} else if (Transparency.BITMASK == transparency) {
value = java.awt.Transparency.BITMASK;
} else if (Transparency.TRANSLUCENT == transparency) {
value = java.awt.Transparency.TRANSLUCENT;
} else {
throw new LionEngineException(transparency);
}
return value;
}
Aggregations