Search in sources :

Example 6 with LionEngineException

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);
    }
}
Also used : LionEngineException(com.b3dgs.lionengine.LionEngineException)

Example 7 with LionEngineException

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);
    }
}
Also used : LionEngineException(com.b3dgs.lionengine.LionEngineException)

Example 8 with LionEngineException

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();
}
Also used : DisplayMode(java.awt.DisplayMode) LionEngineException(com.b3dgs.lionengine.LionEngineException) Dimension(java.awt.Dimension)

Example 9 with LionEngineException

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);
}
Also used : GlyphVector(java.awt.font.GlyphVector) ColorRgba(com.b3dgs.lionengine.graphic.ColorRgba) LionEngineException(com.b3dgs.lionengine.LionEngineException) Rectangle2D(java.awt.geom.Rectangle2D) FontRenderContext(java.awt.font.FontRenderContext) Graphics2D(java.awt.Graphics2D)

Example 10 with LionEngineException

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;
}
Also used : LionEngineException(com.b3dgs.lionengine.LionEngineException) Point(java.awt.Point)

Aggregations

LionEngineException (com.b3dgs.lionengine.LionEngineException)75 IOException (java.io.IOException)13 File (java.io.File)8 OutputStream (java.io.OutputStream)7 ArrayList (java.util.ArrayList)7 XmlReader (com.b3dgs.lionengine.XmlReader)6 Field (java.lang.reflect.Field)6 Test (org.junit.Test)6 Media (com.b3dgs.lionengine.Media)5 Configurer (com.b3dgs.lionengine.game.Configurer)4 UtilFile (com.b3dgs.lionengine.UtilFile)3 Graphic (com.b3dgs.lionengine.graphic.Graphic)3 UtilFile (com.b3dgs.lionengine.util.UtilFile)3 DisplayMode (java.awt.DisplayMode)3 BufferedImage (java.awt.image.BufferedImage)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 AfterAll (org.junit.jupiter.api.AfterAll)3 Animation (com.b3dgs.lionengine.Animation)2 AnimationConfig (com.b3dgs.lionengine.game.AnimationConfig)2 Feature (com.b3dgs.lionengine.game.Feature)2