Package com.lightcrafts.mediax.jai

Examples of com.lightcrafts.mediax.jai.ParameterListDescriptor


    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++) {
View Full Code Here


    tcd.includesLocationInfo() == false) {
    throw new RemoteImagingException(
             JaiI18N.getString("RMIServerProxy1"));
      }

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

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

      // Set parameters on TileCodecParameterList only if there are any
      // parameters defined.
      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];
View Full Code Here

    public NegotiableCapability getDecodeCapability() {
 
  Vector generators = new Vector();
  generators.add(JPEGTileDecoderFactory.class);

  ParameterListDescriptor jpegPld = JAI.getDefaultInstance().getOperationRegistry().getDescriptor("tileDecoder", "jpeg").getParameterListDescriptor("tileDecoder");
 
  Class paramClasses[] = {
      NegotiableNumericRange.class,
      NegotiableCollection.class,
      // XXX Find a way to create a negotiable representing integer
      // arrays
      // integer array,  horizontal subsampling
      // integer array,  vertical subsampling
      // integer array,  quantization table mapping
      // integer array,  quantizationTable0
      // integer array,  quantizationTable1
      // integer array,  quantizationTable2
      // integer array,  quantizationTable3
      NegotiableNumericRange.class,
      NegotiableCollection.class,
      NegotiableCollection.class,
      NegotiableCollection.class
  };

  String paramNames[] = {
      "quality",
      "qualitySet",
      "restartInterval",
      "writeImageInfo",
      "writeTableInfo",
      "writeJFIFHeader"
  };

  // A collection containing the valid values for a boolean valued
  // parameters
  Vector v = new Vector();
  v.add(new Boolean(true));
  v.add(new Boolean(false));
  NegotiableCollection negCollection = new NegotiableCollection(v);

  NegotiableNumericRange nnr1 =
      new NegotiableNumericRange(
          jpegPld.getParamValueRange(paramNames[0]));

  NegotiableNumericRange nnr2 =
      new NegotiableNumericRange(
          jpegPld.getParamValueRange(paramNames[2]));

  // The default values
  Object defaults[] = {
      nnr1,
      negCollection,
View Full Code Here

    JPEGQTable table = jdp.getQTable(i);
    paramList.setParameter("quantizationTable"+i,
        (table == null) ? null : table.getTable());
      }
  else {
      ParameterListDescriptor pld
    = paramList.getParameterListDescriptor();
      for (int i = 0; i < 4; i++) {
    paramList.setParameter("quantizationTable"+i,
        pld.getParamDefaultValue("quantizationTable"+i));
      }
  }

  // extract the quantizationTableMapping
  int[] quanTableMapping = new int[bandNum];
View Full Code Here

    public NegotiableCapability getEncodeCapability() {

  Vector generators = new Vector();
  generators.add(JPEGTileEncoderFactory.class);

  ParameterListDescriptor jpegPld =
      JAI.getDefaultInstance().getOperationRegistry().getDescriptor("tileEncoder", "jpeg").getParameterListDescriptor("tileEncoder");

  Class paramClasses[] = {
      com.lightcrafts.mediax.jai.remote.NegotiableNumericRange.class,
      com.lightcrafts.mediax.jai.remote.NegotiableCollection.class,
      // XXX How should a negotiable be created to represent int arrays
      // integer array,  horizontal subsampling
      // integer array,  vertical subsampling
      // integer array,  quantization table mapping
      // integer array,  quantizationTable0
      // integer array,  quantizationTable1
      // integer array,  quantizationTable2
      // integer array,  quantizationTable3
      com.lightcrafts.mediax.jai.remote.NegotiableNumericRange.class,
      com.lightcrafts.mediax.jai.remote.NegotiableCollection.class,
      com.lightcrafts.mediax.jai.remote.NegotiableCollection.class,
      com.lightcrafts.mediax.jai.remote.NegotiableCollection.class
  };

  String paramNames[] = {
      "quality",
      "qualitySet",
      "restartInterval",
      "writeImageInfo",
      "writeTableInfo",
      "writeJFIFHeader"
  };

  // A collection containing the valid values for a boolean valued
  // parameters
  Vector v = new Vector();
  v.add(new Boolean(true));
  v.add(new Boolean(false));
  NegotiableCollection negCollection = new NegotiableCollection(v);

  NegotiableNumericRange nnr1 =
      new NegotiableNumericRange(
          jpegPld.getParamValueRange(paramNames[0]));

  NegotiableNumericRange nnr2 =
      new NegotiableNumericRange(
          jpegPld.getParamValueRange(paramNames[2]));

  // The default values
  Object defaults[] = {
      nnr1,
      negCollection,
View Full Code Here

      TileCodecParameterList temp = decodingParam;

      if (temp != null) {
    TileCodecDescriptor tcd =
        getTileCodecDescriptor("tileDecoder", formatName);
    ParameterListDescriptor pld =
        tcd.getParameterListDescriptor("tileDecoder");
    decodingParam =
        new TileCodecParameterList(formatName,
                 new String[]{"tileDecoder"},
                 pld);
    String[] names = pld.getParamNames();

    if (names != null)
        for (int i = 0; i < names.length; i++)
      decodingParam.setParameter(names[i],
               temp.getObjectParameter(names[i]));
View Full Code Here

  if (capabilityName == null) {
      throw new IllegalArgumentException(
        JaiI18N.getString("NegotiableCapability1"));
  }

  ParameterListDescriptor desc = getParameterListDescriptor();
  int numParams = desc.getNumParameters();
  String names[] = desc.getParamNames();
  Class classes[] = desc.getParamClasses();
  Object defaults[] = desc.getParamDefaults();

  for (int i=0; i<numParams; i++) {

      // Check that all paramClasses implement Negotiable.
      if (Negotiable.class.isAssignableFrom(classes[i]) == false) {
View Full Code Here

      } else {
    negStatus = 3;
      }
  }

  ParameterListDescriptor pld = getParameterListDescriptor();
  ParameterListDescriptor otherPld =
      capability.getParameterListDescriptor();
  String thisNames[] = pld.getParamNames();
        if (thisNames == null)
            thisNames = new String[0];
  String otherNames[] = otherPld.getParamNames();
        if (otherNames == null)
            otherNames = new String[0];
  Hashtable thisHash = hashNames(thisNames);
  Hashtable otherHash = hashNames(otherNames);

  Class thisClasses[] = pld.getParamClasses();
  Class otherClasses[] = otherPld.getParamClasses();
  Object thisDefaults[] = pld.getParamDefaults();
  Object otherDefaults[] = otherPld.getParamDefaults();

  NegotiableCapability result = null;
  String currParam;
  Negotiable thisValue, otherValue, resultValue;
  ArrayList resultGenerators = new ArrayList();
  if (generators != null)
      resultGenerators.addAll(generators);
  if (capability.getGenerators() != null)
      resultGenerators.addAll(capability.getGenerators());

  switch (negStatus) {

  case 0:

      Vector commonNames = commonElements(thisHash, otherHash);
      Hashtable commonHash = hashNames(commonNames);
      Vector thisExtras = removeAll(thisHash, commonHash);
      Vector otherExtras = removeAll(otherHash, commonHash);

      int thisExtraLength = thisExtras.size();
      int otherExtraLength = otherExtras.size();

      // Create a new PLD which is the amalgamation of the two
      // NC's PLD's
      Vector resultParams = new Vector(commonNames);
      resultParams.addAll(thisExtras);
      resultParams.addAll(otherExtras);
      int resultLength = resultParams.size();
      String resultNames[] = new String[resultLength];
      for (int i=0; i<resultLength; i++) {
    resultNames[i] = (String)resultParams.elementAt(i);
      }

      Class resultClasses[] = new Class[resultLength];
      Object resultDefaults[] = new Object[resultLength];
      Object resultValidValues[] = new Object[resultLength];
      String name;
      int count;
      for (count=0; count<commonNames.size(); count++) {
    name = (String)commonNames.elementAt(count);
    resultClasses[count] = thisClasses[getIndex(thisHash, name)];
    resultDefaults[count] = thisDefaults[getIndex(thisHash, name)];
    resultValidValues[count] = pld.getParamValueRange(name);
      }
      for (int i=0; i<thisExtraLength; i++) {
    name = (String)thisExtras.elementAt(i);
    resultClasses[count+i] = thisClasses[getIndex(thisHash, name)];
    resultDefaults[count+i] = thisDefaults[getIndex(thisHash,
                name)];
    resultValidValues[count+i] = pld.getParamValueRange(name);
      }
      count += thisExtraLength;
      for (int i=0; i<otherExtraLength; i++) {
    name = (String)otherExtras.elementAt(i);
    resultClasses[i+count] = otherClasses[getIndex(otherHash,
                     name)];
    resultDefaults[i+count] = otherDefaults[getIndex(otherHash,
                 name)];
    resultValidValues[i+count] = otherPld.getParamValueRange(name);
      }

      ParameterListDescriptorImpl resultPLD =
    new ParameterListDescriptorImpl(null,
            resultNames,
            resultClasses,
            resultDefaults,
            resultValidValues);

      // Both NC's are preferences
      result = new NegotiableCapability(category,
                capabilityName,
                resultGenerators,
                resultPLD,
                true);

      for (int i=0; i<commonNames.size(); i++) {
    currParam = (String)commonNames.elementAt(i);
    thisValue = (Negotiable)getObjectParameter(currParam);
    otherValue =
        (Negotiable)capability.getObjectParameter(currParam);

    // If one of the values is null, select the other one, and
    // negotiation succeeds. Note that this also takes care
    // of the scenario when both are null, therefore the result
    // is null, and on a non-pref, this would have failed the
    // negotiation, but on a pref, it doesn't, so we just set
    // null (otherValue) as the result and allow negotiation to
    // succeed.
    if (thisValue == null) {
        result.setParameter(currParam, otherValue);
        continue;
    }

    if (otherValue == null) {
        result.setParameter(currParam, thisValue);
        continue;
    }

    // Following only gets executed if neither of the two is
    // a null, and therefore both have set values. If negotiation
    // fails, the negotiation as a whole is failed, otherwise
    // set the result on the resultant NC.
    resultValue = thisValue.negotiate(otherValue);
    if (resultValue == null) {
        return null;
    }

    result.setParameter(currParam, resultValue);
      }

      // Copy the extra ones directly into the result
      for (int i=0; i<thisExtraLength; i++) {
    currParam = (String)thisExtras.elementAt(i);
    result.setParameter(currParam,
            (Negotiable)getObjectParameter(currParam));
      }

      for (int i=0; i<otherExtraLength; i++) {
    currParam = (String)otherExtras.elementAt(i);
    result.setParameter(currParam,
       (Negotiable)capability.getObjectParameter(currParam));
      }

      break;

  case 1:

      // The given capability is a pref, while this is a non-pref
      commonNames = commonElements(thisHash, otherHash);
      commonHash = hashNames(commonNames);
      thisExtras = removeAll(thisHash, commonHash);

      // Create a new PLD which is the amalgamation of the two
      // NC's PLD's
      resultParams = new Vector(commonNames);
      resultParams.addAll(thisExtras);
      resultLength = resultParams.size();
      resultNames = new String[resultLength];
      for (int i=0; i<resultLength; i++) {
    resultNames[i] = (String)resultParams.elementAt(i);
      }

      resultClasses = new Class[resultLength];
      resultDefaults = new Object[resultLength];
      resultValidValues = new Object[resultLength];

      count = 0;
      for (count=0; count<commonNames.size(); count++) {
    name = (String)commonNames.elementAt(count);
    resultClasses[count] = thisClasses[getIndex(thisHash, name)];
    resultDefaults[count] = thisDefaults[getIndex(thisHash, name)];
    resultValidValues[count] = pld.getParamValueRange(name);
      }
      for (int i=0; i<thisExtras.size(); i++) {
    name = (String)thisExtras.elementAt(i);
    resultClasses[i+count] = thisClasses[getIndex(thisHash, name)];
    resultDefaults[i+count] = thisDefaults[getIndex(thisHash,
                name)];
    resultValidValues[i+count] = pld.getParamValueRange(name);
      }

      resultPLD = new ParameterListDescriptorImpl(null,
              resultNames,
              resultClasses,
              resultDefaults,
              resultValidValues);

      result = new NegotiableCapability(category,
                capabilityName,
                resultGenerators,
                resultPLD,
                false);

      for (int i=0; i<commonNames.size(); i++) {
    currParam = (String)commonNames.elementAt(i);
    thisValue = (Negotiable)getObjectParameter(currParam);
    otherValue =
        (Negotiable)capability.getObjectParameter(currParam);

    if (thisValue == null) {
        // If non-pref doesn't have value, negotiation fails right
        // away
        return null;
    }

    if (otherValue == null) {
        // If pref value is null, then non-pref's value wins.
        // This needs to be done separately, since
        // non-null.negotiate(null) returns null, which is *not*
        // what we want.
        result.setParameter(currParam, thisValue);
    } else {
        // Do the negotiation.
        resultValue = thisValue.negotiate(otherValue);

        if (resultValue == null) {
      // Negotiation on one parameter failed, so negotiation
      // on the entire NC has also failed, return null to
      // signify this
      return null;
        } else {
      result.setParameter(currParam, resultValue);
        }
    }
      }

      // Copy the extra ones directly into the result
      for (int i=0; i<thisExtras.size(); i++) {
    currParam = (String)thisExtras.elementAt(i);
    resultValue = (Negotiable)getObjectParameter(currParam);
    if (resultValue == null)
        return null;
    result.setParameter(currParam, resultValue);
      }

      break;

  case 2:

      // The given capability is a non-pref, while this is a pref
      commonNames = commonElements(thisHash, otherHash);
      commonHash = hashNames(commonNames);
      otherExtras = removeAll(otherHash, commonHash);

      // Create a new PLD which is the amalgamation of the two
      // NC's PLD's
      resultParams = new Vector(commonNames);
      resultParams.addAll(otherExtras);
      resultLength = resultParams.size();
      resultNames = new String[resultLength];
      for (int i=0; i<resultLength; i++) {
    resultNames[i] = (String)resultParams.elementAt(i);
      }

      resultClasses = new Class[resultLength];
      resultDefaults = new Object[resultLength];
      resultValidValues = new Object[resultLength];
      count = 0;
      for (count=0; count<commonNames.size(); count++) {
    name = (String)commonNames.elementAt(count);
    resultClasses[count] = thisClasses[getIndex(thisHash, name)];
    resultDefaults[count] = thisDefaults[getIndex(thisHash, name)];
    resultValidValues[count] = pld.getParamValueRange(name);
      }

      for (int i=0; i<otherExtras.size(); i++) {
    name = (String)otherExtras.elementAt(i);
    resultClasses[i+count] = otherClasses[getIndex(otherHash,
                     name)];
    resultDefaults[i+count] = otherDefaults[getIndex(otherHash,
                 name)];
    resultValidValues[i+count] = otherPld.getParamValueRange(name);
      }

      resultPLD = new ParameterListDescriptorImpl(null,
              resultNames,
              resultClasses,
View Full Code Here

  if (other == null) {
      throw new IllegalArgumentException(
          JaiI18N.getString("NegotiableCapability6"));
  }

  ParameterListDescriptor thisDesc = getParameterListDescriptor();
  ParameterListDescriptor otherDesc = other.getParameterListDescriptor();

  String thisNames[] = thisDesc.getParamNames();
        if (thisNames == null)
            thisNames = new String[0];
  String otherNames[] = otherDesc.getParamNames();
        if (otherNames == null)
            otherNames = new String[0];
  Hashtable thisHash = hashNames(thisNames);
  Hashtable otherHash = hashNames(otherNames);

  if (isPreference == false && other.isPreference() == false) {

      // The number of parameters must be the same.
      if (thisDesc.getNumParameters() != otherDesc.getNumParameters())
    return false;

      // The same names should be present in both in the same order.
      if (containsAll(thisHash, otherHash) == false)
    return false;

      Class thisParamClasses[] = thisDesc.getParamClasses();
      Class otherParamClasses[] = otherDesc.getParamClasses();
      for (int i=0; i<thisNames.length; i++) {
    if (thisParamClasses[i] !=
                    otherParamClasses[getIndex(otherHash, thisNames[i])])
        return false;
      }

      return true;

  } else {

      Vector commonNames = commonElements(thisHash, otherHash);

      Class thisParamClasses[] = thisDesc.getParamClasses();
      Class otherParamClasses[] = otherDesc.getParamClasses();
      String currName;
      for (int i=0; i<commonNames.size(); i++) {
    currName = (String)commonNames.elementAt(i);
    if (thisParamClasses[getIndex(thisHash, currName)] !=
        otherParamClasses[getIndex(otherHash, currName)])
View Full Code Here

  // If the supplied registryModeName is "remoteRendered" or
  // "remoteRenderable", in order to get the OperationDescriptor's
  // ParameterListDescriptor, we need to actually use the "rendered"
  // or "renderable" mode respectively.
  ParameterListDescriptor oldPLD = null;
  if (registryModeName.equalsIgnoreCase("remoteRendered")) {
      oldPLD = oldOD.getParameterListDescriptor("rendered");
  } else if (registryModeName.equalsIgnoreCase("remoteRenderable")) {
      oldPLD = oldOD.getParameterListDescriptor("renderable");
  } else {
      oldPLD = oldOD.getParameterListDescriptor(registryModeName);
  }

  int numParams = oldPLD.getNumParameters();

  // If the serverNames are same, nothing to be done for that
  if (oldServerName != newServerName) {

      // Check whether they both support the supplied operation name

      OperationDescriptor newDescs[] =
    getServerSupportedOperationList(newServerName);
      OperationDescriptor newOD;

      if ((newOD = getOperationDescriptor(newDescs,
            operationName)) == null)
    throw new IllegalArgumentException(
               JaiI18N.getString("JAIRMIDescriptor2"));

      // Check the OperationDescriptor equivalence

      // Sources
      if (numSources != newOD.getNumSources())
    throw new IllegalArgumentException(
               JaiI18N.getString("JAIRMIDescriptor3"));

      // Parameters
      ParameterListDescriptor newPLD =
    newOD.getParameterListDescriptor(registryModeName);

      if (numParams != newPLD.getNumParameters())
    throw new IllegalArgumentException(
              JaiI18N.getString("JAIRMIDescriptor4"));

      // Param names
      String oldParamNames[] = oldPLD.getParamNames();
      if (oldParamNames == null)
    oldParamNames = new String[0];
      String newParamNames[] = newPLD.getParamNames();
      if (newParamNames == null)
    newParamNames = new String[0];

      Hashtable oldHash = hashNames(oldParamNames);
      Hashtable newHash = hashNames(newParamNames);

      // The same names should be present in both in the same order.
            if (containsAll(oldHash, newHash) == false)
    throw new IllegalArgumentException(
               JaiI18N.getString("JAIRMIDescriptor8"));

      // Param class types
            Class thisParamClasses[] = oldPLD.getParamClasses();
            Class otherParamClasses[] = newPLD.getParamClasses();
            for (int i=0; i<oldParamNames.length; i++) {
                if (thisParamClasses[i] !=
                    otherParamClasses[getIndex(newHash, oldParamNames[i])])
                    throw new IllegalArgumentException(
               JaiI18N.getString("JAIRMIDescriptor9"));
View Full Code Here

TOP

Related Classes of com.lightcrafts.mediax.jai.ParameterListDescriptor

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.