Package ca.eandb.util

Examples of ca.eandb.util.UnexpectedException


  private static int round(double x, TileDescription.RoundingMode mode) {
    switch (mode) {
    case DOWN: return (int) Math.floor(x);
    case UP: return (int) Math.ceil(x);
    default: throw new UnexpectedException("Invalid rounding mode");
    }
  }
View Full Code Here


      case HALF:
        buf = ShortBuffer.allocate(sx * sy);
        break;

      default:
        throw new UnexpectedException("Invalid pixel type");
      }

      data.put(name, buf);
    }
    return buf;
View Full Code Here

      lastBlock = -1;
      blockIncr = -1;
      break;

    default:
      throw new UnexpectedException("Invalid line order");
    }

    for (int i = firstBlock; i != lastBlock; i += blockIncr) {
      out.seek(blockPtrPos + 8 * i);
      out.writeLong(blockPos - start);
      out.seek(blockPos);
      bytes.rewind();

      // TODO write the next block here
      int x0 = dw.getXMin();
      int x1 = dw.getXMax();
      int y0 = dw.getYMin() + i * cm.getScanLinesPerBlock();
      int y1 = Math.min(y0 + cm.getScanLinesPerBlock() - 1, dw.getYMax());
      Box2i block = new Box2i(x0, y0, x1, y1);
      int blockSize = computeTileSize(block);

      for (int y = y0; y <= y1; y++) {
        for (Channel channel : chlist.channels()) {
          String name = channel.getName();
          int sx = channel.getxSampling();
          int sy = channel.getySampling();
          if (y % sy == 0) {
            int nx = 1 + (x1 - x0 - (x1 % sx)) / sx;
            int offset = ((y - ymin) / sy) * nx;
            Buffer chBuf = getChannelBuffer(name);
            PixelType pt = channel.getPixelType();

            switch (pt) {
            case UINT:
              bytes.asIntBuffer().put((IntBuffer)
                  ((IntBuffer) chBuf).duplicate().position(offset).limit(offset + nx));
              break;

            case HALF:
              bytes.asShortBuffer().put((ShortBuffer)
                  ((ShortBuffer) chBuf).duplicate().position(offset).limit(offset + nx));
              break;

            case FLOAT:
              bytes.asFloatBuffer().put((FloatBuffer)
                  ((FloatBuffer) chBuf).duplicate().position(offset).limit(offset + nx));
              break;

            default:
              throw new UnexpectedException("Invalid pixel type");
            }

            bytes.position(bytes.position() + nx * pt.getSampleSize());
          }
        }
View Full Code Here

    case FLOAT:
      FloatBuffer fbuf = (FloatBuffer) getChannelBuffer(c);
      return MathUtil.clamp((long) fbuf.get(index), 0, (0x1L << 32) - 1L);

    default:
      throw new UnexpectedException("Invalid pixel type");

    }
  }
View Full Code Here

    case FLOAT:
      FloatBuffer fbuf = (FloatBuffer) getChannelBuffer(c);
      return Half.valueOf(fbuf.get(index));

    default:
      throw new UnexpectedException("Invalid pixel type");

    }
  }
View Full Code Here

    case FLOAT:
      FloatBuffer fbuf = (FloatBuffer) getChannelBuffer(c);
      return fbuf.get(index);

    default:
      throw new UnexpectedException("Invalid pixel type");

    }
  }
View Full Code Here

      FloatBuffer fbuf = (FloatBuffer) getChannelBuffer(c);
      fbuf.put(index, (float) ((int) value));
      break;

    default:
      throw new UnexpectedException("invalid pixel type");
    }
  }
View Full Code Here

      FloatBuffer fbuf = (FloatBuffer) getChannelBuffer(c);
      fbuf.put(index, value.floatValue());
      break;

    default:
      throw new UnexpectedException("Invalid pixel type");
    }
  }
View Full Code Here

      FloatBuffer fbuf = (FloatBuffer) getChannelBuffer(c);
      fbuf.put(index, value);
      break;

    default:
      throw new UnexpectedException("Invalid pixel type");
    }
  }
View Full Code Here

      buffer.buf = ByteBuffer.wrap(buf);
      buffer.next = size;

      ready = true;
    } catch (ClassNotFoundException e) {
      throw new UnexpectedException(e);
    }

    System.out.println("Restored BIH from file.");
  }
View Full Code Here

TOP

Related Classes of ca.eandb.util.UnexpectedException

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.