Ejemplo n.º 1
0
 /** Set RGB color to specified index */
 public void setRGB(int index, int rgb) {
   alpha.setValue(index, MAX_LEVEL);
   red.setValue(index, (rgb >> 16) & 0xFF);
   green.setValue(index, (rgb >> 8) & 0xFF);
   blue.setValue(index, (rgb >> 0) & 0xFF);
   gray.setValue(index, ColorUtil.getGrayMix(rgb));
 }
Ejemplo n.º 2
0
 /** Set ARGB color to specified index */
 public void setARGB(int index, int argb) {
   alpha.setValue(index, (argb >> 24) & 0xFF);
   red.setValue(index, (argb >> 16) & 0xFF);
   green.setValue(index, (argb >> 8) & 0xFF);
   blue.setValue(index, (argb >> 0) & 0xFF);
   gray.setValue(index, ColorUtil.getGrayMix(argb));
 }
Ejemplo n.º 3
0
 /** Set ARGB control point values to specified index */
 public void setARGBControlPoint(int index, Color value) {
   alpha.setControlPoint(index, (short) value.getAlpha());
   red.setControlPoint(index, (short) value.getRed());
   green.setControlPoint(index, (short) value.getGreen());
   blue.setControlPoint(index, (short) value.getBlue());
   gray.setControlPoint(index, (short) ColorUtil.getGrayMix(value));
 }
Ejemplo n.º 4
0
  /** @see icy.common.UpdateEventHandler#beginUpdate() */
  public void beginUpdate() {
    updater.beginUpdate();

    red.beginUpdate();
    green.beginUpdate();
    blue.beginUpdate();
    gray.beginUpdate();
    alpha.beginUpdate();
  }
Ejemplo n.º 5
0
  /** @see icy.common.UpdateEventHandler#endUpdate() */
  public void endUpdate() {
    alpha.endUpdate();
    gray.endUpdate();
    blue.endUpdate();
    green.endUpdate();
    red.endUpdate();

    updater.endUpdate();
  }
Ejemplo n.º 6
0
 /**
  * Return true is this is a linear type colormap.<br>
  * Linear colormap are used to display plain gray or color image.<br>
  * A non linear colormap means you usually have an indexed color image or you want to enhance
  * contrast/color in display.
  */
 public boolean isLinear() {
   switch (type) {
     default:
       return red.isLinear() && green.isLinear() && blue.isLinear();
     case GRAY:
       return gray.isLinear();
     case ALPHA:
       return alpha.isLinear();
   }
 }
Ejemplo n.º 7
0
  /**
   * Copy data from specified 2D short array.
   *
   * @param copyAlpha Also copy the alpha information.
   */
  public void copyFrom(short[][] maps, boolean copyAlpha) {
    final int len = maps.length;

    beginUpdate();
    try {
      // red component
      if (len > 0) red.copyFrom(maps[0], 8);
      if (len > 1) green.copyFrom(maps[1], 8);
      if (len > 2) blue.copyFrom(maps[2], 8);
      if (copyAlpha && (len > 3)) alpha.copyFrom(maps[3], 8);
    } finally {
      endUpdate();
    }
  }
Ejemplo n.º 8
0
 /**
  * Copy data from specified source colormap.
  *
  * @param copyAlpha Also copy the alpha information.
  */
 public void copyFrom(IcyColorMap srcColorMap, boolean copyAlpha) {
   beginUpdate();
   try {
     // copy colormap band
     red.copyFrom(srcColorMap.red);
     green.copyFrom(srcColorMap.green);
     blue.copyFrom(srcColorMap.blue);
     gray.copyFrom(srcColorMap.gray);
     if (copyAlpha) alpha.copyFrom(srcColorMap.alpha);
     // copy type
     setType(srcColorMap.type);
   } finally {
     endUpdate();
   }
 }
Ejemplo n.º 9
0
  /** @see IcyColorMap#setTypeFromData() */
  public void setTypeFromData(boolean notifyChange) {
    boolean grayColor = true;
    boolean noColor = true;
    boolean hasAlpha = false;
    IcyColorMapType cmType;

    for (int i = 0; i < MAX_INDEX; i++) {
      final short r = red.map[i];
      final short g = green.map[i];
      final short b = blue.map[i];
      final short a = alpha.map[i];

      grayColor &= (r == g) && (r == b);
      noColor &= (r == 0) && (g == 0) && (b == 0);
      hasAlpha |= (a != MAX_LEVEL);
    }

    if (noColor && hasAlpha) cmType = IcyColorMapType.ALPHA;
    else if (grayColor && !noColor) {
      // set gray map
      gray.copyFrom(red.map, 0);
      cmType = IcyColorMapType.GRAY;
    } else cmType = IcyColorMapType.RGB;

    if (notifyChange) setType(cmType);
    else type = cmType;
  }
Ejemplo n.º 10
0
  @Override
  public boolean saveToXML(Node node) {
    if (node == null) return false;

    XMLUtil.setElementValue(node, ID_NAME, getName());
    XMLUtil.setElementBooleanValue(node, ID_ENABLED, isEnabled());
    XMLUtil.setElementValue(node, ID_TYPE, getType().toString());

    boolean result = true;

    result = result && red.saveToXML(XMLUtil.setElement(node, ID_RED));
    result = result && green.saveToXML(XMLUtil.setElement(node, ID_GREEN));
    result = result && blue.saveToXML(XMLUtil.setElement(node, ID_BLUE));
    result = result && gray.saveToXML(XMLUtil.setElement(node, ID_GRAY));
    result = result && alpha.saveToXML(XMLUtil.setElement(node, ID_ALPHA));

    return result;
  }
Ejemplo n.º 11
0
  @Override
  public boolean loadFromXML(Node node) {
    if (node == null) return false;

    beginUpdate();
    try {
      setName(XMLUtil.getElementValue(node, ID_NAME, ""));
      setEnabled(XMLUtil.getElementBooleanValue(node, ID_ENABLED, true));
      setType(IcyColorMapType.valueOf(XMLUtil.getElementValue(node, ID_TYPE, "")));

      boolean result = true;

      result = result && red.loadFromXML(XMLUtil.getElement(node, ID_RED));
      result = result && green.loadFromXML(XMLUtil.getElement(node, ID_GREEN));
      result = result && blue.loadFromXML(XMLUtil.getElement(node, ID_BLUE));
      result = result && gray.loadFromXML(XMLUtil.getElement(node, ID_GRAY));
      result = result && alpha.loadFromXML(XMLUtil.getElement(node, ID_ALPHA));

      return result;
    } finally {
      endUpdate();
    }
  }
Ejemplo n.º 12
0
 /** Set green intensity (normalized) to specified index */
 public void setNormalizedGreen(int index, float value) {
   green.setNormalizedValue(index, value);
 }
Ejemplo n.º 13
0
 /** Set a green control point to specified index and value */
 public void setGreenControlPoint(int index, int value) {
   green.setControlPoint(index, value);
 }
Ejemplo n.º 14
0
 /** Set a gray control point to specified index and value */
 public void setGrayControlPoint(int index, int value) {
   gray.setControlPoint(index, value);
 }
Ejemplo n.º 15
0
 /** Set a blue control point to specified index and value */
 public void setBlueControlPoint(int index, int value) {
   blue.setControlPoint(index, value);
 }
Ejemplo n.º 16
0
 /** Set red intensity to specified index */
 public void setRed(int index, short value) {
   red.setValue(index, value);
 }
Ejemplo n.º 17
0
 /** Set a alpha control point to specified index and value */
 public void setAlphaControlPoint(int index, int value) {
   alpha.setControlPoint(index, value);
 }
Ejemplo n.º 18
0
 /** Set blue intensity to specified index */
 public void setBlue(int index, short value) {
   blue.setValue(index, value);
 }
Ejemplo n.º 19
0
 /** Set green intensity to specified index */
 public void setGreen(int index, short value) {
   green.setValue(index, value);
 }
Ejemplo n.º 20
0
 /** Set gray intensity (normalized) to specified index */
 public void setNormalizedGray(int index, float value) {
   gray.setNormalizedValue(index, value);
 }
Ejemplo n.º 21
0
 /** Set alpha intensity (normalized) to specified index */
 public void setNormalizedAlpha(int index, float value) {
   alpha.setNormalizedValue(index, value);
 }
Ejemplo n.º 22
0
 /** Set blue intensity (normalized) to specified index */
 public void setNormalizedBlue(int index, float value) {
   blue.setNormalizedValue(index, value);
 }
Ejemplo n.º 23
0
 /** Set a red control point to specified index and value */
 public void setRedControlPoint(int index, int value) {
   // set control point
   red.setControlPoint(index, value);
 }
Ejemplo n.º 24
0
 /** Set red intensity (normalized) to specified index */
 public void setNormalizedRed(int index, float value) {
   red.setNormalizedValue(index, value);
 }
Ejemplo n.º 25
0
 /** Set alpha intensity to specified index */
 public void setAlpha(int index, short value) {
   alpha.setValue(index, value);
 }
Ejemplo n.º 26
0
 /** Set gray intensity to specified index */
 public void setGray(int index, short value) {
   gray.setValue(index, value);
 }