Examples of TextureLoader


Examples of org.gbcpainter.loaders.textures.TextureLoader

    }
    if ( this.explosionTime >= this.animationEndTime ) {
      throw new IllegalArgumentException();
    }

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

    for (String countdownTexture : countdownTextures) {
      loader.loadTexture( countdownTexture, true );
    }

    for (String explosionTexture : explosionTextures) {
      loader.loadTexture( explosionTexture, true );
    }

    loader.loadTexture( BEFORE_ACTIVATION_TEXTURE, true );

  }
View Full Code Here

Examples of org.gbcpainter.loaders.textures.TextureLoader

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

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

    final Dimension dimension = loader.getDimension( resourceName );

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

Examples of org.gbcpainter.loaders.textures.TextureLoader

                                  resourceFromDirection;
    this.resourceNameColored = RESOURCE_NAME_PREFIX +
                               RESOURCE_COLORED +
                               resourceFromDirection;

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

    loader.loadTexture( this.resourceNameNotColored, true );

    loader.loadTexture( this.resourceNameColored, true );


    for (String halfJunctionResource : halfJunctionsResources) {
      loader.loadTexture( halfJunctionResource, true );
    }
  }
View Full Code Here

Examples of org.gbcpainter.loaders.textures.TextureLoader

   * @param colored true if colored, false if not colored
   */
  @Override
  public synchronized void setColored( final boolean colored ) throws TextureNotFoundException {
    this.colored = colored;
    final TextureLoader loader = GraphicsEnv.getInstance().getTextureLoader();

    final String requestedTexture;

    if ( colored ) {
      requestedTexture = this.resourceNameColored;
    } else {
      requestedTexture = this.resourceNameNotColored;
    }

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

    if ( texture == null ) {
      try {
        texture = loader.loadTexture( requestedTexture, true );
      } catch ( Exception e ) {
        throw new TextureNotFoundException( "Can't find texture " + requestedTexture, e );
      }
    }

View Full Code Here

Examples of org.gbcpainter.loaders.textures.TextureLoader

      }
    }



    final TextureLoader loader = GraphicsEnv.getInstance().getTextureLoader();
    //final int baseDimension = GraphicsEnv.getInstance().getBasePointDimension();

    if(!this.voidPipe) {
      if ( isVertical( segment ) ) {
        loader.loadTexture( NON_COLORED_PART_VERTICAL, true );
        /*if ( loader.getBaseDimension( NON_COLORED_PART_VERTICAL ).height !=
              baseDimension ) {
          throw new InvalidTextureException( "Pipe texture " + NON_COLORED_PART_VERTICAL + " has an invalid size!" );
        }*/

        loader.loadTexture( COLORED_PART_VERTICAL, true );
        /*if ( loader.getBaseDimension( COLORED_PART_VERTICAL ).height != baseDimension ) {
          throw new InvalidTextureException( "Pipe texture " + COLORED_PART_VERTICAL + " has an invalid size!" );
        }*/

        loader.loadTexture( COLORED_SLICE_VERTICAL, true );
        loader.loadTexture( NON_COLORED_SLICE_VERTICAL, true );
      } else {
        loader.loadTexture( NON_COLORED_PART_HORIZONTAL, true );
        /*if ( loader.getBaseDimension( NON_COLORED_PART_HORIZONTAL ).width !=
              baseDimension ) {
          throw new InvalidTextureException( "Pipe texture " + NON_COLORED_PART_HORIZONTAL + " has an invalid size!" );
        }*/

        loader.loadTexture( COLORED_PART_HORIZONTAL, true );
        /*if ( loader.getBaseDimension( COLORED_PART_HORIZONTAL ).width != baseDimension ) {
          throw new InvalidTextureException( "Pipe texture " + COLORED_PART_HORIZONTAL + " has an invalid size!" );
        }*/

        loader.loadTexture( COLORED_SLICE_HORIZONTAL, true );
        loader.loadTexture( NON_COLORED_SLICE_HORIZONTAL, true );
      }
    }


  }
View Full Code Here

Examples of org.gbcpainter.loaders.textures.TextureLoader

    if(this.isVoidPipe()) {
      return;
    }

    final Iterable<PipePart> parts = new TreeSet<>( this.colorParts );
    final TextureLoader loader = GraphicsEnv.getInstance().getTextureLoader();
    final Segment pipeSegment = this.getSegment();

    final Dimension textureDimension;

    int gamePosition;
    final int upperLimit;

    /*
      Stampa le texure su schermo.

      Game position mantiene la posizione matematica della tubatura (model), e andrà dall'ascissa dell'estremo
      più a sinistra se la tubatura è orizzontale oppure dall'ordinata dell'estremo superiore se verticale.
      Upperlimit è impostato al limite opposto.

      Viene prima dipinta la parte non colorata, poi la parte colorata.

      screenPosition mantiene la posizione che deve avere la texture su schermo.

      screenPosition viene aggiornato a ogni pezzo di texture come un cursore.

      Questa parte riguarda il disegno delle sole parti non modificate in questo step.
     */
    Rectangle screenRect;
    Point screenPosition;
    final Iterator<Map.Entry<Integer, Boolean>> changedIterator = this.changedParts.entrySet()
                                                                               .iterator();
    Map.Entry<Integer, Boolean> nextSkip = changedIterator.hasNext() ? changedIterator.next() : null;

    if ( this.isVertical() ) {
      textureDimension = loader.getDimension( NON_COLORED_PART_VERTICAL );
      gamePosition = pipeSegment.getMinY();
      upperLimit = pipeSegment.getMaxY();

      for (final PipePart part : parts) {

        for (; gamePosition <= upperLimit && gamePosition < part.getStart(); gamePosition++) {
          screenRect = GraphicsEnv.getInstance().gamePointAndTextureToScreen( new Point( pipeSegment.getXA(), gamePosition ), textureDimension );
          screenPosition = new Point( screenRect.x, screenRect.y );
          final String pickTexture;

          if ( nextSkip != null && nextSkip.getKey() == gamePosition ) {
            pickTexture = ( nextSkip.getValue() ) ? COLORED_PART_VERTICAL : NON_COLORED_PART_VERTICAL;
            nextSkip = changedIterator.hasNext() ? changedIterator.next() : null;
          } else {
            pickTexture = NON_COLORED_PART_VERTICAL;
          }

          this.doDraw( g2, pickTexture, screenPosition );
        }

        for (; gamePosition <= part.getEnd(); gamePosition++) {
          screenRect = GraphicsEnv.getInstance().gamePointAndTextureToScreen( new Point( pipeSegment.getXA(), gamePosition ), textureDimension );
          screenPosition = new Point( screenRect.x, screenRect.y );
          final String pickTexture;

          if ( nextSkip != null && nextSkip.getKey() == gamePosition ) {
            pickTexture = ( nextSkip.getValue() ) ? COLORED_PART_VERTICAL : NON_COLORED_PART_VERTICAL;
            nextSkip = changedIterator.hasNext() ? changedIterator.next() : null;
          } else {
            pickTexture = COLORED_PART_VERTICAL;
          }

          this.doDraw( g2, pickTexture, screenPosition );
        }

      }

      for (; gamePosition <= upperLimit; gamePosition++) {
        screenRect = GraphicsEnv.getInstance().gamePointAndTextureToScreen( new Point( pipeSegment.getXA(), gamePosition ), textureDimension );
        screenPosition = new Point( screenRect.x, screenRect.y );
        final String pickTexture;

        if ( nextSkip != null && nextSkip.getKey() == gamePosition ) {
          pickTexture = ( nextSkip.getValue() ) ? COLORED_PART_VERTICAL : NON_COLORED_PART_VERTICAL;
          nextSkip = changedIterator.hasNext() ? changedIterator.next() : null;
        } else {
          pickTexture = NON_COLORED_PART_VERTICAL;
        }

        this.doDraw( g2, pickTexture, screenPosition );
      }

    } else {
      textureDimension = loader.getDimension( NON_COLORED_PART_HORIZONTAL );

      gamePosition = pipeSegment.getMinX();
      upperLimit = pipeSegment.getMaxX();

      for (final PipePart part : parts) {

        for (; gamePosition <= upperLimit && gamePosition < part.getStart(); gamePosition++) {
          screenRect = GraphicsEnv.getInstance().gamePointAndTextureToScreen( new Point( gamePosition, pipeSegment.getYA() ), textureDimension );
          screenPosition = new Point( screenRect.x, screenRect.y );
          final String pickTexture;

          if ( nextSkip != null && nextSkip.getKey() == gamePosition ) {
            pickTexture = ( nextSkip.getValue() ) ? COLORED_PART_HORIZONTAL : NON_COLORED_PART_HORIZONTAL;
            nextSkip = changedIterator.hasNext() ? changedIterator.next() : null;
          } else {
            pickTexture = NON_COLORED_PART_HORIZONTAL;
          }
          this.doDraw( g2, pickTexture, screenPosition );

        }

        for (; gamePosition <= part.getEnd(); gamePosition++) {

          screenRect = GraphicsEnv.getInstance().gamePointAndTextureToScreen( new Point( gamePosition, pipeSegment.getYA() ), textureDimension );
          screenPosition = new Point( screenRect.x, screenRect.y );
          final String pickTexture;

          if ( nextSkip != null && nextSkip.getKey() == gamePosition ) {
            pickTexture = ( nextSkip.getValue() ) ? COLORED_PART_HORIZONTAL : NON_COLORED_PART_HORIZONTAL;
            nextSkip = changedIterator.hasNext() ? changedIterator.next() : null;
          } else {
            pickTexture = COLORED_PART_HORIZONTAL;
          }
          this.doDraw( g2, pickTexture, screenPosition );
        }
      }

      for (; gamePosition <= upperLimit; gamePosition++) {

        screenRect = GraphicsEnv.getInstance().gamePointAndTextureToScreen( new Point( gamePosition, pipeSegment.getYA() ), textureDimension );
        screenPosition = new Point( screenRect.x, screenRect.y );
        final String pickTexture;

        if ( nextSkip != null && nextSkip.getKey() == gamePosition ) {
          pickTexture = ( nextSkip.getValue() ) ? COLORED_PART_HORIZONTAL : NON_COLORED_PART_HORIZONTAL;
          nextSkip = changedIterator.hasNext() ? changedIterator.next() : null;
        } else {
          pickTexture = NON_COLORED_PART_HORIZONTAL;
        }
        this.doDraw( g2, pickTexture, screenPosition );
      }

    }
    assert ! changedIterator.hasNext();

    /*
      Draws the modified parts on screen

      Modified parts are drawn as slices from the lower coordinate (leftmost X coordinate
      is horizontal, upper Y coordinate if vertical) to the upper one of the animation part
     */
    if ( ! this.coloringAnimations.isEmpty() ) {
      boolean remainingAnimations = false;
      if ( this.isVertical() ) {
        for (PipeColoringAnimation animation : this.coloringAnimations) {
          final Line2D donePart = animation.getDonePart();
          if ( donePart == null ) {
            continue;
          }

          final boolean colored = animation.isColoring();
          @NonNls
          final String selectedTexture = colored ? COLORED_SLICE_VERTICAL : NON_COLORED_SLICE_VERTICAL;
          final Dimension sliceDimension = loader.getDimension( selectedTexture );
          final Rectangle screenRealPosition = GraphicsEnv.getInstance().gamePointAndTextureToScreen( donePart.getP1(), sliceDimension );
          final Rectangle screenRealPositionUpper = GraphicsEnv.getInstance().gamePointAndTextureToScreen( donePart.getP2(), sliceDimension );
          final int lowerY = Math.min( screenRealPosition.y, screenRealPositionUpper.y );
          final int upperY = Math.max( screenRealPosition.y, screenRealPositionUpper.y );

          Point cursor = new Point( screenRealPosition.x, lowerY );
          for (; cursor.y < upperY; cursor.y++) {
            this.doDraw( g2, selectedTexture, cursor );
          }

          if ( ! animation.isTerminated() ) {
            remainingAnimations = true;
          }
        }
      } else {

        for (PipeColoringAnimation animation : this.coloringAnimations) {
          final Line2D donePart = animation.getDonePart();
          if ( donePart == null ) {
            continue;
          }

          final boolean colored = animation.isColoring();
          @NonNls
          final String selectedTexture = colored ? COLORED_SLICE_HORIZONTAL : NON_COLORED_SLICE_HORIZONTAL;
          final Dimension sliceDimension = loader.getDimension( selectedTexture );
          final Rectangle screenRealPosition = GraphicsEnv.getInstance().gamePointAndTextureToScreen( donePart.getP1(), sliceDimension );
          final Rectangle screenRealPositionUpper = GraphicsEnv.getInstance().gamePointAndTextureToScreen( donePart.getP2(), sliceDimension );
          final int lowerX = Math.min( screenRealPosition.x, screenRealPositionUpper.x );
          final int upperX = Math.max( screenRealPosition.x, screenRealPositionUpper.x );

View Full Code Here

Examples of org.gbcpainter.loaders.textures.TextureLoader

  }

  private void doDraw( final @NotNull Graphics2D g2, final @NotNull String resourceName, final @NotNull Point where ) throws Exception {
    boolean done = false;
    boolean tryAcceleration = true;
    final TextureLoader loader = GraphicsEnv.getInstance().getTextureLoader();

    do {
      final Image img = loader.loadTexture( resourceName, tryAcceleration );
      g2.drawImage( img, where.x, where.y, null );
      try {
        if ( ! loader.mustReload( resourceName, tryAcceleration ) ) {
          done = true;
        }
      } catch ( NoSuchElementException e ) {
        if ( ! tryAcceleration ) {
          throw new TextureNotFoundException( e );
View Full Code Here

Examples of ru.snake.spritepacker.core.TextureLoader

    factory.setPreference(PROP_GAP_Y, String.valueOf(propGapY));
    factory.setPreference(PROP_CROP, String.valueOf(propCrop));
    factory.setPreference(PROP_TRANSPARENT, String.valueOf(propTransparent));
    factory.setPreference(PROP_COLORED, String.valueOf(propColored));

    TextureLoader textureLoader = factory.getTextureLoader();
    List<Sprite> sprites = new ArrayList<Sprite>();
    Point current = new Point(0, propOffsetY);

    while (current.y + propHeight < image.getHeight()) {
      current.x = propOffsetX;
View Full Code Here

Examples of ru.snake.spritepacker.core.TextureLoader

  }

  private void importAsIs(File[] images) {
    List<Sprite> spritelist = new ArrayList<Sprite>(images.length);

    TextureLoader textureLoader = factory.getTextureLoader();

    for (File each : images) {
      Texture texture = textureLoader.load(each);

      if (texture == null) {
        continue;
      }
View Full Code Here

Examples of ru.snake.spritepacker.core.TextureLoader

  private void importCropped(File[] images) {
    List<Sprite> spritelist = new ArrayList<Sprite>(images.length);
    List<Point> offsetlist = new ArrayList<Point>(images.length);

    TextureLoader textureLoader = factory.getTextureLoader();

    for (File each : images) {
      Point point = new Point();
      Texture texture = textureLoader.loadCroped(each, point);

      if (texture == null) {
        continue;
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.