Package com.lightcrafts.mediax.jai.tilecodec

Examples of com.lightcrafts.mediax.jai.tilecodec.TileEncoderFactory


     */
    public byte[] getCompressedTile(Long id, int x, int y)
  throws RemoteException {

  TileCodecParameterList tcpl = null;
  TileEncoderFactory tef = null;
  NegotiableCapability codecCap = null;

  if (negotiated != null) {
      codecCap = ((NegotiableCapabilitySet)negotiated.get(id)).
    getNegotiatedValue("tileCodec");
  }

  if (codecCap != null) {

      String category = codecCap.getCategory();
      String capabilityName = codecCap.getCapabilityName();
      List generators = codecCap.getGenerators();

      Class factory;
      for (Iterator i=generators.iterator(); i.hasNext(); ) {

    factory = (Class)i.next();
    if (tef == null &&
        TileEncoderFactory.class.isAssignableFrom(factory)) {
        try {
      tef = (TileEncoderFactory)factory.newInstance();
        } catch (InstantiationException ie) {
      throw new RuntimeException(ie.getMessage());
        } catch (IllegalAccessException iae) {
      throw new RuntimeException(iae.getMessage());
        }
    }
      }

      if (tef == null) {
    throw new RuntimeException(
             JaiI18N.getString("JAIRMIImageServer0"));
      }

      TileCodecDescriptor tcd =
    (TileCodecDescriptor)JAI.getDefaultInstance().
    getOperationRegistry().getDescriptor("tileEncoder",
                 capabilityName);

      if (tcd.includesSampleModelInfo() == false ||
    tcd.includesLocationInfo() == false) {
    throw new RuntimeException(
             JaiI18N.getString("JAIRMIImageServer1"));
      }

      ParameterListDescriptor pld =
    tcd.getParameterListDescriptor("tileEncoder");

      tcpl = new TileCodecParameterList(capabilityName,
                new String[] {"tileEncoder"},
                pld);

      if (pld != null) {

    String paramNames[] = pld.getParamNames();
    String currParam;
    Object currValue;

    if (paramNames != null) {
        for (int i=0; i<paramNames.length; i++) {
      currParam = paramNames[i];
      try {
          currValue = codecCap.getNegotiatedValue(currParam);
      } catch (IllegalArgumentException iae) {
          continue;
      }
      tcpl.setParameter(currParam, currValue);
        }
    }
      }

      Raster r = getSource(id).getTile(x, y);
      ByteArrayOutputStream stream = new ByteArrayOutputStream();
      TileEncoder encoder = tef.createEncoder(stream, tcpl,
                r.getSampleModel());

      try {
    encoder.encode(r);
      } catch (java.io.IOException ioe) {
View Full Code Here


  // Note that only the tileEncoder capabilities are returned from
  // this method since there is no way to distinguish between NC's
  // for the encoder and the decoder.
  String modeName = "tileEncoder";
  String[] descriptorNames = registry.getDescriptorNames(modeName);
  TileEncoderFactory tef = null;

  // Only non-preference NC's can be added.
  NegotiableCapabilitySet capabilities =
      new NegotiableCapabilitySet(false);

  Iterator it;
  for (int i=0; i<descriptorNames.length; i++) {

      it = registry.getFactoryIterator(modeName, descriptorNames[i]);
      for (; it.hasNext(); ) {
    tef = (TileEncoderFactory)it.next();
    capabilities.add(tef.getEncodeCapability());
      }
  }

  return capabilities;
    }
View Full Code Here

        if (!formatName.equals(decodingParam.getFormatName())) {
            throw new IllegalArgumentException(
            JaiI18N.getString("UseTileCodec1"));
        }

        TileEncoderFactory tileEncoderFactory =
            (TileEncoderFactory)registry.getFactory("tileEncoder", formatName);
        TileDecoderFactory tileDecoderFactory =
            (TileDecoderFactory)registry.getFactory("tileDecoder", formatName);
        if (tileEncoderFactory == null || tileDecoderFactory == null)
            throw new RuntimeException(JaiI18N.getString("UseTileCodec2"));
View Full Code Here

TOP

Related Classes of com.lightcrafts.mediax.jai.tilecodec.TileEncoderFactory

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.