sample = lastSample + 1.0; point.setColor(color); point.setSample(sample); points[i] = point;
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()); } }
@Override public void setValueAt(Object aValue, int rowIndex, int columnIndex) { if (getImageInfo() == null) { return; } final ColorPaletteDef.Point point = getImageInfo().getColorPaletteDef().getPointAt(rowIndex); if (columnIndex == 0) { point.setLabel((String) aValue); fireTableCellUpdated(rowIndex, columnIndex); parentForm.applyChanges(); } else if (columnIndex == 1) { final Color color = (Color) aValue; point.setColor(color == null ? ImageInfo.NO_COLOR : color); fireTableCellUpdated(rowIndex, columnIndex); parentForm.applyChanges(); } }
/** * 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 void setSliderColor(int index, Color color) { getImageInfo().getColorPaletteDef().getPointAt(index).setColor(color); 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); } }