use of com.b3dgs.lionengine.LionEngineException in project lionengine by b3dgs.
the class ScreenAwtTest method testFullscreen.
/**
* Test full screen.
*/
@Test
void testFullscreen() {
Medias.setLoadFromJar(ScreenAwtTest.class);
final DisplayMode res = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDisplayModes()[0];
final Config config = new Config(new Resolution(res.getWidth(), res.getHeight(), res.getRefreshRate()), res.getBitDepth(), false, Medias.create("image.png"));
try {
testScreen(config);
} catch (final LionEngineException exception) {
// Skip test
if (!ScreenFullAwt.ERROR_SWITCH.equals(exception.getMessage())) {
throw exception;
}
}
}
use of com.b3dgs.lionengine.LionEngineException in project lionengine by b3dgs.
the class FactoryGraphicHeadless method generateTileset.
@Override
public void generateTileset(ImageBuffer[] images, Media media) {
Check.notNull(images);
Check.notNull(media);
if (images.length == 0) {
throw new LionEngineException("No images found !");
}
final int width = images[0].getWidth();
final int height = images[0].getHeight();
final int multDistance = (int) Math.ceil(width * images.length / (double) height) / 4;
final int[] mult = UtilMath.getClosestSquareMult(images.length, multDistance);
try (OutputStream output = media.getOutputStream()) {
output.write(UtilConversion.intToByteArray(width * mult[1]));
output.write(UtilConversion.intToByteArray(height * mult[0]));
} catch (final IOException exception) {
throw new LionEngineException(exception, media, ERROR_IMAGE_SAVE);
}
}
use of com.b3dgs.lionengine.LionEngineException in project lionengine by b3dgs.
the class FactoryGraphicHeadless method saveImage.
@Override
public void saveImage(ImageBuffer image, Media media) {
Check.notNull(media);
try (OutputStream output = media.getOutputStream()) {
output.write(UtilConversion.intToByteArray(image.getWidth()));
output.write(UtilConversion.intToByteArray(image.getHeight()));
} catch (final IOException exception) {
throw new LionEngineException(exception, media, ERROR_IMAGE_SAVE);
}
}
use of com.b3dgs.lionengine.LionEngineException in project lionengine by b3dgs.
the class ServerUdp method handleType.
private void handleType(DatagramPacket packet) throws IOException {
final ByteBuffer buffer = UtilNetwork.getBuffer(packet);
bandwidthDownSum.addAndGet(buffer.capacity());
final MessageType type = MessageType.from(buffer);
switch(type) {
case CONNECT:
connect(packet, buffer);
break;
case DISCONNECT:
disconnect(packet, buffer);
break;
case ALIVE:
alive(packet, buffer);
break;
case PING:
ping(packet, buffer);
break;
case DIRECT:
direct(packet, buffer);
break;
case DATA:
data(packet, buffer);
break;
case CLIENTS_LIST:
case UNKNOWN:
break;
default:
throw new LionEngineException(type);
}
}
use of com.b3dgs.lionengine.LionEngineException in project lionengine by b3dgs.
the class RasterImageTest method afterAll.
/**
* Terminate engine.
*/
@AfterAll
static void afterAll() {
try {
UtilFile.deleteFile(new File(System.getProperty("java.io.tmpdir"), RasterImageTest.class.getSimpleName()));
} catch (final LionEngineException exception) {
Verbose.exception(exception);
}
Medias.setLoadFromJar(null);
Graphics.setFactoryGraphic(null);
Engine.terminate();
}
Aggregations