@Override
  public void updateOverlay(final F figure, final OverlayView view) {
    final Color strokeColor = figure.get(AttributeKeys.STROKE_COLOR);
    final Overlay overlay = view.getData();
    overlay.setLineColor(AWTColors.getColorRGB(strokeColor));
    // The line style is intentionally omitted here because it is ambiguous and
    // because there is no UI for setting it by the JHotDraw UI.

    // FIXME - is this next line dangerous for drawing attributes? width could
    // conceivably be 0.
    overlay.setLineWidth(figure.get(AttributeKeys.STROKE_WIDTH));
    final Color fillColor = figure.get(AttributeKeys.FILL_COLOR);
    overlay.setFillColor(AWTColors.getColorRGB(fillColor));
    overlay.setAlpha(fillColor.getAlpha());
  }
Example #2
0
 @Override
 public void run() {
   if (!threshSrv.hasThreshold(input)) {
     cancel("This command requires a thresholded image.");
     return;
   }
   ThresholdOverlay thresh = threshSrv.getThreshold(input);
   PointSetIterator iter = thresh.getPointsWithin().iterator();
   if (!iter.hasNext()) {
     cancel("No pixels are within the threshold");
     return;
   }
   Dataset ds = dispSrv.getActiveDataset(input);
   final int numDims = ds.numDimensions();
   final long[] dimensions = new long[numDims];
   final long[] min = new long[numDims];
   /*
    * First pass - find minima and maxima so we can use a shrunken image in some cases.
    */
   for (int i = 0; i < numDims; i++) {
     min[i] = (long) Math.floor(thresh.realMin(i));
     dimensions[i] = (long) Math.floor(thresh.realMax(i) - thresh.realMin(i) + 1);
   }
   final ArrayImg<BitType, BitArray> arrayMask =
       new ArrayImgFactory<BitType>().createBitInstance(dimensions, 1);
   final BitType t = new BitType(arrayMask);
   arrayMask.setLinkedType(t);
   final Img<BitType> mask =
       new ImgTranslationAdapter<BitType, ArrayImg<BitType, BitArray>>(arrayMask, min);
   final RandomAccess<BitType> raMask = mask.randomAccess();
   iter.reset();
   while (iter.hasNext()) {
     long[] pos = iter.next();
     raMask.setPosition(pos);
     raMask.get().set(true);
   }
   output =
       new BinaryMaskOverlay(context, new BinaryMaskRegionOfInterest<BitType, Img<BitType>>(mask));
   output.setAlpha(alpha);
   output.setFillColor(color);
   for (int i = 0; i < numDims; i++) {
     output.setAxis(ds.getImgPlus().axis(i), i);
   }
 }