Package org.gbcpainter.loaders.textures

Examples of org.gbcpainter.loaders.textures.TextureLoader


    }
  }

  @Test
  public void transparentTextureLoading() throws Exception {
    final TextureLoader loader = GraphicsEnv.getInstance().getTextureLoader();

    BufferedImage loaded = (BufferedImage) loader.loadTexture( "Transparent", false );

    assertNotSame(loaded.getTransparency(), Transparency.OPAQUE);
  }
View Full Code Here


    assertNotSame(loaded.getTransparency(), Transparency.OPAQUE);
  }

  @Test
  public void opaqueTextureLoading() throws Exception {
    final TextureLoader loader = GraphicsEnv.getInstance().getTextureLoader();

    BufferedImage loaded = (BufferedImage) loader.loadTexture( "Opaque", false );

    assertEquals(loaded.getTransparency(), Transparency.OPAQUE);

    loaded = (BufferedImage) loader.loadTexture( "Opaque_with_alpha", false );

    assertNotSame(loaded.getTransparency(), Transparency.OPAQUE);
  }
View Full Code Here

    } catch( Exception ignored) {}
  }

  @Test
  public void testLoadNonAcceleratedTexture() throws Exception {
    final TextureLoader loader = GraphicsEnv.getInstance().getTextureLoader();

    loader.loadTexture( "Header", false );

    try {
      loader.mustReload( "Header", true );
      fail();
    } catch ( NoSuchElementException e ){}

    loader.mustReload( "Header", false );

    loader.clear();

    try {
      loader.mustReload( "Header", false );
      fail();
    } catch ( NoSuchElementException e ){}

    assertEquals( loader.getTexture( "Header", false ), null );

    Image oldTexture = loader.loadTexture( "Header", false );

    loader.reloadTextures();

    Image newTexture = loader.getTexture( "Header", false );

    assertNotSame( newTexture, oldTexture );

    loader.getBaseDimension( "Header" );

    loader.clear();

    try {
      loader.getBaseDimension( "Header" );
      fail();
    } catch ( NoSuchElementException e ){}
  }
View Full Code Here

    } catch ( NoSuchElementException e ){}
  }

  @Test
  public void testLoadAcceleratedTexture() throws Exception {
    final TextureLoader loader = GraphicsEnv.getInstance().getTextureLoader();

    loader.loadTexture( "Header", true);

    loader.mustReload( "Header", false );
    loader.mustReload( "Header", true );

    loader.clear();

    try {
      loader.mustReload( "Header", true );
      fail();
    } catch ( NoSuchElementException e ){}

    assertEquals( loader.getTexture( "Header", false ), null );
    assertEquals( loader.getTexture( "Header", true ), null );

    Image oldTexture = loader.loadTexture( "Header", true );

    loader.reloadTextures();

    Image newTexture = loader.getTexture( "Header", true );

    assertNotSame( newTexture, oldTexture );

    loader.getBaseDimension( "Header" );

    loader.clear();

    try {
      loader.getBaseDimension( "Header" );
      fail();
    } catch ( NoSuchElementException e ){}

  }
View Full Code Here

  }

  @Test
  public void testLoadInvalidTexture() throws Exception {
    final TextureLoader loader = GraphicsEnv.getInstance().getTextureLoader();

    try {
      loader.loadTexture( "1234509876", false );
      fail();
    } catch ( TextureNotFoundException e ){}

    try {
      loader.loadTexture( "FakePngExtension", false );
      fail();
    } catch ( IOException e ){}
  }
View Full Code Here

      Iterable<String>> resources, @NotNull T slot ) throws Exception {
    super(  );
    this.resources = new HashMap<>( resources );
    this.actualSlot = slot;

    final TextureLoader loader = GraphicsEnv.getInstance().getTextureLoader();

    for (Iterable<String> slotList : resources.values()) {
      for (String resource : slotList) {
        try {
          loader.loadTexture( resource, true );
        } catch ( Exception e ) {
          throw new TextureNotFoundException( e );
        }
      }
    }
View Full Code Here

   */
  @Override
  public synchronized void draw( @NotNull Graphics2D g2 ) throws Exception {
    boolean done = false;
    boolean tryAcceleration = true;
    final TextureLoader loader = GraphicsEnv.getInstance().getTextureLoader();

    do {
      final String resourceName = this.getResourceName();
      if ( resourceName == null ) {
        done = true;
      } else {
        super.draw( g2 );
        try {
          if ( ! loader.mustReload( resourceName, tryAcceleration ) ) {
            done = true;
          }
        } catch ( NoSuchElementException e ) {
          tryAcceleration = false;
        }
View Full Code Here

    if ( resourceName == null ) {
      return null;
    }

    @Nullable
    final TextureLoader loader = GraphicsEnv.getInstance().getTextureLoader();

    final Dimension dimension = loader.getDimension( resourceName );

    return GraphicsEnv.getInstance().gamePointAndTextureToScreen( position, dimension );

  }
View Full Code Here

    if ( resourceName == null ) {
      return null;
    }

    final TextureLoader loader = GraphicsEnv.getInstance().getTextureLoader();

    Image texture = loader.getTexture( resourceName, true );

    if ( texture == null ) {
      texture = loader.loadTexture( resourceName, true );
    }
    return texture;

  }
View Full Code Here

    if ( resourceName == null ) {
      return null;
    }

    final TextureLoader loader = GraphicsEnv.getInstance().getTextureLoader();

    final Dimension dimension = loader.getDimension( resourceName );

    return GraphicsEnv.getInstance().gamePointAndTextureToScreen( asIfItWasHere, dimension );
  }
View Full Code Here

TOP

Related Classes of org.gbcpainter.loaders.textures.TextureLoader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.