public DefaultImageInfoEditorModel(ImageInfo imageInfo) { super(imageInfo); Assert.argument(imageInfo.getColorPaletteDef() != null, "imageInfo"); }
/** * Transfers the colour palette into this image info. * * @param colorPaletteDef another colour palette * @param minSample the minium allowed sample value in the new colour palette * @param maxSample the maximum allowed sample value in the new colour palette * @param autoDistribute if true, points are distributed between minSample/maxSample. */ public void setColorPaletteDef(ColorPaletteDef colorPaletteDef, double minSample, double maxSample, boolean autoDistribute) { transferPoints(colorPaletteDef, minSample, maxSample, autoDistribute, getColorPaletteDef()); }
@Override public int getSliderCount() { return getImageInfo().getColorPaletteDef().getNumPoints(); }
private ColorPaletteDef.Point getGradationCurvePointAt(int index) { return getImageInfo().getColorPaletteDef().getPointAt(index); }
@Override public void removeSlider(int index) { getImageInfo().getColorPaletteDef().removePointAt(index); fireStateChanged(); }
@Override public Color getSliderColor(int index) { return getImageInfo().getColorPaletteDef().getPointAt(index).getColor(); }
@Override public int getRowCount() { if (getImageInfo() == null) { return 0; } return getImageInfo().getColorPaletteDef().getNumPoints(); }
@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; }
public int getRowCount() { if (getImageInfo() == null) { return 0; } return getImageInfo().getColorPaletteDef().getNumPoints(); }
/** * Sets the colours of the colour palette of this image info. * * @param colors the new colours */ public void setColors(Color[] colors) { ColorPaletteDef cpd = getColorPaletteDef(); int numPoints = cpd.getNumPoints(); for (int i = 0; i < numPoints; i++) { ColorPaletteDef.Point point = cpd.getPointAt(i); point.setColor(colors[i % colors.length]); } }
@Override public double getSliderSample(int index) { return getImageInfo().getColorPaletteDef().getPointAt(index).getSample(); }
@Override public void updateFormModel(ProductSceneView productSceneView) { tableModel.fireTableDataChanged(); discreteCheckBox.setDiscreteColorsMode(parentForm.getImageInfo().getColorPaletteDef().isDiscrete()); }
@Override public void setSliderColor(int index, Color color) { getImageInfo().getColorPaletteDef().getPointAt(index).setColor(color); fireStateChanged(); }
@Override public void createSliderAfter(int index) { final boolean b = getImageInfo().getColorPaletteDef().createPointAfter(index, getSampleScaling()); if (b) { fireStateChanged(); } }
public void actionPerformed(ActionEvent e) { if (shouldFireDiscreteEvent) { parentForm.getImageInfo().getColorPaletteDef().setDiscrete(isSelected()); parentForm.applyChanges(); } } });
@Override public void setSliderSample(int index, double sample) { getImageInfo().getColorPaletteDef().getPointAt(index).setSample(sample); fireStateChanged(); }
@Override public void setValueAt(Object aValue, int rowIndex, int columnIndex) { final ColorPaletteDef.Point point = getImageInfo().getColorPaletteDef().getPointAt(rowIndex); if (columnIndex == 0) { final Color color = (Color) aValue; point.setColor(color == null ? ImageInfo.NO_COLOR : color); fireTableCellUpdated(rowIndex, columnIndex); } else if (columnIndex == 1) { point.setSample((Double) aValue); fireTableCellUpdated(rowIndex, columnIndex); } }
private void testIndexCoding(Band indexBand, final int expectedIndices) { assertTrue(indexBand.isIndexBand()); assertEquals(expectedIndices, indexBand.getIndexCoding().getNumAttributes()); final ColorPaletteDef paletteDef = indexBand.getImageInfo(ProgressMonitor.NULL).getColorPaletteDef(); assertEquals(expectedIndices, paletteDef.getNumColors()); final Color[] colors = paletteDef.getColors(); assertNotSame(0, colors[0].getRed() | colors[0].getGreen() | colors[0].getBlue()); assertNotSame(0, colors[1].getRed() | colors[1].getGreen() | colors[1].getBlue()); assertNotSame(0, colors[2].getRed() | colors[2].getGreen() | colors[2].getBlue()); assertNotSame(0, colors[3].getRed() | colors[3].getGreen() | colors[3].getBlue()); }
@Override public void preEncode(ProfileWriteContext ctx, Product p) throws IOException { NFileWriteable fileWriteable = ctx.getNetcdfFileWriteable(); for (Band band : p.getBands()) { ImageInfo imageInfo = band.getImageInfo(); if (imageInfo != null) { String variableName = ReaderUtils.getVariableName(band); NVariable variable = fileWriteable.findVariable(variableName); if (variable != null) { writeImageInfo(imageInfo.getColorPaletteDef().getPoints(), variable); } } } }
@Test public void testPreserveImageInfo() throws IOException { final Product product2 = ProductSubsetBuilder.createProductSubset(product, null, "subset", ""); final Band band = product2.getBand(INDEX_CODED_BAND_NAME); final Band band2 = product2.getBand(COLORED_BAND_NAME); assertNotNull(band); assertNotNull(band2); final ImageInfo imageInfo = band.getImageInfo(); final ImageInfo imageInfo2 = band2.getImageInfo(); assertNotNull(imageInfo); assertNotNull(imageInfo2); testPalette(imageInfo.getColorPaletteDef(), new Color[]{Color.red, Color.green}); testPalette(imageInfo2.getColorPaletteDef(), new Color[]{Color.blue, Color.black}); }