Tabnine Logo
ColorPaletteDef$Point.getColor
Code IndexAdd Tabnine to your IDE (free)

How to use
getColor
method
in
org.esa.beam.framework.datamodel.ColorPaletteDef$Point

Best Java code snippets using org.esa.beam.framework.datamodel.ColorPaletteDef$Point.getColor (Showing top 19 results out of 315)

origin: bcdev/beam

public Color[] getColors() {
  final Color[] colors = new Color[points.size()];
  for (int i = 0; i < points.size(); i++) {
    colors[i] = points.get(i).getColor();
  }
  return colors;
}
origin: bcdev/beam

g2d.setPaint(slider.getColor());
g2d.fill(sliderShape);
int gray = (slider.getColor().getRed() + slider.getColor().getGreen() + slider.getColor().getBlue()) / 3;
g2d.setColor(gray < 128 ? c2 : c1);
g2d.draw(sliderShape);
origin: bcdev/beam

private TiffShort[] createColorMap(Product product) {
  final ImageInfo imageInfo = product.getBandAt(0).getImageInfo(null, ProgressMonitor.NULL);
  final ColorPaletteDef paletteDef = imageInfo.getColorPaletteDef();
  final TiffShort[] redColor = new TiffShort[TIFF_COLORMAP_SIZE];
  Arrays.fill(redColor, new TiffShort(0));
  final TiffShort[] greenColor = new TiffShort[TIFF_COLORMAP_SIZE];
  Arrays.fill(greenColor, new TiffShort(0));
  final TiffShort[] blueColor = new TiffShort[TIFF_COLORMAP_SIZE];
  Arrays.fill(blueColor, new TiffShort(0));
  final float factor = 65535.0f / 255.0f;
  for (ColorPaletteDef.Point point : paletteDef.getPoints()) {
    final Color color = point.getColor();
    final int red = (int) (color.getRed() * factor);
    final int green = (int) (color.getGreen() * factor);
    final int blue = (int) (color.getBlue() * factor);
    int mapIndex = (int) Math.floor(point.getSample());
    redColor[mapIndex] = new TiffShort(red);
    greenColor[mapIndex] = new TiffShort(green);
    blueColor[mapIndex] = new TiffShort(blue);
  }
  final TiffShort[] colorMap = new TiffShort[TIFF_COLORMAP_SIZE * 3];
  System.arraycopy(redColor, 0, colorMap, 0, redColor.length);
  System.arraycopy(greenColor, 0, colorMap, TIFF_COLORMAP_SIZE, greenColor.length);
  System.arraycopy(blueColor, 0, colorMap, TIFF_COLORMAP_SIZE * 2, blueColor.length);
  return colorMap;
}
origin: bcdev/beam

  return point.getLabel();
} else if (columnIndex == 1) {
  final Color color = point.getColor();
  return color.equals(ImageInfo.NO_COLOR) ? null : color;
} else if (columnIndex == 2) {
origin: bcdev/beam

JDomHelper.addElement(DimapProductConstants.TAG_SAMPLE, point.getSample(),
           colorPalettePointElem);
colorPalettePointElem.addContent(createColorElement(point.getColor()));
origin: bcdev/beam

  sXmlW.printLine(indent + 3, DimapProductConstants.TAG_LABEL, point.getLabel());
DimapProductHelpers.printColorTag(indent + 3, DimapProductConstants.TAG_COLOR, point.getColor(),
                 sXmlW);
sXmlW.println(cppTags[1]);
origin: bcdev/beam

assertEquals(+0.0, cpd.getPointAt(1).getSample(), 1e-10);
assertEquals(+1.0, cpd.getPointAt(2).getSample(), 1e-10);
assertEquals(Color.BLACK, cpd.getPointAt(0).getColor());
assertEquals(Color.GRAY, cpd.getPointAt(1).getColor());
assertEquals(Color.WHITE, cpd.getPointAt(2).getColor());
assertEquals(+0.5, cpd.getPointAt(1).getSample(), 1e-10);
assertEquals(+1.0, cpd.getPointAt(2).getSample(), 1e-10);
assertEquals(Color.BLACK, cpd.getPointAt(0).getColor());
assertEquals(Color.GRAY, cpd.getPointAt(1).getColor());
assertEquals(Color.WHITE, cpd.getPointAt(2).getColor());
origin: bcdev/beam

/**
 * creates a new point between the point at the given index
 *
 * @param index   the index
 * @param scaling the scaling
 *
 * @return true, if a point has been inserted
 */
public boolean createPointAfter(int index, Scaling scaling) {
  Point point1 = getPointAt(index);
  Point point2 = null;
  if (index < points.indexOf(points.lastElement())) {
    point2 = getPointAt(index + 1);
  }
  final Point newPoint;
  if (point2 != null) {
    final double max = Math.max(point1.getSample(), point2.getSample());
    final double min = Math.min(point1.getSample(), point2.getSample());
    final double middle;
    middle = scaling.scale(0.5 * (scaling.scaleInverse(min) + scaling.scaleInverse(max)));
    newPoint = new Point(middle, getCenterColor(point1.getColor(), point2.getColor()));
    insertPointAfter(index, newPoint);
    return true;
  }
  return false;
}
origin: bcdev/beam

private TiffShort[] createColorMap(Product product) {
  final ImageInfo imageInfo = product.getBandAt(0).getImageInfo(null, ProgressMonitor.NULL);
  final ColorPaletteDef paletteDef = imageInfo.getColorPaletteDef();
  final TiffShort[] redColor = new TiffShort[TIFF_COLORMAP_SIZE];
  Arrays.fill(redColor, new TiffShort(0));
  final TiffShort[] greenColor = new TiffShort[TIFF_COLORMAP_SIZE];
  Arrays.fill(greenColor, new TiffShort(0));
  final TiffShort[] blueColor = new TiffShort[TIFF_COLORMAP_SIZE];
  Arrays.fill(blueColor, new TiffShort(0));
  final float factor = 65535.0f / 255.0f;
  for (ColorPaletteDef.Point point : paletteDef.getPoints()) {
    final Color color = point.getColor();
    final int red = (int) (color.getRed() * factor);
    final int green = (int) (color.getGreen() * factor);
    final int blue = (int) (color.getBlue() * factor);
    int mapIndex = (int) Math.floor(point.getSample());
    redColor[mapIndex] = new TiffShort(red);
    greenColor[mapIndex] = new TiffShort(green);
    blueColor[mapIndex] = new TiffShort(blue);
  }
  final TiffShort[] colorMap = new TiffShort[TIFF_COLORMAP_SIZE * 3];
  System.arraycopy(redColor, 0, colorMap, 0, redColor.length);
  System.arraycopy(greenColor, 0, colorMap, TIFF_COLORMAP_SIZE, greenColor.length);
  System.arraycopy(blueColor, 0, colorMap, TIFF_COLORMAP_SIZE *2 , blueColor.length);
  return colorMap;
}
origin: bcdev/beam

private static void transferPoints(ColorPaletteDef sourceCPD,
                  double minSample,
                  double maxSample,
                  boolean autoDistribute,
                  ColorPaletteDef targetCPD) {
  if (autoDistribute || sourceCPD.isAutoDistribute()) {
    alignNumPoints(sourceCPD, targetCPD);
    double minDisplaySample = sourceCPD.getMinDisplaySample();
    double maxDisplaySample = sourceCPD.getMaxDisplaySample();
    double delta1 = (maxSample > minSample) ? maxSample - minSample : 1.0;
    double delta2 = (maxDisplaySample > minDisplaySample) ? maxDisplaySample - minDisplaySample : 1.0;
    double b = delta1 / delta2;
    double a = minSample - minDisplaySample * b;
    for (int i = 0; i < sourceCPD.getNumPoints(); i++) {
      targetCPD.getPointAt(i).setSample(a + b * sourceCPD.getPointAt(i).getSample());
      targetCPD.getPointAt(i).setColor(sourceCPD.getPointAt(i).getColor());
      targetCPD.getPointAt(i).setLabel(sourceCPD.getPointAt(i).getLabel());
    }
  } else {
    targetCPD.setPoints(sourceCPD.getPoints().clone());
  }
}
origin: bcdev/beam

public static Color computeColor(ImageInfo imageInfo, Double rasterValue) {
  final ColorPaletteDef cpd = imageInfo.getColorPaletteDef();
  if (rasterValue <= cpd.getMinDisplaySample()) {
    return cpd.getFirstPoint().getColor();
  } else if (rasterValue >= cpd.getMaxDisplaySample()) {
    return cpd.getLastPoint().getColor();
  } else {
    BorderSamplesAndColors boSaCo = new BorderSamplesAndColors();
    final boolean logScaled = imageInfo.isLogScaled();
    if (logScaled) {
      rasterValue = Stx.LOG10_SCALING.scale(rasterValue);
    }
    for (int i = 0; i < cpd.getNumPoints() - 1; i++) {
      boSaCo = getBorderSamplesAndColors(imageInfo, i, boSaCo);
      if (rasterValue >= boSaCo.sample1 && rasterValue <= boSaCo.sample2) {
        return computeColor(rasterValue, boSaCo);
      }
    }
  }
  return Color.black;
}
origin: bcdev/beam

private static BorderSamplesAndColors getBorderSamplesAndColors(ImageInfo imageInfo, int pointIdx, BorderSamplesAndColors boSaCo) {
  if (boSaCo == null) {
    boSaCo = new BorderSamplesAndColors();
  }
  final boolean logScaled = imageInfo.isLogScaled();
  final ColorPaletteDef cpd = imageInfo.getColorPaletteDef();
  final ColorPaletteDef.Point p1 = cpd.getPointAt(pointIdx);
  final ColorPaletteDef.Point p2 = cpd.getPointAt(pointIdx + 1);
  if (logScaled) {
    boSaCo.sample1 = getSampleLog(p1);
    boSaCo.sample2 = getSampleLog(p2);
  } else {
    boSaCo.sample1 = getSample(p1);
    boSaCo.sample2 = getSample(p2);
  }
  boSaCo.color1 = p1.getColor();
  boSaCo.color2 = p2.getColor();
  return boSaCo;
}
origin: bcdev/beam

/**
 * Stores this color palette definition in the given file
 *
 * @param colorPaletteDef thje color palette definition
 * @param file            the file
 *
 * @throws IOException if an I/O error occurs
 */
public static void storeColorPaletteDef(ColorPaletteDef colorPaletteDef, File file) throws IOException {
  final ColorPaletteDef.Point[] points = colorPaletteDef.getPoints();
  final PropertyMap propertyMap = new PropertyMap();
  final int numPoints = points.length;
  propertyMap.setPropertyInt(_PROPERTY_KEY_NUM_POINTS, numPoints);
  propertyMap.setPropertyBool(_PROPERTY_KEY_AUTODISTRIBUTE, colorPaletteDef.isAutoDistribute());
  for (int i = 0; i < numPoints; i++) {
    propertyMap.setPropertyColor(_PROPERTY_KEY_COLOR + i, points[i].getColor());
    propertyMap.setPropertyDouble(_PROPERTY_KEY_SAMPLE + i, points[i].getSample());
  }
  propertyMap.store(file, "BEAM Colour Palette Definition File"); /*I18N*/
}
origin: bcdev/beam

private Color computeColor(final double sample) {
  for (int i = 0; i < getNumPoints() - 1; i++) {
    final Point p1 = getPointAt(i);
    final Point p2 = getPointAt(i + 1);
    final double sample1 = p1.getSample();
    final double sample2 = p2.getSample();
    final Color color1 = p1.getColor();
    final Color color2 = p2.getColor();
    if (sample >= sample1 && sample <= sample2) {
      if (discrete) {
        return color1;
      } else {
        return computeColor(sample, sample1, sample2, color1, color2);
      }
    }
  }
  return Color.BLACK;
}
origin: bcdev/beam

private static void writeImageInfo(ColorPaletteDef.Point[] points, NVariable variable) throws IOException {
  final double[] sampleValues = new double[points.length];
  final int[] redValues = new int[points.length];
  final int[] greenValues = new int[points.length];
  final int[] blueValues = new int[points.length];
  for (int i = 0; i < points.length; i++) {
    ColorPaletteDef.Point point = points[i];
    sampleValues[i] = point.getSample();
    redValues[i] = point.getColor().getRed();
    greenValues[i] = point.getColor().getGreen();
    blueValues[i] = point.getColor().getBlue();
  }
  variable.addAttribute(COLOR_TABLE_SAMPLE_VALUES, Array.factory(sampleValues));
  variable.addAttribute(COLOR_TABLE_RED_VALUES, Array.factory(redValues));
  variable.addAttribute(COLOR_TABLE_GREEN_VALUES, Array.factory(greenValues));
  variable.addAttribute(COLOR_TABLE_BLUE_VALUES, Array.factory(blueValues));
}
origin: bcdev/beam

@Override
public Color getSliderColor(int index) {
  return getImageInfo().getColorPaletteDef().getPointAt(index).getColor();
}
origin: bcdev/beam

private Color computeColor(double sample, double minDisplay, double maxDisplay) {
  final Color c;
  if (sample <= minDisplay) {
    c = getFirstPoint().getColor();
  } else if (sample >= maxDisplay) {
    c = getLastPoint().getColor();
  } else {
    c = computeColor(sample);
  }
  return c;
}
origin: bcdev/beam

private void testPalette(ColorPaletteDef palette, Color[] colors) {
  assertEquals(colors.length, palette.getPoints().length);
  for (int i = 0; i < colors.length; i++) {
    assertEquals(colors[i], palette.getPointAt(i).getColor());
  }
}
origin: bcdev/beam

@Override
public Object getValueAt(int rowIndex, int columnIndex) {
  final ColorPaletteDef.Point point = getImageInfo().getColorPaletteDef().getPointAt(rowIndex);
  if (columnIndex == 0) {
    final Color color = point.getColor();
    return color.equals(ImageInfo.NO_COLOR) ? null : color;
  } else if (columnIndex == 1) {
    return point.getSample();
  }
  return null;
}
org.esa.beam.framework.datamodelColorPaletteDef$PointgetColor

Popular methods of ColorPaletteDef$Point

  • <init>
  • getSample
  • setColor
  • setSample
  • getLabel
  • setLabel
  • clone
  • createClone

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getContentResolver (Context)
  • setContentView (Activity)
  • notifyDataSetChanged (ArrayAdapter)
  • BufferedInputStream (java.io)
    A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the i
  • URLConnection (java.net)
    A connection to a URL for reading or writing. For HTTP connections, see HttpURLConnection for docume
  • Connection (java.sql)
    A connection represents a link from a Java application to a database. All SQL statements and results
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • HttpServlet (javax.servlet.http)
    Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A sub
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now